Skip to contentSkip to conversation

Cleanup rte_dpaa2_device

PATCH Superseded David Marchand 5 participants 22 messages Nov 8, 2025 – Nov 18, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Cleanup rte_dpaa2_device

The rte_dpaa2_device object keeps track of a device class object (cryptodev, dmadev, ethdev, rawdev) which is a layer violation.

Make use of the device class respective infrastructure and remove those back references.

Disclaimer: this series is untested as I don't have the hardware. I only based those changes on look at the code and other drivers.

Signature · 19 lines
David Marchand

David Marchand (5):
  crypto/dpaa2_sec: remove crypto device in bus device
  dma/dpaa2: remove DMA device in bus device
  net/dpaa2: remove dead code in loopback mode
  net/dpaa2: remove ethdev device in bus device
  bus/fslmc: remove raw device in bus device

 drivers/bus/fslmc/bus_fslmc_driver.h        |  6 ---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  8 ++--
 drivers/dma/dpaa2/dpaa2_qdma.c              |  9 ++--
 drivers/net/dpaa2/dpaa2_ethdev.c            |  6 ++-
 drivers/net/dpaa2/dpaa2_ethdev.h            |  6 ---
 drivers/net/dpaa2/dpaa2_recycle.c           | 50 ---------------------
 6 files changed, 14 insertions(+), 71 deletions(-)

-- 
2.51.0
#1 lore raw

PATCH 1/5 crypto/dpaa2_sec: remove crypto device in bus device

Calling rte_cryptodev_pmd_get_named_dev() is enough to retrieve the crypto device object.

This leaves no user of the cryptodev field in the fslmc device object.

---
 drivers/bus/fslmc/bus_fslmc_driver.h        | 1 -
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
index b6a6238a01..45c7a519f9 100644
@@ -99,7 +99,6 @@ struct rte_dpaa2_device {
 	struct rte_device device;           /**< Inherit core device */
 	union {
 		struct rte_eth_dev *eth_dev;        /**< ethernet device */
-		struct rte_cryptodev *cryptodev;    /**< Crypto Device */
 		struct rte_dma_dev *dmadev;          /**< DMA Device */
 		struct rte_rawdev *rawdev;          /**< Raw Device */
 	};
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +5 -3
index ca10d88da7..698548e6ea 100644
@@ -4503,8 +4503,6 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
 		return -ENOMEM;
 	}
 
-	dpaa2_dev->cryptodev = cryptodev;
-
 	if (dpaa2_svr_family == SVR_LX2160A)
 		rta_set_sec_era(RTA_SEC_ERA_10);
 	else
@@ -4526,10 +4524,14 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
 static int
 cryptodev_dpaa2_sec_remove(struct rte_dpaa2_device *dpaa2_dev)
 {
+	char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
 	struct rte_cryptodev *cryptodev;
 	int ret;
 
-	cryptodev = dpaa2_dev->cryptodev;
+	snprintf(cryptodev_name, sizeof(cryptodev_name), "dpsec-%d",
+			dpaa2_dev->object_id);
+
+	cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
 	if (cryptodev == NULL)
 		return -ENODEV;
 
Signature · 1 line
2.51.0
#2 lore raw

PATCH 2/5 dma/dpaa2: remove DMA device in bus device

In reply to David Marchand

A driver .dev_close op is automatically called when releasing a dma device.
Move device specific unitialisation in this driver .dev_close op.

This leaves no user of the dmadev field in the fslmc device object.

---
 drivers/bus/fslmc/bus_fslmc_driver.h | 1 -
 drivers/dma/dpaa2/dpaa2_qdma.c       | 9 +++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
index 45c7a519f9..efa88754a7 100644
@@ -99,7 +99,6 @@ struct rte_dpaa2_device {
 	struct rte_device device;           /**< Inherit core device */
 	union {
 		struct rte_eth_dev *eth_dev;        /**< ethernet device */
-		struct rte_dma_dev *dmadev;          /**< DMA Device */
 		struct rte_rawdev *rawdev;          /**< Raw Device */
 	};
 	enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
drivers/dma/dpaa2/dpaa2_qdma.c +5 -4
index 4be43d6bd9..beca464c72 100644
@@ -1455,6 +1455,9 @@ dpaa2_qdma_stop(struct rte_dma_dev *dev)
 	return 0;
 }
 
+static int
+dpaa2_dpdmai_dev_uninit(struct rte_dma_dev *dev);
+
 static int
 dpaa2_qdma_close(struct rte_dma_dev *dev)
 {
@@ -1505,6 +1508,8 @@ dpaa2_qdma_close(struct rte_dma_dev *dev)
 	/* Reset QDMA device structure */
 	qdma_dev->num_vqs = 0;
 
+	dpaa2_dpdmai_dev_uninit(dev);
+
 	return 0;
 }
 
@@ -1703,7 +1708,6 @@ dpaa2_qdma_probe(struct rte_dpaa2_driver *dpaa2_drv,
 		return -EINVAL;
 	}
 
-	dpaa2_dev->dmadev = dmadev;
 	dmadev->dev_ops = &dpaa2_qdma_ops;
 	dmadev->device = &dpaa2_dev->device;
 	dmadev->fp_obj->dev_private = dmadev->data->dev_private;
@@ -1727,13 +1731,10 @@ dpaa2_qdma_probe(struct rte_dpaa2_driver *dpaa2_drv,
 static int
 dpaa2_qdma_remove(struct rte_dpaa2_device *dpaa2_dev)
 {
-	struct rte_dma_dev *dmadev = dpaa2_dev->dmadev;
 	int ret;
 
 	DPAA2_QDMA_FUNC_TRACE();
 
-	dpaa2_dpdmai_dev_uninit(dmadev);
-
 	ret = rte_dma_pmd_release(dpaa2_dev->device.name);
 	if (ret)
 		DPAA2_QDMA_ERR("Device cleanup failed");
Signature · 1 line
2.51.0
#3 lore raw

PATCH 3/5 net/dpaa2: remove dead code in loopback mode

In reply to David Marchand

This code was never used.

Fixes f023d059769f ("net/dpaa2: support recycle loopback port")
---
 drivers/net/dpaa2/dpaa2_ethdev.h  |  6 ----
 drivers/net/dpaa2/dpaa2_recycle.c | 50 -------------------------------
 2 files changed, 56 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.h +0 -6
index 87a94bc15b..86b3022ddb 100644
@@ -531,12 +531,6 @@ int dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev);
 int dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev);
 int dpaa2_soft_parser_loaded(void);
 
-int dpaa2_dev_recycle_qp_setup(struct rte_dpaa2_device *dpaa2_dev,
-	uint16_t qidx, uint64_t cntx,
-	eth_rx_burst_t tx_lpbk, eth_tx_burst_t rx_lpbk,
-	struct dpaa2_queue **txq,
-	struct dpaa2_queue **rxq);
-
 void
 dpaa2_dev_mac_setup_stats(struct rte_eth_dev *dev);
 
drivers/net/dpaa2/dpaa2_recycle.c +0 -50

53 lines not on this page · raw message

Signature · 1 line
2.51.0
#4 lore raw

PATCH 4/5 net/dpaa2: remove ethdev device in bus device

In reply to David Marchand

Calling rte_eth_dev_allocated() is enough to retrieve the ethdev device object.

This leaves no user of the ethdev field in the fslmc device object.

---
 drivers/bus/fslmc/bus_fslmc_driver.h | 1 -
 drivers/net/dpaa2/dpaa2_ethdev.c     | 6 ++++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
index efa88754a7..094f885f59 100644
@@ -98,7 +98,6 @@ struct rte_dpaa2_device {
 	TAILQ_ENTRY(rte_dpaa2_device) next; /**< Next probed DPAA2 device. */
 	struct rte_device device;           /**< Inherit core device */
 	union {
-		struct rte_eth_dev *eth_dev;        /**< ethernet device */
 		struct rte_rawdev *rawdev;          /**< Raw Device */
 	};
 	enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
drivers/net/dpaa2/dpaa2_ethdev.c +4 -2
index 7da32ce856..2a26a02cb4 100644
@@ -3320,7 +3320,6 @@ rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv,
 
 	eth_dev->device = &dpaa2_dev->device;
 
-	dpaa2_dev->eth_dev = eth_dev;
 	eth_dev->data->rx_mbuf_alloc_failed = 0;
 
 	if (dpaa2_drv->drv_flags & RTE_DPAA2_DRV_INTR_LSC)
@@ -3349,7 +3348,10 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)
 	struct rte_eth_dev *eth_dev;
 	int ret;
 
-	eth_dev = dpaa2_dev->eth_dev;
+	eth_dev = rte_eth_dev_allocated(dpaa2_dev->device.name);
+	if (!eth_dev)
+		return 0;
+
 	dpaa2_dev_close(eth_dev);
 	dpaa2_valid_dev--;
 	if (!dpaa2_valid_dev)
Signature · 1 line
2.51.0
#5 lore raw

Re: [PATCH 4/5] net/dpaa2: remove ethdev device in bus device

Hi David,

Quoted 38 lines · David Marchand

Calling rte_eth_dev_allocated() is enough to retrieve the ethdev device object.

This leaves no user of the ethdev field in the fslmc device object.

---
 drivers/bus/fslmc/bus_fslmc_driver.h | 1 -
 drivers/net/dpaa2/dpaa2_ethdev.c     | 6 ++++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
index efa88754a7..094f885f59 100644
@@ -98,7 +98,6 @@ struct rte_dpaa2_device {
        TAILQ_ENTRY(rte_dpaa2_device) next; /**< Next probed DPAA2 device. */
        struct rte_device device;           /**< Inherit core device */
        union {
-               struct rte_eth_dev *eth_dev;        /**< ethernet device */
                struct rte_rawdev *rawdev;          /**< Raw Device */
        };
        enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
drivers/net/dpaa2/dpaa2_ethdev.c +0 -1
index 7da32ce856..2a26a02cb4 100644
@@ -3320,7 +3320,6 @@ rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv,
 
        eth_dev->device = &dpaa2_dev->device;
 
-       dpaa2_dev->eth_dev = eth_dev;
        eth_dev->data->rx_mbuf_alloc_failed = 0;
 
        if (dpaa2_drv->drv_flags & RTE_DPAA2_DRV_INTR_LSC)
@@ -3349,7 +3348,10 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)
        struct rte_eth_dev *eth_dev;

drivers/net/dpaa2/dpaa2_ethdev.c rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) · line 3357

Quoted 10 lines
drivers/net/dpaa2/dpaa2_ethdev.c +4 -1
        int ret;
 
-       eth_dev = dpaa2_dev->eth_dev;
+       eth_dev = rte_eth_dev_allocated(dpaa2_dev->device.name);
+       if (!eth_dev)
+               return 0;
+
        dpaa2_dev_close(eth_dev);
        dpaa2_valid_dev--;
        if (!dpaa2_valid_dev)

dpaa2_valid_dev is currently incremented in rte_dpaa2_probe. With your modification, dpaa2_valid_dev will never be decremented in rte_dpaa2_remove if rte_eth_dev_close has already been called. As a consequence, dpaa2_tx_sg_pool will never be freed.

I don’t think dpaa2_tx_sg_pool should be freed in rte_dpaa2_remove; it should be freed in dpaa2_dev_close instead.
For symmetry, dpaa2_tx_sg_pool should also be allocated directly in dpaa2_dev_init.

Regards,

Maxime Leroy

#6 lore raw

Re: [PATCH 4/5] net/dpaa2: remove ethdev device in bus device

Hi Maxime and Hemant,

Quoted 57 lines · Maxime Leroy
Quoted 38 lines · David Marchand

Calling rte_eth_dev_allocated() is enough to retrieve the ethdev device object.

This leaves no user of the ethdev field in the fslmc device object.

---
 drivers/bus/fslmc/bus_fslmc_driver.h | 1 -
 drivers/net/dpaa2/dpaa2_ethdev.c     | 6 ++++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
index efa88754a7..094f885f59 100644
@@ -98,7 +98,6 @@ struct rte_dpaa2_device {
        TAILQ_ENTRY(rte_dpaa2_device) next; /**< Next probed DPAA2 device. */
        struct rte_device device;           /**< Inherit core device */
        union {
-               struct rte_eth_dev *eth_dev;        /**< ethernet device */
                struct rte_rawdev *rawdev;          /**< Raw Device */
        };
        enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
drivers/net/dpaa2/dpaa2_ethdev.c +0 -1
index 7da32ce856..2a26a02cb4 100644
@@ -3320,7 +3320,6 @@ rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv,
 
        eth_dev->device = &dpaa2_dev->device;
 
-       dpaa2_dev->eth_dev = eth_dev;
        eth_dev->data->rx_mbuf_alloc_failed = 0;
 
        if (dpaa2_drv->drv_flags & RTE_DPAA2_DRV_INTR_LSC)
@@ -3349,7 +3348,10 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)
        struct rte_eth_dev *eth_dev;

drivers/net/dpaa2/dpaa2_ethdev.c rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) · line 3357

Quoted 10 lines
drivers/net/dpaa2/dpaa2_ethdev.c +4 -1
        int ret;
 
-       eth_dev = dpaa2_dev->eth_dev;
+       eth_dev = rte_eth_dev_allocated(dpaa2_dev->device.name);
+       if (!eth_dev)
+               return 0;
+
        dpaa2_dev_close(eth_dev);
        dpaa2_valid_dev--;
        if (!dpaa2_valid_dev)

dpaa2_valid_dev is currently incremented in rte_dpaa2_probe. With your modification, dpaa2_valid_dev will never be decremented in rte_dpaa2_remove if rte_eth_dev_close has already been called. As a consequence, dpaa2_tx_sg_pool will never be freed.

Quoted 4 lines

I don’t think dpaa2_tx_sg_pool should be freed in rte_dpaa2_remove; it should be freed in dpaa2_dev_close instead.
For symmetry, dpaa2_tx_sg_pool should also be allocated directly in dpaa2_dev_init.

Indeed, moving the dpaa2_tx_sg_pool handling in dev_init/dev_close is more self contained, and looks cleaner.

Now, taking a step back, I should not try and fix the bug you guys have been working on.
IOW, the check on !eth_dev in this patch of mine is unrelated to the series.

I'll respin a v2 shortly, that focuses on the layer violation only. For you guys to fix the double close bug.

Signature · 1 line
David Marchand
#7 lore raw

Re: [PATCH 4/5] net/dpaa2: remove ethdev device in bus device

Quoted 8 lines · David Marchand
Quoted 4 lines · Maxime Leroy

I don’t think dpaa2_tx_sg_pool should be freed in rte_dpaa2_remove; it should be freed in dpaa2_dev_close instead.
For symmetry, dpaa2_tx_sg_pool should also be allocated directly in dpaa2_dev_init.

Indeed, moving the dpaa2_tx_sg_pool handling in dev_init/dev_close is more self contained, and looks cleaner.

On this topic, in rte_dpaa2_probe:

    /* Invoke PMD device initialization function */
    diag = dpaa2_dev_init(eth_dev);
    if (!diag) {
        diag = dpaa2_tx_sg_pool_init();
        if (diag)
            return diag;

On dpaa2_tx_sg_pool_init() failure, a eth_dev is leaked. Worth fixing while moving around the code related to dpaa2_tx_sg_pool.

Signature · 1 line
David Marchand
#8 lore raw

PATCH 5/5 bus/fslmc: remove raw device in bus device

In reply to David Marchand

There is no user of this field.

---
 drivers/bus/fslmc/bus_fslmc_driver.h | 3 ---
 1 file changed, 3 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -3
index 094f885f59..89abc3c486 100644
@@ -97,9 +97,6 @@ enum rte_dpaa2_dev_type {
 struct rte_dpaa2_device {
 	TAILQ_ENTRY(rte_dpaa2_device) next; /**< Next probed DPAA2 device. */
 	struct rte_device device;           /**< Inherit core device */
-	union {
-		struct rte_rawdev *rawdev;          /**< Raw Device */
-	};
 	enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
 	uint16_t object_id;                 /**< DPAA2 Object ID */
 	enum rte_dpaa2_dev_type ep_dev_type;   /**< Endpoint Device Type */
Signature · 1 line
2.51.0
#9 lore raw
In reply to David Marchand
Quoted 10 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: 08 November 2025 21:02
To: [email protected]
Cc: Hemant Agrawal <[email protected]>; [email protected]
Subject: [PATCH 0/5] Cleanup rte_dpaa2_device
Importance: High

Quoted 9 lines

The rte_dpaa2_device object keeps track of a device class object (cryptodev, dmadev, ethdev, rawdev) which is a layer violation.

Make use of the device class respective infrastructure and remove those back references.

Disclaimer: this series is untested as I don't have the hardware. I only based those changes on look at the code and other drivers.

Thanks for the patchset, we will revert with the test results shortly.

#10 lore raw

v2 cover Cleanup rte_dpaa2_device

In reply to David Marchand

The rte_dpaa2_device object keeps track of a device class object (cryptodev, dmadev, ethdev, rawdev) which is a layer violation.

Make use of the device class respective infrastructure and remove those back references.

Disclaimer: this series is untested as I don't have the hardware. I only based those changes on look at the code and other drivers.

Signature · 23 lines
David Marchand

Changes since v1:
- removed (wrong) attempt at fixing a double close bug in patch 4,


David Marchand (5):
  crypto/dpaa2_sec: remove crypto device in bus device
  dma/dpaa2: remove DMA device in bus device
  net/dpaa2: remove dead code in loopback mode
  net/dpaa2: remove ethdev device in bus device
  bus/fslmc: remove raw device in bus device

 drivers/bus/fslmc/bus_fslmc_driver.h        |  6 ---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  8 ++--
 drivers/dma/dpaa2/dpaa2_qdma.c              |  9 ++--
 drivers/net/dpaa2/dpaa2_ethdev.c            |  3 +-
 drivers/net/dpaa2/dpaa2_ethdev.h            |  6 ---
 drivers/net/dpaa2/dpaa2_recycle.c           | 50 ---------------------
 6 files changed, 11 insertions(+), 71 deletions(-)

-- 
2.51.0
#11 lore raw

PATCH v2 1/5 crypto/dpaa2_sec: remove crypto device in bus device

Calling rte_cryptodev_pmd_get_named_dev() is enough to retrieve the crypto device object.

This leaves no user of the cryptodev field in the fslmc device object.

---
 drivers/bus/fslmc/bus_fslmc_driver.h        | 1 -
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
index b6a6238a01..45c7a519f9 100644
@@ -99,7 +99,6 @@ struct rte_dpaa2_device {
 	struct rte_device device;           /**< Inherit core device */
 	union {
 		struct rte_eth_dev *eth_dev;        /**< ethernet device */
-		struct rte_cryptodev *cryptodev;    /**< Crypto Device */
 		struct rte_dma_dev *dmadev;          /**< DMA Device */
 		struct rte_rawdev *rawdev;          /**< Raw Device */
 	};
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +5 -3
index ca10d88da7..698548e6ea 100644
@@ -4503,8 +4503,6 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
 		return -ENOMEM;
 	}
 
-	dpaa2_dev->cryptodev = cryptodev;
-
 	if (dpaa2_svr_family == SVR_LX2160A)
 		rta_set_sec_era(RTA_SEC_ERA_10);
 	else
@@ -4526,10 +4524,14 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
 static int
 cryptodev_dpaa2_sec_remove(struct rte_dpaa2_device *dpaa2_dev)
 {
+	char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
 	struct rte_cryptodev *cryptodev;
 	int ret;
 
-	cryptodev = dpaa2_dev->cryptodev;
+	snprintf(cryptodev_name, sizeof(cryptodev_name), "dpsec-%d",
+			dpaa2_dev->object_id);
+
+	cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
 	if (cryptodev == NULL)
 		return -ENODEV;
 
Signature · 1 line
2.51.0
#12 lore raw

Re: [PATCH v2 1/5] crypto/dpaa2_sec: remove crypto device in bus device

Hi David,

Quoted 54 lines · David Marchand

Calling rte_cryptodev_pmd_get_named_dev() is enough to retrieve the crypto device object.

This leaves no user of the cryptodev field in the fslmc device object.

---
 drivers/bus/fslmc/bus_fslmc_driver.h        | 1 -
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
index b6a6238a01..45c7a519f9 100644
@@ -99,7 +99,6 @@ struct rte_dpaa2_device {
        struct rte_device device;           /**< Inherit core device */
        union {
                struct rte_eth_dev *eth_dev;        /**< ethernet device */
-               struct rte_cryptodev *cryptodev;    /**< Crypto Device */
                struct rte_dma_dev *dmadev;          /**< DMA Device */
                struct rte_rawdev *rawdev;          /**< Raw Device */
        };
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +5 -4
index ca10d88da7..698548e6ea 100644
@@ -4503,8 +4503,6 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
                return -ENOMEM;
        }
 
-       dpaa2_dev->cryptodev = cryptodev;
-
        if (dpaa2_svr_family == SVR_LX2160A)
                rta_set_sec_era(RTA_SEC_ERA_10);
        else
@@ -4526,10 +4524,14 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
 static int
 cryptodev_dpaa2_sec_remove(struct rte_dpaa2_device *dpaa2_dev)
 {
+       char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
        struct rte_cryptodev *cryptodev;
        int ret;
 
-       cryptodev = dpaa2_dev->cryptodev;
+       snprintf(cryptodev_name, sizeof(cryptodev_name), "dpsec-%d",
+                       dpaa2_dev->object_id);
+
+       cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
        if (cryptodev == NULL)
                return -ENODEV;
 
--
Quoted 2 lines

2.51.0

Should we add a function to generate the cryptodev name instead of duplicating the code, similar to how it’s done for PCI devices (i.e., rte_pci_device_name)?

Maxime Leroy

#13 lore raw

Re: [PATCH v2 1/5] crypto/dpaa2_sec: remove crypto device in bus device

Hello,

Quoted 16 lines · Maxime Leroy
Quoted 16 lines
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +5 -1
@@ -4526,10 +4524,14 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
 static int
 cryptodev_dpaa2_sec_remove(struct rte_dpaa2_device *dpaa2_dev)
 {
+       char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
        struct rte_cryptodev *cryptodev;
        int ret;
 
-       cryptodev = dpaa2_dev->cryptodev;
+       snprintf(cryptodev_name, sizeof(cryptodev_name), "dpsec-%d",
+                       dpaa2_dev->object_id);
+
+       cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
        if (cryptodev == NULL)
                return -ENODEV;
 
Quoted 6 lines
Quoted 3 lines

--
2.51.0

Should we add a function to generate the cryptodev name instead of duplicating the code, similar to how it’s done for PCI devices (i.e., rte_pci_device_name)?

I am not sure I get the parallel..
rte_pci_device_name is a bus level name, I don't see how we could define a fslmc bus level helper that would help here. Ah, you mean adding a helper internal to this cryptodev driver?

I can respin this today, but after this, I'll be offline for the rest of the week (ovscon 2025).

Btw, this series is a cleanup (those drivers have been like this for a long time), and it can be deferred to next release if we are too short on time.
On the other hand, the fixes from
https://patchwork.dpdk.org/project/dpdk/list/?series=36702 seem valid for 25.11.0 (or at least backport material for 25.11.1).

Signature · 1 line
David Marchand
#14 lore raw

Re: [PATCH v2 1/5] crypto/dpaa2_sec: remove crypto device in bus device

Hi David,

Quoted 27 lines · David Marchand

Hello,

Quoted 16 lines · Maxime Leroy
Quoted 16 lines
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +5 -1
@@ -4526,10 +4524,14 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
 static int
 cryptodev_dpaa2_sec_remove(struct rte_dpaa2_device *dpaa2_dev)
 {
+       char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
        struct rte_cryptodev *cryptodev;
        int ret;
 
-       cryptodev = dpaa2_dev->cryptodev;
+       snprintf(cryptodev_name, sizeof(cryptodev_name), "dpsec-%d",
+                       dpaa2_dev->object_id);
+
+       cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
        if (cryptodev == NULL)
                return -ENODEV;
 
Quoted 6 lines
Quoted 3 lines

--
2.51.0

Should we add a function to generate the cryptodev name instead of duplicating the code, similar to how it’s done for PCI devices (i.e., rte_pci_device_name)?

Quoted 5 lines

I am not sure I get the parallel..
rte_pci_device_name is a bus level name, I don't see how we could define a fslmc bus level helper that would help here. Ah, you mean adding a helper internal to this cryptodev driver?

Yes. It's a minor improvement.

Else everything seems good on this serie.

Regards,

Maxime Leroy

#15 lore raw

PATCH v2 2/5 dma/dpaa2: remove DMA device in bus device

In reply to David Marchand

A driver .dev_close op is automatically called when releasing a dma device.
Move device specific unitialisation in this driver .dev_close op.

This leaves no user of the dmadev field in the fslmc device object.

---
 drivers/bus/fslmc/bus_fslmc_driver.h | 1 -
 drivers/dma/dpaa2/dpaa2_qdma.c       | 9 +++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
index 45c7a519f9..efa88754a7 100644
@@ -99,7 +99,6 @@ struct rte_dpaa2_device {
 	struct rte_device device;           /**< Inherit core device */
 	union {
 		struct rte_eth_dev *eth_dev;        /**< ethernet device */
-		struct rte_dma_dev *dmadev;          /**< DMA Device */
 		struct rte_rawdev *rawdev;          /**< Raw Device */
 	};
 	enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
drivers/dma/dpaa2/dpaa2_qdma.c +5 -4
index 4be43d6bd9..beca464c72 100644
@@ -1455,6 +1455,9 @@ dpaa2_qdma_stop(struct rte_dma_dev *dev)
 	return 0;
 }
 
+static int
+dpaa2_dpdmai_dev_uninit(struct rte_dma_dev *dev);
+
 static int
 dpaa2_qdma_close(struct rte_dma_dev *dev)
 {
@@ -1505,6 +1508,8 @@ dpaa2_qdma_close(struct rte_dma_dev *dev)
 	/* Reset QDMA device structure */
 	qdma_dev->num_vqs = 0;
 
+	dpaa2_dpdmai_dev_uninit(dev);
+
 	return 0;
 }
 
@@ -1703,7 +1708,6 @@ dpaa2_qdma_probe(struct rte_dpaa2_driver *dpaa2_drv,
 		return -EINVAL;
 	}
 
-	dpaa2_dev->dmadev = dmadev;
 	dmadev->dev_ops = &dpaa2_qdma_ops;
 	dmadev->device = &dpaa2_dev->device;
 	dmadev->fp_obj->dev_private = dmadev->data->dev_private;
@@ -1727,13 +1731,10 @@ dpaa2_qdma_probe(struct rte_dpaa2_driver *dpaa2_drv,
 static int
 dpaa2_qdma_remove(struct rte_dpaa2_device *dpaa2_dev)
 {
-	struct rte_dma_dev *dmadev = dpaa2_dev->dmadev;
 	int ret;
 
 	DPAA2_QDMA_FUNC_TRACE();
 
-	dpaa2_dpdmai_dev_uninit(dmadev);
-
 	ret = rte_dma_pmd_release(dpaa2_dev->device.name);
 	if (ret)
 		DPAA2_QDMA_ERR("Device cleanup failed");
Signature · 1 line
2.51.0
#16 lore raw

PATCH v2 3/5 net/dpaa2: remove dead code in loopback mode

In reply to David Marchand

This code was never used.

Fixes f023d059769f ("net/dpaa2: support recycle loopback port")
---
 drivers/net/dpaa2/dpaa2_ethdev.h  |  6 ----
 drivers/net/dpaa2/dpaa2_recycle.c | 50 -------------------------------
 2 files changed, 56 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.h +0 -6
index 87a94bc15b..86b3022ddb 100644
@@ -531,12 +531,6 @@ int dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev);
 int dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev);
 int dpaa2_soft_parser_loaded(void);
 
-int dpaa2_dev_recycle_qp_setup(struct rte_dpaa2_device *dpaa2_dev,
-	uint16_t qidx, uint64_t cntx,
-	eth_rx_burst_t tx_lpbk, eth_tx_burst_t rx_lpbk,
-	struct dpaa2_queue **txq,
-	struct dpaa2_queue **rxq);
-
 void
 dpaa2_dev_mac_setup_stats(struct rte_eth_dev *dev);
 
drivers/net/dpaa2/dpaa2_recycle.c +0 -50

53 lines not on this page · raw message

Signature · 1 line
2.51.0
#17 lore raw

PATCH v2 4/5 net/dpaa2: remove ethdev device in bus device

In reply to David Marchand

Calling rte_eth_dev_allocated() is enough to retrieve the ethdev device object.

This leaves no user of the ethdev field in the fslmc device object.

---
Changes since v1:
- dropped return on !eth_dev (this should be fixed in a separate patch),

---
 drivers/bus/fslmc/bus_fslmc_driver.h | 1 -
 drivers/net/dpaa2/dpaa2_ethdev.c     | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
index efa88754a7..094f885f59 100644
@@ -98,7 +98,6 @@ struct rte_dpaa2_device {
 	TAILQ_ENTRY(rte_dpaa2_device) next; /**< Next probed DPAA2 device. */
 	struct rte_device device;           /**< Inherit core device */
 	union {
-		struct rte_eth_dev *eth_dev;        /**< ethernet device */
 		struct rte_rawdev *rawdev;          /**< Raw Device */
 	};
 	enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
drivers/net/dpaa2/dpaa2_ethdev.c +1 -2
index 7da32ce856..c545177999 100644
@@ -3320,7 +3320,6 @@ rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv,
 
 	eth_dev->device = &dpaa2_dev->device;
 
-	dpaa2_dev->eth_dev = eth_dev;
 	eth_dev->data->rx_mbuf_alloc_failed = 0;
 
 	if (dpaa2_drv->drv_flags & RTE_DPAA2_DRV_INTR_LSC)
@@ -3349,7 +3348,7 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)
 	struct rte_eth_dev *eth_dev;
 	int ret;
 
-	eth_dev = dpaa2_dev->eth_dev;
+	eth_dev = rte_eth_dev_allocated(dpaa2_dev->device.name);
 	dpaa2_dev_close(eth_dev);
 	dpaa2_valid_dev--;
 	if (!dpaa2_valid_dev)
Signature · 1 line
2.51.0
#18 lore raw

Re: [PATCH v2 4/5] net/dpaa2: remove ethdev device in bus device

Quoted 40 lines · David Marchand

Calling rte_eth_dev_allocated() is enough to retrieve the ethdev device object.

This leaves no user of the ethdev field in the fslmc device object.

---
Changes since v1:
- dropped return on !eth_dev (this should be fixed in a separate patch),

---
  drivers/bus/fslmc/bus_fslmc_driver.h | 1 -
  drivers/net/dpaa2/dpaa2_ethdev.c     | 3 +--
  2 files changed, 1 insertion(+), 3 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
index efa88754a7..094f885f59 100644
@@ -98,7 +98,6 @@ struct rte_dpaa2_device {
  	TAILQ_ENTRY(rte_dpaa2_device) next; /**< Next probed DPAA2 device. */
  	struct rte_device device;           /**< Inherit core device */
  	union {
-		struct rte_eth_dev *eth_dev;        /**< ethernet device */
  		struct rte_rawdev *rawdev;          /**< Raw Device */
  	};
  	enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
drivers/net/dpaa2/dpaa2_ethdev.c +0 -1
index 7da32ce856..c545177999 100644
@@ -3320,7 +3320,6 @@ rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv,
 
  	eth_dev->device = &dpaa2_dev->device;
 
-	dpaa2_dev->eth_dev = eth_dev;
  	eth_dev->data->rx_mbuf_alloc_failed = 0;
 
  	if (dpaa2_drv->drv_flags & RTE_DPAA2_DRV_INTR_LSC)

drivers/net/dpaa2/dpaa2_ethdev.c rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) · line 3351

Quoted 5 lines
drivers/net/dpaa2/dpaa2_ethdev.c +1 -1
@@ -3349,7 +3348,7 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)
  	struct rte_eth_dev *eth_dev;
  	int ret;
 
-	eth_dev = dpaa2_dev->eth_dev;
+	eth_dev = rte_eth_dev_allocated(dpaa2_dev->device.name);

I have also included this change in my patch series. otherwise it looks ok.

Quoted 3 lines
drivers/net/dpaa2/dpaa2_ethdev.c +0 -0
  	dpaa2_dev_close(eth_dev);
  	dpaa2_valid_dev--;
  	if (!dpaa2_valid_dev)
#19 lore raw

PATCH v2 5/5 bus/fslmc: remove raw device in bus device

In reply to David Marchand

There is no user of this field.

---
 drivers/bus/fslmc/bus_fslmc_driver.h | 3 ---
 1 file changed, 3 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -3
index 094f885f59..89abc3c486 100644
@@ -97,9 +97,6 @@ enum rte_dpaa2_dev_type {
 struct rte_dpaa2_device {
 	TAILQ_ENTRY(rte_dpaa2_device) next; /**< Next probed DPAA2 device. */
 	struct rte_device device;           /**< Inherit core device */
-	union {
-		struct rte_rawdev *rawdev;          /**< Raw Device */
-	};
 	enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
 	uint16_t object_id;                 /**< DPAA2 Object ID */
 	enum rte_dpaa2_dev_type ep_dev_type;   /**< Endpoint Device Type */
Signature · 1 line
2.51.0
#20 lore raw
In reply to David Marchand
Quoted 9 lines · David Marchand

The rte_dpaa2_device object keeps track of a device class object (cryptodev, dmadev, ethdev, rawdev) which is a layer violation.

Make use of the device class respective infrastructure and remove those back references.

Disclaimer: this series is untested as I don't have the hardware. I only based those changes on look at the code and other drivers.

#21 lore raw

13/11/2025 10:16, Hemant Agrawal:

Quoted 12 lines · David Marchand
Quoted 9 lines

The rte_dpaa2_device object keeps track of a device class object (cryptodev, dmadev, ethdev, rawdev) which is a layer violation.

Make use of the device class respective infrastructure and remove those back references.

Disclaimer: this series is untested as I don't have the hardware. I only based those changes on look at the code and other drivers.

Applied on top of other fixes from Hemant, thanks.