Skip to contentSkip to conversation

vhost: rework RARP packet injection

PATCH Applied David Marchand 3 participants 5 messages Sep 15, 2021 – Sep 28, 2021

lore
Share & tools
lore
#0 lore raw

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
index 8549afbbe1..1d30ad0fd9 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · David Marchand

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 +2 -3
index 8549afbbe1..1d30ad0fd9 100644
@@ -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

Reviewed-by on v1 1/1
#2 lore raw
In reply to David Marchand
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.

---
 lib/vhost/virtio_net.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

--
2.23.0

Thanks!

#4 lore raw
Quoted 11 lines · Maxime Coquelin
Quoted 7 lines · David Marchand

Caught by code review, this copy is unnecessary.

---
  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