d2ca178575415c63d0939e02d565addf1c28c84b
[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 struct bnxt_ulp_data {
16         uint32_t                        tbl_scope_id;
17         struct bnxt_ulp_mark_tbl        *mark_tbl;
18         uint32_t                        dev_id; /* Hardware device id */
19         uint32_t                        ref_cnt;
20         struct bnxt_ulp_flow_db         *flow_db;
21         void                            *mapper_data;
22 };
23
24 struct bnxt_ulp_context {
25         struct bnxt_ulp_data    *cfg_data;
26         /* TBD The tfp should be removed once tf_attach is implemented. */
27         struct tf               *g_tfp;
28 };
29
30 struct bnxt_ulp_pci_info {
31         uint32_t        domain;
32         uint8_t         bus;
33 };
34
35 struct bnxt_ulp_session_state {
36         STAILQ_ENTRY(bnxt_ulp_session_state)    next;
37         bool                                    bnxt_ulp_init;
38         pthread_mutex_t                         bnxt_ulp_mutex;
39         struct bnxt_ulp_pci_info                pci_info;
40         struct bnxt_ulp_data                    *cfg_data;
41         /* TBD The tfp should be removed once tf_attach is implemented. */
42         struct tf                               *g_tfp;
43         uint32_t                                session_opened;
44 };
45
46 /* ULP flow id structure */
47 struct rte_tf_flow {
48         uint32_t        flow_id;
49 };
50
51 /*
52  * Allow the deletion of context only for the bnxt device that
53  * created the session
54  * TBD - The implementation of the function should change to
55  * using the reference count once tf_session_attach functionality
56  * is fixed.
57  */
58 bool
59 ulp_ctx_deinit_allowed(void *bp);
60
61 /* Function to set the device id of the hardware. */
62 int32_t
63 bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx, uint32_t dev_id);
64
65 /* Function to get the device id of the hardware. */
66 int32_t
67 bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx, uint32_t *dev_id);
68
69 /* Function to set the table scope id of the EEM table. */
70 int32_t
71 bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,
72                                 uint32_t tbl_scope_id);
73
74 /* Function to get the table scope id of the EEM table. */
75 int32_t
76 bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,
77                                 uint32_t *tbl_scope_id);
78
79 /* Function to set the tfp session details in the ulp context. */
80 int32_t
81 bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);
82
83 /* Function to get the tfp session details from ulp context. */
84 struct tf *
85 bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp);
86
87 /* Get the device table entry based on the device id. */
88 struct bnxt_ulp_device_params *
89 bnxt_ulp_device_params_get(uint32_t dev_id);
90
91 int32_t
92 bnxt_ulp_ctxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,
93                                struct bnxt_ulp_mark_tbl *mark_tbl);
94
95 struct bnxt_ulp_mark_tbl *
96 bnxt_ulp_ctxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);
97
98 /* Function to set the flow database to the ulp context. */
99 int32_t
100 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context *ulp_ctx,
101                                 struct bnxt_ulp_flow_db *flow_db);
102
103 /* Function to get the flow database from the ulp context. */
104 struct bnxt_ulp_flow_db *
105 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context *ulp_ctx);
106
107 /* Function to get the ulp context from eth device. */
108 struct bnxt_ulp_context *
109 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev);
110
111 /* Function to add the ulp mapper data to the ulp context */
112 int32_t
113 bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
114                                     void *mapper_data);
115
116 /* Function to get the ulp mapper data from the ulp context */
117 void *
118 bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);
119
120 #endif /* _BNXT_ULP_H_ */