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>
17 int bnx2x_logtype_init;
18 int bnx2x_logtype_driver;
21 * The set of PCI devices this driver supports
23 #define BROADCOM_PCI_VENDOR_ID 0x14E4
24 static const struct rte_pci_id pci_id_bnx2x_map[] = {
25 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800) },
26 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57711) },
27 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810) },
28 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811) },
29 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_OBS) },
30 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_4_10) },
31 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_2_20) },
32 #ifdef RTE_LIBRTE_BNX2X_MF_SUPPORT
33 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_MF) },
34 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_MF) },
35 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_MF) },
40 static const struct rte_pci_id pci_id_bnx2xvf_map[] = {
41 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800_VF) },
42 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_VF) },
43 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_VF) },
44 { RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_VF) },
48 struct rte_bnx2x_xstats_name_off {
49 char name[RTE_ETH_XSTATS_NAME_SIZE];
54 static const struct rte_bnx2x_xstats_name_off bnx2x_xstats_strings[] = {
56 offsetof(struct bnx2x_eth_stats, brb_drop_hi),
57 offsetof(struct bnx2x_eth_stats, brb_drop_lo)},
58 {"rx_buffer_truncates",
59 offsetof(struct bnx2x_eth_stats, brb_truncate_hi),
60 offsetof(struct bnx2x_eth_stats, brb_truncate_lo)},
61 {"rx_buffer_truncate_discard",
62 offsetof(struct bnx2x_eth_stats, brb_truncate_discard),
63 offsetof(struct bnx2x_eth_stats, brb_truncate_discard)},
64 {"mac_filter_discard",
65 offsetof(struct bnx2x_eth_stats, mac_filter_discard),
66 offsetof(struct bnx2x_eth_stats, mac_filter_discard)},
67 {"no_match_vlan_tag_discard",
68 offsetof(struct bnx2x_eth_stats, mf_tag_discard),
69 offsetof(struct bnx2x_eth_stats, mf_tag_discard)},
71 offsetof(struct bnx2x_eth_stats, pause_frames_sent_hi),
72 offsetof(struct bnx2x_eth_stats, pause_frames_sent_lo)},
74 offsetof(struct bnx2x_eth_stats, pause_frames_received_hi),
75 offsetof(struct bnx2x_eth_stats, pause_frames_received_lo)},
76 {"tx_priority_flow_control",
77 offsetof(struct bnx2x_eth_stats, pfc_frames_sent_hi),
78 offsetof(struct bnx2x_eth_stats, pfc_frames_sent_lo)},
79 {"rx_priority_flow_control",
80 offsetof(struct bnx2x_eth_stats, pfc_frames_received_hi),
81 offsetof(struct bnx2x_eth_stats, pfc_frames_received_lo)}
85 bnx2x_link_update(struct rte_eth_dev *dev)
87 struct bnx2x_softc *sc = dev->data->dev_private;
89 PMD_INIT_FUNC_TRACE();
90 bnx2x_link_status_update(sc);
92 dev->data->dev_link.link_speed = sc->link_vars.line_speed;
93 switch (sc->link_vars.duplex) {
95 dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
98 dev->data->dev_link.link_duplex = ETH_LINK_HALF_DUPLEX;
101 dev->data->dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
102 ETH_LINK_SPEED_FIXED);
103 dev->data->dev_link.link_status = sc->link_vars.link_up;
107 bnx2x_interrupt_action(struct rte_eth_dev *dev)
109 struct bnx2x_softc *sc = dev->data->dev_private;
110 uint32_t link_status;
112 PMD_DEBUG_PERIODIC_LOG(INFO, "Interrupt handled");
114 bnx2x_intr_legacy(sc, 0);
116 if (sc->periodic_flags & PERIODIC_GO)
117 bnx2x_periodic_callout(sc);
118 link_status = REG_RD(sc, sc->link_params.shmem_base +
119 offsetof(struct shmem_region,
120 port_mb[sc->link_params.port].link_status));
121 if ((link_status & LINK_STATUS_LINK_UP) != dev->data->dev_link.link_status)
122 bnx2x_link_update(dev);
126 bnx2x_interrupt_handler(void *param)
128 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
129 struct bnx2x_softc *sc = dev->data->dev_private;
131 bnx2x_interrupt_action(dev);
132 rte_intr_enable(&sc->pci_dev->intr_handle);
136 * Devops - helper functions can be called from user application
140 bnx2x_dev_configure(struct rte_eth_dev *dev)
142 struct bnx2x_softc *sc = dev->data->dev_private;
143 struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
145 int mp_ncpus = sysconf(_SC_NPROCESSORS_CONF);
147 PMD_INIT_FUNC_TRACE();
149 if (rxmode->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
150 sc->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len;
152 if (dev->data->nb_tx_queues > dev->data->nb_rx_queues) {
153 PMD_DRV_LOG(ERR, "The number of TX queues is greater than number of RX queues");
157 sc->num_queues = MAX(dev->data->nb_rx_queues, dev->data->nb_tx_queues);
158 if (sc->num_queues > mp_ncpus) {
159 PMD_DRV_LOG(ERR, "The number of queues is more than number of CPUs");
163 PMD_DRV_LOG(DEBUG, "num_queues=%d, mtu=%d",
164 sc->num_queues, sc->mtu);
167 if (bnx2x_alloc_ilt_mem(sc) != 0) {
168 PMD_DRV_LOG(ERR, "bnx2x_alloc_ilt_mem was failed");
172 /* allocate the host hardware/software hsi structures */
173 if (bnx2x_alloc_hsi_mem(sc) != 0) {
174 PMD_DRV_LOG(ERR, "bnx2x_alloc_hsi_mem was failed");
175 bnx2x_free_ilt_mem(sc);
183 bnx2x_dev_start(struct rte_eth_dev *dev)
185 struct bnx2x_softc *sc = dev->data->dev_private;
188 PMD_INIT_FUNC_TRACE();
190 ret = bnx2x_init(sc);
192 PMD_DRV_LOG(DEBUG, "bnx2x_init failed (%d)", ret);
197 rte_intr_callback_register(&sc->pci_dev->intr_handle,
198 bnx2x_interrupt_handler, (void *)dev);
200 if (rte_intr_enable(&sc->pci_dev->intr_handle))
201 PMD_DRV_LOG(ERR, "rte_intr_enable failed");
204 ret = bnx2x_dev_rx_init(dev);
206 PMD_DRV_LOG(DEBUG, "bnx2x_dev_rx_init returned error code");
210 /* Print important adapter info for the user. */
211 bnx2x_print_adapter_info(sc);
217 bnx2x_dev_stop(struct rte_eth_dev *dev)
219 struct bnx2x_softc *sc = dev->data->dev_private;
222 PMD_INIT_FUNC_TRACE();
225 rte_intr_disable(&sc->pci_dev->intr_handle);
226 rte_intr_callback_unregister(&sc->pci_dev->intr_handle,
227 bnx2x_interrupt_handler, (void *)dev);
230 ret = bnx2x_nic_unload(sc, UNLOAD_NORMAL, FALSE);
232 PMD_DRV_LOG(DEBUG, "bnx2x_nic_unload failed (%d)", ret);
240 bnx2x_dev_close(struct rte_eth_dev *dev)
242 struct bnx2x_softc *sc = dev->data->dev_private;
244 PMD_INIT_FUNC_TRACE();
249 bnx2x_dev_clear_queues(dev);
250 memset(&(dev->data->dev_link), 0 , sizeof(struct rte_eth_link));
252 /* free the host hardware/software hsi structures */
253 bnx2x_free_hsi_mem(sc);
256 bnx2x_free_ilt_mem(sc);
260 bnx2x_promisc_enable(struct rte_eth_dev *dev)
262 struct bnx2x_softc *sc = dev->data->dev_private;
264 PMD_INIT_FUNC_TRACE();
265 sc->rx_mode = BNX2X_RX_MODE_PROMISC;
266 if (rte_eth_allmulticast_get(dev->data->port_id) == 1)
267 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI_PROMISC;
268 bnx2x_set_rx_mode(sc);
272 bnx2x_promisc_disable(struct rte_eth_dev *dev)
274 struct bnx2x_softc *sc = dev->data->dev_private;
276 PMD_INIT_FUNC_TRACE();
277 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
278 if (rte_eth_allmulticast_get(dev->data->port_id) == 1)
279 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI;
280 bnx2x_set_rx_mode(sc);
284 bnx2x_dev_allmulticast_enable(struct rte_eth_dev *dev)
286 struct bnx2x_softc *sc = dev->data->dev_private;
288 PMD_INIT_FUNC_TRACE();
289 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI;
290 if (rte_eth_promiscuous_get(dev->data->port_id) == 1)
291 sc->rx_mode = BNX2X_RX_MODE_ALLMULTI_PROMISC;
292 bnx2x_set_rx_mode(sc);
296 bnx2x_dev_allmulticast_disable(struct rte_eth_dev *dev)
298 struct bnx2x_softc *sc = dev->data->dev_private;
300 PMD_INIT_FUNC_TRACE();
301 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
302 if (rte_eth_promiscuous_get(dev->data->port_id) == 1)
303 sc->rx_mode = BNX2X_RX_MODE_PROMISC;
304 bnx2x_set_rx_mode(sc);
308 bnx2x_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
310 PMD_INIT_FUNC_TRACE();
312 int old_link_status = dev->data->dev_link.link_status;
314 bnx2x_link_update(dev);
316 return old_link_status == dev->data->dev_link.link_status ? -1 : 0;
320 bnx2xvf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
322 int old_link_status = dev->data->dev_link.link_status;
323 struct bnx2x_softc *sc = dev->data->dev_private;
325 bnx2x_link_update(dev);
327 bnx2x_check_bull(sc);
328 if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) {
329 PMD_DRV_LOG(ERR, "PF indicated channel is down."
330 "VF device is no longer operational");
331 dev->data->dev_link.link_status = ETH_LINK_DOWN;
334 return old_link_status == dev->data->dev_link.link_status ? -1 : 0;
338 bnx2x_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
340 struct bnx2x_softc *sc = dev->data->dev_private;
341 uint32_t brb_truncate_discard;
343 uint64_t brb_truncates;
345 PMD_INIT_FUNC_TRACE();
347 bnx2x_stats_handle(sc, STATS_EVENT_UPDATE);
349 memset(stats, 0, sizeof (struct rte_eth_stats));
352 HILO_U64(sc->eth_stats.total_unicast_packets_received_hi,
353 sc->eth_stats.total_unicast_packets_received_lo) +
354 HILO_U64(sc->eth_stats.total_multicast_packets_received_hi,
355 sc->eth_stats.total_multicast_packets_received_lo) +
356 HILO_U64(sc->eth_stats.total_broadcast_packets_received_hi,
357 sc->eth_stats.total_broadcast_packets_received_lo);
360 HILO_U64(sc->eth_stats.total_unicast_packets_transmitted_hi,
361 sc->eth_stats.total_unicast_packets_transmitted_lo) +
362 HILO_U64(sc->eth_stats.total_multicast_packets_transmitted_hi,
363 sc->eth_stats.total_multicast_packets_transmitted_lo) +
364 HILO_U64(sc->eth_stats.total_broadcast_packets_transmitted_hi,
365 sc->eth_stats.total_broadcast_packets_transmitted_lo);
368 HILO_U64(sc->eth_stats.total_bytes_received_hi,
369 sc->eth_stats.total_bytes_received_lo);
372 HILO_U64(sc->eth_stats.total_bytes_transmitted_hi,
373 sc->eth_stats.total_bytes_transmitted_lo);
376 HILO_U64(sc->eth_stats.error_bytes_received_hi,
377 sc->eth_stats.error_bytes_received_lo);
382 HILO_U64(sc->eth_stats.no_buff_discard_hi,
383 sc->eth_stats.no_buff_discard_lo);
386 HILO_U64(sc->eth_stats.brb_drop_hi,
387 sc->eth_stats.brb_drop_lo);
390 HILO_U64(sc->eth_stats.brb_truncate_hi,
391 sc->eth_stats.brb_truncate_lo);
393 brb_truncate_discard = sc->eth_stats.brb_truncate_discard;
395 stats->imissed = brb_drops + brb_truncates +
396 brb_truncate_discard + stats->rx_nombuf;
402 bnx2x_get_xstats_names(__rte_unused struct rte_eth_dev *dev,
403 struct rte_eth_xstat_name *xstats_names,
404 __rte_unused unsigned limit)
406 unsigned int i, stat_cnt = RTE_DIM(bnx2x_xstats_strings);
408 if (xstats_names != NULL)
409 for (i = 0; i < stat_cnt; i++)
410 snprintf(xstats_names[i].name,
411 sizeof(xstats_names[i].name),
413 bnx2x_xstats_strings[i].name);
419 bnx2x_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
422 struct bnx2x_softc *sc = dev->data->dev_private;
423 unsigned int num = RTE_DIM(bnx2x_xstats_strings);
428 bnx2x_stats_handle(sc, STATS_EVENT_UPDATE);
430 for (num = 0; num < n; num++) {
431 if (bnx2x_xstats_strings[num].offset_hi !=
432 bnx2x_xstats_strings[num].offset_lo)
433 xstats[num].value = HILO_U64(
434 *(uint32_t *)((char *)&sc->eth_stats +
435 bnx2x_xstats_strings[num].offset_hi),
436 *(uint32_t *)((char *)&sc->eth_stats +
437 bnx2x_xstats_strings[num].offset_lo));
440 *(uint64_t *)((char *)&sc->eth_stats +
441 bnx2x_xstats_strings[num].offset_lo);
442 xstats[num].id = num;
449 bnx2x_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
451 struct bnx2x_softc *sc = dev->data->dev_private;
452 dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
453 dev_info->max_rx_queues = sc->max_rx_queues;
454 dev_info->max_tx_queues = sc->max_tx_queues;
455 dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
456 dev_info->max_rx_pktlen = BNX2X_MAX_RX_PKT_LEN;
457 dev_info->max_mac_addrs = BNX2X_MAX_MAC_ADDRS;
458 dev_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_20G;
459 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_JUMBO_FRAME;
463 bnx2x_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
464 uint32_t index, uint32_t pool)
466 struct bnx2x_softc *sc = dev->data->dev_private;
468 if (sc->mac_ops.mac_addr_add) {
469 sc->mac_ops.mac_addr_add(dev, mac_addr, index, pool);
476 bnx2x_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
478 struct bnx2x_softc *sc = dev->data->dev_private;
480 if (sc->mac_ops.mac_addr_remove)
481 sc->mac_ops.mac_addr_remove(dev, index);
484 static const struct eth_dev_ops bnx2x_eth_dev_ops = {
485 .dev_configure = bnx2x_dev_configure,
486 .dev_start = bnx2x_dev_start,
487 .dev_stop = bnx2x_dev_stop,
488 .dev_close = bnx2x_dev_close,
489 .promiscuous_enable = bnx2x_promisc_enable,
490 .promiscuous_disable = bnx2x_promisc_disable,
491 .allmulticast_enable = bnx2x_dev_allmulticast_enable,
492 .allmulticast_disable = bnx2x_dev_allmulticast_disable,
493 .link_update = bnx2x_dev_link_update,
494 .stats_get = bnx2x_dev_stats_get,
495 .xstats_get = bnx2x_dev_xstats_get,
496 .xstats_get_names = bnx2x_get_xstats_names,
497 .dev_infos_get = bnx2x_dev_infos_get,
498 .rx_queue_setup = bnx2x_dev_rx_queue_setup,
499 .rx_queue_release = bnx2x_dev_rx_queue_release,
500 .tx_queue_setup = bnx2x_dev_tx_queue_setup,
501 .tx_queue_release = bnx2x_dev_tx_queue_release,
502 .mac_addr_add = bnx2x_mac_addr_add,
503 .mac_addr_remove = bnx2x_mac_addr_remove,
507 * dev_ops for virtual function
509 static const struct eth_dev_ops bnx2xvf_eth_dev_ops = {
510 .dev_configure = bnx2x_dev_configure,
511 .dev_start = bnx2x_dev_start,
512 .dev_stop = bnx2x_dev_stop,
513 .dev_close = bnx2x_dev_close,
514 .promiscuous_enable = bnx2x_promisc_enable,
515 .promiscuous_disable = bnx2x_promisc_disable,
516 .allmulticast_enable = bnx2x_dev_allmulticast_enable,
517 .allmulticast_disable = bnx2x_dev_allmulticast_disable,
518 .link_update = bnx2xvf_dev_link_update,
519 .stats_get = bnx2x_dev_stats_get,
520 .xstats_get = bnx2x_dev_xstats_get,
521 .xstats_get_names = bnx2x_get_xstats_names,
522 .dev_infos_get = bnx2x_dev_infos_get,
523 .rx_queue_setup = bnx2x_dev_rx_queue_setup,
524 .rx_queue_release = bnx2x_dev_rx_queue_release,
525 .tx_queue_setup = bnx2x_dev_tx_queue_setup,
526 .tx_queue_release = bnx2x_dev_tx_queue_release,
527 .mac_addr_add = bnx2x_mac_addr_add,
528 .mac_addr_remove = bnx2x_mac_addr_remove,
533 bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
536 struct rte_pci_device *pci_dev;
537 struct bnx2x_softc *sc;
539 PMD_INIT_FUNC_TRACE();
541 eth_dev->dev_ops = is_vf ? &bnx2xvf_eth_dev_ops : &bnx2x_eth_dev_ops;
542 pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
544 rte_eth_copy_pci_info(eth_dev, pci_dev);
546 sc = eth_dev->data->dev_private;
547 sc->pcie_bus = pci_dev->addr.bus;
548 sc->pcie_device = pci_dev->addr.devid;
551 sc->flags = BNX2X_IS_VF_FLAG;
553 sc->devinfo.vendor_id = pci_dev->id.vendor_id;
554 sc->devinfo.device_id = pci_dev->id.device_id;
555 sc->devinfo.subvendor_id = pci_dev->id.subsystem_vendor_id;
556 sc->devinfo.subdevice_id = pci_dev->id.subsystem_device_id;
558 sc->pcie_func = pci_dev->addr.function;
559 sc->bar[BAR0].base_addr = (void *)pci_dev->mem_resource[0].addr;
561 sc->bar[BAR1].base_addr = (void *)
562 ((uintptr_t)pci_dev->mem_resource[0].addr + PXP_VF_ADDR_DB_START);
564 sc->bar[BAR1].base_addr = pci_dev->mem_resource[2].addr;
566 assert(sc->bar[BAR0].base_addr);
567 assert(sc->bar[BAR1].base_addr);
569 bnx2x_load_firmware(sc);
570 assert(sc->firmware);
572 if (eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
575 sc->rx_budget = BNX2X_RX_BUDGET;
576 sc->hc_rx_ticks = BNX2X_RX_TICKS;
577 sc->hc_tx_ticks = BNX2X_TX_TICKS;
579 sc->interrupt_mode = INTR_MODE_SINGLE_MSIX;
580 sc->rx_mode = BNX2X_RX_MODE_NORMAL;
582 sc->pci_dev = pci_dev;
583 ret = bnx2x_attach(sc);
585 PMD_DRV_LOG(ERR, "bnx2x_attach failed (%d)", ret);
589 eth_dev->data->mac_addrs = (struct ether_addr *)sc->link_params.mac_addr;
591 PMD_DRV_LOG(INFO, "pcie_bus=%d, pcie_device=%d",
592 sc->pcie_bus, sc->pcie_device);
593 PMD_DRV_LOG(INFO, "bar0.addr=%p, bar1.addr=%p",
594 sc->bar[BAR0].base_addr, sc->bar[BAR1].base_addr);
595 PMD_DRV_LOG(INFO, "port=%d, path=%d, vnic=%d, func=%d",
596 PORT_ID(sc), PATH_ID(sc), VNIC_ID(sc), FUNC_ID(sc));
597 PMD_DRV_LOG(INFO, "portID=%d vendorID=0x%x deviceID=0x%x",
598 eth_dev->data->port_id, pci_dev->id.vendor_id, pci_dev->id.device_id);
601 rte_spinlock_init(&sc->vf2pf_lock);
603 if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_mbx_msg),
604 &sc->vf2pf_mbox_mapping, "vf2pf_mbox",
605 RTE_CACHE_LINE_SIZE) != 0)
608 sc->vf2pf_mbox = (struct bnx2x_vf_mbx_msg *)
609 sc->vf2pf_mbox_mapping.vaddr;
611 if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_bulletin),
612 &sc->pf2vf_bulletin_mapping, "vf2pf_bull",
613 RTE_CACHE_LINE_SIZE) != 0)
616 sc->pf2vf_bulletin = (struct bnx2x_vf_bulletin *)
617 sc->pf2vf_bulletin_mapping.vaddr;
619 ret = bnx2x_vf_get_resources(sc, sc->max_tx_queues,
629 eth_bnx2x_dev_init(struct rte_eth_dev *eth_dev)
631 PMD_INIT_FUNC_TRACE();
632 return bnx2x_common_dev_init(eth_dev, 0);
636 eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev)
638 PMD_INIT_FUNC_TRACE();
639 return bnx2x_common_dev_init(eth_dev, 1);
642 static struct rte_pci_driver rte_bnx2x_pmd;
643 static struct rte_pci_driver rte_bnx2xvf_pmd;
645 static int eth_bnx2x_pci_probe(struct rte_pci_driver *pci_drv,
646 struct rte_pci_device *pci_dev)
648 struct rte_eth_dev *eth_dev;
651 eth_dev = rte_eth_dev_pci_allocate(pci_dev, sizeof(struct bnx2x_softc));
655 if (pci_drv == &rte_bnx2x_pmd)
656 ret = eth_bnx2x_dev_init(eth_dev);
657 else if (pci_drv == &rte_bnx2xvf_pmd)
658 ret = eth_bnx2xvf_dev_init(eth_dev);
663 rte_eth_dev_pci_release(eth_dev);
668 static int eth_bnx2x_pci_remove(struct rte_pci_device *pci_dev)
670 return rte_eth_dev_pci_generic_remove(pci_dev, NULL);
673 static struct rte_pci_driver rte_bnx2x_pmd = {
674 .id_table = pci_id_bnx2x_map,
675 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
676 .probe = eth_bnx2x_pci_probe,
677 .remove = eth_bnx2x_pci_remove,
681 * virtual function driver struct
683 static struct rte_pci_driver rte_bnx2xvf_pmd = {
684 .id_table = pci_id_bnx2xvf_map,
685 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
686 .probe = eth_bnx2x_pci_probe,
687 .remove = eth_bnx2x_pci_remove,
690 RTE_PMD_REGISTER_PCI(net_bnx2x, rte_bnx2x_pmd);
691 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2x, pci_id_bnx2x_map);
692 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic | vfio-pci");
693 RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd);
694 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
695 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio-pci");
697 RTE_INIT(bnx2x_init_log);
701 bnx2x_logtype_init = rte_log_register("pmd.bnx2x.init");
702 if (bnx2x_logtype_init >= 0)
703 rte_log_set_level(bnx2x_logtype_init, RTE_LOG_NOTICE);
704 bnx2x_logtype_driver = rte_log_register("pmd.bnx2x.driver");
705 if (bnx2x_logtype_driver >= 0)
706 rte_log_set_level(bnx2x_logtype_driver, RTE_LOG_NOTICE);