kni: fix Rx loop limit

Loop processing packets dequeued from rx_q was using the number of
packets requested, not how many it actually received.

Variable rename to make code a little more clear

Signed-off-by: Jay Rolette <rolette@infiniteio.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>
This commit is contained in:
Jay Rolette 2015-06-03 14:18:57 -05:00 committed by Thomas Monjalon
parent a1f8789546
commit c1c016a3fc

View File

@ -131,7 +131,7 @@ kni_net_rx_normal(struct kni_dev *kni)
{ {
unsigned ret; unsigned ret;
uint32_t len; uint32_t len;
unsigned i, num, num_fq; unsigned i, num_rx, num_fq;
struct rte_kni_mbuf *kva; struct rte_kni_mbuf *kva;
struct rte_kni_mbuf *va[MBUF_BURST_SZ]; struct rte_kni_mbuf *va[MBUF_BURST_SZ];
void * data_kva; void * data_kva;
@ -140,21 +140,22 @@ kni_net_rx_normal(struct kni_dev *kni)
struct net_device *dev = kni->net_dev; struct net_device *dev = kni->net_dev;
/* Get the number of free entries in free_q */ /* Get the number of free entries in free_q */
if ((num_fq = kni_fifo_free_count(kni->free_q)) == 0) { num_fq = kni_fifo_free_count(kni->free_q);
if (num_fq == 0) {
/* No room on the free_q, bail out */ /* No room on the free_q, bail out */
return; return;
} }
/* Calculate the number of entries to dequeue from rx_q */ /* Calculate the number of entries to dequeue from rx_q */
num = min(num_fq, (unsigned)MBUF_BURST_SZ); num_rx = min(num_fq, (unsigned)MBUF_BURST_SZ);
/* Burst dequeue from rx_q */ /* Burst dequeue from rx_q */
ret = kni_fifo_get(kni->rx_q, (void **)va, num); num_rx = kni_fifo_get(kni->rx_q, (void **)va, num_rx);
if (ret == 0) if (num_rx == 0)
return; return;
/* Transfer received packets to netif */ /* Transfer received packets to netif */
for (i = 0; i < num; i++) { for (i = 0; i < num_rx; i++) {
kva = (void *)va[i] - kni->mbuf_va + kni->mbuf_kva; kva = (void *)va[i] - kni->mbuf_va + kni->mbuf_kva;
len = kva->data_len; len = kva->data_len;
data_kva = kva->buf_addr + kva->data_off - kni->mbuf_va data_kva = kva->buf_addr + kva->data_off - kni->mbuf_va
@ -184,8 +185,8 @@ kni_net_rx_normal(struct kni_dev *kni)
} }
/* Burst enqueue mbufs into free_q */ /* Burst enqueue mbufs into free_q */
ret = kni_fifo_put(kni->free_q, (void **)va, num); ret = kni_fifo_put(kni->free_q, (void **)va, num_rx);
if (ret != num) if (ret != num_rx)
/* Failing should not happen */ /* Failing should not happen */
KNI_ERR("Fail to enqueue entries into free_q\n"); KNI_ERR("Fail to enqueue entries into free_q\n");
} }