-/**
- * Get or create a flow counter.
- *
- * @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.
- *
- * @return
- * Index to flow counter on success, 0 otherwise and rte_errno is set.
- */
-static uint32_t
-flow_dv_counter_alloc_fallback(struct rte_eth_dev *dev, uint32_t shared,
- uint32_t id)
-{
- struct mlx5_priv *priv = dev->data->dev_private;
- struct mlx5_pools_container *cont = MLX5_CNT_CONTAINER(priv->sh, 0, 0);
- struct mlx5_flow_counter_pool *pool;
- struct mlx5_flow_counter *cnt = NULL;
- struct mlx5_devx_obj *dcs = NULL;
- uint32_t offset;
-
- if (!priv->config.devx) {
- rte_errno = ENOTSUP;
- return 0;
- }
- dcs = mlx5_devx_cmd_flow_counter_alloc(priv->sh->ctx, 0);
- if (!dcs)
- return 0;
- pool = flow_dv_find_pool_by_id(cont, true, dcs->id);
- if (!pool) {
- cont = flow_dv_pool_create(dev, dcs, 0);
- if (!cont) {
- mlx5_devx_cmd_destroy(dcs);
- rte_errno = ENOMEM;
- return 0;
- }
- pool = TAILQ_FIRST(&cont->pool_list);
- }
- offset = dcs->id % MLX5_COUNTERS_PER_POOL;
- cnt = &pool->counters_raw[offset];
- struct mlx5_flow_counter tmpl = {
- .shared = shared,
- .ref_cnt = 1,
- .id = id,
- .dcs = dcs,
- };
- tmpl.action = mlx5_glue->dv_create_flow_action_counter(dcs->obj, 0);
- if (!tmpl.action) {
- claim_zero(mlx5_devx_cmd_destroy(cnt->dcs));
- rte_errno = errno;
- return 0;
- }
- *cnt = tmpl;
- return MLX5_MAKE_CNT_IDX(pool->index, offset);
-}
-
-/**
- * Release a flow counter.
- *
- * @param[in] dev
- * Pointer to the Ethernet device structure.
- * @param[in] counter
- * Index to the counter handler.
- */
-static void
-flow_dv_counter_release_fallback(struct rte_eth_dev *dev __rte_unused,
- struct mlx5_flow_counter *counter)
-{
- if (!counter)
- return;
- if (--counter->ref_cnt == 0) {
- claim_zero(mlx5_glue->destroy_flow_action(counter->action));
- claim_zero(mlx5_devx_cmd_destroy(counter->dcs));
- counter->action = NULL;
- counter->dcs = NULL;
- }
-}
-
-/**
- * Query a devx flow counter.
- *
- * @param[in] dev
- * Pointer to the Ethernet device structure.
- * @param[in] cnt
- * Pointer to the flow counter.
- * @param[out] pkts
- * The statistics value of packets.
- * @param[out] bytes
- * The statistics value of bytes.
- *
- * @return
- * 0 on success, otherwise a negative errno value and rte_errno is set.
- */
-static inline int
-_flow_dv_query_count_fallback(struct rte_eth_dev *dev __rte_unused,
- struct mlx5_flow_counter *cnt, uint64_t *pkts,
- uint64_t *bytes)
-{
- return mlx5_devx_cmd_flow_counter_query(cnt->dcs, 0, 0, pkts, bytes,
- 0, NULL, NULL, 0);
-}
-
-/**
- * Get a pool by a counter.
- *
- * @param[in] cnt
- * Pointer to the counter.
- *
- * @return
- * The counter pool.
- */
-static struct mlx5_flow_counter_pool *
-flow_dv_counter_pool_get(struct mlx5_flow_counter *cnt)
-{
- if (!cnt->batch) {
- cnt -= cnt->dcs->id % MLX5_COUNTERS_PER_POOL;
- return (struct mlx5_flow_counter_pool *)cnt - 1;
- }
- return cnt->pool;
-}
-