8f0b894d3974086bd127dc30e7b7bdd569861d49
[dpdk.git] / drivers / net / bnxt / tf_ulp / ulp_mapper.h
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 };
26
27 struct bnxt_ulp_mapper_data {
28         struct bnxt_ulp_mapper_glb_resource_entry
29                 glb_res_tbl[TF_DIR_MAX][BNXT_ULP_GLB_RESOURCE_TBL_MAX_SZ];
30         struct ulp_mapper_gen_tbl_list gen_tbl_list[BNXT_ULP_GEN_TBL_MAX_SZ];
31 };
32
33 /* Internal Structure for passing the arguments around */
34 struct bnxt_ulp_mapper_parms {
35         enum bnxt_ulp_template_type             tmpl_type;
36         uint32_t                                dev_id;
37         uint32_t                                act_tid;
38         struct bnxt_ulp_mapper_tbl_info         *atbls; /* action table */
39         uint32_t                                num_atbls;
40         uint32_t                                class_tid;
41         struct bnxt_ulp_mapper_tbl_info         *ctbls; /* class table */
42         uint32_t                                num_ctbls;
43         struct ulp_rte_act_prop                 *act_prop;
44         struct ulp_rte_act_bitmap               *act_bitmap;
45         struct ulp_rte_hdr_bitmap               *hdr_bitmap;
46         struct ulp_rte_hdr_field                *hdr_field;
47         struct ulp_rte_field_bitmap             *fld_bitmap;
48         uint32_t                                *comp_fld;
49         struct ulp_regfile                      *regfile;
50         struct tf                               *tfp;
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 };
64
65 struct bnxt_ulp_mapper_create_parms {
66         uint32_t                        app_priority;
67         struct ulp_rte_hdr_bitmap       *hdr_bitmap;
68         struct ulp_rte_hdr_field        *hdr_field;
69         uint32_t                        *comp_fld;
70         struct ulp_rte_act_bitmap       *act;
71         struct ulp_rte_act_prop         *act_prop;
72         struct ulp_rte_field_bitmap     *fld_bitmap;
73         uint32_t                        class_tid;
74         uint32_t                        act_tid;
75         uint16_t                        func_id;
76         uint32_t                        dir_attr;
77         enum bnxt_ulp_fdb_type          flow_type;
78
79         uint32_t                        flow_id;
80         /* if set then create it as a child flow with parent as parent_fid */
81         uint32_t                        parent_fid;
82         /* if set then create a parent flow */
83         uint32_t                        parent_flow;
84         uint8_t                         tun_idx;
85
86         /* support pattern based rejection */
87         uint32_t                        flow_pattern_id;
88         uint32_t                        act_pattern_id;
89
90 };
91
92 /* Function to initialize any dynamic mapper data. */
93 int32_t
94 ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx);
95
96 /* Function to release all dynamic mapper data. */
97 void
98 ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx);
99
100 /*
101  * Function to handle the mapping of the Flow to be compatible
102  * with the underlying hardware.
103  */
104 int32_t
105 ulp_mapper_flow_create(struct bnxt_ulp_context  *ulp_ctx,
106                        struct bnxt_ulp_mapper_create_parms *parms);
107
108 /* Function that frees all resources associated with the flow. */
109 int32_t
110 ulp_mapper_flow_destroy(struct bnxt_ulp_context *ulp_ctx,
111                         enum bnxt_ulp_fdb_type flow_type,
112                         uint32_t fid);
113
114 /*
115  * Function that frees all resources and can be called on default or regular
116  * flows
117  */
118 int32_t
119 ulp_mapper_resources_free(struct bnxt_ulp_context *ulp_ctx,
120                           enum bnxt_ulp_fdb_type flow_type,
121                           uint32_t fid);
122
123 #endif /* _ULP_MAPPER_H_ */