685f38dc76b65e2a3e8bfa2f36c3c102921560f2
[dpdk.git] / drivers / net / bnxt / tf_core / tf_global_cfg.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef TF_GLOBAL_CFG_H_
7 #define TF_GLOBAL_CFG_H_
8
9 #include "tf_core.h"
10 #include "stack.h"
11
12 /**
13  * The global cfg module provides processing of global cfg types.
14  */
15
16 /* struct tf; */
17
18 /* Internal type not available to user
19  * but available internally within Truflow
20  */
21 enum tf_global_config_internal_type {
22         TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF = TF_GLOBAL_CFG_TYPE_MAX,
23         TF_GLOBAL_CFG_INTERNAL_TYPE_MAX
24 };
25
26 /**
27  * Global cfg configuration enumeration.
28  */
29 enum tf_global_cfg_cfg_type {
30         /**
31          * No configuration
32          */
33         TF_GLOBAL_CFG_CFG_NULL,
34         /**
35          * HCAPI 'controlled'
36          */
37         TF_GLOBAL_CFG_CFG_HCAPI,
38 };
39
40 /**
41  * Global cfg configuration structure, used by the Device to configure
42  * how an individual global cfg type is configured in regard to the HCAPI type.
43  */
44 struct tf_global_cfg_cfg {
45         /**
46          * Global cfg config controls how the DB for that element is
47          * processed.
48          */
49         enum tf_global_cfg_cfg_type cfg_type;
50
51         /**
52          * HCAPI Type for the element. Used for TF to HCAPI type
53          * conversion.
54          */
55         uint16_t hcapi_type;
56 };
57
58 /**
59  * Global Cfg configuration parameters
60  */
61 struct tf_global_cfg_cfg_parms {
62         /**
63          * Number of table types in the configuration array
64          */
65         uint16_t num_elements;
66         /**
67          * Table Type element configuration array
68          */
69         struct tf_global_cfg_cfg *cfg;
70 };
71
72 /**
73  * @page global cfg
74  *
75  * @ref tf_global_cfg_bind
76  *
77  * @ref tf_global_cfg_unbind
78  *
79  * @ref tf_global_cfg_set
80  *
81  * @ref tf_global_cfg_get
82  *
83  */
84 /**
85  * Initializes the Global Cfg module with the requested DBs. Must be
86  * invoked as the first thing before any of the access functions.
87  *
88  * [in] tfp
89  *   Pointer to TF handle
90  *
91  * [in] parms
92  *   Pointer to Global Cfg configuration parameters
93  *
94  * Returns
95  *   - (0) if successful.
96  *   - (-EINVAL) on failure.
97  */
98 int
99 tf_global_cfg_bind(struct tf *tfp,
100                    struct tf_global_cfg_cfg_parms *parms);
101
102 /**
103  * Cleans up the private DBs and releases all the data.
104  *
105  * [in] tfp
106  *   Pointer to TF handle
107  *
108  * [in] parms
109  *   Pointer to Global Cfg configuration parameters
110  *
111  * Returns
112  *   - (0) if successful.
113  *   - (-EINVAL) on failure.
114  */
115 int
116 tf_global_cfg_unbind(struct tf *tfp);
117
118 /**
119  * Updates the global configuration table
120  *
121  * [in] tfp
122  *   Pointer to TF handle, used for HCAPI communication
123  *
124  * [in] parms
125  *   Pointer to global cfg parameters
126  *
127  * Returns
128  *   - (0) if successful.
129  *   - (-EINVAL) on failure.
130  */
131 int tf_global_cfg_set(struct tf *tfp,
132                       struct tf_global_cfg_parms *parms);
133
134 /**
135  * Get global configuration
136  *
137  * [in] tfp
138  *   Pointer to TF handle, used for HCAPI communication
139  *
140  * [in] parms
141  *   Pointer to global cfg parameters
142  *
143  * Returns
144  *   - (0) if successful.
145  *   - (-EINVAL) on failure.
146  */
147 int tf_global_cfg_get(struct tf *tfp,
148                       struct tf_global_cfg_parms *parms);
149
150 #endif /* TF_GLOBAL_CFG_H */