MCPcopy Create free account
hub / github.com/F-Stack/f-stack / flow_dv_mtr_alloc

Function flow_dv_mtr_alloc

dpdk/drivers/net/mlx5/mlx5_flow_dv.c:6960–7010  ·  view source on GitHub ↗

* Allocate a aso flow meter. * * @param[in] dev * Pointer to the Ethernet device structure. * * @return * Index to aso flow meter on success, 0 otherwise and rte_errno is set. */

Source from the content-addressed store, hash-verified

6958 * Index to aso flow meter on success, 0 otherwise and rte_errno is set.
6959 */
6960static uint32_t
6961flow_dv_mtr_alloc(struct rte_eth_dev *dev)
6962{
6963 struct mlx5_priv *priv = dev->data->dev_private;
6964 struct mlx5_aso_mtr *mtr_free = NULL;
6965 struct mlx5_aso_mtr_pools_mng *pools_mng =
6966 &priv->sh->mtrmng->pools_mng;
6967 struct mlx5_aso_mtr_pool *pool;
6968 uint32_t mtr_idx = 0;
6969
6970 if (!priv->sh->cdev->config.devx) {
6971 rte_errno = ENOTSUP;
6972 return 0;
6973 }
6974 /* Allocate the flow meter memory. */
6975 /* Get free meters from management. */
6976 rte_spinlock_lock(&pools_mng->mtrsl);
6977 mtr_free = LIST_FIRST(&pools_mng->meters);
6978 if (mtr_free)
6979 LIST_REMOVE(mtr_free, next);
6980 if (!mtr_free && !flow_dv_mtr_pool_create(dev, &mtr_free)) {
6981 rte_spinlock_unlock(&pools_mng->mtrsl);
6982 return 0;
6983 }
6984 mtr_free->state = ASO_METER_WAIT;
6985 rte_spinlock_unlock(&pools_mng->mtrsl);
6986 pool = container_of(mtr_free,
6987 struct mlx5_aso_mtr_pool,
6988 mtrs[mtr_free->offset]);
6989 mtr_idx = MLX5_MAKE_MTR_IDX(pool->index, mtr_free->offset);
6990 if (!mtr_free->fm.meter_action_g) {
6991#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO
6992 struct rte_flow_error error;
6993 uint8_t reg_id;
6994
6995 reg_id = mlx5_flow_get_reg_id(dev, MLX5_MTR_COLOR, 0, &error);
6996 mtr_free->fm.meter_action_g =
6997 mlx5_glue->dv_create_flow_action_aso
6998 (priv->sh->rx_domain,
6999 pool->devx_obj->obj,
7000 mtr_free->offset,
7001 (1 << MLX5_FLOW_COLOR_GREEN),
7002 reg_id - REG_C_0);
7003#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */
7004 if (!mtr_free->fm.meter_action_g) {
7005 flow_dv_aso_mtr_release_to_pool(dev, mtr_idx);
7006 return 0;
7007 }
7008 }
7009 return mtr_idx;
7010}
7011
7012/**
7013 * Verify the @p attributes will be correctly understood by the NIC and store

Callers

nothing calls this directly

Calls 5

flow_dv_mtr_pool_createFunction · 0.85
mlx5_flow_get_reg_idFunction · 0.85
rte_spinlock_lockFunction · 0.50
rte_spinlock_unlockFunction · 0.50

Tested by

no test coverage detected