xref: /dpdk/drivers/net/bnxt/tf_ulp/ulp_mapper.h (revision ba57777d)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2021 Broadcom
3  * All rights reserved.
4  */
5 
6 #ifndef _ULP_MAPPER_H_
7 #define _ULP_MAPPER_H_
8 
9 #include <rte_log.h>
10 #include <rte_flow.h>
11 #include <rte_flow_driver.h>
12 #include "tf_core.h"
13 #include "ulp_template_db_enum.h"
14 #include "ulp_template_struct.h"
15 #include "bnxt_ulp.h"
16 #include "ulp_utils.h"
17 #include "ulp_gen_tbl.h"
18 
19 #define ULP_IDENTS_INVALID ((uint16_t)0xffff)
20 
21 struct bnxt_ulp_mapper_glb_resource_entry {
22 	enum bnxt_ulp_resource_func	resource_func;
23 	uint32_t			resource_type; /* TF_ enum type */
24 	uint64_t			resource_hndl;
25 	bool				shared;
26 };
27 
28 struct bnxt_ulp_mapper_data {
29 	struct bnxt_ulp_mapper_glb_resource_entry
30 		glb_res_tbl[TF_DIR_MAX][BNXT_ULP_GLB_RF_IDX_LAST];
31 	struct ulp_mapper_gen_tbl_list gen_tbl_list[BNXT_ULP_GEN_TBL_MAX_SZ];
32 };
33 
34 /* Internal Structure for passing the arguments around */
35 struct bnxt_ulp_mapper_parms {
36 	enum bnxt_ulp_template_type		tmpl_type;
37 	uint32_t				dev_id;
38 	uint32_t				act_tid;
39 	struct bnxt_ulp_mapper_tbl_info		*atbls; /* action table */
40 	uint32_t				num_atbls;
41 	uint32_t				class_tid;
42 	struct bnxt_ulp_mapper_tbl_info		*ctbls; /* class table */
43 	uint32_t				num_ctbls;
44 	struct ulp_rte_act_prop			*act_prop;
45 	struct ulp_rte_act_bitmap		*act_bitmap;
46 	struct ulp_rte_hdr_bitmap		*hdr_bitmap;
47 	struct ulp_rte_hdr_field		*hdr_field;
48 	struct ulp_rte_field_bitmap		*fld_bitmap;
49 	uint64_t				*comp_fld;
50 	struct ulp_regfile			*regfile;
51 	struct bnxt_ulp_context			*ulp_ctx;
52 	uint32_t				fid;
53 	enum bnxt_ulp_fdb_type			flow_type;
54 	struct bnxt_ulp_mapper_data		*mapper_data;
55 	struct bnxt_ulp_device_params		*device_params;
56 	uint32_t				parent_fid;
57 	uint32_t				parent_flow;
58 	uint8_t					tun_idx;
59 	uint32_t				app_priority;
60 	uint64_t				shared_hndl;
61 	uint32_t				flow_pattern_id;
62 	uint32_t				act_pattern_id;
63 	uint8_t					app_id;
64 	uint16_t				port_id;
65 };
66 
67 struct bnxt_ulp_mapper_create_parms {
68 	uint32_t			app_priority;
69 	struct ulp_rte_hdr_bitmap	*hdr_bitmap;
70 	struct ulp_rte_hdr_field	*hdr_field;
71 	uint64_t			*comp_fld;
72 	struct ulp_rte_act_bitmap	*act;
73 	struct ulp_rte_act_prop		*act_prop;
74 	struct ulp_rte_field_bitmap	*fld_bitmap;
75 	uint32_t			class_tid;
76 	uint32_t			act_tid;
77 	uint16_t			func_id;
78 	uint32_t			dir_attr;
79 	enum bnxt_ulp_fdb_type		flow_type;
80 
81 	uint32_t			flow_id;
82 	/* if set then create it as a child flow with parent as parent_fid */
83 	uint32_t			parent_fid;
84 	/* if set then create a parent flow */
85 	uint32_t			parent_flow;
86 	uint8_t				tun_idx;
87 	uint64_t			shared_hndl;
88 
89 	/* support pattern based rejection */
90 	uint32_t			flow_pattern_id;
91 	uint32_t			act_pattern_id;
92 	uint8_t				app_id;
93 	uint16_t			port_id;
94 };
95 
96 /* Function to initialize any dynamic mapper data. */
97 int32_t
98 ulp_mapper_init(struct bnxt_ulp_context	*ulp_ctx);
99 
100 /* Function to release all dynamic mapper data. */
101 void
102 ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx);
103 
104 /*
105  * Function to handle the mapping of the Flow to be compatible
106  * with the underlying hardware.
107  */
108 int32_t
109 ulp_mapper_flow_create(struct bnxt_ulp_context	*ulp_ctx,
110 		       struct bnxt_ulp_mapper_create_parms *parms);
111 
112 /* Function that frees all resources associated with the flow. */
113 int32_t
114 ulp_mapper_flow_destroy(struct bnxt_ulp_context *ulp_ctx,
115 			enum bnxt_ulp_fdb_type flow_type,
116 			uint32_t fid);
117 
118 /*
119  * Function that frees all resources and can be called on default or regular
120  * flows
121  */
122 int32_t
123 ulp_mapper_resources_free(struct bnxt_ulp_context *ulp_ctx,
124 			  enum bnxt_ulp_fdb_type flow_type,
125 			  uint32_t fid);
126 
127 int32_t
128 ulp_mapper_get_shared_fid(struct bnxt_ulp_context *ulp,
129 			  uint32_t id,
130 			  uint16_t key,
131 			  uint32_t *fid);
132 
133 #endif /* _ULP_MAPPER_H_ */
134