1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
6 #include <rte_common.h>
20 static void *if_tbl_db[TF_DIR_MAX];
25 /* static void *shadow_if_tbl_db[TF_DIR_MAX]; */
28 * Init flag, set on bind and cleared on unbind
33 * Shadow init flag, set on bind and cleared on unbind
35 /* static uint8_t shadow_init; */
38 * Convert if_tbl_type to hwrm type.
41 * Interface table type
44 * HWRM device data type
48 * -EOPNOTSUPP - Type not supported
51 tf_if_tbl_get_hcapi_type(struct tf_if_tbl_get_hcapi_parms *parms)
53 struct tf_if_tbl_cfg *tbl_cfg;
54 enum tf_if_tbl_cfg_type cfg_type;
56 tbl_cfg = (struct tf_if_tbl_cfg *)parms->tbl_db;
57 cfg_type = tbl_cfg[parms->db_index].cfg_type;
59 if (cfg_type != TF_IF_TBL_CFG)
62 *parms->hcapi_type = tbl_cfg[parms->db_index].hcapi_type;
68 tf_if_tbl_bind(struct tf *tfp __rte_unused,
69 struct tf_if_tbl_cfg_parms *parms)
71 TF_CHECK_PARMS2(tfp, parms);
75 "IF TBL DB already initialized\n");
79 if_tbl_db[TF_DIR_RX] = parms->cfg;
80 if_tbl_db[TF_DIR_TX] = parms->cfg;
85 "Table Type - initialized\n");
91 tf_if_tbl_unbind(struct tf *tfp __rte_unused)
93 /* Bail if nothing has been initialized */
96 "No Table DBs created\n");
100 if_tbl_db[TF_DIR_RX] = NULL;
101 if_tbl_db[TF_DIR_TX] = NULL;
108 tf_if_tbl_set(struct tf *tfp,
109 struct tf_if_tbl_set_parms *parms)
112 struct tf_if_tbl_get_hcapi_parms hparms;
114 TF_CHECK_PARMS3(tfp, parms, parms->data);
118 "%s: No Table DBs created\n",
119 tf_dir_2_str(parms->dir));
123 /* Convert TF type to HCAPI type */
124 hparms.tbl_db = if_tbl_db[parms->dir];
125 hparms.db_index = parms->type;
126 hparms.hcapi_type = &parms->hcapi_type;
127 rc = tf_if_tbl_get_hcapi_type(&hparms);
131 rc = tf_msg_set_if_tbl_entry(tfp, parms);
134 "%s, If Tbl set failed, type:%d, rc:%s\n",
135 tf_dir_2_str(parms->dir),
144 tf_if_tbl_get(struct tf *tfp,
145 struct tf_if_tbl_get_parms *parms)
148 struct tf_if_tbl_get_hcapi_parms hparms;
150 TF_CHECK_PARMS3(tfp, parms, parms->data);
154 "%s: No Table DBs created\n",
155 tf_dir_2_str(parms->dir));
159 /* Convert TF type to HCAPI type */
160 hparms.tbl_db = if_tbl_db[parms->dir];
161 hparms.db_index = parms->type;
162 hparms.hcapi_type = &parms->hcapi_type;
163 rc = tf_if_tbl_get_hcapi_type(&hparms);
168 rc = tf_msg_get_if_tbl_entry(tfp, parms);
171 "%s, If Tbl get failed, type:%d, rc:%s\n",
172 tf_dir_2_str(parms->dir),