mempool: fix slow allocation of large mempools
[dpdk.git] / lib / librte_kni / rte_kni.c
index 0f36485..e388751 100644 (file)
@@ -10,6 +10,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
+#include <linux/version.h>
 
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
@@ -97,10 +98,12 @@ static volatile int kni_fd = -1;
 int
 rte_kni_init(unsigned int max_kni_ifaces __rte_unused)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
        if (rte_eal_iova_mode() != RTE_IOVA_PA) {
                RTE_LOG(ERR, KNI, "KNI requires IOVA as PA\n");
                return -1;
        }
+#endif
 
        /* Check FD and open */
        if (kni_fd < 0) {
@@ -252,6 +255,8 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
        dev_info.group_id = conf->group_id;
        dev_info.mbuf_size = conf->mbuf_size;
        dev_info.mtu = conf->mtu;
+       dev_info.min_mtu = conf->min_mtu;
+       dev_info.max_mtu = conf->max_mtu;
 
        memcpy(dev_info.mac_addr, conf->mac_addr, RTE_ETHER_ADDR_LEN);
 
@@ -300,6 +305,8 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
        kni->group_id = conf->group_id;
        kni->mbuf_size = conf->mbuf_size;
 
+       dev_info.iova_mode = (rte_eal_iova_mode() == RTE_IOVA_VA) ? 1 : 0;
+
        ret = ioctl(kni_fd, RTE_KNI_IOCTL_CREATE, &dev_info);
        if (ret < 0)
                goto ioctl_fail;