1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018-2019 Hisilicon Limited.
9 #define HNS3_MAC_CMD_NUM 21
10 #define HNS3_RD_FIRST_STATS_NUM 2
11 #define HNS3_RD_OTHER_STATS_NUM 4
12 #define HNS3_VALUES_BYTES 8
15 struct hns3_tqp_stats {
16 uint64_t rcb_tx_ring_pktnum_rcd; /* Total num of transmitted packets */
17 uint64_t rcb_rx_ring_pktnum_rcd; /* Total num of received packets */
18 uint64_t rcb_tx_ring_pktnum[HNS3_MAX_TQP_NUM_PER_FUNC];
19 uint64_t rcb_rx_ring_pktnum[HNS3_MAX_TQP_NUM_PER_FUNC];
22 /* mac stats, Statistics counters collected by the MAC, opcode id: 0x0032 */
23 struct hns3_mac_stats {
24 uint64_t mac_tx_mac_pause_num;
25 uint64_t mac_rx_mac_pause_num;
26 uint64_t mac_tx_pfc_pri0_pkt_num;
27 uint64_t mac_tx_pfc_pri1_pkt_num;
28 uint64_t mac_tx_pfc_pri2_pkt_num;
29 uint64_t mac_tx_pfc_pri3_pkt_num;
30 uint64_t mac_tx_pfc_pri4_pkt_num;
31 uint64_t mac_tx_pfc_pri5_pkt_num;
32 uint64_t mac_tx_pfc_pri6_pkt_num;
33 uint64_t mac_tx_pfc_pri7_pkt_num;
34 uint64_t mac_rx_pfc_pri0_pkt_num;
35 uint64_t mac_rx_pfc_pri1_pkt_num;
36 uint64_t mac_rx_pfc_pri2_pkt_num;
37 uint64_t mac_rx_pfc_pri3_pkt_num;
38 uint64_t mac_rx_pfc_pri4_pkt_num;
39 uint64_t mac_rx_pfc_pri5_pkt_num;
40 uint64_t mac_rx_pfc_pri6_pkt_num;
41 uint64_t mac_rx_pfc_pri7_pkt_num;
42 uint64_t mac_tx_total_pkt_num;
43 uint64_t mac_tx_total_oct_num;
44 uint64_t mac_tx_good_pkt_num;
45 uint64_t mac_tx_bad_pkt_num;
46 uint64_t mac_tx_good_oct_num;
47 uint64_t mac_tx_bad_oct_num;
48 uint64_t mac_tx_uni_pkt_num;
49 uint64_t mac_tx_multi_pkt_num;
50 uint64_t mac_tx_broad_pkt_num;
51 uint64_t mac_tx_undersize_pkt_num;
52 uint64_t mac_tx_oversize_pkt_num;
53 uint64_t mac_tx_64_oct_pkt_num;
54 uint64_t mac_tx_65_127_oct_pkt_num;
55 uint64_t mac_tx_128_255_oct_pkt_num;
56 uint64_t mac_tx_256_511_oct_pkt_num;
57 uint64_t mac_tx_512_1023_oct_pkt_num;
58 uint64_t mac_tx_1024_1518_oct_pkt_num;
59 uint64_t mac_tx_1519_2047_oct_pkt_num;
60 uint64_t mac_tx_2048_4095_oct_pkt_num;
61 uint64_t mac_tx_4096_8191_oct_pkt_num;
63 uint64_t mac_tx_8192_9216_oct_pkt_num;
64 uint64_t mac_tx_9217_12287_oct_pkt_num;
65 uint64_t mac_tx_12288_16383_oct_pkt_num;
66 uint64_t mac_tx_1519_max_good_oct_pkt_num;
67 uint64_t mac_tx_1519_max_bad_oct_pkt_num;
69 uint64_t mac_rx_total_pkt_num;
70 uint64_t mac_rx_total_oct_num;
71 uint64_t mac_rx_good_pkt_num;
72 uint64_t mac_rx_bad_pkt_num;
73 uint64_t mac_rx_good_oct_num;
74 uint64_t mac_rx_bad_oct_num;
75 uint64_t mac_rx_uni_pkt_num;
76 uint64_t mac_rx_multi_pkt_num;
77 uint64_t mac_rx_broad_pkt_num;
78 uint64_t mac_rx_undersize_pkt_num;
79 uint64_t mac_rx_oversize_pkt_num;
80 uint64_t mac_rx_64_oct_pkt_num;
81 uint64_t mac_rx_65_127_oct_pkt_num;
82 uint64_t mac_rx_128_255_oct_pkt_num;
83 uint64_t mac_rx_256_511_oct_pkt_num;
84 uint64_t mac_rx_512_1023_oct_pkt_num;
85 uint64_t mac_rx_1024_1518_oct_pkt_num;
86 uint64_t mac_rx_1519_2047_oct_pkt_num;
87 uint64_t mac_rx_2048_4095_oct_pkt_num;
88 uint64_t mac_rx_4096_8191_oct_pkt_num;
90 uint64_t mac_rx_8192_9216_oct_pkt_num;
91 uint64_t mac_rx_9217_12287_oct_pkt_num;
92 uint64_t mac_rx_12288_16383_oct_pkt_num;
93 uint64_t mac_rx_1519_max_good_oct_pkt_num;
94 uint64_t mac_rx_1519_max_bad_oct_pkt_num;
96 uint64_t mac_tx_fragment_pkt_num;
97 uint64_t mac_tx_undermin_pkt_num;
98 uint64_t mac_tx_jabber_pkt_num;
99 uint64_t mac_tx_err_all_pkt_num;
100 uint64_t mac_tx_from_app_good_pkt_num;
101 uint64_t mac_tx_from_app_bad_pkt_num;
102 uint64_t mac_rx_fragment_pkt_num;
103 uint64_t mac_rx_undermin_pkt_num;
104 uint64_t mac_rx_jabber_pkt_num;
105 uint64_t mac_rx_fcs_err_pkt_num;
106 uint64_t mac_rx_send_app_good_pkt_num;
107 uint64_t mac_rx_send_app_bad_pkt_num;
108 uint64_t mac_tx_pfc_pause_pkt_num;
109 uint64_t mac_rx_pfc_pause_pkt_num;
110 uint64_t mac_tx_ctrl_pkt_num;
111 uint64_t mac_rx_ctrl_pkt_num;
114 /* store statistics names and its offset in stats structure */
115 struct hns3_xstats_name_offset {
116 char name[RTE_ETH_XSTATS_NAME_SIZE];
120 #define HNS3_MAC_STATS_OFFSET(f) \
121 (offsetof(struct hns3_mac_stats, f))
123 #define HNS3_ERR_INT_STATS_FIELD_OFFSET(f) \
124 (offsetof(struct hns3_err_msix_intr_stats, f))
126 struct hns3_reset_stats;
127 #define HNS3_RESET_STATS_FIELD_OFFSET(f) \
128 (offsetof(struct hns3_reset_stats, f))
130 #define HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(f) \
131 (offsetof(struct hns3_rx_queue, f))
133 #define HNS3_TX_ERROR_STATS_FIELD_OFFSET(f) \
134 (offsetof(struct hns3_tx_queue, f))
136 int hns3_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats);
137 int hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
139 int hns3_dev_xstats_reset(struct rte_eth_dev *dev);
140 int hns3_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
141 struct rte_eth_xstat_name *xstats_names,
142 __rte_unused unsigned int size);
143 int hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev,
144 __rte_unused const uint64_t *ids,
145 __rte_unused uint64_t *values,
147 int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
148 struct rte_eth_xstat_name *xstats_names,
151 int hns3_stats_reset(struct rte_eth_dev *dev);
152 #endif /* _HNS3_STATS_H_ */