net/bnxt: add default identifiers to ULP mapper
[dpdk.git] / drivers / net / bnxt / tf_ulp / ulp_mapper.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2019 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.h"
14 #include "ulp_template_struct.h"
15 #include "bnxt_ulp.h"
16 #include "ulp_utils.h"
17
18 #define ULP_SZ_BITS2BYTES(x) (((x) + 7) / 8)
19
20 struct bnxt_ulp_mapper_def_id_entry {
21         enum tf_identifier_type ident_type;
22         uint64_t ident;
23 };
24
25 struct bnxt_ulp_mapper_data {
26         struct bnxt_ulp_mapper_def_id_entry
27                 dflt_ids[TF_DIR_MAX][BNXT_ULP_DEF_IDENT_INFO_TBL_MAX_SZ];
28 };
29
30 /* Internal Structure for passing the arguments around */
31 struct bnxt_ulp_mapper_parms {
32         uint32_t                                dev_id;
33         enum bnxt_ulp_byte_order                order;
34         uint32_t                                act_tid;
35         struct bnxt_ulp_mapper_act_tbl_info     *atbls;
36         uint32_t                                num_atbls;
37         uint32_t                                class_tid;
38         struct bnxt_ulp_mapper_class_tbl_info   *ctbls;
39         uint32_t                                num_ctbls;
40         struct ulp_rte_act_prop                 *act_prop;
41         struct ulp_rte_act_bitmap               *act_bitmap;
42         struct ulp_rte_hdr_field                *hdr_field;
43         struct ulp_regfile                      *regfile;
44         struct tf                               *tfp;
45         struct bnxt_ulp_context                 *ulp_ctx;
46         uint8_t                                 encap_byte_swap;
47         uint32_t                                fid;
48         enum bnxt_ulp_flow_db_tables            tbl_idx;
49         struct bnxt_ulp_mapper_data             *mapper_data;
50 };
51
52 struct bnxt_ulp_mapper_create_parms {
53         uint32_t                        app_priority;
54         struct ulp_rte_hdr_bitmap       *hdr_bitmap;
55         struct ulp_rte_hdr_field        *hdr_field;
56         struct ulp_rte_act_bitmap       *act;
57         struct ulp_rte_act_prop         *act_prop;
58         uint32_t                        class_tid;
59         uint32_t                        act_tid;
60         uint16_t                        func_id;
61         enum ulp_direction_type         dir;
62 };
63
64 /* Function to initialize any dynamic mapper data. */
65 int32_t
66 ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx);
67
68 /* Function to release all dynamic mapper data. */
69 void
70 ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx);
71
72 /*
73  * Function to handle the mapping of the Flow to be compatible
74  * with the underlying hardware.
75  */
76 int32_t
77 ulp_mapper_flow_create(struct bnxt_ulp_context  *ulp_ctx,
78                        struct bnxt_ulp_mapper_create_parms *parms,
79                        uint32_t *flowid);
80
81 /* Function that frees all resources associated with the flow. */
82 int32_t
83 ulp_mapper_flow_destroy(struct bnxt_ulp_context *ulp_ctx, uint32_t fid);
84
85 /*
86  * Function that frees all resources and can be called on default or regular
87  * flows
88  */
89 int32_t
90 ulp_mapper_resources_free(struct bnxt_ulp_context       *ulp_ctx,
91                           uint32_t fid,
92                           enum bnxt_ulp_flow_db_tables  tbl_type);
93
94 #endif /* _ULP_MAPPER_H_ */