xref: /dpdk/drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h (revision 80317ff6adfde7f618a100098e068ad5512e8e22)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2021 Broadcom
3  * All rights reserved.
4  */
5 
6 /*!
7  *   \file
8  *   \brief Exported functions for CFA HW programming
9  */
10 #ifndef _HCAPI_CFA_H_
11 #define _HCAPI_CFA_H_
12 
13 #include <stdio.h>
14 #include <string.h>
15 #include <stdbool.h>
16 #include <stdint.h>
17 #include <stddef.h>
18 #include <errno.h>
19 
20 #include "hcapi_cfa_defs.h"
21 
22 #define INVALID_U64 (0xFFFFFFFFFFFFFFFFULL)
23 #define INVALID_U32 (0xFFFFFFFFUL)
24 #define INVALID_U16 (0xFFFFUL)
25 #define INVALID_U8 (0xFFUL)
26 
27 struct hcapi_cfa_devops;
28 
29 /**
30  * CFA device information
31  */
32 struct hcapi_cfa_devinfo {
33 	/** [out] CFA device ops function pointer table */
34 	const struct hcapi_cfa_devops *devops;
35 };
36 
37 /**
38  *  \defgroup CFA_HCAPI_DEVICE_API
39  *  HCAPI used for writing to the hardware
40  *  @{
41  */
42 
43 /** CFA device specific function hooks structure
44  *
45  * The following device hooks can be defined; unless noted otherwise, they are
46  * optional and can be filled with a null pointer. The purpose of these hooks
47  * to support CFA device operations for different device variants.
48  */
49 struct hcapi_cfa_devops {
50 	/** calculate a key hash for the provided key_data
51 	 *
52 	 * This API computes hash for a key.
53 	 *
54 	 * @param[in] key_data
55 	 *   A pointer of the key data buffer
56 	 *
57 	 * @param[in] bitlen
58 	 *   Number of bits of the key data
59 	 *
60 	 * @return
61 	 *   0 for SUCCESS, negative value for FAILURE
62 	 */
63 	uint64_t (*hcapi_cfa_key_hash)(uint64_t *key_data, uint16_t bitlen);
64 
65 	/** hardware operation on the CFA EM key
66 	 *
67 	 * This API provides the functionality to program the exact match and
68 	 * key data to exact match record memory.
69 	 *
70 	 * @param[in] op
71 	 *   A pointer to the Hardware operation parameter
72 	 *
73 	 * @param[in] key_tbl
74 	 *   A pointer to the off-chip EM key table (applicable to EEM and
75 	 *   SR2 EM only), set to NULL for on-chip EM key table or WC
76 	 *   TCAM table.
77 	 *
78 	 * @param[in/out] key_obj
79 	 *   A pointer to the key data object for the hardware operation which
80 	 *   has the following contents:
81 	 *     1. key record memory offset (index to WC TCAM or EM key hash
82 	 *        value)
83 	 *     2. key data
84 	 *   When using the HWOP PUT, the key_obj holds the LREC and key to
85 	 *   be written.
86 	 *   When using the HWOP GET, the key_obj be populated with the LREC
87 	 *   and key which was specified by the key location object.
88 	 *
89 	 * @param[in/out] key_loc
90 	 *   When using the HWOP PUT, this is a pointer to the key location
91 	 *   data structure which holds the information of where the EM key
92 	 *   is stored.  It holds the bucket index and the data pointer of
93 	 *   a dynamic bucket that is chained to static bucket
94 	 *   When using the HWOP GET, this is a pointer to the key location
95 	 *   which should be retrieved.
96 	 *
97 	 *   (valid for SR2 only).
98 	 * @return
99 	 *   0 for SUCCESS, negative value for FAILURE
100 	 */
101 	int (*hcapi_cfa_key_hw_op)(struct hcapi_cfa_hwop *op,
102 				   struct hcapi_cfa_key_tbl *key_tbl,
103 				   struct hcapi_cfa_key_data *key_data,
104 				   struct hcapi_cfa_key_loc *key_loc);
105 };
106 
107 /*@}*/
108 
109 extern const size_t CFA_RM_HANDLE_DATA_SIZE;
110 
111 extern const struct hcapi_cfa_devops cfa_p4_devops;
112 extern const struct hcapi_cfa_devops cfa_p58_devops;
113 
114 #endif /* HCAPI_CFA_H_ */
115