Lines Matching refs:tbl

28 			action->dest_tbl->tbl->rx.s_anchor->chunk :
29 action->dest_tbl->tbl->tx.s_anchor->chunk;
46 int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
54 mlx5dr_domain_lock(tbl->dmn);
56 if (tbl->dmn->type == MLX5DR_DOMAIN_TYPE_NIC_RX ||
57 tbl->dmn->type == MLX5DR_DOMAIN_TYPE_FDB) {
58 ret = dr_table_set_miss_action_nic(tbl->dmn, &tbl->rx, action);
63 if (tbl->dmn->type == MLX5DR_DOMAIN_TYPE_NIC_TX ||
64 tbl->dmn->type == MLX5DR_DOMAIN_TYPE_FDB) {
65 ret = dr_table_set_miss_action_nic(tbl->dmn, &tbl->tx, action);
74 if (tbl->miss_action)
75 refcount_dec(&tbl->miss_action->refcount);
78 tbl->miss_action = action;
79 if (tbl->miss_action)
83 mlx5dr_domain_unlock(tbl->dmn);
92 static void dr_table_uninit_fdb(struct mlx5dr_table *tbl)
94 dr_table_uninit_nic(&tbl->rx);
95 dr_table_uninit_nic(&tbl->tx);
98 static void dr_table_uninit(struct mlx5dr_table *tbl)
100 mlx5dr_domain_lock(tbl->dmn);
102 switch (tbl->dmn->type) {
104 dr_table_uninit_nic(&tbl->rx);
107 dr_table_uninit_nic(&tbl->tx);
110 dr_table_uninit_fdb(tbl);
117 mlx5dr_domain_unlock(tbl->dmn);
159 static int dr_table_init_fdb(struct mlx5dr_table *tbl)
163 ret = dr_table_init_nic(tbl->dmn, &tbl->rx);
167 ret = dr_table_init_nic(tbl->dmn, &tbl->tx);
174 dr_table_uninit_nic(&tbl->rx);
178 static int dr_table_init(struct mlx5dr_table *tbl)
182 INIT_LIST_HEAD(&tbl->matcher_list);
184 mlx5dr_domain_lock(tbl->dmn);
186 switch (tbl->dmn->type) {
188 tbl->table_type = MLX5_FLOW_TABLE_TYPE_NIC_RX;
189 tbl->rx.nic_dmn = &tbl->dmn->info.rx;
190 ret = dr_table_init_nic(tbl->dmn, &tbl->rx);
193 tbl->table_type = MLX5_FLOW_TABLE_TYPE_NIC_TX;
194 tbl->tx.nic_dmn = &tbl->dmn->info.tx;
195 ret = dr_table_init_nic(tbl->dmn, &tbl->tx);
198 tbl->table_type = MLX5_FLOW_TABLE_TYPE_FDB;
199 tbl->rx.nic_dmn = &tbl->dmn->info.rx;
200 tbl->tx.nic_dmn = &tbl->dmn->info.tx;
201 ret = dr_table_init_fdb(tbl);
208 mlx5dr_domain_unlock(tbl->dmn);
213 static int dr_table_destroy_sw_owned_tbl(struct mlx5dr_table *tbl)
215 return mlx5dr_cmd_destroy_flow_table(tbl->dmn->mdev,
216 tbl->table_id,
217 tbl->table_type);
220 static int dr_table_create_sw_owned_tbl(struct mlx5dr_table *tbl, u16 uid)
222 bool en_encap = !!(tbl->flags & MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT);
223 bool en_decap = !!(tbl->flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP);
229 if (tbl->rx.s_anchor)
230 icm_addr_rx = mlx5dr_icm_pool_get_chunk_icm_addr(tbl->rx.s_anchor->chunk);
232 if (tbl->tx.s_anchor)
233 icm_addr_tx = mlx5dr_icm_pool_get_chunk_icm_addr(tbl->tx.s_anchor->chunk);
235 ft_attr.table_type = tbl->table_type;
238 ft_attr.level = tbl->dmn->info.caps.max_ft_level - 1;
244 ret = mlx5dr_cmd_create_flow_table(tbl->dmn->mdev, &ft_attr,
245 NULL, &tbl->table_id);
253 struct mlx5dr_table *tbl;
258 tbl = kzalloc(sizeof(*tbl), GFP_KERNEL);
259 if (!tbl)
262 tbl->dmn = dmn;
263 tbl->level = level;
264 tbl->flags = flags;
265 refcount_set(&tbl->refcount, 1);
267 ret = dr_table_init(tbl);
271 ret = dr_table_create_sw_owned_tbl(tbl, uid);
275 INIT_LIST_HEAD(&tbl->dbg_node);
276 mlx5dr_dbg_tbl_add(tbl);
277 return tbl;
280 dr_table_uninit(tbl);
282 kfree(tbl);
288 int mlx5dr_table_destroy(struct mlx5dr_table *tbl)
292 if (WARN_ON_ONCE(refcount_read(&tbl->refcount) > 1))
295 mlx5dr_dbg_tbl_del(tbl);
296 ret = dr_table_destroy_sw_owned_tbl(tbl);
298 mlx5dr_err(tbl->dmn, "Failed to destroy sw owned table\n");
300 dr_table_uninit(tbl);
302 if (tbl->miss_action)
303 refcount_dec(&tbl->miss_action->refcount);
305 refcount_dec(&tbl->dmn->refcount);
306 kfree(tbl);
311 u32 mlx5dr_table_get_id(struct mlx5dr_table *tbl)
313 return tbl->table_id;