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