Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3 : : * Copyright(c) 2010-2017 Intel Corporation
4 : : */
5 : :
6 : : #include <errno.h>
7 : : #include <rte_common.h>
8 : : #include <ethdev_pci.h>
9 : :
10 : : #include <rte_alarm.h>
11 : :
12 : : #include "ngbe_logs.h"
13 : : #include "ngbe.h"
14 : : #include "ngbe_ethdev.h"
15 : : #include "ngbe_rxtx.h"
16 : : #include "ngbe_regs_group.h"
17 : :
18 : : static const struct reg_info ngbe_regs_general[] = {
19 : : {NGBE_RST, 1, 1, "NGBE_RST"},
20 : : {NGBE_STAT, 1, 1, "NGBE_STAT"},
21 : : {NGBE_PORTCTL, 1, 1, "NGBE_PORTCTL"},
22 : : {NGBE_GPIODATA, 1, 1, "NGBE_GPIODATA"},
23 : : {NGBE_GPIOCTL, 1, 1, "NGBE_GPIOCTL"},
24 : : {NGBE_LEDCTL, 1, 1, "NGBE_LEDCTL"},
25 : : {0, 0, 0, ""}
26 : : };
27 : :
28 : : static const struct reg_info ngbe_regs_nvm[] = {
29 : : {0, 0, 0, ""}
30 : : };
31 : :
32 : : static const struct reg_info ngbe_regs_interrupt[] = {
33 : : {0, 0, 0, ""}
34 : : };
35 : :
36 : : static const struct reg_info ngbe_regs_fctl_others[] = {
37 : : {0, 0, 0, ""}
38 : : };
39 : :
40 : : static const struct reg_info ngbe_regs_rxdma[] = {
41 : : {0, 0, 0, ""}
42 : : };
43 : :
44 : : static const struct reg_info ngbe_regs_rx[] = {
45 : : {0, 0, 0, ""}
46 : : };
47 : :
48 : : static struct reg_info ngbe_regs_tx[] = {
49 : : {0, 0, 0, ""}
50 : : };
51 : :
52 : : static const struct reg_info ngbe_regs_wakeup[] = {
53 : : {0, 0, 0, ""}
54 : : };
55 : :
56 : : static const struct reg_info ngbe_regs_mac[] = {
57 : : {0, 0, 0, ""}
58 : : };
59 : :
60 : : static const struct reg_info ngbe_regs_diagnostic[] = {
61 : : {0, 0, 0, ""},
62 : : };
63 : :
64 : : /* PF registers */
65 : : static const struct reg_info *ngbe_regs_others[] = {
66 : : ngbe_regs_general,
67 : : ngbe_regs_nvm,
68 : : ngbe_regs_interrupt,
69 : : ngbe_regs_fctl_others,
70 : : ngbe_regs_rxdma,
71 : : ngbe_regs_rx,
72 : : ngbe_regs_tx,
73 : : ngbe_regs_wakeup,
74 : : ngbe_regs_mac,
75 : : ngbe_regs_diagnostic,
76 : : NULL};
77 : :
78 : : static int ngbe_dev_close(struct rte_eth_dev *dev);
79 : : static int ngbe_dev_link_update(struct rte_eth_dev *dev,
80 : : int wait_to_complete);
81 : : static int ngbe_dev_stats_reset(struct rte_eth_dev *dev);
82 : : static void ngbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
83 : : static void ngbe_vlan_hw_strip_disable(struct rte_eth_dev *dev,
84 : : uint16_t queue);
85 : :
86 : : static void ngbe_dev_link_status_print(struct rte_eth_dev *dev);
87 : : static int ngbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
88 : : static int ngbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
89 : : static int ngbe_dev_misc_interrupt_setup(struct rte_eth_dev *dev);
90 : : static int ngbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
91 : : static void ngbe_dev_interrupt_handler(void *param);
92 : : static void ngbe_configure_msix(struct rte_eth_dev *dev);
93 : : static void ngbe_pbthresh_set(struct rte_eth_dev *dev);
94 : :
95 : : #define NGBE_SET_HWSTRIP(h, q) do {\
96 : : uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
97 : : uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
98 : : (h)->bitmap[idx] |= 1 << bit;\
99 : : } while (0)
100 : :
101 : : #define NGBE_CLEAR_HWSTRIP(h, q) do {\
102 : : uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
103 : : uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
104 : : (h)->bitmap[idx] &= ~(1 << bit);\
105 : : } while (0)
106 : :
107 : : #define NGBE_GET_HWSTRIP(h, q, r) do {\
108 : : uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
109 : : uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
110 : : (r) = (h)->bitmap[idx] >> bit & 1;\
111 : : } while (0)
112 : :
113 : : /*
114 : : * The set of PCI devices this driver supports
115 : : */
116 : : static const struct rte_pci_id pci_id_ngbe_map[] = {
117 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A2) },
118 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A2S) },
119 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A4) },
120 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A4S) },
121 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860AL2) },
122 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860AL2S) },
123 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860AL4) },
124 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860AL4S) },
125 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860NCSI) },
126 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A1) },
127 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A1L) },
128 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860AL_W) },
129 : : { .vendor_id = 0, /* sentinel */ },
130 : : };
131 : :
132 : : static const struct rte_eth_desc_lim rx_desc_lim = {
133 : : .nb_max = NGBE_RING_DESC_MAX,
134 : : .nb_min = NGBE_RING_DESC_MIN,
135 : : .nb_align = NGBE_RXD_ALIGN,
136 : : };
137 : :
138 : : static const struct rte_eth_desc_lim tx_desc_lim = {
139 : : .nb_max = NGBE_RING_DESC_MAX,
140 : : .nb_min = NGBE_RING_DESC_MIN,
141 : : .nb_align = NGBE_TXD_ALIGN,
142 : : .nb_seg_max = NGBE_TX_MAX_SEG,
143 : : .nb_mtu_seg_max = NGBE_TX_MAX_SEG,
144 : : };
145 : :
146 : : static const struct eth_dev_ops ngbe_eth_dev_ops;
147 : :
148 : : #define HW_XSTAT(m) {#m, offsetof(struct ngbe_hw_stats, m)}
149 : : #define HW_XSTAT_NAME(m, n) {n, offsetof(struct ngbe_hw_stats, m)}
150 : : static const struct rte_ngbe_xstats_name_off rte_ngbe_stats_strings[] = {
151 : : /* MNG RxTx */
152 : : HW_XSTAT(mng_bmc2host_packets),
153 : : HW_XSTAT(mng_host2bmc_packets),
154 : : /* Basic RxTx */
155 : : HW_XSTAT(rx_packets),
156 : : HW_XSTAT(tx_packets),
157 : : HW_XSTAT(rx_bytes),
158 : : HW_XSTAT(tx_bytes),
159 : : HW_XSTAT(rx_total_bytes),
160 : : HW_XSTAT(rx_total_packets),
161 : : HW_XSTAT(tx_total_packets),
162 : : HW_XSTAT(rx_total_missed_packets),
163 : : HW_XSTAT(rx_broadcast_packets),
164 : : HW_XSTAT(tx_broadcast_packets),
165 : : HW_XSTAT(rx_multicast_packets),
166 : : HW_XSTAT(tx_multicast_packets),
167 : : HW_XSTAT(rx_management_packets),
168 : : HW_XSTAT(tx_management_packets),
169 : : HW_XSTAT(rx_management_dropped),
170 : : HW_XSTAT(rx_dma_drop),
171 : : HW_XSTAT(tx_dma_drop),
172 : : HW_XSTAT(tx_secdrp_packets),
173 : :
174 : : /* Basic Error */
175 : : HW_XSTAT(rx_crc_errors),
176 : : HW_XSTAT(rx_illegal_byte_errors),
177 : : HW_XSTAT(rx_error_bytes),
178 : : HW_XSTAT(rx_mac_short_packet_dropped),
179 : : HW_XSTAT(rx_length_errors),
180 : : HW_XSTAT(rx_undersize_errors),
181 : : HW_XSTAT(rx_fragment_errors),
182 : : HW_XSTAT(rx_oversize_cnt),
183 : : HW_XSTAT(rx_jabber_errors),
184 : : HW_XSTAT(rx_l3_l4_xsum_error),
185 : : HW_XSTAT(mac_local_errors),
186 : : HW_XSTAT(mac_remote_errors),
187 : :
188 : : /* PB Stats */
189 : : HW_XSTAT(rx_up_dropped),
190 : : HW_XSTAT(rdb_pkt_cnt),
191 : : HW_XSTAT(rdb_repli_cnt),
192 : : HW_XSTAT(rdb_drp_cnt),
193 : :
194 : : /* MACSEC */
195 : : HW_XSTAT(tx_macsec_pkts_untagged),
196 : : HW_XSTAT(tx_macsec_pkts_encrypted),
197 : : HW_XSTAT(tx_macsec_pkts_protected),
198 : : HW_XSTAT(tx_macsec_octets_encrypted),
199 : : HW_XSTAT(tx_macsec_octets_protected),
200 : : HW_XSTAT(rx_macsec_pkts_untagged),
201 : : HW_XSTAT(rx_macsec_pkts_badtag),
202 : : HW_XSTAT(rx_macsec_pkts_nosci),
203 : : HW_XSTAT(rx_macsec_pkts_unknownsci),
204 : : HW_XSTAT(rx_macsec_octets_decrypted),
205 : : HW_XSTAT(rx_macsec_octets_validated),
206 : : HW_XSTAT(rx_macsec_sc_pkts_unchecked),
207 : : HW_XSTAT(rx_macsec_sc_pkts_delayed),
208 : : HW_XSTAT(rx_macsec_sc_pkts_late),
209 : : HW_XSTAT(rx_macsec_sa_pkts_ok),
210 : : HW_XSTAT(rx_macsec_sa_pkts_invalid),
211 : : HW_XSTAT(rx_macsec_sa_pkts_notvalid),
212 : : HW_XSTAT(rx_macsec_sa_pkts_unusedsa),
213 : : HW_XSTAT(rx_macsec_sa_pkts_notusingsa),
214 : :
215 : : /* MAC RxTx */
216 : : HW_XSTAT(rx_size_64_packets),
217 : : HW_XSTAT(rx_size_65_to_127_packets),
218 : : HW_XSTAT(rx_size_128_to_255_packets),
219 : : HW_XSTAT(rx_size_256_to_511_packets),
220 : : HW_XSTAT(rx_size_512_to_1023_packets),
221 : : HW_XSTAT(rx_size_1024_to_max_packets),
222 : : HW_XSTAT(tx_size_64_packets),
223 : : HW_XSTAT(tx_size_65_to_127_packets),
224 : : HW_XSTAT(tx_size_128_to_255_packets),
225 : : HW_XSTAT(tx_size_256_to_511_packets),
226 : : HW_XSTAT(tx_size_512_to_1023_packets),
227 : : HW_XSTAT(tx_size_1024_to_max_packets),
228 : :
229 : : /* Flow Control */
230 : : HW_XSTAT_NAME(tx_xon_packets, "tx_flow_control_xon_packets"),
231 : : HW_XSTAT_NAME(rx_xon_packets, "rx_flow_control_xon_packets"),
232 : : HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
233 : : HW_XSTAT_NAME(rx_xoff_packets, "rx_flow_control_xoff_packets"),
234 : : };
235 : :
236 : : #define NGBE_NB_HW_STATS (sizeof(rte_ngbe_stats_strings) / \
237 : : sizeof(rte_ngbe_stats_strings[0]))
238 : :
239 : : /* Per-queue statistics */
240 : : #define QP_XSTAT(m) {#m, offsetof(struct ngbe_hw_stats, qp[0].m)}
241 : : static const struct rte_ngbe_xstats_name_off rte_ngbe_qp_strings[] = {
242 : : QP_XSTAT(rx_qp_packets),
243 : : QP_XSTAT(tx_qp_packets),
244 : : QP_XSTAT(rx_qp_bytes),
245 : : QP_XSTAT(tx_qp_bytes),
246 : : QP_XSTAT(rx_qp_mc_packets),
247 : : };
248 : :
249 : : #define NGBE_NB_QP_STATS (sizeof(rte_ngbe_qp_strings) / \
250 : : sizeof(rte_ngbe_qp_strings[0]))
251 : :
252 : : static inline int32_t
253 : : ngbe_pf_reset_hw(struct ngbe_hw *hw)
254 : : {
255 : : uint32_t ctrl_ext;
256 : : int32_t status;
257 : :
258 : 0 : status = hw->mac.reset_hw(hw);
259 : :
260 : : ctrl_ext = rd32(hw, NGBE_PORTCTL);
261 : : /* let hardware know driver is loaded */
262 : : ctrl_ext |= NGBE_PORTCTL_DRVLOAD;
263 : : /* Set PF Reset Done bit so PF/VF Mail Ops can work */
264 : 0 : ctrl_ext |= NGBE_PORTCTL_RSTDONE;
265 : : wr32(hw, NGBE_PORTCTL, ctrl_ext);
266 : : ngbe_flush(hw);
267 : :
268 [ # # ]: 0 : if (status == NGBE_ERR_SFP_NOT_PRESENT)
269 : : status = 0;
270 : : return status;
271 : : }
272 : :
273 : : static inline void
274 : : ngbe_enable_intr(struct rte_eth_dev *dev)
275 : : {
276 : : struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
277 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
278 : :
279 : 0 : wr32(hw, NGBE_IENMISC, intr->mask_misc);
280 : 0 : wr32(hw, NGBE_IMC(0), intr->mask & BIT_MASK32);
281 : : ngbe_flush(hw);
282 : 0 : }
283 : :
284 : : static void
285 : 0 : ngbe_disable_intr(struct ngbe_hw *hw)
286 : : {
287 : 0 : PMD_INIT_FUNC_TRACE();
288 : :
289 : : wr32(hw, NGBE_IMS(0), NGBE_IMS_MASK);
290 : : ngbe_flush(hw);
291 : 0 : }
292 : :
293 : : /*
294 : : * Ensure that all locks are released before first NVM or PHY access
295 : : */
296 : : static void
297 : 0 : ngbe_swfw_lock_reset(struct ngbe_hw *hw)
298 : : {
299 : : uint16_t mask;
300 : :
301 : : /*
302 : : * These ones are more tricky since they are common to all ports; but
303 : : * swfw_sync retries last long enough (1s) to be almost sure that if
304 : : * lock can not be taken it is due to an improper lock of the
305 : : * semaphore.
306 : : */
307 : : mask = NGBE_MNGSEM_SWPHY |
308 : : NGBE_MNGSEM_SWMBX |
309 : : NGBE_MNGSEM_SWFLASH;
310 [ # # ]: 0 : if (hw->mac.acquire_swfw_sync(hw, mask) < 0)
311 : 0 : PMD_DRV_LOG(DEBUG, "SWFW common locks released");
312 : :
313 : 0 : hw->mac.release_swfw_sync(hw, mask);
314 : 0 : }
315 : :
316 : : static int
317 : 0 : eth_ngbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
318 : : {
319 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(eth_dev, *pci_dev);
320 : : struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
321 : 0 : struct ngbe_vfta *shadow_vfta = NGBE_DEV_VFTA(eth_dev);
322 : : struct ngbe_hwstrip *hwstrip = NGBE_DEV_HWSTRIP(eth_dev);
323 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
324 : : const struct rte_memzone *mz;
325 : : uint32_t ctrl_ext;
326 : 0 : u32 led_conf = 0;
327 : : int err, ret;
328 : :
329 : 0 : PMD_INIT_FUNC_TRACE();
330 : :
331 : 0 : eth_dev->dev_ops = &ngbe_eth_dev_ops;
332 : 0 : eth_dev->rx_queue_count = ngbe_dev_rx_queue_count;
333 : 0 : eth_dev->rx_descriptor_status = ngbe_dev_rx_descriptor_status;
334 : 0 : eth_dev->tx_descriptor_status = ngbe_dev_tx_descriptor_status;
335 : 0 : eth_dev->rx_pkt_burst = &ngbe_recv_pkts;
336 : 0 : eth_dev->tx_pkt_burst = &ngbe_xmit_pkts;
337 : 0 : eth_dev->tx_pkt_prepare = &ngbe_prep_pkts;
338 : :
339 : : /*
340 : : * For secondary processes, we don't initialise any further as primary
341 : : * has already done this work. Only check we don't need a different
342 : : * Rx and Tx function.
343 : : */
344 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
345 : : struct ngbe_tx_queue *txq;
346 : : /* Tx queue function in primary, set by last queue initialized
347 : : * Tx queue may not initialized by primary process
348 : : */
349 [ # # ]: 0 : if (eth_dev->data->tx_queues) {
350 : 0 : uint16_t nb_tx_queues = eth_dev->data->nb_tx_queues;
351 : 0 : txq = eth_dev->data->tx_queues[nb_tx_queues - 1];
352 : 0 : ngbe_set_tx_function(eth_dev, txq);
353 : : } else {
354 : : /* Use default Tx function if we get here */
355 : 0 : PMD_INIT_LOG(NOTICE,
356 : : "No Tx queues configured yet. Using default Tx function.");
357 : : }
358 : :
359 : 0 : ngbe_set_rx_function(eth_dev);
360 : :
361 : 0 : return 0;
362 : : }
363 : :
364 : 0 : rte_eth_copy_pci_info(eth_dev, pci_dev);
365 : 0 : eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
366 : :
367 : 0 : hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
368 : :
369 : : /* Vendor and Device ID need to be set before init of shared code */
370 : 0 : hw->back = pci_dev;
371 : 0 : hw->port_id = eth_dev->data->port_id;
372 : 0 : hw->device_id = pci_dev->id.device_id;
373 : 0 : hw->vendor_id = pci_dev->id.vendor_id;
374 [ # # ]: 0 : if (pci_dev->id.subsystem_vendor_id == PCI_VENDOR_ID_WANGXUN) {
375 : 0 : hw->sub_system_id = pci_dev->id.subsystem_device_id;
376 : : } else {
377 : 0 : u32 ssid = 0;
378 : :
379 : 0 : err = ngbe_flash_read_dword(hw, 0xFFFDC, &ssid);
380 [ # # ]: 0 : if (err) {
381 : 0 : PMD_INIT_LOG(ERR,
382 : : "Read of internal subsystem device id failed");
383 : 0 : return -ENODEV;
384 : : }
385 : 0 : hw->sub_system_id = (u16)ssid >> 8 | (u16)ssid << 8;
386 : : }
387 : 0 : ngbe_map_device_id(hw);
388 : :
389 : : /* Reserve memory for interrupt status block */
390 : 0 : mz = rte_eth_dma_zone_reserve(eth_dev, "ngbe_driver", -1,
391 : : NGBE_ISB_SIZE, NGBE_ALIGN, SOCKET_ID_ANY);
392 [ # # ]: 0 : if (mz == NULL)
393 : : return -ENOMEM;
394 : :
395 : 0 : hw->isb_dma = TMZ_PADDR(mz);
396 : 0 : hw->isb_mem = TMZ_VADDR(mz);
397 : :
398 : : /* Initialize the shared code (base driver) */
399 : 0 : err = ngbe_init_shared_code(hw);
400 [ # # ]: 0 : if (err != 0) {
401 : 0 : PMD_INIT_LOG(ERR, "Shared code init failed: %d", err);
402 : 0 : return -EIO;
403 : : }
404 : :
405 : : /* Unlock any pending hardware semaphore */
406 : 0 : ngbe_swfw_lock_reset(hw);
407 : 0 : ngbe_set_ncsi_status(hw);
408 : :
409 : : /* Get Hardware Flow Control setting */
410 : 0 : hw->fc.requested_mode = ngbe_fc_full;
411 : 0 : hw->fc.current_mode = ngbe_fc_full;
412 : 0 : hw->fc.pause_time = NGBE_FC_PAUSE_TIME;
413 : 0 : hw->fc.low_water = NGBE_FC_XON_LOTH;
414 : 0 : hw->fc.high_water = NGBE_FC_XOFF_HITH;
415 : 0 : hw->fc.send_xon = 1;
416 : :
417 : 0 : err = hw->rom.init_params(hw);
418 [ # # ]: 0 : if (err != 0) {
419 : 0 : PMD_INIT_LOG(ERR, "The EEPROM init failed: %d", err);
420 : 0 : return -EIO;
421 : : }
422 : :
423 : : /* Make sure we have a good EEPROM before we read from it */
424 : 0 : err = hw->rom.validate_checksum(hw, NULL);
425 [ # # ]: 0 : if (err != 0) {
426 : 0 : PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", err);
427 : 0 : return -EIO;
428 : : }
429 : :
430 : 0 : err = hw->phy.led_oem_chk(hw, &led_conf);
431 [ # # ]: 0 : if (err == 0)
432 : 0 : hw->led_conf = led_conf;
433 : : else
434 : 0 : hw->led_conf = 0xFFFF;
435 : :
436 : 0 : err = hw->mac.init_hw(hw);
437 [ # # ]: 0 : if (err != 0) {
438 : 0 : PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", err);
439 : 0 : return -EIO;
440 : : }
441 : :
442 : : /* Reset the hw statistics */
443 : 0 : ngbe_dev_stats_reset(eth_dev);
444 : :
445 : : /* disable interrupt */
446 : 0 : ngbe_disable_intr(hw);
447 : :
448 : : /* Allocate memory for storing MAC addresses */
449 : 0 : eth_dev->data->mac_addrs = rte_zmalloc("ngbe", RTE_ETHER_ADDR_LEN *
450 : 0 : hw->mac.num_rar_entries, 0);
451 [ # # ]: 0 : if (eth_dev->data->mac_addrs == NULL) {
452 : 0 : PMD_INIT_LOG(ERR,
453 : : "Failed to allocate %u bytes needed to store MAC addresses",
454 : : RTE_ETHER_ADDR_LEN * hw->mac.num_rar_entries);
455 : 0 : return -ENOMEM;
456 : : }
457 : :
458 : : /* Copy the permanent MAC address */
459 : : rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.perm_addr,
460 : : ð_dev->data->mac_addrs[0]);
461 : :
462 : : /* Allocate memory for storing hash filter MAC addresses */
463 : 0 : eth_dev->data->hash_mac_addrs = rte_zmalloc("ngbe",
464 : : RTE_ETHER_ADDR_LEN * NGBE_VMDQ_NUM_UC_MAC, 0);
465 [ # # ]: 0 : if (eth_dev->data->hash_mac_addrs == NULL) {
466 : 0 : PMD_INIT_LOG(ERR,
467 : : "Failed to allocate %d bytes needed to store MAC addresses",
468 : : RTE_ETHER_ADDR_LEN * NGBE_VMDQ_NUM_UC_MAC);
469 : 0 : rte_free(eth_dev->data->mac_addrs);
470 : 0 : eth_dev->data->mac_addrs = NULL;
471 : 0 : return -ENOMEM;
472 : : }
473 : :
474 : : /* initialize the vfta */
475 : : memset(shadow_vfta, 0, sizeof(*shadow_vfta));
476 : :
477 : : /* initialize the hw strip bitmap*/
478 : : memset(hwstrip, 0, sizeof(*hwstrip));
479 : :
480 : : /* initialize PF if max_vfs not zero */
481 : 0 : ret = ngbe_pf_host_init(eth_dev);
482 [ # # ]: 0 : if (ret) {
483 : 0 : rte_free(eth_dev->data->mac_addrs);
484 : 0 : eth_dev->data->mac_addrs = NULL;
485 : 0 : rte_free(eth_dev->data->hash_mac_addrs);
486 : 0 : eth_dev->data->hash_mac_addrs = NULL;
487 : 0 : return ret;
488 : : }
489 : :
490 : : ctrl_ext = rd32(hw, NGBE_PORTCTL);
491 : : /* let hardware know driver is loaded */
492 : : ctrl_ext |= NGBE_PORTCTL_DRVLOAD;
493 : : /* Set PF Reset Done bit so PF/VF Mail Ops can work */
494 : 0 : ctrl_ext |= NGBE_PORTCTL_RSTDONE;
495 : : wr32(hw, NGBE_PORTCTL, ctrl_ext);
496 : : ngbe_flush(hw);
497 : :
498 : 0 : PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
499 : : (int)hw->mac.type, (int)hw->phy.type);
500 : :
501 : 0 : PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
502 : : eth_dev->data->port_id, pci_dev->id.vendor_id,
503 : : pci_dev->id.device_id);
504 : :
505 : 0 : rte_intr_callback_register(intr_handle,
506 : : ngbe_dev_interrupt_handler, eth_dev);
507 : :
508 : : /* enable uio/vfio intr/eventfd mapping */
509 : 0 : rte_intr_enable(intr_handle);
510 : :
511 : : /* enable support intr */
512 : : ngbe_enable_intr(eth_dev);
513 : :
514 : 0 : return 0;
515 : : }
516 : :
517 : : static int
518 : 0 : eth_ngbe_dev_uninit(struct rte_eth_dev *eth_dev)
519 : : {
520 : 0 : PMD_INIT_FUNC_TRACE();
521 : :
522 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
523 : : return 0;
524 : :
525 : 0 : ngbe_dev_close(eth_dev);
526 : :
527 : 0 : return 0;
528 : : }
529 : :
530 : : static int
531 : 0 : eth_ngbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
532 : : struct rte_pci_device *pci_dev)
533 : : {
534 : 0 : return rte_eth_dev_create(&pci_dev->device, pci_dev->device.name,
535 : : sizeof(struct ngbe_adapter),
536 : : eth_dev_pci_specific_init, pci_dev,
537 : : eth_ngbe_dev_init, NULL);
538 : : }
539 : :
540 : 0 : static int eth_ngbe_pci_remove(struct rte_pci_device *pci_dev)
541 : : {
542 : : struct rte_eth_dev *ethdev;
543 : :
544 : 0 : ethdev = rte_eth_dev_allocated(pci_dev->device.name);
545 [ # # ]: 0 : if (ethdev == NULL)
546 : : return 0;
547 : :
548 : 0 : return rte_eth_dev_pci_generic_remove(pci_dev, eth_ngbe_dev_uninit);
549 : : }
550 : :
551 : : static struct rte_pci_driver rte_ngbe_pmd = {
552 : : .id_table = pci_id_ngbe_map,
553 : : .drv_flags = RTE_PCI_DRV_NEED_MAPPING |
554 : : RTE_PCI_DRV_INTR_LSC,
555 : : .probe = eth_ngbe_pci_probe,
556 : : .remove = eth_ngbe_pci_remove,
557 : : };
558 : :
559 : : static int
560 : 0 : ngbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
561 : : {
562 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
563 : : struct ngbe_vfta *shadow_vfta = NGBE_DEV_VFTA(dev);
564 : : uint32_t vfta;
565 : : uint32_t vid_idx;
566 : : uint32_t vid_bit;
567 : :
568 : 0 : vid_idx = (uint32_t)((vlan_id >> 5) & 0x7F);
569 : 0 : vid_bit = (uint32_t)(1 << (vlan_id & 0x1F));
570 : 0 : vfta = rd32(hw, NGBE_VLANTBL(vid_idx));
571 [ # # ]: 0 : if (on)
572 : 0 : vfta |= vid_bit;
573 : : else
574 : 0 : vfta &= ~vid_bit;
575 : : wr32(hw, NGBE_VLANTBL(vid_idx), vfta);
576 : :
577 : : /* update local VFTA copy */
578 : 0 : shadow_vfta->vfta[vid_idx] = vfta;
579 : :
580 : 0 : return 0;
581 : : }
582 : :
583 : : static void
584 : 0 : ngbe_vlan_strip_q_set(struct rte_eth_dev *dev, uint16_t queue, int on)
585 : : {
586 [ # # ]: 0 : if (on)
587 : 0 : ngbe_vlan_hw_strip_enable(dev, queue);
588 : : else
589 : 0 : ngbe_vlan_hw_strip_disable(dev, queue);
590 : 0 : }
591 : :
592 : : static void
593 [ # # ]: 0 : ngbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
594 : : {
595 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
596 : :
597 [ # # ]: 0 : if (!hw->adapter_stopped) {
598 : 0 : PMD_DRV_LOG(ERR, "Please stop port first");
599 : 0 : return;
600 : : }
601 : :
602 : 0 : ngbe_vlan_strip_q_set(dev, queue, on);
603 : : }
604 : :
605 : : static int
606 : 0 : ngbe_vlan_tpid_set(struct rte_eth_dev *dev,
607 : : enum rte_vlan_type vlan_type,
608 : : uint16_t tpid)
609 : : {
610 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
611 : : int ret = 0;
612 : : uint32_t portctrl, vlan_ext, qinq;
613 : :
614 : : portctrl = rd32(hw, NGBE_PORTCTL);
615 : :
616 : 0 : vlan_ext = (portctrl & NGBE_PORTCTL_VLANEXT);
617 [ # # # # ]: 0 : qinq = vlan_ext && (portctrl & NGBE_PORTCTL_QINQ);
618 [ # # # ]: 0 : switch (vlan_type) {
619 : 0 : case RTE_ETH_VLAN_TYPE_INNER:
620 [ # # ]: 0 : if (vlan_ext) {
621 : 0 : wr32m(hw, NGBE_VLANCTL,
622 : : NGBE_VLANCTL_TPID_MASK,
623 : : NGBE_VLANCTL_TPID(tpid));
624 : 0 : wr32m(hw, NGBE_DMATXCTRL,
625 : : NGBE_DMATXCTRL_TPID_MASK,
626 : : NGBE_DMATXCTRL_TPID(tpid));
627 : : } else {
628 : : ret = -ENOTSUP;
629 : 0 : PMD_DRV_LOG(ERR,
630 : : "Inner type is not supported by single VLAN");
631 : : }
632 : :
633 [ # # ]: 0 : if (qinq) {
634 : 0 : wr32m(hw, NGBE_TAGTPID(0),
635 : : NGBE_TAGTPID_LSB_MASK,
636 : : NGBE_TAGTPID_LSB(tpid));
637 : : }
638 : : break;
639 : 0 : case RTE_ETH_VLAN_TYPE_OUTER:
640 [ # # ]: 0 : if (vlan_ext) {
641 : : /* Only the high 16-bits is valid */
642 : 0 : wr32m(hw, NGBE_EXTAG,
643 : : NGBE_EXTAG_VLAN_MASK,
644 : 0 : NGBE_EXTAG_VLAN(tpid));
645 : : } else {
646 : 0 : wr32m(hw, NGBE_VLANCTL,
647 : : NGBE_VLANCTL_TPID_MASK,
648 : : NGBE_VLANCTL_TPID(tpid));
649 : 0 : wr32m(hw, NGBE_DMATXCTRL,
650 : : NGBE_DMATXCTRL_TPID_MASK,
651 : : NGBE_DMATXCTRL_TPID(tpid));
652 : : }
653 : :
654 [ # # ]: 0 : if (qinq) {
655 : 0 : wr32m(hw, NGBE_TAGTPID(0),
656 : : NGBE_TAGTPID_MSB_MASK,
657 : 0 : NGBE_TAGTPID_MSB(tpid));
658 : : }
659 : : break;
660 : 0 : default:
661 : 0 : PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
662 : 0 : return -EINVAL;
663 : : }
664 : :
665 : : return ret;
666 : : }
667 : :
668 : : void
669 : 0 : ngbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
670 : : {
671 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
672 : : uint32_t vlnctrl;
673 : :
674 : 0 : PMD_INIT_FUNC_TRACE();
675 : :
676 : : /* Filter Table Disable */
677 : : vlnctrl = rd32(hw, NGBE_VLANCTL);
678 : 0 : vlnctrl &= ~NGBE_VLANCTL_VFE;
679 : : wr32(hw, NGBE_VLANCTL, vlnctrl);
680 : 0 : }
681 : :
682 : : void
683 : 0 : ngbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
684 : : {
685 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
686 : : struct ngbe_vfta *shadow_vfta = NGBE_DEV_VFTA(dev);
687 : : uint32_t vlnctrl;
688 : : uint16_t i;
689 : :
690 : 0 : PMD_INIT_FUNC_TRACE();
691 : :
692 : : /* Filter Table Enable */
693 : : vlnctrl = rd32(hw, NGBE_VLANCTL);
694 : 0 : vlnctrl &= ~NGBE_VLANCTL_CFIENA;
695 : 0 : vlnctrl |= NGBE_VLANCTL_VFE;
696 : : wr32(hw, NGBE_VLANCTL, vlnctrl);
697 : :
698 : : /* write whatever is in local vfta copy */
699 [ # # ]: 0 : for (i = 0; i < NGBE_VFTA_SIZE; i++)
700 : 0 : wr32(hw, NGBE_VLANTBL(i), shadow_vfta->vfta[i]);
701 : 0 : }
702 : :
703 : : void
704 : 0 : ngbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
705 : : {
706 : 0 : struct ngbe_hwstrip *hwstrip = NGBE_DEV_HWSTRIP(dev);
707 : : struct ngbe_rx_queue *rxq;
708 : :
709 [ # # ]: 0 : if (queue >= NGBE_MAX_RX_QUEUE_NUM)
710 : : return;
711 : :
712 [ # # ]: 0 : if (on)
713 : 0 : NGBE_SET_HWSTRIP(hwstrip, queue);
714 : : else
715 : 0 : NGBE_CLEAR_HWSTRIP(hwstrip, queue);
716 : :
717 [ # # ]: 0 : if (queue >= dev->data->nb_rx_queues)
718 : : return;
719 : :
720 : 0 : rxq = dev->data->rx_queues[queue];
721 : :
722 [ # # ]: 0 : if (on) {
723 : 0 : rxq->vlan_flags = RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
724 : 0 : rxq->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
725 : : } else {
726 : 0 : rxq->vlan_flags = RTE_MBUF_F_RX_VLAN;
727 : 0 : rxq->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
728 : : }
729 : : }
730 : :
731 : : static void
732 : 0 : ngbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
733 : : {
734 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
735 : : uint32_t ctrl;
736 : :
737 : 0 : PMD_INIT_FUNC_TRACE();
738 : :
739 : 0 : ctrl = rd32(hw, NGBE_RXCFG(queue));
740 : 0 : ctrl &= ~NGBE_RXCFG_VLAN;
741 : : wr32(hw, NGBE_RXCFG(queue), ctrl);
742 : :
743 : : /* record those setting for HW strip per queue */
744 : 0 : ngbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
745 : 0 : }
746 : :
747 : : static void
748 : 0 : ngbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
749 : : {
750 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
751 : : uint32_t ctrl;
752 : :
753 : 0 : PMD_INIT_FUNC_TRACE();
754 : :
755 : 0 : ctrl = rd32(hw, NGBE_RXCFG(queue));
756 : 0 : ctrl |= NGBE_RXCFG_VLAN;
757 : : wr32(hw, NGBE_RXCFG(queue), ctrl);
758 : :
759 : : /* record those setting for HW strip per queue */
760 : 0 : ngbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
761 : 0 : }
762 : :
763 : : static void
764 : 0 : ngbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
765 : : {
766 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
767 : : uint32_t ctrl;
768 : :
769 : 0 : PMD_INIT_FUNC_TRACE();
770 : :
771 : : ctrl = rd32(hw, NGBE_PORTCTL);
772 : : ctrl &= ~NGBE_PORTCTL_VLANEXT;
773 : 0 : ctrl &= ~NGBE_PORTCTL_QINQ;
774 : : wr32(hw, NGBE_PORTCTL, ctrl);
775 : 0 : }
776 : :
777 : : static void
778 : 0 : ngbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
779 : : {
780 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
781 : : uint32_t ctrl;
782 : :
783 : 0 : PMD_INIT_FUNC_TRACE();
784 : :
785 : : ctrl = rd32(hw, NGBE_PORTCTL);
786 : 0 : ctrl |= NGBE_PORTCTL_VLANEXT | NGBE_PORTCTL_QINQ;
787 : : wr32(hw, NGBE_PORTCTL, ctrl);
788 : 0 : }
789 : :
790 : : static void
791 : 0 : ngbe_qinq_hw_strip_disable(struct rte_eth_dev *dev)
792 : : {
793 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
794 : : uint32_t ctrl;
795 : :
796 : 0 : PMD_INIT_FUNC_TRACE();
797 : :
798 : : ctrl = rd32(hw, NGBE_PORTCTL);
799 : 0 : ctrl &= ~NGBE_PORTCTL_QINQ;
800 : : wr32(hw, NGBE_PORTCTL, ctrl);
801 : 0 : }
802 : :
803 : : static void
804 : 0 : ngbe_qinq_hw_strip_enable(struct rte_eth_dev *dev)
805 : : {
806 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
807 : : uint32_t ctrl;
808 : :
809 : 0 : PMD_INIT_FUNC_TRACE();
810 : :
811 : : ctrl = rd32(hw, NGBE_PORTCTL);
812 : 0 : ctrl |= NGBE_PORTCTL_QINQ | NGBE_PORTCTL_VLANEXT;
813 : : wr32(hw, NGBE_PORTCTL, ctrl);
814 : 0 : }
815 : :
816 : : void
817 : 0 : ngbe_vlan_hw_strip_config(struct rte_eth_dev *dev)
818 : : {
819 : : struct ngbe_rx_queue *rxq;
820 : : uint16_t i;
821 : :
822 : 0 : PMD_INIT_FUNC_TRACE();
823 : :
824 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
825 : 0 : rxq = dev->data->rx_queues[i];
826 : :
827 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
828 : 0 : ngbe_vlan_strip_q_set(dev, i, 1);
829 : : else
830 : 0 : ngbe_vlan_strip_q_set(dev, i, 0);
831 : : }
832 : 0 : }
833 : :
834 : : void
835 : 0 : ngbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev, int mask)
836 : : {
837 : : uint16_t i;
838 : : struct rte_eth_rxmode *rxmode;
839 : : struct ngbe_rx_queue *rxq;
840 : :
841 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_STRIP_MASK) {
842 : 0 : rxmode = &dev->data->dev_conf.rxmode;
843 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
844 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
845 : 0 : rxq = dev->data->rx_queues[i];
846 : 0 : rxq->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
847 : : }
848 : : else
849 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
850 : 0 : rxq = dev->data->rx_queues[i];
851 : 0 : rxq->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
852 : : }
853 : : }
854 : 0 : }
855 : :
856 : : static int
857 : 0 : ngbe_vlan_offload_config(struct rte_eth_dev *dev, int mask)
858 : : {
859 : : struct rte_eth_rxmode *rxmode;
860 : 0 : rxmode = &dev->data->dev_conf.rxmode;
861 : :
862 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_STRIP_MASK)
863 : 0 : ngbe_vlan_hw_strip_config(dev);
864 : :
865 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_FILTER_MASK) {
866 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER)
867 : 0 : ngbe_vlan_hw_filter_enable(dev);
868 : : else
869 : 0 : ngbe_vlan_hw_filter_disable(dev);
870 : : }
871 : :
872 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_EXTEND_MASK) {
873 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)
874 : 0 : ngbe_vlan_hw_extend_enable(dev);
875 : : else
876 : 0 : ngbe_vlan_hw_extend_disable(dev);
877 : : }
878 : :
879 [ # # ]: 0 : if (mask & RTE_ETH_QINQ_STRIP_MASK) {
880 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
881 : 0 : ngbe_qinq_hw_strip_enable(dev);
882 : : else
883 : 0 : ngbe_qinq_hw_strip_disable(dev);
884 : : }
885 : :
886 : 0 : return 0;
887 : : }
888 : :
889 : : static int
890 [ # # ]: 0 : ngbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
891 : : {
892 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
893 : :
894 [ # # # # ]: 0 : if (!hw->adapter_stopped && (mask & RTE_ETH_VLAN_STRIP_MASK)) {
895 : 0 : PMD_DRV_LOG(ERR, "Please stop port first");
896 : 0 : return -EPERM;
897 : : }
898 : :
899 : 0 : ngbe_config_vlan_strip_on_all_queues(dev, mask);
900 : :
901 : 0 : ngbe_vlan_offload_config(dev, mask);
902 : :
903 : 0 : return 0;
904 : : }
905 : :
906 : : static int
907 : 0 : ngbe_dev_configure(struct rte_eth_dev *dev)
908 : : {
909 : : struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
910 : : struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
911 : :
912 : 0 : PMD_INIT_FUNC_TRACE();
913 : :
914 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
915 : 0 : dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
916 : :
917 : : /* set flag to update link status after init */
918 : 0 : intr->flags |= NGBE_FLAG_NEED_LINK_UPDATE;
919 : :
920 : : /*
921 : : * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
922 : : * allocation Rx preconditions we will reset it.
923 : : */
924 : 0 : adapter->rx_bulk_alloc_allowed = true;
925 : 0 : adapter->rx_vec_allowed = true;
926 : :
927 : 0 : return 0;
928 : : }
929 : :
930 : : static void
931 : 0 : ngbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
932 : : {
933 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
934 : : struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
935 : :
936 : : wr32(hw, NGBE_GPIODIR, NGBE_GPIODIR_DDR(1));
937 : : wr32(hw, NGBE_GPIOINTEN, NGBE_GPIOINTEN_INT(3));
938 : : wr32(hw, NGBE_GPIOINTTYPE, NGBE_GPIOINTTYPE_LEVEL(0));
939 [ # # ]: 0 : if (hw->phy.type == ngbe_phy_yt8521s_sfi)
940 : : wr32(hw, NGBE_GPIOINTPOL, NGBE_GPIOINTPOL_ACT(0));
941 : : else
942 : : wr32(hw, NGBE_GPIOINTPOL, NGBE_GPIOINTPOL_ACT(3));
943 : :
944 : 0 : intr->mask_misc |= NGBE_ICRMISC_GPIO | NGBE_ICRMISC_HEAT;
945 : 0 : }
946 : :
947 : : /*
948 : : * Configure device link speed and setup link.
949 : : * It returns 0 on success.
950 : : */
951 : : static int
952 : 0 : ngbe_dev_start(struct rte_eth_dev *dev)
953 : : {
954 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
955 : 0 : struct ngbe_hw_stats *hw_stats = NGBE_DEV_STATS(dev);
956 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
957 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
958 : : uint32_t intr_vector = 0;
959 : : int err;
960 : 0 : bool link_up = false, negotiate = false;
961 : 0 : uint32_t speed = 0;
962 : : uint32_t allowed_speeds = 0;
963 : : int mask = 0;
964 : : int status;
965 : : uint32_t *link_speeds;
966 : :
967 : 0 : PMD_INIT_FUNC_TRACE();
968 : :
969 : : /* disable uio/vfio intr/eventfd mapping */
970 : 0 : rte_intr_disable(intr_handle);
971 : :
972 : : /* stop adapter */
973 : 0 : hw->adapter_stopped = 0;
974 : :
975 : : /* reinitialize adapter, this calls reset and start */
976 : 0 : hw->nb_rx_queues = dev->data->nb_rx_queues;
977 : 0 : hw->nb_tx_queues = dev->data->nb_tx_queues;
978 : : status = ngbe_pf_reset_hw(hw);
979 [ # # ]: 0 : if (status != 0)
980 : : return -1;
981 : 0 : hw->mac.start_hw(hw);
982 : 0 : hw->mac.get_link_status = true;
983 : :
984 : 0 : ngbe_set_pcie_master(hw, true);
985 : :
986 : : /* configure PF module if SRIOV enabled */
987 : 0 : ngbe_pf_host_configure(dev);
988 : :
989 : 0 : ngbe_dev_phy_intr_setup(dev);
990 : :
991 : : /* check and configure queue intr-vector mapping */
992 [ # # ]: 0 : if ((rte_intr_cap_multiple(intr_handle) ||
993 [ # # ]: 0 : !RTE_ETH_DEV_SRIOV(dev).active) &&
994 [ # # ]: 0 : dev->data->dev_conf.intr_conf.rxq != 0) {
995 : 0 : intr_vector = dev->data->nb_rx_queues;
996 [ # # ]: 0 : if (rte_intr_efd_enable(intr_handle, intr_vector))
997 : : return -1;
998 : : }
999 : :
1000 [ # # ]: 0 : if (rte_intr_dp_is_en(intr_handle)) {
1001 [ # # ]: 0 : if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
1002 : 0 : dev->data->nb_rx_queues)) {
1003 : 0 : PMD_INIT_LOG(ERR,
1004 : : "Failed to allocate %d rx_queues intr_vec",
1005 : : dev->data->nb_rx_queues);
1006 : 0 : return -ENOMEM;
1007 : : }
1008 : : }
1009 : :
1010 : : /* configure MSI-X for sleep until Rx interrupt */
1011 : 0 : ngbe_configure_msix(dev);
1012 : :
1013 : : /* initialize transmission unit */
1014 : 0 : ngbe_dev_tx_init(dev);
1015 : :
1016 : : /* This can fail when allocating mbufs for descriptor rings */
1017 : 0 : err = ngbe_dev_rx_init(dev);
1018 [ # # ]: 0 : if (err != 0) {
1019 : 0 : PMD_INIT_LOG(ERR, "Unable to initialize Rx hardware");
1020 : 0 : goto error;
1021 : : }
1022 : :
1023 : : mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
1024 : : RTE_ETH_VLAN_EXTEND_MASK;
1025 : 0 : err = ngbe_vlan_offload_config(dev, mask);
1026 [ # # ]: 0 : if (err != 0) {
1027 : 0 : PMD_INIT_LOG(ERR, "Unable to set VLAN offload");
1028 : 0 : goto error;
1029 : : }
1030 : :
1031 : 0 : hw->mac.setup_pba(hw);
1032 : 0 : ngbe_pbthresh_set(dev);
1033 : 0 : ngbe_configure_port(dev);
1034 : :
1035 : 0 : err = ngbe_dev_rxtx_start(dev);
1036 [ # # ]: 0 : if (err < 0) {
1037 : 0 : PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
1038 : 0 : goto error;
1039 : : }
1040 : :
1041 : : /* Skip link setup if loopback mode is enabled. */
1042 [ # # # # ]: 0 : if (hw->is_pf && dev->data->dev_conf.lpbk_mode)
1043 : 0 : goto skip_link_setup;
1044 : :
1045 : 0 : hw->lsc = dev->data->dev_conf.intr_conf.lsc;
1046 : :
1047 : 0 : err = hw->mac.check_link(hw, &speed, &link_up, 0);
1048 [ # # ]: 0 : if (err != 0)
1049 : 0 : goto error;
1050 : 0 : dev->data->dev_link.link_status = link_up;
1051 : :
1052 : : link_speeds = &dev->data->dev_conf.link_speeds;
1053 [ # # ]: 0 : if (*link_speeds == RTE_ETH_LINK_SPEED_AUTONEG)
1054 : 0 : negotiate = true;
1055 : :
1056 : 0 : err = hw->mac.get_link_capabilities(hw, &speed, &negotiate);
1057 [ # # ]: 0 : if (err != 0)
1058 : 0 : goto error;
1059 : :
1060 : : allowed_speeds = 0;
1061 [ # # ]: 0 : if (hw->mac.default_speeds & NGBE_LINK_SPEED_1GB_FULL)
1062 : : allowed_speeds |= RTE_ETH_LINK_SPEED_1G;
1063 [ # # ]: 0 : if (hw->mac.default_speeds & NGBE_LINK_SPEED_100M_FULL)
1064 : 0 : allowed_speeds |= RTE_ETH_LINK_SPEED_100M;
1065 [ # # ]: 0 : if (hw->mac.default_speeds & NGBE_LINK_SPEED_10M_FULL)
1066 : 0 : allowed_speeds |= RTE_ETH_LINK_SPEED_10M;
1067 : :
1068 [ # # ]: 0 : if (((*link_speeds) >> 1) & ~(allowed_speeds >> 1)) {
1069 : 0 : PMD_INIT_LOG(ERR, "Invalid link setting");
1070 : 0 : goto error;
1071 : : }
1072 : :
1073 : 0 : speed = 0x0;
1074 [ # # ]: 0 : if (*link_speeds == RTE_ETH_LINK_SPEED_AUTONEG) {
1075 : 0 : speed = hw->mac.default_speeds;
1076 : : } else {
1077 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_1G)
1078 : 0 : speed |= NGBE_LINK_SPEED_1GB_FULL;
1079 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_100M)
1080 : 0 : speed |= NGBE_LINK_SPEED_100M_FULL;
1081 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_10M)
1082 : 0 : speed |= NGBE_LINK_SPEED_10M_FULL;
1083 : : }
1084 : :
1085 [ # # ]: 0 : if (!hw->ncsi_enabled) {
1086 : 0 : err = hw->phy.init_hw(hw);
1087 [ # # ]: 0 : if (err != 0) {
1088 : 0 : PMD_INIT_LOG(ERR, "PHY init failed");
1089 : 0 : goto error;
1090 : : }
1091 : : }
1092 : 0 : err = hw->mac.setup_link(hw, speed, link_up);
1093 [ # # ]: 0 : if (err != 0)
1094 : 0 : goto error;
1095 : :
1096 : 0 : skip_link_setup:
1097 : :
1098 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle)) {
1099 : : ngbe_dev_misc_interrupt_setup(dev);
1100 : : /* check if lsc interrupt is enabled */
1101 : 0 : if (dev->data->dev_conf.intr_conf.lsc != 0)
1102 : 0 : ngbe_dev_lsc_interrupt_setup(dev, TRUE);
1103 : : else
1104 : 0 : ngbe_dev_lsc_interrupt_setup(dev, FALSE);
1105 : : ngbe_dev_macsec_interrupt_setup(dev);
1106 : 0 : ngbe_set_ivar_map(hw, -1, 1, NGBE_MISC_VEC_ID);
1107 : : } else {
1108 : 0 : rte_intr_callback_unregister(intr_handle,
1109 : : ngbe_dev_interrupt_handler, dev);
1110 [ # # ]: 0 : if (dev->data->dev_conf.intr_conf.lsc != 0)
1111 : 0 : PMD_INIT_LOG(INFO,
1112 : : "LSC won't enable because of no intr multiplex");
1113 : : }
1114 : :
1115 : : /* check if rxq interrupt is enabled */
1116 [ # # # # ]: 0 : if (dev->data->dev_conf.intr_conf.rxq != 0 &&
1117 : 0 : rte_intr_dp_is_en(intr_handle))
1118 : : ngbe_dev_rxq_interrupt_setup(dev);
1119 : :
1120 : : /* enable UIO/VFIO intr/eventfd mapping */
1121 : 0 : rte_intr_enable(intr_handle);
1122 : :
1123 : : /* resume enabled intr since HW reset */
1124 : : ngbe_enable_intr(dev);
1125 : :
1126 [ # # ]: 0 : if (hw->gpio_ctl) {
1127 : : /* gpio0 is used to power on/off control*/
1128 : : wr32(hw, NGBE_GPIODATA, 0);
1129 : : }
1130 : :
1131 : : /*
1132 : : * Update link status right before return, because it may
1133 : : * start link configuration process in a separate thread.
1134 : : */
1135 : : ngbe_dev_link_update(dev, 0);
1136 : :
1137 : 0 : ngbe_read_stats_registers(hw, hw_stats);
1138 : 0 : hw->offset_loaded = 1;
1139 : :
1140 : 0 : return 0;
1141 : :
1142 : 0 : error:
1143 : 0 : PMD_INIT_LOG(ERR, "failure in dev start: %d", err);
1144 : 0 : ngbe_dev_clear_queues(dev);
1145 : 0 : return -EIO;
1146 : : }
1147 : :
1148 : : /*
1149 : : * Stop device: disable rx and tx functions to allow for reconfiguring.
1150 : : */
1151 : : static int
1152 [ # # ]: 0 : ngbe_dev_stop(struct rte_eth_dev *dev)
1153 : : {
1154 : : struct rte_eth_link link;
1155 : : struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
1156 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1157 : 0 : struct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA(dev);
1158 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
1159 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
1160 : : int vf;
1161 : :
1162 [ # # ]: 0 : if (hw->adapter_stopped)
1163 : 0 : goto out;
1164 : :
1165 : 0 : PMD_INIT_FUNC_TRACE();
1166 : :
1167 [ # # ]: 0 : if (hw->gpio_ctl) {
1168 : : /* gpio0 is used to power on/off control*/
1169 : : wr32(hw, NGBE_GPIODATA, NGBE_GPIOBIT_0);
1170 : : }
1171 : :
1172 : : /* disable interrupts */
1173 : 0 : ngbe_disable_intr(hw);
1174 : :
1175 : : /* reset the NIC */
1176 : : ngbe_pf_reset_hw(hw);
1177 : 0 : hw->adapter_stopped = 0;
1178 : :
1179 : : /* stop adapter */
1180 : 0 : ngbe_stop_hw(hw);
1181 : :
1182 [ # # # # ]: 0 : for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
1183 : 0 : vfinfo[vf].clear_to_send = false;
1184 : :
1185 : 0 : ngbe_dev_clear_queues(dev);
1186 : :
1187 : : /* Clear stored conf */
1188 : 0 : dev->data->scattered_rx = 0;
1189 : :
1190 : : /* Clear recorded link status */
1191 : : memset(&link, 0, sizeof(link));
1192 : 0 : rte_eth_linkstatus_set(dev, &link);
1193 : :
1194 [ # # ]: 0 : if (!rte_intr_allow_others(intr_handle))
1195 : : /* resume to the default handler */
1196 : 0 : rte_intr_callback_register(intr_handle,
1197 : : ngbe_dev_interrupt_handler,
1198 : : (void *)dev);
1199 : :
1200 : : /* Clean datapath event and queue/vec mapping */
1201 : 0 : rte_intr_efd_disable(intr_handle);
1202 : 0 : rte_intr_vec_list_free(intr_handle);
1203 : :
1204 : 0 : ngbe_set_pcie_master(hw, true);
1205 : :
1206 : 0 : adapter->rss_reta_updated = 0;
1207 : :
1208 : 0 : hw->adapter_stopped = true;
1209 : 0 : dev->data->dev_started = 0;
1210 : :
1211 : 0 : out:
1212 : : /* close phy to prevent reset in dev_close from restarting physical link */
1213 [ # # # # ]: 0 : if (!(hw->wol_enabled || hw->ncsi_enabled))
1214 : 0 : hw->phy.set_phy_power(hw, false);
1215 : :
1216 : 0 : return 0;
1217 : : }
1218 : :
1219 : : /*
1220 : : * Set device link up: power on.
1221 : : */
1222 : : static int
1223 [ # # ]: 0 : ngbe_dev_set_link_up(struct rte_eth_dev *dev)
1224 : : {
1225 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1226 : :
1227 [ # # # # : 0 : if (!(hw->ncsi_enabled || hw->wol_enabled))
# # # # ]
1228 : 0 : hw->phy.set_phy_power(hw, true);
1229 : :
1230 : 0 : return 0;
1231 : : }
1232 : :
1233 : : /*
1234 : : * Set device link down: power off.
1235 : : */
1236 : : static int
1237 [ # # ]: 0 : ngbe_dev_set_link_down(struct rte_eth_dev *dev)
1238 : : {
1239 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1240 : :
1241 [ # # # # : 0 : if (!(hw->ncsi_enabled || hw->wol_enabled))
# # # # ]
1242 : 0 : hw->phy.set_phy_power(hw, false);
1243 : :
1244 : 0 : return 0;
1245 : : }
1246 : :
1247 : : /*
1248 : : * Reset and stop device.
1249 : : */
1250 : : static int
1251 : 0 : ngbe_dev_close(struct rte_eth_dev *dev)
1252 : : {
1253 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1254 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
1255 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
1256 : : int retries = 0;
1257 : : int ret;
1258 : :
1259 : 0 : PMD_INIT_FUNC_TRACE();
1260 : :
1261 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1262 : : return 0;
1263 : :
1264 : : ngbe_pf_reset_hw(hw);
1265 : :
1266 : 0 : ngbe_dev_stop(dev);
1267 : :
1268 : : /* Let firmware take over control of hardware */
1269 : : wr32m(hw, NGBE_PORTCTL, NGBE_PORTCTL_DRVLOAD, 0);
1270 : :
1271 : 0 : ngbe_dev_free_queues(dev);
1272 : :
1273 : 0 : ngbe_set_pcie_master(hw, false);
1274 : :
1275 : : /* reprogram the RAR[0] in case user changed it. */
1276 : 0 : ngbe_set_rar(hw, 0, hw->mac.addr, 0, true);
1277 : :
1278 : : /* Unlock any pending hardware semaphore */
1279 : 0 : ngbe_swfw_lock_reset(hw);
1280 : :
1281 : : /* disable uio intr before callback unregister */
1282 : 0 : rte_intr_disable(intr_handle);
1283 : :
1284 : : do {
1285 : 0 : ret = rte_intr_callback_unregister(intr_handle,
1286 : : ngbe_dev_interrupt_handler, dev);
1287 [ # # ]: 0 : if (ret >= 0 || ret == -ENOENT) {
1288 : : break;
1289 [ # # ]: 0 : } else if (ret != -EAGAIN) {
1290 : 0 : PMD_INIT_LOG(ERR,
1291 : : "intr callback unregister failed: %d",
1292 : : ret);
1293 : : }
1294 : : rte_delay_ms(100);
1295 [ # # ]: 0 : } while (retries++ < (10 + NGBE_LINK_UP_TIME));
1296 : :
1297 : : /* uninitialize PF if max_vfs not zero */
1298 : 0 : ngbe_pf_host_uninit(dev);
1299 : :
1300 : 0 : rte_free(dev->data->mac_addrs);
1301 : 0 : dev->data->mac_addrs = NULL;
1302 : :
1303 : 0 : rte_free(dev->data->hash_mac_addrs);
1304 : 0 : dev->data->hash_mac_addrs = NULL;
1305 : :
1306 : 0 : return ret;
1307 : : }
1308 : :
1309 : : /*
1310 : : * Reset PF device.
1311 : : */
1312 : : static int
1313 : 0 : ngbe_dev_reset(struct rte_eth_dev *dev)
1314 : : {
1315 : : int ret;
1316 : :
1317 : : /* When a DPDK PMD PF begin to reset PF port, it should notify all
1318 : : * its VF to make them align with it. The detailed notification
1319 : : * mechanism is PMD specific. As to ngbe PF, it is rather complex.
1320 : : * To avoid unexpected behavior in VF, currently reset of PF with
1321 : : * SR-IOV activation is not supported. It might be supported later.
1322 : : */
1323 [ # # ]: 0 : if (dev->data->sriov.active)
1324 : : return -ENOTSUP;
1325 : :
1326 : 0 : ret = eth_ngbe_dev_uninit(dev);
1327 [ # # ]: 0 : if (ret != 0)
1328 : : return ret;
1329 : :
1330 : 0 : ret = eth_ngbe_dev_init(dev, NULL);
1331 : :
1332 : 0 : return ret;
1333 : : }
1334 : :
1335 : : #define UPDATE_QP_COUNTER_32bit(reg, last_counter, counter) \
1336 : : { \
1337 : : uint32_t current_counter = rd32(hw, reg); \
1338 : : if (current_counter < last_counter) \
1339 : : current_counter += 0x100000000LL; \
1340 : : if (!hw->offset_loaded) \
1341 : : last_counter = current_counter; \
1342 : : counter = current_counter - last_counter; \
1343 : : counter &= 0xFFFFFFFFLL; \
1344 : : }
1345 : :
1346 : : #define UPDATE_QP_COUNTER_36bit(reg_lsb, reg_msb, last_counter, counter) \
1347 : : { \
1348 : : uint64_t current_counter_lsb = rd32(hw, reg_lsb); \
1349 : : uint64_t current_counter_msb = rd32(hw, reg_msb); \
1350 : : uint64_t current_counter = (current_counter_msb << 32) | \
1351 : : current_counter_lsb; \
1352 : : if (current_counter < last_counter) \
1353 : : current_counter += 0x1000000000LL; \
1354 : : if (!hw->offset_loaded) \
1355 : : last_counter = current_counter; \
1356 : : counter = current_counter - last_counter; \
1357 : : counter &= 0xFFFFFFFFFLL; \
1358 : : }
1359 : :
1360 : : void
1361 : 0 : ngbe_read_stats_registers(struct ngbe_hw *hw,
1362 : : struct ngbe_hw_stats *hw_stats)
1363 : : {
1364 : : unsigned int i;
1365 : :
1366 : : /* QP Stats */
1367 [ # # ]: 0 : for (i = 0; i < hw->nb_rx_queues; i++) {
1368 [ # # ]: 0 : UPDATE_QP_COUNTER_32bit(NGBE_QPRXPKT(i),
1369 : : hw->qp_last[i].rx_qp_packets,
1370 : : hw_stats->qp[i].rx_qp_packets);
1371 [ # # # # ]: 0 : UPDATE_QP_COUNTER_36bit(NGBE_QPRXOCTL(i), NGBE_QPRXOCTH(i),
1372 : : hw->qp_last[i].rx_qp_bytes,
1373 : : hw_stats->qp[i].rx_qp_bytes);
1374 [ # # ]: 0 : UPDATE_QP_COUNTER_32bit(NGBE_QPRXMPKT(i),
1375 : : hw->qp_last[i].rx_qp_mc_packets,
1376 : : hw_stats->qp[i].rx_qp_mc_packets);
1377 [ # # ]: 0 : UPDATE_QP_COUNTER_32bit(NGBE_QPRXBPKT(i),
1378 : : hw->qp_last[i].rx_qp_bc_packets,
1379 : : hw_stats->qp[i].rx_qp_bc_packets);
1380 : : }
1381 : :
1382 [ # # ]: 0 : for (i = 0; i < hw->nb_tx_queues; i++) {
1383 [ # # ]: 0 : UPDATE_QP_COUNTER_32bit(NGBE_QPTXPKT(i),
1384 : : hw->qp_last[i].tx_qp_packets,
1385 : : hw_stats->qp[i].tx_qp_packets);
1386 [ # # # # ]: 0 : UPDATE_QP_COUNTER_36bit(NGBE_QPTXOCTL(i), NGBE_QPTXOCTH(i),
1387 : : hw->qp_last[i].tx_qp_bytes,
1388 : : hw_stats->qp[i].tx_qp_bytes);
1389 [ # # ]: 0 : UPDATE_QP_COUNTER_32bit(NGBE_QPTXMPKT(i),
1390 : : hw->qp_last[i].tx_qp_mc_packets,
1391 : : hw_stats->qp[i].tx_qp_mc_packets);
1392 [ # # ]: 0 : UPDATE_QP_COUNTER_32bit(NGBE_QPTXBPKT(i),
1393 : : hw->qp_last[i].tx_qp_bc_packets,
1394 : : hw_stats->qp[i].tx_qp_bc_packets);
1395 : : }
1396 : :
1397 : : /* PB Stats */
1398 : 0 : hw_stats->rx_up_dropped += rd32(hw, NGBE_PBRXMISS);
1399 : 0 : hw_stats->rdb_pkt_cnt += rd32(hw, NGBE_PBRXPKT);
1400 : 0 : hw_stats->rdb_repli_cnt += rd32(hw, NGBE_PBRXREP);
1401 : 0 : hw_stats->rdb_drp_cnt += rd32(hw, NGBE_PBRXDROP);
1402 : 0 : hw_stats->tx_xoff_packets += rd32(hw, NGBE_PBTXLNKXOFF);
1403 : 0 : hw_stats->tx_xon_packets += rd32(hw, NGBE_PBTXLNKXON);
1404 : :
1405 : 0 : hw_stats->rx_xon_packets += rd32(hw, NGBE_PBRXLNKXON);
1406 : 0 : hw_stats->rx_xoff_packets += rd32(hw, NGBE_PBRXLNKXOFF);
1407 : :
1408 : : /* DMA Stats */
1409 : 0 : hw_stats->rx_dma_drop += rd32(hw, NGBE_DMARXDROP);
1410 : 0 : hw_stats->tx_dma_drop += rd32(hw, NGBE_DMATXDROP);
1411 : 0 : hw_stats->tx_secdrp_packets += rd32(hw, NGBE_DMATXSECDROP);
1412 : 0 : hw_stats->rx_packets += rd32(hw, NGBE_DMARXPKT);
1413 : 0 : hw_stats->tx_packets += rd32(hw, NGBE_DMATXPKT);
1414 : 0 : hw_stats->rx_bytes += rd64(hw, NGBE_DMARXOCTL);
1415 : 0 : hw_stats->tx_bytes += rd64(hw, NGBE_DMATXOCTL);
1416 : :
1417 : : /* MAC Stats */
1418 : 0 : hw_stats->rx_crc_errors += rd64(hw, NGBE_MACRXERRCRCL);
1419 : 0 : hw_stats->rx_multicast_packets += rd64(hw, NGBE_MACRXMPKTL);
1420 : 0 : hw_stats->tx_multicast_packets += rd64(hw, NGBE_MACTXMPKTL);
1421 : :
1422 : 0 : hw_stats->rx_total_packets += rd64(hw, NGBE_MACRXPKTL);
1423 : 0 : hw_stats->tx_total_packets += rd64(hw, NGBE_MACTXPKTL);
1424 : 0 : hw_stats->rx_total_bytes += rd64(hw, NGBE_MACRXGBOCTL);
1425 : :
1426 : 0 : hw_stats->rx_broadcast_packets += rd64(hw, NGBE_MACRXOCTL);
1427 : 0 : hw_stats->tx_broadcast_packets += rd64(hw, NGBE_MACTXOCTL);
1428 : :
1429 : 0 : hw_stats->rx_size_64_packets += rd64(hw, NGBE_MACRX1TO64L);
1430 : 0 : hw_stats->rx_size_65_to_127_packets += rd64(hw, NGBE_MACRX65TO127L);
1431 : 0 : hw_stats->rx_size_128_to_255_packets += rd64(hw, NGBE_MACRX128TO255L);
1432 : 0 : hw_stats->rx_size_256_to_511_packets += rd64(hw, NGBE_MACRX256TO511L);
1433 : 0 : hw_stats->rx_size_512_to_1023_packets +=
1434 : : rd64(hw, NGBE_MACRX512TO1023L);
1435 : 0 : hw_stats->rx_size_1024_to_max_packets +=
1436 : : rd64(hw, NGBE_MACRX1024TOMAXL);
1437 : 0 : hw_stats->tx_size_64_packets += rd64(hw, NGBE_MACTX1TO64L);
1438 : 0 : hw_stats->tx_size_65_to_127_packets += rd64(hw, NGBE_MACTX65TO127L);
1439 : 0 : hw_stats->tx_size_128_to_255_packets += rd64(hw, NGBE_MACTX128TO255L);
1440 : 0 : hw_stats->tx_size_256_to_511_packets += rd64(hw, NGBE_MACTX256TO511L);
1441 : 0 : hw_stats->tx_size_512_to_1023_packets +=
1442 : : rd64(hw, NGBE_MACTX512TO1023L);
1443 : 0 : hw_stats->tx_size_1024_to_max_packets +=
1444 : : rd64(hw, NGBE_MACTX1024TOMAXL);
1445 : :
1446 : 0 : hw_stats->rx_length_errors += rd64(hw, NGBE_MACRXERRLENL);
1447 : 0 : hw_stats->rx_undersize_errors += rd32(hw, NGBE_MACRXUNDERSIZE);
1448 : 0 : hw_stats->rx_oversize_cnt += rd32(hw, NGBE_MACRXOVERSIZE);
1449 : 0 : hw_stats->rx_jabber_errors += rd32(hw, NGBE_MACRXJABBER);
1450 : :
1451 : : /* MNG Stats */
1452 : 0 : hw_stats->mng_bmc2host_packets = rd32(hw, NGBE_MNGBMC2OS);
1453 : 0 : hw_stats->mng_host2bmc_packets = rd32(hw, NGBE_MNGOS2BMC);
1454 : 0 : hw_stats->rx_management_packets = rd32(hw, NGBE_DMARXMNG);
1455 : 0 : hw_stats->tx_management_packets = rd32(hw, NGBE_DMATXMNG);
1456 : :
1457 : : /* MACsec Stats */
1458 : 0 : hw_stats->tx_macsec_pkts_untagged += rd32(hw, NGBE_LSECTX_UTPKT);
1459 : 0 : hw_stats->tx_macsec_pkts_encrypted +=
1460 : 0 : rd32(hw, NGBE_LSECTX_ENCPKT);
1461 : 0 : hw_stats->tx_macsec_pkts_protected +=
1462 : 0 : rd32(hw, NGBE_LSECTX_PROTPKT);
1463 : 0 : hw_stats->tx_macsec_octets_encrypted +=
1464 : 0 : rd32(hw, NGBE_LSECTX_ENCOCT);
1465 : 0 : hw_stats->tx_macsec_octets_protected +=
1466 : 0 : rd32(hw, NGBE_LSECTX_PROTOCT);
1467 : 0 : hw_stats->rx_macsec_pkts_untagged += rd32(hw, NGBE_LSECRX_UTPKT);
1468 : 0 : hw_stats->rx_macsec_pkts_badtag += rd32(hw, NGBE_LSECRX_BTPKT);
1469 : 0 : hw_stats->rx_macsec_pkts_nosci += rd32(hw, NGBE_LSECRX_NOSCIPKT);
1470 : 0 : hw_stats->rx_macsec_pkts_unknownsci += rd32(hw, NGBE_LSECRX_UNSCIPKT);
1471 : 0 : hw_stats->rx_macsec_octets_decrypted += rd32(hw, NGBE_LSECRX_DECOCT);
1472 : 0 : hw_stats->rx_macsec_octets_validated += rd32(hw, NGBE_LSECRX_VLDOCT);
1473 : 0 : hw_stats->rx_macsec_sc_pkts_unchecked +=
1474 : 0 : rd32(hw, NGBE_LSECRX_UNCHKPKT);
1475 : 0 : hw_stats->rx_macsec_sc_pkts_delayed += rd32(hw, NGBE_LSECRX_DLYPKT);
1476 : 0 : hw_stats->rx_macsec_sc_pkts_late += rd32(hw, NGBE_LSECRX_LATEPKT);
1477 [ # # ]: 0 : for (i = 0; i < 2; i++) {
1478 : 0 : hw_stats->rx_macsec_sa_pkts_ok +=
1479 : 0 : rd32(hw, NGBE_LSECRX_OKPKT(i));
1480 : 0 : hw_stats->rx_macsec_sa_pkts_invalid +=
1481 : 0 : rd32(hw, NGBE_LSECRX_INVPKT(i));
1482 : 0 : hw_stats->rx_macsec_sa_pkts_notvalid +=
1483 : 0 : rd32(hw, NGBE_LSECRX_BADPKT(i));
1484 : : }
1485 [ # # ]: 0 : for (i = 0; i < 4; i++) {
1486 : 0 : hw_stats->rx_macsec_sa_pkts_unusedsa +=
1487 : 0 : rd32(hw, NGBE_LSECRX_INVSAPKT(i));
1488 : 0 : hw_stats->rx_macsec_sa_pkts_notusingsa +=
1489 : 0 : rd32(hw, NGBE_LSECRX_BADSAPKT(i));
1490 : : }
1491 : 0 : hw_stats->rx_total_missed_packets =
1492 : 0 : hw_stats->rx_up_dropped;
1493 : 0 : }
1494 : :
1495 : : static int
1496 : 0 : ngbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
1497 : : struct eth_queue_stats *qstats)
1498 : : {
1499 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1500 : 0 : struct ngbe_hw_stats *hw_stats = NGBE_DEV_STATS(dev);
1501 : : struct ngbe_tx_queue *txq;
1502 : : uint32_t i;
1503 : :
1504 : 0 : ngbe_read_stats_registers(hw, hw_stats);
1505 : :
1506 [ # # ]: 0 : if (stats == NULL)
1507 : : return -EINVAL;
1508 : :
1509 : : /* Fill out the rte_eth_stats statistics structure */
1510 : 0 : stats->ipackets = hw_stats->rx_packets;
1511 : 0 : stats->ibytes = hw_stats->rx_bytes;
1512 : 0 : stats->opackets = hw_stats->tx_packets;
1513 : 0 : stats->obytes = hw_stats->tx_bytes;
1514 : :
1515 [ # # ]: 0 : if (qstats != NULL) {
1516 [ # # # # ]: 0 : for (i = 0; i < NGBE_MAX_QP && i < dev->data->nb_rx_queues; i++) {
1517 : 0 : qstats[i].q_ipackets += hw_stats->qp[i].rx_qp_packets;
1518 : 0 : qstats[i].q_ibytes += hw_stats->qp[i].rx_qp_bytes;
1519 : : }
1520 [ # # # # ]: 0 : for (i = 0; i < NGBE_MAX_QP && i < dev->data->nb_tx_queues; i++) {
1521 : 0 : qstats[i].q_opackets += hw_stats->qp[i].tx_qp_packets;
1522 : 0 : qstats[i].q_obytes += hw_stats->qp[i].tx_qp_bytes;
1523 : : }
1524 : : }
1525 : :
1526 : : /* Rx Errors */
1527 : 0 : stats->imissed = hw_stats->rx_total_missed_packets +
1528 : 0 : hw_stats->rx_dma_drop;
1529 : 0 : stats->ierrors = hw_stats->rx_crc_errors +
1530 : 0 : hw_stats->rx_mac_short_packet_dropped +
1531 : 0 : hw_stats->rx_length_errors +
1532 : 0 : hw_stats->rx_undersize_errors +
1533 : 0 : hw_stats->rdb_drp_cnt +
1534 : 0 : hw_stats->rx_illegal_byte_errors +
1535 : 0 : hw_stats->rx_error_bytes +
1536 : 0 : hw_stats->rx_fragment_errors;
1537 : :
1538 : : /* Tx Errors */
1539 : 0 : stats->oerrors = 0;
1540 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
1541 : 0 : txq = dev->data->tx_queues[i];
1542 : 0 : stats->oerrors += txq->desc_error;
1543 : : }
1544 : :
1545 : : return 0;
1546 : : }
1547 : :
1548 : : static int
1549 : 0 : ngbe_dev_stats_reset(struct rte_eth_dev *dev)
1550 : : {
1551 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1552 : 0 : struct ngbe_hw_stats *hw_stats = NGBE_DEV_STATS(dev);
1553 : : struct ngbe_tx_queue *txq;
1554 : : uint32_t i;
1555 : :
1556 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
1557 : 0 : txq = dev->data->tx_queues[i];
1558 : 0 : txq->desc_error = 0;
1559 : : }
1560 : :
1561 : : /* HW registers are cleared on read */
1562 : 0 : hw->offset_loaded = 0;
1563 : : ngbe_dev_stats_get(dev, NULL, NULL);
1564 : 0 : hw->offset_loaded = 1;
1565 : :
1566 : : /* Reset software totals */
1567 : : memset(hw_stats, 0, sizeof(*hw_stats));
1568 : :
1569 : 0 : return 0;
1570 : : }
1571 : :
1572 : : /* This function calculates the number of xstats based on the current config */
1573 : : static unsigned
1574 : : ngbe_xstats_calc_num(struct rte_eth_dev *dev)
1575 : : {
1576 : 0 : int nb_queues = max(dev->data->nb_rx_queues, dev->data->nb_tx_queues);
1577 : 0 : return NGBE_NB_HW_STATS +
1578 : : NGBE_NB_QP_STATS * nb_queues;
1579 : : }
1580 : :
1581 : : static inline int
1582 : 0 : ngbe_get_name_by_id(uint32_t id, char *name, uint32_t size)
1583 : : {
1584 : : int nb, st;
1585 : :
1586 : : /* Extended stats from ngbe_hw_stats */
1587 [ # # ]: 0 : if (id < NGBE_NB_HW_STATS) {
1588 : 0 : snprintf(name, size, "[hw]%s",
1589 : 0 : rte_ngbe_stats_strings[id].name);
1590 : 0 : return 0;
1591 : : }
1592 : 0 : id -= NGBE_NB_HW_STATS;
1593 : :
1594 : : /* Queue Stats */
1595 [ # # ]: 0 : if (id < NGBE_NB_QP_STATS * NGBE_MAX_QP) {
1596 : 0 : nb = id / NGBE_NB_QP_STATS;
1597 : 0 : st = id % NGBE_NB_QP_STATS;
1598 : 0 : snprintf(name, size, "[q%u]%s", nb,
1599 : 0 : rte_ngbe_qp_strings[st].name);
1600 : 0 : return 0;
1601 : : }
1602 : : id -= NGBE_NB_QP_STATS * NGBE_MAX_QP;
1603 : :
1604 : 0 : return -(int)(id + 1);
1605 : : }
1606 : :
1607 : : static inline int
1608 : : ngbe_get_offset_by_id(uint32_t id, uint32_t *offset)
1609 : : {
1610 : : int nb, st;
1611 : :
1612 : : /* Extended stats from ngbe_hw_stats */
1613 [ # # # # ]: 0 : if (id < NGBE_NB_HW_STATS) {
1614 : 0 : *offset = rte_ngbe_stats_strings[id].offset;
1615 : : return 0;
1616 : : }
1617 : 0 : id -= NGBE_NB_HW_STATS;
1618 : :
1619 : : /* Queue Stats */
1620 [ # # # # : 0 : if (id < NGBE_NB_QP_STATS * NGBE_MAX_QP) {
# # ]
1621 : 0 : nb = id / NGBE_NB_QP_STATS;
1622 : 0 : st = id % NGBE_NB_QP_STATS;
1623 : 0 : *offset = rte_ngbe_qp_strings[st].offset +
1624 : : nb * (NGBE_NB_QP_STATS * sizeof(uint64_t));
1625 : : return 0;
1626 : : }
1627 : :
1628 : : return -1;
1629 : : }
1630 : :
1631 : 0 : static int ngbe_dev_xstats_get_names(struct rte_eth_dev *dev,
1632 : : struct rte_eth_xstat_name *xstats_names, unsigned int limit)
1633 : : {
1634 : : unsigned int i, count;
1635 : :
1636 : : count = ngbe_xstats_calc_num(dev);
1637 [ # # ]: 0 : if (xstats_names == NULL)
1638 : 0 : return count;
1639 : :
1640 : : /* Note: limit >= cnt_stats checked upstream
1641 : : * in rte_eth_xstats_names()
1642 : : */
1643 : 0 : limit = min(limit, count);
1644 : :
1645 : : /* Extended stats from ngbe_hw_stats */
1646 [ # # ]: 0 : for (i = 0; i < limit; i++) {
1647 [ # # ]: 0 : if (ngbe_get_name_by_id(i, xstats_names[i].name,
1648 : : sizeof(xstats_names[i].name))) {
1649 : 0 : PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
1650 : 0 : break;
1651 : : }
1652 : : }
1653 : :
1654 : 0 : return i;
1655 : : }
1656 : :
1657 : 0 : static int ngbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
1658 : : const uint64_t *ids,
1659 : : struct rte_eth_xstat_name *xstats_names,
1660 : : unsigned int limit)
1661 : : {
1662 : : unsigned int i;
1663 : :
1664 [ # # ]: 0 : if (ids == NULL)
1665 : 0 : return ngbe_dev_xstats_get_names(dev, xstats_names, limit);
1666 : :
1667 [ # # ]: 0 : for (i = 0; i < limit; i++) {
1668 [ # # ]: 0 : if (ngbe_get_name_by_id(ids[i], xstats_names[i].name,
1669 : : sizeof(xstats_names[i].name))) {
1670 : 0 : PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
1671 : 0 : return -1;
1672 : : }
1673 : : }
1674 : :
1675 : 0 : return i;
1676 : : }
1677 : :
1678 : : static int
1679 : 0 : ngbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
1680 : : unsigned int limit)
1681 : : {
1682 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1683 : 0 : struct ngbe_hw_stats *hw_stats = NGBE_DEV_STATS(dev);
1684 : : struct ngbe_rx_queue *rxq;
1685 : : uint64_t rx_csum_err = 0;
1686 : : unsigned int i, count;
1687 : :
1688 : 0 : ngbe_read_stats_registers(hw, hw_stats);
1689 : :
1690 : : /* If this is a reset xstats is NULL, and we have cleared the
1691 : : * registers by reading them.
1692 : : */
1693 : : count = ngbe_xstats_calc_num(dev);
1694 [ # # ]: 0 : if (xstats == NULL)
1695 : 0 : return count;
1696 : :
1697 : 0 : limit = min(limit, ngbe_xstats_calc_num(dev));
1698 : :
1699 : : /* Rx Checksum Errors */
1700 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1701 : 0 : rxq = dev->data->rx_queues[i];
1702 : 0 : rx_csum_err += rxq->csum_err;
1703 : : }
1704 : 0 : hw_stats->rx_l3_l4_xsum_error = rx_csum_err;
1705 : :
1706 : : /* Extended stats from ngbe_hw_stats */
1707 [ # # ]: 0 : for (i = 0; i < limit; i++) {
1708 : : uint32_t offset = 0;
1709 : :
1710 : : if (ngbe_get_offset_by_id(i, &offset)) {
1711 : 0 : PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
1712 : : break;
1713 : : }
1714 : 0 : xstats[i].value = *(uint64_t *)(((char *)hw_stats) + offset);
1715 : 0 : xstats[i].id = i;
1716 : : }
1717 : :
1718 : 0 : return i;
1719 : : }
1720 : :
1721 : : static int
1722 : 0 : ngbe_dev_xstats_get_(struct rte_eth_dev *dev, uint64_t *values,
1723 : : unsigned int limit)
1724 : : {
1725 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1726 : 0 : struct ngbe_hw_stats *hw_stats = NGBE_DEV_STATS(dev);
1727 : : unsigned int i, count;
1728 : :
1729 : 0 : ngbe_read_stats_registers(hw, hw_stats);
1730 : :
1731 : : /* If this is a reset xstats is NULL, and we have cleared the
1732 : : * registers by reading them.
1733 : : */
1734 : : count = ngbe_xstats_calc_num(dev);
1735 [ # # ]: 0 : if (values == NULL)
1736 : 0 : return count;
1737 : :
1738 : 0 : limit = min(limit, ngbe_xstats_calc_num(dev));
1739 : :
1740 : : /* Extended stats from ngbe_hw_stats */
1741 [ # # ]: 0 : for (i = 0; i < limit; i++) {
1742 : : uint32_t offset;
1743 : :
1744 : : if (ngbe_get_offset_by_id(i, &offset)) {
1745 : 0 : PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
1746 : : break;
1747 : : }
1748 : 0 : values[i] = *(uint64_t *)(((char *)hw_stats) + offset);
1749 : : }
1750 : :
1751 : 0 : return i;
1752 : : }
1753 : :
1754 : : static int
1755 : 0 : ngbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
1756 : : uint64_t *values, unsigned int limit)
1757 : : {
1758 : 0 : struct ngbe_hw_stats *hw_stats = NGBE_DEV_STATS(dev);
1759 : : unsigned int i;
1760 : :
1761 [ # # ]: 0 : if (ids == NULL)
1762 : 0 : return ngbe_dev_xstats_get_(dev, values, limit);
1763 : :
1764 [ # # ]: 0 : for (i = 0; i < limit; i++) {
1765 : : uint32_t offset;
1766 : :
1767 [ # # ]: 0 : if (ngbe_get_offset_by_id(ids[i], &offset)) {
1768 : 0 : PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
1769 : : break;
1770 : : }
1771 : 0 : values[i] = *(uint64_t *)(((char *)hw_stats) + offset);
1772 : : }
1773 : :
1774 : 0 : return i;
1775 : : }
1776 : :
1777 : : static int
1778 : 0 : ngbe_dev_xstats_reset(struct rte_eth_dev *dev)
1779 : : {
1780 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1781 : 0 : struct ngbe_hw_stats *hw_stats = NGBE_DEV_STATS(dev);
1782 : : struct ngbe_rx_queue *rxq;
1783 : : int i = 0;
1784 : :
1785 : : /* HW registers are cleared on read */
1786 : 0 : hw->offset_loaded = 0;
1787 : 0 : ngbe_read_stats_registers(hw, hw_stats);
1788 : 0 : hw->offset_loaded = 1;
1789 : :
1790 : : /* Reset software totals */
1791 : : memset(hw_stats, 0, sizeof(*hw_stats));
1792 : :
1793 : : /* Reset rxq checksum errors */
1794 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1795 : 0 : rxq = dev->data->rx_queues[i];
1796 : 0 : rxq->csum_err = 0;
1797 : : }
1798 : :
1799 : 0 : return 0;
1800 : : }
1801 : :
1802 : : static int
1803 [ # # ]: 0 : ngbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
1804 : : {
1805 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1806 : : int ret;
1807 : :
1808 [ # # ]: 0 : ret = snprintf(fw_version, fw_size, "0x%08x", hw->eeprom_id);
1809 : :
1810 [ # # ]: 0 : if (ret < 0)
1811 : : return -EINVAL;
1812 : :
1813 : 0 : ret += 1; /* add the size of '\0' */
1814 [ # # ]: 0 : if (fw_size < (size_t)ret)
1815 : 0 : return ret;
1816 : :
1817 : : return 0;
1818 : : }
1819 : :
1820 : : static int
1821 : 0 : ngbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
1822 : : {
1823 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
1824 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1825 : :
1826 : 0 : dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
1827 : 0 : dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
1828 : 0 : dev_info->min_rx_bufsize = 1024;
1829 : 0 : dev_info->max_rx_pktlen = NGBE_MAX_MTU + NGBE_ETH_OVERHEAD;
1830 : 0 : dev_info->min_mtu = RTE_ETHER_MIN_MTU;
1831 : 0 : dev_info->max_mtu = NGBE_MAX_MTU;
1832 : 0 : dev_info->max_mac_addrs = hw->mac.num_rar_entries;
1833 : 0 : dev_info->max_hash_mac_addrs = NGBE_VMDQ_NUM_UC_MAC;
1834 : 0 : dev_info->max_vfs = pci_dev->max_vfs;
1835 : 0 : dev_info->rx_queue_offload_capa = ngbe_get_rx_queue_offloads(dev);
1836 : 0 : dev_info->rx_offload_capa = (ngbe_get_rx_port_offloads(dev) |
1837 : 0 : dev_info->rx_queue_offload_capa);
1838 : 0 : dev_info->tx_queue_offload_capa = 0;
1839 : 0 : dev_info->tx_offload_capa = ngbe_get_tx_port_offloads(dev);
1840 : :
1841 : 0 : dev_info->default_rxconf = (struct rte_eth_rxconf) {
1842 : : .rx_thresh = {
1843 : : .pthresh = NGBE_DEFAULT_RX_PTHRESH,
1844 : : .hthresh = NGBE_DEFAULT_RX_HTHRESH,
1845 : : .wthresh = NGBE_DEFAULT_RX_WTHRESH,
1846 : : },
1847 : : .rx_free_thresh = NGBE_DEFAULT_RX_FREE_THRESH,
1848 : : .rx_drop_en = 0,
1849 : : .offloads = 0,
1850 : : };
1851 : :
1852 : 0 : dev_info->default_txconf = (struct rte_eth_txconf) {
1853 : : .tx_thresh = {
1854 : : .pthresh = NGBE_DEFAULT_TX_PTHRESH,
1855 : : .hthresh = NGBE_DEFAULT_TX_HTHRESH,
1856 : : .wthresh = NGBE_DEFAULT_TX_WTHRESH,
1857 : : },
1858 : : .tx_free_thresh = NGBE_DEFAULT_TX_FREE_THRESH,
1859 : : .offloads = 0,
1860 : : };
1861 : :
1862 : 0 : dev_info->rx_desc_lim = rx_desc_lim;
1863 : 0 : dev_info->tx_desc_lim = tx_desc_lim;
1864 : :
1865 : 0 : dev_info->hash_key_size = NGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
1866 : 0 : dev_info->reta_size = RTE_ETH_RSS_RETA_SIZE_128;
1867 : 0 : dev_info->flow_type_rss_offloads = NGBE_RSS_OFFLOAD_ALL;
1868 : :
1869 : 0 : dev_info->speed_capa = RTE_ETH_LINK_SPEED_1G | RTE_ETH_LINK_SPEED_100M |
1870 : : RTE_ETH_LINK_SPEED_10M;
1871 : :
1872 : : /* Driver-preferred Rx/Tx parameters */
1873 : 0 : dev_info->default_rxportconf.burst_size = 32;
1874 : 0 : dev_info->default_txportconf.burst_size = 32;
1875 : 0 : dev_info->default_rxportconf.nb_queues = 1;
1876 : 0 : dev_info->default_txportconf.nb_queues = 1;
1877 : 0 : dev_info->default_rxportconf.ring_size = 256;
1878 : 0 : dev_info->default_txportconf.ring_size = 256;
1879 : :
1880 : 0 : return 0;
1881 : : }
1882 : :
1883 : : const uint32_t *
1884 : 0 : ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)
1885 : : {
1886 [ # # # # ]: 0 : if (dev->rx_pkt_burst == ngbe_recv_pkts ||
1887 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM)
1888 [ # # ]: 0 : dev->rx_pkt_burst == ngbe_recv_pkts_vec ||
1889 [ # # ]: 0 : dev->rx_pkt_burst == ngbe_recv_scattered_pkts_vec ||
1890 : : #endif
1891 [ # # ]: 0 : dev->rx_pkt_burst == ngbe_recv_pkts_sc_single_alloc ||
1892 [ # # ]: 0 : dev->rx_pkt_burst == ngbe_recv_pkts_sc_bulk_alloc ||
1893 : : dev->rx_pkt_burst == ngbe_recv_pkts_bulk_alloc)
1894 : 0 : return ngbe_get_supported_ptypes(no_of_elements);
1895 : :
1896 : : return NULL;
1897 : : }
1898 : :
1899 : : static void
1900 : 0 : ngbe_dev_overheat(struct rte_eth_dev *dev)
1901 : : {
1902 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1903 : : s32 temp_state;
1904 : :
1905 : 0 : temp_state = hw->mac.check_overtemp(hw);
1906 [ # # ]: 0 : if (!temp_state)
1907 : : return;
1908 : :
1909 [ # # ]: 0 : if (temp_state == NGBE_ERR_UNDERTEMP) {
1910 : 0 : PMD_DRV_LOG(CRIT, "Network adapter has been started again, "
1911 : : "since the temperature has been back to normal state.");
1912 : : wr32m(hw, NGBE_PBRXCTL, NGBE_PBRXCTL_ENA, NGBE_PBRXCTL_ENA);
1913 : : ngbe_dev_set_link_up(dev);
1914 [ # # ]: 0 : } else if (temp_state == NGBE_ERR_OVERTEMP) {
1915 : 0 : PMD_DRV_LOG(CRIT, "Network adapter has been stopped because it has over heated.");
1916 : : wr32m(hw, NGBE_PBRXCTL, NGBE_PBRXCTL_ENA, 0);
1917 : : ngbe_dev_set_link_down(dev);
1918 : : }
1919 : : }
1920 : :
1921 : : /* return 0 means link status changed, -1 means not changed */
1922 : : int
1923 [ # # ]: 0 : ngbe_dev_link_update_share(struct rte_eth_dev *dev,
1924 : : int wait_to_complete)
1925 : : {
1926 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
1927 : : struct rte_eth_link link;
1928 [ # # ]: 0 : u32 link_speed = NGBE_LINK_SPEED_UNKNOWN;
1929 : : u32 lan_speed = 0;
1930 : : bool link_up;
1931 : : int err;
1932 : : int wait = 1;
1933 : : u32 reg;
1934 : :
1935 : : memset(&link, 0, sizeof(link));
1936 : : link.link_status = RTE_ETH_LINK_DOWN;
1937 : : link.link_speed = RTE_ETH_SPEED_NUM_NONE;
1938 : : link.link_duplex = RTE_ETH_LINK_HALF_DUPLEX;
1939 : 0 : link.link_autoneg = !(dev->data->dev_conf.link_speeds &
1940 : : ~RTE_ETH_LINK_SPEED_AUTONEG);
1941 : :
1942 : 0 : hw->mac.get_link_status = true;
1943 : :
1944 : : /* check if it needs to wait to complete, if lsc interrupt is enabled */
1945 [ # # # # ]: 0 : if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
1946 : : wait = 0;
1947 : :
1948 : 0 : err = hw->mac.check_link(hw, &link_speed, &link_up, wait);
1949 [ # # ]: 0 : if (err != 0) {
1950 : : link.link_speed = RTE_ETH_SPEED_NUM_NONE;
1951 [ # # ]: 0 : link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
1952 : 0 : return rte_eth_linkstatus_set(dev, &link);
1953 : : }
1954 : :
1955 [ # # ]: 0 : if (!link_up)
1956 : 0 : return rte_eth_linkstatus_set(dev, &link);
1957 : :
1958 : 0 : link.link_status = RTE_ETH_LINK_UP;
1959 : 0 : link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
1960 : :
1961 [ # # # # ]: 0 : switch (link_speed) {
1962 : : default:
1963 : : case NGBE_LINK_SPEED_UNKNOWN:
1964 : : link.link_speed = RTE_ETH_SPEED_NUM_NONE;
1965 : : break;
1966 : :
1967 : 0 : case NGBE_LINK_SPEED_10M_FULL:
1968 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_10M;
1969 : : lan_speed = 0;
1970 : 0 : break;
1971 : :
1972 : 0 : case NGBE_LINK_SPEED_100M_FULL:
1973 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_100M;
1974 : : lan_speed = 1;
1975 : 0 : break;
1976 : :
1977 : 0 : case NGBE_LINK_SPEED_1GB_FULL:
1978 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_1G;
1979 : : lan_speed = 2;
1980 : 0 : break;
1981 : : }
1982 : :
1983 [ # # ]: 0 : if (hw->is_pf) {
1984 : : wr32m(hw, NGBE_LAN_SPEED, NGBE_LAN_SPEED_MASK, lan_speed);
1985 [ # # ]: 0 : if (link_speed & (NGBE_LINK_SPEED_1GB_FULL |
1986 : : NGBE_LINK_SPEED_100M_FULL |
1987 : : NGBE_LINK_SPEED_10M_FULL)) {
1988 : : wr32m(hw, NGBE_MACTXCFG, NGBE_MACTXCFG_SPEED_MASK,
1989 : : NGBE_MACTXCFG_SPEED_1G | NGBE_MACTXCFG_TE);
1990 : : }
1991 : : /* Re configure MAC RX */
1992 : : reg = rd32(hw, NGBE_MACRXCFG);
1993 : : wr32(hw, NGBE_MACRXCFG, reg);
1994 : : wr32m(hw, NGBE_MACRXFLT, NGBE_MACRXFLT_PROMISC,
1995 : : NGBE_MACRXFLT_PROMISC);
1996 : : reg = rd32(hw, NGBE_MAC_WDG_TIMEOUT);
1997 : : wr32(hw, NGBE_MAC_WDG_TIMEOUT, reg);
1998 : : }
1999 : :
2000 : : return rte_eth_linkstatus_set(dev, &link);
2001 : : }
2002 : :
2003 : : static int
2004 : 0 : ngbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
2005 : : {
2006 : 0 : return ngbe_dev_link_update_share(dev, wait_to_complete);
2007 : : }
2008 : :
2009 : : static int
2010 : 0 : ngbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
2011 : : {
2012 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2013 : : uint32_t fctrl;
2014 : :
2015 : : fctrl = rd32(hw, NGBE_PSRCTL);
2016 : 0 : fctrl |= (NGBE_PSRCTL_UCP | NGBE_PSRCTL_MCP);
2017 : : wr32(hw, NGBE_PSRCTL, fctrl);
2018 : :
2019 : 0 : return 0;
2020 : : }
2021 : :
2022 : : static int
2023 : 0 : ngbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
2024 : : {
2025 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2026 : : uint32_t fctrl;
2027 : :
2028 : : fctrl = rd32(hw, NGBE_PSRCTL);
2029 : 0 : fctrl &= (~NGBE_PSRCTL_UCP);
2030 [ # # ]: 0 : if (dev->data->all_multicast == 1)
2031 : 0 : fctrl |= NGBE_PSRCTL_MCP;
2032 : : else
2033 : 0 : fctrl &= (~NGBE_PSRCTL_MCP);
2034 : : wr32(hw, NGBE_PSRCTL, fctrl);
2035 : :
2036 : 0 : return 0;
2037 : : }
2038 : :
2039 : : static int
2040 : 0 : ngbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
2041 : : {
2042 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2043 : : uint32_t fctrl;
2044 : :
2045 : : fctrl = rd32(hw, NGBE_PSRCTL);
2046 : 0 : fctrl |= NGBE_PSRCTL_MCP;
2047 : : wr32(hw, NGBE_PSRCTL, fctrl);
2048 : :
2049 : 0 : return 0;
2050 : : }
2051 : :
2052 : : static int
2053 [ # # ]: 0 : ngbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
2054 : : {
2055 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2056 : : uint32_t fctrl;
2057 : :
2058 [ # # ]: 0 : if (dev->data->promiscuous == 1)
2059 : : return 0; /* must remain in all_multicast mode */
2060 : :
2061 : : fctrl = rd32(hw, NGBE_PSRCTL);
2062 : 0 : fctrl &= (~NGBE_PSRCTL_MCP);
2063 : : wr32(hw, NGBE_PSRCTL, fctrl);
2064 : :
2065 : 0 : return 0;
2066 : : }
2067 : :
2068 : : /**
2069 : : * It clears the interrupt causes and enables the interrupt.
2070 : : * It will be called once only during NIC initialized.
2071 : : *
2072 : : * @param dev
2073 : : * Pointer to struct rte_eth_dev.
2074 : : * @param on
2075 : : * Enable or Disable.
2076 : : *
2077 : : * @return
2078 : : * - On success, zero.
2079 : : * - On failure, a negative value.
2080 : : */
2081 : : static int
2082 : 0 : ngbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on)
2083 : : {
2084 : : struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
2085 : :
2086 : 0 : ngbe_dev_link_status_print(dev);
2087 [ # # ]: 0 : if (on != 0) {
2088 : 0 : intr->mask_misc |= NGBE_ICRMISC_PHY;
2089 : 0 : intr->mask_misc |= NGBE_ICRMISC_GPIO;
2090 : : } else {
2091 : 0 : intr->mask_misc &= ~NGBE_ICRMISC_PHY;
2092 : 0 : intr->mask_misc &= ~NGBE_ICRMISC_GPIO;
2093 : : }
2094 : :
2095 : 0 : return 0;
2096 : : }
2097 : :
2098 : : /**
2099 : : * It clears the interrupt causes and enables the interrupt.
2100 : : * It will be called once only during NIC initialized.
2101 : : *
2102 : : * @param dev
2103 : : * Pointer to struct rte_eth_dev.
2104 : : *
2105 : : * @return
2106 : : * - On success, zero.
2107 : : * - On failure, a negative value.
2108 : : */
2109 : : static int
2110 : : ngbe_dev_misc_interrupt_setup(struct rte_eth_dev *dev)
2111 : : {
2112 : : struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
2113 : : u64 mask;
2114 : :
2115 : : mask = NGBE_ICR_MASK;
2116 : : mask &= (1ULL << NGBE_MISC_VEC_ID);
2117 : 0 : intr->mask |= mask;
2118 [ # # ]: 0 : intr->mask_misc |= NGBE_ICRMISC_GPIO;
2119 : :
2120 : : return 0;
2121 : : }
2122 : :
2123 : : /**
2124 : : * It clears the interrupt causes and enables the interrupt.
2125 : : * It will be called once only during NIC initialized.
2126 : : *
2127 : : * @param dev
2128 : : * Pointer to struct rte_eth_dev.
2129 : : *
2130 : : * @return
2131 : : * - On success, zero.
2132 : : * - On failure, a negative value.
2133 : : */
2134 : : static int
2135 : : ngbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
2136 : : {
2137 : : struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
2138 : : u64 mask;
2139 : :
2140 : : mask = NGBE_ICR_MASK;
2141 : : mask &= ~((1ULL << NGBE_RX_VEC_START) - 1);
2142 : 0 : intr->mask |= mask;
2143 : :
2144 : 0 : return 0;
2145 : : }
2146 : :
2147 : : /**
2148 : : * It clears the interrupt causes and enables the interrupt.
2149 : : * It will be called once only during NIC initialized.
2150 : : *
2151 : : * @param dev
2152 : : * Pointer to struct rte_eth_dev.
2153 : : *
2154 : : * @return
2155 : : * - On success, zero.
2156 : : * - On failure, a negative value.
2157 : : */
2158 : : static int
2159 : : ngbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
2160 : : {
2161 : : struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
2162 : :
2163 : 0 : intr->mask_misc |= NGBE_ICRMISC_LNKSEC;
2164 : :
2165 : : return 0;
2166 : : }
2167 : :
2168 : : /*
2169 : : * It reads ICR and sets flag for the link_update.
2170 : : *
2171 : : * @param dev
2172 : : * Pointer to struct rte_eth_dev.
2173 : : *
2174 : : * @return
2175 : : * - On success, zero.
2176 : : * - On failure, a negative value.
2177 : : */
2178 : : static int
2179 [ # # ]: 0 : ngbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
2180 : : {
2181 : : uint32_t eicr;
2182 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2183 : : struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
2184 : :
2185 : 0 : eicr = ((u32 *)hw->isb_mem)[NGBE_ISB_VEC0];
2186 [ # # ]: 0 : if (!eicr) {
2187 : : /*
2188 : : * shared interrupt alert!
2189 : : * make sure interrupts are enabled because the read will
2190 : : * have disabled interrupts.
2191 : : */
2192 [ # # ]: 0 : if (!hw->adapter_stopped)
2193 : : ngbe_enable_intr(dev);
2194 : 0 : return 0;
2195 : : }
2196 : 0 : ((u32 *)hw->isb_mem)[NGBE_ISB_VEC0] = 0;
2197 : :
2198 : : /* read-on-clear nic registers here */
2199 : 0 : eicr = ((u32 *)hw->isb_mem)[NGBE_ISB_MISC];
2200 : 0 : PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
2201 : :
2202 : 0 : intr->flags = 0;
2203 : :
2204 : : /* set flag for async link update */
2205 [ # # ]: 0 : if (eicr & NGBE_ICRMISC_PHY)
2206 : 0 : intr->flags |= NGBE_FLAG_NEED_LINK_UPDATE;
2207 : :
2208 [ # # ]: 0 : if (eicr & NGBE_ICRMISC_VFMBX)
2209 : 0 : intr->flags |= NGBE_FLAG_MAILBOX;
2210 : :
2211 [ # # ]: 0 : if (eicr & NGBE_ICRMISC_LNKSEC)
2212 : 0 : intr->flags |= NGBE_FLAG_MACSEC;
2213 : :
2214 [ # # ]: 0 : if (eicr & NGBE_ICRMISC_GPIO)
2215 : 0 : intr->flags |= NGBE_FLAG_NEED_LINK_UPDATE;
2216 : :
2217 [ # # ]: 0 : if (eicr & NGBE_ICRMISC_HEAT)
2218 : 0 : intr->flags |= NGBE_FLAG_OVERHEAT;
2219 : :
2220 : 0 : ((u32 *)hw->isb_mem)[NGBE_ISB_MISC] = 0;
2221 : :
2222 : 0 : return 0;
2223 : : }
2224 : :
2225 : : /**
2226 : : * It gets and then prints the link status.
2227 : : *
2228 : : * @param dev
2229 : : * Pointer to struct rte_eth_dev.
2230 : : *
2231 : : * @return
2232 : : * - On success, zero.
2233 : : * - On failure, a negative value.
2234 : : */
2235 : : static void
2236 : 0 : ngbe_dev_link_status_print(struct rte_eth_dev *dev)
2237 : : {
2238 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2239 : : struct rte_eth_link link;
2240 : :
2241 : 0 : rte_eth_linkstatus_get(dev, &link);
2242 : :
2243 [ # # ]: 0 : if (link.link_status == RTE_ETH_LINK_UP) {
2244 [ # # ]: 0 : PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
2245 : : (int)(dev->data->port_id),
2246 : : (unsigned int)link.link_speed,
2247 : : link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX ?
2248 : : "full-duplex" : "half-duplex");
2249 : : } else {
2250 : 0 : PMD_INIT_LOG(INFO, " Port %d: Link Down",
2251 : : (int)(dev->data->port_id));
2252 : : }
2253 : 0 : PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
2254 : : pci_dev->addr.domain,
2255 : : pci_dev->addr.bus,
2256 : : pci_dev->addr.devid,
2257 : : pci_dev->addr.function);
2258 : 0 : }
2259 : :
2260 : : /*
2261 : : * It executes link_update after knowing an interrupt occurred.
2262 : : *
2263 : : * @param dev
2264 : : * Pointer to struct rte_eth_dev.
2265 : : *
2266 : : * @return
2267 : : * - On success, zero.
2268 : : * - On failure, a negative value.
2269 : : */
2270 : : static int
2271 : 0 : ngbe_dev_interrupt_action(struct rte_eth_dev *dev)
2272 : : {
2273 : : struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
2274 : :
2275 : 0 : PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
2276 : :
2277 [ # # ]: 0 : if (intr->flags & NGBE_FLAG_MAILBOX) {
2278 : 0 : ngbe_pf_mbx_process(dev);
2279 : 0 : intr->flags &= ~NGBE_FLAG_MAILBOX;
2280 : : }
2281 : :
2282 [ # # ]: 0 : if (intr->flags & NGBE_FLAG_NEED_LINK_UPDATE) {
2283 : : struct rte_eth_link link;
2284 : :
2285 : : /*get the link status before link update, for predicting later*/
2286 : 0 : rte_eth_linkstatus_get(dev, &link);
2287 : :
2288 : : ngbe_dev_link_update(dev, 0);
2289 : 0 : intr->flags &= ~NGBE_FLAG_NEED_LINK_UPDATE;
2290 : 0 : ngbe_dev_link_status_print(dev);
2291 [ # # ]: 0 : if (dev->data->dev_link.link_speed != link.link_speed)
2292 : 0 : rte_eth_dev_callback_process(dev,
2293 : : RTE_ETH_EVENT_INTR_LSC, NULL);
2294 : : }
2295 : :
2296 [ # # ]: 0 : if (intr->flags & NGBE_FLAG_OVERHEAT) {
2297 : 0 : ngbe_dev_overheat(dev);
2298 : 0 : intr->flags &= ~NGBE_FLAG_OVERHEAT;
2299 : : }
2300 : :
2301 : 0 : PMD_DRV_LOG(DEBUG, "enable intr immediately");
2302 : : ngbe_enable_intr(dev);
2303 : :
2304 : 0 : return 0;
2305 : : }
2306 : :
2307 : : /**
2308 : : * Interrupt handler triggered by NIC for handling
2309 : : * specific interrupt.
2310 : : *
2311 : : * @param param
2312 : : * The address of parameter (struct rte_eth_dev *) registered before.
2313 : : */
2314 : : static void
2315 : 0 : ngbe_dev_interrupt_handler(void *param)
2316 : : {
2317 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
2318 : :
2319 : 0 : ngbe_dev_interrupt_get_status(dev);
2320 : 0 : ngbe_dev_interrupt_action(dev);
2321 : 0 : }
2322 : :
2323 : : static int
2324 : 0 : ngbe_dev_led_on(struct rte_eth_dev *dev)
2325 : : {
2326 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2327 [ # # ]: 0 : return hw->mac.led_on(hw, 0) == 0 ? 0 : -ENOTSUP;
2328 : : }
2329 : :
2330 : : static int
2331 : 0 : ngbe_dev_led_off(struct rte_eth_dev *dev)
2332 : : {
2333 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2334 [ # # ]: 0 : return hw->mac.led_off(hw, 0) == 0 ? 0 : -ENOTSUP;
2335 : : }
2336 : :
2337 : : static int
2338 : 0 : ngbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
2339 : : {
2340 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2341 : : uint32_t mflcn_reg;
2342 : : uint32_t fccfg_reg;
2343 : : int rx_pause;
2344 : : int tx_pause;
2345 : :
2346 : 0 : fc_conf->pause_time = hw->fc.pause_time;
2347 : 0 : fc_conf->high_water = hw->fc.high_water;
2348 : 0 : fc_conf->low_water = hw->fc.low_water;
2349 : 0 : fc_conf->send_xon = hw->fc.send_xon;
2350 : 0 : fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
2351 : :
2352 : : /*
2353 : : * Return rx_pause status according to actual setting of
2354 : : * RXFCCFG register.
2355 : : */
2356 : : mflcn_reg = rd32(hw, NGBE_RXFCCFG);
2357 [ # # ]: 0 : if (mflcn_reg & NGBE_RXFCCFG_FC)
2358 : : rx_pause = 1;
2359 : : else
2360 : : rx_pause = 0;
2361 : :
2362 : : /*
2363 : : * Return tx_pause status according to actual setting of
2364 : : * TXFCCFG register.
2365 : : */
2366 : : fccfg_reg = rd32(hw, NGBE_TXFCCFG);
2367 [ # # ]: 0 : if (fccfg_reg & NGBE_TXFCCFG_FC)
2368 : : tx_pause = 1;
2369 : : else
2370 : : tx_pause = 0;
2371 : :
2372 [ # # ]: 0 : if (rx_pause && tx_pause)
2373 : 0 : fc_conf->mode = RTE_ETH_FC_FULL;
2374 [ # # ]: 0 : else if (rx_pause)
2375 : 0 : fc_conf->mode = RTE_ETH_FC_RX_PAUSE;
2376 [ # # ]: 0 : else if (tx_pause)
2377 : 0 : fc_conf->mode = RTE_ETH_FC_TX_PAUSE;
2378 : : else
2379 : 0 : fc_conf->mode = RTE_ETH_FC_NONE;
2380 : :
2381 : 0 : return 0;
2382 : : }
2383 : :
2384 : : static int
2385 : 0 : ngbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
2386 : : {
2387 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2388 : : int err;
2389 : : uint32_t rx_buf_size;
2390 : : uint32_t max_high_water;
2391 : 0 : enum ngbe_fc_mode rte_fcmode_2_ngbe_fcmode[] = {
2392 : : ngbe_fc_none,
2393 : : ngbe_fc_rx_pause,
2394 : : ngbe_fc_tx_pause,
2395 : : ngbe_fc_full
2396 : : };
2397 : :
2398 : 0 : PMD_INIT_FUNC_TRACE();
2399 : :
2400 : : rx_buf_size = rd32(hw, NGBE_PBRXSIZE);
2401 : 0 : PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
2402 : :
2403 : : /*
2404 : : * At least reserve one Ethernet frame for watermark
2405 : : * high_water/low_water in kilo bytes for ngbe
2406 : : */
2407 : 0 : max_high_water = (rx_buf_size - RTE_ETHER_MAX_LEN) >> 10;
2408 [ # # ]: 0 : if (fc_conf->high_water > max_high_water ||
2409 [ # # ]: 0 : fc_conf->high_water < fc_conf->low_water) {
2410 : 0 : PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
2411 : 0 : PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
2412 : 0 : return -EINVAL;
2413 : : }
2414 : :
2415 : 0 : hw->fc.requested_mode = rte_fcmode_2_ngbe_fcmode[fc_conf->mode];
2416 : 0 : hw->fc.pause_time = fc_conf->pause_time;
2417 : 0 : hw->fc.high_water = fc_conf->high_water;
2418 : 0 : hw->fc.low_water = fc_conf->low_water;
2419 : 0 : hw->fc.send_xon = fc_conf->send_xon;
2420 : 0 : hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
2421 : 0 : hw->fc.mac_ctrl_frame_fwd = fc_conf->mac_ctrl_frame_fwd;
2422 : :
2423 : 0 : err = hw->mac.fc_enable(hw);
2424 : :
2425 : : /* Not negotiated is not an error case */
2426 [ # # ]: 0 : if (err == 0 || err == NGBE_ERR_FC_NOT_NEGOTIATED) {
2427 : 0 : wr32m(hw, NGBE_MACRXFLT, NGBE_MACRXFLT_CTL_MASK,
2428 [ # # ]: 0 : (fc_conf->mac_ctrl_frame_fwd
2429 : : ? NGBE_MACRXFLT_CTL_NOPS : NGBE_MACRXFLT_CTL_DROP));
2430 : : ngbe_flush(hw);
2431 : :
2432 : 0 : return 0;
2433 : : }
2434 : :
2435 : 0 : PMD_INIT_LOG(ERR, "ngbe_fc_enable = 0x%x", err);
2436 : 0 : return -EIO;
2437 : : }
2438 : :
2439 : : /* Additional bittime to account for NGBE framing */
2440 : : #define NGBE_ETH_FRAMING 20
2441 : :
2442 : : /*
2443 : : * ngbe_fc_hpbthresh_set - calculate high water mark for flow control
2444 : : *
2445 : : * @dv_id: device interface delay
2446 : : * @pb: packet buffer to calculate
2447 : : */
2448 : : static s32
2449 : 0 : ngbe_fc_hpbthresh_set(struct rte_eth_dev *dev)
2450 : : {
2451 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2452 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2453 : : u32 max_frame_size, tc, dv_id, rx_pb;
2454 : : s32 kb, marker;
2455 : :
2456 : : /* Calculate max LAN frame size */
2457 : : max_frame_size = rd32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK);
2458 : 0 : tc = max_frame_size + NGBE_ETH_FRAMING;
2459 : :
2460 : : /* Calculate delay value for device */
2461 : 0 : dv_id = NGBE_DV(tc, tc);
2462 : :
2463 : : /* Loopback switch introduces additional latency */
2464 [ # # ]: 0 : if (pci_dev->max_vfs)
2465 : 0 : dv_id += NGBE_B2BT(tc);
2466 : :
2467 : : /* Delay value is calculated in bit times convert to KB */
2468 : 0 : kb = NGBE_BT2KB(dv_id);
2469 : 0 : rx_pb = rd32(hw, NGBE_PBRXSIZE) >> 10;
2470 : :
2471 : 0 : marker = rx_pb - kb;
2472 : :
2473 : : /* It is possible that the packet buffer is not large enough
2474 : : * to provide required headroom. In this case throw an error
2475 : : * to user and do the best we can.
2476 : : */
2477 [ # # ]: 0 : if (marker < 0) {
2478 : 0 : PMD_DRV_LOG(WARNING, "Packet Buffer can not provide enough headroom to support flow control.");
2479 : 0 : marker = tc + 1;
2480 : : }
2481 : :
2482 : 0 : return marker;
2483 : : }
2484 : :
2485 : : /*
2486 : : * ngbe_fc_lpbthresh_set - calculate low water mark for flow control
2487 : : *
2488 : : * @dv_id: device interface delay
2489 : : */
2490 : : static s32
2491 : : ngbe_fc_lpbthresh_set(struct rte_eth_dev *dev)
2492 : : {
2493 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2494 : : u32 max_frame_size, tc, dv_id;
2495 : : s32 kb;
2496 : :
2497 : : /* Calculate max LAN frame size */
2498 : : max_frame_size = rd32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK);
2499 : : tc = max_frame_size + NGBE_ETH_FRAMING;
2500 : :
2501 : : /* Calculate delay value for device */
2502 : 0 : dv_id = NGBE_LOW_DV(tc);
2503 : :
2504 : : /* Delay value is calculated in bit times convert to KB */
2505 : 0 : kb = NGBE_BT2KB(dv_id);
2506 : :
2507 : : return kb;
2508 : : }
2509 : :
2510 : : /*
2511 : : * ngbe_pbthresh_setup - calculate and setup high low water marks
2512 : : */
2513 : : static void
2514 : 0 : ngbe_pbthresh_set(struct rte_eth_dev *dev)
2515 : : {
2516 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2517 : :
2518 : 0 : hw->fc.high_water = ngbe_fc_hpbthresh_set(dev);
2519 : 0 : hw->fc.low_water = ngbe_fc_lpbthresh_set(dev);
2520 : :
2521 : : /* Low water marks must not be larger than high water marks */
2522 [ # # ]: 0 : if (hw->fc.low_water > hw->fc.high_water)
2523 : 0 : hw->fc.low_water = 0;
2524 : 0 : }
2525 : :
2526 : : int
2527 : 0 : ngbe_dev_rss_reta_update(struct rte_eth_dev *dev,
2528 : : struct rte_eth_rss_reta_entry64 *reta_conf,
2529 : : uint16_t reta_size)
2530 : : {
2531 : : uint8_t i, j, mask;
2532 : : uint32_t reta;
2533 : : uint16_t idx, shift;
2534 : : struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
2535 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2536 : :
2537 : 0 : PMD_INIT_FUNC_TRACE();
2538 : :
2539 [ # # ]: 0 : if (!hw->is_pf) {
2540 : 0 : PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
2541 : : "NIC.");
2542 : 0 : return -ENOTSUP;
2543 : : }
2544 : :
2545 [ # # ]: 0 : if (reta_size != RTE_ETH_RSS_RETA_SIZE_128) {
2546 : 0 : PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
2547 : : "(%d) doesn't match the number hardware can supported "
2548 : : "(%d)", reta_size, RTE_ETH_RSS_RETA_SIZE_128);
2549 : 0 : return -EINVAL;
2550 : : }
2551 : :
2552 [ # # ]: 0 : for (i = 0; i < reta_size; i += 4) {
2553 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
2554 : : shift = i % RTE_ETH_RETA_GROUP_SIZE;
2555 : 0 : mask = (uint8_t)RS64(reta_conf[idx].mask, shift, 0xF);
2556 [ # # ]: 0 : if (!mask)
2557 : 0 : continue;
2558 : :
2559 : 0 : reta = rd32a(hw, NGBE_REG_RSSTBL, i >> 2);
2560 [ # # ]: 0 : for (j = 0; j < 4; j++) {
2561 [ # # ]: 0 : if (RS8(mask, j, 0x1)) {
2562 : 0 : reta &= ~(MS32(8 * j, 0xFF));
2563 : 0 : reta |= LS32(reta_conf[idx].reta[shift + j],
2564 : : 8 * j, 0xFF);
2565 : : }
2566 : : }
2567 : : wr32a(hw, NGBE_REG_RSSTBL, i >> 2, reta);
2568 : : }
2569 : 0 : adapter->rss_reta_updated = 1;
2570 : :
2571 : 0 : return 0;
2572 : : }
2573 : :
2574 : : int
2575 : 0 : ngbe_dev_rss_reta_query(struct rte_eth_dev *dev,
2576 : : struct rte_eth_rss_reta_entry64 *reta_conf,
2577 : : uint16_t reta_size)
2578 : : {
2579 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2580 : : uint8_t i, j, mask;
2581 : : uint32_t reta;
2582 : : uint16_t idx, shift;
2583 : :
2584 : 0 : PMD_INIT_FUNC_TRACE();
2585 : :
2586 [ # # ]: 0 : if (reta_size != RTE_ETH_RSS_RETA_SIZE_128) {
2587 : 0 : PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
2588 : : "(%d) doesn't match the number hardware can supported "
2589 : : "(%d)", reta_size, RTE_ETH_RSS_RETA_SIZE_128);
2590 : 0 : return -EINVAL;
2591 : : }
2592 : :
2593 [ # # ]: 0 : for (i = 0; i < reta_size; i += 4) {
2594 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
2595 : : shift = i % RTE_ETH_RETA_GROUP_SIZE;
2596 : 0 : mask = (uint8_t)RS64(reta_conf[idx].mask, shift, 0xF);
2597 [ # # ]: 0 : if (!mask)
2598 : 0 : continue;
2599 : :
2600 : 0 : reta = rd32a(hw, NGBE_REG_RSSTBL, i >> 2);
2601 [ # # ]: 0 : for (j = 0; j < 4; j++) {
2602 [ # # ]: 0 : if (RS8(mask, j, 0x1))
2603 : 0 : reta_conf[idx].reta[shift + j] =
2604 : 0 : (uint16_t)RS32(reta, 8 * j, 0xFF);
2605 : : }
2606 : : }
2607 : :
2608 : : return 0;
2609 : : }
2610 : :
2611 : : static int
2612 : 0 : ngbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
2613 : : uint32_t index, uint32_t pool)
2614 : : {
2615 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2616 : : uint32_t enable_addr = 1;
2617 : :
2618 : 0 : return ngbe_set_rar(hw, index, mac_addr->addr_bytes,
2619 : : pool, enable_addr);
2620 : : }
2621 : :
2622 : : static void
2623 : 0 : ngbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
2624 : : {
2625 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2626 : :
2627 : 0 : ngbe_clear_rar(hw, index);
2628 : 0 : }
2629 : :
2630 : : static int
2631 : 0 : ngbe_set_default_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *addr)
2632 : : {
2633 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2634 : :
2635 : : ngbe_remove_rar(dev, 0);
2636 : 0 : ngbe_add_rar(dev, addr, 0, pci_dev->max_vfs);
2637 : :
2638 : 0 : return 0;
2639 : : }
2640 : :
2641 : : static int
2642 [ # # ]: 0 : ngbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
2643 : : {
2644 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2645 : : uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
2646 : : struct rte_eth_dev_data *dev_data = dev->data;
2647 : :
2648 : : /* If device is started, refuse mtu that requires the support of
2649 : : * scattered packets when this feature has not been enabled before.
2650 : : */
2651 [ # # ]: 0 : if (dev_data->dev_started && !dev_data->scattered_rx &&
2652 : 0 : (frame_size + 2 * RTE_VLAN_HLEN >
2653 [ # # ]: 0 : dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
2654 : 0 : PMD_INIT_LOG(ERR, "Stop port first.");
2655 : 0 : return -EINVAL;
2656 : : }
2657 : :
2658 : 0 : wr32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK,
2659 : 0 : NGBE_FRMSZ_MAX(frame_size));
2660 : :
2661 : 0 : return 0;
2662 : : }
2663 : :
2664 : : static uint32_t
2665 : 0 : ngbe_uta_vector(struct ngbe_hw *hw, struct rte_ether_addr *uc_addr)
2666 : : {
2667 : : uint32_t vector = 0;
2668 : :
2669 [ # # # # : 0 : switch (hw->mac.mc_filter_type) {
# ]
2670 : 0 : case 0: /* use bits [47:36] of the address */
2671 : 0 : vector = ((uc_addr->addr_bytes[4] >> 4) |
2672 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 4));
2673 : 0 : break;
2674 : 0 : case 1: /* use bits [46:35] of the address */
2675 : 0 : vector = ((uc_addr->addr_bytes[4] >> 3) |
2676 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 5));
2677 : 0 : break;
2678 : 0 : case 2: /* use bits [45:34] of the address */
2679 : 0 : vector = ((uc_addr->addr_bytes[4] >> 2) |
2680 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 6));
2681 : 0 : break;
2682 : 0 : case 3: /* use bits [43:32] of the address */
2683 : 0 : vector = ((uc_addr->addr_bytes[4]) |
2684 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 8));
2685 : 0 : break;
2686 : : default: /* Invalid mc_filter_type */
2687 : : break;
2688 : : }
2689 : :
2690 : : /* vector can only be 12-bits or boundary will be exceeded */
2691 : 0 : vector &= 0xFFF;
2692 : 0 : return vector;
2693 : : }
2694 : :
2695 : : static int
2696 [ # # ]: 0 : ngbe_uc_hash_table_set(struct rte_eth_dev *dev,
2697 : : struct rte_ether_addr *mac_addr, uint8_t on)
2698 : : {
2699 : : uint32_t vector;
2700 : : uint32_t uta_idx;
2701 : : uint32_t reg_val;
2702 : : uint32_t uta_mask;
2703 : : uint32_t psrctl;
2704 : :
2705 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2706 : : struct ngbe_uta_info *uta_info = NGBE_DEV_UTA_INFO(dev);
2707 : :
2708 : 0 : vector = ngbe_uta_vector(hw, mac_addr);
2709 : 0 : uta_idx = (vector >> 5) & 0x7F;
2710 : 0 : uta_mask = 0x1UL << (vector & 0x1F);
2711 : :
2712 [ # # ]: 0 : if (!!on == !!(uta_info->uta_shadow[uta_idx] & uta_mask))
2713 : : return 0;
2714 : :
2715 : 0 : reg_val = rd32(hw, NGBE_UCADDRTBL(uta_idx));
2716 [ # # ]: 0 : if (on) {
2717 : 0 : uta_info->uta_in_use++;
2718 : 0 : reg_val |= uta_mask;
2719 : 0 : uta_info->uta_shadow[uta_idx] |= uta_mask;
2720 : : } else {
2721 : 0 : uta_info->uta_in_use--;
2722 : 0 : reg_val &= ~uta_mask;
2723 : 0 : uta_info->uta_shadow[uta_idx] &= ~uta_mask;
2724 : : }
2725 : :
2726 : : wr32(hw, NGBE_UCADDRTBL(uta_idx), reg_val);
2727 : :
2728 : : psrctl = rd32(hw, NGBE_PSRCTL);
2729 [ # # ]: 0 : if (uta_info->uta_in_use > 0)
2730 : 0 : psrctl |= NGBE_PSRCTL_UCHFENA;
2731 : : else
2732 : 0 : psrctl &= ~NGBE_PSRCTL_UCHFENA;
2733 : :
2734 : 0 : psrctl &= ~NGBE_PSRCTL_ADHF12_MASK;
2735 : 0 : psrctl |= NGBE_PSRCTL_ADHF12(hw->mac.mc_filter_type);
2736 : : wr32(hw, NGBE_PSRCTL, psrctl);
2737 : :
2738 : 0 : return 0;
2739 : : }
2740 : :
2741 : : static int
2742 [ # # ]: 0 : ngbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
2743 : : {
2744 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2745 : : struct ngbe_uta_info *uta_info = NGBE_DEV_UTA_INFO(dev);
2746 : : uint32_t psrctl;
2747 : : int i;
2748 : :
2749 [ # # ]: 0 : if (on) {
2750 [ # # ]: 0 : for (i = 0; i < RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
2751 : 0 : uta_info->uta_shadow[i] = ~0;
2752 : 0 : wr32(hw, NGBE_UCADDRTBL(i), ~0);
2753 : : }
2754 : : } else {
2755 [ # # ]: 0 : for (i = 0; i < RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
2756 : 0 : uta_info->uta_shadow[i] = 0;
2757 : 0 : wr32(hw, NGBE_UCADDRTBL(i), 0);
2758 : : }
2759 : : }
2760 : :
2761 : : psrctl = rd32(hw, NGBE_PSRCTL);
2762 [ # # ]: 0 : if (on)
2763 : 0 : psrctl |= NGBE_PSRCTL_UCHFENA;
2764 : : else
2765 : 0 : psrctl &= ~NGBE_PSRCTL_UCHFENA;
2766 : :
2767 : 0 : psrctl &= ~NGBE_PSRCTL_ADHF12_MASK;
2768 : 0 : psrctl |= NGBE_PSRCTL_ADHF12(hw->mac.mc_filter_type);
2769 : : wr32(hw, NGBE_PSRCTL, psrctl);
2770 : :
2771 : 0 : return 0;
2772 : : }
2773 : :
2774 : : static int
2775 : 0 : ngbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
2776 : : {
2777 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2778 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
2779 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2780 : : uint32_t mask;
2781 : :
2782 : : mask = rd32(hw, NGBE_IMC(0));
2783 : 0 : mask |= (1 << queue_id);
2784 : : wr32(hw, NGBE_IMC(0), mask);
2785 : 0 : rte_intr_enable(intr_handle);
2786 : :
2787 : 0 : return 0;
2788 : : }
2789 : :
2790 : : static int
2791 : 0 : ngbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
2792 : : {
2793 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2794 : : uint32_t mask;
2795 : :
2796 : : mask = rd32(hw, NGBE_IMS(0));
2797 : 0 : mask |= (1 << queue_id);
2798 : : wr32(hw, NGBE_IMS(0), mask);
2799 : :
2800 : 0 : return 0;
2801 : : }
2802 : :
2803 : : /**
2804 : : * Set the IVAR registers, mapping interrupt causes to vectors
2805 : : * @param hw
2806 : : * pointer to ngbe_hw struct
2807 : : * @direction
2808 : : * 0 for Rx, 1 for Tx, -1 for other causes
2809 : : * @queue
2810 : : * queue to map the corresponding interrupt to
2811 : : * @msix_vector
2812 : : * the vector to map to the corresponding queue
2813 : : */
2814 : : void
2815 : 0 : ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
2816 : : uint8_t queue, uint8_t msix_vector)
2817 : : {
2818 : : uint32_t tmp, idx;
2819 : :
2820 [ # # ]: 0 : if (direction == -1) {
2821 : : /* other causes */
2822 : 0 : msix_vector |= NGBE_IVARMISC_VLD;
2823 : : idx = 0;
2824 : : tmp = rd32(hw, NGBE_IVARMISC);
2825 : 0 : tmp &= ~(0xFF << idx);
2826 : 0 : tmp |= (msix_vector << idx);
2827 : : wr32(hw, NGBE_IVARMISC, tmp);
2828 : : } else {
2829 : : /* rx or tx causes */
2830 : 0 : msix_vector |= NGBE_IVAR_VLD; /* Workaround for ICR lost */
2831 : 0 : idx = ((16 * (queue & 1)) + (8 * direction));
2832 : 0 : tmp = rd32(hw, NGBE_IVAR(queue >> 1));
2833 : 0 : tmp &= ~(0xFF << idx);
2834 : 0 : tmp |= (msix_vector << idx);
2835 : : wr32(hw, NGBE_IVAR(queue >> 1), tmp);
2836 : : }
2837 : 0 : }
2838 : :
2839 : : /**
2840 : : * Sets up the hardware to properly generate MSI-X interrupts
2841 : : * @hw
2842 : : * board private structure
2843 : : */
2844 : : static void
2845 : 0 : ngbe_configure_msix(struct rte_eth_dev *dev)
2846 : : {
2847 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2848 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
2849 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2850 : : uint32_t queue_id, base = NGBE_MISC_VEC_ID;
2851 : : uint32_t vec = NGBE_MISC_VEC_ID;
2852 : : uint32_t gpie;
2853 : :
2854 : : /*
2855 : : * Won't configure MSI-X register if no mapping is done
2856 : : * between intr vector and event fd
2857 : : * but if MSI-X has been enabled already, need to configure
2858 : : * auto clean, auto mask and throttling.
2859 : : */
2860 : : gpie = rd32(hw, NGBE_GPIE);
2861 [ # # ]: 0 : if (!rte_intr_dp_is_en(intr_handle) &&
2862 [ # # ]: 0 : !(gpie & NGBE_GPIE_MSIX))
2863 : : return;
2864 : :
2865 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle)) {
2866 : : base = NGBE_RX_VEC_START;
2867 : : vec = base;
2868 : : }
2869 : :
2870 : : /* setup GPIE for MSI-X mode */
2871 : : gpie = rd32(hw, NGBE_GPIE);
2872 : 0 : gpie |= NGBE_GPIE_MSIX;
2873 : : wr32(hw, NGBE_GPIE, gpie);
2874 : :
2875 : : /* Populate the IVAR table and set the ITR values to the
2876 : : * corresponding register.
2877 : : */
2878 [ # # ]: 0 : if (rte_intr_dp_is_en(intr_handle)) {
2879 [ # # ]: 0 : for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
2880 : 0 : queue_id++) {
2881 : : /* by default, 1:1 mapping */
2882 : 0 : ngbe_set_ivar_map(hw, 0, queue_id, vec);
2883 : 0 : rte_intr_vec_list_index_set(intr_handle,
2884 : : queue_id, vec);
2885 : 0 : if (vec < base + rte_intr_nb_efd_get(intr_handle)
2886 [ # # ]: 0 : - 1)
2887 : 0 : vec++;
2888 : : }
2889 : :
2890 : 0 : ngbe_set_ivar_map(hw, -1, 1, NGBE_MISC_VEC_ID);
2891 : : }
2892 : : wr32(hw, NGBE_ITR(NGBE_MISC_VEC_ID),
2893 : : NGBE_ITR_IVAL_1G(NGBE_QUEUE_ITR_INTERVAL_DEFAULT)
2894 : : | NGBE_ITR_WRDSA);
2895 : : }
2896 : :
2897 : : static u8 *
2898 : 0 : ngbe_dev_addr_list_itr(__rte_unused struct ngbe_hw *hw,
2899 : : u8 **mc_addr_ptr, u32 *vmdq)
2900 : : {
2901 : : u8 *mc_addr;
2902 : :
2903 : 0 : *vmdq = 0;
2904 : 0 : mc_addr = *mc_addr_ptr;
2905 : 0 : *mc_addr_ptr = (mc_addr + sizeof(struct rte_ether_addr));
2906 : 0 : return mc_addr;
2907 : : }
2908 : :
2909 : : int
2910 : 0 : ngbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
2911 : : struct rte_ether_addr *mc_addr_set,
2912 : : uint32_t nb_mc_addr)
2913 : : {
2914 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2915 : : u8 *mc_addr_list;
2916 : :
2917 : : mc_addr_list = (u8 *)mc_addr_set;
2918 : 0 : return hw->mac.update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
2919 : : ngbe_dev_addr_list_itr, TRUE);
2920 : : }
2921 : :
2922 : : static uint64_t
2923 : : ngbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
2924 : : {
2925 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2926 : : uint64_t systime_cycles;
2927 : :
2928 : 0 : systime_cycles = (uint64_t)rd32(hw, NGBE_TSTIMEL);
2929 [ # # ]: 0 : systime_cycles |= (uint64_t)rd32(hw, NGBE_TSTIMEH) << 32;
2930 : :
2931 : : return systime_cycles;
2932 : : }
2933 : :
2934 : : static uint64_t
2935 : : ngbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
2936 : : {
2937 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2938 : : uint64_t rx_tstamp_cycles;
2939 : :
2940 : : /* TSRXSTMPL stores ns and TSRXSTMPH stores seconds. */
2941 : 0 : rx_tstamp_cycles = (uint64_t)rd32(hw, NGBE_TSRXSTMPL);
2942 [ # # ]: 0 : rx_tstamp_cycles |= (uint64_t)rd32(hw, NGBE_TSRXSTMPH) << 32;
2943 : :
2944 : : return rx_tstamp_cycles;
2945 : : }
2946 : :
2947 : : static uint64_t
2948 : : ngbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
2949 : : {
2950 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2951 : : uint64_t tx_tstamp_cycles;
2952 : :
2953 : : /* TSTXSTMPL stores ns and TSTXSTMPH stores seconds. */
2954 : 0 : tx_tstamp_cycles = (uint64_t)rd32(hw, NGBE_TSTXSTMPL);
2955 [ # # ]: 0 : tx_tstamp_cycles |= (uint64_t)rd32(hw, NGBE_TSTXSTMPH) << 32;
2956 : :
2957 : : return tx_tstamp_cycles;
2958 : : }
2959 : :
2960 : : static void
2961 : 0 : ngbe_start_timecounters(struct rte_eth_dev *dev)
2962 : : {
2963 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
2964 : : struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
2965 : : uint32_t incval = 0;
2966 : : uint32_t shift = 0;
2967 : :
2968 : : incval = NGBE_INCVAL_1GB;
2969 : : shift = NGBE_INCVAL_SHIFT_1GB;
2970 : :
2971 : : wr32(hw, NGBE_TSTIMEINC, NGBE_TSTIMEINC_IV(incval));
2972 : :
2973 : 0 : memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
2974 : 0 : memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
2975 : 0 : memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
2976 : :
2977 : 0 : adapter->systime_tc.cc_mask = NGBE_CYCLECOUNTER_MASK;
2978 : 0 : adapter->systime_tc.cc_shift = shift;
2979 : 0 : adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
2980 : :
2981 : 0 : adapter->rx_tstamp_tc.cc_mask = NGBE_CYCLECOUNTER_MASK;
2982 : 0 : adapter->rx_tstamp_tc.cc_shift = shift;
2983 : 0 : adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
2984 : :
2985 : 0 : adapter->tx_tstamp_tc.cc_mask = NGBE_CYCLECOUNTER_MASK;
2986 : 0 : adapter->tx_tstamp_tc.cc_shift = shift;
2987 : 0 : adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
2988 : 0 : }
2989 : :
2990 : : static int
2991 : 0 : ngbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
2992 : : {
2993 : : struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
2994 : :
2995 : 0 : adapter->systime_tc.nsec += delta;
2996 : 0 : adapter->rx_tstamp_tc.nsec += delta;
2997 : 0 : adapter->tx_tstamp_tc.nsec += delta;
2998 : :
2999 : 0 : return 0;
3000 : : }
3001 : :
3002 : : static int
3003 : 0 : ngbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
3004 : : {
3005 : : uint64_t ns;
3006 : : struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
3007 : :
3008 : : ns = rte_timespec_to_ns(ts);
3009 : : /* Set the timecounters to a new value. */
3010 : 0 : adapter->systime_tc.nsec = ns;
3011 : 0 : adapter->rx_tstamp_tc.nsec = ns;
3012 : 0 : adapter->tx_tstamp_tc.nsec = ns;
3013 : :
3014 : 0 : return 0;
3015 : : }
3016 : :
3017 : : static int
3018 : 0 : ngbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
3019 : : {
3020 : : uint64_t ns, systime_cycles;
3021 : : struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
3022 : :
3023 : : systime_cycles = ngbe_read_systime_cyclecounter(dev);
3024 : : ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
3025 : 0 : *ts = rte_ns_to_timespec(ns);
3026 : :
3027 : 0 : return 0;
3028 : : }
3029 : :
3030 : : static int
3031 : 0 : ngbe_timesync_enable(struct rte_eth_dev *dev)
3032 : : {
3033 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
3034 : : uint32_t tsync_ctl;
3035 : :
3036 : : /* Stop the timesync system time. */
3037 : : wr32(hw, NGBE_TSTIMEINC, 0x0);
3038 : : /* Reset the timesync system time value. */
3039 : : wr32(hw, NGBE_TSTIMEL, 0x0);
3040 : : wr32(hw, NGBE_TSTIMEH, 0x0);
3041 : :
3042 : 0 : ngbe_start_timecounters(dev);
3043 : :
3044 : : /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
3045 : : wr32(hw, NGBE_ETFLT(NGBE_ETF_ID_1588),
3046 : : RTE_ETHER_TYPE_1588 | NGBE_ETFLT_ENA | NGBE_ETFLT_1588);
3047 : :
3048 : : /* Enable timestamping of received PTP packets. */
3049 : : tsync_ctl = rd32(hw, NGBE_TSRXCTL);
3050 : 0 : tsync_ctl |= NGBE_TSRXCTL_ENA;
3051 : : wr32(hw, NGBE_TSRXCTL, tsync_ctl);
3052 : :
3053 : : /* Enable timestamping of transmitted PTP packets. */
3054 : : tsync_ctl = rd32(hw, NGBE_TSTXCTL);
3055 : 0 : tsync_ctl |= NGBE_TSTXCTL_ENA;
3056 : : wr32(hw, NGBE_TSTXCTL, tsync_ctl);
3057 : :
3058 : : ngbe_flush(hw);
3059 : :
3060 : 0 : return 0;
3061 : : }
3062 : :
3063 : : static int
3064 : 0 : ngbe_timesync_disable(struct rte_eth_dev *dev)
3065 : : {
3066 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
3067 : : uint32_t tsync_ctl;
3068 : :
3069 : : /* Disable timestamping of transmitted PTP packets. */
3070 : : tsync_ctl = rd32(hw, NGBE_TSTXCTL);
3071 : 0 : tsync_ctl &= ~NGBE_TSTXCTL_ENA;
3072 : : wr32(hw, NGBE_TSTXCTL, tsync_ctl);
3073 : :
3074 : : /* Disable timestamping of received PTP packets. */
3075 : : tsync_ctl = rd32(hw, NGBE_TSRXCTL);
3076 : 0 : tsync_ctl &= ~NGBE_TSRXCTL_ENA;
3077 : : wr32(hw, NGBE_TSRXCTL, tsync_ctl);
3078 : :
3079 : : /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
3080 : : wr32(hw, NGBE_ETFLT(NGBE_ETF_ID_1588), 0);
3081 : :
3082 : : /* Stop incrementing the System Time registers. */
3083 : : wr32(hw, NGBE_TSTIMEINC, 0);
3084 : :
3085 : 0 : return 0;
3086 : : }
3087 : :
3088 : : static int
3089 : 0 : ngbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
3090 : : struct timespec *timestamp,
3091 : : uint32_t flags __rte_unused)
3092 : : {
3093 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
3094 : : struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
3095 : : uint32_t tsync_rxctl;
3096 : : uint64_t rx_tstamp_cycles;
3097 : : uint64_t ns;
3098 : :
3099 : : tsync_rxctl = rd32(hw, NGBE_TSRXCTL);
3100 [ # # ]: 0 : if ((tsync_rxctl & NGBE_TSRXCTL_VLD) == 0)
3101 : : return -EINVAL;
3102 : :
3103 : : rx_tstamp_cycles = ngbe_read_rx_tstamp_cyclecounter(dev);
3104 : : ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
3105 : 0 : *timestamp = rte_ns_to_timespec(ns);
3106 : :
3107 : 0 : return 0;
3108 : : }
3109 : :
3110 : : static int
3111 : 0 : ngbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
3112 : : struct timespec *timestamp)
3113 : : {
3114 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
3115 : : struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
3116 : : uint32_t tsync_txctl;
3117 : : uint64_t tx_tstamp_cycles;
3118 : : uint64_t ns;
3119 : :
3120 : : tsync_txctl = rd32(hw, NGBE_TSTXCTL);
3121 [ # # ]: 0 : if ((tsync_txctl & NGBE_TSTXCTL_VLD) == 0)
3122 : : return -EINVAL;
3123 : :
3124 : : tx_tstamp_cycles = ngbe_read_tx_tstamp_cyclecounter(dev);
3125 : : ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
3126 : 0 : *timestamp = rte_ns_to_timespec(ns);
3127 : :
3128 : 0 : return 0;
3129 : : }
3130 : :
3131 : : static int
3132 : : ngbe_get_reg_length(struct rte_eth_dev *dev __rte_unused)
3133 : : {
3134 : : int count = 0;
3135 : : int g_ind = 0;
3136 : : const struct reg_info *reg_group;
3137 : : const struct reg_info **reg_set = ngbe_regs_others;
3138 : :
3139 [ # # # # ]: 0 : while ((reg_group = reg_set[g_ind++]))
3140 : 0 : count += ngbe_regs_group_count(reg_group);
3141 : :
3142 : : return count;
3143 : : }
3144 : :
3145 : : static int
3146 [ # # ]: 0 : ngbe_get_regs(struct rte_eth_dev *dev,
3147 : : struct rte_dev_reg_info *regs)
3148 : : {
3149 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
3150 : 0 : uint32_t *data = regs->data;
3151 : : int g_ind = 0;
3152 : : int count = 0;
3153 : : const struct reg_info *reg_group;
3154 : : const struct reg_info **reg_set = ngbe_regs_others;
3155 : :
3156 [ # # ]: 0 : if (data == NULL) {
3157 : 0 : regs->length = ngbe_get_reg_length(dev);
3158 : 0 : regs->width = sizeof(uint32_t);
3159 : 0 : return 0;
3160 : : }
3161 : :
3162 : : /* Support only full register dump */
3163 [ # # ]: 0 : if (regs->length == 0 ||
3164 [ # # ]: 0 : regs->length == (uint32_t)ngbe_get_reg_length(dev)) {
3165 : 0 : regs->version = hw->mac.type << 24 |
3166 : 0 : hw->revision_id << 16 |
3167 : 0 : hw->device_id;
3168 [ # # ]: 0 : while ((reg_group = reg_set[g_ind++]))
3169 : 0 : count += ngbe_read_regs_group(dev, &data[count],
3170 : : reg_group);
3171 : : return 0;
3172 : : }
3173 : :
3174 : : return -ENOTSUP;
3175 : : }
3176 : :
3177 : : static int
3178 : 0 : ngbe_get_eeprom_length(struct rte_eth_dev *dev)
3179 : : {
3180 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
3181 : :
3182 : : /* Return unit is byte count */
3183 : 0 : return hw->rom.word_size * 2;
3184 : : }
3185 : :
3186 : : static int
3187 [ # # ]: 0 : ngbe_get_eeprom(struct rte_eth_dev *dev,
3188 : : struct rte_dev_eeprom_info *in_eeprom)
3189 : : {
3190 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
3191 : : struct ngbe_rom_info *eeprom = &hw->rom;
3192 : 0 : uint16_t *data = in_eeprom->data;
3193 : : int first, length;
3194 : :
3195 : 0 : first = in_eeprom->offset >> 1;
3196 : 0 : length = in_eeprom->length >> 1;
3197 [ # # ]: 0 : if (first > hw->rom.word_size ||
3198 [ # # ]: 0 : ((first + length) > hw->rom.word_size))
3199 : : return -EINVAL;
3200 : :
3201 : 0 : in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
3202 : :
3203 : 0 : return eeprom->readw_buffer(hw, first, length, data);
3204 : : }
3205 : :
3206 : : static int
3207 [ # # ]: 0 : ngbe_set_eeprom(struct rte_eth_dev *dev,
3208 : : struct rte_dev_eeprom_info *in_eeprom)
3209 : : {
3210 : : struct ngbe_hw *hw = ngbe_dev_hw(dev);
3211 : : struct ngbe_rom_info *eeprom = &hw->rom;
3212 : 0 : uint16_t *data = in_eeprom->data;
3213 : : int first, length;
3214 : :
3215 : 0 : first = in_eeprom->offset >> 1;
3216 : 0 : length = in_eeprom->length >> 1;
3217 [ # # ]: 0 : if (first > hw->rom.word_size ||
3218 [ # # ]: 0 : ((first + length) > hw->rom.word_size))
3219 : : return -EINVAL;
3220 : :
3221 : 0 : in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
3222 : :
3223 : 0 : return eeprom->writew_buffer(hw, first, length, data);
3224 : : }
3225 : :
3226 : : static const struct eth_dev_ops ngbe_eth_dev_ops = {
3227 : : .dev_configure = ngbe_dev_configure,
3228 : : .dev_infos_get = ngbe_dev_info_get,
3229 : : .dev_start = ngbe_dev_start,
3230 : : .dev_stop = ngbe_dev_stop,
3231 : : .dev_set_link_up = ngbe_dev_set_link_up,
3232 : : .dev_set_link_down = ngbe_dev_set_link_down,
3233 : : .dev_close = ngbe_dev_close,
3234 : : .dev_reset = ngbe_dev_reset,
3235 : : .promiscuous_enable = ngbe_dev_promiscuous_enable,
3236 : : .promiscuous_disable = ngbe_dev_promiscuous_disable,
3237 : : .allmulticast_enable = ngbe_dev_allmulticast_enable,
3238 : : .allmulticast_disable = ngbe_dev_allmulticast_disable,
3239 : : .link_update = ngbe_dev_link_update,
3240 : : .stats_get = ngbe_dev_stats_get,
3241 : : .xstats_get = ngbe_dev_xstats_get,
3242 : : .xstats_get_by_id = ngbe_dev_xstats_get_by_id,
3243 : : .stats_reset = ngbe_dev_stats_reset,
3244 : : .xstats_reset = ngbe_dev_xstats_reset,
3245 : : .xstats_get_names = ngbe_dev_xstats_get_names,
3246 : : .xstats_get_names_by_id = ngbe_dev_xstats_get_names_by_id,
3247 : : .fw_version_get = ngbe_fw_version_get,
3248 : : .dev_supported_ptypes_get = ngbe_dev_supported_ptypes_get,
3249 : : .mtu_set = ngbe_dev_mtu_set,
3250 : : .vlan_filter_set = ngbe_vlan_filter_set,
3251 : : .vlan_tpid_set = ngbe_vlan_tpid_set,
3252 : : .vlan_offload_set = ngbe_vlan_offload_set,
3253 : : .vlan_strip_queue_set = ngbe_vlan_strip_queue_set,
3254 : : .rx_queue_start = ngbe_dev_rx_queue_start,
3255 : : .rx_queue_stop = ngbe_dev_rx_queue_stop,
3256 : : .tx_queue_start = ngbe_dev_tx_queue_start,
3257 : : .tx_queue_stop = ngbe_dev_tx_queue_stop,
3258 : : .rx_queue_setup = ngbe_dev_rx_queue_setup,
3259 : : .rx_queue_release = ngbe_dev_rx_queue_release,
3260 : : .tx_queue_setup = ngbe_dev_tx_queue_setup,
3261 : : .tx_queue_release = ngbe_dev_tx_queue_release,
3262 : : .rx_queue_intr_enable = ngbe_dev_rx_queue_intr_enable,
3263 : : .rx_queue_intr_disable = ngbe_dev_rx_queue_intr_disable,
3264 : : .dev_led_on = ngbe_dev_led_on,
3265 : : .dev_led_off = ngbe_dev_led_off,
3266 : : .flow_ctrl_get = ngbe_flow_ctrl_get,
3267 : : .flow_ctrl_set = ngbe_flow_ctrl_set,
3268 : : .mac_addr_add = ngbe_add_rar,
3269 : : .mac_addr_remove = ngbe_remove_rar,
3270 : : .mac_addr_set = ngbe_set_default_mac_addr,
3271 : : .uc_hash_table_set = ngbe_uc_hash_table_set,
3272 : : .uc_all_hash_table_set = ngbe_uc_all_hash_table_set,
3273 : : .reta_update = ngbe_dev_rss_reta_update,
3274 : : .reta_query = ngbe_dev_rss_reta_query,
3275 : : .rss_hash_update = ngbe_dev_rss_hash_update,
3276 : : .rss_hash_conf_get = ngbe_dev_rss_hash_conf_get,
3277 : : .set_mc_addr_list = ngbe_dev_set_mc_addr_list,
3278 : : .rxq_info_get = ngbe_rxq_info_get,
3279 : : .txq_info_get = ngbe_txq_info_get,
3280 : : .rx_burst_mode_get = ngbe_rx_burst_mode_get,
3281 : : .tx_burst_mode_get = ngbe_tx_burst_mode_get,
3282 : : .timesync_enable = ngbe_timesync_enable,
3283 : : .timesync_disable = ngbe_timesync_disable,
3284 : : .timesync_read_rx_timestamp = ngbe_timesync_read_rx_timestamp,
3285 : : .timesync_read_tx_timestamp = ngbe_timesync_read_tx_timestamp,
3286 : : .get_reg = ngbe_get_regs,
3287 : : .get_eeprom_length = ngbe_get_eeprom_length,
3288 : : .get_eeprom = ngbe_get_eeprom,
3289 : : .set_eeprom = ngbe_set_eeprom,
3290 : : .timesync_adjust_time = ngbe_timesync_adjust_time,
3291 : : .timesync_read_time = ngbe_timesync_read_time,
3292 : : .timesync_write_time = ngbe_timesync_write_time,
3293 : : .tx_done_cleanup = ngbe_dev_tx_done_cleanup,
3294 : : };
3295 : :
3296 : 302 : RTE_PMD_REGISTER_PCI(net_ngbe, rte_ngbe_pmd);
3297 : : RTE_PMD_REGISTER_PCI_TABLE(net_ngbe, pci_id_ngbe_map);
3298 : : RTE_PMD_REGISTER_KMOD_DEP(net_ngbe, "* igb_uio | uio_pci_generic | vfio-pci");
3299 : :
3300 [ - + ]: 302 : RTE_LOG_REGISTER_SUFFIX(ngbe_logtype_init, init, NOTICE);
3301 [ - + ]: 302 : RTE_LOG_REGISTER_SUFFIX(ngbe_logtype_driver, driver, NOTICE);
3302 : :
3303 : : #ifdef RTE_ETHDEV_DEBUG_RX
3304 : : RTE_LOG_REGISTER_SUFFIX(ngbe_logtype_rx, rx, DEBUG);
3305 : : #endif
3306 : : #ifdef RTE_ETHDEV_DEBUG_TX
3307 : : RTE_LOG_REGISTER_SUFFIX(ngbe_logtype_tx, tx, DEBUG);
3308 : : #endif
|