-/**
- * 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_ext *cnt_ext;
- 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_ext = MLX5_GET_POOL_CNT_EXT(pool, offset);
- cnt_ext->shared = shared;
- cnt_ext->ref_cnt = 1;
- cnt_ext->id = id;
- cnt_ext->dcs = dcs;
- pool->counters_raw[offset].action =
- mlx5_glue->dv_create_flow_action_counter(dcs->obj, 0);
- if (!pool->counters_raw[offset].action) {
- claim_zero(mlx5_devx_cmd_destroy(dcs));
- rte_errno = errno;
- return 0;
- }
- return MLX5_MAKE_CNT_IDX(pool->index, offset);
-}
-
-/**
- * Release a flow counter.
- *
- * @param[in] dev
- * Pointer to the Ethernet device structure.
- * @param[in] counter
- * Extend counter handler.
- */
-static void
-flow_dv_counter_release_fallback(struct rte_eth_dev *dev __rte_unused,
- struct mlx5_flow_counter_ext *counter)
-{
- if (!counter)
- return;
- claim_zero(mlx5_devx_cmd_destroy(counter->dcs));
- 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_ext *cnt, uint64_t *pkts,
- uint64_t *bytes)
-{
- return mlx5_devx_cmd_flow_counter_query(cnt->dcs, 0, 0, pkts, bytes,
- 0, NULL, NULL, 0);
-}
-