d88225f2f25480277a9b6b7b4e6a93e283835719
[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 /* Function to set the device id of the hardware. */
51 int32_t
52 bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx, uint32_t dev_id);
53
54 /* Function to get the device id of the hardware. */
55 int32_t
56 bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx, uint32_t *dev_id);
57
58 /* Function to set the table scope id of the EEM table. */
59 int32_t
60 bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,
61                                 uint32_t tbl_scope_id);
62
63 /* Function to get the table scope id of the EEM table. */
64 int32_t
65 bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,
66                                 uint32_t *tbl_scope_id);
67
68 /* Function to set the tfp session details in the ulp context. */
69 int32_t
70 bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);
71
72 /* Function to get the tfp session details from ulp context. */
73 struct tf *
74 bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp);
75
76 /* Get the device table entry based on the device id. */
77 struct bnxt_ulp_device_params *
78 bnxt_ulp_device_params_get(uint32_t dev_id);
79
80 int32_t
81 bnxt_ulp_ctxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,
82                                struct bnxt_ulp_mark_tbl *mark_tbl);
83
84 struct bnxt_ulp_mark_tbl *
85 bnxt_ulp_ctxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);
86
87 /* Function to set the flow database to the ulp context. */
88 int32_t
89 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context *ulp_ctx,
90                                 struct bnxt_ulp_flow_db *flow_db);
91
92 /* Function to get the flow database from the ulp context. */
93 struct bnxt_ulp_flow_db *
94 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context *ulp_ctx);
95
96 /* Function to get the ulp context from eth device. */
97 struct bnxt_ulp_context *
98 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev);
99
100 #endif /* _BNXT_ULP_H_ */