src/dpdk/drivers/net/ena/ena_ethdev.c
static int ena_xstats_get(struct rte_eth_dev *dev,
			  struct rte_eth_xstat *xstats,
			  unsigned int n)
{
	struct ena_adapter *adapter = dev->data->dev_private;
	unsigned int xstats_count = ena_xstats_calc_num(dev);
	unsigned int stat, i, count = 0;
	int stat_offset;
	void *stats_begin;

	if (n < xstats_count)
		return xstats_count;

	if (!xstats)
		return 0;

	for (stat = 0; stat < ENA_STATS_ARRAY_GLOBAL; stat++, count++) {
		stat_offset = ena_stats_global_strings[stat].stat_offset;
		stats_begin = &adapter->dev_stats;

		xstats[count].id = count;
		xstats[count].value = *((uint64_t *)
			((char *)stats_begin + stat_offset));
	}

	/* Even if the function below fails, we should copy previous (or initial
	 * values) to keep structure of rte_eth_xstat consistent.
	 */
	ena_copy_eni_stats(adapter);
	for (stat = 0; stat < ENA_STATS_ARRAY_ENI; stat++, count++) {
		stat_offset = ena_stats_eni_strings[stat].stat_offset;
		stats_begin = &adapter->eni_stats;

		xstats[count].id = count;
		xstats[count].value = *((uint64_t *)
		    ((char *)stats_begin + stat_offset));
	}

	for (stat = 0; stat < ENA_STATS_ARRAY_RX; stat++) {
		for (i = 0; i < dev->data->nb_rx_queues; i++, count++) {
			stat_offset = ena_stats_rx_strings[stat].stat_offset;
			stats_begin = &adapter->rx_ring[i].rx_stats;

			xstats[count].id = count;
			xstats[count].value = *((uint64_t *)
				((char *)stats_begin + stat_offset));
		}
	}

	for (stat = 0; stat < ENA_STATS_ARRAY_TX; stat++) {
		for (i = 0; i < dev->data->nb_tx_queues; i++, count++) {
			stat_offset = ena_stats_tx_strings[stat].stat_offset;
			stats_begin = &adapter->tx_ring[i].rx_stats;

			xstats[count].id = count;
			xstats[count].value = *((uint64_t *)
				((char *)stats_begin + stat_offset));
		}
	}

	return count;
}
/**
 * DPDK callback to get extended device statistics.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 * @param[out] stats
 *   Stats table output buffer.
 * @param n
 *   The size of the stats table.
 *
 * @return
 *   Number of xstats on success, negative on failure.
 */
DPDK callback to get extended device statistics.
@param dev
Pointer to Ethernet device structure.
@param[out] stats
Stats table output buffer.
@param n
The size of the stats table.

@return
Number of xstats on success, negative on failure.
DPDK callback to get extended device statistics . @param dev Pointer to Ethernet device structure . @param [ out ] stats Stats table output buffer . @param n The size of the stats table . @return Number of xstats on success negative on failure .
static int ena_xstats_get(struct rte_eth_dev *dev,
			  struct rte_eth_xstat *xstats,
			  unsigned int n)
{
	struct ena_adapter *adapter = dev->data->dev_private;
	unsigned int xstats_count = ena_xstats_calc_num(dev);
	unsigned int stat, i, count = 0;
	int stat_offset;
	void *stats_begin;
	if (n < xstats_count)
		return xstats_count;
	if (!xstats)
		return 0;
	for (stat = 0; stat < ENA_STATS_ARRAY_GLOBAL; stat++, count++) {
		stat_offset = ena_stats_global_strings[stat].stat_offset;
		stats_begin = &adapter->dev_stats;
		xstats[count].id = count;
		xstats[count].value = *((uint64_t *)
			((char *)stats_begin + stat_offset));
	}
	ena_copy_eni_stats(adapter);
	for (stat = 0; stat < ENA_STATS_ARRAY_ENI; stat++, count++) {
		stat_offset = ena_stats_eni_strings[stat].stat_offset;
		stats_begin = &adapter->eni_stats;
		xstats[count].id = count;
		xstats[count].value = *((uint64_t *)
		    ((char *)stats_begin + stat_offset));
	}
	for (stat = 0; stat < ENA_STATS_ARRAY_RX; stat++) {
		for (i = 0; i < dev->data->nb_rx_queues; i++, count++) {
			stat_offset = ena_stats_rx_strings[stat].stat_offset;
			stats_begin = &adapter->rx_ring[i].rx_stats;
			xstats[count].id = count;
			xstats[count].value = *((uint64_t *)
				((char *)stats_begin + stat_offset));
		}
	}
	for (stat = 0; stat < ENA_STATS_ARRAY_TX; stat++) {
		for (i = 0; i < dev->data->nb_tx_queues; i++, count++) {
			stat_offset = ena_stats_tx_strings[stat].stat_offset;
			stats_begin = &adapter->tx_ring[i].rx_stats;
			xstats[count].id = count;
			xstats[count].value = *((uint64_t *)
				((char *)stats_begin + stat_offset));
		}
	}
	return count;
}
static int ena_xstats_get ( struct rte_eth_dev * dev , struct rte_eth_xstat * xstats , unsigned int n ) { struct ena_adapter * adapter = dev -> data -> dev_private ; unsigned int xstats_count = ena_xstats_calc_num ( dev ) ; unsigned int stat , i , count = 0 ; int stat_offset ; void * stats_begin ; if ( n < xstats_count ) return xstats_count ; if ( ! xstats ) return 0 ; for ( stat = 0 ; stat < ENA_STATS_ARRAY_GLOBAL ; stat ++ , count ++ ) { stat_offset = ena_stats_global_strings [ stat ] . stat_offset ; stats_begin = & adapter -> dev_stats ; xstats [ count ] . id = count ; xstats [ count ] . value = * ( ( uint64_t * ) ( ( char * ) stats_begin + stat_offset ) ) ; } ena_copy_eni_stats ( adapter ) ; for ( stat = 0 ; stat < ENA_STATS_ARRAY_ENI ; stat ++ , count ++ ) { stat_offset = ena_stats_eni_strings [ stat ] . stat_offset ; stats_begin = & adapter -> eni_stats ; xstats [ count ] . id = count ; xstats [ count ] . value = * ( ( uint64_t * ) ( ( char * ) stats_begin + stat_offset ) ) ; } for ( stat = 0 ; stat < ENA_STATS_ARRAY_RX ; stat ++ ) { for ( i = 0 ; i < dev -> data -> nb_rx_queues ; i ++ , count ++ ) { stat_offset = ena_stats_rx_strings [ stat ] . stat_offset ; stats_begin = & adapter -> rx_ring [ i ] . rx_stats ; xstats [ count ] . id = count ; xstats [ count ] . value = * ( ( uint64_t * ) ( ( char * ) stats_begin + stat_offset ) ) ; } } for ( stat = 0 ; stat < ENA_STATS_ARRAY_TX ; stat ++ ) { for ( i = 0 ; i < dev -> data -> nb_tx_queues ; i ++ , count ++ ) { stat_offset = ena_stats_tx_strings [ stat ] . stat_offset ; stats_begin = & adapter -> tx_ring [ i ] . rx_stats ; xstats [ count ] . id = count ; xstats [ count ] . value = * ( ( uint64_t * ) ( ( char * ) stats_begin + stat_offset ) ) ; } } return count ; }
DPDK callback to get extended device statistics.
DPDK callback to get extended device statistics .
/* Even if the function below fails, we should copy previous (or initial
	 * values) to keep structure of rte_eth_xstat consistent.
	 */