DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Boyer <andrew.boyer@amd.com>
To: <dev@dpdk.org>
Cc: Andrew Boyer <andrew.boyer@amd.com>,
	Neel Patel <neel.patel@amd.com>,
	"R Mohamed Shah" <mohamedshah.r@amd.com>
Subject: [PATCH v1 12/35] net/ionic: move PCI-specific code to a separate file
Date: Mon, 10 Oct 2022 17:50:09 -0700	[thread overview]
Message-ID: <20221011005032.47584-13-andrew.boyer@amd.com> (raw)
In-Reply-To: <20221007174336.54354-1-andrew.boyer@amd.com>

For future support of virtual devices, move the PCI code to its own
file. Create a new device interface, struct ionic_dev_intf, to plug
in to common code.

Signed-off-by: Andrew Boyer <andrew.boyer@amd.com>
Signed-off-by: Neel Patel <neel.patel@amd.com>
Signed-off-by: R Mohamed Shah <mohamedshah.r@amd.com>
---
 drivers/net/ionic/ionic.h         |  13 +-
 drivers/net/ionic/ionic_dev.c     |  62 ---------
 drivers/net/ionic/ionic_dev.h     |  13 +-
 drivers/net/ionic/ionic_dev_pci.c | 216 ++++++++++++++++++++++++++++++
 drivers/net/ionic/ionic_ethdev.c  | 161 ++++++----------------
 drivers/net/ionic/ionic_ethdev.h  |   9 ++
 drivers/net/ionic/ionic_main.c    |   2 +-
 drivers/net/ionic/meson.build     |   1 +
 8 files changed, 286 insertions(+), 191 deletions(-)
 create mode 100644 drivers/net/ionic/ionic_dev_pci.c

diff --git a/drivers/net/ionic/ionic.h b/drivers/net/ionic/ionic.h
index ebe23ad4e6..6bfab623f7 100644
--- a/drivers/net/ionic/ionic.h
+++ b/drivers/net/ionic/ionic.h
@@ -8,8 +8,6 @@
 #include <stdint.h>
 #include <inttypes.h>
 
-#include <bus_pci_driver.h>
-
 #include "ionic_dev.h"
 #include "ionic_if.h"
 #include "ionic_osdep.h"
@@ -42,6 +40,11 @@ struct ionic_hw {
 	uint16_t vendor_id;
 };
 
+struct ionic_bars {
+	struct ionic_dev_bar bar[IONIC_BARS_MAX];
+	uint32_t num_bars;
+};
+
 /*
  * Structure to store private data for each driver instance (for each adapter).
  */
@@ -49,10 +52,10 @@ struct ionic_adapter {
 	struct ionic_hw hw;
 	struct ionic_dev idev;
 	const char *name;
-	struct ionic_dev_bar bars[IONIC_BARS_MAX];
+	struct ionic_bars bars;
+	const struct ionic_dev_intf *intf;
 	struct ionic_identity	ident;
 	struct ionic_lif *lif;
-	uint32_t num_bars;
 	uint32_t max_ntxqs_per_lif;
 	uint32_t max_nrxqs_per_lif;
 	uint32_t max_mac_addrs;
@@ -61,7 +64,7 @@ struct ionic_adapter {
 	bool intrs[IONIC_INTR_CTRL_REGS_MAX];
 	bool link_up;
 	char fw_version[IONIC_DEVINFO_FWVERS_BUFLEN];
-	struct rte_pci_device *pci_dev;
+	void *bus_dev;
 };
 
 /** ionic_admin_ctx - Admin command context.
diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c
index a631523e59..d0d2ab1b17 100644
--- a/drivers/net/ionic/ionic_dev.c
+++ b/drivers/net/ionic/ionic_dev.c
@@ -10,68 +10,6 @@
 #include "ionic_lif.h"
 #include "ionic.h"
 
-int
-ionic_dev_setup(struct ionic_adapter *adapter)
-{
-	struct ionic_dev_bar *bar = adapter->bars;
-	unsigned int num_bars = adapter->num_bars;
-	struct ionic_dev *idev = &adapter->idev;
-	uint32_t sig;
-	u_char *bar0_base;
-	unsigned int i;
-
-	/* BAR0: dev_cmd and interrupts */
-	if (num_bars < 1) {
-		IONIC_PRINT(ERR, "No bars found, aborting");
-		return -EFAULT;
-	}
-
-	if (bar->len < IONIC_BAR0_SIZE) {
-		IONIC_PRINT(ERR,
-			"Resource bar size %lu too small, aborting",
-			bar->len);
-		return -EFAULT;
-	}
-
-	bar0_base = bar->vaddr;
-	idev->dev_info = (union ionic_dev_info_regs *)
-		&bar0_base[IONIC_BAR0_DEV_INFO_REGS_OFFSET];
-	idev->dev_cmd = (union ionic_dev_cmd_regs *)
-		&bar0_base[IONIC_BAR0_DEV_CMD_REGS_OFFSET];
-	idev->intr_status = (struct ionic_intr_status *)
-		&bar0_base[IONIC_BAR0_INTR_STATUS_OFFSET];
-	idev->intr_ctrl = (struct ionic_intr *)
-		&bar0_base[IONIC_BAR0_INTR_CTRL_OFFSET];
-
-	sig = ioread32(&idev->dev_info->signature);
-	if (sig != IONIC_DEV_INFO_SIGNATURE) {
-		IONIC_PRINT(ERR, "Incompatible firmware signature %" PRIx32 "",
-			sig);
-		return -EFAULT;
-	}
-
-	for (i = 0; i < IONIC_DEVINFO_FWVERS_BUFLEN; i++)
-		adapter->fw_version[i] =
-			ioread8(&idev->dev_info->fw_version[i]);
-	adapter->fw_version[IONIC_DEVINFO_FWVERS_BUFLEN - 1] = '\0';
-
-	adapter->name = adapter->pci_dev->device.name;
-
-	IONIC_PRINT(DEBUG, "%s firmware version: %s",
-		adapter->name, adapter->fw_version);
-
-	/* BAR1: doorbells */
-	bar++;
-	if (num_bars < 2) {
-		IONIC_PRINT(ERR, "Doorbell bar missing, aborting");
-		return -EFAULT;
-	}
-
-	idev->db_pages = bar->vaddr;
-
-	return 0;
-}
-
 /* Devcmd Interface */
 
 uint8_t
diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h
index 600d8f4abd..3b8e9fc3c2 100644
--- a/drivers/net/ionic/ionic_dev.h
+++ b/drivers/net/ionic/ionic_dev.h
@@ -173,14 +173,23 @@ struct ionic_cq {
 struct ionic_lif;
 struct ionic_adapter;
 struct ionic_qcq;
+struct rte_mempool;
+struct rte_eth_dev;
+
+struct ionic_dev_intf {
+	int  (*setup)(struct ionic_adapter *adapter);
+	void (*copy_bus_info)(struct ionic_adapter *adapter,
+			struct rte_eth_dev *eth_dev);
+	int  (*configure_intr)(struct ionic_adapter *adapter);
+	void (*unconfigure_intr)(struct ionic_adapter *adapter);
+	void (*unmap_bars)(struct ionic_adapter *adapter);
+};
 
 void ionic_intr_init(struct ionic_dev *idev, struct ionic_intr_info *intr,
 	unsigned long index);
 
 const char *ionic_opcode_to_str(enum ionic_cmd_opcode opcode);
 
-int ionic_dev_setup(struct ionic_adapter *adapter);
-
 void ionic_dev_cmd_go(struct ionic_dev *idev, union ionic_dev_cmd *cmd);
 uint8_t ionic_dev_cmd_status(struct ionic_dev *idev);
 bool ionic_dev_cmd_done(struct ionic_dev *idev);
diff --git a/drivers/net/ionic/ionic_dev_pci.c b/drivers/net/ionic/ionic_dev_pci.c
new file mode 100644
index 0000000000..1735fa9b17
--- /dev/null
+++ b/drivers/net/ionic/ionic_dev_pci.c
@@ -0,0 +1,216 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018-2022 Advanced Micro Devices, Inc. All Rights Reserved.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdint.h>
+
+#include <rte_common.h>
+#include <rte_interrupts.h>
+#include <rte_log.h>
+#include <rte_pci.h>
+#include <bus_pci_driver.h>
+#include <rte_eal.h>
+#include <ethdev_pci.h>
+#include <rte_dev.h>
+
+#include "ionic.h"
+#include "ionic_if.h"
+#include "ionic_dev.h"
+#include "ionic_ethdev.h"
+#include "ionic_logs.h"
+
+static const struct rte_pci_id pci_id_ionic_map[] = {
+	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_PF) },
+	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_VF) },
+	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_MGMT) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+static int
+ionic_pci_setup(struct ionic_adapter *adapter)
+{
+	struct ionic_dev_bar *bar = adapter->bars.bar;
+	unsigned int num_bars = adapter->bars.num_bars;
+	struct ionic_dev *idev = &adapter->idev;
+	struct rte_pci_device *bus_dev = adapter->bus_dev;
+	uint32_t sig;
+	u_char *bar0_base;
+	unsigned int i;
+
+	/* BAR0: dev_cmd and interrupts */
+	if (num_bars < 1) {
+		IONIC_PRINT(ERR, "No bars found, aborting\n");
+		return -EFAULT;
+	}
+
+	if (bar->len < IONIC_BAR0_SIZE) {
+		IONIC_PRINT(ERR,
+			"Resource bar size %lu too small, aborting\n",
+			bar->len);
+		return -EFAULT;
+	}
+
+	bar0_base = bar->vaddr;
+	idev->dev_info = (union ionic_dev_info_regs *)
+		&bar0_base[IONIC_BAR0_DEV_INFO_REGS_OFFSET];
+	idev->dev_cmd = (union ionic_dev_cmd_regs *)
+		&bar0_base[IONIC_BAR0_DEV_CMD_REGS_OFFSET];
+	idev->intr_status = (struct ionic_intr_status *)
+		&bar0_base[IONIC_BAR0_INTR_STATUS_OFFSET];
+	idev->intr_ctrl = (struct ionic_intr *)
+		&bar0_base[IONIC_BAR0_INTR_CTRL_OFFSET];
+
+	sig = ioread32(&idev->dev_info->signature);
+	if (sig != IONIC_DEV_INFO_SIGNATURE) {
+		IONIC_PRINT(ERR, "Incompatible firmware signature %#x",
+			sig);
+		return -EFAULT;
+	}
+
+	for (i = 0; i < IONIC_DEVINFO_FWVERS_BUFLEN; i++)
+		adapter->fw_version[i] =
+			ioread8(&idev->dev_info->fw_version[i]);
+	adapter->fw_version[IONIC_DEVINFO_FWVERS_BUFLEN - 1] = '\0';
+
+	adapter->name = bus_dev->device.name;
+
+	IONIC_PRINT(DEBUG, "%s firmware version: %s",
+		adapter->name, adapter->fw_version);
+
+	/* BAR1: doorbells */
+	bar++;
+	if (num_bars < 2) {
+		IONIC_PRINT(ERR, "Doorbell bar missing, aborting\n");
+		return -EFAULT;
+	}
+
+	idev->db_pages = bar->vaddr;
+
+	return 0;
+}
+
+static void
+ionic_pci_copy_bus_info(struct ionic_adapter *adapter,
+	struct rte_eth_dev *eth_dev)
+{
+	rte_eth_copy_pci_info(eth_dev, adapter->bus_dev);
+}
+
+static int
+ionic_pci_configure_intr(struct ionic_adapter *adapter)
+{
+	struct rte_pci_device *pci_dev =
+		(struct rte_pci_device *)(adapter->bus_dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+	int err;
+
+	IONIC_PRINT(ERR, "Configuring %u intrs", adapter->nintrs);
+
+	if (rte_intr_efd_enable(intr_handle, adapter->nintrs)) {
+		IONIC_PRINT(ERR, "Fail to create eventfd");
+		return -1;
+	}
+
+	if (rte_intr_dp_is_en(intr_handle)) {
+		IONIC_PRINT(NOTICE,
+			"Packet I/O interrupt on datapath is enabled");
+		if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
+						adapter->nintrs)) {
+			IONIC_PRINT(ERR, "Failed to allocate %u vectors",
+						adapter->nintrs);
+			return -ENOMEM;
+		}
+	}
+
+	err = rte_intr_callback_register(intr_handle,
+		ionic_dev_interrupt_handler,
+		adapter);
+	if (err) {
+		IONIC_PRINT(ERR,
+			"Failure registering interrupts handler (%d)", err);
+		return err;
+	}
+
+	/* enable intr mapping */
+	err = rte_intr_enable(intr_handle);
+	if (err) {
+		IONIC_PRINT(ERR, "Failure enabling interrupts (%d)", err);
+		return err;
+	}
+
+	return 0;
+}
+
+static void
+ionic_pci_unconfigure_intr(struct ionic_adapter *adapter)
+{
+	struct rte_pci_device *pci_dev =
+		(struct rte_pci_device *)(adapter->bus_dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+
+	rte_intr_disable(intr_handle);
+
+	rte_intr_callback_unregister(intr_handle,
+		ionic_dev_interrupt_handler,
+		adapter);
+}
+
+static const struct ionic_dev_intf ionic_pci_intf = {
+	.setup = ionic_pci_setup,
+	.copy_bus_info = ionic_pci_copy_bus_info,
+	.configure_intr = ionic_pci_configure_intr,
+	.unconfigure_intr = ionic_pci_unconfigure_intr,
+};
+
+static int
+eth_ionic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+		struct rte_pci_device *pci_dev)
+{
+	struct rte_mem_resource *resource;
+	struct ionic_bars bars;
+	unsigned long i;
+
+	IONIC_PRINT(NOTICE, "Initializing device %s %s",
+		pci_dev->device.name,
+		rte_eal_process_type() == RTE_PROC_SECONDARY ?
+		"[SECONDARY]" : "");
+
+	bars.num_bars = 0;
+	for (i = 0; i < PCI_MAX_RESOURCE && i < IONIC_BARS_MAX; i++) {
+		resource = &pci_dev->mem_resource[i];
+		if (resource->phys_addr == 0 || resource->len == 0)
+			continue;
+
+		bars.bar[bars.num_bars].vaddr = resource->addr;
+		bars.bar[bars.num_bars].bus_addr = resource->phys_addr;
+		bars.bar[bars.num_bars].len = resource->len;
+		bars.num_bars++;
+	}
+
+	return eth_ionic_dev_probe((void *)pci_dev,
+			&pci_dev->device,
+			&bars,
+			&ionic_pci_intf,
+			pci_dev->id.device_id,
+			pci_dev->id.vendor_id);
+}
+
+static int
+eth_ionic_pci_remove(struct rte_pci_device *pci_dev)
+{
+	return eth_ionic_dev_remove(&pci_dev->device);
+}
+
+static struct rte_pci_driver rte_pci_ionic_pmd = {
+	.id_table = pci_id_ionic_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+	.probe = eth_ionic_pci_probe,
+	.remove = eth_ionic_pci_remove,
+};
+
+RTE_PMD_REGISTER_PCI(net_ionic_pci, rte_pci_ionic_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_ionic_pci, pci_id_ionic_map);
+RTE_PMD_REGISTER_KMOD_DEP(net_ionic_pci, "* igb_uio | uio_pci_generic | vfio-pci");
diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index efea691b8f..186cde8330 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -2,12 +2,9 @@
  * Copyright 2018-2022 Advanced Micro Devices, Inc. All Rights Reserved.
  */
 
-#include <rte_pci.h>
-#include <bus_pci_driver.h>
 #include <rte_ethdev.h>
 #include <ethdev_driver.h>
 #include <rte_malloc.h>
-#include <ethdev_pci.h>
 
 #include "ionic_logs.h"
 #include "ionic.h"
@@ -57,13 +54,6 @@ static int  ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 static int  ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev,
 	char *fw_version, size_t fw_size);
 
-static const struct rte_pci_id pci_id_ionic_map[] = {
-	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_PF) },
-	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_VF) },
-	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_MGMT) },
-	{ .vendor_id = 0, /* sentinel */ },
-};
-
 static const struct rte_eth_desc_lim rx_desc_lim = {
 	.nb_max = IONIC_MAX_RING_DESC,
 	.nb_min = IONIC_MIN_RING_DESC,
@@ -328,7 +318,7 @@ ionic_dev_link_update(struct rte_eth_dev *eth_dev,
  * @return
  *  void
  */
-static void
+void
 ionic_dev_interrupt_handler(void *param)
 {
 	struct ionic_adapter *adapter = (struct ionic_adapter *)param;
@@ -946,8 +936,6 @@ ionic_dev_stop(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
-static void ionic_unconfigure_intr(struct ionic_adapter *adapter);
-
 /*
  * Reset and stop device.
  */
@@ -966,22 +954,24 @@ ionic_dev_close(struct rte_eth_dev *eth_dev)
 	ionic_lif_free_queues(lif);
 
 	IONIC_PRINT(NOTICE, "Removing device %s", eth_dev->device->name);
-	ionic_unconfigure_intr(adapter);
+	if (adapter->intf->unconfigure_intr)
+		(*adapter->intf->unconfigure_intr)(adapter);
 
 	rte_eth_dev_destroy(eth_dev, eth_ionic_dev_uninit);
 
 	ionic_port_reset(adapter);
 	ionic_reset(adapter);
+	if (adapter->intf->unmap_bars)
+		(*adapter->intf->unmap_bars)(adapter);
 
 	rte_free(adapter);
 
 	return 0;
 }
 
-static int
+int
 eth_ionic_dev_init(struct rte_eth_dev *eth_dev, void *init_params)
 {
-	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 	struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
 	struct ionic_adapter *adapter = (struct ionic_adapter *)init_params;
 	int err;
@@ -997,7 +987,8 @@ eth_ionic_dev_init(struct rte_eth_dev *eth_dev, void *init_params)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	rte_eth_copy_pci_info(eth_dev, pci_dev);
+	if (adapter->intf->copy_bus_info)
+		(*adapter->intf->copy_bus_info)(adapter, eth_dev);
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
 	lif->eth_dev = eth_dev;
@@ -1068,73 +1059,12 @@ eth_ionic_dev_uninit(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
-static int
-ionic_configure_intr(struct ionic_adapter *adapter)
-{
-	struct rte_pci_device *pci_dev = adapter->pci_dev;
-	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
-	int err;
-
-	IONIC_PRINT(DEBUG, "Configuring %u intrs", adapter->nintrs);
-
-	if (rte_intr_efd_enable(intr_handle, adapter->nintrs)) {
-		IONIC_PRINT(ERR, "Fail to create eventfd");
-		return -1;
-	}
-
-	if (rte_intr_dp_is_en(intr_handle)) {
-		IONIC_PRINT(DEBUG,
-			"Packet I/O interrupt on datapath is enabled");
-
-		if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
-						adapter->nintrs)) {
-			IONIC_PRINT(ERR, "Failed to allocate %u vectors",
-				adapter->nintrs);
-			return -ENOMEM;
-		}
-	}
-
-	err = rte_intr_callback_register(intr_handle,
-		ionic_dev_interrupt_handler,
-		adapter);
-
-	if (err) {
-		IONIC_PRINT(ERR,
-			"Failure registering interrupts handler (%d)",
-			err);
-		return err;
-	}
-
-	/* enable intr mapping */
-	err = rte_intr_enable(intr_handle);
-
-	if (err) {
-		IONIC_PRINT(ERR, "Failure enabling interrupts (%d)", err);
-		return err;
-	}
-
-	return 0;
-}
-
-static void
-ionic_unconfigure_intr(struct ionic_adapter *adapter)
-{
-	struct rte_pci_device *pci_dev = adapter->pci_dev;
-	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
-
-	rte_intr_disable(intr_handle);
-
-	rte_intr_callback_unregister(intr_handle,
-		ionic_dev_interrupt_handler,
-		adapter);
-}
-
-static int
-eth_ionic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
-		struct rte_pci_device *pci_dev)
+int
+eth_ionic_dev_probe(void *bus_dev, struct rte_device *rte_dev,
+	struct ionic_bars *bars, const struct ionic_dev_intf *intf,
+	uint16_t device_id, uint16_t vendor_id)
 {
 	char name[RTE_ETH_NAME_MAX_LEN];
-	struct rte_mem_resource *resource;
 	struct ionic_adapter *adapter;
 	struct ionic_hw *hw;
 	unsigned long i;
@@ -1149,9 +1079,6 @@ eth_ionic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		goto err;
 	}
 
-	IONIC_PRINT(DEBUG, "Initializing device %s",
-		pci_dev->device.name);
-
 	adapter = rte_zmalloc("ionic", sizeof(*adapter), 0);
 	if (!adapter) {
 		IONIC_PRINT(ERR, "OOM");
@@ -1159,11 +1086,12 @@ eth_ionic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		goto err;
 	}
 
-	adapter->pci_dev = pci_dev;
+	adapter->bus_dev = bus_dev;
 	hw = &adapter->hw;
 
-	hw->device_id = pci_dev->id.device_id;
-	hw->vendor_id = pci_dev->id.vendor_id;
+	/* Vendor and Device ID need to be set before init of shared code */
+	hw->device_id = device_id;
+	hw->vendor_id = vendor_id;
 
 	err = ionic_init_mac(hw);
 	if (err != 0) {
@@ -1172,19 +1100,21 @@ eth_ionic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		goto err_free_adapter;
 	}
 
-	adapter->num_bars = 0;
-	for (i = 0; i < PCI_MAX_RESOURCE && i < IONIC_BARS_MAX; i++) {
-		resource = &pci_dev->mem_resource[i];
-		if (resource->phys_addr == 0 || resource->len == 0)
-			continue;
-		adapter->bars[adapter->num_bars].vaddr = resource->addr;
-		adapter->bars[adapter->num_bars].bus_addr = resource->phys_addr;
-		adapter->bars[adapter->num_bars].len = resource->len;
-		adapter->num_bars++;
+	adapter->bars.num_bars = bars->num_bars;
+	for (i = 0; i < bars->num_bars; i++) {
+		adapter->bars.bar[i].vaddr = bars->bar[i].vaddr;
+		adapter->bars.bar[i].bus_addr = bars->bar[i].bus_addr;
+		adapter->bars.bar[i].len = bars->bar[i].len;
 	}
 
-	/* Discover ionic dev resources */
+	if (intf->setup == NULL) {
+		IONIC_PRINT(ERR, "Device setup function is mandatory");
+		goto err_free_adapter;
+	}
+
+	adapter->intf = intf;
 
+	/* Discover ionic dev resources */
 	err = ionic_setup(adapter);
 	if (err) {
 		IONIC_PRINT(ERR, "Cannot setup device: %d, aborting", err);
@@ -1241,20 +1171,20 @@ eth_ionic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		goto err_free_adapter;
 	}
 
-	snprintf(name, sizeof(name), "%s_lif", pci_dev->device.name);
-	err = rte_eth_dev_create(&pci_dev->device,
-			name, sizeof(struct ionic_lif),
+	snprintf(name, sizeof(name), "%s_lif", rte_dev->name);
+	err = rte_eth_dev_create(rte_dev, name, sizeof(struct ionic_lif),
 			NULL, NULL, eth_ionic_dev_init, adapter);
 	if (err) {
 		IONIC_PRINT(ERR, "Cannot create eth device for %s", name);
 		goto err_free_adapter;
 	}
 
-	err = ionic_configure_intr(adapter);
-
-	if (err) {
-		IONIC_PRINT(ERR, "Failed to configure interrupts");
-		goto err_free_adapter;
+	if (adapter->intf->configure_intr) {
+		err = (*adapter->intf->configure_intr)(adapter);
+		if (err) {
+			IONIC_PRINT(ERR, "Failed to configure interrupts");
+			goto err_free_adapter;
+		}
 	}
 
 	return 0;
@@ -1265,33 +1195,22 @@ eth_ionic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	return err;
 }
 
-static int
-eth_ionic_pci_remove(struct rte_pci_device *pci_dev)
+int
+eth_ionic_dev_remove(struct rte_device *rte_dev)
 {
 	char name[RTE_ETH_NAME_MAX_LEN];
 	struct rte_eth_dev *eth_dev;
 
 	/* Adapter lookup is using the eth_dev name */
-	snprintf(name, sizeof(name), "%s_lif", pci_dev->device.name);
+	snprintf(name, sizeof(name), "%s_lif", rte_dev->name);
 
 	eth_dev = rte_eth_dev_allocated(name);
 	if (eth_dev)
 		ionic_dev_close(eth_dev);
 	else
-		IONIC_PRINT(DEBUG, "Cannot find device %s",
-			pci_dev->device.name);
+		IONIC_PRINT(DEBUG, "Cannot find device %s", rte_dev->name);
 
 	return 0;
 }
 
-static struct rte_pci_driver rte_ionic_pmd = {
-	.id_table = pci_id_ionic_map,
-	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
-	.probe = eth_ionic_pci_probe,
-	.remove = eth_ionic_pci_remove,
-};
-
-RTE_PMD_REGISTER_PCI(net_ionic, rte_ionic_pmd);
-RTE_PMD_REGISTER_PCI_TABLE(net_ionic, pci_id_ionic_map);
-RTE_PMD_REGISTER_KMOD_DEP(net_ionic, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_LOG_REGISTER_DEFAULT(ionic_logtype, NOTICE);
diff --git a/drivers/net/ionic/ionic_ethdev.h b/drivers/net/ionic/ionic_ethdev.h
index f4a4276d33..c5726408de 100644
--- a/drivers/net/ionic/ionic_ethdev.h
+++ b/drivers/net/ionic/ionic_ethdev.h
@@ -18,6 +18,15 @@
 #define IONIC_ETH_DEV_TO_LIF(eth_dev) ((struct ionic_lif *) \
 	(eth_dev)->data->dev_private)
 
+struct ionic_bars;
+struct ionic_dev_intf;
+
+int eth_ionic_dev_probe(void *bus_dev, struct rte_device *rte_dev,
+	struct ionic_bars *bars, const struct ionic_dev_intf *intf,
+	uint16_t device_id, uint16_t vendor_id);
+int eth_ionic_dev_remove(struct rte_device *rte_dev);
+
+void ionic_dev_interrupt_handler(void *param);
 int ionic_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete);
 
 #endif /* _IONIC_ETHDEV_H_ */
diff --git a/drivers/net/ionic/ionic_main.c b/drivers/net/ionic/ionic_main.c
index b42430713c..996af0a51f 100644
--- a/drivers/net/ionic/ionic_main.c
+++ b/drivers/net/ionic/ionic_main.c
@@ -336,7 +336,7 @@ ionic_dev_cmd_wait_check(struct ionic_dev *idev, unsigned long max_wait)
 int
 ionic_setup(struct ionic_adapter *adapter)
 {
-	return ionic_dev_setup(adapter);
+	return (*adapter->intf->setup)(adapter);
 }
 
 int
diff --git a/drivers/net/ionic/meson.build b/drivers/net/ionic/meson.build
index e251e7cbe0..2869e0027c 100644
--- a/drivers/net/ionic/meson.build
+++ b/drivers/net/ionic/meson.build
@@ -9,6 +9,7 @@ endif
 
 sources = files(
         'ionic_dev.c',
+        'ionic_dev_pci.c',
         'ionic_ethdev.c',
         'ionic_lif.c',
         'ionic_mac_api.c',
-- 
2.17.1


  parent reply	other threads:[~2022-10-11  0:52 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-07 17:43 [PATCH 00/35] net/ionic: updates for 22.11 release Andrew Boyer
2022-10-07 17:43 ` [PATCH 01/35] net/ionic: fix up endianness for Rx and Tx handling Andrew Boyer
2022-10-07 17:43 ` [PATCH 02/35] net/ionic: fix up endianness for RSS Andrew Boyer
2022-10-07 17:43 ` [PATCH 03/35] net/ionic: fix to set the adapter name for logging Andrew Boyer
2022-10-07 17:43 ` [PATCH 04/35] net/ionic: fix up the Rx filter save API Andrew Boyer
2022-10-07 17:43 ` [PATCH 05/35] net/ionic: fix up reported error stats Andrew Boyer
2022-10-07 17:43 ` [PATCH 06/35] net/ionic: update documentation and copyrights Andrew Boyer
2022-10-18 17:02   ` Ferruh Yigit
2022-10-07 17:43 ` [PATCH 07/35] net/ionic: update license terms to remove GPL Andrew Boyer
2022-10-18 17:02   ` Ferruh Yigit
2022-10-07 17:43 ` [PATCH 08/35] net/ionic: update MTU calculations Andrew Boyer
2022-10-07 17:43 ` [PATCH 09/35] net/ionic: simplify code by removing doorbell map helper Andrew Boyer
2022-10-07 17:43 ` [PATCH 10/35] net/ionic: remove unused identifiers Andrew Boyer
2022-10-07 17:43 ` [PATCH 11/35] net/ionic: only allocate interrupts if required Andrew Boyer
2022-10-07 17:43 ` [PATCH 12/35] net/ionic: move PCI-specific code to a separate file Andrew Boyer
2022-10-07 17:43 ` [PATCH 13/35] net/ionic: only request notifyq interrupt if supported Andrew Boyer
2022-10-07 17:43 ` [PATCH 14/35] net/ionic: replace void pointer with actual type Andrew Boyer
2022-10-07 17:43 ` [PATCH 15/35] net/ionic: free all buffers during Rx queue stop Andrew Boyer
2022-10-07 17:43 ` [PATCH 16/35] net/ionic: precalculate segment lengths on receive side Andrew Boyer
2022-10-07 17:43 ` [PATCH 17/35] net/ionic: use a helper variable in packet Tx function Andrew Boyer
2022-10-07 17:43 ` [PATCH 18/35] net/ionic: do one-time init of receive descriptors Andrew Boyer
2022-10-07 17:43 ` [PATCH 19/35] net/ionic: overhaul receive side for performance Andrew Boyer
2022-10-07 17:43 ` [PATCH 20/35] net/ionic: overhaul transmit " Andrew Boyer
2022-10-07 17:43 ` [PATCH 21/35] net/ionic: add support for mbuf fast free Andrew Boyer
2022-10-07 17:43 ` [PATCH 22/35] net/ionic: do bulk allocations of receive mbufs Andrew Boyer
2022-10-07 17:43 ` [PATCH 23/35] net/ionic: add a lookup table for packet type Andrew Boyer
2022-10-07 17:43 ` [PATCH 24/35] net/ionic: add a lookup table for checksum flags Andrew Boyer
2022-10-07 17:43 ` [PATCH 25/35] net/ionic: advertise supported packet types Andrew Boyer
2022-10-07 17:43 ` [PATCH 26/35] net/ionic: add Rx descriptor status functions Andrew Boyer
2022-10-07 17:43 ` [PATCH 27/35] net/ionic: add Tx descriptor status function Andrew Boyer
2022-10-07 17:43 ` [PATCH 28/35] net/ionic: add Q-in-CMB option controlled by devarg Andrew Boyer
2022-10-07 17:43 ` [PATCH 29/35] net/ionic: update array allocations to use calloc Andrew Boyer
2022-10-07 17:43 ` [PATCH 30/35] net/ionic: add alignment and socket info in allocations Andrew Boyer
2022-10-07 17:43 ` [PATCH 31/35] net/ionic: allow client to specify Tx free threshold Andrew Boyer
2022-10-07 17:43 ` [PATCH 32/35] net/ionic: add optimized handlers for non-scattered Rx/Tx Andrew Boyer
2022-10-07 17:43 ` [PATCH 33/35] net/ionic: use a helper variable for page size Andrew Boyer
2022-10-07 17:43 ` [PATCH 34/35] net/ionic: retry init commands up to five times Andrew Boyer
2022-10-07 17:43 ` [PATCH 35/35] net/ionic: add watchdogs to protect each queue type Andrew Boyer
2022-10-11  0:49 ` [PATCH v1 00/35] net/ionic: updates for 22.11 release Andrew Boyer
2022-10-18 17:05   ` Ferruh Yigit
2022-10-18 19:40   ` [PATCH v2 00/36] " Andrew Boyer
2022-10-18 21:56     ` Ferruh Yigit
2022-10-18 19:40   ` [PATCH v2 01/36] net/ionic: fix up endianness for Rx and Tx handling Andrew Boyer
2022-10-18 19:40   ` [PATCH v2 02/36] net/ionic: fix up endianness for RSS Andrew Boyer
2022-10-18 19:40   ` [PATCH v2 03/36] net/ionic: fix to set the adapter name for logging Andrew Boyer
2022-10-18 19:40   ` [PATCH v2 04/36] net/ionic: fix up the Rx filter save API Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 05/36] net/ionic: fix up reported error stats Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 06/36] net/ionic: update documentation and copyrights Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 07/36] net/ionic: update supported devices list Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 08/36] net/ionic: update license terms to remove GPL Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 09/36] net/ionic: update MTU calculations Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 10/36] net/ionic: simplify code by removing doorbell map helper Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 11/36] net/ionic: remove unused identifiers Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 12/36] net/ionic: only allocate interrupts if required Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 13/36] net/ionic: move PCI-specific code to a separate file Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 14/36] net/ionic: only request notifyq interrupt if supported Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 15/36] net/ionic: replace void pointer with actual type Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 16/36] net/ionic: free all buffers during Rx queue stop Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 17/36] net/ionic: precalculate segment lengths on receive side Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 18/36] net/ionic: use a helper variable in packet Tx function Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 19/36] net/ionic: do one-time init of receive descriptors Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 20/36] net/ionic: overhaul receive side for performance Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 21/36] net/ionic: overhaul transmit " Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 22/36] net/ionic: add support for mbuf fast free Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 23/36] net/ionic: do bulk allocations of receive mbufs Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 24/36] net/ionic: add a lookup table for packet type Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 25/36] net/ionic: add a lookup table for checksum flags Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 26/36] net/ionic: advertise supported packet types Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 27/36] net/ionic: add Rx descriptor status functions Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 28/36] net/ionic: add Tx descriptor status function Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 29/36] net/ionic: add Q-in-CMB option controlled by devarg Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 30/36] net/ionic: update array allocations to use calloc Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 31/36] net/ionic: add alignment and socket info in allocations Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 32/36] net/ionic: allow client to specify Tx free threshold Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 33/36] net/ionic: add optimized handlers for non-scattered Rx/Tx Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 34/36] net/ionic: use a helper variable for page size Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 35/36] net/ionic: retry init commands up to five times Andrew Boyer
2022-10-18 19:41   ` [PATCH v2 36/36] net/ionic: add watchdogs to protect each queue type Andrew Boyer
2022-10-11  0:49 ` [PATCH v1 01/35] net/ionic: fix up endianness for Rx and Tx handling Andrew Boyer
2022-10-11  0:49 ` [PATCH v1 02/35] net/ionic: fix up endianness for RSS Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 03/35] net/ionic: fix to set the adapter name for logging Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 04/35] net/ionic: fix up the Rx filter save API Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 05/35] net/ionic: fix up reported error stats Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 06/35] net/ionic: update documentation and copyrights Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 07/35] net/ionic: update license terms to remove GPL Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 08/35] net/ionic: update MTU calculations Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 09/35] net/ionic: simplify code by removing doorbell map helper Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 10/35] net/ionic: remove unused identifiers Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 11/35] net/ionic: only allocate interrupts if required Andrew Boyer
2022-10-11  0:50 ` Andrew Boyer [this message]
2022-10-11  0:50 ` [PATCH v1 13/35] net/ionic: only request notifyq interrupt if supported Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 14/35] net/ionic: replace void pointer with actual type Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 15/35] net/ionic: free all buffers during Rx queue stop Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 16/35] net/ionic: precalculate segment lengths on receive side Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 17/35] net/ionic: use a helper variable in packet Tx function Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 18/35] net/ionic: do one-time init of receive descriptors Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 19/35] net/ionic: overhaul receive side for performance Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 20/35] net/ionic: overhaul transmit " Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 21/35] net/ionic: add support for mbuf fast free Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 22/35] net/ionic: do bulk allocations of receive mbufs Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 23/35] net/ionic: add a lookup table for packet type Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 24/35] net/ionic: add a lookup table for checksum flags Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 25/35] net/ionic: advertise supported packet types Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 26/35] net/ionic: add Rx descriptor status functions Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 27/35] net/ionic: add Tx descriptor status function Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 28/35] net/ionic: add Q-in-CMB option controlled by devarg Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 29/35] net/ionic: update array allocations to use calloc Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 30/35] net/ionic: add alignment and socket info in allocations Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 31/35] net/ionic: allow client to specify Tx free threshold Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 32/35] net/ionic: add optimized handlers for non-scattered Rx/Tx Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 33/35] net/ionic: use a helper variable for page size Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 34/35] net/ionic: retry init commands up to five times Andrew Boyer
2022-10-11  0:50 ` [PATCH v1 35/35] net/ionic: add watchdogs to protect each queue type Andrew Boyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221011005032.47584-13-andrew.boyer@amd.com \
    --to=andrew.boyer@amd.com \
    --cc=dev@dpdk.org \
    --cc=mohamedshah.r@amd.com \
    --cc=neel.patel@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).