bus/pci: add RTE_PCI_DRV_NEED_IOVA_AS_PA flag
cover bus/pci: add RTE_PCI_DRV_NEED_IOVA_AS_PA flag
From: liufeng1 <[email protected]>
This series adds a new PCI driver flag, RTE_PCI_DRV_NEED_IOVA_AS_PA, which allows a PCI driver to tell the PCI bus layer that it cannot work with IOVA as VA and must use IOVA as PA.
The existing RTE_PCI_DRV_NEED_IOVA_AS_VA flag already provides the opposite requirement. Some PCI devices, however, are managed by a kernel driver that uses an identity-mapped IOMMU domain (e.g. when the kernel is booted with iommu=pt). The user-space PMD for such devices must use IOVA as PA, because the DMA addresses programmed by DPDK must match the identity mapping programmed by the kernel driver.
Without this flag, a PCI driver bound to a non-VFIO/UIO kernel driver has no way to force IOVA as PA. pci_device_iova_mode() returns RTE_IOVA_DC for those devices, and rte_eal_init() then sees an enabled IOMMU and selects RTE_IOVA_VA, which breaks identity-domain PMDs and forces users to pass --iova-mode=pa on the command line.
When RTE_PCI_DRV_NEED_IOVA_AS_PA is set, pci_device_iova_mode() returns RTE_IOVA_PA for the device. The requirement is propagated through rte_pci_get_iommu_class() to rte_bus_get_iommu_class(), so rte_eal_init() selects IOVA as PA automatically.
This is a generic mechanism: any PCI driver whose underlying kernel driver uses an identity IOMMU domain can set the flag.
liufeng1 (1):
bus/pci: add RTE_PCI_DRV_NEED_IOVA_AS_PA flag
drivers/bus/pci/bus_pci_driver.h | 2 ++ drivers/bus/pci/linux/pci.c | 4 ++++ drivers/bus/pci/pci_common.c | 3 +-- 3 files changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/1 bus/pci: add RTE_PCI_DRV_NEED_IOVA_AS_PA flag
From: liufeng1 <[email protected]>
Add a new PCI driver flag, RTE_PCI_DRV_NEED_IOVA_AS_PA, that allows a driver to tell the PCI bus layer it cannot work with IOVA as VA and must use IOVA as PA.
The existing RTE_PCI_DRV_NEED_IOVA_AS_VA flag already provides the opposite requirement. Some PCI devices, however, are managed by a kernel driver that uses an identity-mapped IOMMU domain (e.g. when the
kernel is booted with iommu=pt). The user-space PMD for such devices
must use IOVA as PA, because the DMA addresses programmed by DPDK must match the identity mapping programmed by the kernel driver.
Without this flag, a PCI driver bound to a non-VFIO/UIO kernel driver has no way to force IOVA as PA. pci_device_iova_mode() returns RTE_IOVA_DC for those devices, and rte_eal_init() then sees an enabled IOMMU and selects RTE_IOVA_VA, which breaks identity-domain PMDs and forces users to pass --iova-mode=pa on the command line.
When RTE_PCI_DRV_NEED_IOVA_AS_PA is set, pci_device_iova_mode() returns RTE_IOVA_PA for the device. The requirement is propagated through rte_pci_get_iommu_class() to rte_bus_get_iommu_class(), so rte_eal_init() selects IOVA as PA automatically.
This is a generic mechanism: any PCI driver whose underlying kernel driver uses an identity IOMMU domain can set the flag.
--- drivers/bus/pci/bus_pci_driver.h | 2 ++ drivers/bus/pci/linux/pci.c | 4 ++++ drivers/bus/pci/pci_common.c | 3 +-- 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/bus/pci/bus_pci_driver.h +2 -0
@@ -140,6 +140,8 @@ struct rte_pci_driver {#define RTE_PCI_DRV_KEEP_MAPPED_RES 0x0020/** Device driver needs IOVA as VA and cannot work with IOVA as PA */ #define RTE_PCI_DRV_NEED_IOVA_AS_VA 0x0040 +/** Device driver needs IOVA as PA and cannot work with IOVA as VA */ +#define RTE_PCI_DRV_NEED_IOVA_AS_PA 0x0080/** * Register a PCI driver.
drivers/bus/pci/linux/pci.c +4 -0
@@ -609,6 +609,8 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv, iova_mode =RTE_IOVA_PA ; else if ((pdrv->drv_flags & RTE_PCI_DRV_NEED_IOVA_AS_VA) != 0) iova_mode =RTE_IOVA_VA ; + else if ((pdrv->drv_flags & RTE_PCI_DRV_NEED_IOVA_AS_PA) != 0) + iova_mode =RTE_IOVA_PA ;break ; }
@@ -620,6 +622,8 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv,default :if ((pdrv->drv_flags &RTE_PCI_DRV_NEED_IOVA_AS_VA ) !=0 ) iova_mode =RTE_IOVA_VA ; +else if ((pdrv->drv_flags &RTE_PCI_DRV_NEED_IOVA_AS_PA ) !=0 ) + iova_mode =RTE_IOVA_PA ;break ; }return iova_mode;
drivers/bus/pci/pci_common.c +1 -2
@@ -533,8 +533,7 @@ rte_pci_get_iommu_class(void) iommu_no_va =pci_device_iommu_support_va (dev) ?0 :1 ; -if (dev->kdrv ==RTE_PCI_KDRV_UNKNOWN || - dev->kdrv ==RTE_PCI_KDRV_NONE ) +if (dev->kdrv ==RTE_PCI_KDRV_NONE )continue ; RTE_BUS_FOREACH_DRV(drv, &rte_pci_bus) {enum rte_iova_mode dev_iova_mode;
Signature · 1 line
2.52.0
Quoted 61 lines · On Sat, Oct 10, 2026 at 05:25:25PM +0800, [email protected] wrote:
From: liufeng1 <[email protected]>
Add a new PCI driver flag,
RTE_PCI_DRV_NEED_IOVA_AS_PA, that allows a driver to tell the PCI bus layer it cannot work with IOVA as VA and must use IOVA as PA.The existing
RTE_PCI_DRV_NEED_IOVA_AS_VAflag already provides the opposite requirement. Some PCI devices, however, are managed by a kernel driver that uses an identity-mapped IOMMU domain (e.g. when the
kernel is booted with iommu=pt). The user-space PMD for such devices
must use IOVA as PA, because the DMA addresses programmed by DPDK must match the identity mapping programmed by the kernel driver.Without this flag, a PCI driver bound to a non-VFIO/UIO kernel driver has no way to force IOVA as PA.
pci_device_iova_mode()returnsRTE_IOVA_DCfor those devices, andrte_eal_init()then sees an enabled IOMMU and selectsRTE_IOVA_VA, which breaks identity-domain PMDs and forces users to pass --iova-mode=pa on the command line.When
RTE_PCI_DRV_NEED_IOVA_AS_PAis set,pci_device_iova_mode()returnsRTE_IOVA_PAfor the device. The requirement is propagated throughrte_pci_get_iommu_class()torte_bus_get_iommu_class(), sorte_eal_init()selects IOVA as PA automatically.This is a generic mechanism: any PCI driver whose underlying kernel driver uses an identity IOMMU domain can set the flag.
Signed-off-by Jie Liu <[email protected]>--- drivers/bus/pci/bus_pci_driver.h | 2 ++ drivers/bus/pci/linux/pci.c | 4 ++++ drivers/bus/pci/pci_common.c | 3 +-- 3 files changed, 7 insertions(+), 2 deletions(-)drivers/bus/pci/bus_pci_driver.h +2
-0@@ -140,6 +140,8 @@ struct rte_pci_driver {#define RTE_PCI_DRV_KEEP_MAPPED_RES 0x0020/** Device driver needs IOVA as VA and cannot work with IOVA as PA */ #define RTE_PCI_DRV_NEED_IOVA_AS_VA 0x0040 +/** Device driver needs IOVA as PA and cannot work with IOVA as VA */ +#define RTE_PCI_DRV_NEED_IOVA_AS_PA 0x0080/** * Register a PCI driver. drivers/bus/pci/linux/pci.c +2
-0@@ -609,6 +609,8 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv, iova_mode =RTE_IOVA_PA ; else if ((pdrv->drv_flags & RTE_PCI_DRV_NEED_IOVA_AS_VA) != 0) iova_mode =RTE_IOVA_VA ; + else if ((pdrv->drv_flags & RTE_PCI_DRV_NEED_IOVA_AS_PA) != 0) + iova_mode =RTE_IOVA_PA ;break ; }
drivers/bus/pci/linux/pci.c pci_device_iova_mode(const struct rte_pci_driver *pdrv, · line 629
Quoted 8 lines
drivers/bus/pci/linux/pci.c +2
-0@@ -620,6 +622,8 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv,default :if ((pdrv->drv_flags &RTE_PCI_DRV_NEED_IOVA_AS_VA ) !=0 ) iova_mode =RTE_IOVA_VA ; +else if ((pdrv->drv_flags &RTE_PCI_DRV_NEED_IOVA_AS_PA ) !=0 ) + iova_mode =RTE_IOVA_PA ;break ; }return iova_mode;
Do we need a sanity check somewhere that we don't have two drivers with conflicting flags set i.e. one NEED_IOVA_AS_VA and one NEED_IOVA_AS_PA? It should never happen, I imagine, but things that should never happen have this annoying habit of sometimes happening! :-)
/Bruce
v2 cover bus/pci: add RTE_PCI_DRV_NEED_IOVA_AS_PA flag
In reply to [email protected]From: Jie Liu <[email protected]>
V2:
Add a new PCI driver flag, RTE_PCI_DRV_NEED_IOVA_AS_PA, that allows a driver to tell the PCI bus layer it cannot work with IOVA as VA and must use IOVA as PA.
The existing RTE_PCI_DRV_NEED_IOVA_AS_VA flag already provides the opposite requirement. Some PCI devices, however, are managed by a kernel driver that uses an identity-mapped IOMMU domain (e.g. when the
kernel is booted with iommu=pt). The user-space PMD for such devices
must use IOVA as PA, because the DMA addresses programmed by DPDK must match the identity mapping programmed by the kernel driver.
Without this flag, a PCI driver bound to a non-VFIO/UIO kernel driver has no way to force IOVA as PA. pci_device_iova_mode() returns RTE_IOVA_DC for those devices, and rte_eal_init() then sees an enabled IOMMU and selects RTE_IOVA_VA, which breaks identity-domain PMDs and forces users to pass --iova-mode=pa on the command line.
When RTE_PCI_DRV_NEED_IOVA_AS_PA is set, pci_device_iova_mode() returns RTE_IOVA_PA for the device. The requirement is propagated through rte_pci_get_iommu_class() to rte_bus_get_iommu_class(), so rte_eal_init() selects IOVA as PA automatically.
If a driver sets both RTE_PCI_DRV_NEED_IOVA_AS_VA and RTE_PCI_DRV_NEED_IOVA_AS_PA at the same time, a warning is emitted and the conflicting requirement is ignored (RTE_IOVA_DC), because the two flags are mutually exclusive.
This is a generic mechanism: any PCI driver whose underlying kernel driver uses an identity IOMMU domain can set the flag.
liufeng1 (1):
bus/pci: add RTE_PCI_DRV_NEED_IOVA_AS_PA flag
drivers/bus/pci/bus_pci_driver.h | 2 ++ drivers/bus/pci/linux/pci.c | 13 +++++++++++++ drivers/bus/pci/pci_common.c | 3 +-- 3 files changed, 16 insertions(+), 2 deletions(-)
Signature · 1 line
2.52.0
PATCH v2 1/1 bus/pci: add RTE_PCI_DRV_NEED_IOVA_AS_PA flag
From: liufeng1 <[email protected]>
Add a new PCI driver flag, RTE_PCI_DRV_NEED_IOVA_AS_PA, that allows a driver to tell the PCI bus layer it cannot work with IOVA as VA and must use IOVA as PA.
The existing RTE_PCI_DRV_NEED_IOVA_AS_VA flag already provides the opposite requirement. Some PCI devices, however, are managed by a kernel driver that uses an identity-mapped IOMMU domain (e.g. when the
kernel is booted with iommu=pt). The user-space PMD for such devices
must use IOVA as PA, because the DMA addresses programmed by DPDK must match the identity mapping programmed by the kernel driver.
Without this flag, a PCI driver bound to a non-VFIO/UIO kernel driver has no way to force IOVA as PA. pci_device_iova_mode() returns RTE_IOVA_DC for those devices, and rte_eal_init() then sees an enabled IOMMU and selects RTE_IOVA_VA, which breaks identity-domain PMDs and forces users to pass --iova-mode=pa on the command line.
When RTE_PCI_DRV_NEED_IOVA_AS_PA is set, pci_device_iova_mode() returns RTE_IOVA_PA for the device. The requirement is propagated through rte_pci_get_iommu_class() to rte_bus_get_iommu_class(), so rte_eal_init() selects IOVA as PA automatically.
If a driver sets both RTE_PCI_DRV_NEED_IOVA_AS_VA and RTE_PCI_DRV_NEED_IOVA_AS_PA at the same time, a warning is emitted and the conflicting requirement is ignored (RTE_IOVA_DC), because the two flags are mutually exclusive.
This is a generic mechanism: any PCI driver whose underlying kernel driver uses an identity IOMMU domain can set the flag.
--- drivers/bus/pci/bus_pci_driver.h | 2 ++ drivers/bus/pci/linux/pci.c | 13 +++++++++++++ drivers/bus/pci/pci_common.c | 3 +-- 3 files changed, 16 insertions(+), 2 deletions(-)
drivers/bus/pci/bus_pci_driver.h +2 -0
@@ -140,6 +140,8 @@ struct rte_pci_driver {#define RTE_PCI_DRV_KEEP_MAPPED_RES 0x0020/** Device driver needs IOVA as VA and cannot work with IOVA as PA */ #define RTE_PCI_DRV_NEED_IOVA_AS_VA 0x0040 +/** Device driver needs IOVA as PA and cannot work with IOVA as VA */ +#define RTE_PCI_DRV_NEED_IOVA_AS_PA 0x0080/** * Register a PCI driver.
drivers/bus/pci/linux/pci.c +13 -0
@@ -595,6 +595,15 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv, {enum rte_iova_mode iova_mode =RTE_IOVA_DC ; +if ((pdrv->drv_flags & + (RTE_PCI_DRV_NEED_IOVA_AS_VA |RTE_PCI_DRV_NEED_IOVA_AS_PA )) == + (RTE_PCI_DRV_NEED_IOVA_AS_VA |RTE_PCI_DRV_NEED_IOVA_AS_PA )) { +RTE_LOG (WARNING ,EAL , +"PCI driver '%s' sets both NEED_IOVA_AS_VA and NEED_IOVA_AS_PA flags, ignoring\n" , + pdrv->driver.name); +return iova_mode; + } +switch (pdev->kdrv) {case RTE_PCI_KDRV_VFIO : {static int is_vfio_noiommu_enabled =-1 ;
@@ -609,6 +618,8 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv, iova_mode =RTE_IOVA_PA ; else if ((pdrv->drv_flags & RTE_PCI_DRV_NEED_IOVA_AS_VA) != 0) iova_mode =RTE_IOVA_VA ; + else if ((pdrv->drv_flags & RTE_PCI_DRV_NEED_IOVA_AS_PA) != 0) + iova_mode =RTE_IOVA_PA ;break ; }
@@ -620,6 +631,8 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv,default :if ((pdrv->drv_flags &RTE_PCI_DRV_NEED_IOVA_AS_VA ) !=0 ) iova_mode =RTE_IOVA_VA ; +else if ((pdrv->drv_flags &RTE_PCI_DRV_NEED_IOVA_AS_PA ) !=0 ) + iova_mode =RTE_IOVA_PA ;break ; }return iova_mode;
drivers/bus/pci/pci_common.c +1 -2
@@ -533,8 +533,7 @@ rte_pci_get_iommu_class(void) iommu_no_va =pci_device_iommu_support_va (dev) ?0 :1 ; -if (dev->kdrv ==RTE_PCI_KDRV_UNKNOWN || - dev->kdrv ==RTE_PCI_KDRV_NONE ) +if (dev->kdrv ==RTE_PCI_KDRV_NONE )continue ; RTE_BUS_FOREACH_DRV(drv, &rte_pci_bus) {enum rte_iova_mode dev_iova_mode;
Signature · 1 line
2.52.0