1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018-2019 Hisilicon Limited.
5 #include <rte_ethdev.h>
7 #include <rte_malloc.h>
9 #include "hns3_ethdev.h"
10 #include "hns3_rxtx.h"
11 #include "hns3_logs.h"
12 #include "hns3_regs.h"
15 static const struct hns3_xstats_name_offset hns3_mac_strings[] = {
16 {"mac_tx_mac_pause_num",
17 HNS3_MAC_STATS_OFFSET(mac_tx_mac_pause_num)},
18 {"mac_rx_mac_pause_num",
19 HNS3_MAC_STATS_OFFSET(mac_rx_mac_pause_num)},
20 {"mac_tx_control_pkt_num",
21 HNS3_MAC_STATS_OFFSET(mac_tx_ctrl_pkt_num)},
22 {"mac_rx_control_pkt_num",
23 HNS3_MAC_STATS_OFFSET(mac_rx_ctrl_pkt_num)},
24 {"mac_tx_pfc_pkt_num",
25 HNS3_MAC_STATS_OFFSET(mac_tx_pfc_pause_pkt_num)},
26 {"mac_tx_pfc_pri0_pkt_num",
27 HNS3_MAC_STATS_OFFSET(mac_tx_pfc_pri0_pkt_num)},
28 {"mac_tx_pfc_pri1_pkt_num",
29 HNS3_MAC_STATS_OFFSET(mac_tx_pfc_pri1_pkt_num)},
30 {"mac_tx_pfc_pri2_pkt_num",
31 HNS3_MAC_STATS_OFFSET(mac_tx_pfc_pri2_pkt_num)},
32 {"mac_tx_pfc_pri3_pkt_num",
33 HNS3_MAC_STATS_OFFSET(mac_tx_pfc_pri3_pkt_num)},
34 {"mac_tx_pfc_pri4_pkt_num",
35 HNS3_MAC_STATS_OFFSET(mac_tx_pfc_pri4_pkt_num)},
36 {"mac_tx_pfc_pri5_pkt_num",
37 HNS3_MAC_STATS_OFFSET(mac_tx_pfc_pri5_pkt_num)},
38 {"mac_tx_pfc_pri6_pkt_num",
39 HNS3_MAC_STATS_OFFSET(mac_tx_pfc_pri6_pkt_num)},
40 {"mac_tx_pfc_pri7_pkt_num",
41 HNS3_MAC_STATS_OFFSET(mac_tx_pfc_pri7_pkt_num)},
42 {"mac_rx_pfc_pkt_num",
43 HNS3_MAC_STATS_OFFSET(mac_rx_pfc_pause_pkt_num)},
44 {"mac_rx_pfc_pri0_pkt_num",
45 HNS3_MAC_STATS_OFFSET(mac_rx_pfc_pri0_pkt_num)},
46 {"mac_rx_pfc_pri1_pkt_num",
47 HNS3_MAC_STATS_OFFSET(mac_rx_pfc_pri1_pkt_num)},
48 {"mac_rx_pfc_pri2_pkt_num",
49 HNS3_MAC_STATS_OFFSET(mac_rx_pfc_pri2_pkt_num)},
50 {"mac_rx_pfc_pri3_pkt_num",
51 HNS3_MAC_STATS_OFFSET(mac_rx_pfc_pri3_pkt_num)},
52 {"mac_rx_pfc_pri4_pkt_num",
53 HNS3_MAC_STATS_OFFSET(mac_rx_pfc_pri4_pkt_num)},
54 {"mac_rx_pfc_pri5_pkt_num",
55 HNS3_MAC_STATS_OFFSET(mac_rx_pfc_pri5_pkt_num)},
56 {"mac_rx_pfc_pri6_pkt_num",
57 HNS3_MAC_STATS_OFFSET(mac_rx_pfc_pri6_pkt_num)},
58 {"mac_rx_pfc_pri7_pkt_num",
59 HNS3_MAC_STATS_OFFSET(mac_rx_pfc_pri7_pkt_num)},
60 {"mac_tx_total_pkt_num",
61 HNS3_MAC_STATS_OFFSET(mac_tx_total_pkt_num)},
62 {"mac_tx_total_oct_num",
63 HNS3_MAC_STATS_OFFSET(mac_tx_total_oct_num)},
64 {"mac_tx_good_pkt_num",
65 HNS3_MAC_STATS_OFFSET(mac_tx_good_pkt_num)},
66 {"mac_tx_bad_pkt_num",
67 HNS3_MAC_STATS_OFFSET(mac_tx_bad_pkt_num)},
68 {"mac_tx_good_oct_num",
69 HNS3_MAC_STATS_OFFSET(mac_tx_good_oct_num)},
70 {"mac_tx_bad_oct_num",
71 HNS3_MAC_STATS_OFFSET(mac_tx_bad_oct_num)},
72 {"mac_tx_uni_pkt_num",
73 HNS3_MAC_STATS_OFFSET(mac_tx_uni_pkt_num)},
74 {"mac_tx_multi_pkt_num",
75 HNS3_MAC_STATS_OFFSET(mac_tx_multi_pkt_num)},
76 {"mac_tx_broad_pkt_num",
77 HNS3_MAC_STATS_OFFSET(mac_tx_broad_pkt_num)},
78 {"mac_tx_undersize_pkt_num",
79 HNS3_MAC_STATS_OFFSET(mac_tx_undersize_pkt_num)},
80 {"mac_tx_oversize_pkt_num",
81 HNS3_MAC_STATS_OFFSET(mac_tx_oversize_pkt_num)},
82 {"mac_tx_64_oct_pkt_num",
83 HNS3_MAC_STATS_OFFSET(mac_tx_64_oct_pkt_num)},
84 {"mac_tx_65_127_oct_pkt_num",
85 HNS3_MAC_STATS_OFFSET(mac_tx_65_127_oct_pkt_num)},
86 {"mac_tx_128_255_oct_pkt_num",
87 HNS3_MAC_STATS_OFFSET(mac_tx_128_255_oct_pkt_num)},
88 {"mac_tx_256_511_oct_pkt_num",
89 HNS3_MAC_STATS_OFFSET(mac_tx_256_511_oct_pkt_num)},
90 {"mac_tx_512_1023_oct_pkt_num",
91 HNS3_MAC_STATS_OFFSET(mac_tx_512_1023_oct_pkt_num)},
92 {"mac_tx_1024_1518_oct_pkt_num",
93 HNS3_MAC_STATS_OFFSET(mac_tx_1024_1518_oct_pkt_num)},
94 {"mac_tx_1519_2047_oct_pkt_num",
95 HNS3_MAC_STATS_OFFSET(mac_tx_1519_2047_oct_pkt_num)},
96 {"mac_tx_2048_4095_oct_pkt_num",
97 HNS3_MAC_STATS_OFFSET(mac_tx_2048_4095_oct_pkt_num)},
98 {"mac_tx_4096_8191_oct_pkt_num",
99 HNS3_MAC_STATS_OFFSET(mac_tx_4096_8191_oct_pkt_num)},
100 {"mac_tx_8192_9216_oct_pkt_num",
101 HNS3_MAC_STATS_OFFSET(mac_tx_8192_9216_oct_pkt_num)},
102 {"mac_tx_9217_12287_oct_pkt_num",
103 HNS3_MAC_STATS_OFFSET(mac_tx_9217_12287_oct_pkt_num)},
104 {"mac_tx_12288_16383_oct_pkt_num",
105 HNS3_MAC_STATS_OFFSET(mac_tx_12288_16383_oct_pkt_num)},
106 {"mac_tx_1519_max_good_pkt_num",
107 HNS3_MAC_STATS_OFFSET(mac_tx_1519_max_good_oct_pkt_num)},
108 {"mac_tx_1519_max_bad_pkt_num",
109 HNS3_MAC_STATS_OFFSET(mac_tx_1519_max_bad_oct_pkt_num)},
110 {"mac_rx_total_pkt_num",
111 HNS3_MAC_STATS_OFFSET(mac_rx_total_pkt_num)},
112 {"mac_rx_total_oct_num",
113 HNS3_MAC_STATS_OFFSET(mac_rx_total_oct_num)},
114 {"mac_rx_good_pkt_num",
115 HNS3_MAC_STATS_OFFSET(mac_rx_good_pkt_num)},
116 {"mac_rx_bad_pkt_num",
117 HNS3_MAC_STATS_OFFSET(mac_rx_bad_pkt_num)},
118 {"mac_rx_good_oct_num",
119 HNS3_MAC_STATS_OFFSET(mac_rx_good_oct_num)},
120 {"mac_rx_bad_oct_num",
121 HNS3_MAC_STATS_OFFSET(mac_rx_bad_oct_num)},
122 {"mac_rx_uni_pkt_num",
123 HNS3_MAC_STATS_OFFSET(mac_rx_uni_pkt_num)},
124 {"mac_rx_multi_pkt_num",
125 HNS3_MAC_STATS_OFFSET(mac_rx_multi_pkt_num)},
126 {"mac_rx_broad_pkt_num",
127 HNS3_MAC_STATS_OFFSET(mac_rx_broad_pkt_num)},
128 {"mac_rx_undersize_pkt_num",
129 HNS3_MAC_STATS_OFFSET(mac_rx_undersize_pkt_num)},
130 {"mac_rx_oversize_pkt_num",
131 HNS3_MAC_STATS_OFFSET(mac_rx_oversize_pkt_num)},
132 {"mac_rx_64_oct_pkt_num",
133 HNS3_MAC_STATS_OFFSET(mac_rx_64_oct_pkt_num)},
134 {"mac_rx_65_127_oct_pkt_num",
135 HNS3_MAC_STATS_OFFSET(mac_rx_65_127_oct_pkt_num)},
136 {"mac_rx_128_255_oct_pkt_num",
137 HNS3_MAC_STATS_OFFSET(mac_rx_128_255_oct_pkt_num)},
138 {"mac_rx_256_511_oct_pkt_num",
139 HNS3_MAC_STATS_OFFSET(mac_rx_256_511_oct_pkt_num)},
140 {"mac_rx_512_1023_oct_pkt_num",
141 HNS3_MAC_STATS_OFFSET(mac_rx_512_1023_oct_pkt_num)},
142 {"mac_rx_1024_1518_oct_pkt_num",
143 HNS3_MAC_STATS_OFFSET(mac_rx_1024_1518_oct_pkt_num)},
144 {"mac_rx_1519_2047_oct_pkt_num",
145 HNS3_MAC_STATS_OFFSET(mac_rx_1519_2047_oct_pkt_num)},
146 {"mac_rx_2048_4095_oct_pkt_num",
147 HNS3_MAC_STATS_OFFSET(mac_rx_2048_4095_oct_pkt_num)},
148 {"mac_rx_4096_8191_oct_pkt_num",
149 HNS3_MAC_STATS_OFFSET(mac_rx_4096_8191_oct_pkt_num)},
150 {"mac_rx_8192_9216_oct_pkt_num",
151 HNS3_MAC_STATS_OFFSET(mac_rx_8192_9216_oct_pkt_num)},
152 {"mac_rx_9217_12287_oct_pkt_num",
153 HNS3_MAC_STATS_OFFSET(mac_rx_9217_12287_oct_pkt_num)},
154 {"mac_rx_12288_16383_oct_pkt_num",
155 HNS3_MAC_STATS_OFFSET(mac_rx_12288_16383_oct_pkt_num)},
156 {"mac_rx_1519_max_good_pkt_num",
157 HNS3_MAC_STATS_OFFSET(mac_rx_1519_max_good_oct_pkt_num)},
158 {"mac_rx_1519_max_bad_pkt_num",
159 HNS3_MAC_STATS_OFFSET(mac_rx_1519_max_bad_oct_pkt_num)},
160 {"mac_tx_fragment_pkt_num",
161 HNS3_MAC_STATS_OFFSET(mac_tx_fragment_pkt_num)},
162 {"mac_tx_undermin_pkt_num",
163 HNS3_MAC_STATS_OFFSET(mac_tx_undermin_pkt_num)},
164 {"mac_tx_jabber_pkt_num",
165 HNS3_MAC_STATS_OFFSET(mac_tx_jabber_pkt_num)},
166 {"mac_tx_err_all_pkt_num",
167 HNS3_MAC_STATS_OFFSET(mac_tx_err_all_pkt_num)},
168 {"mac_tx_from_app_good_pkt_num",
169 HNS3_MAC_STATS_OFFSET(mac_tx_from_app_good_pkt_num)},
170 {"mac_tx_from_app_bad_pkt_num",
171 HNS3_MAC_STATS_OFFSET(mac_tx_from_app_bad_pkt_num)},
172 {"mac_rx_fragment_pkt_num",
173 HNS3_MAC_STATS_OFFSET(mac_rx_fragment_pkt_num)},
174 {"mac_rx_undermin_pkt_num",
175 HNS3_MAC_STATS_OFFSET(mac_rx_undermin_pkt_num)},
176 {"mac_rx_jabber_pkt_num",
177 HNS3_MAC_STATS_OFFSET(mac_rx_jabber_pkt_num)},
178 {"mac_rx_fcs_err_pkt_num",
179 HNS3_MAC_STATS_OFFSET(mac_rx_fcs_err_pkt_num)},
180 {"mac_rx_send_app_good_pkt_num",
181 HNS3_MAC_STATS_OFFSET(mac_rx_send_app_good_pkt_num)},
182 {"mac_rx_send_app_bad_pkt_num",
183 HNS3_MAC_STATS_OFFSET(mac_rx_send_app_bad_pkt_num)}
186 static const struct hns3_xstats_name_offset hns3_error_int_stats_strings[] = {
187 {"MAC_AFIFO_TNL_INT_R",
188 HNS3_ERR_INT_STATS_FIELD_OFFSET(mac_afifo_tnl_int_cnt)},
189 {"PPU_MPF_ABNORMAL_INT_ST2_MSIX",
190 HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_mpf_abn_int_st2_msix_cnt)},
191 {"SSU_PORT_BASED_ERR_INT_MSIX",
192 HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_port_based_pf_int_cnt)},
193 {"PPP_PF_ABNORMAL_INT_ST0",
194 HNS3_ERR_INT_STATS_FIELD_OFFSET(ppp_pf_abnormal_int_cnt)},
195 {"PPU_PF_ABNORMAL_INT_ST_MSIX",
196 HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_pf_abnormal_int_msix_cnt)},
197 {"IMP_TCM_ECC_INT_STS",
198 HNS3_ERR_INT_STATS_FIELD_OFFSET(imp_tcm_ecc_int_cnt)},
199 {"CMDQ_MEM_ECC_INT_STS",
200 HNS3_ERR_INT_STATS_FIELD_OFFSET(cmdq_mem_ecc_int_cnt)},
201 {"IMP_RD_POISON_INT_STS",
202 HNS3_ERR_INT_STATS_FIELD_OFFSET(imp_rd_poison_int_cnt)},
203 {"TQP_INT_ECC_INT_STS",
204 HNS3_ERR_INT_STATS_FIELD_OFFSET(tqp_int_ecc_int_cnt)},
206 HNS3_ERR_INT_STATS_FIELD_OFFSET(msix_ecc_int_cnt)},
207 {"SSU_ECC_MULTI_BIT_INT_0",
208 HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_ecc_multi_bit_int_0_cnt)},
209 {"SSU_ECC_MULTI_BIT_INT_1",
210 HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_ecc_multi_bit_int_1_cnt)},
211 {"SSU_COMMON_ERR_INT",
212 HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_common_ecc_int_cnt)},
214 HNS3_ERR_INT_STATS_FIELD_OFFSET(igu_int_cnt)},
215 {"PPP_MPF_ABNORMAL_INT_ST1",
216 HNS3_ERR_INT_STATS_FIELD_OFFSET(ppp_mpf_abnormal_int_st1_cnt)},
217 {"PPP_MPF_ABNORMAL_INT_ST3",
218 HNS3_ERR_INT_STATS_FIELD_OFFSET(ppp_mpf_abnormal_int_st3_cnt)},
219 {"PPU_MPF_ABNORMAL_INT_ST1",
220 HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_mpf_abnormal_int_st1_cnt)},
221 {"PPU_MPF_ABNORMAL_INT_ST2_RAS",
222 HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_mpf_abn_int_st2_ras_cnt)},
223 {"PPU_MPF_ABNORMAL_INT_ST3",
224 HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_mpf_abnormal_int_st3_cnt)},
226 HNS3_ERR_INT_STATS_FIELD_OFFSET(tm_sch_int_cnt)},
228 HNS3_ERR_INT_STATS_FIELD_OFFSET(qcn_fifo_int_cnt)},
230 HNS3_ERR_INT_STATS_FIELD_OFFSET(qcn_ecc_int_cnt)},
232 HNS3_ERR_INT_STATS_FIELD_OFFSET(ncsi_ecc_int_cnt)},
233 {"SSU_PORT_BASED_ERR_INT_RAS",
234 HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_port_based_err_int_cnt)},
235 {"SSU_FIFO_OVERFLOW_INT",
236 HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_fifo_overflow_int_cnt)},
238 HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_ets_tcg_int_cnt)},
239 {"IGU_EGU_TNL_INT_STS",
240 HNS3_ERR_INT_STATS_FIELD_OFFSET(igu_egu_tnl_int_cnt)},
241 {"PPU_PF_ABNORMAL_INT_ST_RAS",
242 HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_pf_abnormal_int_ras_cnt)},
245 /* The statistic of reset */
246 static const struct hns3_xstats_name_offset hns3_reset_stats_strings[] = {
248 HNS3_RESET_STATS_FIELD_OFFSET(request_cnt)},
250 HNS3_RESET_STATS_FIELD_OFFSET(global_cnt)},
252 HNS3_RESET_STATS_FIELD_OFFSET(imp_cnt)},
254 HNS3_RESET_STATS_FIELD_OFFSET(exec_cnt)},
255 {"RESET_SUCCESS_CNT",
256 HNS3_RESET_STATS_FIELD_OFFSET(success_cnt)},
258 HNS3_RESET_STATS_FIELD_OFFSET(fail_cnt)},
260 HNS3_RESET_STATS_FIELD_OFFSET(merge_cnt)}
263 /* The statistic of errors in Rx BD */
264 static const struct hns3_xstats_name_offset hns3_rx_bd_error_strings[] = {
266 HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(pkt_len_errors)},
268 HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(l2_errors)}
271 /* The dfx statistic in Rx datapath */
272 static const struct hns3_xstats_name_offset hns3_rxq_dfx_stats_strings[] = {
273 {"L3_CHECKSUM_ERRORS",
274 HNS3_RXQ_DFX_STATS_FIELD_OFFSET(l3_csum_errors)},
275 {"L4_CHECKSUM_ERRORS",
276 HNS3_RXQ_DFX_STATS_FIELD_OFFSET(l4_csum_errors)},
277 {"OL3_CHECKSUM_ERRORS",
278 HNS3_RXQ_DFX_STATS_FIELD_OFFSET(ol3_csum_errors)},
279 {"OL4_CHECKSUM_ERRORS",
280 HNS3_RXQ_DFX_STATS_FIELD_OFFSET(ol4_csum_errors)}
283 /* The dfx statistic in Tx datapath */
284 static const struct hns3_xstats_name_offset hns3_txq_dfx_stats_strings[] = {
285 {"OVER_LENGTH_PKT_CNT",
286 HNS3_TXQ_DFX_STATS_FIELD_OFFSET(over_length_pkt_cnt)},
287 {"EXCEED_LIMITED_BD_PKT_CNT",
288 HNS3_TXQ_DFX_STATS_FIELD_OFFSET(exceed_limit_bd_pkt_cnt)},
289 {"EXCEED_LIMITED_BD_PKT_REASSEMBLE_FAIL_CNT",
290 HNS3_TXQ_DFX_STATS_FIELD_OFFSET(exceed_limit_bd_reassem_fail)},
291 {"UNSUPPORTED_TUNNEL_PKT_CNT",
292 HNS3_TXQ_DFX_STATS_FIELD_OFFSET(unsupported_tunnel_pkt_cnt)},
294 HNS3_TXQ_DFX_STATS_FIELD_OFFSET(queue_full_cnt)},
295 {"SHORT_PKT_PAD_FAIL_CNT",
296 HNS3_TXQ_DFX_STATS_FIELD_OFFSET(pkt_padding_fail_cnt)}
299 /* The statistic of rx queue */
300 static const struct hns3_xstats_name_offset hns3_rx_queue_strings[] = {
301 {"RX_QUEUE_FBD", HNS3_RING_RX_FBDNUM_REG}
304 /* The statistic of tx queue */
305 static const struct hns3_xstats_name_offset hns3_tx_queue_strings[] = {
306 {"TX_QUEUE_FBD", HNS3_RING_TX_FBDNUM_REG}
309 #define HNS3_NUM_MAC_STATS (sizeof(hns3_mac_strings) / \
310 sizeof(hns3_mac_strings[0]))
312 #define HNS3_NUM_ERROR_INT_XSTATS (sizeof(hns3_error_int_stats_strings) / \
313 sizeof(hns3_error_int_stats_strings[0]))
315 #define HNS3_NUM_RESET_XSTATS (sizeof(hns3_reset_stats_strings) / \
316 sizeof(hns3_reset_stats_strings[0]))
318 #define HNS3_NUM_RX_BD_ERROR_XSTATS (sizeof(hns3_rx_bd_error_strings) / \
319 sizeof(hns3_rx_bd_error_strings[0]))
321 #define HNS3_NUM_RXQ_DFX_XSTATS (sizeof(hns3_rxq_dfx_stats_strings) / \
322 sizeof(hns3_rxq_dfx_stats_strings[0]))
324 #define HNS3_NUM_TXQ_DFX_XSTATS (sizeof(hns3_txq_dfx_stats_strings) / \
325 sizeof(hns3_txq_dfx_stats_strings[0]))
327 #define HNS3_NUM_RX_QUEUE_STATS (sizeof(hns3_rx_queue_strings) / \
328 sizeof(hns3_rx_queue_strings[0]))
330 #define HNS3_NUM_TX_QUEUE_STATS (sizeof(hns3_tx_queue_strings) / \
331 sizeof(hns3_tx_queue_strings[0]))
333 #define HNS3_FIX_NUM_STATS (HNS3_NUM_MAC_STATS + HNS3_NUM_ERROR_INT_XSTATS + \
334 HNS3_NUM_RESET_XSTATS)
336 static void hns3_tqp_stats_clear(struct hns3_hw *hw);
339 * Query all the MAC statistics data of Network ICL command ,opcode id: 0x0034.
340 * This command is used before send 'query_mac_stat command', the descriptor
341 * number of 'query_mac_stat command' must match with reg_num in this command.
343 * Pointer to structure hns3_hw.
348 hns3_update_mac_stats(struct hns3_hw *hw, const uint32_t desc_num)
350 uint64_t *data = (uint64_t *)(&hw->mac_stats);
351 struct hns3_cmd_desc *desc;
356 desc = rte_malloc("hns3_mac_desc",
357 desc_num * sizeof(struct hns3_cmd_desc), 0);
359 hns3_err(hw, "Mac_update_stats alloced desc malloc fail");
363 hns3_cmd_setup_basic_desc(desc, HNS3_OPC_STATS_MAC_ALL, true);
364 ret = hns3_cmd_send(hw, desc, desc_num);
366 hns3_err(hw, "Update complete MAC pkt stats fail : %d", ret);
371 for (i = 0; i < desc_num; i++) {
372 /* For special opcode 0034, only the first desc has the head */
374 desc_data = (uint64_t *)(&desc[i].data[0]);
375 n = HNS3_RD_FIRST_STATS_NUM;
377 desc_data = (uint64_t *)(&desc[i]);
378 n = HNS3_RD_OTHER_STATS_NUM;
381 for (k = 0; k < n; k++) {
382 *data += rte_le_to_cpu_64(*desc_data);
393 * Query Mac stat reg num command ,opcode id: 0x0033.
394 * This command is used before send 'query_mac_stat command', the descriptor
395 * number of 'query_mac_stat command' must match with reg_num in this command.
397 * Pointer to structure rte_eth_stats.
402 hns3_mac_query_reg_num(struct rte_eth_dev *dev, uint32_t *desc_num)
404 struct hns3_adapter *hns = dev->data->dev_private;
405 struct hns3_hw *hw = &hns->hw;
406 struct hns3_cmd_desc desc;
411 hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_MAC_REG_NUM, true);
412 ret = hns3_cmd_send(hw, &desc, 1);
417 * The num of MAC statistics registers that are provided by IMP in this
420 desc_data = (uint32_t *)(&desc.data[0]);
421 reg_num = rte_le_to_cpu_32(*desc_data);
424 * The descriptor number of 'query_additional_mac_stat command' is
425 * '1 + (reg_num-3)/4 + ((reg_num-3)%4 !=0)';
426 * This value is 83 in this version
428 *desc_num = 1 + ((reg_num - 3) >> 2) +
429 (uint32_t)(((reg_num - 3) & 0x3) ? 1 : 0);
435 hns3_query_update_mac_stats(struct rte_eth_dev *dev)
437 struct hns3_adapter *hns = dev->data->dev_private;
438 struct hns3_hw *hw = &hns->hw;
442 ret = hns3_mac_query_reg_num(dev, &desc_num);
444 ret = hns3_update_mac_stats(hw, desc_num);
446 hns3_err(hw, "Query mac reg num fail : %d", ret);
450 /* Get tqp stats from register */
452 hns3_update_tqp_stats(struct hns3_hw *hw)
454 struct hns3_tqp_stats *stats = &hw->tqp_stats;
455 struct hns3_cmd_desc desc;
460 for (i = 0; i < hw->tqps_num; i++) {
461 hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_RX_STATUS,
464 desc.data[0] = rte_cpu_to_le_32((uint32_t)i);
465 ret = hns3_cmd_send(hw, &desc, 1);
467 hns3_err(hw, "Failed to query RX No.%u queue stat: %d",
471 cnt = rte_le_to_cpu_32(desc.data[1]);
472 stats->rcb_rx_ring_pktnum_rcd += cnt;
473 stats->rcb_rx_ring_pktnum[i] += cnt;
475 hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_TX_STATUS,
478 desc.data[0] = rte_cpu_to_le_32((uint32_t)i);
479 ret = hns3_cmd_send(hw, &desc, 1);
481 hns3_err(hw, "Failed to query TX No.%u queue stat: %d",
485 cnt = rte_le_to_cpu_32(desc.data[1]);
486 stats->rcb_tx_ring_pktnum_rcd += cnt;
487 stats->rcb_tx_ring_pktnum[i] += cnt;
494 * Query tqp tx queue statistics ,opcode id: 0x0B03.
495 * Query tqp rx queue statistics ,opcode id: 0x0B13.
496 * Get all statistics of a port.
498 * Pointer to Ethernet device.
500 * Pointer to structure rte_eth_stats.
505 hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
507 struct hns3_adapter *hns = eth_dev->data->dev_private;
508 struct hns3_hw *hw = &hns->hw;
509 struct hns3_tqp_stats *stats = &hw->tqp_stats;
510 struct hns3_rx_queue *rxq;
511 struct hns3_tx_queue *txq;
517 /* Update tqp stats by read register */
518 ret = hns3_update_tqp_stats(hw);
520 hns3_err(hw, "Update tqp stats fail : %d", ret);
524 /* Get the error stats of received packets */
525 num = RTE_MIN(RTE_ETHDEV_QUEUE_STAT_CNTRS, eth_dev->data->nb_rx_queues);
526 for (i = 0; i != num; ++i) {
527 rxq = eth_dev->data->rx_queues[i];
529 cnt = rxq->err_stats.l2_errors +
530 rxq->err_stats.pkt_len_errors;
531 rte_stats->q_errors[i] = cnt;
532 rte_stats->q_ipackets[i] =
533 stats->rcb_rx_ring_pktnum[i] - cnt;
534 rte_stats->ierrors += cnt;
537 /* Get the error stats of transmitted packets */
538 num = RTE_MIN(RTE_ETHDEV_QUEUE_STAT_CNTRS, eth_dev->data->nb_tx_queues);
539 for (i = 0; i < num; i++) {
540 txq = eth_dev->data->tx_queues[i];
542 rte_stats->q_opackets[i] = stats->rcb_tx_ring_pktnum[i];
545 rte_stats->oerrors = 0;
546 rte_stats->ipackets = stats->rcb_rx_ring_pktnum_rcd -
548 rte_stats->opackets = stats->rcb_tx_ring_pktnum_rcd -
550 rte_stats->rx_nombuf = eth_dev->data->rx_mbuf_alloc_failed;
556 hns3_stats_reset(struct rte_eth_dev *eth_dev)
558 struct hns3_adapter *hns = eth_dev->data->dev_private;
559 struct hns3_hw *hw = &hns->hw;
560 struct hns3_cmd_desc desc_reset;
561 struct hns3_rx_queue *rxq;
566 * Note: Reading hardware statistics of rx/tx queue packet number
569 for (i = 0; i < hw->tqps_num; i++) {
570 hns3_cmd_setup_basic_desc(&desc_reset, HNS3_OPC_QUERY_RX_STATUS,
572 desc_reset.data[0] = rte_cpu_to_le_32((uint32_t)i);
573 ret = hns3_cmd_send(hw, &desc_reset, 1);
575 hns3_err(hw, "Failed to reset RX No.%u queue stat: %d",
580 hns3_cmd_setup_basic_desc(&desc_reset, HNS3_OPC_QUERY_TX_STATUS,
582 desc_reset.data[0] = rte_cpu_to_le_32((uint32_t)i);
583 ret = hns3_cmd_send(hw, &desc_reset, 1);
585 hns3_err(hw, "Failed to reset TX No.%u queue stat: %d",
592 * Clear soft stats of rx error packet which will be dropped
595 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
596 rxq = eth_dev->data->rx_queues[i];
598 rxq->err_stats.pkt_len_errors = 0;
599 rxq->err_stats.l2_errors = 0;
603 hns3_tqp_stats_clear(hw);
609 hns3_mac_stats_reset(__rte_unused struct rte_eth_dev *dev)
611 struct hns3_adapter *hns = dev->data->dev_private;
612 struct hns3_hw *hw = &hns->hw;
613 struct hns3_mac_stats *mac_stats = &hw->mac_stats;
616 ret = hns3_query_update_mac_stats(dev);
618 hns3_err(hw, "Clear Mac stats fail : %d", ret);
622 memset(mac_stats, 0, sizeof(struct hns3_mac_stats));
627 /* This function calculates the number of xstats based on the current config */
629 hns3_xstats_calc_num(struct rte_eth_dev *dev)
631 struct hns3_adapter *hns = dev->data->dev_private;
632 uint16_t nb_rx_q = dev->data->nb_rx_queues;
633 uint16_t nb_tx_q = dev->data->nb_tx_queues;
634 int bderr_stats = nb_rx_q * HNS3_NUM_RX_BD_ERROR_XSTATS;
635 int rx_dfx_stats = nb_rx_q * HNS3_NUM_RXQ_DFX_XSTATS;
636 int tx_dfx_stats = nb_tx_q * HNS3_NUM_TXQ_DFX_XSTATS;
637 int rx_queue_stats = nb_rx_q * HNS3_NUM_RX_QUEUE_STATS;
638 int tx_queue_stats = nb_tx_q * HNS3_NUM_TX_QUEUE_STATS;
641 return bderr_stats + rx_dfx_stats + tx_dfx_stats +
642 rx_queue_stats + tx_queue_stats + HNS3_NUM_RESET_XSTATS;
644 return bderr_stats + rx_dfx_stats + tx_dfx_stats +
645 rx_queue_stats + tx_queue_stats + HNS3_FIX_NUM_STATS;
649 hns3_queue_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
652 struct hns3_adapter *hns = dev->data->dev_private;
653 struct hns3_hw *hw = &hns->hw;
657 /* Get rx queue stats */
658 for (j = 0; j < dev->data->nb_rx_queues; j++) {
659 for (i = 0; i < HNS3_NUM_RX_QUEUE_STATS; i++) {
660 reg_offset = hns3_get_tqp_reg_offset(j);
661 xstats[*count].value = hns3_read_dev(hw,
662 reg_offset + hns3_rx_queue_strings[i].offset);
663 xstats[*count].id = *count;
668 /* Get tx queue stats */
669 for (j = 0; j < dev->data->nb_tx_queues; j++) {
670 for (i = 0; i < HNS3_NUM_TX_QUEUE_STATS; i++) {
671 reg_offset = hns3_get_tqp_reg_offset(j);
672 xstats[*count].value = hns3_read_dev(hw,
673 reg_offset + hns3_tx_queue_strings[i].offset);
674 xstats[*count].id = *count;
681 hns3_error_int_stats_add(struct hns3_adapter *hns, const char *err)
683 struct hns3_pf *pf = &hns->pf;
687 for (i = 0; i < HNS3_NUM_ERROR_INT_XSTATS; i++) {
688 if (strcmp(hns3_error_int_stats_strings[i].name, err) == 0) {
689 addr = (char *)&pf->abn_int_stats +
690 hns3_error_int_stats_strings[i].offset;
691 *(uint64_t *)addr += 1;
698 hns3_rxq_dfx_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
701 struct hns3_rx_dfx_stats *dfx_stats;
702 struct hns3_rx_queue *rxq;
706 for (i = 0; i < dev->data->nb_rx_queues; i++) {
707 rxq = (struct hns3_rx_queue *)dev->data->rx_queues[i];
711 dfx_stats = &rxq->dfx_stats;
712 for (j = 0; j < HNS3_NUM_RXQ_DFX_XSTATS; j++) {
713 val = (char *)dfx_stats +
714 hns3_rxq_dfx_stats_strings[j].offset;
715 xstats[*count].value = *(uint64_t *)val;
716 xstats[*count].id = *count;
723 hns3_txq_dfx_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
726 struct hns3_tx_dfx_stats *dfx_stats;
727 struct hns3_tx_queue *txq;
731 for (i = 0; i < dev->data->nb_tx_queues; i++) {
732 txq = (struct hns3_tx_queue *)dev->data->tx_queues[i];
736 dfx_stats = &txq->dfx_stats;
737 for (j = 0; j < HNS3_NUM_TXQ_DFX_XSTATS; j++) {
738 val = (char *)dfx_stats +
739 hns3_txq_dfx_stats_strings[j].offset;
740 xstats[*count].value = *(uint64_t *)val;
741 xstats[*count].id = *count;
748 hns3_tqp_dfx_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
751 hns3_rxq_dfx_stats_get(dev, xstats, count);
752 hns3_txq_dfx_stats_get(dev, xstats, count);
755 * Retrieve extended(tqp | Mac) statistics of an Ethernet device.
757 * Pointer to Ethernet device.
759 * A pointer to a table of structure of type *rte_eth_xstat*
760 * to be filled with device statistics ids and values.
761 * This parameter can be set to NULL if n is 0.
763 * The size of the xstats array (number of elements).
765 * 0 on fail, count(The size of the statistics elements) on success.
768 hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
771 struct hns3_adapter *hns = dev->data->dev_private;
772 struct hns3_pf *pf = &hns->pf;
773 struct hns3_hw *hw = &hns->hw;
774 struct hns3_mac_stats *mac_stats = &hw->mac_stats;
775 struct hns3_reset_stats *reset_stats = &hw->reset.stats;
776 struct hns3_rx_bd_errors_stats *rx_err_stats;
777 struct hns3_rx_queue *rxq;
786 count = hns3_xstats_calc_num(dev);
793 /* Update Mac stats */
794 ret = hns3_query_update_mac_stats(dev);
796 hns3_err(hw, "Update Mac stats fail : %d", ret);
800 /* Get MAC stats from hw->hw_xstats.mac_stats struct */
801 for (i = 0; i < HNS3_NUM_MAC_STATS; i++) {
802 addr = (char *)mac_stats + hns3_mac_strings[i].offset;
803 xstats[count].value = *(uint64_t *)addr;
804 xstats[count].id = count;
808 for (i = 0; i < HNS3_NUM_ERROR_INT_XSTATS; i++) {
809 addr = (char *)&pf->abn_int_stats +
810 hns3_error_int_stats_strings[i].offset;
811 xstats[count].value = *(uint64_t *)addr;
812 xstats[count].id = count;
817 /* Get the reset stat */
818 for (i = 0; i < HNS3_NUM_RESET_XSTATS; i++) {
819 addr = (char *)reset_stats + hns3_reset_stats_strings[i].offset;
820 xstats[count].value = *(uint64_t *)addr;
821 xstats[count].id = count;
825 /* Get the Rx BD errors stats */
826 for (j = 0; j < dev->data->nb_rx_queues; j++) {
827 for (i = 0; i < HNS3_NUM_RX_BD_ERROR_XSTATS; i++) {
828 rxq = dev->data->rx_queues[j];
830 rx_err_stats = &rxq->err_stats;
831 addr = (char *)rx_err_stats +
832 hns3_rx_bd_error_strings[i].offset;
833 xstats[count].value = *(uint64_t *)addr;
834 xstats[count].id = count;
840 hns3_tqp_dfx_stats_get(dev, xstats, &count);
841 hns3_queue_stats_get(dev, xstats, &count);
847 hns3_tqp_dfx_stats_name_get(struct rte_eth_dev *dev,
848 struct rte_eth_xstat_name *xstats_names,
853 for (j = 0; j < dev->data->nb_rx_queues; j++) {
854 for (i = 0; i < HNS3_NUM_RXQ_DFX_XSTATS; i++) {
855 snprintf(xstats_names[*count].name,
856 sizeof(xstats_names[*count].name),
858 hns3_rxq_dfx_stats_strings[i].name);
863 for (j = 0; j < dev->data->nb_tx_queues; j++) {
864 for (i = 0; i < HNS3_NUM_TXQ_DFX_XSTATS; i++) {
865 snprintf(xstats_names[*count].name,
866 sizeof(xstats_names[*count].name),
868 hns3_txq_dfx_stats_strings[i].name);
875 * Retrieve names of extended statistics of an Ethernet device.
877 * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
879 * xstats_names[i].name => xstats[i].value
881 * And the array index is same with id field of 'struct rte_eth_xstat':
884 * This assumption makes key-value pair matching less flexible but simpler.
887 * Pointer to Ethernet device.
888 * @param xstats_names
889 * An rte_eth_xstat_name array of at least *size* elements to
890 * be filled. If set to NULL, the function returns the required number
893 * The size of the xstats_names array (number of elements).
895 * - A positive value lower or equal to size: success. The return value
896 * is the number of entries filled in the stats table.
899 hns3_dev_xstats_get_names(struct rte_eth_dev *dev,
900 struct rte_eth_xstat_name *xstats_names,
901 __rte_unused unsigned int size)
903 struct hns3_adapter *hns = dev->data->dev_private;
904 int cnt_stats = hns3_xstats_calc_num(dev);
908 if (xstats_names == NULL)
911 /* Note: size limited checked in rte_eth_xstats_get_names() */
913 /* Get MAC name from hw->hw_xstats.mac_stats struct */
914 for (i = 0; i < HNS3_NUM_MAC_STATS; i++) {
915 snprintf(xstats_names[count].name,
916 sizeof(xstats_names[count].name),
917 "%s", hns3_mac_strings[i].name);
921 for (i = 0; i < HNS3_NUM_ERROR_INT_XSTATS; i++) {
922 snprintf(xstats_names[count].name,
923 sizeof(xstats_names[count].name),
924 "%s", hns3_error_int_stats_strings[i].name);
928 for (i = 0; i < HNS3_NUM_RESET_XSTATS; i++) {
929 snprintf(xstats_names[count].name,
930 sizeof(xstats_names[count].name),
931 "%s", hns3_reset_stats_strings[i].name);
935 for (j = 0; j < dev->data->nb_rx_queues; j++) {
936 for (i = 0; i < HNS3_NUM_RX_BD_ERROR_XSTATS; i++) {
937 snprintf(xstats_names[count].name,
938 sizeof(xstats_names[count].name),
940 hns3_rx_bd_error_strings[i].name);
945 hns3_tqp_dfx_stats_name_get(dev, xstats_names, &count);
947 for (j = 0; j < dev->data->nb_rx_queues; j++) {
948 for (i = 0; i < HNS3_NUM_RX_QUEUE_STATS; i++) {
949 snprintf(xstats_names[count].name,
950 sizeof(xstats_names[count].name),
951 "rx_q%u_%s", j, hns3_rx_queue_strings[i].name);
956 for (j = 0; j < dev->data->nb_tx_queues; j++) {
957 for (i = 0; i < HNS3_NUM_TX_QUEUE_STATS; i++) {
958 snprintf(xstats_names[count].name,
959 sizeof(xstats_names[count].name),
960 "tx_q%u_%s", j, hns3_tx_queue_strings[i].name);
969 * Retrieve extended statistics of an Ethernet device.
972 * Pointer to Ethernet device.
974 * A pointer to an ids array passed by application. This tells which
975 * statistics values function should retrieve. This parameter
976 * can be set to NULL if size is 0. In this case function will retrieve
977 * all avalible statistics.
979 * A pointer to a table to be filled with device statistics values.
981 * The size of the ids array (number of elements).
983 * - A positive value lower or equal to size: success. The return value
984 * is the number of entries filled in the stats table.
985 * - A positive value higher than size: error, the given statistics table
986 * is too small. The return value corresponds to the size that should
987 * be given to succeed. The entries in the table are not valid and
988 * shall not be used by the caller.
992 hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
993 uint64_t *values, uint32_t size)
995 const uint32_t cnt_stats = hns3_xstats_calc_num(dev);
996 struct hns3_adapter *hns = dev->data->dev_private;
997 struct rte_eth_xstat *values_copy;
998 struct hns3_hw *hw = &hns->hw;
999 uint32_t count_value;
1004 if (ids == NULL && values == NULL)
1008 if (size < cnt_stats)
1011 /* Update tqp stats by read register */
1012 ret = hns3_update_tqp_stats(hw);
1014 hns3_err(hw, "Update tqp stats fail : %d", ret);
1018 len = cnt_stats * sizeof(struct rte_eth_xstat);
1019 values_copy = rte_zmalloc("hns3_xstats_values", len, 0);
1020 if (values_copy == NULL) {
1021 hns3_err(hw, "Failed to allocate %" PRIx64 " bytes needed "
1022 "to store statistics values", len);
1026 count_value = hns3_dev_xstats_get(dev, values_copy, cnt_stats);
1027 if (count_value != cnt_stats) {
1028 rte_free(values_copy);
1032 if (ids == NULL && values != NULL) {
1033 for (i = 0; i < cnt_stats; i++)
1034 memcpy(&values[i], &values_copy[i].value,
1037 rte_free(values_copy);
1041 for (i = 0; i < size; i++) {
1042 if (ids[i] >= cnt_stats) {
1043 hns3_err(hw, "ids[%u] (%" PRIx64 ") is invalid, "
1044 "should < %u", i, ids[i], cnt_stats);
1045 rte_free(values_copy);
1048 memcpy(&values[i], &values_copy[ids[i]].value,
1052 rte_free(values_copy);
1057 * Retrieve names of extended statistics of an Ethernet device.
1060 * Pointer to Ethernet device.
1061 * @param xstats_names
1062 * An rte_eth_xstat_name array of at least *size* elements to
1063 * be filled. If set to NULL, the function returns the required number
1066 * IDs array given by app to retrieve specific statistics
1068 * The size of the xstats_names array (number of elements).
1070 * - A positive value lower or equal to size: success. The return value
1071 * is the number of entries filled in the stats table.
1072 * - A positive value higher than size: error, the given statistics table
1073 * is too small. The return value corresponds to the size that should
1074 * be given to succeed. The entries in the table are not valid and
1075 * shall not be used by the caller.
1078 hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
1079 struct rte_eth_xstat_name *xstats_names,
1080 const uint64_t *ids, uint32_t size)
1082 const uint32_t cnt_stats = hns3_xstats_calc_num(dev);
1083 struct hns3_adapter *hns = dev->data->dev_private;
1084 struct rte_eth_xstat_name *names_copy;
1085 struct hns3_hw *hw = &hns->hw;
1089 if (xstats_names == NULL)
1093 if (size < cnt_stats)
1096 return hns3_dev_xstats_get_names(dev, xstats_names, cnt_stats);
1099 len = cnt_stats * sizeof(struct rte_eth_xstat_name);
1100 names_copy = rte_zmalloc("hns3_xstats_names", len, 0);
1101 if (names_copy == NULL) {
1102 hns3_err(hw, "Failed to allocate %" PRIx64 " bytes needed "
1103 "to store statistics names", len);
1107 (void)hns3_dev_xstats_get_names(dev, names_copy, cnt_stats);
1109 for (i = 0; i < size; i++) {
1110 if (ids[i] >= cnt_stats) {
1111 hns3_err(hw, "ids[%u] (%" PRIx64 ") is invalid, "
1112 "should < %u", i, ids[i], cnt_stats);
1113 rte_free(names_copy);
1116 snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
1117 "%s", names_copy[ids[i]].name);
1120 rte_free(names_copy);
1125 hns3_tqp_dfx_stats_clear(struct rte_eth_dev *dev)
1127 struct hns3_rx_queue *rxq;
1128 struct hns3_tx_queue *txq;
1131 /* Clear Rx dfx stats */
1132 for (i = 0; i < dev->data->nb_rx_queues; i++) {
1133 rxq = dev->data->rx_queues[i];
1135 memset(&rxq->dfx_stats, 0,
1136 sizeof(struct hns3_rx_dfx_stats));
1139 /* Clear Tx dfx stats */
1140 for (i = 0; i < dev->data->nb_tx_queues; i++) {
1141 txq = dev->data->tx_queues[i];
1143 memset(&txq->dfx_stats, 0,
1144 sizeof(struct hns3_tx_dfx_stats));
1149 hns3_dev_xstats_reset(struct rte_eth_dev *dev)
1151 struct hns3_adapter *hns = dev->data->dev_private;
1152 struct hns3_pf *pf = &hns->pf;
1155 /* Clear tqp stats */
1156 ret = hns3_stats_reset(dev);
1160 /* Clear reset stats */
1161 memset(&hns->hw.reset.stats, 0, sizeof(struct hns3_reset_stats));
1163 hns3_tqp_dfx_stats_clear(dev);
1168 /* HW registers are cleared on read */
1169 ret = hns3_mac_stats_reset(dev);
1173 /* Clear error stats */
1174 memset(&pf->abn_int_stats, 0, sizeof(struct hns3_err_msix_intr_stats));
1180 hns3_tqp_stats_init(struct hns3_hw *hw)
1182 struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats;
1184 tqp_stats->rcb_rx_ring_pktnum = rte_zmalloc("hns3_rx_ring_pkt_num",
1185 sizeof(uint64_t) * hw->tqps_num, 0);
1186 if (tqp_stats->rcb_rx_ring_pktnum == NULL) {
1187 hns3_err(hw, "failed to allocate rx_ring pkt_num.");
1191 tqp_stats->rcb_tx_ring_pktnum = rte_zmalloc("hns3_tx_ring_pkt_num",
1192 sizeof(uint64_t) * hw->tqps_num, 0);
1193 if (tqp_stats->rcb_tx_ring_pktnum == NULL) {
1194 hns3_err(hw, "failed to allocate tx_ring pkt_num.");
1195 rte_free(tqp_stats->rcb_rx_ring_pktnum);
1196 tqp_stats->rcb_rx_ring_pktnum = NULL;
1204 hns3_tqp_stats_uninit(struct hns3_hw *hw)
1206 struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats;
1208 rte_free(tqp_stats->rcb_rx_ring_pktnum);
1209 tqp_stats->rcb_rx_ring_pktnum = NULL;
1210 rte_free(tqp_stats->rcb_tx_ring_pktnum);
1211 tqp_stats->rcb_tx_ring_pktnum = NULL;
1215 hns3_tqp_stats_clear(struct hns3_hw *hw)
1217 struct hns3_tqp_stats *stats = &hw->tqp_stats;
1219 stats->rcb_rx_ring_pktnum_rcd = 0;
1220 stats->rcb_tx_ring_pktnum_rcd = 0;
1221 memset(stats->rcb_rx_ring_pktnum, 0, sizeof(uint64_t) * hw->tqps_num);
1222 memset(stats->rcb_tx_ring_pktnum, 0, sizeof(uint64_t) * hw->tqps_num);