src/dpdk/drivers/net/hinic/hinic_pmd_ethdev.c
static int hinic_dev_xstats_get(struct rte_eth_dev *dev,
			 struct rte_eth_xstat *xstats,
			 unsigned int n)
{
	u16 qid = 0;
	u32 i;
	int err, count;
	struct hinic_nic_dev *nic_dev;
	struct hinic_phy_port_stats port_stats;
	struct hinic_vport_stats vport_stats;
	struct hinic_rxq	*rxq = NULL;
	struct hinic_rxq_stats rxq_stats;
	struct hinic_txq	*txq = NULL;
	struct hinic_txq_stats txq_stats;

	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
	count = hinic_xstats_calc_num(nic_dev);
	if ((int)n < count)
		return count;

	count = 0;

	/* Get stats from hinic_rxq_stats */
	for (qid = 0; qid < nic_dev->num_rq; qid++) {
		rxq = nic_dev->rxqs[qid];
		hinic_rxq_get_stats(rxq, &rxq_stats);

		for (i = 0; i < HINIC_RXQ_XSTATS_NUM; i++) {
			xstats[count].value =
				*(uint64_t *)(((char *)&rxq_stats) +
				hinic_rxq_stats_strings[i].offset);
			xstats[count].id = count;
			count++;
		}
	}

	/* Get stats from hinic_txq_stats */
	for (qid = 0; qid < nic_dev->num_sq; qid++) {
		txq = nic_dev->txqs[qid];
		hinic_txq_get_stats(txq, &txq_stats);

		for (i = 0; i < HINIC_TXQ_XSTATS_NUM; i++) {
			xstats[count].value =
				*(uint64_t *)(((char *)&txq_stats) +
				hinic_txq_stats_strings[i].offset);
			xstats[count].id = count;
			count++;
		}
	}

	/* Get stats from hinic_vport_stats */
	err = hinic_get_vport_stats(nic_dev->hwdev, &vport_stats);
	if (err)
		return err;

	for (i = 0; i < HINIC_VPORT_XSTATS_NUM; i++) {
		xstats[count].value =
			*(uint64_t *)(((char *)&vport_stats) +
			hinic_vport_stats_strings[i].offset);
		xstats[count].id = count;
		count++;
	}

	if (HINIC_IS_VF(nic_dev->hwdev))
		return count;

	/* Get stats from hinic_phy_port_stats */
	err = hinic_get_phy_port_stats(nic_dev->hwdev, &port_stats);
	if (err)
		return err;

	for (i = 0; i < HINIC_PHYPORT_XSTATS_NUM; i++) {
		xstats[count].value = *(uint64_t *)(((char *)&port_stats) +
				hinic_phyport_stats_strings[i].offset);
		xstats[count].id = count;
		count++;
	}

	return count;
}
/**
 * DPDK callback to get extended device statistics.
 *
 * @param dev
 *   Pointer to Ethernet device.
 * @param xstats
 *   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 error value otherwise.
 */
DPDK callback to get extended device statistics.
@param dev
Pointer to Ethernet device.
@param xstats
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 error value otherwise.
DPDK callback to get extended device statistics . @param dev Pointer to Ethernet device . @param xstats 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 error value otherwise .
static int hinic_dev_xstats_get(struct rte_eth_dev *dev,
			 struct rte_eth_xstat *xstats,
			 unsigned int n)
{
	u16 qid = 0;
	u32 i;
	int err, count;
	struct hinic_nic_dev *nic_dev;
	struct hinic_phy_port_stats port_stats;
	struct hinic_vport_stats vport_stats;
	struct hinic_rxq	*rxq = NULL;
	struct hinic_rxq_stats rxq_stats;
	struct hinic_txq	*txq = NULL;
	struct hinic_txq_stats txq_stats;
	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
	count = hinic_xstats_calc_num(nic_dev);
	if ((int)n < count)
		return count;
	count = 0;
	for (qid = 0; qid < nic_dev->num_rq; qid++) {
		rxq = nic_dev->rxqs[qid];
		hinic_rxq_get_stats(rxq, &rxq_stats);
		for (i = 0; i < HINIC_RXQ_XSTATS_NUM; i++) {
			xstats[count].value =
				*(uint64_t *)(((char *)&rxq_stats) +
				hinic_rxq_stats_strings[i].offset);
			xstats[count].id = count;
			count++;
		}
	}
	for (qid = 0; qid < nic_dev->num_sq; qid++) {
		txq = nic_dev->txqs[qid];
		hinic_txq_get_stats(txq, &txq_stats);
		for (i = 0; i < HINIC_TXQ_XSTATS_NUM; i++) {
			xstats[count].value =
				*(uint64_t *)(((char *)&txq_stats) +
				hinic_txq_stats_strings[i].offset);
			xstats[count].id = count;
			count++;
		}
	}
	err = hinic_get_vport_stats(nic_dev->hwdev, &vport_stats);
	if (err)
		return err;
	for (i = 0; i < HINIC_VPORT_XSTATS_NUM; i++) {
		xstats[count].value =
			*(uint64_t *)(((char *)&vport_stats) +
			hinic_vport_stats_strings[i].offset);
		xstats[count].id = count;
		count++;
	}
	if (HINIC_IS_VF(nic_dev->hwdev))
		return count;
	err = hinic_get_phy_port_stats(nic_dev->hwdev, &port_stats);
	if (err)
		return err;
	for (i = 0; i < HINIC_PHYPORT_XSTATS_NUM; i++) {
		xstats[count].value = *(uint64_t *)(((char *)&port_stats) +
				hinic_phyport_stats_strings[i].offset);
		xstats[count].id = count;
		count++;
	}
	return count;
}
static int hinic_dev_xstats_get ( struct rte_eth_dev * dev , struct rte_eth_xstat * xstats , unsigned int n ) { u16 qid = 0 ; u32 i ; int err , count ; struct hinic_nic_dev * nic_dev ; struct hinic_phy_port_stats port_stats ; struct hinic_vport_stats vport_stats ; struct hinic_rxq * rxq = NULL ; struct hinic_rxq_stats rxq_stats ; struct hinic_txq * txq = NULL ; struct hinic_txq_stats txq_stats ; nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV ( dev ) ; count = hinic_xstats_calc_num ( nic_dev ) ; if ( ( int ) n < count ) return count ; count = 0 ; for ( qid = 0 ; qid < nic_dev -> num_rq ; qid ++ ) { rxq = nic_dev -> rxqs [ qid ] ; hinic_rxq_get_stats ( rxq , & rxq_stats ) ; for ( i = 0 ; i < HINIC_RXQ_XSTATS_NUM ; i ++ ) { xstats [ count ] . value = * ( uint64_t * ) ( ( ( char * ) & rxq_stats ) + hinic_rxq_stats_strings [ i ] . offset ) ; xstats [ count ] . id = count ; count ++ ; } } for ( qid = 0 ; qid < nic_dev -> num_sq ; qid ++ ) { txq = nic_dev -> txqs [ qid ] ; hinic_txq_get_stats ( txq , & txq_stats ) ; for ( i = 0 ; i < HINIC_TXQ_XSTATS_NUM ; i ++ ) { xstats [ count ] . value = * ( uint64_t * ) ( ( ( char * ) & txq_stats ) + hinic_txq_stats_strings [ i ] . offset ) ; xstats [ count ] . id = count ; count ++ ; } } err = hinic_get_vport_stats ( nic_dev -> hwdev , & vport_stats ) ; if ( err ) return err ; for ( i = 0 ; i < HINIC_VPORT_XSTATS_NUM ; i ++ ) { xstats [ count ] . value = * ( uint64_t * ) ( ( ( char * ) & vport_stats ) + hinic_vport_stats_strings [ i ] . offset ) ; xstats [ count ] . id = count ; count ++ ; } if ( HINIC_IS_VF ( nic_dev -> hwdev ) ) return count ; err = hinic_get_phy_port_stats ( nic_dev -> hwdev , & port_stats ) ; if ( err ) return err ; for ( i = 0 ; i < HINIC_PHYPORT_XSTATS_NUM ; i ++ ) { xstats [ count ] . value = * ( uint64_t * ) ( ( ( char * ) & port_stats ) + hinic_phyport_stats_strings [ i ] . offset ) ; xstats [ count ] . id = count ; count ++ ; } return count ; }
DPDK callback to get extended device statistics.
DPDK callback to get extended device statistics .
/* Get stats from hinic_rxq_stats */ /* Get stats from hinic_txq_stats */ /* Get stats from hinic_vport_stats */ /* Get stats from hinic_phy_port_stats */