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