src/dpdk/drivers/net/softnic/rte_eth_softnic_tm.c
static int
pmd_tm_shared_shaper_add_update(struct rte_eth_dev *dev,
	uint32_t shared_shaper_id,
	uint32_t shaper_profile_id,
	struct rte_tm_error *error)
{
	struct pmd_internals *p = dev->data->dev_private;
	struct tm_shared_shaper *ss;
	struct tm_shaper_profile *sp;
	struct tm_node *nt;

	/* Shaper profile must be valid. */
	sp = tm_shaper_profile_search(dev, shaper_profile_id);
	if (sp == NULL)
		return -rte_tm_error_set(error,
			EINVAL,
			RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
			NULL,
			rte_strerror(EINVAL));

	/**
	 * Add new shared shaper
	 */
	ss = tm_shared_shaper_search(dev, shared_shaper_id);
	if (ss == NULL) {
		struct tm_shared_shaper_list *ssl =
			&p->soft.tm.h.shared_shapers;

		/* Hierarchy must not be frozen */
		if (p->soft.tm.hierarchy_frozen)
			return -rte_tm_error_set(error,
				EBUSY,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EBUSY));

		/* Memory allocation */
		ss = calloc(1, sizeof(struct tm_shared_shaper));
		if (ss == NULL)
			return -rte_tm_error_set(error,
				ENOMEM,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(ENOMEM));

		/* Fill in */
		ss->shared_shaper_id = shared_shaper_id;
		ss->shaper_profile_id = shaper_profile_id;

		/* Add to list */
		TAILQ_INSERT_TAIL(ssl, ss, node);
		p->soft.tm.h.n_shared_shapers++;

		return 0;
	}

	/**
	 * Update existing shared shaper
	 */
	/* Hierarchy must be frozen (run-time update) */
	if (p->soft.tm.hierarchy_frozen == 0)
		return -rte_tm_error_set(error,
			EBUSY,
			RTE_TM_ERROR_TYPE_UNSPECIFIED,
			NULL,
			rte_strerror(EBUSY));


	/* Propagate change. */
	nt = tm_shared_shaper_get_tc(dev, ss);
	if (update_subport_tc_rate(dev, nt, ss, sp))
		return -rte_tm_error_set(error,
			EINVAL,
			RTE_TM_ERROR_TYPE_UNSPECIFIED,
			NULL,
			rte_strerror(EINVAL));

	return 0;
}
/* Traffic manager shared shaper add/update */
Traffic manager shared shaper add/update
Traffic manager shared shaper add / update
static int
pmd_tm_shared_shaper_add_update(struct rte_eth_dev *dev,
	uint32_t shared_shaper_id,
	uint32_t shaper_profile_id,
	struct rte_tm_error *error)
{
	struct pmd_internals *p = dev->data->dev_private;
	struct tm_shared_shaper *ss;
	struct tm_shaper_profile *sp;
	struct tm_node *nt;
	sp = tm_shaper_profile_search(dev, shaper_profile_id);
	if (sp == NULL)
		return -rte_tm_error_set(error,
			EINVAL,
			RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
			NULL,
			rte_strerror(EINVAL));
	ss = tm_shared_shaper_search(dev, shared_shaper_id);
	if (ss == NULL) {
		struct tm_shared_shaper_list *ssl =
			&p->soft.tm.h.shared_shapers;
		if (p->soft.tm.hierarchy_frozen)
			return -rte_tm_error_set(error,
				EBUSY,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EBUSY));
		ss = calloc(1, sizeof(struct tm_shared_shaper));
		if (ss == NULL)
			return -rte_tm_error_set(error,
				ENOMEM,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(ENOMEM));
		ss->shared_shaper_id = shared_shaper_id;
		ss->shaper_profile_id = shaper_profile_id;
		TAILQ_INSERT_TAIL(ssl, ss, node);
		p->soft.tm.h.n_shared_shapers++;
		return 0;
	}
	if (p->soft.tm.hierarchy_frozen == 0)
		return -rte_tm_error_set(error,
			EBUSY,
			RTE_TM_ERROR_TYPE_UNSPECIFIED,
			NULL,
			rte_strerror(EBUSY));
	nt = tm_shared_shaper_get_tc(dev, ss);
	if (update_subport_tc_rate(dev, nt, ss, sp))
		return -rte_tm_error_set(error,
			EINVAL,
			RTE_TM_ERROR_TYPE_UNSPECIFIED,
			NULL,
			rte_strerror(EINVAL));
	return 0;
}
static int pmd_tm_shared_shaper_add_update ( struct rte_eth_dev * dev , uint32_t shared_shaper_id , uint32_t shaper_profile_id , struct rte_tm_error * error ) { struct pmd_internals * p = dev -> data -> dev_private ; struct tm_shared_shaper * ss ; struct tm_shaper_profile * sp ; struct tm_node * nt ; sp = tm_shaper_profile_search ( dev , shaper_profile_id ) ; if ( sp == NULL ) return - rte_tm_error_set ( error , EINVAL , RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID , NULL , rte_strerror ( EINVAL ) ) ; ss = tm_shared_shaper_search ( dev , shared_shaper_id ) ; if ( ss == NULL ) { struct tm_shared_shaper_list * ssl = & p -> soft . tm . h . shared_shapers ; if ( p -> soft . tm . hierarchy_frozen ) return - rte_tm_error_set ( error , EBUSY , RTE_TM_ERROR_TYPE_UNSPECIFIED , NULL , rte_strerror ( EBUSY ) ) ; ss = calloc ( 1 , sizeof ( struct tm_shared_shaper ) ) ; if ( ss == NULL ) return - rte_tm_error_set ( error , ENOMEM , RTE_TM_ERROR_TYPE_UNSPECIFIED , NULL , rte_strerror ( ENOMEM ) ) ; ss -> shared_shaper_id = shared_shaper_id ; ss -> shaper_profile_id = shaper_profile_id ; TAILQ_INSERT_TAIL ( ssl , ss , node ) ; p -> soft . tm . h . n_shared_shapers ++ ; return 0 ; } if ( p -> soft . tm . hierarchy_frozen == 0 ) return - rte_tm_error_set ( error , EBUSY , RTE_TM_ERROR_TYPE_UNSPECIFIED , NULL , rte_strerror ( EBUSY ) ) ; nt = tm_shared_shaper_get_tc ( dev , ss ) ; if ( update_subport_tc_rate ( dev , nt , ss , sp ) ) return - rte_tm_error_set ( error , EINVAL , RTE_TM_ERROR_TYPE_UNSPECIFIED , NULL , rte_strerror ( EINVAL ) ) ; return 0 ; }
Traffic manager shared shaper add/update
Traffic manager shared shaper add / update
/* Shaper profile must be valid. */ /**
	 * Add new shared shaper
	 */ /* Hierarchy must not be frozen */ /* Memory allocation */ /* Fill in */ /* Add to list */ /**
	 * Update existing shared shaper
	 */ /* Hierarchy must be frozen (run-time update) */ /* Propagate change. */