1*2d9fd380Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause 2*2d9fd380Sjfb8856606 * Copyright(c) 2014-2019 Broadcom 3*2d9fd380Sjfb8856606 * All rights reserved. 4*2d9fd380Sjfb8856606 */ 5*2d9fd380Sjfb8856606 6*2d9fd380Sjfb8856606 #ifndef _ULP_MAPPER_H_ 7*2d9fd380Sjfb8856606 #define _ULP_MAPPER_H_ 8*2d9fd380Sjfb8856606 9*2d9fd380Sjfb8856606 #include <rte_log.h> 10*2d9fd380Sjfb8856606 #include <rte_flow.h> 11*2d9fd380Sjfb8856606 #include <rte_flow_driver.h> 12*2d9fd380Sjfb8856606 #include "tf_core.h" 13*2d9fd380Sjfb8856606 #include "ulp_template_db_enum.h" 14*2d9fd380Sjfb8856606 #include "ulp_template_struct.h" 15*2d9fd380Sjfb8856606 #include "bnxt_ulp.h" 16*2d9fd380Sjfb8856606 #include "ulp_utils.h" 17*2d9fd380Sjfb8856606 18*2d9fd380Sjfb8856606 #define ULP_IDENTS_INVALID ((uint16_t)0xffff) 19*2d9fd380Sjfb8856606 20*2d9fd380Sjfb8856606 /* 21*2d9fd380Sjfb8856606 * The cache table opcode is used to convey informat from the cache handler 22*2d9fd380Sjfb8856606 * to the tcam handler. The opcodes do the following: 23*2d9fd380Sjfb8856606 * NORMAL - tcam should process all instructions as normal 24*2d9fd380Sjfb8856606 * SKIP - tcam is using the cached entry and doesn't need to process the 25*2d9fd380Sjfb8856606 * instruction. 26*2d9fd380Sjfb8856606 * ALLOC - tcam needs to allocate the tcam index and store in the cache entry 27*2d9fd380Sjfb8856606 */ 28*2d9fd380Sjfb8856606 enum bnxt_ulp_cache_table_opc { 29*2d9fd380Sjfb8856606 BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL, 30*2d9fd380Sjfb8856606 BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP, 31*2d9fd380Sjfb8856606 BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC 32*2d9fd380Sjfb8856606 }; 33*2d9fd380Sjfb8856606 34*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_cache_entry { 35*2d9fd380Sjfb8856606 uint32_t ref_count; 36*2d9fd380Sjfb8856606 uint16_t tcam_idx; 37*2d9fd380Sjfb8856606 uint16_t idents[BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM]; 38*2d9fd380Sjfb8856606 uint8_t ident_types[BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM]; 39*2d9fd380Sjfb8856606 }; 40*2d9fd380Sjfb8856606 41*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_glb_resource_entry { 42*2d9fd380Sjfb8856606 enum bnxt_ulp_resource_func resource_func; 43*2d9fd380Sjfb8856606 uint32_t resource_type; /* TF_ enum type */ 44*2d9fd380Sjfb8856606 uint64_t resource_hndl; 45*2d9fd380Sjfb8856606 }; 46*2d9fd380Sjfb8856606 47*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_data { 48*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_glb_resource_entry 49*2d9fd380Sjfb8856606 glb_res_tbl[TF_DIR_MAX][BNXT_ULP_GLB_RESOURCE_TBL_MAX_SZ]; 50*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_cache_entry 51*2d9fd380Sjfb8856606 *cache_tbl[BNXT_ULP_CACHE_TBL_MAX_SZ]; 52*2d9fd380Sjfb8856606 }; 53*2d9fd380Sjfb8856606 54*2d9fd380Sjfb8856606 /* Internal Structure for passing the arguments around */ 55*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_parms { 56*2d9fd380Sjfb8856606 enum bnxt_ulp_template_type tmpl_type; 57*2d9fd380Sjfb8856606 uint32_t dev_id; 58*2d9fd380Sjfb8856606 uint32_t act_tid; 59*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_tbl_info *atbls; /* action table */ 60*2d9fd380Sjfb8856606 uint32_t num_atbls; 61*2d9fd380Sjfb8856606 uint32_t class_tid; 62*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_tbl_info *ctbls; /* class table */ 63*2d9fd380Sjfb8856606 uint32_t num_ctbls; 64*2d9fd380Sjfb8856606 struct ulp_rte_act_prop *act_prop; 65*2d9fd380Sjfb8856606 struct ulp_rte_act_bitmap *act_bitmap; 66*2d9fd380Sjfb8856606 struct ulp_rte_hdr_bitmap *hdr_bitmap; 67*2d9fd380Sjfb8856606 struct ulp_rte_hdr_field *hdr_field; 68*2d9fd380Sjfb8856606 uint32_t *comp_fld; 69*2d9fd380Sjfb8856606 struct ulp_regfile *regfile; 70*2d9fd380Sjfb8856606 struct tf *tfp; 71*2d9fd380Sjfb8856606 struct bnxt_ulp_context *ulp_ctx; 72*2d9fd380Sjfb8856606 uint8_t encap_byte_swap; 73*2d9fd380Sjfb8856606 uint32_t fid; 74*2d9fd380Sjfb8856606 enum bnxt_ulp_fdb_type flow_type; 75*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_data *mapper_data; 76*2d9fd380Sjfb8856606 enum bnxt_ulp_cache_table_opc tcam_tbl_opc; 77*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_cache_entry *cache_ptr; 78*2d9fd380Sjfb8856606 struct bnxt_ulp_device_params *device_params; 79*2d9fd380Sjfb8856606 uint32_t parent_fid; 80*2d9fd380Sjfb8856606 uint32_t parent_flow; 81*2d9fd380Sjfb8856606 uint8_t tun_idx; 82*2d9fd380Sjfb8856606 }; 83*2d9fd380Sjfb8856606 84*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_create_parms { 85*2d9fd380Sjfb8856606 uint32_t app_priority; 86*2d9fd380Sjfb8856606 struct ulp_rte_hdr_bitmap *hdr_bitmap; 87*2d9fd380Sjfb8856606 struct ulp_rte_hdr_field *hdr_field; 88*2d9fd380Sjfb8856606 uint32_t *comp_fld; 89*2d9fd380Sjfb8856606 struct ulp_rte_act_bitmap *act; 90*2d9fd380Sjfb8856606 struct ulp_rte_act_prop *act_prop; 91*2d9fd380Sjfb8856606 uint32_t class_tid; 92*2d9fd380Sjfb8856606 uint32_t act_tid; 93*2d9fd380Sjfb8856606 uint16_t func_id; 94*2d9fd380Sjfb8856606 uint32_t dir_attr; 95*2d9fd380Sjfb8856606 enum bnxt_ulp_fdb_type flow_type; 96*2d9fd380Sjfb8856606 97*2d9fd380Sjfb8856606 uint32_t flow_id; 98*2d9fd380Sjfb8856606 /* if set then create it as a child flow with parent as parent_fid */ 99*2d9fd380Sjfb8856606 uint32_t parent_fid; 100*2d9fd380Sjfb8856606 /* if set then create a parent flow */ 101*2d9fd380Sjfb8856606 uint32_t parent_flow; 102*2d9fd380Sjfb8856606 uint8_t tun_idx; 103*2d9fd380Sjfb8856606 }; 104*2d9fd380Sjfb8856606 105*2d9fd380Sjfb8856606 /* Function to initialize any dynamic mapper data. */ 106*2d9fd380Sjfb8856606 int32_t 107*2d9fd380Sjfb8856606 ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx); 108*2d9fd380Sjfb8856606 109*2d9fd380Sjfb8856606 /* Function to release all dynamic mapper data. */ 110*2d9fd380Sjfb8856606 void 111*2d9fd380Sjfb8856606 ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx); 112*2d9fd380Sjfb8856606 113*2d9fd380Sjfb8856606 /* 114*2d9fd380Sjfb8856606 * Function to handle the mapping of the Flow to be compatible 115*2d9fd380Sjfb8856606 * with the underlying hardware. 116*2d9fd380Sjfb8856606 */ 117*2d9fd380Sjfb8856606 int32_t 118*2d9fd380Sjfb8856606 ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx, 119*2d9fd380Sjfb8856606 struct bnxt_ulp_mapper_create_parms *parms); 120*2d9fd380Sjfb8856606 121*2d9fd380Sjfb8856606 /* Function that frees all resources associated with the flow. */ 122*2d9fd380Sjfb8856606 int32_t 123*2d9fd380Sjfb8856606 ulp_mapper_flow_destroy(struct bnxt_ulp_context *ulp_ctx, 124*2d9fd380Sjfb8856606 enum bnxt_ulp_fdb_type flow_type, 125*2d9fd380Sjfb8856606 uint32_t fid); 126*2d9fd380Sjfb8856606 127*2d9fd380Sjfb8856606 /* 128*2d9fd380Sjfb8856606 * Function that frees all resources and can be called on default or regular 129*2d9fd380Sjfb8856606 * flows 130*2d9fd380Sjfb8856606 */ 131*2d9fd380Sjfb8856606 int32_t 132*2d9fd380Sjfb8856606 ulp_mapper_resources_free(struct bnxt_ulp_context *ulp_ctx, 133*2d9fd380Sjfb8856606 enum bnxt_ulp_fdb_type flow_type, 134*2d9fd380Sjfb8856606 uint32_t fid); 135*2d9fd380Sjfb8856606 136*2d9fd380Sjfb8856606 #endif /* _ULP_MAPPER_H_ */ 137