src/dpdk/drivers/net/mlx5/mlx5_stats.c
int
mlx5_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats,
		unsigned int n)
{
	struct mlx5_priv *priv = dev->data->dev_private;
	unsigned int i;
	uint64_t counters[n];
	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
	uint16_t mlx5_stats_n = xstats_ctrl->mlx5_stats_n;

	if (n >= mlx5_stats_n && stats) {
		int stats_n;
		int ret;

		stats_n = mlx5_os_get_stats_n(dev);
		if (stats_n < 0)
			return stats_n;
		if (xstats_ctrl->stats_n != stats_n)
			mlx5_os_stats_init(dev);
		ret = mlx5_os_read_dev_counters(dev, counters);
		if (ret)
			return ret;
		for (i = 0; i != mlx5_stats_n; ++i) {
			stats[i].id = i;
			if (xstats_ctrl->info[i].dev) {
				uint64_t wrap_n;
				uint64_t hw_stat = xstats_ctrl->hw_stats[i];

				stats[i].value = (counters[i] -
						  xstats_ctrl->base[i]) &
						  (uint64_t)UINT32_MAX;
				wrap_n = hw_stat >> 32;
				if (stats[i].value <
					    (hw_stat & (uint64_t)UINT32_MAX))
					wrap_n++;
				stats[i].value |= (wrap_n) << 32;
				xstats_ctrl->hw_stats[i] = stats[i].value;
			} else {
				stats[i].value =
					(counters[i] - xstats_ctrl->base[i]);
			}
		}
	}
	mlx5_stats_n = mlx5_txpp_xstats_get(dev, stats, n, mlx5_stats_n);
	return mlx5_stats_n;
}
/**
 * DPDK callback to get extended device statistics.
 *
 * @param dev
 *   Pointer to Ethernet device.
 * @param[out] stats
 *   Pointer to rte extended stats table.
 * @param n
 *   The size of the stats table.
 *
 * @return
 *   Number of extended stats on success and stats is filled,
 *   negative on error and rte_errno is set.
 */
DPDK callback to get extended device statistics.
@param dev
Pointer to Ethernet device.
@param[out] stats
Pointer to rte extended stats table.
@param n
The size of the stats table.

@return
Number of extended stats on success and stats is filled,
negative on error and rte_errno is set.
DPDK callback to get extended device statistics . @param dev Pointer to Ethernet device . @param [ out ] stats Pointer to rte extended stats table . @param n The size of the stats table . @return Number of extended stats on success and stats is filled negative on error and rte_errno is set .
int
mlx5_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats,
		unsigned int n)
{
	struct mlx5_priv *priv = dev->data->dev_private;
	unsigned int i;
	uint64_t counters[n];
	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
	uint16_t mlx5_stats_n = xstats_ctrl->mlx5_stats_n;
	if (n >= mlx5_stats_n && stats) {
		int stats_n;
		int ret;
		stats_n = mlx5_os_get_stats_n(dev);
		if (stats_n < 0)
			return stats_n;
		if (xstats_ctrl->stats_n != stats_n)
			mlx5_os_stats_init(dev);
		ret = mlx5_os_read_dev_counters(dev, counters);
		if (ret)
			return ret;
		for (i = 0; i != mlx5_stats_n; ++i) {
			stats[i].id = i;
			if (xstats_ctrl->info[i].dev) {
				uint64_t wrap_n;
				uint64_t hw_stat = xstats_ctrl->hw_stats[i];
				stats[i].value = (counters[i] -
						  xstats_ctrl->base[i]) &
						  (uint64_t)UINT32_MAX;
				wrap_n = hw_stat >> 32;
				if (stats[i].value <
					    (hw_stat & (uint64_t)UINT32_MAX))
					wrap_n++;
				stats[i].value |= (wrap_n) << 32;
				xstats_ctrl->hw_stats[i] = stats[i].value;
			} else {
				stats[i].value =
					(counters[i] - xstats_ctrl->base[i]);
			}
		}
	}
	mlx5_stats_n = mlx5_txpp_xstats_get(dev, stats, n, mlx5_stats_n);
	return mlx5_stats_n;
}
int mlx5_xstats_get ( struct rte_eth_dev * dev , struct rte_eth_xstat * stats , unsigned int n ) { struct mlx5_priv * priv = dev -> data -> dev_private ; unsigned int i ; uint64_t counters [ n ] ; struct mlx5_xstats_ctrl * xstats_ctrl = & priv -> xstats_ctrl ; uint16_t mlx5_stats_n = xstats_ctrl -> mlx5_stats_n ; if ( n >= mlx5_stats_n && stats ) { int stats_n ; int ret ; stats_n = mlx5_os_get_stats_n ( dev ) ; if ( stats_n < 0 ) return stats_n ; if ( xstats_ctrl -> stats_n != stats_n ) mlx5_os_stats_init ( dev ) ; ret = mlx5_os_read_dev_counters ( dev , counters ) ; if ( ret ) return ret ; for ( i = 0 ; i != mlx5_stats_n ; ++ i ) { stats [ i ] . id = i ; if ( xstats_ctrl -> info [ i ] . dev ) { uint64_t wrap_n ; uint64_t hw_stat = xstats_ctrl -> hw_stats [ i ] ; stats [ i ] . value = ( counters [ i ] - xstats_ctrl -> base [ i ] ) & ( uint64_t ) UINT32_MAX ; wrap_n = hw_stat >> 32 ; if ( stats [ i ] . value < ( hw_stat & ( uint64_t ) UINT32_MAX ) ) wrap_n ++ ; stats [ i ] . value |= ( wrap_n ) << 32 ; xstats_ctrl -> hw_stats [ i ] = stats [ i ] . value ; } else { stats [ i ] . value = ( counters [ i ] - xstats_ctrl -> base [ i ] ) ; } } } mlx5_stats_n = mlx5_txpp_xstats_get ( dev , stats , n , mlx5_stats_n ) ; return mlx5_stats_n ; }
DPDK callback to get extended device statistics.
DPDK callback to get extended device statistics .