[RFC,01/29] net/qdma: add net PMD template

Message ID 20220706075219.517046-2-aman.kumar@vvdntech.in (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers
Series cover letter for net/qdma PMD |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Aman Kumar July 6, 2022, 7:51 a.m. UTC
  add probe and remove function template for qdma PMD.
define supported PCI device table.

Signed-off-by: Aman Kumar <aman.kumar@vvdntech.in>
---
 drivers/net/qdma/meson.build   |  18 ++++++
 drivers/net/qdma/qdma_ethdev.c | 107 +++++++++++++++++++++++++++++++++
 drivers/net/qdma/version.map   |   3 +
 3 files changed, 128 insertions(+)
 create mode 100644 drivers/net/qdma/meson.build
 create mode 100644 drivers/net/qdma/qdma_ethdev.c
 create mode 100644 drivers/net/qdma/version.map
  

Patch

diff --git a/drivers/net/qdma/meson.build b/drivers/net/qdma/meson.build
new file mode 100644
index 0000000000..fe9d2d48d7
--- /dev/null
+++ b/drivers/net/qdma/meson.build
@@ -0,0 +1,18 @@ 
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2021-2022 Xilinx, Inc. All rights reserved.
+# Copyright(c) 2022 VVDN Technologies Private Limited. All rights reserved.
+
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+endif
+if (not dpdk_conf.has('RTE_ARCH_X86_64'))
+    build = false
+    reason = 'only supported on x86_64'
+endif
+
+includes += include_directories('.')
+
+sources = files(
+        'qdma_ethdev.c',
+)
diff --git a/drivers/net/qdma/qdma_ethdev.c b/drivers/net/qdma/qdma_ethdev.c
new file mode 100644
index 0000000000..35d7c88658
--- /dev/null
+++ b/drivers/net/qdma/qdma_ethdev.c
@@ -0,0 +1,107 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2022 Xilinx, Inc. All rights reserved.
+ * Copyright(c) 2022 VVDN Technologies Private Limited. All rights reserved.
+ */
+
+#include <ethdev_pci.h>
+#include <rte_dev.h>
+#include <rte_pci.h>
+#include <rte_ether.h>
+#include <rte_ethdev.h>
+
+/*
+ * The set of PCI devices this driver supports
+ */
+static struct rte_pci_id qdma_pci_id_tbl[] = {
+#define RTE_PCI_DEV_ID_DECL(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
+#ifndef PCI_VENDOR_ID_VVDN
+#define PCI_VENDOR_ID_VVDN 0x1f44
+#endif
+
+	/** Gen 3 PF */
+	/** PCIe lane width x8 */
+	RTE_PCI_DEV_ID_DECL(PCI_VENDOR_ID_VVDN, 0x0201)	/** PF */
+
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+/**
+ * DPDK callback to register a PCI device.
+ *
+ * This function creates an Ethernet device for each port of a given
+ * PCI device.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   0 on success, negative errno value on failure.
+ */
+static int qdma_eth_dev_init(struct rte_eth_dev *dev)
+{
+	struct rte_pci_device *pci_dev;
+
+	/* sanity checks */
+	if (dev == NULL)
+		return -EINVAL;
+	if (dev->data == NULL)
+		return -EINVAL;
+	if (dev->data->dev_private == NULL)
+		return -EINVAL;
+
+	pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	if (pci_dev == NULL)
+		return -EINVAL;
+
+	/* for secondary processes, we don't initialise any further as primary
+	 * has already done this work.
+	 */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	return 0;
+}
+
+/**
+ * DPDK callback to deregister PCI device.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   0 on success, negative errno value on failure.
+ */
+static int qdma_eth_dev_uninit(struct rte_eth_dev *dev)
+{
+	/* sanity checks */
+	if (dev == NULL)
+		return -EINVAL;
+	/* only uninitialize in the primary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	return 0;
+}
+
+static int eth_qdma_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+				struct rte_pci_device *pci_dev)
+{
+	return rte_eth_dev_pci_generic_probe(pci_dev, 0,
+						qdma_eth_dev_init);
+}
+
+/* Detach a ethdev interface */
+static int eth_qdma_pci_remove(struct rte_pci_device *pci_dev)
+{
+	return rte_eth_dev_pci_generic_remove(pci_dev, qdma_eth_dev_uninit);
+}
+
+static struct rte_pci_driver rte_qdma_pmd = {
+	.id_table = qdma_pci_id_tbl,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+	.probe = eth_qdma_pci_probe,
+	.remove = eth_qdma_pci_remove,
+};
+
+RTE_PMD_REGISTER_PCI(net_qdma, rte_qdma_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_qdma, qdma_pci_id_tbl);
diff --git a/drivers/net/qdma/version.map b/drivers/net/qdma/version.map
new file mode 100644
index 0000000000..c2e0723b4c
--- /dev/null
+++ b/drivers/net/qdma/version.map
@@ -0,0 +1,3 @@ 
+DPDK_22 {
+	local: *;
+};