1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
11 #include <sys/queue.h>
13 #include "rte_ethdev.h"
15 #include "ulp_template_db_enum.h"
17 /* NAT defines to reuse existing inner L2 SMAC and DMAC */
18 #define BNXT_ULP_NAT_INNER_L2_HEADER_SMAC 0x2000
19 #define BNXT_ULP_NAT_INNER_L2_HEADER_DMAC 0x100
21 /* defines for the ulp_flags */
22 #define BNXT_ULP_VF_REP_ENABLED 0x1
23 #define ULP_VF_REP_IS_ENABLED(flag) ((flag) & BNXT_ULP_VF_REP_ENABLED)
25 struct bnxt_ulp_df_rule_info {
26 uint32_t port_to_app_flow_id;
27 uint32_t app_to_port_flow_id;
31 struct bnxt_ulp_vfr_rule_info {
32 uint32_t rep2vf_flow_id;
33 uint32_t vf2rep_flow_id;
34 uint16_t parent_port_id;
38 struct bnxt_ulp_data {
39 uint32_t tbl_scope_id;
40 struct bnxt_ulp_mark_tbl *mark_tbl;
41 uint32_t dev_id; /* Hardware device id */
43 struct bnxt_ulp_flow_db *flow_db;
45 struct bnxt_ulp_port_db *port_db;
46 struct bnxt_ulp_fc_info *fc_info;
48 struct bnxt_ulp_df_rule_info df_rule_info[RTE_MAX_ETHPORTS];
49 struct bnxt_ulp_vfr_rule_info vfr_rule_info[RTE_MAX_ETHPORTS];
52 struct bnxt_ulp_context {
53 struct bnxt_ulp_data *cfg_data;
57 struct bnxt_ulp_pci_info {
62 struct bnxt_ulp_session_state {
63 STAILQ_ENTRY(bnxt_ulp_session_state) next;
65 pthread_mutex_t bnxt_ulp_mutex;
66 struct bnxt_ulp_pci_info pci_info;
67 struct bnxt_ulp_data *cfg_data;
69 uint32_t session_opened;
72 /* ULP flow id structure */
77 struct ulp_tlv_param {
78 enum bnxt_ulp_df_param_type type;
84 * Allow the deletion of context only for the bnxt device that
86 * TBD - The implementation of the function should change to
87 * using the reference count once tf_session_attach functionality
91 ulp_ctx_deinit_allowed(void *bp);
93 /* Function to set the device id of the hardware. */
95 bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx, uint32_t dev_id);
97 /* Function to get the device id of the hardware. */
99 bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx, uint32_t *dev_id);
101 /* Function to set the table scope id of the EEM table. */
103 bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,
104 uint32_t tbl_scope_id);
106 /* Function to get the table scope id of the EEM table. */
108 bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,
109 uint32_t *tbl_scope_id);
111 /* Function to set the tfp session details in the ulp context. */
113 bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);
115 /* Function to get the tfp session details from ulp context. */
117 bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp);
119 /* Get the device table entry based on the device id. */
120 struct bnxt_ulp_device_params *
121 bnxt_ulp_device_params_get(uint32_t dev_id);
124 bnxt_ulp_ctxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,
125 struct bnxt_ulp_mark_tbl *mark_tbl);
127 struct bnxt_ulp_mark_tbl *
128 bnxt_ulp_ctxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);
130 /* Function to set the flow database to the ulp context. */
132 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context *ulp_ctx,
133 struct bnxt_ulp_flow_db *flow_db);
135 /* Function to get the flow database from the ulp context. */
136 struct bnxt_ulp_flow_db *
137 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context *ulp_ctx);
139 /* Function to get the ulp context from eth device. */
140 struct bnxt_ulp_context *
141 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev);
143 /* Function to add the ulp mapper data to the ulp context */
145 bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
148 /* Function to get the ulp mapper data from the ulp context */
150 bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);
152 /* Function to set the port database to the ulp context. */
154 bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx,
155 struct bnxt_ulp_port_db *port_db);
157 /* Function to get the port database from the ulp context. */
158 struct bnxt_ulp_port_db *
159 bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx);
161 /* Function to create default flows. */
163 ulp_default_flow_create(struct rte_eth_dev *eth_dev,
164 struct ulp_tlv_param *param_list,
165 uint32_t ulp_class_tid,
168 /* Function to destroy default flows. */
170 ulp_default_flow_destroy(struct rte_eth_dev *eth_dev,
174 bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
175 struct rte_flow_error *error);
178 bnxt_ulp_cntxt_ptr2_fc_info_set(struct bnxt_ulp_context *ulp_ctx,
179 struct bnxt_ulp_fc_info *ulp_fc_info);
181 struct bnxt_ulp_fc_info *
182 bnxt_ulp_cntxt_ptr2_fc_info_get(struct bnxt_ulp_context *ulp_ctx);
185 bnxt_ulp_cntxt_ptr2_ulp_flags_get(struct bnxt_ulp_context *ulp_ctx,
189 bnxt_ulp_get_df_rule_info(uint8_t port_id, struct bnxt_ulp_context *ulp_ctx,
190 struct bnxt_ulp_df_rule_info *info);
192 struct bnxt_ulp_vfr_rule_info*
193 bnxt_ulp_cntxt_ptr2_ulp_vfr_info_get(struct bnxt_ulp_context *ulp_ctx,
196 #endif /* _BNXT_ULP_H_ */