Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2022 HiSilicon Limited
3 : : */
4 : :
5 : : #include <rte_malloc.h>
6 : :
7 : : #include "hns3_common.h"
8 : : #include "hns3_logs.h"
9 : : #include "hns3_regs.h"
10 : : #include "hns3_rxtx.h"
11 : : #include "hns3_dump.h"
12 : :
13 : : #define HNS3_BD_DW_NUM 8
14 : : #define HNS3_BD_ADDRESS_LAST_DW 2
15 : :
16 : : static const char *
17 : 0 : hns3_get_adapter_state_name(enum hns3_adapter_state state)
18 : : {
19 : : const struct {
20 : : enum hns3_adapter_state state;
21 : : const char *name;
22 : 0 : } adapter_state_name[] = {
23 : : {HNS3_NIC_UNINITIALIZED, "UNINITIALIZED"},
24 : : {HNS3_NIC_INITIALIZED, "INITIALIZED"},
25 : : {HNS3_NIC_CONFIGURING, "CONFIGURING"},
26 : : {HNS3_NIC_CONFIGURED, "CONFIGURED"},
27 : : {HNS3_NIC_STARTING, "STARTING"},
28 : : {HNS3_NIC_STARTED, "STARTED"},
29 : : {HNS3_NIC_STOPPING, "STOPPING"},
30 : : {HNS3_NIC_CLOSING, "CLOSING"},
31 : : {HNS3_NIC_CLOSED, "CLOSED"},
32 : : {HNS3_NIC_REMOVED, "REMOVED"},
33 : : {HNS3_NIC_NSTATES, "NSTATES"},
34 : : };
35 : : uint32_t i;
36 : :
37 [ # # ]: 0 : for (i = 0; i < RTE_DIM(adapter_state_name); i++)
38 [ # # ]: 0 : if (state == adapter_state_name[i].state)
39 : 0 : return adapter_state_name[i].name;
40 : :
41 : : return "Unknown";
42 : : }
43 : :
44 : : static const char *
45 : : hns3_get_io_func_hint_name(uint32_t hint)
46 : : {
47 : 0 : switch (hint) {
48 : : case HNS3_IO_FUNC_HINT_NONE:
49 : : return "none";
50 : 0 : case HNS3_IO_FUNC_HINT_VEC:
51 : 0 : return "vec";
52 : 0 : case HNS3_IO_FUNC_HINT_SVE:
53 : 0 : return "sve";
54 : 0 : case HNS3_IO_FUNC_HINT_SIMPLE:
55 : 0 : return "simple";
56 : 0 : case HNS3_IO_FUNC_HINT_COMMON:
57 : 0 : return "common";
58 : 0 : default:
59 : 0 : return "unknown";
60 : : }
61 : : }
62 : :
63 : : static void
64 : 0 : hns3_get_dev_mac_info(FILE *file, struct hns3_adapter *hns)
65 : : {
66 : : struct hns3_hw *hw = &hns->hw;
67 : : struct hns3_pf *pf = &hns->pf;
68 : :
69 : : fprintf(file, " - MAC Info:\n");
70 : 0 : fprintf(file,
71 : : "\t -- media_type=%s\n"
72 : : "\t -- query_type=%u\n"
73 : : "\t -- supported_speed=0x%x\n"
74 : : "\t -- advertising=0x%x\n"
75 : : "\t -- lp_advertising=0x%x\n"
76 : : "\t -- support_autoneg=%s\n"
77 : : "\t -- support_fc_autoneg=%s\n",
78 : 0 : hns3_get_media_type_name(hw->mac.media_type),
79 : 0 : hw->mac.query_type,
80 : : hw->mac.supported_speed,
81 : : hw->mac.advertising,
82 : : hw->mac.lp_advertising,
83 [ # # ]: 0 : hw->mac.support_autoneg != 0 ? "Yes" : "No",
84 [ # # ]: 0 : pf->support_fc_autoneg ? "Yes" : "No");
85 : 0 : }
86 : :
87 : : static void
88 : 0 : hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
89 : : {
90 : : const struct {
91 : : enum hns3_dev_cap cap;
92 : : const char *name;
93 : 0 : } caps_name[] = {
94 : : {HNS3_DEV_SUPPORT_DCB_B, "DCB"},
95 : : {HNS3_DEV_SUPPORT_COPPER_B, "COPPER"},
96 : : {HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B, "FD QUEUE REGION"},
97 : : {HNS3_DEV_SUPPORT_PTP_B, "PTP"},
98 : : {HNS3_DEV_SUPPORT_TX_PUSH_B, "TX PUSH"},
99 : : {HNS3_DEV_SUPPORT_INDEP_TXRX_B, "INDEP TXRX"},
100 : : {HNS3_DEV_SUPPORT_STASH_B, "STASH"},
101 : : {HNS3_DEV_SUPPORT_SIMPLE_BD_B, "SIMPLE BD"},
102 : : {HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, "RXD Advanced Layout"},
103 : : {HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, "OUTER UDP CKSUM"},
104 : : {HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"},
105 : : {HNS3_DEV_SUPPORT_TM_B, "TM"},
106 : : {HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, "VF VLAN FILTER MOD"},
107 : : {HNS3_DEV_SUPPORT_FC_AUTO_B, "FC AUTO"},
108 : : {HNS3_DEV_SUPPORT_GRO_B, "GRO"}
109 : : };
110 : : uint32_t i;
111 : :
112 : : fprintf(file, " - Dev Capability:\n");
113 [ # # ]: 0 : for (i = 0; i < RTE_DIM(caps_name); i++)
114 : 0 : fprintf(file, "\t -- support %s: %s\n", caps_name[i].name,
115 [ # # ]: 0 : hns3_get_bit(hw->capability, caps_name[i].cap) ? "Yes" :
116 : : "No");
117 : 0 : }
118 : :
119 : : static const char *
120 : 0 : hns3_get_fdir_tuple_name(uint32_t index)
121 : : {
122 : 0 : const char * const tuple_name[] = {
123 : : "outer_dst_mac",
124 : : "outer_src_mac",
125 : : "outer_vlan_1st_tag",
126 : : "outer_vlan_2nd_tag",
127 : : "outer_eth_type",
128 : : "outer_l2_rsv",
129 : : "outer_ip_tos",
130 : : "outer_ip_proto",
131 : : "outer_src_ip",
132 : : "outer_dst_ip",
133 : : "outer_l3_rsv",
134 : : "outer_src_port",
135 : : "outer_dst_port",
136 : : "outer_l4_rsv",
137 : : "outer_tun_vni",
138 : : "outer_tun_flow_id",
139 : : "inner_dst_mac",
140 : : "inner_src_mac",
141 : : "inner_vlan_tag1",
142 : : "inner_vlan_tag2",
143 : : "inner_eth_type",
144 : : "inner_l2_rsv",
145 : : "inner_ip_tos",
146 : : "inner_ip_proto",
147 : : "inner_src_ip",
148 : : "inner_dst_ip",
149 : : "inner_l3_rsv",
150 : : "inner_src_port",
151 : : "inner_dst_port",
152 : : "inner_sctp_tag",
153 : : };
154 [ # # ]: 0 : if (index < RTE_DIM(tuple_name))
155 : 0 : return tuple_name[index];
156 : : else
157 : : return "unknown";
158 : : }
159 : :
160 : : static void
161 : 0 : hns3_get_fdir_basic_info(FILE *file, struct hns3_pf *pf)
162 : : {
163 : : #define HNS3_PERLINE_TUPLE_NAME_LEN 4
164 : : struct hns3_fd_cfg *fdcfg = &pf->fdir.fd_cfg;
165 : : uint32_t i, count = 0;
166 : :
167 : : fprintf(file, " - Fdir Info:\n");
168 : 0 : fprintf(file,
169 : : "\t -- mode=%u max_key_len=%u rule_num:%u cnt_num:%u\n"
170 : : "\t -- key_sel=%u tuple_active=0x%x meta_data_active=0x%x\n"
171 : : "\t -- ipv6_word_en: in_s=%u in_d=%u out_s=%u out_d=%u\n"
172 : : "\t -- index_cfg: %s\n"
173 : : "\t -- tuple_config: %s\n"
174 : : "\t -- active_tuples:\n",
175 : 0 : fdcfg->fd_mode, fdcfg->max_key_length,
176 : : fdcfg->rule_num[HNS3_FD_STAGE_1],
177 : 0 : fdcfg->cnt_num[HNS3_FD_STAGE_1],
178 : 0 : fdcfg->key_cfg[HNS3_FD_STAGE_1].key_sel,
179 : : fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active,
180 : : fdcfg->key_cfg[HNS3_FD_STAGE_1].meta_data_active,
181 : 0 : fdcfg->key_cfg[HNS3_FD_STAGE_1].inner_sipv6_word_en,
182 : 0 : fdcfg->key_cfg[HNS3_FD_STAGE_1].inner_dipv6_word_en,
183 : 0 : fdcfg->key_cfg[HNS3_FD_STAGE_1].outer_sipv6_word_en,
184 : 0 : fdcfg->key_cfg[HNS3_FD_STAGE_1].outer_dipv6_word_en,
185 : : hns3_fdir_index_config_name(pf->fdir.index_cfg),
186 : : hns3_tuple_config_name(pf->fdir.tuple_cfg));
187 : :
188 [ # # ]: 0 : for (i = 0; i < MAX_TUPLE; i++) {
189 [ # # ]: 0 : if (!(fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active & BIT(i)))
190 : 0 : continue;
191 [ # # ]: 0 : if (count % HNS3_PERLINE_TUPLE_NAME_LEN == 0)
192 : : fprintf(file, "\t ");
193 : 0 : fprintf(file, " %s", hns3_get_fdir_tuple_name(i));
194 : 0 : count++;
195 [ # # ]: 0 : if (count % HNS3_PERLINE_TUPLE_NAME_LEN == 0)
196 : : fprintf(file, "\n");
197 : : }
198 [ # # ]: 0 : if (count % HNS3_PERLINE_TUPLE_NAME_LEN)
199 : : fprintf(file, "\n");
200 : 0 : }
201 : :
202 : : static void
203 : 0 : hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
204 : : {
205 : 0 : struct hns3_adapter *hns = dev->data->dev_private;
206 : : struct hns3_hw *hw = &hns->hw;
207 : :
208 [ # # # # : 0 : fprintf(file,
# # ]
209 : : " - Device Base Info:\n"
210 : : "\t -- name: %s\n"
211 : : "\t -- adapter_state=%s\n"
212 : : "\t -- nb_rx_queues=%u nb_tx_queues=%u\n"
213 : : "\t -- total_tqps_num=%u tqps_num=%u intr_tqps_num=%u\n"
214 : : "\t -- rss_size_max=%u alloc_rss_size=%u tx_qnum_per_tc=%u\n"
215 : : "\t -- min_tx_pkt_len=%u intr_mapping_mode=%u vlan_mode=%u\n"
216 : : "\t -- tso_mode=%u max_non_tso_bd_num=%u\n"
217 : : "\t -- max_tm_rate=%u Mbps\n"
218 : : "\t -- set link down: %s\n"
219 : : "\t -- rx_func_hint=%s tx_func_hint=%s\n"
220 : : "\t -- dev_flags: lsc=%d\n"
221 : : "\t -- intr_conf: lsc=%u rxq=%u\n",
222 : 0 : dev->data->name,
223 : : hns3_get_adapter_state_name(hw->adapter_state),
224 : 0 : dev->data->nb_rx_queues, dev->data->nb_tx_queues,
225 : 0 : hw->total_tqps_num, hw->tqps_num, hw->intr_tqps_num,
226 : 0 : hw->rss_size_max, hw->alloc_rss_size, hw->tx_qnum_per_tc,
227 : 0 : hw->min_tx_pkt_len, hw->intr.mapping_mode, hw->vlan_mode,
228 : 0 : hw->tso_mode, hw->max_non_tso_bd_num,
229 : : hw->max_tm_rate,
230 [ # # ]: 0 : hw->set_link_down ? "Yes" : "No",
231 : : hns3_get_io_func_hint_name(hns->rx_func_hint),
232 : : hns3_get_io_func_hint_name(hns->tx_func_hint),
233 : 0 : !!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC),
234 : 0 : dev->data->dev_conf.intr_conf.lsc,
235 [ # # # # : 0 : dev->data->dev_conf.intr_conf.rxq);
# # ]
236 : 0 : }
237 : :
238 : : static struct hns3_rx_queue *
239 : 0 : hns3_get_rx_queue(struct rte_eth_dev *dev)
240 : : {
241 : 0 : struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
242 : : struct hns3_rx_queue *rxq;
243 : : uint32_t queue_id;
244 : : void **rx_queues;
245 : :
246 [ # # ]: 0 : for (queue_id = 0; queue_id < dev->data->nb_rx_queues; queue_id++) {
247 : 0 : rx_queues = dev->data->rx_queues;
248 [ # # # # ]: 0 : if (rx_queues == NULL || rx_queues[queue_id] == NULL) {
249 : 0 : hns3_err(hw, "detect rx_queues is NULL!");
250 : 0 : return NULL;
251 : : }
252 : :
253 : : rxq = (struct hns3_rx_queue *)rx_queues[queue_id];
254 [ # # ]: 0 : if (rxq->rx_deferred_start)
255 : : continue;
256 : :
257 : : return rx_queues[queue_id];
258 : : }
259 : :
260 : : return NULL;
261 : : }
262 : :
263 : : static struct hns3_tx_queue *
264 : 0 : hns3_get_tx_queue(struct rte_eth_dev *dev)
265 : : {
266 : 0 : struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
267 : : struct hns3_tx_queue *txq;
268 : : uint32_t queue_id;
269 : : void **tx_queues;
270 : :
271 [ # # ]: 0 : for (queue_id = 0; queue_id < dev->data->nb_tx_queues; queue_id++) {
272 : 0 : tx_queues = dev->data->tx_queues;
273 [ # # # # ]: 0 : if (tx_queues == NULL || tx_queues[queue_id] == NULL) {
274 : 0 : hns3_err(hw, "detect tx_queues is NULL!");
275 : 0 : return NULL;
276 : : }
277 : :
278 : : txq = (struct hns3_tx_queue *)tx_queues[queue_id];
279 [ # # ]: 0 : if (txq->tx_deferred_start)
280 : : continue;
281 : :
282 : : return tx_queues[queue_id];
283 : : }
284 : :
285 : : return NULL;
286 : : }
287 : :
288 : : static void
289 : 0 : hns3_get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev)
290 : : {
291 : 0 : struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
292 : : struct hns3_rx_queue *rxq;
293 : : struct hns3_tx_queue *txq;
294 : : uint32_t queue_id = 0;
295 : : void **rx_queues;
296 : : void **tx_queues;
297 : :
298 [ # # ]: 0 : if (hns3_dev_get_support(hw, INDEP_TXRX))
299 : : return;
300 : :
301 [ # # ]: 0 : if (dev->data->nb_rx_queues < dev->data->nb_tx_queues) {
302 : 0 : rx_queues = hw->fkq_data.rx_queues;
303 [ # # # # ]: 0 : if (rx_queues == NULL || rx_queues[queue_id] == NULL) {
304 : 0 : hns3_err(hw, "detect rx_queues is NULL!");
305 : 0 : return;
306 : : }
307 : : rxq = (struct hns3_rx_queue *)rx_queues[queue_id];
308 : :
309 : 0 : fprintf(file,
310 : : "\t -- first fake_queue info:\n"
311 : : "\t Rx: port=%u nb_desc=%u free_thresh=%u\n",
312 : 0 : rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh);
313 [ # # ]: 0 : } else if (dev->data->nb_rx_queues > dev->data->nb_tx_queues) {
314 : 0 : tx_queues = hw->fkq_data.tx_queues;
315 : : queue_id = 0;
316 : :
317 [ # # # # ]: 0 : if (tx_queues == NULL || tx_queues[queue_id] == NULL) {
318 : 0 : hns3_err(hw, "detect tx_queues is NULL!");
319 : 0 : return;
320 : : }
321 : : txq = (struct hns3_tx_queue *)tx_queues[queue_id];
322 : :
323 : 0 : fprintf(file,
324 : : "\t -- first fake_queue info:\n"
325 : : "\t Tx: port=%u nb_desc=%u\n",
326 : 0 : txq->port_id, txq->nb_tx_desc);
327 : : }
328 : : }
329 : :
330 : : static void
331 : 0 : hns3_get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state,
332 : : uint32_t nb_queues, bool is_rxq)
333 : : {
334 : : #define HNS3_QUEUE_NUM_PER_STATS (sizeof(*queue_state) * HNS3_UINT8_BIT)
335 : : uint32_t queue_en_reg;
336 : : uint32_t reg_offset;
337 : : uint32_t state;
338 : : uint32_t i;
339 : :
340 [ # # ]: 0 : queue_en_reg = is_rxq ? HNS3_RING_RX_EN_REG : HNS3_RING_TX_EN_REG;
341 [ # # ]: 0 : for (i = 0; i < nb_queues; i++) {
342 : 0 : reg_offset = hns3_get_tqp_reg_offset(i);
343 : 0 : state = hns3_read_dev(hw, reg_offset + HNS3_RING_EN_REG);
344 [ # # ]: 0 : if (hns3_dev_get_support(hw, INDEP_TXRX))
345 [ # # # # ]: 0 : state = state && hns3_read_dev(hw, reg_offset +
346 : : queue_en_reg);
347 : 0 : hns3_set_bit(queue_state[i / HNS3_QUEUE_NUM_PER_STATS],
348 : : i % HNS3_QUEUE_NUM_PER_STATS, state);
349 : : }
350 : 0 : }
351 : :
352 : : static void
353 : 0 : hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state,
354 : : uint32_t nb_queues, uint32_t line_num)
355 : : {
356 : : #define HNS3_NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT)
357 : 0 : uint32_t id = line_num * HNS3_NUM_QUEUE_PER_LINE;
358 : : uint32_t i;
359 : :
360 [ # # ]: 0 : for (i = 0; i < HNS3_NUM_QUEUE_PER_LINE; i++) {
361 : 0 : fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], i));
362 : :
363 [ # # ]: 0 : if (id % HNS3_UINT8_BIT == HNS3_UINT8_BIT - 1) {
364 [ # # ]: 0 : fprintf(file, "%s",
365 : : i == HNS3_NUM_QUEUE_PER_LINE - 1 ? "\n" : ":");
366 : : }
367 : 0 : id++;
368 [ # # ]: 0 : if (id >= nb_queues) {
369 : : fprintf(file, "\n");
370 : : break;
371 : : }
372 : : }
373 : 0 : }
374 : :
375 : : static void
376 : 0 : hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state,
377 : : uint32_t nb_queues, bool is_rxq)
378 : : {
379 : : #define HNS3_NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT)
380 : : uint32_t i;
381 : :
382 [ # # ]: 0 : fprintf(file, "\t %s queue id | enable state bitMap\n",
383 : : is_rxq ? "Rx" : "Tx");
384 : :
385 [ # # ]: 0 : for (i = 0; i < (nb_queues - 1) / HNS3_NUM_QUEUE_PER_LINE + 1; i++) {
386 : 0 : uint32_t line_end = (i + 1) * HNS3_NUM_QUEUE_PER_LINE - 1;
387 : 0 : uint32_t line_start = i * HNS3_NUM_QUEUE_PER_LINE;
388 : 0 : fprintf(file, "\t %04u - %04u | ", line_start,
389 : : nb_queues - 1 > line_end ? line_end : nb_queues - 1);
390 : :
391 : 0 : hns3_print_queue_state_perline(file, queue_state, nb_queues, i);
392 : : }
393 : 0 : }
394 : :
395 : : static void
396 : 0 : hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev)
397 : : {
398 : 0 : struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
399 : : uint32_t *rx_queue_state;
400 : : uint32_t *tx_queue_state;
401 : : uint32_t nb_rx_queues;
402 : : uint32_t nb_tx_queues;
403 : : uint32_t bitmap_size;
404 : :
405 : 0 : nb_rx_queues = dev->data->nb_rx_queues;
406 : 0 : nb_tx_queues = dev->data->nb_tx_queues;
407 [ # # ]: 0 : if (nb_rx_queues == 0) {
408 : : fprintf(file, "\t -- Rx queue number is 0\n");
409 : 0 : return;
410 : : }
411 [ # # ]: 0 : if (nb_tx_queues == 0) {
412 : : fprintf(file, "\t -- Tx queue number is 0\n");
413 : 0 : return;
414 : : }
415 : :
416 : 0 : bitmap_size = (hw->tqps_num * sizeof(uint32_t) + HNS3_UINT32_BIT) /
417 : : HNS3_UINT32_BIT;
418 : 0 : rx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0);
419 [ # # ]: 0 : if (rx_queue_state == NULL) {
420 : 0 : hns3_err(hw, "Failed to allocate memory for rx queue state!");
421 : 0 : return;
422 : : }
423 : :
424 : 0 : tx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0);
425 [ # # ]: 0 : if (tx_queue_state == NULL) {
426 : 0 : hns3_err(hw, "Failed to allocate memory for tx queue state!");
427 : 0 : rte_free(rx_queue_state);
428 : 0 : return;
429 : : }
430 : :
431 : : fprintf(file, "\t -- enable state:\n");
432 : 0 : hns3_get_queue_enable_state(hw, rx_queue_state, nb_rx_queues, true);
433 : 0 : hns3_display_queue_enable_state(file, rx_queue_state, nb_rx_queues,
434 : : true);
435 : :
436 : 0 : hns3_get_queue_enable_state(hw, tx_queue_state, nb_tx_queues, false);
437 : 0 : hns3_display_queue_enable_state(file, tx_queue_state, nb_tx_queues,
438 : : false);
439 : 0 : rte_free(rx_queue_state);
440 : 0 : rte_free(tx_queue_state);
441 : : }
442 : :
443 : : static void
444 : 0 : hns3_get_rxtx_queue_head_tail_pointer(FILE *file, struct rte_eth_dev *dev)
445 : : {
446 : 0 : struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
447 : : uint32_t reg_offset, queue_id;
448 : : void **rx_queues, **tx_queues;
449 : : struct hns3_rx_queue *rxq;
450 : : struct hns3_tx_queue *txq;
451 : : uint16_t sw_hold;
452 : :
453 : 0 : rx_queues = dev->data->rx_queues;
454 [ # # ]: 0 : if (rx_queues == NULL)
455 : : return;
456 : 0 : tx_queues = dev->data->tx_queues;
457 [ # # ]: 0 : if (tx_queues == NULL)
458 : : return;
459 : :
460 : : fprintf(file, "\t -- Rx queue head and tail info:\n");
461 : : fprintf(file, "\t qid sw_head sw_hold hw_head hw_tail\n");
462 [ # # ]: 0 : for (queue_id = 0; queue_id < dev->data->nb_rx_queues; queue_id++) {
463 [ # # ]: 0 : if (rx_queues[queue_id] == NULL)
464 : 0 : continue;
465 : : rxq = (struct hns3_rx_queue *)rx_queues[queue_id];
466 [ # # ]: 0 : if (rxq->rx_deferred_start)
467 : 0 : continue;
468 : :
469 [ # # # # ]: 0 : if (dev->rx_pkt_burst == hns3_recv_pkts_vec ||
470 : : dev->rx_pkt_burst == hns3_recv_pkts_vec_sve)
471 : 0 : sw_hold = rxq->rx_rearm_nb;
472 : : else
473 : 0 : sw_hold = rxq->rx_free_hold;
474 : :
475 : 0 : reg_offset = hns3_get_tqp_reg_offset(queue_id);
476 : 0 : fprintf(file, "\t %-5u%-9u%-9u%-9u%u\n", queue_id,
477 : 0 : rxq->next_to_use, sw_hold,
478 : : hns3_read_dev(hw, HNS3_RING_RX_HEAD_REG + reg_offset),
479 : : hns3_read_dev(hw, HNS3_RING_RX_TAIL_REG + reg_offset));
480 : : }
481 : :
482 : : fprintf(file, "\t -- Tx queue head and tail info:\n");
483 : : fprintf(file, "\t qid sw_head sw_tail hw_head hw_tail\n");
484 [ # # ]: 0 : for (queue_id = 0; queue_id < dev->data->nb_tx_queues; queue_id++) {
485 [ # # ]: 0 : if (tx_queues[queue_id] == NULL)
486 : 0 : continue;
487 : : txq = (struct hns3_tx_queue *)tx_queues[queue_id];
488 [ # # ]: 0 : if (txq->tx_deferred_start)
489 : 0 : continue;
490 : :
491 : 0 : reg_offset = hns3_get_tqp_reg_offset(queue_id);
492 : 0 : fprintf(file, "\t %-5u%-9u%-9u%-9u%u\n", queue_id,
493 : 0 : txq->next_to_clean, txq->next_to_use,
494 : : hns3_read_dev(hw, HNS3_RING_TX_HEAD_REG + reg_offset),
495 : : hns3_read_dev(hw, HNS3_RING_TX_TAIL_REG + reg_offset));
496 : : }
497 : : }
498 : :
499 : : static void
500 : 0 : hns3_get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev)
501 : : {
502 : : struct hns3_rx_queue *rxq;
503 : : struct hns3_tx_queue *txq;
504 : :
505 : 0 : rxq = hns3_get_rx_queue(dev);
506 [ # # ]: 0 : if (rxq == NULL)
507 : : return;
508 : 0 : txq = hns3_get_tx_queue(dev);
509 [ # # ]: 0 : if (txq == NULL)
510 : : return;
511 : : fprintf(file, " - Rx/Tx Queue Info:\n");
512 : 0 : fprintf(file,
513 : : "\t -- first queue rxtx info:\n"
514 : : "\t Rx: port=%u nb_desc=%u free_thresh=%u\n"
515 : : "\t Tx: port=%u nb_desc=%u\n"
516 : : "\t -- tx push: %s\n",
517 : 0 : rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh,
518 : 0 : txq->port_id, txq->nb_tx_desc,
519 [ # # ]: 0 : txq->tx_push_enable ? "enabled" : "disabled");
520 : :
521 : 0 : hns3_get_rxtx_fake_queue_info(file, dev);
522 : 0 : hns3_get_rxtx_queue_enable_state(file, dev);
523 : 0 : hns3_get_rxtx_queue_head_tail_pointer(file, dev);
524 : : }
525 : :
526 : : static int
527 : 0 : hns3_get_vlan_filter_cfg(FILE *file, struct hns3_hw *hw)
528 : : {
529 : : #define HNS3_FILTER_TYPE_VF 0
530 : : #define HNS3_FILTER_TYPE_PORT 1
531 : : #define HNS3_FILTER_FE_NIC_INGRESS_B BIT(0)
532 : : #define HNS3_FILTER_FE_NIC_EGRESS_B BIT(1)
533 : : struct hns3_vlan_filter_ctrl_cmd *req;
534 : : struct hns3_cmd_desc desc;
535 : : uint8_t i;
536 : : int ret;
537 : :
538 : : static const uint32_t vlan_filter_type[] = {
539 : : HNS3_FILTER_TYPE_PORT,
540 : : HNS3_FILTER_TYPE_VF
541 : : };
542 : :
543 [ # # ]: 0 : for (i = 0; i < RTE_DIM(vlan_filter_type); i++) {
544 : 0 : hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_FILTER_CTRL,
545 : : true);
546 : : req = (struct hns3_vlan_filter_ctrl_cmd *)desc.data;
547 : 0 : req->vlan_type = vlan_filter_type[i];
548 : 0 : req->vf_id = HNS3_PF_FUNC_ID;
549 : 0 : ret = hns3_cmd_send(hw, &desc, 1);
550 [ # # ]: 0 : if (ret != 0) {
551 : 0 : hns3_err(hw,
552 : : "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!",
553 : : ret, 1, rte_le_to_cpu_16(desc.opcode));
554 : 0 : return ret;
555 : : }
556 [ # # ]: 0 : fprintf(file,
557 : : "\t -- %s VLAN filter configuration\n"
558 : : "\t nic_ingress :%s\n"
559 : : "\t nic_egress :%s\n",
560 [ # # ]: 0 : req->vlan_type == HNS3_FILTER_TYPE_PORT ?
561 : : "Port" : "VF",
562 : : req->vlan_fe & HNS3_FILTER_FE_NIC_INGRESS_B ?
563 : : "Enable" : "Disable",
564 [ # # ]: 0 : req->vlan_fe & HNS3_FILTER_FE_NIC_EGRESS_B ?
565 : : "Enable" : "Disable");
566 : : }
567 : :
568 : : return 0;
569 : : }
570 : :
571 : : static int
572 : 0 : hns3_get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw)
573 : : {
574 : : struct hns3_vport_vtag_rx_cfg_cmd *req;
575 : : struct hns3_cmd_desc desc;
576 : : uint16_t vport_id;
577 : : uint8_t bitmap;
578 : : int ret;
579 : :
580 : 0 : hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_RX_CFG, true);
581 : : req = (struct hns3_vport_vtag_rx_cfg_cmd *)desc.data;
582 : : vport_id = HNS3_PF_FUNC_ID;
583 : 0 : req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD;
584 : : bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE);
585 : 0 : req->vf_bitmap[req->vf_offset] = bitmap;
586 : :
587 : : /*
588 : : * current version VF is not supported when PF is driven by DPDK driver,
589 : : * just need to configure rx parameters for PF vport.
590 : : */
591 : 0 : ret = hns3_cmd_send(hw, &desc, 1);
592 [ # # ]: 0 : if (ret != 0) {
593 : 0 : hns3_err(hw,
594 : : "NIC firmware exec ret=%d optcode=0x%x!", ret,
595 : : rte_le_to_cpu_16(desc.opcode));
596 : 0 : return ret;
597 : : }
598 : :
599 [ # # # # : 0 : fprintf(file,
# # # # #
# ]
600 : : "\t -- RX VLAN configuration\n"
601 : : "\t vlan1_strip_en :%s\n"
602 : : "\t vlan2_strip_en :%s\n"
603 : : "\t vlan1_vlan_prionly :%s\n"
604 : : "\t vlan2_vlan_prionly :%s\n"
605 : : "\t vlan1_strip_discard :%s\n"
606 : : "\t vlan2_strip_discard :%s\n",
607 : : hns3_get_bit(req->vport_vlan_cfg,
608 : : HNS3_REM_TAG1_EN_B) ? "Enable" : "Disable",
609 : : hns3_get_bit(req->vport_vlan_cfg,
610 : : HNS3_REM_TAG2_EN_B) ? "Enable" : "Disable",
611 : : hns3_get_bit(req->vport_vlan_cfg,
612 : : HNS3_SHOW_TAG1_EN_B) ? "Enable" : "Disable",
613 : : hns3_get_bit(req->vport_vlan_cfg,
614 : : HNS3_SHOW_TAG2_EN_B) ? "Enable" : "Disable",
615 : : hns3_get_bit(req->vport_vlan_cfg,
616 : : HNS3_DISCARD_TAG1_EN_B) ? "Enable" : "Disable",
617 [ # # ]: 0 : hns3_get_bit(req->vport_vlan_cfg,
618 : : HNS3_DISCARD_TAG2_EN_B) ? "Enable" : "Disable");
619 : :
620 : 0 : return 0;
621 : : }
622 : :
623 : : static void
624 : 0 : hns3_parse_tx_vlan_cfg(FILE *file, struct hns3_vport_vtag_tx_cfg_cmd *req)
625 : : {
626 : : #define VLAN_VID_MASK 0x0fff
627 : : #define VLAN_PRIO_SHIFT 13
628 : :
629 [ # # # # : 0 : fprintf(file,
# # # # ]
630 : : "\t -- TX VLAN configuration\n"
631 : : "\t accept_tag1 :%s\n"
632 : : "\t accept_untag1 :%s\n"
633 : : "\t insert_tag1_en :%s\n"
634 : : "\t default_vlan_tag1 = %d, qos = %d\n"
635 : : "\t accept_tag2 :%s\n"
636 : : "\t accept_untag2 :%s\n"
637 : : "\t insert_tag2_en :%s\n"
638 : : "\t default_vlan_tag2 = %d, qos = %d\n"
639 : : "\t vlan_shift_mode :%s\n",
640 : : hns3_get_bit(req->vport_vlan_cfg,
641 : : HNS3_ACCEPT_TAG1_B) ? "Enable" : "Disable",
642 : : hns3_get_bit(req->vport_vlan_cfg,
643 : : HNS3_ACCEPT_UNTAG1_B) ? "Enable" : "Disable",
644 : : hns3_get_bit(req->vport_vlan_cfg,
645 : : HNS3_PORT_INS_TAG1_EN_B) ? "Enable" : "Disable",
646 : : req->def_vlan_tag1 & VLAN_VID_MASK,
647 [ # # ]: 0 : req->def_vlan_tag1 >> VLAN_PRIO_SHIFT,
648 : : hns3_get_bit(req->vport_vlan_cfg,
649 : : HNS3_ACCEPT_TAG2_B) ? "Enable" : "Disable",
650 : : hns3_get_bit(req->vport_vlan_cfg,
651 : : HNS3_ACCEPT_UNTAG2_B) ? "Enable" : "Disable",
652 : : hns3_get_bit(req->vport_vlan_cfg,
653 : : HNS3_PORT_INS_TAG2_EN_B) ? "Enable" : "Disable",
654 : : req->def_vlan_tag2 & VLAN_VID_MASK,
655 [ # # ]: 0 : req->def_vlan_tag2 >> VLAN_PRIO_SHIFT,
656 : 0 : hns3_get_bit(req->vport_vlan_cfg,
657 [ # # ]: 0 : HNS3_TAG_SHIFT_MODE_EN_B) ? "Enable" :
658 : : "Disable");
659 : 0 : }
660 : :
661 : : static int
662 : 0 : hns3_get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw)
663 : : {
664 : : struct hns3_vport_vtag_tx_cfg_cmd *req;
665 : : struct hns3_cmd_desc desc;
666 : : uint16_t vport_id;
667 : : uint8_t bitmap;
668 : : int ret;
669 : :
670 : 0 : hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_TX_CFG, true);
671 : : req = (struct hns3_vport_vtag_tx_cfg_cmd *)desc.data;
672 : : vport_id = HNS3_PF_FUNC_ID;
673 : 0 : req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD;
674 : : bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE);
675 : 0 : req->vf_bitmap[req->vf_offset] = bitmap;
676 : : /*
677 : : * current version VF is not supported when PF is driven by DPDK driver,
678 : : * just need to configure tx parameters for PF vport.
679 : : */
680 : 0 : ret = hns3_cmd_send(hw, &desc, 1);
681 [ # # ]: 0 : if (ret != 0) {
682 : 0 : hns3_err(hw,
683 : : "NIC firmware exec ret=%d desc_num=%d optcode=0x%x!",
684 : : ret, 1, rte_le_to_cpu_16(desc.opcode));
685 : 0 : return ret;
686 : : }
687 : :
688 : 0 : hns3_parse_tx_vlan_cfg(file, req);
689 : :
690 : 0 : return 0;
691 : : }
692 : :
693 : : static void
694 : : hns3_get_port_pvid_info(FILE *file, struct hns3_hw *hw)
695 : : {
696 : 0 : fprintf(file, " - pvid status: %s\n",
697 [ # # ]: 0 : hw->port_base_vlan_cfg.state ? "On" : "Off");
698 : : }
699 : :
700 : : static void
701 : 0 : hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw)
702 : : {
703 : : int ret;
704 : :
705 : : fprintf(file, " - VLAN Config Info:\n");
706 : 0 : ret = hns3_get_vlan_filter_cfg(file, hw);
707 [ # # ]: 0 : if (ret < 0)
708 : : return;
709 : :
710 : 0 : ret = hns3_get_vlan_rx_offload_cfg(file, hw);
711 [ # # ]: 0 : if (ret < 0)
712 : : return;
713 : :
714 : 0 : ret = hns3_get_vlan_tx_offload_cfg(file, hw);
715 : : if (ret < 0)
716 : : return;
717 : : }
718 : :
719 : : static void
720 : 0 : hns3_get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf)
721 : : {
722 : : struct hns3_shaper_profile_list *shaper_profile_list =
723 : : &conf->shaper_profile_list;
724 : : struct hns3_tm_shaper_profile *shaper_profile;
725 : :
726 [ # # ]: 0 : if (conf->nb_shaper_profile == 0)
727 : : return;
728 : :
729 : : fprintf(file, "\t -- shaper_profile:\n");
730 [ # # ]: 0 : TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) {
731 : 0 : fprintf(file,
732 : : "\t id=%u reference_count=%u peak_rate=%" PRIu64 "Bps\n",
733 : : shaper_profile->shaper_profile_id,
734 : : shaper_profile->reference_count,
735 : : shaper_profile->profile.peak.rate);
736 : : }
737 : : }
738 : :
739 : : static void
740 : 0 : hns3_get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf)
741 : : {
742 [ # # ]: 0 : if (conf->root == NULL)
743 : : return;
744 : :
745 : 0 : fprintf(file,
746 : : "\t -- port_node:\n"
747 : : "\t node_id=%u reference_count=%u shaper_profile_id=%d\n",
748 : : conf->root->id, conf->root->reference_count,
749 [ # # ]: 0 : conf->root->shaper_profile ?
750 : 0 : (int)conf->root->shaper_profile->shaper_profile_id : -1);
751 : : }
752 : :
753 : : static void
754 : 0 : hns3_get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf)
755 : : {
756 : : struct hns3_tm_node_list *tc_list = &conf->tc_list;
757 : : struct hns3_tm_node *tc_node[HNS3_MAX_TC_NUM];
758 : : struct hns3_tm_node *tm_node;
759 : : uint32_t tidx;
760 : :
761 [ # # ]: 0 : if (conf->nb_tc_node == 0)
762 : 0 : return;
763 : :
764 : : fprintf(file, "\t -- tc_node:\n");
765 : : memset(tc_node, 0, sizeof(tc_node));
766 [ # # ]: 0 : TAILQ_FOREACH(tm_node, tc_list, node) {
767 [ # # ]: 0 : tidx = hns3_tm_calc_node_tc_no(conf, tm_node->id);
768 [ # # ]: 0 : if (tidx < HNS3_MAX_TC_NUM)
769 : 0 : tc_node[tidx] = tm_node;
770 : : }
771 : :
772 [ # # ]: 0 : for (tidx = 0; tidx < HNS3_MAX_TC_NUM; tidx++) {
773 : 0 : tm_node = tc_node[tidx];
774 [ # # ]: 0 : if (tm_node == NULL)
775 : 0 : continue;
776 : 0 : fprintf(file,
777 : : "\t id=%u TC%u reference_count=%u parent_id=%d "
778 : : "shaper_profile_id=%d\n",
779 [ # # ]: 0 : tm_node->id, hns3_tm_calc_node_tc_no(conf, tm_node->id),
780 : : tm_node->reference_count,
781 [ # # ]: 0 : tm_node->parent ? (int)tm_node->parent->id : -1,
782 [ # # ]: 0 : tm_node->shaper_profile ?
783 : 0 : (int)tm_node->shaper_profile->shaper_profile_id : -1);
784 : : }
785 : : }
786 : :
787 : : static void
788 : 0 : hns3_get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node,
789 : : uint32_t *queue_node_tc,
790 : : uint32_t nb_tx_queues)
791 : : {
792 : : #define HNS3_PERLINE_QUEUES 32
793 : : #define HNS3_PERLINE_STRIDE 8
794 : : uint32_t i, j, line_num, start_queue_id, end_queue_id;
795 : :
796 : 0 : line_num = (nb_tx_queues + HNS3_PERLINE_QUEUES - 1) /
797 : : HNS3_PERLINE_QUEUES;
798 [ # # ]: 0 : for (i = 0; i < line_num; i++) {
799 : 0 : start_queue_id = i * HNS3_PERLINE_QUEUES;
800 : 0 : end_queue_id = (i + 1) * HNS3_PERLINE_QUEUES - 1;
801 : 0 : if (end_queue_id > nb_tx_queues - 1)
802 : : end_queue_id = nb_tx_queues - 1;
803 : : fprintf(file, "\t %04u - %04u | ", start_queue_id,
804 : : end_queue_id);
805 [ # # ]: 0 : for (j = start_queue_id; j < nb_tx_queues; j++) {
806 [ # # ]: 0 : if (j >= end_queue_id + 1)
807 : : break;
808 [ # # # # ]: 0 : if (j > start_queue_id && j % HNS3_PERLINE_STRIDE == 0)
809 : : fprintf(file, ":");
810 : 0 : fprintf(file, "%u",
811 [ # # ]: 0 : queue_node[j] ? queue_node_tc[j] :
812 : : HNS3_MAX_TC_NUM);
813 : : }
814 : : fprintf(file, "\n");
815 : : }
816 : 0 : }
817 : :
818 : : static void
819 : 0 : hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf,
820 : : uint32_t nb_tx_queues)
821 : 0 : {
822 : : struct hns3_tm_node_list *queue_list = &conf->queue_list;
823 : 0 : uint32_t nb_queue_node = conf->nb_leaf_nodes_max + 1;
824 : 0 : struct hns3_tm_node *queue_node[nb_queue_node];
825 : 0 : uint32_t queue_node_tc[nb_queue_node];
826 : : struct hns3_tm_node *tm_node;
827 : :
828 [ # # ]: 0 : if (conf->nb_queue_node == 0)
829 : 0 : return;
830 : :
831 : : fprintf(file,
832 : : "\t -- queue_node:\n"
833 : : "\t tx queue id | mapped tc (8 mean node not exist)\n");
834 : :
835 : : memset(queue_node, 0, sizeof(queue_node));
836 : : memset(queue_node_tc, 0, sizeof(queue_node_tc));
837 : 0 : nb_tx_queues = RTE_MIN(nb_tx_queues, nb_queue_node);
838 [ # # ]: 0 : TAILQ_FOREACH(tm_node, queue_list, node) {
839 [ # # ]: 0 : if (tm_node->id >= nb_queue_node)
840 : 0 : continue;
841 : 0 : queue_node[tm_node->id] = tm_node;
842 : 0 : queue_node_tc[tm_node->id] = tm_node->parent ?
843 [ # # # # ]: 0 : hns3_tm_calc_node_tc_no(conf, tm_node->parent->id) : 0;
844 : 0 : nb_tx_queues = RTE_MAX(nb_tx_queues, tm_node->id + 1);
845 : : }
846 : :
847 : 0 : hns3_get_tm_conf_queue_format_info(file, queue_node, queue_node_tc,
848 : : nb_tx_queues);
849 : : }
850 : :
851 : : static void
852 : 0 : hns3_get_tm_conf_info(FILE *file, struct rte_eth_dev *dev)
853 : : {
854 : 0 : struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
855 : : struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
856 : 0 : struct hns3_tm_conf *conf = &pf->tm_conf;
857 : :
858 [ # # ]: 0 : if (!hns3_dev_get_support(hw, TM))
859 : : return;
860 : :
861 : : fprintf(file, " - TM config info:\n");
862 : 0 : fprintf(file,
863 : : "\t -- nb_leaf_nodes_max=%u nb_nodes_max=%u\n"
864 : : "\t -- nb_shaper_profile=%u nb_tc_node=%u nb_queue_node=%u\n"
865 : : "\t -- committed=%u\n",
866 : : conf->nb_leaf_nodes_max, conf->nb_nodes_max,
867 : : conf->nb_shaper_profile, conf->nb_tc_node, conf->nb_queue_node,
868 : 0 : conf->committed);
869 : :
870 : 0 : hns3_get_tm_conf_shaper_info(file, conf);
871 : 0 : hns3_get_tm_conf_port_node_info(file, conf);
872 : 0 : hns3_get_tm_conf_tc_node_info(file, conf);
873 : 0 : hns3_get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues);
874 : : }
875 : :
876 : : static void
877 : : hns3_fc_mode_to_rxtx_pause(enum hns3_fc_mode fc_mode, bool *rx_pause,
878 : : bool *tx_pause)
879 : : {
880 : : switch (fc_mode) {
881 : : case HNS3_FC_NONE:
882 : : *tx_pause = false;
883 : : *rx_pause = false;
884 : : break;
885 : : case HNS3_FC_RX_PAUSE:
886 : : *rx_pause = true;
887 : : *tx_pause = false;
888 : : break;
889 : : case HNS3_FC_TX_PAUSE:
890 : : *rx_pause = false;
891 : : *tx_pause = true;
892 : : break;
893 : : case HNS3_FC_FULL:
894 : : *rx_pause = true;
895 : : *tx_pause = true;
896 : : break;
897 : : default:
898 : : *rx_pause = false;
899 : : *tx_pause = false;
900 : : break;
901 : : }
902 : : }
903 : :
904 : : static bool
905 : : hns3_is_link_fc_mode(struct hns3_adapter *hns)
906 : : {
907 : : struct hns3_hw *hw = &hns->hw;
908 : : struct hns3_pf *pf = &hns->pf;
909 : :
910 : 0 : if (hw->current_fc_status == HNS3_FC_STATUS_PFC)
911 : : return false;
912 : :
913 [ # # # # ]: 0 : if (hw->num_tc > 1 && !pf->support_multi_tc_pause)
914 : : return false;
915 : :
916 : : return true;
917 : : }
918 : :
919 : : static void
920 : 0 : hns3_get_link_fc_info(FILE *file, struct rte_eth_dev *dev)
921 : : {
922 [ # # ]: 0 : struct hns3_adapter *hns = dev->data->dev_private;
923 : : struct hns3_hw *hw = &hns->hw;
924 : : struct rte_eth_fc_conf cur_fc_conf;
925 : : bool rx_pause1;
926 : : bool tx_pause1;
927 : : bool rx_pause2;
928 : : bool tx_pause2;
929 : : int ret;
930 : :
931 : : if (!hns3_is_link_fc_mode(hns))
932 : 0 : return;
933 : :
934 : 0 : ret = hns3_flow_ctrl_get(dev, &cur_fc_conf);
935 [ # # ]: 0 : if (ret) {
936 : : fprintf(file, "get device flow control info fail!\n");
937 : 0 : return;
938 : : }
939 : :
940 [ # # ]: 0 : hns3_fc_mode_to_rxtx_pause(hw->requested_fc_mode,
941 : : &rx_pause1, &tx_pause1);
942 [ # # ]: 0 : hns3_fc_mode_to_rxtx_pause((enum hns3_fc_mode)cur_fc_conf.mode,
943 : : &rx_pause2, &tx_pause2);
944 : :
945 [ # # # # : 0 : fprintf(file,
# # # # ]
946 : : "\t -- link_fc_info:\n"
947 : : "\t Requested fc:\n"
948 : : "\t Rx: %s\n"
949 : : "\t Tx: %s\n"
950 : : "\t Current fc:\n"
951 : : "\t Rx: %s\n"
952 : : "\t Tx: %s\n"
953 : : "\t Autonegotiate: %s\n"
954 : : "\t Pause time: 0x%x\n",
955 : : rx_pause1 ? "On" : "Off", tx_pause1 ? "On" : "Off",
956 : : rx_pause2 ? "On" : "Off", tx_pause2 ? "On" : "Off",
957 : 0 : cur_fc_conf.autoneg == RTE_ETH_LINK_AUTONEG ? "On" : "Off",
958 [ # # ]: 0 : cur_fc_conf.pause_time);
959 : : }
960 : :
961 : : static void
962 : 0 : hns3_get_flow_ctrl_info(FILE *file, struct rte_eth_dev *dev)
963 : : {
964 : 0 : struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
965 : :
966 : : fprintf(file, " - Flow Ctrl Info:\n");
967 : : fprintf(file,
968 : : "\t -- fc_common_info:\n"
969 : : "\t current_fc_status=%u\n"
970 : : "\t requested_fc_mode=%u\n",
971 : 0 : hw->current_fc_status,
972 : 0 : hw->requested_fc_mode);
973 : :
974 : 0 : hns3_get_link_fc_info(file, dev);
975 : 0 : }
976 : :
977 : : int
978 : 0 : hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
979 : : {
980 : 0 : struct hns3_adapter *hns = dev->data->dev_private;
981 : 0 : struct hns3_hw *hw = &hns->hw;
982 : :
983 : 0 : rte_spinlock_lock(&hw->lock);
984 : :
985 : 0 : hns3_get_device_basic_info(file, dev);
986 : 0 : hns3_get_dev_feature_capability(file, hw);
987 : 0 : hns3_get_rxtx_queue_info(file, dev);
988 : : hns3_get_port_pvid_info(file, hw);
989 : :
990 : : /*
991 : : * VF only supports dumping basic info, feature capability and queue
992 : : * info.
993 : : */
994 [ # # ]: 0 : if (hns->is_vf) {
995 : : rte_spinlock_unlock(&hw->lock);
996 : 0 : return 0;
997 : : }
998 : :
999 : 0 : hns3_get_dev_mac_info(file, hns);
1000 : 0 : hns3_get_vlan_config_info(file, hw);
1001 : 0 : hns3_get_fdir_basic_info(file, &hns->pf);
1002 : 0 : hns3_get_tm_conf_info(file, dev);
1003 : 0 : hns3_get_flow_ctrl_info(file, dev);
1004 : :
1005 : : rte_spinlock_unlock(&hw->lock);
1006 : :
1007 : 0 : return 0;
1008 : : }
1009 : :
1010 : : int
1011 : 0 : hns3_rx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
1012 : : uint16_t offset, uint16_t num, FILE *file)
1013 : : {
1014 : 0 : struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1015 : 0 : struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
1016 : : uint32_t *bd_data;
1017 : : uint16_t count = 0;
1018 : : uint16_t desc_id;
1019 : : int i;
1020 : :
1021 [ # # ]: 0 : if (offset >= rxq->nb_rx_desc)
1022 : : return -EINVAL;
1023 : :
1024 [ # # ]: 0 : if (num > rxq->nb_rx_desc) {
1025 : 0 : hns3_err(hw, "Invalid BD num=%u", num);
1026 : 0 : return -EINVAL;
1027 : : }
1028 : :
1029 [ # # ]: 0 : while (count < num) {
1030 : 0 : desc_id = (rxq->next_to_use + offset + count) % rxq->nb_rx_desc;
1031 : 0 : bd_data = (uint32_t *)(&rxq->rx_ring[desc_id]);
1032 : 0 : fprintf(file, "Rx queue id:%u BD id:%u\n", queue_id, desc_id);
1033 [ # # ]: 0 : for (i = 0; i < HNS3_BD_DW_NUM; i++) {
1034 : : /*
1035 : : * For the sake of security, first 8 bytes of BD which
1036 : : * stands for physical address of packet should not be
1037 : : * shown.
1038 : : */
1039 [ # # ]: 0 : if (i < HNS3_BD_ADDRESS_LAST_DW) {
1040 : : fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, 0);
1041 : 0 : continue;
1042 : : }
1043 : 0 : fprintf(file, "RX BD WORD[%d]:0x%08x\n", i,
1044 : 0 : *(bd_data + i));
1045 : : }
1046 : 0 : count++;
1047 : : }
1048 : :
1049 : : return 0;
1050 : : }
1051 : :
1052 : : int
1053 : 0 : hns3_tx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
1054 : : uint16_t offset, uint16_t num, FILE *file)
1055 : : {
1056 : 0 : struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1057 : 0 : struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id];
1058 : : uint32_t *bd_data;
1059 : : uint16_t count = 0;
1060 : : uint16_t desc_id;
1061 : : int i;
1062 : :
1063 [ # # ]: 0 : if (offset >= txq->nb_tx_desc)
1064 : : return -EINVAL;
1065 : :
1066 [ # # ]: 0 : if (num > txq->nb_tx_desc) {
1067 : 0 : hns3_err(hw, "Invalid BD num=%u", num);
1068 : 0 : return -EINVAL;
1069 : : }
1070 : :
1071 [ # # ]: 0 : while (count < num) {
1072 : 0 : desc_id = (txq->next_to_use + offset + count) % txq->nb_tx_desc;
1073 : 0 : bd_data = (uint32_t *)(&txq->tx_ring[desc_id]);
1074 : 0 : fprintf(file, "Tx queue id:%u BD id:%u\n", queue_id, desc_id);
1075 [ # # ]: 0 : for (i = 0; i < HNS3_BD_DW_NUM; i++) {
1076 : : /*
1077 : : * For the sake of security, first 8 bytes of BD which
1078 : : * stands for physical address of packet should not be
1079 : : * shown.
1080 : : */
1081 [ # # ]: 0 : if (i < HNS3_BD_ADDRESS_LAST_DW) {
1082 : : fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0);
1083 : 0 : continue;
1084 : : }
1085 : :
1086 : 0 : fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i,
1087 : 0 : *(bd_data + i));
1088 : : }
1089 : 0 : count++;
1090 : : }
1091 : :
1092 : : return 0;
1093 : : }
|