src/dpdk/drivers/net/mvpp2/mrvl_mtr.c
static int
mrvl_meter_profile_update(struct rte_eth_dev *dev, uint32_t mtr_id,
			  uint32_t meter_profile_id,
			  struct rte_mtr_error *error)
{
	struct mrvl_priv *priv = dev->data->dev_private;
	struct mrvl_mtr_profile *profile;
	struct mrvl_mtr *mtr;
	int ret, enabled = 0;

	if (!priv->ppio)
		return -rte_mtr_error_set(error, EPERM,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED,
					  NULL, "Port is uninitialized\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 does not exist\n");

	profile = mrvl_mtr_profile_from_id(priv, 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");

	ret = mrvl_meter_disable(dev, mtr_id, error);
	if (ret)
		return -rte_mtr_error_set(error, EPERM,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
					  NULL);

	if (mtr->plcr) {
		enabled = 1;
		pp2_cls_plcr_deinit(mtr->plcr);
		mtr->plcr = NULL;
	}

	mtr->profile->refcnt--;
	mtr->profile = profile;
	profile->refcnt++;

	if (enabled)
		return mrvl_meter_enable(dev, mtr_id, error);

	return 0;
}
/**
 * Update profile used by the meter.
 *
 * @param dev Pointer to the device.
 * @param mtr_id Id of the meter object.
 * @param error Pointer to the error.
 * @returns 0 on success, negative value otherwise.
 */
Update profile used by the meter.
@param dev Pointer to the device.
@param mtr_id Id of the meter object.
@param error Pointer to the error.
@returns 0 on success, negative value otherwise.
Update profile used by the meter . @param dev Pointer to the device . @param mtr_id Id of the meter object . @param error Pointer to the error . @returns 0 on success negative value otherwise .
static int
mrvl_meter_profile_update(struct rte_eth_dev *dev, uint32_t mtr_id,
			  uint32_t meter_profile_id,
			  struct rte_mtr_error *error)
{
	struct mrvl_priv *priv = dev->data->dev_private;
	struct mrvl_mtr_profile *profile;
	struct mrvl_mtr *mtr;
	int ret, enabled = 0;
	if (!priv->ppio)
		return -rte_mtr_error_set(error, EPERM,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED,
					  NULL, "Port is uninitialized\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 does not exist\n");
	profile = mrvl_mtr_profile_from_id(priv, 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");
	ret = mrvl_meter_disable(dev, mtr_id, error);
	if (ret)
		return -rte_mtr_error_set(error, EPERM,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
					  NULL);
	if (mtr->plcr) {
		enabled = 1;
		pp2_cls_plcr_deinit(mtr->plcr);
		mtr->plcr = NULL;
	}
	mtr->profile->refcnt--;
	mtr->profile = profile;
	profile->refcnt++;
	if (enabled)
		return mrvl_meter_enable(dev, mtr_id, error);
	return 0;
}
static int mrvl_meter_profile_update ( struct rte_eth_dev * dev , uint32_t mtr_id , uint32_t meter_profile_id , struct rte_mtr_error * error ) { struct mrvl_priv * priv = dev -> data -> dev_private ; struct mrvl_mtr_profile * profile ; struct mrvl_mtr * mtr ; int ret , enabled = 0 ; if ( ! priv -> ppio ) return - rte_mtr_error_set ( error , EPERM , RTE_MTR_ERROR_TYPE_UNSPECIFIED , 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 " ) ; profile = mrvl_mtr_profile_from_id ( priv , meter_profile_id ) ; if ( ! profile ) return - rte_mtr_error_set ( error , EINVAL , RTE_MTR_ERROR_TYPE_METER_PROFILE_ID , NULL , " \n " ) ; ret = mrvl_meter_disable ( dev , mtr_id , error ) ; if ( ret ) return - rte_mtr_error_set ( error , EPERM , RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL , NULL ) ; if ( mtr -> plcr ) { enabled = 1 ; pp2_cls_plcr_deinit ( mtr -> plcr ) ; mtr -> plcr = NULL ; } mtr -> profile -> refcnt -- ; mtr -> profile = profile ; profile -> refcnt ++ ; if ( enabled ) return mrvl_meter_enable ( dev , mtr_id , error ) ; return 0 ; }
Update profile used by the meter.
Update profile used by the meter .