src/dpdk/drivers/net/mvpp2/mrvl_mtr.c
static int
mrvl_meter_profile_add(struct rte_eth_dev *dev, uint32_t meter_profile_id,
		       struct rte_mtr_meter_profile *profile,
		       struct rte_mtr_error *error)
{
	struct mrvl_priv *priv = dev->data->dev_private;
	struct mrvl_mtr_profile *prof;

	if (!profile)
		return -rte_mtr_error_set(error, EINVAL,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED,
					  NULL, NULL);

	if (profile->alg != RTE_MTR_SRTCM_RFC2697)
		return -rte_mtr_error_set(error, EINVAL,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED,
					  NULL,
					  "Only srTCM RFC 2697 is supported\n");

	prof = mrvl_mtr_profile_from_id(priv, meter_profile_id);
	if (prof)
		return -rte_mtr_error_set(error, EEXIST,
					  RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
					  NULL, "Profile id already exists\n");

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

	prof->profile_id = meter_profile_id;
	memcpy(&prof->profile, profile, sizeof(*profile));

	LIST_INSERT_HEAD(&priv->profiles, prof, next);

	return 0;
}
/**
 * Add profile to the list of profiles.
 *
 * @param dev Pointer to the device.
 * @param meter_profile_id Id of the new profile.
 * @param profile Pointer to the profile configuration.
 * @param error Pointer to the error.
 * @returns 0 on success, negative value otherwise.
 */
Add profile to the list of profiles.
@param dev Pointer to the device.
@param meter_profile_id Id of the new profile.
@param profile Pointer to the profile configuration.
@param error Pointer to the error.
@returns 0 on success, negative value otherwise.
Add profile to the list of profiles . @param dev Pointer to the device . @param meter_profile_id Id of the new profile . @param profile Pointer to the profile configuration . @param error Pointer to the error . @returns 0 on success negative value otherwise .
static int
mrvl_meter_profile_add(struct rte_eth_dev *dev, uint32_t meter_profile_id,
		       struct rte_mtr_meter_profile *profile,
		       struct rte_mtr_error *error)
{
	struct mrvl_priv *priv = dev->data->dev_private;
	struct mrvl_mtr_profile *prof;
	if (!profile)
		return -rte_mtr_error_set(error, EINVAL,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED,
					  NULL, NULL);
	if (profile->alg != RTE_MTR_SRTCM_RFC2697)
		return -rte_mtr_error_set(error, EINVAL,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED,
					  NULL,
					  "Only srTCM RFC 2697 is supported\n");
	prof = mrvl_mtr_profile_from_id(priv, meter_profile_id);
	if (prof)
		return -rte_mtr_error_set(error, EEXIST,
					  RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
					  NULL, "Profile id already exists\n");
	prof = rte_zmalloc_socket(NULL, sizeof(*prof), 0, rte_socket_id());
	if (!prof)
		return -rte_mtr_error_set(error, ENOMEM,
					  RTE_MTR_ERROR_TYPE_UNSPECIFIED,
					  NULL, NULL);
	prof->profile_id = meter_profile_id;
	memcpy(&prof->profile, profile, sizeof(*profile));
	LIST_INSERT_HEAD(&priv->profiles, prof, next);
	return 0;
}
static int mrvl_meter_profile_add ( struct rte_eth_dev * dev , uint32_t meter_profile_id , struct rte_mtr_meter_profile * profile , struct rte_mtr_error * error ) { struct mrvl_priv * priv = dev -> data -> dev_private ; struct mrvl_mtr_profile * prof ; if ( ! profile ) return - rte_mtr_error_set ( error , EINVAL , RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL , NULL ) ; if ( profile -> alg != RTE_MTR_SRTCM_RFC2697 ) return - rte_mtr_error_set ( error , EINVAL , RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL , " \n " ) ; prof = mrvl_mtr_profile_from_id ( priv , meter_profile_id ) ; if ( prof ) return - rte_mtr_error_set ( error , EEXIST , RTE_MTR_ERROR_TYPE_METER_PROFILE_ID , NULL , " \n " ) ; prof = rte_zmalloc_socket ( NULL , sizeof ( * prof ) , 0 , rte_socket_id ( ) ) ; if ( ! prof ) return - rte_mtr_error_set ( error , ENOMEM , RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL , NULL ) ; prof -> profile_id = meter_profile_id ; memcpy ( & prof -> profile , profile , sizeof ( * profile ) ) ; LIST_INSERT_HEAD ( & priv -> profiles , prof , next ) ; return 0 ; }
Add profile to the list of profiles.
Add profile to the list of profiles .