src/dpdk/drivers/net/hns3/hns3_stats.c
int
hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
{
	struct hns3_adapter *hns = eth_dev->data->dev_private;
	struct hns3_hw *hw = &hns->hw;
	struct hns3_tqp_stats *stats = &hw->tqp_stats;
	struct hns3_rx_queue *rxq;
	uint64_t cnt;
	uint16_t i;
	int ret;

	/* Update tqp stats by read register */
	ret = hns3_update_tqp_stats(hw);
	if (ret) {
		hns3_err(hw, "Update tqp stats fail : %d", ret);
		return ret;
	}

	/* Get the error stats of received packets */
	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
		rxq = eth_dev->data->rx_queues[i];
		if (rxq) {
			cnt = rxq->err_stats.l2_errors +
				rxq->err_stats.pkt_len_errors;
			rte_stats->ierrors += cnt;
		}
	}

	rte_stats->oerrors = 0;
	/*
	 * If HW statistics are reset by stats_reset, but a lot of residual
	 * packets exist in the hardware queue and these packets are error
	 * packets, flip overflow may occurred. So return 0 in this case.
	 */
	rte_stats->ipackets =
		stats->rcb_rx_ring_pktnum_rcd > rte_stats->ierrors ?
		stats->rcb_rx_ring_pktnum_rcd - rte_stats->ierrors : 0;
	rte_stats->opackets  = stats->rcb_tx_ring_pktnum_rcd -
		rte_stats->oerrors;
	rte_stats->rx_nombuf = eth_dev->data->rx_mbuf_alloc_failed;

	return 0;
}
/*
 * Query tqp tx queue statistics ,opcode id: 0x0B03.
 * Query tqp rx queue statistics ,opcode id: 0x0B13.
 * Get all statistics of a port.
 * @param eth_dev
 *   Pointer to Ethernet device.
 * @praram rte_stats
 *   Pointer to structure rte_eth_stats.
 * @return
 *   0 on success.
 */
Query tqp tx queue statistics ,opcode id: 0x0B03.
Query tqp rx queue statistics ,opcode id: 0x0B13.
Get all statistics of a port.
@param eth_dev
Pointer to Ethernet device.
Query tqp tx queue statistics opcode id : 0x0B03 . Query tqp rx queue statistics opcode id : 0x0B13 . Get all statistics of a port . @param eth_dev Pointer to Ethernet device .
int
hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
{
	struct hns3_adapter *hns = eth_dev->data->dev_private;
	struct hns3_hw *hw = &hns->hw;
	struct hns3_tqp_stats *stats = &hw->tqp_stats;
	struct hns3_rx_queue *rxq;
	uint64_t cnt;
	uint16_t i;
	int ret;
	ret = hns3_update_tqp_stats(hw);
	if (ret) {
		hns3_err(hw, "Update tqp stats fail : %d", ret);
		return ret;
	}
	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
		rxq = eth_dev->data->rx_queues[i];
		if (rxq) {
			cnt = rxq->err_stats.l2_errors +
				rxq->err_stats.pkt_len_errors;
			rte_stats->ierrors += cnt;
		}
	}
	rte_stats->oerrors = 0;
	rte_stats->ipackets =
		stats->rcb_rx_ring_pktnum_rcd > rte_stats->ierrors ?
		stats->rcb_rx_ring_pktnum_rcd - rte_stats->ierrors : 0;
	rte_stats->opackets  = stats->rcb_tx_ring_pktnum_rcd -
		rte_stats->oerrors;
	rte_stats->rx_nombuf = eth_dev->data->rx_mbuf_alloc_failed;
	return 0;
}
int hns3_stats_get ( struct rte_eth_dev * eth_dev , struct rte_eth_stats * rte_stats ) { struct hns3_adapter * hns = eth_dev -> data -> dev_private ; struct hns3_hw * hw = & hns -> hw ; struct hns3_tqp_stats * stats = & hw -> tqp_stats ; struct hns3_rx_queue * rxq ; uint64_t cnt ; uint16_t i ; int ret ; ret = hns3_update_tqp_stats ( hw ) ; if ( ret ) { hns3_err ( hw , " " , ret ) ; return ret ; } for ( i = 0 ; i < eth_dev -> data -> nb_rx_queues ; i ++ ) { rxq = eth_dev -> data -> rx_queues [ i ] ; if ( rxq ) { cnt = rxq -> err_stats . l2_errors + rxq -> err_stats . pkt_len_errors ; rte_stats -> ierrors += cnt ; } } rte_stats -> oerrors = 0 ; rte_stats -> ipackets = stats -> rcb_rx_ring_pktnum_rcd > rte_stats -> ierrors ? stats -> rcb_rx_ring_pktnum_rcd - rte_stats -> ierrors : 0 ; rte_stats -> opackets = stats -> rcb_tx_ring_pktnum_rcd - rte_stats -> oerrors ; rte_stats -> rx_nombuf = eth_dev -> data -> rx_mbuf_alloc_failed ; return 0 ; }
Query tqp tx queue statistics ,opcode id: 0x0B03.
Query tqp tx queue statistics opcode id : 0x0B03 .
/* Update tqp stats by read register */ /* Get the error stats of received packets */ /*
	 * If HW statistics are reset by stats_reset, but a lot of residual
	 * packets exist in the hardware queue and these packets are error
	 * packets, flip overflow may occurred. So return 0 in this case.
	 */