src/dpdk/drivers/net/mlx5/mlx5_stats.c
int
mlx5_xstats_reset(struct rte_eth_dev *dev)
{
	struct mlx5_priv *priv = dev->data->dev_private;
	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
	int stats_n;
	unsigned int i;
	uint64_t *counters;
	int ret;

	stats_n = mlx5_os_get_stats_n(dev);
	if (stats_n < 0) {
		DRV_LOG(ERR, "port %u cannot get stats: %s", dev->data->port_id,
			strerror(-stats_n));
		return stats_n;
	}
	if (xstats_ctrl->stats_n != stats_n)
		mlx5_os_stats_init(dev);
	counters =  mlx5_malloc(MLX5_MEM_SYS, sizeof(*counters) *
			xstats_ctrl->mlx5_stats_n, 0,
			SOCKET_ID_ANY);
	if (!counters) {
		DRV_LOG(WARNING, "port %u unable to allocate memory for xstats "
				"counters",
		     dev->data->port_id);
		rte_errno = ENOMEM;
		return -rte_errno;
	}
	ret = mlx5_os_read_dev_counters(dev, counters);
	if (ret) {
		DRV_LOG(ERR, "port %u cannot read device counters: %s",
			dev->data->port_id, strerror(rte_errno));
		mlx5_free(counters);
		return ret;
	}
	for (i = 0; i != xstats_ctrl->mlx5_stats_n; ++i) {
		xstats_ctrl->base[i] = counters[i];
		xstats_ctrl->hw_stats[i] = 0;
	}
	mlx5_txpp_xstats_reset(dev);
	mlx5_free(counters);
	return 0;
}
/**
 * DPDK callback to clear device extended statistics.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 *
 * @return
 *   0 on success and stats is reset, negative errno value otherwise and
 *   rte_errno is set.
 */
DPDK callback to clear device extended statistics.
@param dev
Pointer to Ethernet device structure.

@return
0 on success and stats is reset, negative errno value otherwise and
rte_errno is set.
DPDK callback to clear device extended statistics . @param dev Pointer to Ethernet device structure . @return 0 on success and stats is reset negative errno value otherwise and rte_errno is set .
int
mlx5_xstats_reset(struct rte_eth_dev *dev)
{
	struct mlx5_priv *priv = dev->data->dev_private;
	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
	int stats_n;
	unsigned int i;
	uint64_t *counters;
	int ret;
	stats_n = mlx5_os_get_stats_n(dev);
	if (stats_n < 0) {
		DRV_LOG(ERR, "port %u cannot get stats: %s", dev->data->port_id,
			strerror(-stats_n));
		return stats_n;
	}
	if (xstats_ctrl->stats_n != stats_n)
		mlx5_os_stats_init(dev);
	counters =  mlx5_malloc(MLX5_MEM_SYS, sizeof(*counters) *
			xstats_ctrl->mlx5_stats_n, 0,
			SOCKET_ID_ANY);
	if (!counters) {
		DRV_LOG(WARNING, "port %u unable to allocate memory for xstats "
				"counters",
		     dev->data->port_id);
		rte_errno = ENOMEM;
		return -rte_errno;
	}
	ret = mlx5_os_read_dev_counters(dev, counters);
	if (ret) {
		DRV_LOG(ERR, "port %u cannot read device counters: %s",
			dev->data->port_id, strerror(rte_errno));
		mlx5_free(counters);
		return ret;
	}
	for (i = 0; i != xstats_ctrl->mlx5_stats_n; ++i) {
		xstats_ctrl->base[i] = counters[i];
		xstats_ctrl->hw_stats[i] = 0;
	}
	mlx5_txpp_xstats_reset(dev);
	mlx5_free(counters);
	return 0;
}
int mlx5_xstats_reset ( struct rte_eth_dev * dev ) { struct mlx5_priv * priv = dev -> data -> dev_private ; struct mlx5_xstats_ctrl * xstats_ctrl = & priv -> xstats_ctrl ; int stats_n ; unsigned int i ; uint64_t * counters ; int ret ; stats_n = mlx5_os_get_stats_n ( dev ) ; if ( stats_n < 0 ) { DRV_LOG ( ERR , " " , dev -> data -> port_id , strerror ( - stats_n ) ) ; return stats_n ; } if ( xstats_ctrl -> stats_n != stats_n ) mlx5_os_stats_init ( dev ) ; counters = mlx5_malloc ( MLX5_MEM_SYS , sizeof ( * counters ) * xstats_ctrl -> mlx5_stats_n , 0 , SOCKET_ID_ANY ) ; if ( ! counters ) { DRV_LOG ( WARNING , " " " " , dev -> data -> port_id ) ; rte_errno = ENOMEM ; return - rte_errno ; } ret = mlx5_os_read_dev_counters ( dev , counters ) ; if ( ret ) { DRV_LOG ( ERR , " " , dev -> data -> port_id , strerror ( rte_errno ) ) ; mlx5_free ( counters ) ; return ret ; } for ( i = 0 ; i != xstats_ctrl -> mlx5_stats_n ; ++ i ) { xstats_ctrl -> base [ i ] = counters [ i ] ; xstats_ctrl -> hw_stats [ i ] = 0 ; } mlx5_txpp_xstats_reset ( dev ) ; mlx5_free ( counters ) ; return 0 ; }
DPDK callback to clear device extended statistics.
DPDK callback to clear device extended statistics .