9696730cc215c60413997dd405417dc40d8c8c61
[dpdk.git] / drivers / net / bnxt / tf_ulp / ulp_mark_mgr.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2019 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _ULP_MARK_MGR_H_
7 #define _ULP_MARK_MGR_H_
8
9 #include "bnxt_ulp.h"
10
11 #define BNXT_ULP_MARK_VALID   0x1
12 #define BNXT_ULP_MARK_VFR_ID  0x2
13 #define BNXT_ULP_MARK_GLOBAL_HW_FID 0x4
14 #define BNXT_ULP_MARK_LOCAL_HW_FID 0x8
15
16 struct bnxt_lfid_mark_info {
17         uint16_t        mark_id;
18         uint16_t        flags;
19 };
20
21 struct bnxt_gfid_mark_info {
22         uint32_t        mark_id;
23         uint16_t        flags;
24 };
25
26 struct bnxt_ulp_mark_tbl {
27         struct bnxt_lfid_mark_info      *lfid_tbl;
28         struct bnxt_gfid_mark_info      *gfid_tbl;
29         uint32_t                        lfid_num_entries;
30         uint32_t                        gfid_num_entries;
31         uint32_t                        gfid_mask;
32         uint32_t                        gfid_type_bit;
33 };
34
35 /*
36  * Allocate and Initialize all Mark Manager resources for this ulp context.
37  *
38  * Initialize MARK database for GFID & LFID tables
39  * GFID: Global flow id which is based on EEM hash id.
40  * LFID: Local flow id which is the CFA action pointer.
41  * GFID is used for EEM flows, LFID is used for EM flows.
42  *
43  * Flow mapper modules adds mark_id in the MARK database.
44  *
45  * BNXT PMD receive handler extracts the hardware flow id from the
46  * received completion record. Fetches mark_id from the MARK
47  * database using the flow id. Injects mark_id into the packet's mbuf.
48  *
49  * ctxt [in] The ulp context for the mark manager.
50  */
51 int32_t
52 ulp_mark_db_init(struct bnxt_ulp_context *ctxt);
53
54 /*
55  * Release all resources in the Mark Manager for this ulp context
56  *
57  * ctxt [in] The ulp context for the mark manager
58  */
59 int32_t
60 ulp_mark_db_deinit(struct bnxt_ulp_context *ctxt);
61
62 /*
63  * Get a Mark from the Mark Manager
64  *
65  * ctxt [in] The ulp context for the mark manager
66  *
67  * is_gfid [in] The type of fid (GFID or LFID)
68  *
69  * fid [in] The flow id that is returned by HW in BD
70  *
71  * vfr_flag [out].it indicatesif mark is vfr_id or mark id
72  *
73  * mark [out] The mark that is associated with the FID
74  *
75  */
76 int32_t
77 ulp_mark_db_mark_get(struct bnxt_ulp_context *ctxt,
78                      bool is_gfid,
79                      uint32_t fid,
80                      uint32_t *vfr_flag,
81                      uint32_t *mark);
82
83 /*
84  * Adds a Mark to the Mark Manager
85  *
86  * ctxt [in] The ulp context for the mark manager
87  *
88  * mark_flag [in] mark flags.
89  *
90  * fid [in] The flow id that is returned by HW in BD
91  *
92  * mark [in] The mark to be associated with the FID
93  *
94  */
95 int32_t
96 ulp_mark_db_mark_add(struct bnxt_ulp_context *ctxt,
97                      uint32_t mark_flag,
98                      uint32_t gfid,
99                      uint32_t mark);
100
101 /*
102  * Removes a Mark from the Mark Manager
103  *
104  * ctxt [in] The ulp context for the mark manager
105  *
106  * mark_flag [in] mark flags
107  *
108  * fid [in] The flow id that is returned by HW in BD
109  *
110  */
111 int32_t
112 ulp_mark_db_mark_del(struct bnxt_ulp_context *ctxt,
113                      uint32_t mark_flag,
114                      uint32_t gfid);
115
116 #endif /* _ULP_MARK_MGR_H_ */