1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
3 * Copyright (c) 2015-2018 Cavium Inc.
9 #include "bnx2x_rxtx.h"
12 #include <rte_ethdev_pci.h>
13 #include <rte_alarm.h>
15 int bnx2x_logtype_init;
16 int bnx2x_logtype_driver;
19 * The set of PCI devices this driver supports
21 #define BROADCOM_PCI_VENDOR_ID 0x14E4
22 static const struct rte_pci_id pci_id_bnx2x_map[] = {
23 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800) },
24 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57711) },
25 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810) },
26 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811) },
27 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_OBS) },
28 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_4_10) },
29 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_2_20) },
30 #ifdef RTE_LIBRTE_BNX2X_MF_SUPPORT
31 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_MF) },
32 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_MF) },
33 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_MF) },
38 static const struct rte_pci_id pci_id_bnx2xvf_map[] = {
39 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800_VF) },
40 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_VF) },
41 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_VF) },
42 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_VF) },
46 struct rte_bnx2x_xstats_name_off {
47 char name[RTE_ETH_XSTATS_NAME_SIZE];
52 static const struct rte_bnx2x_xstats_name_off bnx2x_xstats_strings[] = {
54 offsetof(struct bnx2x_eth_stats, brb_drop_hi),
55 offsetof(struct bnx2x_eth_stats, brb_drop_lo)},
56 {"rx_buffer_truncates",
57 offsetof(struct bnx2x_eth_stats, brb_truncate_hi),
58 offsetof(struct bnx2x_eth_stats, brb_truncate_lo)},
59 {"rx_buffer_truncate_discard",
60 offsetof(struct bnx2x_eth_stats, brb_truncate_discard),
61 offsetof(struct bnx2x_eth_stats, brb_truncate_discard)},
62 {"mac_filter_discard",
63 offsetof(struct bnx2x_eth_stats, mac_filter_discard),
64 offsetof(struct bnx2x_eth_stats, mac_filter_discard)},
65 {"no_match_vlan_tag_discard",
66 offsetof(struct bnx2x_eth_stats, mf_tag_discard),
67 offsetof(struct bnx2x_eth_stats, mf_tag_discard)},
69 offsetof(struct bnx2x_eth_stats, pause_frames_sent_hi),
70 offsetof(struct bnx2x_eth_stats, pause_frames_sent_lo)},
72 offsetof(struct bnx2x_eth_stats, pause_frames_received_hi),
73 offsetof(struct bnx2x_eth_stats, pause_frames_received_lo)},
74 {"tx_priority_flow_control",
75 offsetof(struct bnx2x_eth_stats, pfc_frames_sent_hi),
76 offsetof(struct bnx2x_eth_stats, pfc_frames_sent_lo)},
77 {"rx_priority_flow_control",
78 offsetof(struct bnx2x_eth_stats, pfc_frames_received_hi),
79 offsetof(struct bnx2x_eth_stats, pfc_frames_received_lo)}
83 bnx2x_link_update(struct rte_eth_dev *dev)
85 struct bnx2x_softc *sc = dev->data->dev_private;
86 struct rte_eth_link link;
88 PMD_INIT_FUNC_TRACE(sc);
90 bnx2x_link_status_update(sc);
91 memset(&link, 0, sizeof(link));
93 link.link_speed = sc->link_vars.line_speed;
94 switch (sc->link_vars.duplex) {
96 link.link_duplex = ETH_LINK_FULL_DUPLEX;
99 link.link_duplex = ETH_LINK_HALF_DUPLEX;
102 link.link_autoneg = !(dev->data->dev_conf.link_speeds &
103 ETH_LINK_SPEED_FIXED);
104 link.link_status = sc->link_vars.link_up;
106 return rte_eth_linkstatus_set(dev, &link);
110 bnx2x_interrupt_action(struct rte_eth_dev *dev, int intr_cxt)
112 struct bnx2x_softc *sc = dev->data->dev_private;
113 uint32_t link_status;
115 bnx2x_intr_legacy(sc);
117 if ((atomic_load_acq_long(&sc->periodic_flags) == PERIODIC_GO) &&
119 bnx2x_periodic_callout(sc);
120 link_status = REG_RD(sc, sc->link_params.shmem_base +
121 offsetof(struct shmem_region,
122 port_mb[sc->link_params.port].link_status));
123 if ((link_status & LINK_STATUS_LINK_UP) != dev->data->dev_link.link_status)
124 bnx2x_link_update(dev);
128 bnx2x_interrupt_handler(void *param)
130 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
131 struct bnx2x_softc *sc = dev->data->dev_private;
133 PMD_DEBUG_PERIODIC_LOG(INFO, sc, "Interrupt handled");
135 bnx2x_interrupt_action(dev, 1);
136 rte_intr_enable(&sc->pci_dev->intr_handle);
139 static void bnx2x_periodic_start(void *param)
141 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
142 struct bnx2x_softc *sc = dev->data->dev_private;
145 atomic_store_rel_long(&sc->periodic_flags, PERIODIC_GO);
146 bnx2x_interrupt_action(dev, 0);
148 ret = rte_eal_alarm_set(BNX2X_SP_TIMER_PERIOD,
149 bnx2x_periodic_start, (void *)dev);
151 PMD_DRV_LOG(ERR, sc, "Unable to start periodic"
152 " timer rc %d", ret);
153 assert(false && "Unable to start periodic timer");
158 void bnx2x_periodic_stop(void *param)
160 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
161 struct bnx2x_softc *sc = dev->data->dev_private;
163 atomic_store_rel_long(&sc->periodic_flags, PERIODIC_STOP);
165 rte_eal_alarm_cancel(bnx2x_periodic_start, (void *)dev);
167 PMD_DRV_LOG(DEBUG, sc, "Periodic poll stopped");
171 * Devops - helper functions can be called from user application
175 bnx2x_dev_configure(struct rte_eth_dev *dev)
177 struct bnx2x_softc *sc = dev->data->dev_private;
178 struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
180 int mp_ncpus = sysconf(_SC_NPROCESSORS_CONF);
182 PMD_INIT_FUNC_TRACE(sc);
184 if (rxmode->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
185 sc->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len;
186 dev->data->mtu = sc->mtu;
189 if (dev->data->nb_tx_queues > dev->data->nb_rx_queues) {
190 PMD_DRV_LOG(ERR, sc, "The number of TX queues is greater than number of RX queues");
194 sc->num_queues = MAX(dev->data->nb_rx_queues, dev->data->nb_tx_queues);
195 if (sc->num_queues > mp_ncpus) {
196 PMD_DRV_LOG(ERR, sc, "The number of queues is more than number of CPUs");
200 PMD_DRV_LOG(DEBUG, sc, "num_queues=%d, mtu=%d",
201 sc->num_queues, sc->mtu);
204 if (bnx2x_alloc_ilt_mem(sc) != 0) {
205 PMD_DRV_LOG(ERR, sc, "bnx2x_alloc_ilt_mem was failed");
209 /* allocate the host hardware/software hsi structures */
210 if (bnx2x_alloc_hsi_mem(sc) != 0) {
211 PMD_DRV_LOG(ERR, sc, "bnx2x_alloc_hsi_mem was failed");
212 bnx2x_free_ilt_mem(sc);
216 bnx2x_dev_rxtx_init_dummy(dev);
221 bnx2x_dev_start(struct rte_eth_dev *dev)
223 struct bnx2x_softc *sc = dev->data->dev_private;
226 PMD_INIT_FUNC_TRACE(sc);
228 /* start the periodic callout */
229 if (atomic_load_acq_long(&sc->periodic_flags) == PERIODIC_STOP) {
230 bnx2x_periodic_start(dev);
231 PMD_DRV_LOG(DEBUG, sc, "Periodic poll re-started");
234 ret = bnx2x_init(sc);
236 PMD_DRV_LOG(DEBUG, sc, "bnx2x_init failed (%d)", ret);
241 rte_intr_callback_register(&sc->pci_dev->intr_handle,
242 bnx2x_interrupt_handler, (void *)dev);
244 if (rte_intr_enable(&sc->pci_dev->intr_handle))
245 PMD_DRV_LOG(ERR, sc, "rte_intr_enable failed");
248 bnx2x_dev_rxtx_init(dev);
250 bnx2x_print_device_info(sc);
256 bnx2x_dev_stop(struct rte_eth_dev *dev)
258 struct bnx2x_softc *sc = dev->data->dev_private;
261 PMD_INIT_FUNC_TRACE(sc);
263 bnx2x_dev_rxtx_init_dummy(dev);
266 rte_intr_disable(&sc->pci_dev->intr_handle);
267 rte_intr_callback_unregister(&sc->pci_dev->intr_handle,
268 bnx2x_interrupt_handler, (void *)dev);
271 /* stop the periodic callout */
272 bnx2x_periodic_stop(dev);
274 ret = bnx2x_nic_unload(sc, UNLOAD_NORMAL, FALSE);
276 PMD_DRV_LOG(DEBUG, sc, "bnx2x_nic_unload failed (%d)", ret);
284 bnx2x_dev_close(struct rte_eth_dev *dev)
286 struct bnx2x_softc *sc = dev->data->dev_private;
288 PMD_INIT_FUNC_TRACE(sc);
293 bnx2x_dev_clear_queues(dev);
294 memset(&(dev->data->dev_link), 0 , sizeof(struct rte_eth_link));
296 /* free the host hardware/software hsi structures */
297 bnx2x_free_hsi_mem(sc);
300 bnx2x_free_ilt_mem(sc);
304 bnx2x_promisc_enable(struct rte_eth_dev *dev)
306 struct bnx2x_softc *sc = dev->data->dev_private;
308 PMD_INIT_FUNC_TRACE(sc);
309 sc->rx_mode = BNX2X_RX_MODE_PROMISC;
310 if (rte_eth_allmulticast_get(dev->data->port_id) == 1)
311 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI_PROMISC;
312 bnx2x_set_rx_mode(sc);
316 bnx2x_promisc_disable(struct rte_eth_dev *dev)
318 struct bnx2x_softc *sc = dev->data->dev_private;
320 PMD_INIT_FUNC_TRACE(sc);
321 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
322 if (rte_eth_allmulticast_get(dev->data->port_id) == 1)
323 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI;
324 bnx2x_set_rx_mode(sc);
328 bnx2x_dev_allmulticast_enable(struct rte_eth_dev *dev)
330 struct bnx2x_softc *sc = dev->data->dev_private;
332 PMD_INIT_FUNC_TRACE(sc);
333 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI;
334 if (rte_eth_promiscuous_get(dev->data->port_id) == 1)
335 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI_PROMISC;
336 bnx2x_set_rx_mode(sc);
340 bnx2x_dev_allmulticast_disable(struct rte_eth_dev *dev)
342 struct bnx2x_softc *sc = dev->data->dev_private;
344 PMD_INIT_FUNC_TRACE(sc);
345 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
346 if (rte_eth_promiscuous_get(dev->data->port_id) == 1)
347 sc->rx_mode = BNX2X_RX_MODE_PROMISC;
348 bnx2x_set_rx_mode(sc);
352 bnx2x_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
354 struct bnx2x_softc *sc = dev->data->dev_private;
356 PMD_INIT_FUNC_TRACE(sc);
358 return bnx2x_link_update(dev);
362 bnx2xvf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
364 struct bnx2x_softc *sc = dev->data->dev_private;
367 ret = bnx2x_link_update(dev);
369 bnx2x_check_bull(sc);
370 if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) {
371 PMD_DRV_LOG(ERR, sc, "PF indicated channel is down."
372 "VF device is no longer operational");
373 dev->data->dev_link.link_status = ETH_LINK_DOWN;
380 bnx2x_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
382 struct bnx2x_softc *sc = dev->data->dev_private;
383 uint32_t brb_truncate_discard;
385 uint64_t brb_truncates;
387 PMD_INIT_FUNC_TRACE(sc);
389 bnx2x_stats_handle(sc, STATS_EVENT_UPDATE);
391 memset(stats, 0, sizeof (struct rte_eth_stats));
394 HILO_U64(sc->eth_stats.total_unicast_packets_received_hi,
395 sc->eth_stats.total_unicast_packets_received_lo) +
396 HILO_U64(sc->eth_stats.total_multicast_packets_received_hi,
397 sc->eth_stats.total_multicast_packets_received_lo) +
398 HILO_U64(sc->eth_stats.total_broadcast_packets_received_hi,
399 sc->eth_stats.total_broadcast_packets_received_lo);
402 HILO_U64(sc->eth_stats.total_unicast_packets_transmitted_hi,
403 sc->eth_stats.total_unicast_packets_transmitted_lo) +
404 HILO_U64(sc->eth_stats.total_multicast_packets_transmitted_hi,
405 sc->eth_stats.total_multicast_packets_transmitted_lo) +
406 HILO_U64(sc->eth_stats.total_broadcast_packets_transmitted_hi,
407 sc->eth_stats.total_broadcast_packets_transmitted_lo);
410 HILO_U64(sc->eth_stats.total_bytes_received_hi,
411 sc->eth_stats.total_bytes_received_lo);
414 HILO_U64(sc->eth_stats.total_bytes_transmitted_hi,
415 sc->eth_stats.total_bytes_transmitted_lo);
418 HILO_U64(sc->eth_stats.error_bytes_received_hi,
419 sc->eth_stats.error_bytes_received_lo);
424 HILO_U64(sc->eth_stats.no_buff_discard_hi,
425 sc->eth_stats.no_buff_discard_lo);
428 HILO_U64(sc->eth_stats.brb_drop_hi,
429 sc->eth_stats.brb_drop_lo);
432 HILO_U64(sc->eth_stats.brb_truncate_hi,
433 sc->eth_stats.brb_truncate_lo);
435 brb_truncate_discard = sc->eth_stats.brb_truncate_discard;
437 stats->imissed = brb_drops + brb_truncates +
438 brb_truncate_discard + stats->rx_nombuf;
444 bnx2x_get_xstats_names(__rte_unused struct rte_eth_dev *dev,
445 struct rte_eth_xstat_name *xstats_names,
446 __rte_unused unsigned limit)
448 unsigned int i, stat_cnt = RTE_DIM(bnx2x_xstats_strings);
450 if (xstats_names != NULL)
451 for (i = 0; i < stat_cnt; i++)
452 snprintf(xstats_names[i].name,
453 sizeof(xstats_names[i].name),
455 bnx2x_xstats_strings[i].name);
461 bnx2x_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
464 struct bnx2x_softc *sc = dev->data->dev_private;
465 unsigned int num = RTE_DIM(bnx2x_xstats_strings);
470 bnx2x_stats_handle(sc, STATS_EVENT_UPDATE);
472 for (num = 0; num < n; num++) {
473 if (bnx2x_xstats_strings[num].offset_hi !=
474 bnx2x_xstats_strings[num].offset_lo)
475 xstats[num].value = HILO_U64(
476 *(uint32_t *)((char *)&sc->eth_stats +
477 bnx2x_xstats_strings[num].offset_hi),
478 *(uint32_t *)((char *)&sc->eth_stats +
479 bnx2x_xstats_strings[num].offset_lo));
482 *(uint64_t *)((char *)&sc->eth_stats +
483 bnx2x_xstats_strings[num].offset_lo);
484 xstats[num].id = num;
491 bnx2x_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
493 struct bnx2x_softc *sc = dev->data->dev_private;
494 dev_info->max_rx_queues = sc->max_rx_queues;
495 dev_info->max_tx_queues = sc->max_tx_queues;
496 dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
497 dev_info->max_rx_pktlen = BNX2X_MAX_RX_PKT_LEN;
498 dev_info->max_mac_addrs = BNX2X_MAX_MAC_ADDRS;
499 dev_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_20G;
500 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
504 bnx2x_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
505 uint32_t index, uint32_t pool)
507 struct bnx2x_softc *sc = dev->data->dev_private;
509 if (sc->mac_ops.mac_addr_add) {
510 sc->mac_ops.mac_addr_add(dev, mac_addr, index, pool);
517 bnx2x_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
519 struct bnx2x_softc *sc = dev->data->dev_private;
521 if (sc->mac_ops.mac_addr_remove)
522 sc->mac_ops.mac_addr_remove(dev, index);
525 static const struct eth_dev_ops bnx2x_eth_dev_ops = {
526 .dev_configure = bnx2x_dev_configure,
527 .dev_start = bnx2x_dev_start,
528 .dev_stop = bnx2x_dev_stop,
529 .dev_close = bnx2x_dev_close,
530 .promiscuous_enable = bnx2x_promisc_enable,
531 .promiscuous_disable = bnx2x_promisc_disable,
532 .allmulticast_enable = bnx2x_dev_allmulticast_enable,
533 .allmulticast_disable = bnx2x_dev_allmulticast_disable,
534 .link_update = bnx2x_dev_link_update,
535 .stats_get = bnx2x_dev_stats_get,
536 .xstats_get = bnx2x_dev_xstats_get,
537 .xstats_get_names = bnx2x_get_xstats_names,
538 .dev_infos_get = bnx2x_dev_infos_get,
539 .rx_queue_setup = bnx2x_dev_rx_queue_setup,
540 .rx_queue_release = bnx2x_dev_rx_queue_release,
541 .tx_queue_setup = bnx2x_dev_tx_queue_setup,
542 .tx_queue_release = bnx2x_dev_tx_queue_release,
543 .mac_addr_add = bnx2x_mac_addr_add,
544 .mac_addr_remove = bnx2x_mac_addr_remove,
548 * dev_ops for virtual function
550 static const struct eth_dev_ops bnx2xvf_eth_dev_ops = {
551 .dev_configure = bnx2x_dev_configure,
552 .dev_start = bnx2x_dev_start,
553 .dev_stop = bnx2x_dev_stop,
554 .dev_close = bnx2x_dev_close,
555 .promiscuous_enable = bnx2x_promisc_enable,
556 .promiscuous_disable = bnx2x_promisc_disable,
557 .allmulticast_enable = bnx2x_dev_allmulticast_enable,
558 .allmulticast_disable = bnx2x_dev_allmulticast_disable,
559 .link_update = bnx2xvf_dev_link_update,
560 .stats_get = bnx2x_dev_stats_get,
561 .xstats_get = bnx2x_dev_xstats_get,
562 .xstats_get_names = bnx2x_get_xstats_names,
563 .dev_infos_get = bnx2x_dev_infos_get,
564 .rx_queue_setup = bnx2x_dev_rx_queue_setup,
565 .rx_queue_release = bnx2x_dev_rx_queue_release,
566 .tx_queue_setup = bnx2x_dev_tx_queue_setup,
567 .tx_queue_release = bnx2x_dev_tx_queue_release,
568 .mac_addr_add = bnx2x_mac_addr_add,
569 .mac_addr_remove = bnx2x_mac_addr_remove,
574 bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
577 struct rte_pci_device *pci_dev;
578 struct rte_pci_addr pci_addr;
579 struct bnx2x_softc *sc;
580 static bool adapter_info = true;
582 /* Extract key data structures */
583 sc = eth_dev->data->dev_private;
584 pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
585 pci_addr = pci_dev->addr;
587 snprintf(sc->devinfo.name, NAME_SIZE, PCI_SHORT_PRI_FMT ":dpdk-port-%u",
588 pci_addr.bus, pci_addr.devid, pci_addr.function,
589 eth_dev->data->port_id);
591 PMD_INIT_FUNC_TRACE(sc);
593 eth_dev->dev_ops = is_vf ? &bnx2xvf_eth_dev_ops : &bnx2x_eth_dev_ops;
595 rte_eth_copy_pci_info(eth_dev, pci_dev);
597 sc->pcie_bus = pci_dev->addr.bus;
598 sc->pcie_device = pci_dev->addr.devid;
600 sc->devinfo.vendor_id = pci_dev->id.vendor_id;
601 sc->devinfo.device_id = pci_dev->id.device_id;
602 sc->devinfo.subvendor_id = pci_dev->id.subsystem_vendor_id;
603 sc->devinfo.subdevice_id = pci_dev->id.subsystem_device_id;
606 sc->flags = BNX2X_IS_VF_FLAG;
608 sc->pcie_func = pci_dev->addr.function;
609 sc->bar[BAR0].base_addr = (void *)pci_dev->mem_resource[0].addr;
611 sc->bar[BAR1].base_addr = (void *)
612 ((uintptr_t)pci_dev->mem_resource[0].addr + PXP_VF_ADDR_DB_START);
614 sc->bar[BAR1].base_addr = pci_dev->mem_resource[2].addr;
616 assert(sc->bar[BAR0].base_addr);
617 assert(sc->bar[BAR1].base_addr);
619 bnx2x_load_firmware(sc);
620 assert(sc->firmware);
622 if (eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
625 sc->rx_budget = BNX2X_RX_BUDGET;
626 sc->hc_rx_ticks = BNX2X_RX_TICKS;
627 sc->hc_tx_ticks = BNX2X_TX_TICKS;
629 sc->interrupt_mode = INTR_MODE_SINGLE_MSIX;
630 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
632 sc->pci_dev = pci_dev;
633 ret = bnx2x_attach(sc);
635 PMD_DRV_LOG(ERR, sc, "bnx2x_attach failed (%d)", ret);
639 /* Print important adapter info for the user. */
641 bnx2x_print_adapter_info(sc);
642 adapter_info = false;
645 /* schedule periodic poll for slowpath link events */
647 PMD_DRV_LOG(DEBUG, sc, "Scheduling periodic poll for slowpath link events");
648 ret = rte_eal_alarm_set(BNX2X_SP_TIMER_PERIOD,
649 bnx2x_periodic_start, (void *)eth_dev);
651 PMD_DRV_LOG(ERR, sc, "Unable to start periodic"
652 " timer rc %d", ret);
657 eth_dev->data->mac_addrs = (struct ether_addr *)sc->link_params.mac_addr;
660 rte_spinlock_init(&sc->vf2pf_lock);
662 ret = bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_mbx_msg),
663 &sc->vf2pf_mbox_mapping, "vf2pf_mbox",
664 RTE_CACHE_LINE_SIZE);
668 sc->vf2pf_mbox = (struct bnx2x_vf_mbx_msg *)
669 sc->vf2pf_mbox_mapping.vaddr;
671 ret = bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_bulletin),
672 &sc->pf2vf_bulletin_mapping, "vf2pf_bull",
673 RTE_CACHE_LINE_SIZE);
677 sc->pf2vf_bulletin = (struct bnx2x_vf_bulletin *)
678 sc->pf2vf_bulletin_mapping.vaddr;
680 ret = bnx2x_vf_get_resources(sc, sc->max_tx_queues,
689 bnx2x_periodic_stop(eth_dev);
694 eth_bnx2x_dev_init(struct rte_eth_dev *eth_dev)
696 struct bnx2x_softc *sc = eth_dev->data->dev_private;
697 PMD_INIT_FUNC_TRACE(sc);
698 return bnx2x_common_dev_init(eth_dev, 0);
702 eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev)
704 struct bnx2x_softc *sc = eth_dev->data->dev_private;
705 PMD_INIT_FUNC_TRACE(sc);
706 return bnx2x_common_dev_init(eth_dev, 1);
709 static struct rte_pci_driver rte_bnx2x_pmd;
710 static struct rte_pci_driver rte_bnx2xvf_pmd;
712 static int eth_bnx2x_pci_probe(struct rte_pci_driver *pci_drv,
713 struct rte_pci_device *pci_dev)
715 if (pci_drv == &rte_bnx2x_pmd)
716 return rte_eth_dev_pci_generic_probe(pci_dev,
717 sizeof(struct bnx2x_softc), eth_bnx2x_dev_init);
718 else if (pci_drv == &rte_bnx2xvf_pmd)
719 return rte_eth_dev_pci_generic_probe(pci_dev,
720 sizeof(struct bnx2x_softc), eth_bnx2xvf_dev_init);
725 static int eth_bnx2x_pci_remove(struct rte_pci_device *pci_dev)
727 return rte_eth_dev_pci_generic_remove(pci_dev, NULL);
730 static struct rte_pci_driver rte_bnx2x_pmd = {
731 .id_table = pci_id_bnx2x_map,
732 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
733 .probe = eth_bnx2x_pci_probe,
734 .remove = eth_bnx2x_pci_remove,
738 * virtual function driver struct
740 static struct rte_pci_driver rte_bnx2xvf_pmd = {
741 .id_table = pci_id_bnx2xvf_map,
742 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
743 .probe = eth_bnx2x_pci_probe,
744 .remove = eth_bnx2x_pci_remove,
747 RTE_PMD_REGISTER_PCI(net_bnx2x, rte_bnx2x_pmd);
748 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2x, pci_id_bnx2x_map);
749 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic | vfio-pci");
750 RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd);
751 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
752 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio-pci");
754 RTE_INIT(bnx2x_init_log)
756 bnx2x_logtype_init = rte_log_register("pmd.net.bnx2x.init");
757 if (bnx2x_logtype_init >= 0)
758 rte_log_set_level(bnx2x_logtype_init, RTE_LOG_NOTICE);
759 bnx2x_logtype_driver = rte_log_register("pmd.net.bnx2x.driver");
760 if (bnx2x_logtype_driver >= 0)
761 rte_log_set_level(bnx2x_logtype_driver, RTE_LOG_NOTICE);