DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, bruce.richardson@intel.com,
	andremue@linux.microsoft.com,
	Nagadheeraj Rottela <rnagadheeraj@marvell.com>,
	Srikanth Jampala <jsrikanth@marvell.com>,
	Fan Zhang <fanzhang.oss@gmail.com>,
	Ashish Gupta <ashish.gupta@marvell.com>
Subject: [RFC 03/10] drivers: remove weak symbols in Nitrox drivers
Date: Fri,  7 Feb 2025 09:32:43 +0100	[thread overview]
Message-ID: <20250207083252.3131588-4-david.marchand@redhat.com> (raw)
In-Reply-To: <20250207083252.3131588-1-david.marchand@redhat.com>

Make compress and crypto drivers register to the common driver.
Remove (unneeded) include_directories().

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/common/nitrox/meson.build     |  3 --
 drivers/common/nitrox/nitrox_device.c | 75 ++++++++++-----------------
 drivers/common/nitrox/nitrox_device.h | 16 ++++++
 drivers/common/nitrox/version.map     |  1 +
 drivers/compress/nitrox/meson.build   |  2 -
 drivers/compress/nitrox/nitrox_comp.c |  6 +++
 drivers/crypto/nitrox/meson.build     |  2 -
 drivers/crypto/nitrox/nitrox_sym.c    |  6 +++
 8 files changed, 57 insertions(+), 54 deletions(-)

diff --git a/drivers/common/nitrox/meson.build b/drivers/common/nitrox/meson.build
index f3cb42f006..115dd8de4d 100644
--- a/drivers/common/nitrox/meson.build
+++ b/drivers/common/nitrox/meson.build
@@ -14,6 +14,3 @@ sources += files(
         'nitrox_logs.c',
         'nitrox_qp.c',
 )
-
-includes += include_directories('../../crypto/nitrox')
-includes += include_directories('../../compress/nitrox')
diff --git a/drivers/common/nitrox/nitrox_device.c b/drivers/common/nitrox/nitrox_device.c
index 39edc440a7..6cd57faaa4 100644
--- a/drivers/common/nitrox/nitrox_device.c
+++ b/drivers/common/nitrox/nitrox_device.c
@@ -6,8 +6,6 @@
 
 #include "nitrox_device.h"
 #include "nitrox_hal.h"
-#include "nitrox_sym.h"
-#include "nitrox_comp.h"
 
 #define PCI_VENDOR_ID_CAVIUM	0x177d
 #define NITROX_V_PCI_VF_DEV_ID	0x13
@@ -63,11 +61,21 @@ ndev_release(struct nitrox_device *ndev)
 	rte_free(ndev);
 }
 
+TAILQ_HEAD(ndrv_list, nitrox_driver);
+static struct ndrv_list ndrv_list = TAILQ_HEAD_INITIALIZER(ndrv_list);
+
+void
+nitrox_register_driver(struct nitrox_driver *ndrv)
+{
+	TAILQ_INSERT_TAIL(&ndrv_list, ndrv, next);
+}
+
 static int
 nitrox_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		struct rte_pci_device *pdev)
 {
 	struct nitrox_device *ndev;
+	struct nitrox_driver *ndrv;
 	int err = -1;
 
 	/* Nitrox CSR space */
@@ -79,19 +87,21 @@ nitrox_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		return -ENOMEM;
 
 	ndev_init(ndev, pdev);
-	err = nitrox_sym_pmd_create(ndev);
-	if (err)
-		goto sym_pmd_err;
-
-	err = nitrox_comp_pmd_create(ndev);
-	if (err)
-		goto comp_pmd_err;
+	TAILQ_FOREACH(ndrv, &ndrv_list, next) {
+		err = ndrv->create(ndev);
+		if (err)
+			goto drv_err;
+	}
 
 	return 0;
 
-comp_pmd_err:
-	nitrox_sym_pmd_destroy(ndev);
-sym_pmd_err:
+drv_err:
+	ndrv = TAILQ_PREV(ndrv, ndrv_list, next);
+	while (ndrv != NULL) {
+		ndrv->destroy(ndev);
+		ndrv = TAILQ_PREV(ndrv, ndrv_list, next);
+	}
+
 	ndev_release(ndev);
 	return err;
 }
@@ -100,19 +110,18 @@ static int
 nitrox_pci_remove(struct rte_pci_device *pdev)
 {
 	struct nitrox_device *ndev;
+	struct nitrox_driver *ndrv;
 	int err;
 
 	ndev = find_ndev(pdev);
 	if (!ndev)
 		return -ENODEV;
 
-	err = nitrox_sym_pmd_destroy(ndev);
-	if (err)
-		return err;
-
-	err = nitrox_comp_pmd_destroy(ndev);
-	if (err)
-		return err;
+	TAILQ_FOREACH(ndrv, &ndrv_list, next) {
+		err = ndrv->destroy(ndev);
+		if (err)
+			return err;
+	}
 
 	ndev_release(ndev);
 	return 0;
@@ -133,33 +142,5 @@ static struct rte_pci_driver nitrox_pmd = {
 	.remove         = nitrox_pci_remove,
 };
 
-__rte_weak int
-nitrox_sym_pmd_create(struct nitrox_device *ndev)
-{
-	RTE_SET_USED(ndev);
-	return 0;
-}
-
-__rte_weak int
-nitrox_sym_pmd_destroy(struct nitrox_device *ndev)
-{
-	RTE_SET_USED(ndev);
-	return 0;
-}
-
-__rte_weak int
-nitrox_comp_pmd_create(struct nitrox_device *ndev)
-{
-	RTE_SET_USED(ndev);
-	return 0;
-}
-
-__rte_weak int
-nitrox_comp_pmd_destroy(struct nitrox_device *ndev)
-{
-	RTE_SET_USED(ndev);
-	return 0;
-}
-
 RTE_PMD_REGISTER_PCI(nitrox, nitrox_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(nitrox, pci_id_nitrox_map);
diff --git a/drivers/common/nitrox/nitrox_device.h b/drivers/common/nitrox/nitrox_device.h
index 877bccb321..b74b71808e 100644
--- a/drivers/common/nitrox/nitrox_device.h
+++ b/drivers/common/nitrox/nitrox_device.h
@@ -6,6 +6,7 @@
 #define _NITROX_DEVICE_H_
 
 #include <bus_pci_driver.h>
+#include <rte_compat.h>
 
 struct nitrox_sym_device;
 struct nitrox_comp_device;
@@ -21,4 +22,19 @@ struct nitrox_device {
 	uint16_t nr_queues;
 };
 
+struct nitrox_driver {
+	TAILQ_ENTRY(nitrox_driver) next;
+	int (*create)(struct nitrox_device *ndev);
+	int (*destroy)(struct nitrox_device *ndev);
+};
+
+__rte_internal
+void nitrox_register_driver(struct nitrox_driver *ndrv);
+
+#define NITROX_REGISTER_DRIVER(ndrv) \
+RTE_INIT(ndrv ## _register) \
+{ \
+	nitrox_register_driver(&ndrv); \
+}
+
 #endif /* _NITROX_DEVICE_H_ */
diff --git a/drivers/common/nitrox/version.map b/drivers/common/nitrox/version.map
index 43295171e4..f58c044fc5 100644
--- a/drivers/common/nitrox/version.map
+++ b/drivers/common/nitrox/version.map
@@ -4,6 +4,7 @@ INTERNAL {
 	nitrox_logtype;
 	nitrox_qp_release;
 	nitrox_qp_setup;
+	nitrox_register_driver;
 
 	local: *;
 };
diff --git a/drivers/compress/nitrox/meson.build b/drivers/compress/nitrox/meson.build
index 1becc66912..5cecc2ad66 100644
--- a/drivers/compress/nitrox/meson.build
+++ b/drivers/compress/nitrox/meson.build
@@ -12,5 +12,3 @@ sources += files(
         'nitrox_comp.c',
         'nitrox_comp_reqmgr.c',
 )
-
-includes += include_directories('../../common/nitrox')
diff --git a/drivers/compress/nitrox/nitrox_comp.c b/drivers/compress/nitrox/nitrox_comp.c
index 1b2054c61a..41a3ee0de8 100644
--- a/drivers/compress/nitrox/nitrox_comp.c
+++ b/drivers/compress/nitrox/nitrox_comp.c
@@ -602,3 +602,9 @@ nitrox_comp_pmd_destroy(struct nitrox_device *ndev)
 	ndev->comp_dev = NULL;
 	return 0;
 }
+
+static struct nitrox_driver comp_drv = {
+	.create = nitrox_comp_pmd_create,
+	.destroy = nitrox_comp_pmd_destroy,
+};
+NITROX_REGISTER_DRIVER(comp_drv);
diff --git a/drivers/crypto/nitrox/meson.build b/drivers/crypto/nitrox/meson.build
index f8887713d2..cbe2b7d6dc 100644
--- a/drivers/crypto/nitrox/meson.build
+++ b/drivers/crypto/nitrox/meson.build
@@ -13,5 +13,3 @@ sources += files(
         'nitrox_sym_capabilities.c',
         'nitrox_sym_reqmgr.c',
 )
-
-includes += include_directories('../../common/nitrox')
diff --git a/drivers/crypto/nitrox/nitrox_sym.c b/drivers/crypto/nitrox/nitrox_sym.c
index da70121d91..7c2dc98a4b 100644
--- a/drivers/crypto/nitrox/nitrox_sym.c
+++ b/drivers/crypto/nitrox/nitrox_sym.c
@@ -798,6 +798,12 @@ nitrox_sym_pmd_destroy(struct nitrox_device *ndev)
 	return rte_cryptodev_pmd_destroy(ndev->sym_dev->cdev);
 }
 
+static struct nitrox_driver sym_drv = {
+	.create = nitrox_sym_pmd_create,
+	.destroy = nitrox_sym_pmd_destroy,
+};
+NITROX_REGISTER_DRIVER(sym_drv);
+
 static struct cryptodev_driver nitrox_crypto_drv;
 RTE_PMD_REGISTER_CRYPTO_DRIVER(nitrox_crypto_drv,
 		nitrox_rte_sym_drv,
-- 
2.48.1


  parent reply	other threads:[~2025-02-07  8:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-07  8:32 [RFC 00/10] Remove weak symbols David Marchand
2025-02-07  8:32 ` [RFC 01/10] bus/auxiliary: remove " David Marchand
2025-02-07  8:32 ` [RFC 02/10] common/qat: " David Marchand
2025-02-07  8:32 ` David Marchand [this message]
2025-02-07  8:32 ` [RFC 04/10] net/enic: " David Marchand
2025-02-07  8:32 ` [RFC 05/10] net/hns3: " David Marchand
2025-02-07  8:32 ` [RFC 06/10] net/fm10k: " David Marchand
2025-02-07  8:51   ` Bruce Richardson
2025-02-07  8:32 ` [RFC 07/10] net/nfp: " David Marchand
2025-02-07  8:44   ` Chaoyong He
2025-02-07  8:32 ` [RFC 08/10] net/virtio: " David Marchand
2025-02-07  8:32 ` [RFC 09/10] app/compress-perf: " David Marchand
2025-02-07  8:32 ` [RFC 10/10] eal: deprecate " David Marchand

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=20250207083252.3131588-4-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=andremue@linux.microsoft.com \
    --cc=ashish.gupta@marvell.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=jsrikanth@marvell.com \
    --cc=rnagadheeraj@marvell.com \
    --cc=thomas@monjalon.net \
    /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).