net/bnxt: support ULP session manager init
[dpdk.git] / drivers / net / bnxt / tf_ulp / ulp_flow_db.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2019 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _ULP_FLOW_DB_H_
7 #define _ULP_FLOW_DB_H_
8
9 #include "bnxt_ulp.h"
10 #include "ulp_template_db.h"
11
12 #define BNXT_FLOW_DB_DEFAULT_NUM_FLOWS          128
13 #define BNXT_FLOW_DB_DEFAULT_NUM_RESOURCES      5
14
15 /* Structure for the flow database resource information. */
16 struct ulp_fdb_resource_info {
17         /* Points to next resource in the chained list. */
18         uint32_t        nxt_resource_idx;
19         union {
20                 uint64_t        resource_em_handle;
21                 struct {
22                         uint32_t        resource_type;
23                         uint32_t        resource_hndl;
24                 };
25         };
26 };
27
28 /* Structure for the flow database resource information. */
29 struct bnxt_ulp_flow_tbl {
30         /* Flow tbl is the resource object list for each flow id. */
31         struct ulp_fdb_resource_info    *flow_resources;
32
33         /* Flow table stack to track free list of resources. */
34         uint32_t        *flow_tbl_stack;
35         uint32_t        head_index;
36         uint32_t        tail_index;
37
38         /* Table to track the active flows. */
39         uint64_t        *active_flow_tbl;
40         uint32_t        num_flows;
41         uint32_t        num_resources;
42 };
43
44 /* Flow database supports two tables. */
45 enum bnxt_ulp_flow_db_tables {
46         BNXT_ULP_REGULAR_FLOW_TABLE,
47         BNXT_ULP_DEFAULT_FLOW_TABLE,
48         BNXT_ULP_FLOW_TABLE_MAX
49 };
50
51 /* Structure for the flow database resource information. */
52 struct bnxt_ulp_flow_db {
53         struct bnxt_ulp_flow_tbl        flow_tbl[BNXT_ULP_FLOW_TABLE_MAX];
54 };
55
56 /*
57  * Initialize the flow database. Memory is allocated in this
58  * call and assigned to the flow database.
59  *
60  * ulp_ctxt [in] Ptr to ulp context
61  *
62  * Returns 0 on success or negative number on failure.
63  */
64 int32_t ulp_flow_db_init(struct bnxt_ulp_context *ulp_ctxt);
65
66 /*
67  * Deinitialize the flow database. Memory is deallocated in
68  * this call and all flows should have been purged before this
69  * call.
70  *
71  * ulp_ctxt [in] Ptr to ulp context
72  *
73  * Returns 0 on success.
74  */
75 int32_t ulp_flow_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
76
77 #endif /* _ULP_FLOW_DB_H_ */