1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2014-2023 Broadcom 3 * All rights reserved. 4 */ 5 6 #ifndef _ULP_TEMPLATE_STRUCT_H_ 7 #define _ULP_TEMPLATE_STRUCT_H_ 8 9 #include <stdint.h> 10 #include "rte_ether.h" 11 #include "rte_icmp.h" 12 #include "rte_ip.h" 13 #include "rte_tcp.h" 14 #include "rte_udp.h" 15 #include "rte_esp.h" 16 #include "rte_sctp.h" 17 #include "rte_flow.h" 18 #include "tf_core.h" 19 20 /* Number of fields for each protocol */ 21 #define BNXT_ULP_PROTO_HDR_SVIF_NUM 2 22 #define BNXT_ULP_PROTO_HDR_ETH_NUM 3 23 #define BNXT_ULP_PROTO_HDR_S_VLAN_NUM 3 24 #define BNXT_ULP_PROTO_HDR_VLAN_NUM 6 25 #define BNXT_ULP_PROTO_HDR_IPV4_NUM 10 26 #define BNXT_ULP_PROTO_HDR_IPV6_NUM 8 27 #define BNXT_ULP_PROTO_HDR_UDP_NUM 4 28 #define BNXT_ULP_PROTO_HDR_TCP_NUM 9 29 #define BNXT_ULP_PROTO_HDR_VXLAN_NUM 4 30 #define BNXT_ULP_PROTO_HDR_GRE_NUM 2 31 #define BNXT_ULP_PROTO_HDR_ICMP_NUM 5 32 #define BNXT_ULP_PROTO_HDR_ECPRI_NUM 2 33 #define BNXT_ULP_PROTO_HDR_MAX 128 34 #define BNXT_ULP_PROTO_HDR_ENCAP_MAX 64 35 #define BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX 1 36 37 /* Direction attributes */ 38 #define BNXT_ULP_FLOW_ATTR_TRANSFER 0x1 39 #define BNXT_ULP_FLOW_ATTR_INGRESS 0x2 40 #define BNXT_ULP_FLOW_ATTR_EGRESS 0x4 41 42 struct ulp_rte_hdr_bitmap { 43 uint64_t bits; 44 }; 45 46 struct ulp_rte_field_bitmap { 47 uint64_t bits; 48 }; 49 50 /* Structure to store the protocol fields */ 51 #define RTE_PARSER_FLOW_HDR_FIELD_SIZE 16 52 struct ulp_rte_hdr_field { 53 uint8_t spec[RTE_PARSER_FLOW_HDR_FIELD_SIZE]; 54 uint8_t mask[RTE_PARSER_FLOW_HDR_FIELD_SIZE]; 55 uint32_t size; 56 }; 57 58 struct ulp_rte_act_bitmap { 59 uint64_t bits; 60 }; 61 62 /* Structure to hold the action property details. */ 63 struct ulp_rte_act_prop { 64 uint8_t act_details[BNXT_ULP_ACT_PROP_IDX_LAST]; 65 }; 66 67 /* Structure to be used for passing all the parser functions */ 68 struct ulp_rte_parser_params { 69 struct ulp_rte_hdr_bitmap hdr_bitmap; 70 struct ulp_rte_hdr_bitmap enc_hdr_bitmap; 71 struct ulp_rte_hdr_bitmap hdr_fp_bit; 72 struct ulp_rte_field_bitmap fld_bitmap; 73 struct ulp_rte_field_bitmap fld_s_bitmap; 74 struct ulp_rte_hdr_field hdr_field[BNXT_ULP_PROTO_HDR_MAX]; 75 struct ulp_rte_hdr_field enc_field[BNXT_ULP_PROTO_HDR_ENCAP_MAX]; 76 uint64_t comp_fld[BNXT_ULP_CF_IDX_LAST]; 77 uint32_t field_idx; 78 struct ulp_rte_act_bitmap act_bitmap; 79 struct ulp_rte_act_prop act_prop; 80 uint32_t dir_attr; 81 uint32_t priority; 82 uint32_t fid; 83 uint32_t parent_flow; 84 uint32_t child_flow; 85 uint16_t func_id; 86 uint16_t port_id; 87 uint32_t class_id; 88 uint32_t act_tmpl; 89 struct bnxt_ulp_context *ulp_ctx; 90 uint32_t hdr_sig_id; 91 uint64_t flow_sig_id; 92 uint32_t flow_pattern_id; 93 uint32_t act_pattern_id; 94 uint8_t app_id; 95 uint8_t tun_idx; 96 97 }; 98 99 /* Flow Parser Header Information Structure */ 100 struct bnxt_ulp_rte_hdr_info { 101 enum bnxt_ulp_hdr_type hdr_type; 102 /* Flow Parser Protocol Header Function Prototype */ 103 int (*proto_hdr_func)(const struct rte_flow_item *item_list, 104 struct ulp_rte_parser_params *params); 105 }; 106 107 /* Flow Parser Header Information Structure Array defined in template source*/ 108 extern struct bnxt_ulp_rte_hdr_info ulp_hdr_info[]; 109 extern struct bnxt_ulp_rte_hdr_info ulp_vendor_hdr_info[]; 110 111 /* Flow Parser Action Information Structure */ 112 struct bnxt_ulp_rte_act_info { 113 enum bnxt_ulp_act_type act_type; 114 /* Flow Parser Protocol Action Function Prototype */ 115 int32_t (*proto_act_func) 116 (const struct rte_flow_action *action_item, 117 struct ulp_rte_parser_params *params); 118 }; 119 120 /* Flow Parser Action Information Structure Array defined in template source*/ 121 extern struct bnxt_ulp_rte_act_info ulp_act_info[]; 122 extern struct bnxt_ulp_rte_act_info ulp_vendor_act_info[]; 123 124 /* Flow Matcher structures */ 125 struct bnxt_ulp_header_match_info { 126 struct ulp_rte_hdr_bitmap hdr_bitmap; 127 uint32_t start_idx; 128 uint32_t num_entries; 129 uint32_t class_tmpl_id; 130 uint32_t act_vnic; 131 }; 132 133 struct ulp_rte_bitmap { 134 uint64_t bits; 135 }; 136 137 struct bnxt_ulp_class_match_info { 138 struct ulp_rte_bitmap hdr_sig; 139 struct ulp_rte_bitmap field_sig; 140 uint32_t class_hid; 141 uint32_t class_tid; 142 uint8_t act_vnic; 143 uint8_t wc_pri; 144 uint8_t app_sig; 145 uint32_t hdr_sig_id; 146 uint64_t flow_sig_id; 147 uint32_t flow_pattern_id; 148 }; 149 150 /* Flow Matcher templates Structure for class entries */ 151 extern uint16_t ulp_class_sig_tbl[]; 152 extern struct bnxt_ulp_class_match_info ulp_class_match_list[]; 153 154 /* Flow Matcher Action structures */ 155 struct bnxt_ulp_action_match_info { 156 struct ulp_rte_act_bitmap act_bitmap; 157 uint32_t act_tmpl_id; 158 }; 159 160 struct bnxt_ulp_act_match_info { 161 struct ulp_rte_bitmap act_sig; 162 uint32_t act_hid; 163 uint32_t act_tid; 164 uint32_t act_pattern_id; 165 uint8_t app_sig; 166 }; 167 168 /* Flow Matcher templates Structure for action entries */ 169 extern uint16_t ulp_act_sig_tbl[]; 170 extern struct bnxt_ulp_act_match_info ulp_act_match_list[]; 171 172 /* Device Specific Tables for mapper */ 173 struct bnxt_ulp_mapper_cond_info { 174 enum bnxt_ulp_cond_opc cond_opcode; 175 uint64_t cond_operand; 176 }; 177 178 struct bnxt_ulp_mapper_cond_list_info { 179 enum bnxt_ulp_cond_list_opc cond_list_opcode; 180 uint32_t cond_start_idx; 181 uint32_t cond_nums; 182 int32_t cond_true_goto; 183 int32_t cond_false_goto; 184 }; 185 186 struct bnxt_ulp_mapper_func_info { 187 enum bnxt_ulp_func_opc func_opc; 188 enum bnxt_ulp_func_src func_src1; 189 enum bnxt_ulp_func_src func_src2; 190 uint16_t func_opr1; 191 uint16_t func_opr2; 192 uint16_t func_dst_opr; 193 }; 194 195 struct bnxt_ulp_template_device_tbls { 196 struct bnxt_ulp_mapper_tmpl_info *tmpl_list; 197 uint32_t tmpl_list_size; 198 struct bnxt_ulp_mapper_tbl_info *tbl_list; 199 uint32_t tbl_list_size; 200 struct bnxt_ulp_mapper_key_info *key_info_list; 201 uint32_t key_info_list_size; 202 struct bnxt_ulp_mapper_field_info *result_field_list; 203 uint32_t result_field_list_size; 204 struct bnxt_ulp_mapper_ident_info *ident_list; 205 uint32_t ident_list_size; 206 struct bnxt_ulp_mapper_cond_info *cond_list; 207 uint32_t cond_list_size; 208 }; 209 210 struct bnxt_ulp_dyn_size_map { 211 uint32_t slab_size; 212 enum tf_tbl_type tbl_type; 213 }; 214 215 /* Device specific parameters */ 216 struct bnxt_ulp_device_params { 217 uint8_t description[16]; 218 enum bnxt_ulp_byte_order key_byte_order; 219 enum bnxt_ulp_byte_order result_byte_order; 220 enum bnxt_ulp_byte_order encap_byte_order; 221 enum bnxt_ulp_byte_order wc_key_byte_order; 222 enum bnxt_ulp_byte_order em_byte_order; 223 uint8_t encap_byte_swap; 224 uint8_t num_phy_ports; 225 uint32_t mark_db_lfid_entries; 226 uint64_t mark_db_gfid_entries; 227 uint64_t int_flow_db_num_entries; 228 uint64_t ext_flow_db_num_entries; 229 uint32_t flow_count_db_entries; 230 uint32_t fdb_parent_flow_entries; 231 uint32_t num_resources_per_flow; 232 uint32_t ext_cntr_table_type; 233 uint64_t byte_count_mask; 234 uint64_t packet_count_mask; 235 uint32_t byte_count_shift; 236 uint32_t packet_count_shift; 237 uint32_t wc_dynamic_pad_en; 238 uint32_t em_dynamic_pad_en; 239 uint32_t dynamic_sram_en; 240 uint32_t dyn_encap_list_size; 241 struct bnxt_ulp_dyn_size_map dyn_encap_sizes[5]; 242 uint32_t dyn_modify_list_size; 243 struct bnxt_ulp_dyn_size_map dyn_modify_sizes[4]; 244 uint16_t em_blk_size_bits; 245 uint16_t em_blk_align_bits; 246 uint16_t em_key_align_bytes; 247 uint16_t em_result_size_bits; 248 uint16_t wc_slice_width; 249 uint16_t wc_max_slices; 250 uint32_t wc_mode_list[4]; 251 uint32_t wc_mod_list_max_size; 252 uint32_t wc_ctl_size_bits; 253 const struct bnxt_ulp_template_device_tbls *dev_tbls; 254 }; 255 256 /* Flow Mapper */ 257 struct bnxt_ulp_mapper_tmpl_info { 258 uint32_t device_name; 259 uint32_t start_tbl_idx; 260 uint32_t num_tbls; 261 struct bnxt_ulp_mapper_cond_list_info reject_info; 262 }; 263 264 struct bnxt_ulp_mapper_tbl_info { 265 enum bnxt_ulp_resource_func resource_func; 266 uint32_t resource_type; /* TF_ enum type */ 267 enum bnxt_ulp_resource_sub_type resource_sub_type; 268 struct bnxt_ulp_mapper_cond_list_info execute_info; 269 struct bnxt_ulp_mapper_func_info func_info; 270 enum bnxt_ulp_cond_opc cond_opcode; 271 uint32_t cond_operand; 272 uint8_t direction; 273 enum bnxt_ulp_pri_opc pri_opcode; 274 uint32_t pri_operand; 275 276 /* conflict resolution opcode */ 277 enum bnxt_ulp_accept_opc accept_opcode; 278 279 enum bnxt_ulp_critical_resource critical_resource; 280 281 /* Information for accessing the ulp_key_field_list */ 282 uint32_t key_start_idx; 283 uint16_t key_bit_size; 284 uint16_t key_num_fields; 285 /* Size of the blob that holds the key */ 286 uint16_t blob_key_bit_size; 287 uint16_t record_size; 288 289 /* Information for accessing the ulp_class_result_field_list */ 290 uint32_t result_start_idx; 291 uint16_t result_bit_size; 292 uint16_t result_num_fields; 293 uint16_t encap_num_fields; 294 295 /* Information for accessing the ulp_ident_list */ 296 uint32_t ident_start_idx; 297 uint16_t ident_nums; 298 299 enum bnxt_ulp_mark_db_opc mark_db_opcode; 300 301 /* Table opcode for table operations */ 302 uint32_t tbl_opcode; 303 uint32_t tbl_operand; 304 enum bnxt_ulp_generic_tbl_lkup_type gen_tbl_lkup_type; 305 306 /* FDB table opcode */ 307 enum bnxt_ulp_fdb_opc fdb_opcode; 308 uint32_t fdb_operand; 309 310 /* Manage ref_cnt via opcode for generic tables */ 311 enum bnxt_ulp_ref_cnt_opc ref_cnt_opcode; 312 313 /* Shared session */ 314 enum bnxt_ulp_session_type session_type; 315 }; 316 317 struct bnxt_ulp_mapper_field_info { 318 uint8_t description[64]; 319 uint16_t field_bit_size; 320 enum bnxt_ulp_field_opc field_opc; 321 enum bnxt_ulp_field_src field_src1; 322 uint8_t field_opr1[16]; 323 enum bnxt_ulp_field_src field_src2; 324 uint8_t field_opr2[16]; 325 enum bnxt_ulp_field_src field_src3; 326 uint8_t field_opr3[16]; 327 }; 328 329 struct bnxt_ulp_mapper_key_info { 330 struct bnxt_ulp_mapper_field_info field_info_spec; 331 struct bnxt_ulp_mapper_field_info field_info_mask; 332 }; 333 334 struct bnxt_ulp_mapper_ident_info { 335 uint8_t description[64]; 336 uint32_t resource_func; 337 338 uint16_t ident_type; 339 uint16_t ident_bit_size; 340 uint16_t ident_bit_pos; 341 enum bnxt_ulp_rf_idx regfile_idx; 342 }; 343 344 struct bnxt_ulp_glb_resource_info { 345 uint8_t app_id; 346 enum bnxt_ulp_device_id device_id; 347 enum tf_dir direction; 348 enum bnxt_ulp_session_type session_type; 349 enum bnxt_ulp_resource_func resource_func; 350 uint32_t resource_type; /* TF_ enum type */ 351 enum bnxt_ulp_glb_rf_idx glb_regfile_index; 352 }; 353 354 struct bnxt_ulp_resource_resv_info { 355 uint8_t app_id; 356 enum bnxt_ulp_device_id device_id; 357 enum tf_dir direction; 358 enum bnxt_ulp_session_type session_type; 359 enum bnxt_ulp_resource_func resource_func; 360 uint32_t resource_type; /* TF_ enum type */ 361 uint32_t count; 362 }; 363 364 struct bnxt_ulp_app_capabilities_info { 365 uint8_t app_id; 366 uint32_t vxlan_port; 367 uint32_t vxlan_ip_port; 368 uint32_t ecpri_udp_port; 369 enum bnxt_ulp_device_id device_id; 370 uint32_t upgrade_fw_update; 371 uint8_t ha_pool_id; 372 uint8_t ha_reg_state; 373 uint8_t ha_reg_cnt; 374 uint32_t flags; 375 }; 376 377 struct bnxt_ulp_cache_tbl_params { 378 uint16_t num_entries; 379 }; 380 381 struct bnxt_ulp_generic_tbl_params { 382 const char *name; 383 uint16_t result_num_entries; 384 uint16_t result_num_bytes; 385 enum bnxt_ulp_byte_order result_byte_order; 386 uint32_t hash_tbl_entries; 387 uint16_t num_buckets; 388 uint16_t key_num_bytes; 389 }; 390 391 struct bnxt_ulp_shared_act_info { 392 uint64_t act_bitmask; 393 }; 394 395 /* 396 * Flow Mapper Static Data Externs: 397 * Access to the below static data should be done through access functions and 398 * directly throughout the code. 399 */ 400 401 /* 402 * The ulp_device_params is indexed by the dev_id. 403 * This table maintains the device specific parameters. 404 */ 405 extern struct bnxt_ulp_device_params ulp_device_params[]; 406 407 /* 408 * The ulp_act_prop_map_table provides the mapping to index and size of action 409 * properties. 410 */ 411 extern uint32_t ulp_act_prop_map_table[]; 412 413 /* 414 * The ulp_glb_resource_tbl provides the list of global resources that need to 415 * be initialized and where to store them. 416 */ 417 extern struct bnxt_ulp_glb_resource_info ulp_glb_resource_tbl[]; 418 419 /* 420 * The ulp_app_glb_resource_tbl provides the list of shared resources required 421 * in the event that shared session is enabled. 422 */ 423 extern struct bnxt_ulp_glb_resource_info ulp_app_glb_resource_tbl[]; 424 425 /* 426 * The ulp_resource_resv_list provides the list of tf resources required when 427 * calling tf_open. 428 */ 429 extern struct bnxt_ulp_resource_resv_info ulp_resource_resv_list[]; 430 431 /* 432 * The ulp_app_resource_resv_list provides the list of tf resources required 433 * when calling tf_open. 434 */ 435 extern struct bnxt_ulp_resource_resv_info ulp_app_resource_resv_list[]; 436 437 /* 438 * The_app_cap_info_list provides the list of ULP capabilities per app/device. 439 */ 440 extern struct bnxt_ulp_app_capabilities_info ulp_app_cap_info_list[]; 441 442 /* 443 * The ulp_cache_tbl_parms table provides the sizes of the cache tables the 444 * mapper must dynamically allocate during initialization. 445 */ 446 extern struct bnxt_ulp_cache_tbl_params ulp_cache_tbl_params[]; 447 448 /* 449 * The ulp_generic_tbl_parms table provides the sizes of the generic tables the 450 * mapper must dynamically allocate during initialization. 451 */ 452 extern struct bnxt_ulp_generic_tbl_params ulp_generic_tbl_params[]; 453 /* 454 * The ulp_global template table is used to initialize default entries 455 * that could be reused by other templates. 456 */ 457 extern uint32_t ulp_glb_template_tbl[]; 458 #endif /* _ULP_TEMPLATE_STRUCT_H_ */ 459