[dpdk-dev] [PATCH v2] examples/multi_proces: fix Rx packets distribution

Gregory Etelson getelson at nvidia.com
Tue Nov 9 10:58:47 CET 2021


MP servers distributes Rx packets between clients according to
round-robin scheme.

Current implementation always started packets distribution from
the first client. That procedure resulted in uniform distribution
in cases when Rx packets number was around clients number
multiplication. However, if RX burst repeatedly returned single
packet, round-robin scheme would not work because all packets
were assigned to the first client only.

The patch does not restart packets distribution from
the first client.
Packets distribution always continues to the next client.

Cc: stable at dpdk.org

Fixes: af75078fece3 ("first public release")

Signed-off-by: Gregory Etelson <getelson at nvidia.com>
Acked-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
v2: Remove explisit static variable initialization.
---
 examples/multi_process/client_server_mp/mp_server/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/examples/multi_process/client_server_mp/mp_server/main.c
index b4761ebc7b..31e7e76706 100644
--- a/examples/multi_process/client_server_mp/mp_server/main.c
+++ b/examples/multi_process/client_server_mp/mp_server/main.c
@@ -234,7 +234,12 @@ process_packets(uint32_t port_num __rte_unused,
 		struct rte_mbuf *pkts[], uint16_t rx_count)
 {
 	uint16_t i;
-	uint8_t client = 0;
+	/*
+	 * C99: All objects with static storage duration
+	 * shall be initialized (set to their initial values) before
+	 * program startup.
+	 */
+	static uint8_t client;
 
 	for (i = 0; i < rx_count; i++) {
 		enqueue_rx_packet(client, pkts[i]);
-- 
2.33.1



More information about the dev mailing list