1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2019-2020 Broadcom 3 * All rights reserved. 4 */ 5 6 #ifndef _BNXT_ULP_H_ 7 #define _BNXT_ULP_H_ 8 9 #include <inttypes.h> 10 #include <stdbool.h> 11 #include <sys/queue.h> 12 13 #include "rte_ethdev.h" 14 15 #include "ulp_template_db_enum.h" 16 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 20 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) 24 25 struct bnxt_ulp_df_rule_info { 26 uint32_t port_to_app_flow_id; 27 uint32_t app_to_port_flow_id; 28 uint8_t valid; 29 }; 30 31 struct bnxt_ulp_data { 32 uint32_t tbl_scope_id; 33 struct bnxt_ulp_mark_tbl *mark_tbl; 34 uint32_t dev_id; /* Hardware device id */ 35 uint32_t ref_cnt; 36 struct bnxt_ulp_flow_db *flow_db; 37 void *mapper_data; 38 struct bnxt_ulp_port_db *port_db; 39 struct bnxt_ulp_fc_info *fc_info; 40 uint32_t ulp_flags; 41 struct bnxt_ulp_df_rule_info df_rule_info[RTE_MAX_ETHPORTS]; 42 }; 43 44 struct bnxt_ulp_context { 45 struct bnxt_ulp_data *cfg_data; 46 /* TBD The tfp should be removed once tf_attach is implemented. */ 47 struct tf *g_tfp; 48 }; 49 50 struct bnxt_ulp_pci_info { 51 uint32_t domain; 52 uint8_t bus; 53 }; 54 55 struct bnxt_ulp_session_state { 56 STAILQ_ENTRY(bnxt_ulp_session_state) next; 57 bool bnxt_ulp_init; 58 pthread_mutex_t bnxt_ulp_mutex; 59 struct bnxt_ulp_pci_info pci_info; 60 struct bnxt_ulp_data *cfg_data; 61 /* TBD The tfp should be removed once tf_attach is implemented. */ 62 struct tf *g_tfp; 63 uint32_t session_opened; 64 }; 65 66 /* ULP flow id structure */ 67 struct rte_tf_flow { 68 uint32_t flow_id; 69 }; 70 71 struct ulp_tlv_param { 72 enum bnxt_ulp_df_param_type type; 73 uint32_t length; 74 uint8_t value[16]; 75 }; 76 77 /* 78 * Allow the deletion of context only for the bnxt device that 79 * created the session 80 * TBD - The implementation of the function should change to 81 * using the reference count once tf_session_attach functionality 82 * is fixed. 83 */ 84 bool 85 ulp_ctx_deinit_allowed(void *bp); 86 87 /* Function to set the device id of the hardware. */ 88 int32_t 89 bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx, uint32_t dev_id); 90 91 /* Function to get the device id of the hardware. */ 92 int32_t 93 bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx, uint32_t *dev_id); 94 95 /* Function to set the table scope id of the EEM table. */ 96 int32_t 97 bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx, 98 uint32_t tbl_scope_id); 99 100 /* Function to get the table scope id of the EEM table. */ 101 int32_t 102 bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx, 103 uint32_t *tbl_scope_id); 104 105 /* Function to set the tfp session details in the ulp context. */ 106 int32_t 107 bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp); 108 109 /* Function to get the tfp session details from ulp context. */ 110 struct tf * 111 bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp); 112 113 /* Get the device table entry based on the device id. */ 114 struct bnxt_ulp_device_params * 115 bnxt_ulp_device_params_get(uint32_t dev_id); 116 117 int32_t 118 bnxt_ulp_ctxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx, 119 struct bnxt_ulp_mark_tbl *mark_tbl); 120 121 struct bnxt_ulp_mark_tbl * 122 bnxt_ulp_ctxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx); 123 124 /* Function to set the flow database to the ulp context. */ 125 int32_t 126 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context *ulp_ctx, 127 struct bnxt_ulp_flow_db *flow_db); 128 129 /* Function to get the flow database from the ulp context. */ 130 struct bnxt_ulp_flow_db * 131 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context *ulp_ctx); 132 133 /* Function to get the ulp context from eth device. */ 134 struct bnxt_ulp_context * 135 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev); 136 137 /* Function to add the ulp mapper data to the ulp context */ 138 int32_t 139 bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx, 140 void *mapper_data); 141 142 /* Function to get the ulp mapper data from the ulp context */ 143 void * 144 bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx); 145 146 /* Function to set the port database to the ulp context. */ 147 int32_t 148 bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx, 149 struct bnxt_ulp_port_db *port_db); 150 151 /* Function to get the port database from the ulp context. */ 152 struct bnxt_ulp_port_db * 153 bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx); 154 155 /* Function to create default flows. */ 156 int32_t 157 ulp_default_flow_create(struct rte_eth_dev *eth_dev, 158 struct ulp_tlv_param *param_list, 159 uint32_t ulp_class_tid, 160 uint32_t *flow_id); 161 162 /* Function to destroy default flows. */ 163 int32_t 164 ulp_default_flow_destroy(struct rte_eth_dev *eth_dev, 165 uint32_t flow_id); 166 167 int 168 bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, 169 struct rte_flow_error *error); 170 171 int32_t 172 bnxt_ulp_cntxt_ptr2_fc_info_set(struct bnxt_ulp_context *ulp_ctx, 173 struct bnxt_ulp_fc_info *ulp_fc_info); 174 175 struct bnxt_ulp_fc_info * 176 bnxt_ulp_cntxt_ptr2_fc_info_get(struct bnxt_ulp_context *ulp_ctx); 177 178 int32_t 179 bnxt_ulp_cntxt_ptr2_ulp_flags_get(struct bnxt_ulp_context *ulp_ctx, 180 uint32_t *flags); 181 182 int32_t 183 bnxt_ulp_get_df_rule_info(uint8_t port_id, struct bnxt_ulp_context *ulp_ctx, 184 struct bnxt_ulp_df_rule_info *info); 185 186 #endif /* _BNXT_ULP_H_ */ 187