[1/4] examples/qos_sched: fix errors when TX port not up

Message ID 20230203100533.10377-2-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series small fixes and improvements for qos_sched example |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Bruce Richardson Feb. 3, 2023, 10:05 a.m. UTC
  The TX port config will fail if the port is not up, so wait 10 seconds
on startup for it to start.

Fixes: de3cfa2c9823 ("sched: initial import")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 examples/qos_sched/init.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
  

Comments

Cristian Dumitrescu Feb. 17, 2023, 4:19 p.m. UTC | #1
> -----Original Message-----
> From: Richardson, Bruce <bruce.richardson@intel.com>
> Sent: Friday, February 3, 2023 10:06 AM
> To: dev@dpdk.org
> Cc: Singh, Jasvinder <jasvinder.singh@intel.com>; Richardson, Bruce
> <bruce.richardson@intel.com>; stable@dpdk.org; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>
> Subject: [PATCH 1/4] examples/qos_sched: fix errors when TX port not up
> 
> The TX port config will fail if the port is not up, so wait 10 seconds
> on startup for it to start.
> 
> Fixes: de3cfa2c9823 ("sched: initial import")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  examples/qos_sched/init.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  

Patch

diff --git a/examples/qos_sched/init.c b/examples/qos_sched/init.c
index 0709aec10c..6020367705 100644
--- a/examples/qos_sched/init.c
+++ b/examples/qos_sched/init.c
@@ -326,6 +326,8 @@  int app_init(void)
 	for(i = 0; i < nb_pfc; i++) {
 		uint32_t socket = rte_lcore_to_socket_id(qos_conf[i].rx_core);
 		struct rte_ring *ring;
+		struct rte_eth_link link = {0};
+		int retry_count = 100, retry_delay = 100; /* try every 100ms for 10 sec */
 
 		snprintf(ring_name, MAX_NAME_LEN, "ring-%u-%u", i, qos_conf[i].rx_core);
 		ring = rte_ring_lookup(ring_name);
@@ -356,6 +358,14 @@  int app_init(void)
 		app_init_port(qos_conf[i].rx_port, qos_conf[i].mbuf_pool);
 		app_init_port(qos_conf[i].tx_port, qos_conf[i].mbuf_pool);
 
+		rte_eth_link_get(qos_conf[i].tx_port, &link);
+		if (link.link_status == 0)
+			printf("Waiting for link on port %u\n", qos_conf[i].tx_port);
+		while (link.link_status == 0 && retry_count--) {
+			rte_delay_ms(retry_delay);
+			rte_eth_link_get(qos_conf[i].tx_port, &link);
+		}
+
 		qos_conf[i].sched_port = app_init_sched_port(qos_conf[i].tx_port, socket);
 	}