lib: fix typos
[dpdk.git] / lib / librte_kni / rte_kni.c
index 40288a1..8eca8c0 100644 (file)
@@ -340,7 +340,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
        /* Get an available slot from the pool */
        slot = kni_memzone_pool_alloc();
        if (!slot) {
-               RTE_LOG(ERR, KNI, "Cannot allocate more KNI interfaces; increase the number of max_kni_ifaces(current %d) or release unusued ones.\n",
+               RTE_LOG(ERR, KNI, "Cannot allocate more KNI interfaces; increase the number of max_kni_ifaces(current %d) or release unused ones.\n",
                        kni_memzone_pool.max_ifaces);
                return NULL;
        }
@@ -456,7 +456,7 @@ va2pa(struct rte_mbuf *m)
 {
        return (void *)((unsigned long)m -
                        ((unsigned long)m->buf_addr -
-                        (unsigned long)m->buf_physaddr));
+                        (unsigned long)m->buf_iova));
 }
 
 static void
@@ -624,6 +624,7 @@ kni_allocate_mbufs(struct rte_kni *kni)
        int i, ret;
        struct rte_mbuf *pkts[MAX_MBUF_BURST_NUM];
        void *phys[MAX_MBUF_BURST_NUM];
+       int allocq_free;
 
        RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pool) !=
                         offsetof(struct rte_kni_mbuf, pool));
@@ -646,7 +647,9 @@ kni_allocate_mbufs(struct rte_kni *kni)
                return;
        }
 
-       for (i = 0; i < MAX_MBUF_BURST_NUM; i++) {
+       allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) \
+                       & (MAX_MBUF_BURST_NUM - 1);
+       for (i = 0; i < allocq_free; i++) {
                pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool);
                if (unlikely(pkts[i] == NULL)) {
                        /* Out of memory */
@@ -656,7 +659,7 @@ kni_allocate_mbufs(struct rte_kni *kni)
                phys[i] = va2pa(pkts[i]);
        }
 
-       /* No pkt mbuf alocated */
+       /* No pkt mbuf allocated */
        if (i <= 0)
                return;