Skip to contentSkip to conversation

vhost: add port mirroring function in the vhost lib

PATCH In review Cheng Jiang 3 participants 8 messages Apr 21, 2023 – May 17, 2023

lore
Share & tools
lore
#0 lore raw

cover vhost: add port mirroring function in the vhost lib

Similar to the port mirroring function on the switch or router, this patch set implements such function on the Vhost lib. When data is sent to a front-end, it will also send the data to its mirror front-end. When data is received from a front-end, it will also send the data to its mirror front-end.

Cheng Jiang (2):
vhost: add ingress API for port mirroring datapath
vhost: add egress API for port mirroring datapath

 lib/vhost/rte_vhost_async.h |   17 +
 lib/vhost/version.map       |    3 +
 lib/vhost/virtio_net.c      | 1266 +++++++++++++++++++++++++++++++++++
 3 files changed, 1286 insertions(+)

--
2.35.1

#1 lore raw

PATCH 1/2 vhost: add ingress API for port mirroring datapath

Similar to the port mirroring function on the switch or router, this patch also implements an ingress function on the Vhost lib. When data is sent to a front-end, it will also send the data to its mirror front-end.

---
 lib/vhost/rte_vhost_async.h |   6 +
 lib/vhost/version.map       |   1 +
 lib/vhost/virtio_net.c      | 688 ++++++++++++++++++++++++++++++++++++
 3 files changed, 695 insertions(+)
lib/vhost/rte_vhost_async.h +6 -0
index 8f190dd44b..30aaf66b60 100644
@@ -286,6 +286,12 @@ __rte_experimental
 int
 rte_vhost_async_dma_unconfigure(int16_t dma_id, uint16_t vchan_id);
 
+__rte_experimental
+uint16_t rte_vhost_async_try_egress_burst(int vid, uint16_t queue_id,
+		int mr_vid, uint16_t mr_queue_id,
+		struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count,
+		int *nr_inflight, int16_t dma_id, uint16_t vchan_id);
+
 #ifdef __cplusplus
 }
 #endif
lib/vhost/version.map +1 -0
index d322a4a888..95f75a6928 100644
@@ -98,6 +98,7 @@ EXPERIMENTAL {
 	# added in 22.11
 	rte_vhost_async_dma_unconfigure;
 	rte_vhost_vring_call_nonblock;
+	rte_vhost_async_try_egress_burst;
 };
 
 INTERNAL {
lib/vhost/virtio_net.c +688 -0

691 lines not on this page · raw message

Signature · 1 line
2.35.1
#2 lore raw

PATCH 2/2 vhost: add egress API for port mirroring datapath

In reply to Cheng Jiang

This patch implements egress function on the Vhost lib. When packets are received from a front-end, it will also send the packets to its mirror front-end.

---
 lib/vhost/rte_vhost_async.h |  11 +
 lib/vhost/version.map       |   2 +
 lib/vhost/virtio_net.c      | 682 +++++++++++++++++++++++++++++++++---
 3 files changed, 643 insertions(+), 52 deletions(-)
lib/vhost/rte_vhost_async.h +11 -0
index 30aaf66b60..4df473f1ec 100644
@@ -286,6 +286,17 @@ __rte_experimental
 int
 rte_vhost_async_dma_unconfigure(int16_t dma_id, uint16_t vchan_id);
 
+__rte_experimental
+uint16_t rte_vhost_submit_ingress_mirroring_burst(int vid, uint16_t queue_id,
+		int mirror_vid, uint16_t mirror_queue_id,
+		struct rte_mbuf **pkts, uint16_t count,
+		int16_t dma_id, uint16_t vchan_id);
+
+__rte_experimental
+uint16_t rte_vhost_poll_ingress_completed(int vid, uint16_t queue_id, int mr_vid,
+		uint16_t mr_queue_id, struct rte_mbuf **pkts, uint16_t count,
+		int16_t dma_id, uint16_t vchan_id);
+
 __rte_experimental
 uint16_t rte_vhost_async_try_egress_burst(int vid, uint16_t queue_id,
 		int mr_vid, uint16_t mr_queue_id,
lib/vhost/version.map +2 -0
index 95f75a6928..347ea6ac9c 100644
@@ -98,6 +98,8 @@ EXPERIMENTAL {
 	# added in 22.11
 	rte_vhost_async_dma_unconfigure;
 	rte_vhost_vring_call_nonblock;
+	rte_vhost_submit_ingress_mirroring_burst;
+	rte_vhost_poll_ingress_completed;
 	rte_vhost_async_try_egress_burst;
 };
 
lib/vhost/virtio_net.c +630 -52

701 lines not on this page · raw message

Signature · 1 line
2.35.1
#3 lore raw
In reply to Cheng Jiang

Hi Cheng,

Quoted 5 lines · Cheng Jiang

Similar to the port mirroring function on the switch or router, this patch set implements such function on the Vhost lib. When data is sent to a front-end, it will also send the data to its mirror front-end. When data is received from a front-end, it will also send the data to its mirror front-end.

Why not just keeping mirroring in the switch/router?
I am really not convinced this is the way to go:
1. API is too complex
2. It requires async support
3. There is too much code duplication, it increases virtio-net.c by 30%, and it is without packed ring support.
4. If mirror port is down for any reason, packets to/from the original port are dropped.
5. It seems to assume negotiated features of the two ports are identical, e.g. Virtio-net header length? If so, that's not a manageable solution.

Regards,
Maxime

Quoted 13 lines

Cheng Jiang (2):
vhost: add ingress API for port mirroring datapath
vhost: add egress API for port mirroring datapath

  lib/vhost/rte_vhost_async.h |   17 +
  lib/vhost/version.map       |    3 +
  lib/vhost/virtio_net.c      | 1266 +++++++++++++++++++++++++++++++++++
  3 files changed, 1286 insertions(+)

--
2.35.1

#4 lore raw

Hi Maxime,

Quoted 20 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Wednesday, May 3, 2023 5:37 PM
To: Jiang, Cheng1 <[email protected]>; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; Wang, YuanX <[email protected]>; He, Xingguang <[email protected]>; David Marchand <[email protected]>
Subject: Re: [PATCH 0/2] vhost: add port mirroring function in the vhost lib

Hi Cheng,

Quoted 5 lines · Cheng Jiang

Similar to the port mirroring function on the switch or router, this patch set implements such function on the Vhost lib. When data is sent to a front-end, it will also send the data to its mirror front-end. When data is received from a front-end, it will also send the data to its mirror front-end.

Quoted 11 lines

Why not just keeping mirroring in the switch/router?
I am really not convinced this is the way to go:
1. API is too complex
2. It requires async support
3. There is too much code duplication, it increases virtio-net.c by 30%, and it is without packed ring support.
4. If mirror port is down for any reason, packets to/from the original port are dropped.
5. It seems to assume negotiated features of the two ports are identical, e.g. Virtio-net header length? If so, that's not a manageable solution.

Thank you for your feedback.
I concur that placing the mirror function in the Vhost library is not ideal. We are currently considering implementing either a mirror Vhost PMD, or adding a function to TestPMD to handle this functionality. Would you please share your thoughts on this plan and let us know which option you prefer?

Thanks a lot,
Cheng

Quoted 17 lines

Regards,
Maxime

Quoted 13 lines

Cheng Jiang (2):
vhost: add ingress API for port mirroring datapath
vhost: add egress API for port mirroring datapath

  lib/vhost/rte_vhost_async.h |   17 +
  lib/vhost/version.map       |    3 +
  lib/vhost/virtio_net.c      | 1266 +++++++++++++++++++++++++++++++++++
  3 files changed, 1286 insertions(+)

--
2.35.1

#5 lore raw
Quoted 47 lines

-----Original Message-----
From: Jiang, Cheng1 <[email protected]>
Sent: Monday, May 8, 2023 8:23 PM
To: Maxime Coquelin <[email protected]>; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; Wang, YuanX <[email protected]>; He, Xingguang <[email protected]>; David Marchand <[email protected]>
Subject: RE: [PATCH 0/2] vhost: add port mirroring function in the vhost lib

Hi Maxime,

Quoted 10 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Wednesday, May 3, 2023 5:37 PM
To: Jiang, Cheng1 <[email protected]>; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; Wang, YuanX <[email protected]>; He, Xingguang <[email protected]>; David Marchand <[email protected]>
Subject: Re: [PATCH 0/2] vhost: add port mirroring function in the vhost

lib

Quoted 10 lines

Hi Cheng,

Quoted 5 lines · Cheng Jiang

Similar to the port mirroring function on the switch or router, this patch set implements such function on the Vhost lib. When data is sent to a front-end, it will also send the data to its mirror front-end. When data is received from a front-end, it will also send the data to its mirror front-end.

Quoted 11 lines

Why not just keeping mirroring in the switch/router?
I am really not convinced this is the way to go:
1. API is too complex
2. It requires async support
3. There is too much code duplication, it increases virtio-net.c by 30%, and it is without packed ring support.
4. If mirror port is down for any reason, packets to/from the original port are dropped.
5. It seems to assume negotiated features of the two ports are identical, e.g. Virtio-net header length? If so, that's not a manageable solution.

Quoted 6 lines

Thank you for your feedback.
I concur that placing the mirror function in the Vhost library is not ideal. We are currently considering implementing either a mirror Vhost PMD, or adding a function to TestPMD to handle this functionality. Would you please share your thoughts on this plan and let us know which option you prefer?

Based on current implementation, it seems that vhost lib could be ignorant of the mirroring usage. Making these logic into APP like testpmd seems to make more sense.

Thanks,
Chenbo

Quoted 24 lines

Thanks a lot,
Cheng

Quoted 12 lines

Regards,
Maxime

Quoted 8 lines

Cheng Jiang (2):
vhost: add ingress API for port mirroring datapath
vhost: add egress API for port mirroring datapath

  lib/vhost/rte_vhost_async.h |   17 +
  lib/vhost/version.map       |    3 +
  lib/vhost/virtio_net.c      | 1266

+++++++++++++++++++++++++++++++++++

Quoted 5 lines
Quoted 5 lines
  3 files changed, 1286 insertions(+)

--
2.35.1

#6 lore raw
Quoted 54 lines · Chenbo
Quoted 47 lines

-----Original Message-----
From: Jiang, Cheng1 <[email protected]>
Sent: Monday, May 8, 2023 8:23 PM
To: Maxime Coquelin <[email protected]>; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; Wang, YuanX <[email protected]>; He, Xingguang <[email protected]>; David Marchand <[email protected]>
Subject: RE: [PATCH 0/2] vhost: add port mirroring function in the vhost lib

Hi Maxime,

Quoted 10 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Wednesday, May 3, 2023 5:37 PM
To: Jiang, Cheng1 <[email protected]>; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; Wang, YuanX <[email protected]>; He, Xingguang <[email protected]>; David Marchand <[email protected]>
Subject: Re: [PATCH 0/2] vhost: add port mirroring function in the vhost

lib

Quoted 10 lines

Hi Cheng,

Quoted 5 lines · Cheng Jiang

Similar to the port mirroring function on the switch or router, this patch set implements such function on the Vhost lib. When data is sent to a front-end, it will also send the data to its mirror front-end. When data is received from a front-end, it will also send the data to its mirror front-end.

Quoted 11 lines

Why not just keeping mirroring in the switch/router?
I am really not convinced this is the way to go:
1. API is too complex
2. It requires async support
3. There is too much code duplication, it increases virtio-net.c by 30%, and it is without packed ring support.
4. If mirror port is down for any reason, packets to/from the original port are dropped.
5. It seems to assume negotiated features of the two ports are identical, e.g. Virtio-net header length? If so, that's not a manageable solution.

Quoted 6 lines

Thank you for your feedback.
I concur that placing the mirror function in the Vhost library is not ideal. We are currently considering implementing either a mirror Vhost PMD, or adding a function to TestPMD to handle this functionality. Would you please share your thoughts on this plan and let us know which option you prefer?

Quoted 3 lines

Based on current implementation, it seems that vhost lib could be ignorant of the mirroring usage. Making these logic into APP like testpmd seems to make more sense.

I agree with Chenbo, it should be done at the application level, which would enable to also mirror non-Vhost ports.

Thanks,
Maxime

Quoted 28 lines

Thanks,
Chenbo

Quoted 24 lines

Thanks a lot,
Cheng

Quoted 12 lines

Regards,
Maxime

Quoted 8 lines

Cheng Jiang (2):
vhost: add ingress API for port mirroring datapath
vhost: add egress API for port mirroring datapath

   lib/vhost/rte_vhost_async.h |   17 +
   lib/vhost/version.map       |    3 +
   lib/vhost/virtio_net.c      | 1266

+++++++++++++++++++++++++++++++++++

Quoted 5 lines
Quoted 5 lines
   3 files changed, 1286 insertions(+)

--
2.35.1

#7 lore raw

Hi Maxime/Chenbo,

Quoted 71 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Thursday, May 11, 2023 8:16 PM
To: Xia, Chenbo <[email protected]>; Jiang, Cheng1 <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; Wang, YuanX <[email protected]>; He, Xingguang <[email protected]>; David Marchand <[email protected]>
Subject: Re: [PATCH 0/2] vhost: add port mirroring function in the vhost lib

Quoted 7 lines · Chenbo
Quoted 7 lines

-----Original Message-----
From: Jiang, Cheng1 <[email protected]>
Sent: Monday, May 8, 2023 8:23 PM
To: Maxime Coquelin <[email protected]>; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; Wang,

YuanX

Quoted 7 lines
Quoted 7 lines

<[email protected]>; He, Xingguang <[email protected]>; David Marchand <[email protected]>
Subject: RE: [PATCH 0/2] vhost: add port mirroring function in the vhost lib

Hi Maxime,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Wednesday, May 3, 2023 5:37 PM
To: Jiang, Cheng1 <[email protected]>; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; Wang,

YuanX

Quoted 34 lines
Quoted 33 lines
Quoted 4 lines

<[email protected]>; He, Xingguang <[email protected]>; David Marchand <[email protected]>
Subject: Re: [PATCH 0/2] vhost: add port mirroring function in the vhost

lib

Quoted 10 lines

Hi Cheng,

Quoted 5 lines · Cheng Jiang

Similar to the port mirroring function on the switch or router, this patch set implements such function on the Vhost lib. When data is sent to a front-end, it will also send the data to its mirror front-end. When data is received from a front-end, it will also send the data to its mirror front-end.

Quoted 11 lines

Why not just keeping mirroring in the switch/router?
I am really not convinced this is the way to go:
1. API is too complex
2. It requires async support
3. There is too much code duplication, it increases virtio-net.c by 30%, and it is without packed ring support.
4. If mirror port is down for any reason, packets to/from the original port are dropped.
5. It seems to assume negotiated features of the two ports are identical, e.g. Virtio-net header length? If so, that's not a manageable solution.

Thank you for your feedback.
I concur that placing the mirror function in the Vhost library is not ideal. We are currently considering implementing either a mirror Vhost PMD, or adding a function to TestPMD to handle this functionality. Would you please share your thoughts on this plan and let us know which option you prefer?

Quoted 6 lines
Quoted 3 lines

Based on current implementation, it seems that vhost lib could be ignorant of the mirroring usage. Making these logic into APP like testpmd seems to make more sense.

I agree with Chenbo, it should be done at the application level, which would enable to also mirror non-Vhost ports.

I mostly agree with your opinions. However, the workload for implementing a general mirror framework to support all ports in the application level would be too large for us for now. Currently, we are more focused on demonstrating the superior performance advantages of async Vhost and DSA with this mirror work. Therefore, we may need to temporarily put this upstream process on hold.

I greatly appreciate your feedback and help. Maybe we can discuss the details in the future. Thank you again!

Best regards,
Cheng

Quoted 32 lines

Thanks,
Maxime

Quoted 28 lines

Thanks,
Chenbo

Quoted 24 lines

Thanks a lot,
Cheng

Quoted 12 lines

Regards,
Maxime

Quoted 8 lines

Cheng Jiang (2):
vhost: add ingress API for port mirroring datapath
vhost: add egress API for port mirroring datapath

   lib/vhost/rte_vhost_async.h |   17 +
   lib/vhost/version.map       |    3 +
   lib/vhost/virtio_net.c      | 1266

+++++++++++++++++++++++++++++++++++

Quoted 5 lines
Quoted 5 lines
   3 files changed, 1286 insertions(+)

--
2.35.1