On 4/6/2021 10:30 AM, Jiawen Wu wrote:
Add basic PCIe ethdev probe and remove.
Signed-off-by: Jiawen Wu <jiawe...@trustnetic.com>
<...>
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -1,10 +1,12 @@
- /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2018-2020
- */
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2020
+ */
Can you please fix this where it is introduced at first place?
<...>
+static int
+eth_ngbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+ struct rte_pci_device *pci_dev)
+{
+ struct rte_eth_dev *pf_ethdev;
+ struct rte_eth_devargs eth_da;
+ int retval;
+
+ if (pci_dev->device.devargs) {
+ retval = rte_eth_devargs_parse(pci_dev->device.devargs->args,
+ ð_da);
+ if (retval)
+ return retval;
+ } else {
+ memset(ð_da, 0, sizeof(eth_da));
+ }
+
+ retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name,
+ sizeof(struct ngbe_adapter),
+ eth_dev_pci_specific_init, pci_dev,
+ eth_ngbe_dev_init, NULL);
+
+ if (retval || eth_da.nb_representor_ports < 1)
+ return retval;
no need to check the 'nb_representor_ports' here, the driver does not support
the port anyway, it can return immediately.
Similarly 'rte_eth_devargs_parse()' call above can be removed, for same reason.
When port representor support added to driver, following check also may be added
since new representator types are added recently.
if (eth_da.type != RTE_ETH_REPRESENTOR_VF)
return -ENOTSUP;
+
+ pf_ethdev = rte_eth_dev_allocated(pci_dev->device.name);
+ if (pf_ethdev == NULL)
+ return -ENODEV;
+
Also above part can be removed completely, pf_ethdev is get to use in the
existance of the port representor, no need to get it now.
+ return 0;
+}
+
+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)
+ return -ENODEV;
This is not an error case, you can return success (0) here.
Same applies to txgbe too.