1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2019 Broadcom
11 #include <rte_flow_driver.h>
13 #include "ulp_template_db.h"
14 #include "ulp_template_struct.h"
16 #include "ulp_utils.h"
18 #define ULP_SZ_BITS2BYTES(x) (((x) + 7) / 8)
19 #define ULP_IDENTS_INVALID ((uint16_t)0xffff)
22 * The cache table opcode is used to convey informat from the cache handler
23 * to the tcam handler. The opcodes do the following:
24 * NORMAL - tcam should process all instructions as normal
25 * SKIP - tcam is using the cached entry and doesn't need to process the
27 * ALLOC - tcam needs to allocate the tcam index and store in the cache entry
29 enum bnxt_ulp_cache_table_opc {
30 BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL,
31 BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP,
32 BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC
35 struct bnxt_ulp_mapper_cache_entry {
38 uint16_t idents[BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM];
39 uint8_t ident_types[BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM];
42 struct bnxt_ulp_mapper_glb_resource_entry {
43 enum bnxt_ulp_resource_func resource_func;
44 uint32_t resource_type; /* TF_ enum type */
45 uint64_t resource_hndl;
48 struct bnxt_ulp_mapper_data {
49 struct bnxt_ulp_mapper_glb_resource_entry
50 glb_res_tbl[TF_DIR_MAX][BNXT_ULP_GLB_RESOURCE_INFO_TBL_MAX_SZ];
51 struct bnxt_ulp_mapper_cache_entry
52 *cache_tbl[BNXT_ULP_CACHE_TBL_MAX_SZ];
55 /* Internal Structure for passing the arguments around */
56 struct bnxt_ulp_mapper_parms {
58 enum bnxt_ulp_byte_order order;
60 struct bnxt_ulp_mapper_act_tbl_info *atbls;
63 struct bnxt_ulp_mapper_class_tbl_info *ctbls;
65 struct ulp_rte_act_prop *act_prop;
66 struct ulp_rte_act_bitmap *act_bitmap;
67 struct ulp_rte_hdr_field *hdr_field;
69 struct ulp_regfile *regfile;
71 struct bnxt_ulp_context *ulp_ctx;
72 uint8_t encap_byte_swap;
74 enum bnxt_ulp_flow_db_tables tbl_idx;
75 struct bnxt_ulp_mapper_data *mapper_data;
76 enum bnxt_ulp_cache_table_opc tcam_tbl_opc;
77 struct bnxt_ulp_mapper_cache_entry *cache_ptr;
80 struct bnxt_ulp_mapper_create_parms {
81 uint32_t app_priority;
82 struct ulp_rte_hdr_bitmap *hdr_bitmap;
83 struct ulp_rte_hdr_field *hdr_field;
85 struct ulp_rte_act_bitmap *act;
86 struct ulp_rte_act_prop *act_prop;
90 enum ulp_direction_type dir;
93 /* Function to initialize any dynamic mapper data. */
95 ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx);
97 /* Function to release all dynamic mapper data. */
99 ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx);
102 * Function to handle the mapping of the Flow to be compatible
103 * with the underlying hardware.
106 ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
107 struct bnxt_ulp_mapper_create_parms *parms,
110 /* Function that frees all resources associated with the flow. */
112 ulp_mapper_flow_destroy(struct bnxt_ulp_context *ulp_ctx, uint32_t fid);
115 * Function that frees all resources and can be called on default or regular
119 ulp_mapper_resources_free(struct bnxt_ulp_context *ulp_ctx,
121 enum bnxt_ulp_flow_db_tables tbl_type);
123 #endif /* _ULP_MAPPER_H_ */