Skip to contentSkip to conversation

examples/flow_filtering: add delay during updating link status

PATCH Superseded Beilei Xing 3 participants 9 messages Jan 24, 2018 – Feb 1, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/flow_filtering: add delay during updating link status

Add up to 9s delay for getting link status to make sure NIC updates link status successfully, just like other applications such as testpmd and l2fwd.

---
 examples/flow_filtering/main.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
examples/flow_filtering/main.c +11 -1
index 4a07b63..1788f24 100644
@@ -55,6 +55,7 @@
 #include <rte_mbuf.h>
 #include <rte_net.h>
 #include <rte_flow.h>
+#include <rte_cycles.h>
 
 static volatile bool force_quit;
 
@@ -119,13 +120,22 @@ main_loop(void)
 	rte_eth_dev_close(port_id);
 }
 
+#define CHECK_INTERVAL 1000  /* 100ms */
+#define MAX_REPEAT_TIME 90   /* 9s (90 * 100ms) in total */
+
 static void
 assert_link_status(void)
 {
 	struct rte_eth_link link;
+	uint8_t rep_cnt = MAX_REPEAT_TIME;
 
 	memset(&link, 0, sizeof(link));
-	rte_eth_link_get(port_id, &link);
+	do {
+		rte_eth_link_get(port_id, &link);
+		if (link.link_status == ETH_LINK_UP)
+			break;
+	} while (--rep_cnt);
+
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
 }
Signature · 1 line
2.5.5
#1 lore raw

Hi Beilei,

PSB

Quoted 29 lines

-----Original Message-----
From: Beilei Xing [mailto:[email protected]]
Sent: Wednesday, January 24, 2018 9:53 AM
To: Ori Kam <[email protected]>
Cc: [email protected]
Subject: [PATCH] examples/flow_filtering: add delay during updating link status

Add up to 9s delay for getting link status to make sure NIC updates link status successfully, just like other applications such as testpmd and l2fwd.

---
 examples/flow_filtering/main.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
examples/flow_filtering/main.c +1 -0
index 4a07b63..1788f24 100644
@@ -55,6 +55,7 @@
 #include <rte_mbuf.h>
 #include <rte_net.h>
 #include <rte_flow.h>
+#include <rte_cycles.h>
 
 static volatile bool force_quit;
 

examples/flow_filtering/main.c main_loop(void) · line 123

Quoted 4 lines
examples/flow_filtering/main.c +1 -0
@@ -119,13 +120,22 @@ main_loop(void)
 	rte_eth_dev_close(port_id);
 }
 
+#define CHECK_INTERVAL 1000  /* 100ms */

This define is not used.

Quoted 5 lines
examples/flow_filtering/main.c +2 -0
+#define MAX_REPEAT_TIME 90   /* 9s (90 * 100ms) in total */
+
 static void
 assert_link_status(void)
 {

examples/flow_filtering/main.c main_loop(void) · line 137

Quoted 10 lines
examples/flow_filtering/main.c +6 -1
 	struct rte_eth_link link;
+	uint8_t rep_cnt = MAX_REPEAT_TIME;
 
 	memset(&link, 0, sizeof(link));
-	rte_eth_link_get(port_id, &link);
+	do {
+		rte_eth_link_get(port_id, &link);
+		if (link.link_status == ETH_LINK_UP)
+			break;
+	} while (--rep_cnt);

I think you are missing the rte_delay_ms(CHECK_INTERVAL);
Currently the code will work for 90 iterations but we can't grantee the duration.

Quoted 5 lines
examples/flow_filtering/main.c +1 -1
+
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");  }
--

2.5.5

Regards,
Ori

#2 lore raw
Quoted 59 lines

-----Original Message-----
From: Ori Kam [mailto:[email protected]]
Sent: Wednesday, January 24, 2018 4:17 PM
To: Xing, Beilei <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH] examples/flow_filtering: add delay during updating link status

Hi Beilei,

PSB

Quoted 10 lines

-----Original Message-----
From: Beilei Xing [mailto:[email protected]]
Sent: Wednesday, January 24, 2018 9:53 AM
To: Ori Kam <[email protected]>
Cc: [email protected]
Subject: [PATCH] examples/flow_filtering: add delay during updating link status

Add up to 9s delay for getting link status to make sure NIC updates link status successfully, just like other applications such as testpmd and

l2fwd.

Quoted 19 lines
---
 examples/flow_filtering/main.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/examples/flow_filtering/main.c index 4a07b63..1788f24 100644

examples/flow_filtering/main.c +1 -0
@@ -55,6 +55,7 @@
 #include <rte_mbuf.h>
 #include <rte_net.h>
 #include <rte_flow.h>
+#include <rte_cycles.h>
 
 static volatile bool force_quit;
 

examples/flow_filtering/main.c main_loop(void) · line 123

Quoted 4 lines
examples/flow_filtering/main.c +1 -0
@@ -119,13 +120,22 @@ main_loop(void)
 	rte_eth_dev_close(port_id);
 }
 
+#define CHECK_INTERVAL 1000  /* 100ms */

This define is not used.

Quoted 8 lines
examples/flow_filtering/main.c +3 -0
+#define MAX_REPEAT_TIME 90   /* 9s (90 * 100ms) in total */
+
 static void
 assert_link_status(void)
 {
 	struct rte_eth_link link;
+	uint8_t rep_cnt = MAX_REPEAT_TIME;
 
Quoted 10 lines

examples/flow_filtering/main.c main_loop(void) · line 137

Quoted 7 lines
examples/flow_filtering/main.c +5 -1
 	memset(&link, 0, sizeof(link));
-	rte_eth_link_get(port_id, &link);
+	do {
+		rte_eth_link_get(port_id, &link);
+		if (link.link_status == ETH_LINK_UP)
+			break;
+	} while (--rep_cnt);

I think you are missing the rte_delay_ms(CHECK_INTERVAL); Currently the code will work for 90 iterations but we can't grantee the duration.

Sorry for missing rte_delay_ms in this patch, will send v2 later, thanks.

Quoted 9 lines
Quoted 6 lines
examples/flow_filtering/main.c +1 -1
+
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");  }
--

2.5.5

Regards,
Ori

#3 lore raw

PATCH v2 1/1 examples/flow_filtering: add delay during updating link status

In reply to Beilei Xing

Add up to 9s delay for getting link status to make sure NIC updates link status successfully, just like other applications such as testpmd and l2fwd.

---

v2 changes:
- Add rte_delay_ms(CHECK_INTERVAL) which is missed in v1.

 examples/flow_filtering/main.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
examples/flow_filtering/main.c +12 -1
index 4a07b63..85d5727 100644
@@ -55,6 +55,7 @@
 #include <rte_mbuf.h>
 #include <rte_net.h>
 #include <rte_flow.h>
+#include <rte_cycles.h>
 
 static volatile bool force_quit;
 
@@ -119,13 +120,23 @@ main_loop(void)
 	rte_eth_dev_close(port_id);
 }
 
+#define CHECK_INTERVAL 1000  /* 100ms */
+#define MAX_REPEAT_TIME 90   /* 9s (90 * 100ms) in total */
+
 static void
 assert_link_status(void)
 {
 	struct rte_eth_link link;
+	uint8_t rep_cnt = MAX_REPEAT_TIME;
 
 	memset(&link, 0, sizeof(link));
-	rte_eth_link_get(port_id, &link);
+	do {
+		rte_eth_link_get(port_id, &link);
+		if (link.link_status == ETH_LINK_UP)
+			break;
+		rte_delay_ms(CHECK_INTERVAL);
+	} while (--rep_cnt);
+
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
 }
Signature · 1 line
2.5.5
#4 lore raw

Hi

Quoted 33 lines

-----Original Message-----
From: Beilei Xing [mailto:[email protected]]
Sent: Wednesday, January 24, 2018 10:35 AM
To: Ori Kam <[email protected]>
Cc: [email protected]
Subject: [PATCH v2] examples/flow_filtering: add delay during updating link status

Add up to 9s delay for getting link status to make sure NIC updates link status successfully, just like other applications such as testpmd and l2fwd.

---

v2 changes:
- Add rte_delay_ms(CHECK_INTERVAL) which is missed in v1.

 examples/flow_filtering/main.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
examples/flow_filtering/main.c +1 -0
index 4a07b63..85d5727 100644
@@ -55,6 +55,7 @@
 #include <rte_mbuf.h>
 #include <rte_net.h>
 #include <rte_flow.h>
+#include <rte_cycles.h>
 
 static volatile bool force_quit;
 

examples/flow_filtering/main.c main_loop(void) · line 124

Quoted 5 lines
examples/flow_filtering/main.c +2 -0
@@ -119,13 +120,23 @@ main_loop(void)
 	rte_eth_dev_close(port_id);
 }
 
+#define CHECK_INTERVAL 1000  /* 100ms */
+#define MAX_REPEAT_TIME 90   /* 9s (90 * 100ms) in total */

I know that in other examples there is use of MAX_REPEAT_TIME but don't you think the name is incorrect, It should be called:
MAX_REPEAT_TIMES or MAX_REPEAT_COUNT?
Since it doesn't represent time but iterations. What do you think?

Quoted 20 lines
examples/flow_filtering/main.c +9 -2
+
 static void
 assert_link_status(void)
 {
 	struct rte_eth_link link;
+	uint8_t rep_cnt = MAX_REPEAT_TIME;
 
 	memset(&link, 0, sizeof(link));
-	rte_eth_link_get(port_id, &link);
+	do {
+		rte_eth_link_get(port_id, &link);
+		if (link.link_status == ETH_LINK_UP)
+			break;
+		rte_delay_ms(CHECK_INTERVAL);
+	} while (--rep_cnt);
+
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");  }
--

2.5.5

#5 lore raw
Quoted 50 lines

-----Original Message-----
From: Ori Kam [mailto:[email protected]]
Sent: Wednesday, January 24, 2018 4:56 PM
To: Xing, Beilei <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH v2] examples/flow_filtering: add delay during updating link status

Hi

Quoted 10 lines

-----Original Message-----
From: Beilei Xing [mailto:[email protected]]
Sent: Wednesday, January 24, 2018 10:35 AM
To: Ori Kam <[email protected]>
Cc: [email protected]
Subject: [PATCH v2] examples/flow_filtering: add delay during updating link status

Add up to 9s delay for getting link status to make sure NIC updates link status successfully, just like other applications such as testpmd and

l2fwd.

Quoted 26 lines

---

v2 changes:
- Add rte_delay_ms(CHECK_INTERVAL) which is missed in v1.

 examples/flow_filtering/main.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/examples/flow_filtering/main.c index 4a07b63..85d5727 100644

examples/flow_filtering/main.c +1 -0
@@ -55,6 +55,7 @@
 #include <rte_mbuf.h>
 #include <rte_net.h>
 #include <rte_flow.h>
+#include <rte_cycles.h>
 
 static volatile bool force_quit;
 
@@ -119,13 +120,23 @@ main_loop(void)
 	rte_eth_dev_close(port_id);
 }
 
Quoted 9 lines

examples/flow_filtering/main.c main_loop(void) · line 124

Quoted 2 lines
examples/flow_filtering/main.c +2 -0
+#define CHECK_INTERVAL 1000  /* 100ms */
+#define MAX_REPEAT_TIME 90   /* 9s (90 * 100ms) in total */

I know that in other examples there is use of MAX_REPEAT_TIME but don't you think the name is incorrect, It should be called:
MAX_REPEAT_TIMES or MAX_REPEAT_COUNT?
Since it doesn't represent time but iterations.
What do you think?

Make sense, looks like MAX_REPEAT_TIMES should be more accurate than MAX_REPEAT_TIME. Will update in next version.

Quoted 20 lines
Quoted 20 lines
examples/flow_filtering/main.c +9 -2
+
 static void
 assert_link_status(void)
 {
 	struct rte_eth_link link;
+	uint8_t rep_cnt = MAX_REPEAT_TIME;
 
 	memset(&link, 0, sizeof(link));
-	rte_eth_link_get(port_id, &link);
+	do {
+		rte_eth_link_get(port_id, &link);
+		if (link.link_status == ETH_LINK_UP)
+			break;
+		rte_delay_ms(CHECK_INTERVAL);
+	} while (--rep_cnt);
+
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");  }
--

2.5.5

#6 lore raw

PATCH v3 1/1 examples/flow_filtering: add delay during updating link status

In reply to Beilei Xing

Add up to 9s delay for getting link status to make sure NIC updates link status successfully, just like other applications such as testpmd and l2fwd.

---
v3 changes:
- Modify MAX_REPEAT_TIME with MAX_REPEAT_TIMES
v2 changes:
- Add rte_delay_ms(CHECK_INTERVAL) which is missed in v1.

 examples/flow_filtering/main.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
examples/flow_filtering/main.c +12 -1
index 4a07b63..d16a0a5 100644
@@ -55,6 +55,7 @@
 #include <rte_mbuf.h>
 #include <rte_net.h>
 #include <rte_flow.h>
+#include <rte_cycles.h>
 
 static volatile bool force_quit;
 
@@ -119,13 +120,23 @@ main_loop(void)
 	rte_eth_dev_close(port_id);
 }
 
+#define CHECK_INTERVAL 1000  /* 100ms */
+#define MAX_REPEAT_TIMES 90  /* 9s (90 * 100ms) in total */
+
 static void
 assert_link_status(void)
 {
 	struct rte_eth_link link;
+	uint8_t rep_cnt = MAX_REPEAT_TIMES;
 
 	memset(&link, 0, sizeof(link));
-	rte_eth_link_get(port_id, &link);
+	do {
+		rte_eth_link_get(port_id, &link);
+		if (link.link_status == ETH_LINK_UP)
+			break;
+		rte_delay_ms(CHECK_INTERVAL);
+	} while (--rep_cnt);
+
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
 }
Signature · 1 line
2.5.5
Acked-by on v3 1/1
#7 lore raw
Quoted 62 lines

-----Original Message-----
From: Beilei Xing [mailto:[email protected]]
Sent: Wednesday, January 24, 2018 12:16 PM
To: Ori Kam <[email protected]>
Cc: [email protected]
Subject: [PATCH v3] examples/flow_filtering: add delay during updating link status

Add up to 9s delay for getting link status to make sure NIC updates link status successfully, just like other applications such as testpmd and l2fwd.

---
v3 changes:
- Modify MAX_REPEAT_TIME with MAX_REPEAT_TIMES
v2 changes:
- Add rte_delay_ms(CHECK_INTERVAL) which is missed in v1.

 examples/flow_filtering/main.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
examples/flow_filtering/main.c +12 -2
index 4a07b63..d16a0a5 100644
@@ -55,6 +55,7 @@
 #include <rte_mbuf.h>
 #include <rte_net.h>
 #include <rte_flow.h>
+#include <rte_cycles.h>
 
 static volatile bool force_quit;
 
@@ -119,13 +120,23 @@ main_loop(void)
 	rte_eth_dev_close(port_id);
 }
 
+#define CHECK_INTERVAL 1000  /* 100ms */
+#define MAX_REPEAT_TIMES 90  /* 9s (90 * 100ms) in total */
+
 static void
 assert_link_status(void)
 {
 	struct rte_eth_link link;
+	uint8_t rep_cnt = MAX_REPEAT_TIMES;
 
 	memset(&link, 0, sizeof(link));
-	rte_eth_link_get(port_id, &link);
+	do {
+		rte_eth_link_get(port_id, &link);
+		if (link.link_status == ETH_LINK_UP)
+			break;
+		rte_delay_ms(CHECK_INTERVAL);
+	} while (--rep_cnt);
+
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
 }
--
Quoted 1 line

2.5.5

Thanks,
Ori