src/dpdk/drivers/net/mvpp2/mrvl_mtr.c
static int
mrvl_create(struct rte_eth_dev *dev, uint32_t mtr_id,
	    struct rte_mtr_params *params, int shared,
	    struct rte_mtr_error *error)
{
	struct mrvl_priv *priv = dev->data->dev_private;
	struct mrvl_mtr_profile *profile;
	struct mrvl_mtr *mtr;

	profile = mrvl_mtr_profile_from_id(priv, params->meter_profile_id);
	if (!profile)
		return -rte_mtr_error_set(error, EINVAL,
					  RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
					  NULL, "Profile id does not exist\n");

	mtr = mrvl_mtr_from_id(priv, mtr_id);
	if (mtr)
		return -rte_mtr_error_set(error, EEXIST,
					  RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
					  "Meter id already exists\n");

	mtr = rte_zmalloc_socket(NULL, sizeof(*mtr), 0, rte_socket_id());
	if (!mtr)
		return -rte_mtr_error_set(error, ENOMEM,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED,
					  NULL, NULL);

	mtr->shared = shared;
	mtr->mtr_id = mtr_id;
	mtr->plcr_bit = MRVL_PLCR_BIT_INVALID;
	mtr->profile = profile;
	profile->refcnt++;
	LIST_INSERT_HEAD(&priv->mtrs, mtr, next);

	if (params->meter_enable)
		return mrvl_meter_enable(dev, mtr_id, error);

	return 0;
}
/**
 * Create new meter.
 *
 * @param dev Pointer to the device.
 * @param mtr_id Id of the meter.
 * @param params Pointer to the meter parameters.
 * @param shared Flags indicating whether meter is shared.
 * @param error Pointer to the error.
 * @returns 0 on success, negative value otherwise.
 */
Create new meter.
@param dev Pointer to the device.
@param mtr_id Id of the meter.
@param params Pointer to the meter parameters.
@param shared Flags indicating whether meter is shared.
@param error Pointer to the error.
@returns 0 on success, negative value otherwise.
Create new meter . @param dev Pointer to the device . @param mtr_id Id of the meter . @param params Pointer to the meter parameters . @param shared Flags indicating whether meter is shared . @param error Pointer to the error . @returns 0 on success negative value otherwise .
static int
mrvl_create(struct rte_eth_dev *dev, uint32_t mtr_id,
	    struct rte_mtr_params *params, int shared,
	    struct rte_mtr_error *error)
{
	struct mrvl_priv *priv = dev->data->dev_private;
	struct mrvl_mtr_profile *profile;
	struct mrvl_mtr *mtr;
	profile = mrvl_mtr_profile_from_id(priv, params->meter_profile_id);
	if (!profile)
		return -rte_mtr_error_set(error, EINVAL,
					  RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
					  NULL, "Profile id does not exist\n");
	mtr = mrvl_mtr_from_id(priv, mtr_id);
	if (mtr)
		return -rte_mtr_error_set(error, EEXIST,
					  RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
					  "Meter id already exists\n");
	mtr = rte_zmalloc_socket(NULL, sizeof(*mtr), 0, rte_socket_id());
	if (!mtr)
		return -rte_mtr_error_set(error, ENOMEM,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED,
					  NULL, NULL);
	mtr->shared = shared;
	mtr->mtr_id = mtr_id;
	mtr->plcr_bit = MRVL_PLCR_BIT_INVALID;
	mtr->profile = profile;
	profile->refcnt++;
	LIST_INSERT_HEAD(&priv->mtrs, mtr, next);
	if (params->meter_enable)
		return mrvl_meter_enable(dev, mtr_id, error);
	return 0;
}
static int mrvl_create ( struct rte_eth_dev * dev , uint32_t mtr_id , struct rte_mtr_params * params , int shared , struct rte_mtr_error * error ) { struct mrvl_priv * priv = dev -> data -> dev_private ; struct mrvl_mtr_profile * profile ; struct mrvl_mtr * mtr ; profile = mrvl_mtr_profile_from_id ( priv , params -> meter_profile_id ) ; if ( ! profile ) return - rte_mtr_error_set ( error , EINVAL , RTE_MTR_ERROR_TYPE_METER_PROFILE_ID , NULL , " \n " ) ; mtr = mrvl_mtr_from_id ( priv , mtr_id ) ; if ( mtr ) return - rte_mtr_error_set ( error , EEXIST , RTE_MTR_ERROR_TYPE_MTR_ID , NULL , " \n " ) ; mtr = rte_zmalloc_socket ( NULL , sizeof ( * mtr ) , 0 , rte_socket_id ( ) ) ; if ( ! mtr ) return - rte_mtr_error_set ( error , ENOMEM , RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL , NULL ) ; mtr -> shared = shared ; mtr -> mtr_id = mtr_id ; mtr -> plcr_bit = MRVL_PLCR_BIT_INVALID ; mtr -> profile = profile ; profile -> refcnt ++ ; LIST_INSERT_HEAD ( & priv -> mtrs , mtr , next ) ; if ( params -> meter_enable ) return mrvl_meter_enable ( dev , mtr_id , error ) ; return 0 ; }
Create new meter.
Create new meter .