Indirect actions should be used to do shared counters.
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Acked-by: Somnath Kotur <somnath.kotur@broadcom.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
ACTION_QUEUE_INDEX,
ACTION_DROP,
ACTION_COUNT,
- ACTION_COUNT_SHARED,
ACTION_COUNT_ID,
ACTION_RSS,
ACTION_RSS_FUNC,
static const enum index action_count[] = {
ACTION_COUNT_ID,
- ACTION_COUNT_SHARED,
ACTION_NEXT,
ZERO,
};
.args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
.call = parse_vc_conf,
},
- [ACTION_COUNT_SHARED] = {
- .name = "shared",
- .help = "shared counter",
- .next = NEXT(action_count, NEXT_ENTRY(COMMON_BOOLEAN)),
- .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
- shared, 1)),
- .call = parse_vc_conf,
- },
[ACTION_RSS] = {
.name = "rss",
.help = "spread packets among several queues",
directions. At least one direction must be specified.
Specifying both directions at once for a given rule is not recommended but
-may be valid in a few cases (e.g. shared counters).
+may be valid in a few cases.
Attribute: Transfer
^^^^^^^^^^^^^^^^^^^
+=======+========+============+=======+
| 0 | MARK | ``mark`` | 0x2a |
+-------+--------+------------+-------+
- | 1 | COUNT | ``shared`` | 0 |
- | | +------------+-------+
- | | | ``id`` | 0 |
+ | 1 | COUNT | ``id`` | 0 |
+-------+--------+------------+-------+
| 2 | QUEUE | ``queue`` | 10 |
+-------+--------+------------+-------+
Counters can be retrieved and reset through ``rte_flow_query()``, see
``struct rte_flow_query_count``.
-The shared flag indicates whether the counter is unique to the flow rule the
-action is specified with, or whether it is a shared counter.
-
-For a count action with the shared flag set, then a global device
-namespace is assumed for the counter id, so that any matched flow rules using
-a count action with the same counter id on the same port will contribute to
-that counter.
-
For ports within the same switch domain then the counter id namespace extends
to all ports within that switch domain.
-The shared flag is DEPRECATED and ``INDIRECT`` ``COUNT`` action should be used
-to make shared counters.
-
.. _table_rte_flow_action_count:
.. table:: COUNT
+------------+---------------------------------+
| Field | Value |
+============+=================================+
- | ``shared`` | DEPRECATED, shared counter flag |
- +------------+---------------------------------+
| ``id`` | counter id |
+------------+---------------------------------+
to support modifying fields larger than 64 bits.
In addition, documentation will be updated to clarify byte order.
-* ethdev: Attribute ``shared`` of the ``struct rte_flow_action_count``
- is deprecated and will be removed in DPDK 21.11. Shared counters should
- be managed using shared actions API (``rte_flow_shared_action_create`` etc).
-
* ethdev: Definition of the flow API action ``RTE_FLOW_ACTION_TYPE_PORT_ID``
is ambiguous and needs clarification.
Structure ``rte_flow_action_port_id`` will be extended to specify
driver callback. It is replaced by the more complete function
``rte_eth_rx_descriptor_status``.
+* ethdev: Removed deprecated ``shared`` attribute of the
+ ``struct rte_flow_action_count``. Shared counters should be managed
+ using indirect actions API (``rte_flow_action_handle_create`` etc).
+
* i40e: Removed i40evf driver.
iavf already became the default VF driver for i40e devices,
so there is no need to maintain i40evf.
act_count = action_item->conf;
if (act_count) {
- if (act_count->shared) {
- BNXT_TF_DBG(ERR,
- "Parse Error:Shared count not supported\n");
- return BNXT_TF_RC_PARSE_ERR;
- }
memcpy(&act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_COUNT],
&act_count->id,
BNXT_ULP_ACT_PROP_SZ_COUNT);
struct roc_npc_action in_actions[], uint32_t *flowkey_cfg)
{
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
- const struct rte_flow_action_count *act_count;
const struct rte_flow_action_queue *act_q;
int i = 0, rc = 0;
int rq;
break;
case RTE_FLOW_ACTION_TYPE_COUNT:
- act_count = (const struct rte_flow_action_count *)
- actions->conf;
-
- if (act_count->shared == 1) {
- plt_npc_dbg("Shared counter is not supported");
- goto err_exit;
- }
in_actions[i].type = ROC_NPC_ACTION_TYPE_COUNT;
break;
goto out;
if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) {
- ret = hns3_counter_new(dev, fdir_rule.act_cnt.shared,
- fdir_rule.act_cnt.id, error);
+ ret = hns3_counter_new(dev, 0, fdir_rule.act_cnt.id, error);
if (ret)
goto out;
if (filter->input.cnt_ena) {
struct rte_flow_action_count *act_count = &filter->act_count;
- filter->counter = ice_fdir_counter_alloc(pf,
- act_count->shared,
- act_count->id);
+ filter->counter = ice_fdir_counter_alloc(pf, 0, act_count->id);
if (!filter->counter) {
rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ACTION, NULL,
mlx5_os_set_reg_mr_cb(&sh->share_cache.reg_mr_cb,
&sh->share_cache.dereg_mr_cb);
mlx5_os_dev_shared_handler_install(sh);
- sh->cnt_id_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_DWORD);
- if (!sh->cnt_id_tbl) {
- err = rte_errno;
- goto error;
- }
if (LIST_EMPTY(&mlx5_dev_ctx_list)) {
err = mlx5_flow_os_init_workspace_once();
if (err)
pthread_mutex_destroy(&sh->txpp.mutex);
pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
MLX5_ASSERT(sh);
- if (sh->cnt_id_tbl)
- mlx5_l3t_destroy(sh->cnt_id_tbl);
if (sh->share_cache.cache.table)
mlx5_mr_btree_free(&sh->share_cache.cache);
if (sh->tis)
mlx5_aso_flow_mtrs_mng_close(sh);
mlx5_flow_ipool_destroy(sh);
mlx5_os_dev_shared_handler_uninstall(sh);
- if (sh->cnt_id_tbl) {
- mlx5_l3t_destroy(sh->cnt_id_tbl);
- sh->cnt_id_tbl = NULL;
- }
if (sh->tx_uar) {
mlx5_glue->devx_free_uar(sh->tx_uar);
sh->tx_uar = NULL;
#define MLX5_MAX_PENDING_QUERIES 4
#define MLX5_CNT_CONTAINER_RESIZE 64
#define MLX5_CNT_SHARED_OFFSET 0x80000000
-#define IS_LEGACY_SHARED_CNT(cnt) (!!((cnt) & MLX5_CNT_SHARED_OFFSET))
#define IS_BATCH_CNT(cnt) (((cnt) & (MLX5_CNT_SHARED_OFFSET - 1)) >= \
MLX5_CNT_BATCH_OFFSET)
#define MLX5_CNT_SIZE (sizeof(struct mlx5_flow_counter))
};
};
-/* Shared counter configuration. */
-struct mlx5_shared_counter_conf {
- struct rte_eth_dev *dev; /* The device shared counter belongs to. */
- uint32_t id; /* The shared counter ID. */
-};
-
struct mlx5_flow_counter_pool;
/* Generic counters information. */
struct mlx5_flow_counter {
void *default_miss_action; /* Default miss action. */
struct mlx5_indexed_pool *ipool[MLX5_IPOOL_MAX];
struct mlx5_indexed_pool *mdh_ipools[MLX5_MAX_MODIFY_NUM];
- /* Memory Pool for mlx5 flow resources. */
- struct mlx5_l3t_tbl *cnt_id_tbl; /* Shared counter lookup table. */
/* Shared interrupt handler section. */
struct rte_intr_handle intr_handle; /* Interrupt handler for device. */
struct rte_intr_handle intr_handle_devx; /* DEVX interrupt handler. */
return 0;
}
-/**
- * Check if action counter is shared by either old or new mechanism.
- *
- * @param[in] action
- * Pointer to the action structure.
- *
- * @return
- * True when counter is shared, false otherwise.
- */
-static inline bool
-is_shared_action_count(const struct rte_flow_action *action)
-{
- const struct rte_flow_action_count *count =
- (const struct rte_flow_action_count *)action->conf;
-
- if ((int)action->type == MLX5_RTE_FLOW_ACTION_TYPE_COUNT)
- return true;
- return !!(count && count->shared);
-}
-
/**
* Validate count action.
*
break;
case RTE_FLOW_ACTION_TYPE_COUNT:
ret = flow_dv_validate_action_count
- (dev, is_shared_action_count(act),
- *action_flags | sub_action_flags,
+ (dev, false, *action_flags | sub_action_flags,
error);
if (ret < 0)
return ret;
return 0;
}
-/**
- * Allocate a shared flow counter.
- *
- * @param[in] ctx
- * Pointer to the shared counter configuration.
- * @param[in] data
- * Pointer to save the allocated counter index.
- *
- * @return
- * Index to flow counter on success, 0 otherwise and rte_errno is set.
- */
-
-static int32_t
-flow_dv_counter_alloc_shared_cb(void *ctx, union mlx5_l3t_data *data)
-{
- struct mlx5_shared_counter_conf *conf = ctx;
- struct rte_eth_dev *dev = conf->dev;
- struct mlx5_flow_counter *cnt;
-
- data->dword = flow_dv_counter_alloc(dev, 0);
- data->dword |= MLX5_CNT_SHARED_OFFSET;
- cnt = flow_dv_counter_get_by_idx(dev, data->dword, NULL);
- cnt->shared_info.id = conf->id;
- return 0;
-}
-
-/**
- * Get a shared flow counter.
- *
- * @param[in] dev
- * Pointer to the Ethernet device structure.
- * @param[in] id
- * Counter identifier.
- *
- * @return
- * Index to flow counter on success, 0 otherwise and rte_errno is set.
- */
-static uint32_t
-flow_dv_counter_get_shared(struct rte_eth_dev *dev, uint32_t id)
-{
- struct mlx5_priv *priv = dev->data->dev_private;
- struct mlx5_shared_counter_conf conf = {
- .dev = dev,
- .id = id,
- };
- union mlx5_l3t_data data = {
- .dword = 0,
- };
-
- mlx5_l3t_prepare_entry(priv->sh->cnt_id_tbl, id, &data,
- flow_dv_counter_alloc_shared_cb, &conf);
- return data.dword;
-}
-
/**
* Get age param from counter index.
*
if (pool->is_aged) {
flow_dv_counter_remove_from_age(dev, counter, cnt);
} else {
- /*
- * If the counter action is shared by ID, the l3t_clear_entry
- * function reduces its references counter. If after the
- * reduction the action is still referenced, the function
- * returns here and does not release it.
- */
- if (IS_LEGACY_SHARED_CNT(counter) &&
- mlx5_l3t_clear_entry(priv->sh->cnt_id_tbl,
- cnt->shared_info.id))
- return;
/*
* If the counter action is shared by indirect action API,
* the atomic function reduces its references counter.
* If after the reduction the action is still referenced, the
* function returns here and does not release it.
- * When the counter action is not shared neither by ID nor by
+ * When the counter action is not shared by
* indirect action API, shared info is 1 before the reduction,
* so this condition is failed and function doesn't return here.
*/
- if (!IS_LEGACY_SHARED_CNT(counter) &&
- __atomic_sub_fetch(&cnt->shared_info.refcnt, 1,
+ if (__atomic_sub_fetch(&cnt->shared_info.refcnt, 1,
__ATOMIC_RELAXED))
return;
}
++actions_n;
break;
case MLX5_RTE_FLOW_ACTION_TYPE_COUNT:
+ shared_count = true;
+ /* fall-through. */
case RTE_FLOW_ACTION_TYPE_COUNT:
- shared_count = is_shared_action_count(actions);
ret = flow_dv_validate_action_count(dev, shared_count,
action_flags,
error);
static uint32_t
flow_dv_translate_create_counter(struct rte_eth_dev *dev,
struct mlx5_flow *dev_flow,
- const struct rte_flow_action_count *count,
+ const struct rte_flow_action_count *count
+ __rte_unused,
const struct rte_flow_action_age *age)
{
uint32_t counter;
struct mlx5_age_param *age_param;
- if (count && count->shared)
- counter = flow_dv_counter_get_shared(dev, count->id);
- else
- counter = flow_dv_counter_alloc(dev, !!age);
+ counter = flow_dv_counter_alloc(dev, !!age);
if (!counter || age == NULL)
return counter;
age_param = flow_dv_counter_idx_get_age(dev, counter);
* when they are not shared.
*/
if (action_flags & MLX5_FLOW_ACTION_AGE) {
- if ((non_shared_age &&
- count && !count->shared) ||
+ if ((non_shared_age && count) ||
!(priv->sh->flow_hit_aso_en &&
(attr->group || attr->transfer))) {
/* Creates age by counters. */
"Indirect age action not supported");
return flow_dv_validate_action_age(0, action, dev, err);
case RTE_FLOW_ACTION_TYPE_COUNT:
- /*
- * There are two mechanisms to share the action count.
- * The old mechanism uses the shared field to share, while the
- * new mechanism uses the indirect action API.
- * This validation comes to make sure that the two mechanisms
- * are not combined.
- */
- if (is_shared_action_count(action))
- return rte_flow_error_set(err, ENOTSUP,
- RTE_FLOW_ERROR_TYPE_ACTION,
- NULL,
- "Mix shared and indirect counter is not supported");
return flow_dv_validate_action_count(dev, true, 0, err);
case RTE_FLOW_ACTION_TYPE_CONNTRACK:
if (!priv->sh->ct_aso_en)
*
* @param[in] dev
* Pointer to the Ethernet device structure.
- * @param[in] shared
- * Indicate if this counter is shared with other flows.
* @param[in] id
* Counter identifier.
*
* Index to the counter, 0 otherwise and rte_errno is set.
*/
static uint32_t
-flow_verbs_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id)
+flow_verbs_counter_new(struct rte_eth_dev *dev, uint32_t id __rte_unused)
{
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng;
struct mlx5_flow_counter_pool *pool = NULL;
struct mlx5_flow_counter *cnt = NULL;
- union mlx5_l3t_data data;
uint32_t n_valid = cmng->n_valid;
uint32_t pool_idx, cnt_idx;
uint32_t i;
int ret;
- if (shared && !mlx5_l3t_get_entry(priv->sh->cnt_id_tbl, id, &data) &&
- data.dword)
- return data.dword;
for (pool_idx = 0; pool_idx < n_valid; ++pool_idx) {
pool = cmng->pools[pool_idx];
if (!pool)
TAILQ_REMOVE(&pool->counters[0], cnt, next);
i = MLX5_CNT_ARRAY_IDX(pool, cnt);
cnt_idx = MLX5_MAKE_CNT_IDX(pool_idx, i);
- if (shared) {
- data.dword = cnt_idx;
- if (mlx5_l3t_set_entry(priv->sh->cnt_id_tbl, id, &data))
- return 0;
- cnt->shared_info.id = id;
- cnt_idx |= MLX5_CNT_SHARED_OFFSET;
- }
/* Create counter with Verbs. */
ret = flow_verbs_counter_create(dev, cnt);
if (!ret) {
static void
flow_verbs_counter_release(struct rte_eth_dev *dev, uint32_t counter)
{
- struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_flow_counter_pool *pool;
struct mlx5_flow_counter *cnt;
cnt = flow_verbs_counter_get_by_idx(dev, counter, &pool);
- if (IS_LEGACY_SHARED_CNT(counter) &&
- mlx5_l3t_clear_entry(priv->sh->cnt_id_tbl, cnt->shared_info.id))
- return;
#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42)
claim_zero(mlx5_glue->destroy_counter_set
((struct ibv_counter_set *)cnt->dcs_when_active));
#endif
if (!flow->counter) {
- flow->counter = flow_verbs_counter_new(dev, count->shared,
- count->id);
+ flow->counter = flow_verbs_counter_new(dev, count->id);
if (!flow->counter)
return rte_flow_error_set(error, rte_errno,
RTE_FLOW_ERROR_TYPE_ACTION,
struct otx2_eth_dev *hw = dev->data->dev_private;
struct otx2_npc_flow_info *npc = &hw->npc_flow;
const struct rte_flow_action_port_id *port_act;
- const struct rte_flow_action_count *act_count;
const struct rte_flow_action_mark *act_mark;
const struct rte_flow_action_queue *act_q;
const struct rte_flow_action_vf *vf_act;
break;
case RTE_FLOW_ACTION_TYPE_COUNT:
- act_count =
- (const struct rte_flow_action_count *)
- actions->conf;
-
- if (act_count->shared == 1) {
- errmsg = "Shared Counters not supported";
- errcode = ENOTSUP;
- goto err_exit;
- }
/* Indicates, need a counter */
flow->ctr_id = 1;
req_act |= OTX2_FLOW_ACT_COUNT;
static int
sfc_mae_rule_parse_action_count(struct sfc_adapter *sa,
- const struct rte_flow_action_count *conf,
+ const struct rte_flow_action_count *conf
+ __rte_unused,
efx_mae_actions_t *spec)
{
int rc;
- if (conf->shared) {
- rc = ENOTSUP;
- goto fail_counter_shared;
- }
-
if ((sa->counter_rxq.state & SFC_COUNTER_RXQ_INITIALIZED) == 0) {
sfc_err(sa,
"counter queue is not configured for COUNT action");
fail_populate_count:
fail_no_service_core:
fail_counter_queue_uninit:
-fail_counter_shared:
return rc;
}
action,
"COUNT: Null configuration");
- if (conf->shared)
- return rte_flow_error_set(error,
- ENOTSUP,
- RTE_FLOW_ERROR_TYPE_ACTION_CONF,
- conf,
- "COUNT: Shared counters not supported");
-
if (n_count)
return rte_flow_error_set(error,
ENOTSUP,
* At least one direction must be specified.
*
* Specifying both directions at once for a given rule is not recommended
- * but may be valid in a few cases (e.g. shared counter).
+ * but may be valid in a few cases.
*/
struct rte_flow_attr {
uint32_t group; /**< Priority group. */
* Counters can be retrieved and reset through ``rte_flow_query()``, see
* ``struct rte_flow_query_count``.
*
- * @deprecated Shared attribute is deprecated, use generic
- * RTE_FLOW_ACTION_TYPE_INDIRECT action.
- *
- * The shared flag indicates whether the counter is unique to the flow rule the
- * action is specified with, or whether it is a shared counter.
- *
- * For a count action with the shared flag set, then then a global device
- * namespace is assumed for the counter id, so that any matched flow rules using
- * a count action with the same counter id on the same port will contribute to
- * that counter.
- *
* For ports within the same switch domain then the counter id namespace extends
* to all ports within that switch domain.
*/
struct rte_flow_action_count {
- /** @deprecated Share counter ID with other flow rules. */
- uint32_t shared:1;
- uint32_t reserved:31; /**< Reserved, must be zero. */
uint32_t id; /**< Counter ID. */
};