2 * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
4 * Copyright (c) 2015 QLogic Corporation.
8 * See LICENSE.bnx2x_pmd for copyright and licensing details.
12 #include "bnx2x_rxtx.h"
15 #include <rte_ethdev_pci.h>
18 * The set of PCI devices this driver supports
20 #define BROADCOM_PCI_VENDOR_ID 0x14E4
21 static const struct rte_pci_id pci_id_bnx2x_map[] = {
22 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800) },
23 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57711) },
24 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810) },
25 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811) },
26 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_OBS) },
27 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_4_10) },
28 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_2_20) },
29 #ifdef RTE_LIBRTE_BNX2X_MF_SUPPORT
30 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_MF) },
31 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_MF) },
32 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_MF) },
37 static const struct rte_pci_id pci_id_bnx2xvf_map[] = {
38 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800_VF) },
39 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_VF) },
40 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_VF) },
41 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_VF) },
45 struct rte_bnx2x_xstats_name_off {
46 char name[RTE_ETH_XSTATS_NAME_SIZE];
51 static const struct rte_bnx2x_xstats_name_off bnx2x_xstats_strings[] = {
53 offsetof(struct bnx2x_eth_stats, brb_drop_hi),
54 offsetof(struct bnx2x_eth_stats, brb_drop_lo)},
55 {"rx_buffer_truncates",
56 offsetof(struct bnx2x_eth_stats, brb_truncate_hi),
57 offsetof(struct bnx2x_eth_stats, brb_truncate_lo)},
58 {"rx_buffer_truncate_discard",
59 offsetof(struct bnx2x_eth_stats, brb_truncate_discard),
60 offsetof(struct bnx2x_eth_stats, brb_truncate_discard)},
61 {"mac_filter_discard",
62 offsetof(struct bnx2x_eth_stats, mac_filter_discard),
63 offsetof(struct bnx2x_eth_stats, mac_filter_discard)},
64 {"no_match_vlan_tag_discard",
65 offsetof(struct bnx2x_eth_stats, mf_tag_discard),
66 offsetof(struct bnx2x_eth_stats, mf_tag_discard)},
68 offsetof(struct bnx2x_eth_stats, pause_frames_sent_hi),
69 offsetof(struct bnx2x_eth_stats, pause_frames_sent_lo)},
71 offsetof(struct bnx2x_eth_stats, pause_frames_received_hi),
72 offsetof(struct bnx2x_eth_stats, pause_frames_received_lo)},
73 {"tx_priority_flow_control",
74 offsetof(struct bnx2x_eth_stats, pfc_frames_sent_hi),
75 offsetof(struct bnx2x_eth_stats, pfc_frames_sent_lo)},
76 {"rx_priority_flow_control",
77 offsetof(struct bnx2x_eth_stats, pfc_frames_received_hi),
78 offsetof(struct bnx2x_eth_stats, pfc_frames_received_lo)}
82 bnx2x_link_update(struct rte_eth_dev *dev)
84 struct bnx2x_softc *sc = dev->data->dev_private;
86 PMD_INIT_FUNC_TRACE();
87 bnx2x_link_status_update(sc);
89 dev->data->dev_link.link_speed = sc->link_vars.line_speed;
90 switch (sc->link_vars.duplex) {
92 dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
95 dev->data->dev_link.link_duplex = ETH_LINK_HALF_DUPLEX;
98 dev->data->dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
99 ETH_LINK_SPEED_FIXED);
100 dev->data->dev_link.link_status = sc->link_vars.link_up;
104 bnx2x_interrupt_action(struct rte_eth_dev *dev)
106 struct bnx2x_softc *sc = dev->data->dev_private;
107 uint32_t link_status;
109 PMD_DEBUG_PERIODIC_LOG(INFO, "Interrupt handled");
111 bnx2x_intr_legacy(sc, 0);
113 if (sc->periodic_flags & PERIODIC_GO)
114 bnx2x_periodic_callout(sc);
115 link_status = REG_RD(sc, sc->link_params.shmem_base +
116 offsetof(struct shmem_region,
117 port_mb[sc->link_params.port].link_status));
118 if ((link_status & LINK_STATUS_LINK_UP) != dev->data->dev_link.link_status)
119 bnx2x_link_update(dev);
123 bnx2x_interrupt_handler(void *param)
125 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
126 struct bnx2x_softc *sc = dev->data->dev_private;
128 bnx2x_interrupt_action(dev);
129 rte_intr_enable(&sc->pci_dev->intr_handle);
133 * Devops - helper functions can be called from user application
137 bnx2x_dev_configure(struct rte_eth_dev *dev)
139 struct bnx2x_softc *sc = dev->data->dev_private;
140 int mp_ncpus = sysconf(_SC_NPROCESSORS_CONF);
142 PMD_INIT_FUNC_TRACE();
144 if (dev->data->dev_conf.rxmode.jumbo_frame)
145 sc->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len;
147 if (dev->data->nb_tx_queues > dev->data->nb_rx_queues) {
148 PMD_DRV_LOG(ERR, "The number of TX queues is greater than number of RX queues");
152 sc->num_queues = MAX(dev->data->nb_rx_queues, dev->data->nb_tx_queues);
153 if (sc->num_queues > mp_ncpus) {
154 PMD_DRV_LOG(ERR, "The number of queues is more than number of CPUs");
158 PMD_DRV_LOG(DEBUG, "num_queues=%d, mtu=%d",
159 sc->num_queues, sc->mtu);
162 if (bnx2x_alloc_ilt_mem(sc) != 0) {
163 PMD_DRV_LOG(ERR, "bnx2x_alloc_ilt_mem was failed");
167 /* allocate the host hardware/software hsi structures */
168 if (bnx2x_alloc_hsi_mem(sc) != 0) {
169 PMD_DRV_LOG(ERR, "bnx2x_alloc_hsi_mem was failed");
170 bnx2x_free_ilt_mem(sc);
178 bnx2x_dev_start(struct rte_eth_dev *dev)
180 struct bnx2x_softc *sc = dev->data->dev_private;
183 PMD_INIT_FUNC_TRACE();
185 ret = bnx2x_init(sc);
187 PMD_DRV_LOG(DEBUG, "bnx2x_init failed (%d)", ret);
192 rte_intr_callback_register(&sc->pci_dev->intr_handle,
193 bnx2x_interrupt_handler, (void *)dev);
195 if (rte_intr_enable(&sc->pci_dev->intr_handle))
196 PMD_DRV_LOG(ERR, "rte_intr_enable failed");
199 ret = bnx2x_dev_rx_init(dev);
201 PMD_DRV_LOG(DEBUG, "bnx2x_dev_rx_init returned error code");
205 /* Print important adapter info for the user. */
206 bnx2x_print_adapter_info(sc);
212 bnx2x_dev_stop(struct rte_eth_dev *dev)
214 struct bnx2x_softc *sc = dev->data->dev_private;
217 PMD_INIT_FUNC_TRACE();
220 rte_intr_disable(&sc->pci_dev->intr_handle);
221 rte_intr_callback_unregister(&sc->pci_dev->intr_handle,
222 bnx2x_interrupt_handler, (void *)dev);
225 ret = bnx2x_nic_unload(sc, UNLOAD_NORMAL, FALSE);
227 PMD_DRV_LOG(DEBUG, "bnx2x_nic_unload failed (%d)", ret);
235 bnx2x_dev_close(struct rte_eth_dev *dev)
237 struct bnx2x_softc *sc = dev->data->dev_private;
239 PMD_INIT_FUNC_TRACE();
244 bnx2x_dev_clear_queues(dev);
245 memset(&(dev->data->dev_link), 0 , sizeof(struct rte_eth_link));
247 /* free the host hardware/software hsi structures */
248 bnx2x_free_hsi_mem(sc);
251 bnx2x_free_ilt_mem(sc);
255 bnx2x_promisc_enable(struct rte_eth_dev *dev)
257 struct bnx2x_softc *sc = dev->data->dev_private;
259 PMD_INIT_FUNC_TRACE();
260 sc->rx_mode = BNX2X_RX_MODE_PROMISC;
261 if (rte_eth_allmulticast_get(dev->data->port_id) == 1)
262 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI_PROMISC;
263 bnx2x_set_rx_mode(sc);
267 bnx2x_promisc_disable(struct rte_eth_dev *dev)
269 struct bnx2x_softc *sc = dev->data->dev_private;
271 PMD_INIT_FUNC_TRACE();
272 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
273 if (rte_eth_allmulticast_get(dev->data->port_id) == 1)
274 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI;
275 bnx2x_set_rx_mode(sc);
279 bnx2x_dev_allmulticast_enable(struct rte_eth_dev *dev)
281 struct bnx2x_softc *sc = dev->data->dev_private;
283 PMD_INIT_FUNC_TRACE();
284 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI;
285 if (rte_eth_promiscuous_get(dev->data->port_id) == 1)
286 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI_PROMISC;
287 bnx2x_set_rx_mode(sc);
291 bnx2x_dev_allmulticast_disable(struct rte_eth_dev *dev)
293 struct bnx2x_softc *sc = dev->data->dev_private;
295 PMD_INIT_FUNC_TRACE();
296 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
297 if (rte_eth_promiscuous_get(dev->data->port_id) == 1)
298 sc->rx_mode = BNX2X_RX_MODE_PROMISC;
299 bnx2x_set_rx_mode(sc);
303 bnx2x_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
305 PMD_INIT_FUNC_TRACE();
307 int old_link_status = dev->data->dev_link.link_status;
309 bnx2x_link_update(dev);
311 return old_link_status == dev->data->dev_link.link_status ? -1 : 0;
315 bnx2xvf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
317 int old_link_status = dev->data->dev_link.link_status;
318 struct bnx2x_softc *sc = dev->data->dev_private;
320 bnx2x_link_update(dev);
322 bnx2x_check_bull(sc);
323 if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) {
324 PMD_DRV_LOG(ERR, "PF indicated channel is down."
325 "VF device is no longer operational");
326 dev->data->dev_link.link_status = ETH_LINK_DOWN;
329 return old_link_status == dev->data->dev_link.link_status ? -1 : 0;
333 bnx2x_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
335 struct bnx2x_softc *sc = dev->data->dev_private;
336 uint32_t brb_truncate_discard;
338 uint64_t brb_truncates;
340 PMD_INIT_FUNC_TRACE();
342 bnx2x_stats_handle(sc, STATS_EVENT_UPDATE);
344 memset(stats, 0, sizeof (struct rte_eth_stats));
347 HILO_U64(sc->eth_stats.total_unicast_packets_received_hi,
348 sc->eth_stats.total_unicast_packets_received_lo) +
349 HILO_U64(sc->eth_stats.total_multicast_packets_received_hi,
350 sc->eth_stats.total_multicast_packets_received_lo) +
351 HILO_U64(sc->eth_stats.total_broadcast_packets_received_hi,
352 sc->eth_stats.total_broadcast_packets_received_lo);
355 HILO_U64(sc->eth_stats.total_unicast_packets_transmitted_hi,
356 sc->eth_stats.total_unicast_packets_transmitted_lo) +
357 HILO_U64(sc->eth_stats.total_multicast_packets_transmitted_hi,
358 sc->eth_stats.total_multicast_packets_transmitted_lo) +
359 HILO_U64(sc->eth_stats.total_broadcast_packets_transmitted_hi,
360 sc->eth_stats.total_broadcast_packets_transmitted_lo);
363 HILO_U64(sc->eth_stats.total_bytes_received_hi,
364 sc->eth_stats.total_bytes_received_lo);
367 HILO_U64(sc->eth_stats.total_bytes_transmitted_hi,
368 sc->eth_stats.total_bytes_transmitted_lo);
371 HILO_U64(sc->eth_stats.error_bytes_received_hi,
372 sc->eth_stats.error_bytes_received_lo);
377 HILO_U64(sc->eth_stats.no_buff_discard_hi,
378 sc->eth_stats.no_buff_discard_lo);
381 HILO_U64(sc->eth_stats.brb_drop_hi,
382 sc->eth_stats.brb_drop_lo);
385 HILO_U64(sc->eth_stats.brb_truncate_hi,
386 sc->eth_stats.brb_truncate_lo);
388 brb_truncate_discard = sc->eth_stats.brb_truncate_discard;
390 stats->imissed = brb_drops + brb_truncates +
391 brb_truncate_discard + stats->rx_nombuf;
395 bnx2x_get_xstats_names(__rte_unused struct rte_eth_dev *dev,
396 struct rte_eth_xstat_name *xstats_names,
397 __rte_unused unsigned limit)
399 unsigned int i, stat_cnt = RTE_DIM(bnx2x_xstats_strings);
401 if (xstats_names != NULL)
402 for (i = 0; i < stat_cnt; i++)
403 snprintf(xstats_names[i].name,
404 sizeof(xstats_names[i].name),
406 bnx2x_xstats_strings[i].name);
412 bnx2x_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
415 struct bnx2x_softc *sc = dev->data->dev_private;
416 unsigned int num = RTE_DIM(bnx2x_xstats_strings);
421 bnx2x_stats_handle(sc, STATS_EVENT_UPDATE);
423 for (num = 0; num < n; num++) {
424 if (bnx2x_xstats_strings[num].offset_hi !=
425 bnx2x_xstats_strings[num].offset_lo)
426 xstats[num].value = HILO_U64(
427 *(uint32_t *)((char *)&sc->eth_stats +
428 bnx2x_xstats_strings[num].offset_hi),
429 *(uint32_t *)((char *)&sc->eth_stats +
430 bnx2x_xstats_strings[num].offset_lo));
433 *(uint64_t *)((char *)&sc->eth_stats +
434 bnx2x_xstats_strings[num].offset_lo);
435 xstats[num].id = num;
442 bnx2x_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
444 struct bnx2x_softc *sc = dev->data->dev_private;
445 dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
446 dev_info->max_rx_queues = sc->max_rx_queues;
447 dev_info->max_tx_queues = sc->max_tx_queues;
448 dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
449 dev_info->max_rx_pktlen = BNX2X_MAX_RX_PKT_LEN;
450 dev_info->max_mac_addrs = BNX2X_MAX_MAC_ADDRS;
451 dev_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_20G;
455 bnx2x_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
456 uint32_t index, uint32_t pool)
458 struct bnx2x_softc *sc = dev->data->dev_private;
460 if (sc->mac_ops.mac_addr_add) {
461 sc->mac_ops.mac_addr_add(dev, mac_addr, index, pool);
468 bnx2x_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
470 struct bnx2x_softc *sc = dev->data->dev_private;
472 if (sc->mac_ops.mac_addr_remove)
473 sc->mac_ops.mac_addr_remove(dev, index);
476 static const struct eth_dev_ops bnx2x_eth_dev_ops = {
477 .dev_configure = bnx2x_dev_configure,
478 .dev_start = bnx2x_dev_start,
479 .dev_stop = bnx2x_dev_stop,
480 .dev_close = bnx2x_dev_close,
481 .promiscuous_enable = bnx2x_promisc_enable,
482 .promiscuous_disable = bnx2x_promisc_disable,
483 .allmulticast_enable = bnx2x_dev_allmulticast_enable,
484 .allmulticast_disable = bnx2x_dev_allmulticast_disable,
485 .link_update = bnx2x_dev_link_update,
486 .stats_get = bnx2x_dev_stats_get,
487 .xstats_get = bnx2x_dev_xstats_get,
488 .xstats_get_names = bnx2x_get_xstats_names,
489 .dev_infos_get = bnx2x_dev_infos_get,
490 .rx_queue_setup = bnx2x_dev_rx_queue_setup,
491 .rx_queue_release = bnx2x_dev_rx_queue_release,
492 .tx_queue_setup = bnx2x_dev_tx_queue_setup,
493 .tx_queue_release = bnx2x_dev_tx_queue_release,
494 .mac_addr_add = bnx2x_mac_addr_add,
495 .mac_addr_remove = bnx2x_mac_addr_remove,
499 * dev_ops for virtual function
501 static const struct eth_dev_ops bnx2xvf_eth_dev_ops = {
502 .dev_configure = bnx2x_dev_configure,
503 .dev_start = bnx2x_dev_start,
504 .dev_stop = bnx2x_dev_stop,
505 .dev_close = bnx2x_dev_close,
506 .promiscuous_enable = bnx2x_promisc_enable,
507 .promiscuous_disable = bnx2x_promisc_disable,
508 .allmulticast_enable = bnx2x_dev_allmulticast_enable,
509 .allmulticast_disable = bnx2x_dev_allmulticast_disable,
510 .link_update = bnx2xvf_dev_link_update,
511 .stats_get = bnx2x_dev_stats_get,
512 .xstats_get = bnx2x_dev_xstats_get,
513 .xstats_get_names = bnx2x_get_xstats_names,
514 .dev_infos_get = bnx2x_dev_infos_get,
515 .rx_queue_setup = bnx2x_dev_rx_queue_setup,
516 .rx_queue_release = bnx2x_dev_rx_queue_release,
517 .tx_queue_setup = bnx2x_dev_tx_queue_setup,
518 .tx_queue_release = bnx2x_dev_tx_queue_release,
519 .mac_addr_add = bnx2x_mac_addr_add,
520 .mac_addr_remove = bnx2x_mac_addr_remove,
525 bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
528 struct rte_pci_device *pci_dev;
529 struct bnx2x_softc *sc;
531 PMD_INIT_FUNC_TRACE();
533 eth_dev->dev_ops = is_vf ? &bnx2xvf_eth_dev_ops : &bnx2x_eth_dev_ops;
534 pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
536 rte_eth_copy_pci_info(eth_dev, pci_dev);
538 sc = eth_dev->data->dev_private;
539 sc->pcie_bus = pci_dev->addr.bus;
540 sc->pcie_device = pci_dev->addr.devid;
543 sc->flags = BNX2X_IS_VF_FLAG;
545 sc->devinfo.vendor_id = pci_dev->id.vendor_id;
546 sc->devinfo.device_id = pci_dev->id.device_id;
547 sc->devinfo.subvendor_id = pci_dev->id.subsystem_vendor_id;
548 sc->devinfo.subdevice_id = pci_dev->id.subsystem_device_id;
550 sc->pcie_func = pci_dev->addr.function;
551 sc->bar[BAR0].base_addr = (void *)pci_dev->mem_resource[0].addr;
553 sc->bar[BAR1].base_addr = (void *)
554 ((uintptr_t)pci_dev->mem_resource[0].addr + PXP_VF_ADDR_DB_START);
556 sc->bar[BAR1].base_addr = pci_dev->mem_resource[2].addr;
558 assert(sc->bar[BAR0].base_addr);
559 assert(sc->bar[BAR1].base_addr);
561 bnx2x_load_firmware(sc);
562 assert(sc->firmware);
564 if (eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
567 sc->rx_budget = BNX2X_RX_BUDGET;
568 sc->hc_rx_ticks = BNX2X_RX_TICKS;
569 sc->hc_tx_ticks = BNX2X_TX_TICKS;
571 sc->interrupt_mode = INTR_MODE_SINGLE_MSIX;
572 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
574 sc->pci_dev = pci_dev;
575 ret = bnx2x_attach(sc);
577 PMD_DRV_LOG(ERR, "bnx2x_attach failed (%d)", ret);
581 eth_dev->data->mac_addrs = (struct ether_addr *)sc->link_params.mac_addr;
583 PMD_DRV_LOG(INFO, "pcie_bus=%d, pcie_device=%d",
584 sc->pcie_bus, sc->pcie_device);
585 PMD_DRV_LOG(INFO, "bar0.addr=%p, bar1.addr=%p",
586 sc->bar[BAR0].base_addr, sc->bar[BAR1].base_addr);
587 PMD_DRV_LOG(INFO, "port=%d, path=%d, vnic=%d, func=%d",
588 PORT_ID(sc), PATH_ID(sc), VNIC_ID(sc), FUNC_ID(sc));
589 PMD_DRV_LOG(INFO, "portID=%d vendorID=0x%x deviceID=0x%x",
590 eth_dev->data->port_id, pci_dev->id.vendor_id, pci_dev->id.device_id);
593 rte_spinlock_init(&sc->vf2pf_lock);
595 if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_mbx_msg),
596 &sc->vf2pf_mbox_mapping, "vf2pf_mbox",
597 RTE_CACHE_LINE_SIZE) != 0)
600 sc->vf2pf_mbox = (struct bnx2x_vf_mbx_msg *)
601 sc->vf2pf_mbox_mapping.vaddr;
603 if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_bulletin),
604 &sc->pf2vf_bulletin_mapping, "vf2pf_bull",
605 RTE_CACHE_LINE_SIZE) != 0)
608 sc->pf2vf_bulletin = (struct bnx2x_vf_bulletin *)
609 sc->pf2vf_bulletin_mapping.vaddr;
611 ret = bnx2x_vf_get_resources(sc, sc->max_tx_queues,
621 eth_bnx2x_dev_init(struct rte_eth_dev *eth_dev)
623 PMD_INIT_FUNC_TRACE();
624 return bnx2x_common_dev_init(eth_dev, 0);
628 eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev)
630 PMD_INIT_FUNC_TRACE();
631 return bnx2x_common_dev_init(eth_dev, 1);
634 static struct rte_pci_driver rte_bnx2x_pmd;
635 static struct rte_pci_driver rte_bnx2xvf_pmd;
637 static int eth_bnx2x_pci_probe(struct rte_pci_driver *pci_drv,
638 struct rte_pci_device *pci_dev)
640 struct rte_eth_dev *eth_dev;
643 eth_dev = rte_eth_dev_pci_allocate(pci_dev, sizeof(struct bnx2x_softc));
647 if (pci_drv == &rte_bnx2x_pmd)
648 ret = eth_bnx2x_dev_init(eth_dev);
649 else if (pci_drv == &rte_bnx2xvf_pmd)
650 ret = eth_bnx2xvf_dev_init(eth_dev);
655 rte_eth_dev_pci_release(eth_dev);
660 static int eth_bnx2x_pci_remove(struct rte_pci_device *pci_dev)
662 return rte_eth_dev_pci_generic_remove(pci_dev, NULL);
665 static struct rte_pci_driver rte_bnx2x_pmd = {
666 .id_table = pci_id_bnx2x_map,
667 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
668 .probe = eth_bnx2x_pci_probe,
669 .remove = eth_bnx2x_pci_remove,
673 * virtual function driver struct
675 static struct rte_pci_driver rte_bnx2xvf_pmd = {
676 .id_table = pci_id_bnx2xvf_map,
677 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
678 .probe = eth_bnx2x_pci_probe,
679 .remove = eth_bnx2x_pci_remove,
682 RTE_PMD_REGISTER_PCI(net_bnx2x, rte_bnx2x_pmd);
683 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2x, pci_id_bnx2x_map);
684 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic | vfio-pci");
685 RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd);
686 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
687 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio-pci");