vhost: rework RARP packet injection
PATCH 1/1 vhost: rework RARP packet injection
Caught by code review, this copy is unnecessary.
--- lib/vhost/virtio_net.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
lib/vhost/virtio_net.c +3 -8
@@ -3364,6 +3364,8 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, count =0 ; goto out; } + pkts[0 ] = rarp_mbuf; + pkts++; count -=1 ; }
@@ -3386,15 +3388,8 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, out_access_unlock:rte_spinlock_unlock (&vq->access_lock); -if (unlikely (rarp_mbuf !=NULL )) { -/* -* Inject it to the head of "pkts" array, so that switch's mac -* learning table will get updated first. -*/ -memmove (&pkts[1 ], pkts, count *sizeof (struct rte_mbuf *)); - pkts[0 ] = rarp_mbuf; +if (unlikely (rarp_mbuf !=NULL )) count +=1 ; - }return count; }
Signature · 1 line
2.23.0
Quoted 28 lines · David Marchand
Caught by code review, this copy is unnecessary.
Signed-off-by David Marchand <[email protected]>--- lib/vhost/virtio_net.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)lib/vhost/virtio_net.c +2
-3@@ -3364,6 +3364,8 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, count =0 ; goto out; } + pkts[0 ] = rarp_mbuf; + pkts++; count -=1 ; }@@ -3386,15 +3388,8 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, out_access_unlock:rte_spinlock_unlock (&vq->access_lock); -if (unlikely (rarp_mbuf !=NULL )) { -/* -* Inject it to the head of "pkts" array, so that switch's mac
lib/vhost/virtio_net.c rte_vhost_dequeue_burst(int vid, uint16_t queue_id, · line 3395
Quoted 10 lines
lib/vhost/virtio_net.c +1
-5-* learning table will get updated first. -*/ -memmove (&pkts[1 ], pkts, count *sizeof (struct rte_mbuf *)); - pkts[0 ] = rarp_mbuf; +if (unlikely (rarp_mbuf !=NULL )) count +=1 ; - }return count; }
That's indeed much better!
Thanks,
Maxime
Quoted 8 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, September 15, 2021 10:55 PM
To: [email protected]
Cc: Maxime Coquelin <[email protected]>; Xia, Chenbo <[email protected]>
Subject: [PATCH] vhost: rework RARP packet injection
Quoted 8 lines
Caught by code review, this copy is unnecessary.
Signed-off-by David Marchand <[email protected]>--- lib/vhost/virtio_net.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)--
2.23.0
Thanks!
Maxime Coquelin
AppliedQuoted 7 lines · David Marchand
Caught by code review, this copy is unnecessary.
Signed-off-by David Marchand <[email protected]>--- lib/vhost/virtio_net.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
Applied to dpdk-next-virtio/main.
Thanks,
Maxime
Quoted 11 lines · Maxime Coquelin
Quoted 7 lines · David Marchand
Caught by code review, this copy is unnecessary.
Signed-off-by David Marchand <[email protected]>---
lib/vhost/virtio_net.c| 11 +++--------1 file changed, 3 insertions(+), 8 deletions(-)
Quoted 5 lines
Applied to dpdk-next-virtio/main.
Thanks,
Maxime
As you suggested on IRC, I added back the comment that got removed:
@@ -3136,6 +3136,12 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id,
count = 0;
goto out;
}
+ /*
+ * Inject it to the head of "pkts" array, so that switch's mac
+ * learning table will get updated first.
+ */
+ pkts[0] = rarp_mbuf;
+ pkts++;
count -= 1;
}Regards,
Maxime