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