Currently, the list memory was allocated by the list API caller.
Move it to be allocated by the create API in order to save consistence
with the hlist utility.
Signed-off-by: Matan Azrad <matan@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
#ifdef HAVE_IBV_FLOW_DV_SUPPORT
/* Init port id action list. */
snprintf(s, sizeof(s), "%s_port_id_action_list", sh->ibdev_name);
- mlx5_list_create(&sh->port_id_action_list, s, sh,
- flow_dv_port_id_create_cb,
- flow_dv_port_id_match_cb,
- flow_dv_port_id_remove_cb,
- flow_dv_port_id_clone_cb,
- flow_dv_port_id_clone_free_cb);
+ sh->port_id_action_list = mlx5_list_create(s, sh,
+ flow_dv_port_id_create_cb,
+ flow_dv_port_id_match_cb,
+ flow_dv_port_id_remove_cb,
+ flow_dv_port_id_clone_cb,
+ flow_dv_port_id_clone_free_cb);
+ if (!sh->port_id_action_list)
+ goto error;
/* Init push vlan action list. */
snprintf(s, sizeof(s), "%s_push_vlan_action_list", sh->ibdev_name);
- mlx5_list_create(&sh->push_vlan_action_list, s, sh,
- flow_dv_push_vlan_create_cb,
- flow_dv_push_vlan_match_cb,
- flow_dv_push_vlan_remove_cb,
- flow_dv_push_vlan_clone_cb,
- flow_dv_push_vlan_clone_free_cb);
+ sh->push_vlan_action_list = mlx5_list_create(s, sh,
+ flow_dv_push_vlan_create_cb,
+ flow_dv_push_vlan_match_cb,
+ flow_dv_push_vlan_remove_cb,
+ flow_dv_push_vlan_clone_cb,
+ flow_dv_push_vlan_clone_free_cb);
+ if (!sh->push_vlan_action_list)
+ goto error;
/* Init sample action list. */
snprintf(s, sizeof(s), "%s_sample_action_list", sh->ibdev_name);
- mlx5_list_create(&sh->sample_action_list, s, sh,
- flow_dv_sample_create_cb,
- flow_dv_sample_match_cb,
- flow_dv_sample_remove_cb,
- flow_dv_sample_clone_cb,
- flow_dv_sample_clone_free_cb);
+ sh->sample_action_list = mlx5_list_create(s, sh,
+ flow_dv_sample_create_cb,
+ flow_dv_sample_match_cb,
+ flow_dv_sample_remove_cb,
+ flow_dv_sample_clone_cb,
+ flow_dv_sample_clone_free_cb);
+ if (!sh->sample_action_list)
+ goto error;
/* Init dest array action list. */
snprintf(s, sizeof(s), "%s_dest_array_list", sh->ibdev_name);
- mlx5_list_create(&sh->dest_array_list, s, sh,
- flow_dv_dest_array_create_cb,
- flow_dv_dest_array_match_cb,
- flow_dv_dest_array_remove_cb,
- flow_dv_dest_array_clone_cb,
- flow_dv_dest_array_clone_free_cb);
+ sh->dest_array_list = mlx5_list_create(s, sh,
+ flow_dv_dest_array_create_cb,
+ flow_dv_dest_array_match_cb,
+ flow_dv_dest_array_remove_cb,
+ flow_dv_dest_array_clone_cb,
+ flow_dv_dest_array_clone_free_cb);
+ if (!sh->dest_array_list)
+ goto error;
/* Create tags hash list table. */
snprintf(s, sizeof(s), "%s_tags", sh->ibdev_name);
sh->tag_table = mlx5_hlist_create(s, MLX5_TAGS_HLIST_ARRAY_SIZE, 0,
sh->tunnel_hub = NULL;
}
mlx5_free_table_hash_list(priv);
+ if (sh->port_id_action_list) {
+ mlx5_list_destroy(sh->port_id_action_list);
+ sh->port_id_action_list = NULL;
+ }
+ if (sh->push_vlan_action_list) {
+ mlx5_list_destroy(sh->push_vlan_action_list);
+ sh->push_vlan_action_list = NULL;
+ }
+ if (sh->sample_action_list) {
+ mlx5_list_destroy(sh->sample_action_list);
+ sh->sample_action_list = NULL;
+ }
+ if (sh->dest_array_list) {
+ mlx5_list_destroy(sh->dest_array_list);
+ sh->dest_array_list = NULL;
+ }
return err;
}
mlx5_release_tunnel_hub(sh, priv->dev_port);
sh->tunnel_hub = NULL;
}
- mlx5_list_destroy(&sh->port_id_action_list);
- mlx5_list_destroy(&sh->push_vlan_action_list);
mlx5_free_table_hash_list(priv);
+ if (sh->port_id_action_list) {
+ mlx5_list_destroy(sh->port_id_action_list);
+ sh->port_id_action_list = NULL;
+ }
+ if (sh->push_vlan_action_list) {
+ mlx5_list_destroy(sh->push_vlan_action_list);
+ sh->push_vlan_action_list = NULL;
+ }
+ if (sh->sample_action_list) {
+ mlx5_list_destroy(sh->sample_action_list);
+ sh->sample_action_list = NULL;
+ }
+ if (sh->dest_array_list) {
+ mlx5_list_destroy(sh->dest_array_list);
+ sh->dest_array_list = NULL;
+ }
}
/**
err = ENOTSUP;
goto error;
}
- mlx5_list_create(&priv->hrxqs, "hrxq", eth_dev, mlx5_hrxq_create_cb,
- mlx5_hrxq_match_cb,
- mlx5_hrxq_remove_cb,
- mlx5_hrxq_clone_cb,
- mlx5_hrxq_clone_free_cb);
+ priv->hrxqs = mlx5_list_create("hrxq", eth_dev, mlx5_hrxq_create_cb,
+ mlx5_hrxq_match_cb,
+ mlx5_hrxq_remove_cb,
+ mlx5_hrxq_clone_cb,
+ mlx5_hrxq_clone_free_cb);
+ if (!priv->hrxqs)
+ goto error;
rte_rwlock_init(&priv->ind_tbls_lock);
/* Query availability of metadata reg_c's. */
err = mlx5_flow_discover_mreg_c(eth_dev);
mlx5_l3t_destroy(priv->mtr_profile_tbl);
if (own_domain_id)
claim_zero(rte_eth_switch_domain_free(priv->domain_id));
- mlx5_list_destroy(&priv->hrxqs);
+ if (priv->hrxqs)
+ mlx5_list_destroy(priv->hrxqs);
mlx5_free(priv);
if (eth_dev != NULL)
eth_dev->data->dev_private = NULL;
if (ret)
DRV_LOG(WARNING, "port %u some flows still remain",
dev->data->port_id);
- mlx5_list_destroy(&priv->hrxqs);
+ if (priv->hrxqs)
+ mlx5_list_destroy(priv->hrxqs);
/*
* Free the shared context in last turn, because the cleanup
* routines above may use some shared fields, like
struct mlx5_hlist *encaps_decaps; /* Encap/decap action hash list. */
struct mlx5_hlist *modify_cmds;
struct mlx5_hlist *tag_table;
- struct mlx5_list port_id_action_list; /* Port ID action list. */
- struct mlx5_list push_vlan_action_list; /* Push VLAN actions. */
- struct mlx5_list sample_action_list; /* List of sample actions. */
- struct mlx5_list dest_array_list;
+ struct mlx5_list *port_id_action_list; /* Port ID action list. */
+ struct mlx5_list *push_vlan_action_list; /* Push VLAN actions. */
+ struct mlx5_list *sample_action_list; /* List of sample actions. */
+ struct mlx5_list *dest_array_list;
/* List of destination array actions. */
struct mlx5_flow_counter_mng cmng; /* Counters management structure. */
void *default_miss_action; /* Default miss action. */
struct mlx5_obj_ops obj_ops; /* HW objects operations. */
LIST_HEAD(rxq, mlx5_rxq_ctrl) rxqsctrl; /* DPDK Rx queues. */
LIST_HEAD(rxqobj, mlx5_rxq_obj) rxqsobj; /* Verbs/DevX Rx queues. */
- struct mlx5_list hrxqs; /* Hash Rx queues. */
+ struct mlx5_list *hrxqs; /* Hash Rx queues. */
LIST_HEAD(txq, mlx5_txq_ctrl) txqsctrl; /* DPDK Tx queues. */
LIST_HEAD(txqobj, mlx5_txq_obj) txqsobj; /* Verbs/DevX Tx queues. */
/* Indirection tables. */
/**< hash list entry, 64-bits key inside. */
struct mlx5_flow_tbl_resource tbl;
/**< flow table resource. */
- struct mlx5_list matchers;
+ struct mlx5_list *matchers;
/**< matchers' header associated with the flow table. */
struct mlx5_flow_dv_jump_tbl_resource jump;
/**< jump resource, at most one for each table created. */
.data = ref,
};
- entry = mlx5_list_register(&priv->sh->port_id_action_list, &ctx);
+ entry = mlx5_list_register(priv->sh->port_id_action_list, &ctx);
if (!entry)
return -rte_errno;
resource = container_of(entry, typeof(*resource), entry);
.data = ref,
};
- entry = mlx5_list_register(&priv->sh->push_vlan_action_list, &ctx);
+ entry = mlx5_list_register(priv->sh->push_vlan_action_list, &ctx);
if (!entry)
return -rte_errno;
resource = container_of(entry, typeof(*resource), entry);
MKSTR(matcher_name, "%s_%s_%u_%u_matcher_list",
key.is_fdb ? "FDB" : "NIC", key.is_egress ? "egress" : "ingress",
key.level, key.id);
- mlx5_list_create(&tbl_data->matchers, matcher_name, sh,
- flow_dv_matcher_create_cb,
- flow_dv_matcher_match_cb,
- flow_dv_matcher_remove_cb,
- flow_dv_matcher_clone_cb,
- flow_dv_matcher_clone_free_cb);
+ tbl_data->matchers = mlx5_list_create(matcher_name, sh,
+ flow_dv_matcher_create_cb,
+ flow_dv_matcher_match_cb,
+ flow_dv_matcher_remove_cb,
+ flow_dv_matcher_clone_cb,
+ flow_dv_matcher_clone_free_cb);
+ if (!tbl_data->matchers) {
+ rte_flow_error_set(error, ENOMEM,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL,
+ "cannot create tbl matcher list");
+ mlx5_flow_os_destroy_flow_action(tbl_data->jump.action);
+ mlx5_flow_os_destroy_flow_tbl(tbl->obj);
+ mlx5_ipool_free(sh->ipool[MLX5_IPOOL_JUMP], idx);
+ return NULL;
+ }
return &tbl_data->entry;
}
tbl_data->tunnel->tunnel_id : 0,
tbl_data->group_id);
}
- mlx5_list_destroy(&tbl_data->matchers);
+ mlx5_list_destroy(tbl_data->matchers);
mlx5_ipool_free(sh->ipool[MLX5_IPOOL_JUMP], tbl_data->idx);
}
return -rte_errno; /* No need to refill the error info */
tbl_data = container_of(tbl, struct mlx5_flow_tbl_data_entry, tbl);
ref->tbl = tbl;
- entry = mlx5_list_register(&tbl_data->matchers, &ctx);
+ entry = mlx5_list_register(tbl_data->matchers, &ctx);
if (!entry) {
flow_dv_tbl_resource_release(MLX5_SH(dev), tbl);
return rte_flow_error_set(error, ENOMEM,
.data = ref,
};
- entry = mlx5_list_register(&priv->sh->sample_action_list, &ctx);
+ entry = mlx5_list_register(priv->sh->sample_action_list, &ctx);
if (!entry)
return -rte_errno;
resource = container_of(entry, typeof(*resource), entry);
.data = ref,
};
- entry = mlx5_list_register(&priv->sh->dest_array_list, &ctx);
+ entry = mlx5_list_register(priv->sh->dest_array_list, &ctx);
if (!entry)
return -rte_errno;
resource = container_of(entry, typeof(*resource), entry);
int ret;
MLX5_ASSERT(matcher->matcher_object);
- ret = mlx5_list_unregister(&tbl->matchers, &matcher->entry);
+ ret = mlx5_list_unregister(tbl->matchers, &matcher->entry);
flow_dv_tbl_resource_release(MLX5_SH(dev), &tbl->tbl);
return ret;
}
if (!resource)
return 0;
MLX5_ASSERT(resource->action);
- return mlx5_list_unregister(&priv->sh->port_id_action_list,
+ return mlx5_list_unregister(priv->sh->port_id_action_list,
&resource->entry);
}
if (!resource)
return 0;
MLX5_ASSERT(resource->action);
- return mlx5_list_unregister(&priv->sh->push_vlan_action_list,
+ return mlx5_list_unregister(priv->sh->push_vlan_action_list,
&resource->entry);
}
if (!resource)
return 0;
MLX5_ASSERT(resource->verbs_action);
- return mlx5_list_unregister(&priv->sh->sample_action_list,
+ return mlx5_list_unregister(priv->sh->sample_action_list,
&resource->entry);
}
if (!resource)
return 0;
MLX5_ASSERT(resource->action);
- return mlx5_list_unregister(&priv->sh->dest_array_list,
+ return mlx5_list_unregister(priv->sh->dest_array_list,
&resource->entry);
}
claim_zero(mlx5_flow_os_destroy_flow(color_rule->rule));
tbl = container_of(color_rule->matcher->tbl,
typeof(*tbl), tbl);
- mlx5_list_unregister(&tbl->matchers,
+ mlx5_list_unregister(tbl->matchers,
&color_rule->matcher->entry);
TAILQ_REMOVE(&sub_policy->color_rules[i],
color_rule, next_port);
if (mtrmng->def_matcher[i]) {
tbl = container_of(mtrmng->def_matcher[i]->tbl,
struct mlx5_flow_tbl_data_entry, tbl);
- mlx5_list_unregister(&tbl->matchers,
+ mlx5_list_unregister(tbl->matchers,
&mtrmng->def_matcher[i]->entry);
mtrmng->def_matcher[i] = NULL;
}
container_of(mtrmng->drop_matcher[i][j]->tbl,
struct mlx5_flow_tbl_data_entry,
tbl);
- mlx5_list_unregister(&tbl->matchers,
+ mlx5_list_unregister(tbl->matchers,
&mtrmng->drop_matcher[i][j]->entry);
mtrmng->drop_matcher[i][j] = NULL;
}
matcher.priority = priority;
matcher.crc = rte_raw_cksum((const void *)matcher.mask.buf,
matcher.mask.size);
- entry = mlx5_list_register(&tbl_data->matchers, &ctx);
+ entry = mlx5_list_register(tbl_data->matchers, &ctx);
if (!entry) {
DRV_LOG(ERR, "Failed to register meter drop matcher.");
return -1;
struct mlx5_flow_tbl_data_entry *tbl =
container_of(color_rule->matcher->tbl,
typeof(*tbl), tbl);
- mlx5_list_unregister(&tbl->matchers,
+ mlx5_list_unregister(tbl->matchers,
&color_rule->matcher->entry);
}
mlx5_free(color_rule);
matcher.crc = rte_raw_cksum
((const void *)matcher.mask.buf,
matcher.mask.size);
- entry = mlx5_list_register(&tbl_data->matchers, &ctx);
+ entry = mlx5_list_register(tbl_data->matchers, &ctx);
if (!entry) {
DRV_LOG(ERR, "Failed to register meter "
"drop default matcher.");
matcher.crc = rte_raw_cksum
((const void *)matcher.mask.buf,
matcher.mask.size);
- entry = mlx5_list_register(&tbl_data->matchers, &ctx);
+ entry = mlx5_list_register(tbl_data->matchers, &ctx);
if (!entry) {
DRV_LOG(ERR,
"Failed to register meter drop matcher.");
struct mlx5_flow_tbl_data_entry *tbl =
container_of(color_rule->matcher->tbl,
typeof(*tbl), tbl);
- mlx5_list_unregister(&tbl->matchers,
+ mlx5_list_unregister(tbl->matchers,
&color_rule->matcher->entry);
}
mlx5_free(color_rule);
if (rss_desc->shared_rss) {
hrxq = __mlx5_hrxq_create(dev, rss_desc);
} else {
- entry = mlx5_list_register(&priv->hrxqs, &ctx);
+ entry = mlx5_list_register(priv->hrxqs, &ctx);
if (!entry)
return 0;
hrxq = container_of(entry, typeof(*hrxq), entry);
if (!hrxq)
return 0;
if (!hrxq->standalone)
- return mlx5_list_unregister(&priv->hrxqs, &hrxq->entry);
+ return mlx5_list_unregister(priv->hrxqs, &hrxq->entry);
__mlx5_hrxq_remove(dev, hrxq);
return 0;
}
{
struct mlx5_priv *priv = dev->data->dev_private;
- return mlx5_list_get_entry_num(&priv->hrxqs);
+ return mlx5_list_get_entry_num(priv->hrxqs);
}
/**
/********************* mlx5 list ************************/
-int
-mlx5_list_create(struct mlx5_list *list, const char *name, void *ctx,
+struct mlx5_list *
+mlx5_list_create(const char *name, void *ctx,
mlx5_list_create_cb cb_create,
mlx5_list_match_cb cb_match,
mlx5_list_remove_cb cb_remove,
mlx5_list_clone_cb cb_clone,
mlx5_list_clone_free_cb cb_clone_free)
{
+ struct mlx5_list *list;
int i;
- MLX5_ASSERT(list);
if (!cb_match || !cb_create || !cb_remove || !cb_clone ||
- !cb_clone_free)
- return -1;
+ !cb_clone_free) {
+ rte_errno = EINVAL;
+ return NULL;
+ }
+ list = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*list), 0, SOCKET_ID_ANY);
+ if (!list)
+ return NULL;
if (name)
snprintf(list->name, sizeof(list->name), "%s", name);
list->ctx = ctx;
DRV_LOG(DEBUG, "mlx5 list %s initialized.", list->name);
for (i = 0; i <= RTE_MAX_LCORE; i++)
LIST_INIT(&list->cache[i].h);
- return 0;
+ return list;
}
static struct mlx5_list_entry *
}
}
}
- memset(list, 0, sizeof(*list));
+ mlx5_free(list);
}
uint32_t
* @param cb_remove
* Callback function for entry remove.
* @return
- * 0 on success, otherwise failure.
+ * List pointer on success, otherwise NULL.
*/
-int mlx5_list_create(struct mlx5_list *list,
- const char *name, void *ctx,
- mlx5_list_create_cb cb_create,
- mlx5_list_match_cb cb_match,
- mlx5_list_remove_cb cb_remove,
- mlx5_list_clone_cb cb_clone,
- mlx5_list_clone_free_cb cb_clone_free);
+struct mlx5_list *mlx5_list_create(const char *name, void *ctx,
+ mlx5_list_create_cb cb_create,
+ mlx5_list_match_cb cb_match,
+ mlx5_list_remove_cb cb_remove,
+ mlx5_list_clone_cb cb_clone,
+ mlx5_list_clone_free_cb cb_clone_free);
/**
* Search an entry matching the key.
err = ENOTSUP;
goto error;
}
- mlx5_list_create(&priv->hrxqs, "hrxq", eth_dev,
+ priv->hrxqs = mlx5_list_create("hrxq", eth_dev,
mlx5_hrxq_create_cb, mlx5_hrxq_match_cb,
mlx5_hrxq_remove_cb, mlx5_hrxq_clone_cb,
mlx5_hrxq_clone_free_cb);