net/mlx5: allocate list memory in create function
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>
This commit is contained in:
parent
84fbba5b9e
commit
679f46c775
@ -347,36 +347,44 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
|
||||
#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,
|
||||
@ -531,6 +539,22 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -592,9 +616,23 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1798,11 +1836,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
|
||||
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);
|
||||
@ -1861,7 +1901,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_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;
|
||||
|
@ -1612,7 +1612,8 @@ mlx5_dev_close(struct rte_eth_dev *dev)
|
||||
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
|
||||
|
@ -1139,10 +1139,10 @@ struct mlx5_dev_ctx_shared {
|
||||
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. */
|
||||
@ -1384,7 +1384,7 @@ struct mlx5_priv {
|
||||
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. */
|
||||
|
@ -591,7 +591,7 @@ struct mlx5_flow_tbl_data_entry {
|
||||
/**< 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. */
|
||||
|
@ -3889,7 +3889,7 @@ flow_dv_port_id_action_resource_register
|
||||
.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);
|
||||
@ -4014,7 +4014,7 @@ flow_dv_push_vlan_action_resource_register
|
||||
.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);
|
||||
@ -10117,12 +10117,22 @@ flow_dv_tbl_create_cb(struct mlx5_hlist *list, uint64_t key64, void *cb_ctx)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -10250,7 +10260,7 @@ flow_dv_tbl_remove_cb(struct mlx5_hlist *list,
|
||||
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);
|
||||
}
|
||||
|
||||
@ -10383,7 +10393,7 @@ flow_dv_matcher_register(struct rte_eth_dev *dev,
|
||||
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,
|
||||
@ -10980,7 +10990,7 @@ flow_dv_sample_resource_register(struct rte_eth_dev *dev,
|
||||
.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);
|
||||
@ -11195,7 +11205,7 @@ flow_dv_dest_array_resource_register(struct rte_eth_dev *dev,
|
||||
.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);
|
||||
@ -13673,7 +13683,7 @@ flow_dv_matcher_release(struct rte_eth_dev *dev,
|
||||
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;
|
||||
}
|
||||
@ -13816,7 +13826,7 @@ flow_dv_port_id_action_resource_release(struct rte_eth_dev *dev,
|
||||
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);
|
||||
}
|
||||
|
||||
@ -13874,7 +13884,7 @@ flow_dv_push_vlan_action_resource_release(struct rte_eth_dev *dev,
|
||||
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);
|
||||
}
|
||||
|
||||
@ -13955,7 +13965,7 @@ flow_dv_sample_resource_release(struct rte_eth_dev *dev,
|
||||
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);
|
||||
}
|
||||
|
||||
@ -14003,7 +14013,7 @@ flow_dv_dest_array_resource_release(struct rte_eth_dev *dev,
|
||||
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);
|
||||
}
|
||||
|
||||
@ -14854,7 +14864,7 @@ __flow_dv_destroy_sub_policy_rules(struct rte_eth_dev *dev,
|
||||
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);
|
||||
@ -15647,7 +15657,7 @@ flow_dv_destroy_mtr_drop_tbls(struct rte_eth_dev *dev)
|
||||
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;
|
||||
}
|
||||
@ -15657,7 +15667,7 @@ flow_dv_destroy_mtr_drop_tbls(struct rte_eth_dev *dev)
|
||||
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;
|
||||
}
|
||||
@ -15791,7 +15801,7 @@ __flow_dv_create_policy_matcher(struct rte_eth_dev *dev,
|
||||
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;
|
||||
@ -15899,7 +15909,7 @@ __flow_dv_create_domain_policy_rules(struct rte_eth_dev *dev,
|
||||
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);
|
||||
@ -16295,7 +16305,7 @@ flow_dv_create_mtr_tbls(struct rte_eth_dev *dev,
|
||||
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.");
|
||||
@ -16334,7 +16344,7 @@ flow_dv_create_mtr_tbls(struct rte_eth_dev *dev,
|
||||
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.");
|
||||
@ -16753,7 +16763,7 @@ flow_dv_meter_hierarchy_rule_create(struct rte_eth_dev *dev,
|
||||
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);
|
||||
|
@ -2385,7 +2385,7 @@ uint32_t mlx5_hrxq_get(struct rte_eth_dev *dev,
|
||||
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);
|
||||
@ -2415,7 +2415,7 @@ int mlx5_hrxq_release(struct rte_eth_dev *dev, uint32_t hrxq_idx)
|
||||
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;
|
||||
}
|
||||
@ -2503,7 +2503,7 @@ mlx5_hrxq_verify(struct rte_eth_dev *dev)
|
||||
{
|
||||
struct mlx5_priv *priv = dev->data->dev_private;
|
||||
|
||||
return mlx5_list_get_entry_num(&priv->hrxqs);
|
||||
return mlx5_list_get_entry_num(priv->hrxqs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,20 +11,25 @@
|
||||
|
||||
/********************* 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;
|
||||
@ -37,7 +42,7 @@ mlx5_list_create(struct mlx5_list *list, const char *name, void *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 *
|
||||
@ -244,7 +249,7 @@ mlx5_list_destroy(struct mlx5_list *list)
|
||||
}
|
||||
}
|
||||
}
|
||||
memset(list, 0, sizeof(*list));
|
||||
mlx5_free(list);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
@ -420,15 +420,14 @@ struct mlx5_list {
|
||||
* @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.
|
||||
|
@ -610,7 +610,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user