1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
11 #include <sys/queue.h>
13 #include "rte_ethdev.h"
15 #include "ulp_template_db_enum.h"
17 #include "bnxt_tf_common.h"
19 /* NAT defines to reuse existing inner L2 SMAC and DMAC */
20 #define BNXT_ULP_NAT_INNER_L2_HEADER_SMAC 0x2000
21 #define BNXT_ULP_NAT_OUTER_MOST_L2_HDR_SMAC 0x6000
22 #define BNXT_ULP_NAT_OUTER_MOST_L2_VLAN_TAGS 0xc00
23 #define BNXT_ULP_NAT_INNER_L2_HEADER_DMAC 0x100
24 #define BNXT_ULP_NAT_OUTER_MOST_L2_HDR_DMAC 0x300
25 #define BNXT_ULP_NAT_OUTER_MOST_FLAGS (BNXT_ULP_NAT_OUTER_MOST_L2_HDR_SMAC |\
26 BNXT_ULP_NAT_OUTER_MOST_L2_VLAN_TAGS |\
27 BNXT_ULP_NAT_OUTER_MOST_L2_HDR_DMAC)
29 /* defines for the ulp_flags */
30 #define BNXT_ULP_VF_REP_ENABLED 0x1
31 #define ULP_VF_REP_IS_ENABLED(flag) ((flag) & BNXT_ULP_VF_REP_ENABLED)
33 struct bnxt_ulp_df_rule_info {
34 uint32_t port_to_app_flow_id;
35 uint32_t app_to_port_flow_id;
39 struct bnxt_ulp_vfr_rule_info {
40 uint32_t rep2vf_flow_id;
41 uint32_t vf2rep_flow_id;
42 uint16_t parent_port_id;
46 struct bnxt_ulp_data {
47 uint32_t tbl_scope_id;
48 struct bnxt_ulp_mark_tbl *mark_tbl;
49 uint32_t dev_id; /* Hardware device id */
51 struct bnxt_ulp_flow_db *flow_db;
52 pthread_mutex_t flow_db_lock;
54 struct bnxt_ulp_port_db *port_db;
55 struct bnxt_ulp_fc_info *fc_info;
57 struct bnxt_ulp_df_rule_info df_rule_info[RTE_MAX_ETHPORTS];
58 struct bnxt_ulp_vfr_rule_info vfr_rule_info[RTE_MAX_ETHPORTS];
59 enum bnxt_ulp_flow_mem_type mem_type;
60 #define BNXT_ULP_TUN_ENTRY_INVALID -1
61 #define BNXT_ULP_MAX_TUN_CACHE_ENTRIES 16
62 struct bnxt_tun_cache_entry tun_tbl[BNXT_ULP_MAX_TUN_CACHE_ENTRIES];
65 struct bnxt_ulp_context {
66 struct bnxt_ulp_data *cfg_data;
70 struct bnxt_ulp_pci_info {
75 struct bnxt_ulp_session_state {
76 STAILQ_ENTRY(bnxt_ulp_session_state) next;
78 pthread_mutex_t bnxt_ulp_mutex;
79 struct bnxt_ulp_pci_info pci_info;
80 struct bnxt_ulp_data *cfg_data;
82 uint32_t session_opened;
85 /* ULP flow id structure */
90 struct ulp_tlv_param {
91 enum bnxt_ulp_df_param_type type;
97 * Allow the deletion of context only for the bnxt device that
101 ulp_ctx_deinit_allowed(struct bnxt_ulp_context *ulp_ctx);
103 /* Function to set the device id of the hardware. */
105 bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx, uint32_t dev_id);
107 /* Function to get the device id of the hardware. */
109 bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx, uint32_t *dev_id);
111 /* Function to get whether or not ext mem is used for EM */
113 bnxt_ulp_cntxt_mem_type_get(struct bnxt_ulp_context *ulp_ctx,
114 enum bnxt_ulp_flow_mem_type *mem_type);
116 /* Function to set whether or not ext mem is used for EM */
118 bnxt_ulp_cntxt_mem_type_set(struct bnxt_ulp_context *ulp_ctx,
119 enum bnxt_ulp_flow_mem_type mem_type);
121 /* Function to set the table scope id of the EEM table. */
123 bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,
124 uint32_t tbl_scope_id);
126 /* Function to get the table scope id of the EEM table. */
128 bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,
129 uint32_t *tbl_scope_id);
131 /* Function to set the tfp session details in the ulp context. */
133 bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);
135 /* Function to get the tfp session details from ulp context. */
137 bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp);
139 /* Get the device table entry based on the device id. */
140 struct bnxt_ulp_device_params *
141 bnxt_ulp_device_params_get(uint32_t dev_id);
144 bnxt_ulp_ctxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,
145 struct bnxt_ulp_mark_tbl *mark_tbl);
147 struct bnxt_ulp_mark_tbl *
148 bnxt_ulp_ctxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);
150 /* Function to set the flow database to the ulp context. */
152 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context *ulp_ctx,
153 struct bnxt_ulp_flow_db *flow_db);
155 /* Function to get the flow database from the ulp context. */
156 struct bnxt_ulp_flow_db *
157 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context *ulp_ctx);
159 /* Function to get the tunnel cache table info from the ulp context. */
160 struct bnxt_tun_cache_entry *
161 bnxt_ulp_cntxt_ptr2_tun_tbl_get(struct bnxt_ulp_context *ulp_ctx);
163 /* Function to get the ulp context from eth device. */
164 struct bnxt_ulp_context *
165 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev);
167 /* Function to add the ulp mapper data to the ulp context */
169 bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
172 /* Function to get the ulp mapper data from the ulp context */
174 bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);
176 /* Function to set the port database to the ulp context. */
178 bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx,
179 struct bnxt_ulp_port_db *port_db);
181 /* Function to get the port database from the ulp context. */
182 struct bnxt_ulp_port_db *
183 bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx);
185 /* Function to create default flows. */
187 ulp_default_flow_create(struct rte_eth_dev *eth_dev,
188 struct ulp_tlv_param *param_list,
189 uint32_t ulp_class_tid,
192 /* Function to destroy default flows. */
194 ulp_default_flow_destroy(struct rte_eth_dev *eth_dev,
198 bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
199 struct rte_flow_error *error);
202 bnxt_ulp_cntxt_ptr2_fc_info_set(struct bnxt_ulp_context *ulp_ctx,
203 struct bnxt_ulp_fc_info *ulp_fc_info);
205 struct bnxt_ulp_fc_info *
206 bnxt_ulp_cntxt_ptr2_fc_info_get(struct bnxt_ulp_context *ulp_ctx);
209 bnxt_ulp_cntxt_ptr2_ulp_flags_get(struct bnxt_ulp_context *ulp_ctx,
213 bnxt_ulp_get_df_rule_info(uint8_t port_id, struct bnxt_ulp_context *ulp_ctx,
214 struct bnxt_ulp_df_rule_info *info);
216 struct bnxt_ulp_vfr_rule_info*
217 bnxt_ulp_cntxt_ptr2_ulp_vfr_info_get(struct bnxt_ulp_context *ulp_ctx,
221 bnxt_ulp_cntxt_acquire_fdb_lock(struct bnxt_ulp_context *ulp_ctx);
224 bnxt_ulp_cntxt_release_fdb_lock(struct bnxt_ulp_context *ulp_ctx);
227 ulp_post_process_tun_flow(struct ulp_rte_parser_params *params);
229 #endif /* _BNXT_ULP_H_ */