src/dpdk/drivers/net/softnic/rte_eth_softnic_tm.c
static int
pmd_tm_node_stats_read(struct rte_eth_dev *dev,
	uint32_t node_id,
	struct rte_tm_node_stats *stats,
	uint64_t *stats_mask,
	int clear,
	struct rte_tm_error *error)
{
	struct tm_node *n;

	/* Port must be started and TM used. */
	if (dev->data->dev_started == 0 && (tm_used(dev) == 0))
		return -rte_tm_error_set(error,
			EBUSY,
			RTE_TM_ERROR_TYPE_UNSPECIFIED,
			NULL,
			rte_strerror(EBUSY));

	/* Node must be valid */
	n = tm_node_search(dev, node_id);
	if (n == NULL)
		return -rte_tm_error_set(error,
			EINVAL,
			RTE_TM_ERROR_TYPE_NODE_ID,
			NULL,
			rte_strerror(EINVAL));

	switch (n->level) {
	case TM_NODE_LEVEL_PORT:
		if (read_port_stats(dev, n, stats, stats_mask, clear))
			return -rte_tm_error_set(error,
				EINVAL,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EINVAL));
		return 0;

	case TM_NODE_LEVEL_SUBPORT:
		if (read_subport_stats(dev, n, stats, stats_mask, clear))
			return -rte_tm_error_set(error,
				EINVAL,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EINVAL));
		return 0;

	case TM_NODE_LEVEL_PIPE:
		if (read_pipe_stats(dev, n, stats, stats_mask, clear))
			return -rte_tm_error_set(error,
				EINVAL,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EINVAL));
		return 0;

	case TM_NODE_LEVEL_TC:
		if (read_tc_stats(dev, n, stats, stats_mask, clear))
			return -rte_tm_error_set(error,
				EINVAL,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EINVAL));
		return 0;

	case TM_NODE_LEVEL_QUEUE:
	default:
		if (read_queue_stats(dev, n, stats, stats_mask, clear))
			return -rte_tm_error_set(error,
				EINVAL,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EINVAL));
		return 0;
	}
}
/* Traffic manager read stats counters for specific node */
Traffic manager read stats counters for specific node
Traffic manager read stats counters for specific node
static int
pmd_tm_node_stats_read(struct rte_eth_dev *dev,
	uint32_t node_id,
	struct rte_tm_node_stats *stats,
	uint64_t *stats_mask,
	int clear,
	struct rte_tm_error *error)
{
	struct tm_node *n;
	if (dev->data->dev_started == 0 && (tm_used(dev) == 0))
		return -rte_tm_error_set(error,
			EBUSY,
			RTE_TM_ERROR_TYPE_UNSPECIFIED,
			NULL,
			rte_strerror(EBUSY));
	n = tm_node_search(dev, node_id);
	if (n == NULL)
		return -rte_tm_error_set(error,
			EINVAL,
			RTE_TM_ERROR_TYPE_NODE_ID,
			NULL,
			rte_strerror(EINVAL));
	switch (n->level) {
	case TM_NODE_LEVEL_PORT:
		if (read_port_stats(dev, n, stats, stats_mask, clear))
			return -rte_tm_error_set(error,
				EINVAL,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EINVAL));
		return 0;
	case TM_NODE_LEVEL_SUBPORT:
		if (read_subport_stats(dev, n, stats, stats_mask, clear))
			return -rte_tm_error_set(error,
				EINVAL,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EINVAL));
		return 0;
	case TM_NODE_LEVEL_PIPE:
		if (read_pipe_stats(dev, n, stats, stats_mask, clear))
			return -rte_tm_error_set(error,
				EINVAL,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EINVAL));
		return 0;
	case TM_NODE_LEVEL_TC:
		if (read_tc_stats(dev, n, stats, stats_mask, clear))
			return -rte_tm_error_set(error,
				EINVAL,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EINVAL));
		return 0;
	case TM_NODE_LEVEL_QUEUE:
	default:
		if (read_queue_stats(dev, n, stats, stats_mask, clear))
			return -rte_tm_error_set(error,
				EINVAL,
				RTE_TM_ERROR_TYPE_UNSPECIFIED,
				NULL,
				rte_strerror(EINVAL));
		return 0;
	}
}
static int pmd_tm_node_stats_read ( struct rte_eth_dev * dev , uint32_t node_id , struct rte_tm_node_stats * stats , uint64_t * stats_mask , int clear , struct rte_tm_error * error ) { struct tm_node * n ; if ( dev -> data -> dev_started == 0 && ( tm_used ( dev ) == 0 ) ) return - rte_tm_error_set ( error , EBUSY , RTE_TM_ERROR_TYPE_UNSPECIFIED , NULL , rte_strerror ( EBUSY ) ) ; n = tm_node_search ( dev , node_id ) ; if ( n == NULL ) return - rte_tm_error_set ( error , EINVAL , RTE_TM_ERROR_TYPE_NODE_ID , NULL , rte_strerror ( EINVAL ) ) ; switch ( n -> level ) { case TM_NODE_LEVEL_PORT : if ( read_port_stats ( dev , n , stats , stats_mask , clear ) ) return - rte_tm_error_set ( error , EINVAL , RTE_TM_ERROR_TYPE_UNSPECIFIED , NULL , rte_strerror ( EINVAL ) ) ; return 0 ; case TM_NODE_LEVEL_SUBPORT : if ( read_subport_stats ( dev , n , stats , stats_mask , clear ) ) return - rte_tm_error_set ( error , EINVAL , RTE_TM_ERROR_TYPE_UNSPECIFIED , NULL , rte_strerror ( EINVAL ) ) ; return 0 ; case TM_NODE_LEVEL_PIPE : if ( read_pipe_stats ( dev , n , stats , stats_mask , clear ) ) return - rte_tm_error_set ( error , EINVAL , RTE_TM_ERROR_TYPE_UNSPECIFIED , NULL , rte_strerror ( EINVAL ) ) ; return 0 ; case TM_NODE_LEVEL_TC : if ( read_tc_stats ( dev , n , stats , stats_mask , clear ) ) return - rte_tm_error_set ( error , EINVAL , RTE_TM_ERROR_TYPE_UNSPECIFIED , NULL , rte_strerror ( EINVAL ) ) ; return 0 ; case TM_NODE_LEVEL_QUEUE : default : if ( read_queue_stats ( dev , n , stats , stats_mask , clear ) ) return - rte_tm_error_set ( error , EINVAL , RTE_TM_ERROR_TYPE_UNSPECIFIED , NULL , rte_strerror ( EINVAL ) ) ; return 0 ; } }
Traffic manager read stats counters for specific node
Traffic manager read stats counters for specific node
/* Port must be started and TM used. */ /* Node must be valid */