2021-07-08 09:32:21 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
|
|
|
|
* Copyright(c) 2010-2017 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <rte_common.h>
|
|
|
|
#include <ethdev_pci.h>
|
|
|
|
|
2021-07-08 09:32:22 +00:00
|
|
|
#include "ngbe_devids.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The set of PCI devices this driver supports
|
|
|
|
*/
|
|
|
|
static const struct rte_pci_id pci_id_ngbe_map[] = {
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A2) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A2S) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A4) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A4S) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860AL2) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860AL2S) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860AL4) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860AL4S) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860NCSI) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A1) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860A1L) },
|
|
|
|
{ RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, NGBE_DEV_ID_EM_WX1860AL_W) },
|
|
|
|
{ .vendor_id = 0, /* sentinel */ },
|
|
|
|
};
|
|
|
|
|
2021-07-08 09:32:21 +00:00
|
|
|
static int
|
2021-07-08 09:32:22 +00:00
|
|
|
eth_ngbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
|
2021-07-08 09:32:21 +00:00
|
|
|
{
|
2021-07-08 09:32:22 +00:00
|
|
|
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
|
|
|
|
|
|
|
|
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rte_eth_copy_pci_info(eth_dev, pci_dev);
|
|
|
|
|
2021-07-08 09:32:21 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2021-07-08 09:32:22 +00:00
|
|
|
static int
|
|
|
|
eth_ngbe_dev_uninit(struct rte_eth_dev *eth_dev)
|
2021-07-08 09:32:21 +00:00
|
|
|
{
|
2021-07-08 09:32:22 +00:00
|
|
|
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
RTE_SET_USED(eth_dev);
|
|
|
|
|
2021-07-08 09:32:21 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2021-07-08 09:32:22 +00:00
|
|
|
static int
|
|
|
|
eth_ngbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
|
|
|
|
struct rte_pci_device *pci_dev)
|
|
|
|
{
|
|
|
|
return rte_eth_dev_create(&pci_dev->device, pci_dev->device.name,
|
|
|
|
0, eth_dev_pci_specific_init, pci_dev,
|
|
|
|
eth_ngbe_dev_init, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int eth_ngbe_pci_remove(struct rte_pci_device *pci_dev)
|
|
|
|
{
|
|
|
|
struct rte_eth_dev *ethdev;
|
|
|
|
|
|
|
|
ethdev = rte_eth_dev_allocated(pci_dev->device.name);
|
|
|
|
if (ethdev == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return rte_eth_dev_destroy(ethdev, eth_ngbe_dev_uninit);
|
|
|
|
}
|
|
|
|
|
2021-07-08 09:32:21 +00:00
|
|
|
static struct rte_pci_driver rte_ngbe_pmd = {
|
2021-07-08 09:32:22 +00:00
|
|
|
.id_table = pci_id_ngbe_map,
|
|
|
|
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
|
2021-07-08 09:32:21 +00:00
|
|
|
.probe = eth_ngbe_pci_probe,
|
|
|
|
.remove = eth_ngbe_pci_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
RTE_PMD_REGISTER_PCI(net_ngbe, rte_ngbe_pmd);
|
2021-07-08 09:32:22 +00:00
|
|
|
RTE_PMD_REGISTER_PCI_TABLE(net_ngbe, pci_id_ngbe_map);
|
|
|
|
RTE_PMD_REGISTER_KMOD_DEP(net_ngbe, "* igb_uio | uio_pci_generic | vfio-pci");
|