4843da56226514eef5935a0deed4891e5217fd3d
[dpdk.git] / drivers / net / bnxt / tf_ulp / bnxt_ulp.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _BNXT_ULP_H_
7 #define _BNXT_ULP_H_
8
9 #include <inttypes.h>
10 #include <stdbool.h>
11 #include <sys/queue.h>
12
13 #include "rte_ethdev.h"
14
15 #include "ulp_template_db_enum.h"
16
17 struct bnxt_ulp_data {
18         uint32_t                        tbl_scope_id;
19         struct bnxt_ulp_mark_tbl        *mark_tbl;
20         uint32_t                        dev_id; /* Hardware device id */
21         uint32_t                        ref_cnt;
22         struct bnxt_ulp_flow_db         *flow_db;
23         void                            *mapper_data;
24         struct bnxt_ulp_port_db         *port_db;
25         uint32_t                        port_to_app_flow_id;
26         uint32_t                        app_to_port_flow_id;
27         uint32_t                        tx_cfa_action;
28 };
29
30 struct bnxt_ulp_context {
31         struct bnxt_ulp_data    *cfg_data;
32         /* TBD The tfp should be removed once tf_attach is implemented. */
33         struct tf               *g_tfp;
34 };
35
36 struct bnxt_ulp_pci_info {
37         uint32_t        domain;
38         uint8_t         bus;
39 };
40
41 struct bnxt_ulp_session_state {
42         STAILQ_ENTRY(bnxt_ulp_session_state)    next;
43         bool                                    bnxt_ulp_init;
44         pthread_mutex_t                         bnxt_ulp_mutex;
45         struct bnxt_ulp_pci_info                pci_info;
46         struct bnxt_ulp_data                    *cfg_data;
47         /* TBD The tfp should be removed once tf_attach is implemented. */
48         struct tf                               *g_tfp;
49         uint32_t                                session_opened;
50 };
51
52 /* ULP flow id structure */
53 struct rte_tf_flow {
54         uint32_t        flow_id;
55 };
56
57 struct ulp_tlv_param {
58         enum bnxt_ulp_df_param_type type;
59         uint32_t length;
60         uint8_t value[16];
61 };
62
63 /*
64  * Allow the deletion of context only for the bnxt device that
65  * created the session
66  * TBD - The implementation of the function should change to
67  * using the reference count once tf_session_attach functionality
68  * is fixed.
69  */
70 bool
71 ulp_ctx_deinit_allowed(void *bp);
72
73 /* Function to set the device id of the hardware. */
74 int32_t
75 bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx, uint32_t dev_id);
76
77 /* Function to get the device id of the hardware. */
78 int32_t
79 bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx, uint32_t *dev_id);
80
81 /* Function to set the table scope id of the EEM table. */
82 int32_t
83 bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,
84                                 uint32_t tbl_scope_id);
85
86 /* Function to get the table scope id of the EEM table. */
87 int32_t
88 bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,
89                                 uint32_t *tbl_scope_id);
90
91 /* Function to set the tfp session details in the ulp context. */
92 int32_t
93 bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);
94
95 /* Function to get the tfp session details from ulp context. */
96 struct tf *
97 bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp);
98
99 /* Get the device table entry based on the device id. */
100 struct bnxt_ulp_device_params *
101 bnxt_ulp_device_params_get(uint32_t dev_id);
102
103 int32_t
104 bnxt_ulp_ctxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,
105                                struct bnxt_ulp_mark_tbl *mark_tbl);
106
107 struct bnxt_ulp_mark_tbl *
108 bnxt_ulp_ctxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);
109
110 /* Function to set the flow database to the ulp context. */
111 int32_t
112 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context *ulp_ctx,
113                                 struct bnxt_ulp_flow_db *flow_db);
114
115 /* Function to get the flow database from the ulp context. */
116 struct bnxt_ulp_flow_db *
117 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context *ulp_ctx);
118
119 /* Function to get the ulp context from eth device. */
120 struct bnxt_ulp_context *
121 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev);
122
123 /* Function to add the ulp mapper data to the ulp context */
124 int32_t
125 bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
126                                     void *mapper_data);
127
128 /* Function to get the ulp mapper data from the ulp context */
129 void *
130 bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);
131
132 /* Function to set the port database to the ulp context. */
133 int32_t
134 bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx,
135                                 struct bnxt_ulp_port_db *port_db);
136
137 /* Function to get the port database from the ulp context. */
138 struct bnxt_ulp_port_db *
139 bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx);
140
141 /* Function to create default flows. */
142 int32_t
143 ulp_default_flow_create(struct rte_eth_dev *eth_dev,
144                         struct ulp_tlv_param *param_list,
145                         uint32_t ulp_class_tid,
146                         uint32_t *flow_id);
147
148 /* Function to destroy default flows. */
149 int32_t
150 ulp_default_flow_destroy(struct rte_eth_dev *eth_dev,
151                          uint32_t flow_id);
152
153 int
154 bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
155                       struct rte_flow_error *error);
156
157 #endif /* _BNXT_ULP_H_ */