1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
6 #include <rte_common.h>
8 #include "tf_global_cfg.h"
18 static void *global_cfg_db[TF_DIR_MAX];
21 * Init flag, set on bind and cleared on unbind
26 * Get HCAPI type parameters for a single element
28 struct tf_global_cfg_get_hcapi_parms {
30 * [in] Global Cfg DB Handle
34 * [in] DB Index, indicates which DB entry to perform the
39 * [out] Pointer to the hcapi type for the specified db_index
45 * Check global_cfg_type and return hwrm type.
47 * [in] global_cfg_type
51 * HWRM device data type
55 * -EOPNOTSUPP - Type not supported
58 tf_global_cfg_get_hcapi_type(struct tf_global_cfg_get_hcapi_parms *parms)
60 struct tf_global_cfg_cfg *global_cfg;
61 enum tf_global_cfg_cfg_type cfg_type;
63 global_cfg = (struct tf_global_cfg_cfg *)parms->global_cfg_db;
64 cfg_type = global_cfg[parms->db_index].cfg_type;
66 if (cfg_type != TF_GLOBAL_CFG_CFG_HCAPI)
69 *parms->hcapi_type = global_cfg[parms->db_index].hcapi_type;
75 tf_global_cfg_bind(struct tf *tfp __rte_unused,
76 struct tf_global_cfg_cfg_parms *parms)
78 TF_CHECK_PARMS2(tfp, parms);
82 "Global Cfg DB already initialized\n");
86 global_cfg_db[TF_DIR_RX] = parms->cfg;
87 global_cfg_db[TF_DIR_TX] = parms->cfg;
92 "Global Cfg - initialized\n");
98 tf_global_cfg_unbind(struct tf *tfp __rte_unused)
100 /* Bail if nothing has been initialized */
103 "No Global Cfg DBs created\n");
107 global_cfg_db[TF_DIR_RX] = NULL;
108 global_cfg_db[TF_DIR_TX] = NULL;
115 tf_global_cfg_set(struct tf *tfp,
116 struct tf_global_cfg_parms *parms)
119 struct tf_global_cfg_get_hcapi_parms hparms;
122 TF_CHECK_PARMS3(tfp, parms, parms->config);
126 "%s: No Global Cfg DBs created\n",
127 tf_dir_2_str(parms->dir));
131 /* Convert TF type to HCAPI type */
132 hparms.global_cfg_db = global_cfg_db[parms->dir];
133 hparms.db_index = parms->type;
134 hparms.hcapi_type = &hcapi_type;
135 rc = tf_global_cfg_get_hcapi_type(&hparms);
138 "%s, Failed type lookup, type:%d, rc:%s\n",
139 tf_dir_2_str(parms->dir),
145 rc = tf_msg_set_global_cfg(tfp, parms);
148 "%s, Set failed, type:%d, rc:%s\n",
149 tf_dir_2_str(parms->dir),
158 tf_global_cfg_get(struct tf *tfp,
159 struct tf_global_cfg_parms *parms)
163 struct tf_global_cfg_get_hcapi_parms hparms;
166 TF_CHECK_PARMS3(tfp, parms, parms->config);
170 "%s: No Global Cfg DBs created\n",
171 tf_dir_2_str(parms->dir));
175 hparms.global_cfg_db = global_cfg_db[parms->dir];
176 hparms.db_index = parms->type;
177 hparms.hcapi_type = &hcapi_type;
178 rc = tf_global_cfg_get_hcapi_type(&hparms);
181 "%s, Failed type lookup, type:%d, rc:%s\n",
182 tf_dir_2_str(parms->dir),
189 rc = tf_msg_get_global_cfg(tfp, parms);
192 "%s, Get failed, type:%d, rc:%s\n",
193 tf_dir_2_str(parms->dir),