On Fri, Nov 15, 2019 at 2:40 PM Jerin Jacob <jerinjac...@gmail.com> wrote: > On Fri, Nov 15, 2019 at 6:29 PM David Marchand > <david.march...@redhat.com> wrote: > > So far, KNI could not work with IOVA as VA. > > Your patchset adds support for IOVA as VA if kernel is >= 4.6. > > We need achive the following. > > IOVA as PA has performance implication on KNI case. So we need to > make IOVA as PA when KNI module is loaded.
- The current behaviour is: * buses announce PA, nothing to do wrt KNI, * buses announce VA or DC (whatever the considerations on iommu), if physical addresses are available, then PA is used and KNI works, - Now, with this new feature (on kernels >= 4.6), we can have KNI work with VA, the previous workaround can be skipped. There is another consideration wrt performance, as a consequence, for kernels 4.6, if physical addresses are available, we can select PA for KNI. _But_ I did not see people complaining about the current behavior. I see no reason to change this if the VA support can't be used (kernels < 4.6). So how about (I inverted the #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0), it was causing me headaches): diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c index 9e2d50cfb..33f3c674c 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -1073,6 +1073,11 @@ rte_eal_init(int argc, char **argv) */ iova_mode = RTE_IOVA_VA; RTE_LOG(DEBUG, EAL, "Physical addresses are unavailable, selecting IOVA as VA mode.\n"); +#if defined(RTE_LIBRTE_KNI) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) + } else if (rte_eal_check_module("rte_kni") == 1) { + iova_mode = RTE_IOVA_PA; + RTE_LOG(DEBUG, EAL, "Forcing IOVA as 'PA' for better perfomance with KNI\n"); +#endif } else if (is_iommu_enabled()) { /* we have an IOMMU, pick IOVA as VA mode */ iova_mode = RTE_IOVA_VA; @@ -1085,7 +1090,7 @@ rte_eal_init(int argc, char **argv) RTE_LOG(DEBUG, EAL, "IOMMU is not available, selecting IOVA as PA mode.\n"); } } -#ifdef RTE_LIBRTE_KNI - /* Workaround for KNI which requires physical address to work */ +#if defined(RTE_LIBRTE_KNI) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) + /* Workaround for KNI which requires physical address to work with kernels < 4.6 */ if (iova_mode == RTE_IOVA_VA && rte_eal_check_module("rte_kni") == 1) { -- David Marchand