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"
11 #include <rte_string_fns.h>
13 #include <rte_ethdev_pci.h>
14 #include <rte_alarm.h>
16 int bnx2x_logtype_init;
17 int bnx2x_logtype_driver;
20 * The set of PCI devices this driver supports
22 #define BROADCOM_PCI_VENDOR_ID 0x14E4
23 static const struct rte_pci_id pci_id_bnx2x_map[] = {
24 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800) },
25 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57711) },
26 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810) },
27 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811) },
28 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_OBS) },
29 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_4_10) },
30 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_2_20) },
31 #ifdef RTE_LIBRTE_BNX2X_MF_SUPPORT
32 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_MF) },
33 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_MF) },
34 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_MF) },
39 static const struct rte_pci_id pci_id_bnx2xvf_map[] = {
40 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800_VF) },
41 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_VF) },
42 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_VF) },
43 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_VF) },
47 struct rte_bnx2x_xstats_name_off {
48 char name[RTE_ETH_XSTATS_NAME_SIZE];
53 static const struct rte_bnx2x_xstats_name_off bnx2x_xstats_strings[] = {
55 offsetof(struct bnx2x_eth_stats, brb_drop_hi),
56 offsetof(struct bnx2x_eth_stats, brb_drop_lo)},
57 {"rx_buffer_truncates",
58 offsetof(struct bnx2x_eth_stats, brb_truncate_hi),
59 offsetof(struct bnx2x_eth_stats, brb_truncate_lo)},
60 {"rx_buffer_truncate_discard",
61 offsetof(struct bnx2x_eth_stats, brb_truncate_discard),
62 offsetof(struct bnx2x_eth_stats, brb_truncate_discard)},
63 {"mac_filter_discard",
64 offsetof(struct bnx2x_eth_stats, mac_filter_discard),
65 offsetof(struct bnx2x_eth_stats, mac_filter_discard)},
66 {"no_match_vlan_tag_discard",
67 offsetof(struct bnx2x_eth_stats, mf_tag_discard),
68 offsetof(struct bnx2x_eth_stats, mf_tag_discard)},
70 offsetof(struct bnx2x_eth_stats, pause_frames_sent_hi),
71 offsetof(struct bnx2x_eth_stats, pause_frames_sent_lo)},
73 offsetof(struct bnx2x_eth_stats, pause_frames_received_hi),
74 offsetof(struct bnx2x_eth_stats, pause_frames_received_lo)},
75 {"tx_priority_flow_control",
76 offsetof(struct bnx2x_eth_stats, pfc_frames_sent_hi),
77 offsetof(struct bnx2x_eth_stats, pfc_frames_sent_lo)},
78 {"rx_priority_flow_control",
79 offsetof(struct bnx2x_eth_stats, pfc_frames_received_hi),
80 offsetof(struct bnx2x_eth_stats, pfc_frames_received_lo)}
84 bnx2x_link_update(struct rte_eth_dev *dev)
86 struct bnx2x_softc *sc = dev->data->dev_private;
87 struct rte_eth_link link;
89 PMD_INIT_FUNC_TRACE(sc);
91 bnx2x_link_status_update(sc);
92 memset(&link, 0, sizeof(link));
94 link.link_speed = sc->link_vars.line_speed;
95 switch (sc->link_vars.duplex) {
97 link.link_duplex = ETH_LINK_FULL_DUPLEX;
100 link.link_duplex = ETH_LINK_HALF_DUPLEX;
103 link.link_autoneg = !(dev->data->dev_conf.link_speeds &
104 ETH_LINK_SPEED_FIXED);
105 link.link_status = sc->link_vars.link_up;
107 return rte_eth_linkstatus_set(dev, &link);
111 bnx2x_interrupt_action(struct rte_eth_dev *dev)
113 struct bnx2x_softc *sc = dev->data->dev_private;
114 uint32_t link_status;
116 bnx2x_intr_legacy(sc);
118 if (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 atomic_store_rel_long(&sc->periodic_flags, PERIODIC_STOP);
136 bnx2x_interrupt_action(dev);
137 atomic_store_rel_long(&sc->periodic_flags, PERIODIC_GO);
138 rte_intr_enable(&sc->pci_dev->intr_handle);
141 static void bnx2x_periodic_start(void *param)
143 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
144 struct bnx2x_softc *sc = dev->data->dev_private;
147 atomic_store_rel_long(&sc->periodic_flags, PERIODIC_GO);
148 bnx2x_interrupt_action(dev);
150 ret = rte_eal_alarm_set(BNX2X_SP_TIMER_PERIOD,
151 bnx2x_periodic_start, (void *)dev);
153 PMD_DRV_LOG(ERR, sc, "Unable to start periodic"
154 " timer rc %d", ret);
155 assert(false && "Unable to start periodic timer");
160 void bnx2x_periodic_stop(void *param)
162 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
163 struct bnx2x_softc *sc = dev->data->dev_private;
165 atomic_store_rel_long(&sc->periodic_flags, PERIODIC_STOP);
167 rte_eal_alarm_cancel(bnx2x_periodic_start, (void *)dev);
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 (sc->periodic_flags & PERIODIC_STOP)
230 bnx2x_periodic_start(dev);
232 ret = bnx2x_init(sc);
234 PMD_DRV_LOG(DEBUG, sc, "bnx2x_init failed (%d)", ret);
239 rte_intr_callback_register(&sc->pci_dev->intr_handle,
240 bnx2x_interrupt_handler, (void *)dev);
242 if (rte_intr_enable(&sc->pci_dev->intr_handle))
243 PMD_DRV_LOG(ERR, sc, "rte_intr_enable failed");
246 bnx2x_dev_rxtx_init(dev);
248 bnx2x_print_device_info(sc);
254 bnx2x_dev_stop(struct rte_eth_dev *dev)
256 struct bnx2x_softc *sc = dev->data->dev_private;
259 PMD_INIT_FUNC_TRACE(sc);
261 bnx2x_dev_rxtx_init_dummy(dev);
264 rte_intr_disable(&sc->pci_dev->intr_handle);
265 rte_intr_callback_unregister(&sc->pci_dev->intr_handle,
266 bnx2x_interrupt_handler, (void *)dev);
269 /* stop the periodic callout */
270 bnx2x_periodic_stop(dev);
272 ret = bnx2x_nic_unload(sc, UNLOAD_NORMAL, FALSE);
274 PMD_DRV_LOG(DEBUG, sc, "bnx2x_nic_unload failed (%d)", ret);
282 bnx2x_dev_close(struct rte_eth_dev *dev)
284 struct bnx2x_softc *sc = dev->data->dev_private;
286 PMD_INIT_FUNC_TRACE(sc);
291 bnx2x_dev_clear_queues(dev);
292 memset(&(dev->data->dev_link), 0 , sizeof(struct rte_eth_link));
294 /* free the host hardware/software hsi structures */
295 bnx2x_free_hsi_mem(sc);
298 bnx2x_free_ilt_mem(sc);
302 bnx2x_promisc_enable(struct rte_eth_dev *dev)
304 struct bnx2x_softc *sc = dev->data->dev_private;
306 PMD_INIT_FUNC_TRACE(sc);
307 sc->rx_mode = BNX2X_RX_MODE_PROMISC;
308 if (rte_eth_allmulticast_get(dev->data->port_id) == 1)
309 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI_PROMISC;
310 bnx2x_set_rx_mode(sc);
314 bnx2x_promisc_disable(struct rte_eth_dev *dev)
316 struct bnx2x_softc *sc = dev->data->dev_private;
318 PMD_INIT_FUNC_TRACE(sc);
319 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
320 if (rte_eth_allmulticast_get(dev->data->port_id) == 1)
321 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI;
322 bnx2x_set_rx_mode(sc);
326 bnx2x_dev_allmulticast_enable(struct rte_eth_dev *dev)
328 struct bnx2x_softc *sc = dev->data->dev_private;
330 PMD_INIT_FUNC_TRACE(sc);
331 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI;
332 if (rte_eth_promiscuous_get(dev->data->port_id) == 1)
333 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI_PROMISC;
334 bnx2x_set_rx_mode(sc);
338 bnx2x_dev_allmulticast_disable(struct rte_eth_dev *dev)
340 struct bnx2x_softc *sc = dev->data->dev_private;
342 PMD_INIT_FUNC_TRACE(sc);
343 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
344 if (rte_eth_promiscuous_get(dev->data->port_id) == 1)
345 sc->rx_mode = BNX2X_RX_MODE_PROMISC;
346 bnx2x_set_rx_mode(sc);
350 bnx2x_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
352 struct bnx2x_softc *sc = dev->data->dev_private;
354 PMD_INIT_FUNC_TRACE(sc);
356 return bnx2x_link_update(dev);
360 bnx2xvf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
362 struct bnx2x_softc *sc = dev->data->dev_private;
365 ret = bnx2x_link_update(dev);
367 bnx2x_check_bull(sc);
368 if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) {
369 PMD_DRV_LOG(ERR, sc, "PF indicated channel is down."
370 "VF device is no longer operational");
371 dev->data->dev_link.link_status = ETH_LINK_DOWN;
378 bnx2x_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
380 struct bnx2x_softc *sc = dev->data->dev_private;
381 uint32_t brb_truncate_discard;
383 uint64_t brb_truncates;
385 PMD_INIT_FUNC_TRACE(sc);
387 bnx2x_stats_handle(sc, STATS_EVENT_UPDATE);
389 memset(stats, 0, sizeof (struct rte_eth_stats));
392 HILO_U64(sc->eth_stats.total_unicast_packets_received_hi,
393 sc->eth_stats.total_unicast_packets_received_lo) +
394 HILO_U64(sc->eth_stats.total_multicast_packets_received_hi,
395 sc->eth_stats.total_multicast_packets_received_lo) +
396 HILO_U64(sc->eth_stats.total_broadcast_packets_received_hi,
397 sc->eth_stats.total_broadcast_packets_received_lo);
400 HILO_U64(sc->eth_stats.total_unicast_packets_transmitted_hi,
401 sc->eth_stats.total_unicast_packets_transmitted_lo) +
402 HILO_U64(sc->eth_stats.total_multicast_packets_transmitted_hi,
403 sc->eth_stats.total_multicast_packets_transmitted_lo) +
404 HILO_U64(sc->eth_stats.total_broadcast_packets_transmitted_hi,
405 sc->eth_stats.total_broadcast_packets_transmitted_lo);
408 HILO_U64(sc->eth_stats.total_bytes_received_hi,
409 sc->eth_stats.total_bytes_received_lo);
412 HILO_U64(sc->eth_stats.total_bytes_transmitted_hi,
413 sc->eth_stats.total_bytes_transmitted_lo);
416 HILO_U64(sc->eth_stats.error_bytes_received_hi,
417 sc->eth_stats.error_bytes_received_lo);
422 HILO_U64(sc->eth_stats.no_buff_discard_hi,
423 sc->eth_stats.no_buff_discard_lo);
426 HILO_U64(sc->eth_stats.brb_drop_hi,
427 sc->eth_stats.brb_drop_lo);
430 HILO_U64(sc->eth_stats.brb_truncate_hi,
431 sc->eth_stats.brb_truncate_lo);
433 brb_truncate_discard = sc->eth_stats.brb_truncate_discard;
435 stats->imissed = brb_drops + brb_truncates +
436 brb_truncate_discard + stats->rx_nombuf;
442 bnx2x_get_xstats_names(__rte_unused struct rte_eth_dev *dev,
443 struct rte_eth_xstat_name *xstats_names,
444 __rte_unused unsigned limit)
446 unsigned int i, stat_cnt = RTE_DIM(bnx2x_xstats_strings);
448 if (xstats_names != NULL)
449 for (i = 0; i < stat_cnt; i++)
450 strlcpy(xstats_names[i].name,
451 bnx2x_xstats_strings[i].name,
452 sizeof(xstats_names[i].name));
458 bnx2x_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
461 struct bnx2x_softc *sc = dev->data->dev_private;
462 unsigned int num = RTE_DIM(bnx2x_xstats_strings);
467 bnx2x_stats_handle(sc, STATS_EVENT_UPDATE);
469 for (num = 0; num < n; num++) {
470 if (bnx2x_xstats_strings[num].offset_hi !=
471 bnx2x_xstats_strings[num].offset_lo)
472 xstats[num].value = HILO_U64(
473 *(uint32_t *)((char *)&sc->eth_stats +
474 bnx2x_xstats_strings[num].offset_hi),
475 *(uint32_t *)((char *)&sc->eth_stats +
476 bnx2x_xstats_strings[num].offset_lo));
479 *(uint64_t *)((char *)&sc->eth_stats +
480 bnx2x_xstats_strings[num].offset_lo);
481 xstats[num].id = num;
488 bnx2x_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
490 struct bnx2x_softc *sc = dev->data->dev_private;
491 dev_info->max_rx_queues = sc->max_rx_queues;
492 dev_info->max_tx_queues = sc->max_tx_queues;
493 dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
494 dev_info->max_rx_pktlen = BNX2X_MAX_RX_PKT_LEN;
495 dev_info->max_mac_addrs = BNX2X_MAX_MAC_ADDRS;
496 dev_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_20G;
497 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
501 bnx2x_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
502 uint32_t index, uint32_t pool)
504 struct bnx2x_softc *sc = dev->data->dev_private;
506 if (sc->mac_ops.mac_addr_add) {
507 sc->mac_ops.mac_addr_add(dev, mac_addr, index, pool);
514 bnx2x_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
516 struct bnx2x_softc *sc = dev->data->dev_private;
518 if (sc->mac_ops.mac_addr_remove)
519 sc->mac_ops.mac_addr_remove(dev, index);
522 static const struct eth_dev_ops bnx2x_eth_dev_ops = {
523 .dev_configure = bnx2x_dev_configure,
524 .dev_start = bnx2x_dev_start,
525 .dev_stop = bnx2x_dev_stop,
526 .dev_close = bnx2x_dev_close,
527 .promiscuous_enable = bnx2x_promisc_enable,
528 .promiscuous_disable = bnx2x_promisc_disable,
529 .allmulticast_enable = bnx2x_dev_allmulticast_enable,
530 .allmulticast_disable = bnx2x_dev_allmulticast_disable,
531 .link_update = bnx2x_dev_link_update,
532 .stats_get = bnx2x_dev_stats_get,
533 .xstats_get = bnx2x_dev_xstats_get,
534 .xstats_get_names = bnx2x_get_xstats_names,
535 .dev_infos_get = bnx2x_dev_infos_get,
536 .rx_queue_setup = bnx2x_dev_rx_queue_setup,
537 .rx_queue_release = bnx2x_dev_rx_queue_release,
538 .tx_queue_setup = bnx2x_dev_tx_queue_setup,
539 .tx_queue_release = bnx2x_dev_tx_queue_release,
540 .mac_addr_add = bnx2x_mac_addr_add,
541 .mac_addr_remove = bnx2x_mac_addr_remove,
545 * dev_ops for virtual function
547 static const struct eth_dev_ops bnx2xvf_eth_dev_ops = {
548 .dev_configure = bnx2x_dev_configure,
549 .dev_start = bnx2x_dev_start,
550 .dev_stop = bnx2x_dev_stop,
551 .dev_close = bnx2x_dev_close,
552 .promiscuous_enable = bnx2x_promisc_enable,
553 .promiscuous_disable = bnx2x_promisc_disable,
554 .allmulticast_enable = bnx2x_dev_allmulticast_enable,
555 .allmulticast_disable = bnx2x_dev_allmulticast_disable,
556 .link_update = bnx2xvf_dev_link_update,
557 .stats_get = bnx2x_dev_stats_get,
558 .xstats_get = bnx2x_dev_xstats_get,
559 .xstats_get_names = bnx2x_get_xstats_names,
560 .dev_infos_get = bnx2x_dev_infos_get,
561 .rx_queue_setup = bnx2x_dev_rx_queue_setup,
562 .rx_queue_release = bnx2x_dev_rx_queue_release,
563 .tx_queue_setup = bnx2x_dev_tx_queue_setup,
564 .tx_queue_release = bnx2x_dev_tx_queue_release,
565 .mac_addr_add = bnx2x_mac_addr_add,
566 .mac_addr_remove = bnx2x_mac_addr_remove,
571 bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
574 struct rte_pci_device *pci_dev;
575 struct rte_pci_addr pci_addr;
576 struct bnx2x_softc *sc;
577 static bool adapter_info = true;
579 /* Extract key data structures */
580 sc = eth_dev->data->dev_private;
581 pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
582 pci_addr = pci_dev->addr;
584 snprintf(sc->devinfo.name, NAME_SIZE, PCI_SHORT_PRI_FMT ":dpdk-port-%u",
585 pci_addr.bus, pci_addr.devid, pci_addr.function,
586 eth_dev->data->port_id);
588 PMD_INIT_FUNC_TRACE(sc);
590 eth_dev->dev_ops = is_vf ? &bnx2xvf_eth_dev_ops : &bnx2x_eth_dev_ops;
592 rte_eth_copy_pci_info(eth_dev, pci_dev);
594 sc->pcie_bus = pci_dev->addr.bus;
595 sc->pcie_device = pci_dev->addr.devid;
597 sc->devinfo.vendor_id = pci_dev->id.vendor_id;
598 sc->devinfo.device_id = pci_dev->id.device_id;
599 sc->devinfo.subvendor_id = pci_dev->id.subsystem_vendor_id;
600 sc->devinfo.subdevice_id = pci_dev->id.subsystem_device_id;
603 sc->flags = BNX2X_IS_VF_FLAG;
605 sc->pcie_func = pci_dev->addr.function;
606 sc->bar[BAR0].base_addr = (void *)pci_dev->mem_resource[0].addr;
608 sc->bar[BAR1].base_addr = (void *)
609 ((uintptr_t)pci_dev->mem_resource[0].addr + PXP_VF_ADDR_DB_START);
611 sc->bar[BAR1].base_addr = pci_dev->mem_resource[2].addr;
613 assert(sc->bar[BAR0].base_addr);
614 assert(sc->bar[BAR1].base_addr);
616 bnx2x_load_firmware(sc);
617 assert(sc->firmware);
619 if (eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
622 sc->rx_budget = BNX2X_RX_BUDGET;
623 sc->hc_rx_ticks = BNX2X_RX_TICKS;
624 sc->hc_tx_ticks = BNX2X_TX_TICKS;
626 sc->interrupt_mode = INTR_MODE_SINGLE_MSIX;
627 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
629 sc->pci_dev = pci_dev;
630 ret = bnx2x_attach(sc);
632 PMD_DRV_LOG(ERR, sc, "bnx2x_attach failed (%d)", ret);
636 /* Print important adapter info for the user. */
638 bnx2x_print_adapter_info(sc);
639 adapter_info = false;
642 /* schedule periodic poll for slowpath link events */
644 PMD_DRV_LOG(DEBUG, sc, "Scheduling periodic poll for slowpath link events");
645 ret = rte_eal_alarm_set(BNX2X_SP_TIMER_PERIOD,
646 bnx2x_periodic_start, (void *)eth_dev);
648 PMD_DRV_LOG(ERR, sc, "Unable to start periodic"
649 " timer rc %d", ret);
654 eth_dev->data->mac_addrs = (struct ether_addr *)sc->link_params.mac_addr;
657 rte_spinlock_init(&sc->vf2pf_lock);
659 ret = bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_mbx_msg),
660 &sc->vf2pf_mbox_mapping, "vf2pf_mbox",
661 RTE_CACHE_LINE_SIZE);
665 sc->vf2pf_mbox = (struct bnx2x_vf_mbx_msg *)
666 sc->vf2pf_mbox_mapping.vaddr;
668 ret = bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_bulletin),
669 &sc->pf2vf_bulletin_mapping, "vf2pf_bull",
670 RTE_CACHE_LINE_SIZE);
674 sc->pf2vf_bulletin = (struct bnx2x_vf_bulletin *)
675 sc->pf2vf_bulletin_mapping.vaddr;
677 ret = bnx2x_vf_get_resources(sc, sc->max_tx_queues,
686 bnx2x_periodic_stop(eth_dev);
691 eth_bnx2x_dev_init(struct rte_eth_dev *eth_dev)
693 struct bnx2x_softc *sc = eth_dev->data->dev_private;
694 PMD_INIT_FUNC_TRACE(sc);
695 return bnx2x_common_dev_init(eth_dev, 0);
699 eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev)
701 struct bnx2x_softc *sc = eth_dev->data->dev_private;
702 PMD_INIT_FUNC_TRACE(sc);
703 return bnx2x_common_dev_init(eth_dev, 1);
706 static struct rte_pci_driver rte_bnx2x_pmd;
707 static struct rte_pci_driver rte_bnx2xvf_pmd;
709 static int eth_bnx2x_pci_probe(struct rte_pci_driver *pci_drv,
710 struct rte_pci_device *pci_dev)
712 if (pci_drv == &rte_bnx2x_pmd)
713 return rte_eth_dev_pci_generic_probe(pci_dev,
714 sizeof(struct bnx2x_softc), eth_bnx2x_dev_init);
715 else if (pci_drv == &rte_bnx2xvf_pmd)
716 return rte_eth_dev_pci_generic_probe(pci_dev,
717 sizeof(struct bnx2x_softc), eth_bnx2xvf_dev_init);
722 static int eth_bnx2x_pci_remove(struct rte_pci_device *pci_dev)
724 return rte_eth_dev_pci_generic_remove(pci_dev, NULL);
727 static struct rte_pci_driver rte_bnx2x_pmd = {
728 .id_table = pci_id_bnx2x_map,
729 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
730 .probe = eth_bnx2x_pci_probe,
731 .remove = eth_bnx2x_pci_remove,
735 * virtual function driver struct
737 static struct rte_pci_driver rte_bnx2xvf_pmd = {
738 .id_table = pci_id_bnx2xvf_map,
739 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
740 .probe = eth_bnx2x_pci_probe,
741 .remove = eth_bnx2x_pci_remove,
744 RTE_PMD_REGISTER_PCI(net_bnx2x, rte_bnx2x_pmd);
745 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2x, pci_id_bnx2x_map);
746 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic | vfio-pci");
747 RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd);
748 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
749 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio-pci");
751 RTE_INIT(bnx2x_init_log)
753 bnx2x_logtype_init = rte_log_register("pmd.net.bnx2x.init");
754 if (bnx2x_logtype_init >= 0)
755 rte_log_set_level(bnx2x_logtype_init, RTE_LOG_NOTICE);
756 bnx2x_logtype_driver = rte_log_register("pmd.net.bnx2x.driver");
757 if (bnx2x_logtype_driver >= 0)
758 rte_log_set_level(bnx2x_logtype_driver, RTE_LOG_NOTICE);