Skip to contentSkip to conversation

app/testpmd: fix quit testpmd with vfs and pf

PATCH In review Ke Zhang 6 participants 18 messages Mar 22, 2022 – Aug 8, 2022 Network drivers

lore
Share & tools
lore

Ke Zhang

author
#0 lore raw

PATCH 1/1 app/testpmd: fix quit testpmd with vfs and pf

When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory.

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

---
 app/test-pmd/testpmd.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +23 -5
index f7e18aee25..ca6c77b14b 100644
@@ -3378,8 +3378,11 @@ detach_devargs(char *identifier)
 void
 pmd_test_exit(void)
 {
+	unsigned int ports[RTE_MAX_ETHPORTS];
+	unsigned int count = 0;
 	portid_t pt_id;
 	unsigned int i;
+	int index;
 	int ret;
 
 	if (test_done == 0)
@@ -3396,15 +3399,30 @@ pmd_test_exit(void)
 #endif
 	if (ports != NULL) {
 		no_link_check = 1;
+		i = 0;
+
+		/* Fetch the valid port id from port list*/
 		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nStopping port %d...\n", pt_id);
+			ports[i] = pt_id;
+			i++;
+		}
+
+		count = i;
+		/*
+		 * Free the port from Reverse order, as general,
+		 * PF port < VF port, VF should be free before PF
+		 * be free.
+		 */
+		for (index = count - 1 ; index >= 0 ; index--) {
+			printf("\nStopping port %d...\n", ports[index]);
 			fflush(stdout);
-			stop_port(pt_id);
+			stop_port(ports[index]);
 		}
-		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nShutting down port %d...\n", pt_id);
+
+		for (index = count - 1 ; index >= 0 ; index--) {
+			printf("\nShutting down port %d...\n", ports[index]);
 			fflush(stdout);
-			close_port(pt_id);
+			close_port(ports[index]);
 		}
 	}
 
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Ke Zhang

When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory.

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

---

This fix looks similar to series: 21823. Please check Ferruh's comments on it.

There is a scenario, where this fix may not work.
"if there is an earlier port id which is released, after that new vf is created taking that port id. In such case port id of vf < pf port id"

This patch covers most of the cases and that way its an improvement. So I am ok with it.

Quoted 55 lines
  app/test-pmd/testpmd.c | 28 +++++++++++++++++++++++-----
  1 file changed, 23 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +23 -5
index f7e18aee25..ca6c77b14b 100644
@@ -3378,8 +3378,11 @@ detach_devargs(char *identifier)
  void
  pmd_test_exit(void)
  {
+	unsigned int ports[RTE_MAX_ETHPORTS];
+	unsigned int count = 0;
  	portid_t pt_id;
  	unsigned int i;
+	int index;
  	int ret;
 
  	if (test_done == 0)
@@ -3396,15 +3399,30 @@ pmd_test_exit(void)
  #endif
  	if (ports != NULL) {
  		no_link_check = 1;
+		i = 0;
+
+		/* Fetch the valid port id from port list*/
  		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nStopping port %d...\n", pt_id);
+			ports[i] = pt_id;
+			i++;
+		}
+
+		count = i;
+		/*
+		 * Free the port from Reverse order, as general,
+		 * PF port < VF port, VF should be free before PF
+		 * be free.
+		 */
+		for (index = count - 1 ; index >= 0 ; index--) {
+			printf("\nStopping port %d...\n", ports[index]);
  			fflush(stdout);
-			stop_port(pt_id);
+			stop_port(ports[index]);
  		}
-		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nShutting down port %d...\n", pt_id);
+
+		for (index = count - 1 ; index >= 0 ; index--) {
+			printf("\nShutting down port %d...\n", ports[index]);
  			fflush(stdout);
-			close_port(pt_id);
+			close_port(ports[index]);
  		}
  	}
 
#2 lore raw
Quoted 77 lines · Aman Deep
Quoted 10 lines · Ke Zhang

When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory.

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

---

This fix looks similar to series: 21823. Please check Ferruh's comments on it.

There is a scenario, where this fix may not work.
"if there is an earlier port id which is released, after that new vf is created taking that port id. In such case port id of vf < pf port id"

This patch covers most of the cases and that way its an improvement. So I am ok with it.

Quoted 53 lines

  app/test-pmd/testpmd.c | 28 +++++++++++++++++++++++-----

  1 file changed, 23 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +0 -0
index f7e18aee25..ca6c77b14b 100644
@@ -3378,8 +3378,11 @@ detach_devargs(char *identifier)

  void
  pmd_test_exit(void)
  {
+    unsigned int ports[RTE_MAX_ETHPORTS];
+    unsigned int count = 0;
      portid_t pt_id;
      unsigned int i;
+    int index;
      int ret;
        if (test_done == 0)

app/test-pmd/testpmd.c +20 -5
@@ -3396,15 +3399,30 @@ pmd_test_exit(void)
   #endif
       if (ports != NULL) {
           no_link_check = 1;
+        i = 0;
+
+        /* Fetch the valid port id from port list*/
           RTE_ETH_FOREACH_DEV(pt_id) {
-            printf("\nStopping port %d...\n", pt_id);
+            ports[i] = pt_id;
+            i++;
+        }
+
+        count = i;
+        /*
+         * Free the port from Reverse order, as general,
+         * PF port < VF port, VF should be free before PF
+         * be free.
+         */
+        for (index = count - 1 ; index >= 0 ; index--) {
+            printf("\nStopping port %d...\n", ports[index]);
               fflush(stdout);
-            stop_port(pt_id);
+            stop_port(ports[index]);
           }
-        RTE_ETH_FOREACH_DEV(pt_id) {
-            printf("\nShutting down port %d...\n", pt_id);
+
+        for (index = count - 1 ; index >= 0 ; index--) {
+            printf("\nShutting down port %d...\n", ports[index]);
               fflush(stdout);
-            close_port(pt_id);
+            close_port(ports[index]);
           }
       }
#3 lore raw
In reply to Singh, Aman Deep
Quoted 15 lines · Aman Deep
Quoted 10 lines · Ke Zhang

When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory.

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

---

This fix looks similar to series: 21823. Please check Ferruh's comments on it.

Quoted 8 lines

There is a scenario, where this fix may not work.
"if there is an earlier port id which is released, after that new vf is created taking that port id. In such case port id of vf < pf port id"

This patch covers most of the cases and that way its an improvement. So I am ok with it.

Agree that patch covers most of the cases with simple/small change, so OK to continue with it.

@Ke, can you please check minor comments below.

Quoted 12 lines
Quoted 8 lines

  app/test-pmd/testpmd.c | 28 +++++++++++++++++++++++-----

  1 file changed, 23 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +0 -0
index f7e18aee25..ca6c77b14b 100644
@@ -3378,8 +3378,11 @@ detach_devargs(char *identifier)
Quoted 4 lines

  void
  pmd_test_exit(void)
  {
+    unsigned int ports[RTE_MAX_ETHPORTS];

testpmd holds port IDs as 'portid_t', so can you please change type form 'int' to 'portid_t'?

Quoted 1 line
Quoted 1 line

+    unsigned int count = 0;

For 'index' & 'count', no reason to make one 'unsigned int' and other 'int', better to keep type same for both, and both can be 'int'.

Quoted 3 lines
Quoted 3 lines

      portid_t pt_id;
      unsigned int i;
+    int index;

These new variables only used in one if block, can you please move declaring them to that scope, to the beginning of that block.

Quoted 5 lines
Quoted 5 lines

      int ret;
      if (test_done == 0)

app/test-pmd/testpmd.c +0 -0
@@ -3396,15 +3399,30 @@ pmd_test_exit(void)
   #endif
       if (ports != NULL) {
Quoted 8 lines

app/test-pmd/testpmd.c pmd_test_exit(void) · line 3407

Quoted 8 lines
app/test-pmd/testpmd.c +5 -1
           no_link_check = 1;
+        i = 0;
+
+        /* Fetch the valid port id from port list*/
           RTE_ETH_FOREACH_DEV(pt_id) {
-            printf("\nStopping port %d...\n", pt_id);
+            ports[i] = pt_id;
+            i++;

Can use 'count' directly, instead of 'i'.

Quoted 25 lines
Quoted 24 lines
app/test-pmd/testpmd.c +15 -4
+        }
+
+        count = i;
+        /*
+         * Free the port from Reverse order, as general,
+         * PF port < VF port, VF should be free before PF
+         * be free.
+         */
+        for (index = count - 1 ; index >= 0 ; index--) {
+            printf("\nStopping port %d...\n", ports[index]);
               fflush(stdout);
-            stop_port(pt_id);
+            stop_port(ports[index]);
           }
-        RTE_ETH_FOREACH_DEV(pt_id) {
-            printf("\nShutting down port %d...\n", pt_id);
+
+        for (index = count - 1 ; index >= 0 ; index--) {
+            printf("\nShutting down port %d...\n", ports[index]);
               fflush(stdout);
-            close_port(pt_id);
+            close_port(ports[index]);
           }
       }
author
#4 lore raw

PATCH v2 1/1 app/testpmd: fix quit testpmd with vfs and pf

In reply to Ke Zhang

When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory.

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

Fixes 08fd782b8454 ("app/testpmd: fix quit to stop all ports before close")
---
 app/test-pmd/testpmd.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +22 -5
index 04c39adc21..67b4941942 100644
@@ -3491,17 +3491,34 @@ pmd_test_exit(void)
 		}
 	}
 #endif
+	portid_t ethports[RTE_MAX_ETHPORTS];
+	int count;
+	int index;
 	if (ports != NULL) {
 		no_link_check = 1;
+		count = 0;
+
+		/* Fetch the valid port id from port list*/
 		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nStopping port %d...\n", pt_id);
+			ethports[count] = pt_id;
+			count++;
+		}
+
+		/*
+		 * Free the port from Reverse order, as general,
+		 * PF port < VF port, VF should be free before PF
+		 * be free.
+		 */
+		for (index = count - 1 ; index >= 0 ; index--) {
+			printf("\nStopping port %d...\n", ethports[index]);
 			fflush(stdout);
-			stop_port(pt_id);
+			stop_port(ethports[index]);
 		}
-		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nShutting down port %d...\n", pt_id);
+
+		for (index = count - 1 ; index >= 0 ; index--) {
+			printf("\nShutting down port %d...\n", ethports[index]);
 			fflush(stdout);
-			close_port(pt_id);
+			close_port(ethports[index]);
 		}
 	}
 
Signature · 1 line
2.25.1
#5 lore raw
Quoted 21 lines · Ke Zhang

When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory.

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

Fixes 08fd782b8454 ("app/testpmd: fix quit to stop all ports before close")
---
  app/test-pmd/testpmd.c | 27 ++++++++++++++++++++++-----
  1 file changed, 22 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +0 -0
index 04c39adc21..67b4941942 100644

app/test-pmd/testpmd.c pmd_test_exit(void) · line 3496

Quoted 6 lines
app/test-pmd/testpmd.c +3 -0
@@ -3491,17 +3491,34 @@ pmd_test_exit(void)
  		}
  	}
  #endif
+	portid_t ethports[RTE_MAX_ETHPORTS];
+	int count;
+	int index;

Hi Ke,

These variables only used in the 'if' block, to reduce the scope of them can you please move them at the very top of the block:

if (ports != NULL) {
	portid_t ethports[RTE_MAX_ETHPORTS];
	int count = 0;
	int index;

	no_link_check = 1;

...

Quoted 33 lines
  	if (ports != NULL) {
  		no_link_check = 1;
app/test-pmd/testpmd.c +19 -5
+		count = 0;
+
+		/* Fetch the valid port id from port list*/
  		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nStopping port %d...\n", pt_id);
+			ethports[count] = pt_id;
+			count++;
+		}
+
+		/*
+		 * Free the port from Reverse order, as general,
+		 * PF port < VF port, VF should be free before PF
+		 * be free.
+		 */
+		for (index = count - 1 ; index >= 0 ; index--) {
+			printf("\nStopping port %d...\n", ethports[index]);
  			fflush(stdout);
-			stop_port(pt_id);
+			stop_port(ethports[index]);
  		}
-		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nShutting down port %d...\n", pt_id);
+
+		for (index = count - 1 ; index >= 0 ; index--) {
+			printf("\nShutting down port %d...\n", ethports[index]);
  			fflush(stdout);
-			close_port(pt_id);
+			close_port(ethports[index]);
  		}
  	}
author
#6 lore raw

PATCH v2 1/1 app/testpmd: fix quit testpmd with vfs and pf

In reply to Ke Zhang

When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory.

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

Fixes 08fd782b8454 ("app/testpmd: fix quit to stop all ports before close")
---
 app/test-pmd/testpmd.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +21 -5
index 04c39adc21..c01ecf7279 100644
@@ -3492,16 +3492,32 @@ pmd_test_exit(void)
 	}
 #endif
 	if (ports != NULL) {
+		portid_t ethports[RTE_MAX_ETHPORTS];
+		int count = 0;
+		int index = 0;
 		no_link_check = 1;
+
+		/* Fetch the valid port id from port list*/
 		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nStopping port %d...\n", pt_id);
+			ethports[count] = pt_id;
+			count++;
+		}
+
+		/*
+		 * Free the port from Reverse order, as general,
+		 * PF port < VF port, VF should be free before PF
+		 * be free.
+		 */
+		for (index = count - 1 ; index >= 0 ; index--) {
+			printf("\nStopping port %d...\n", ethports[index]);
 			fflush(stdout);
-			stop_port(pt_id);
+			stop_port(ethports[index]);
 		}
-		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nShutting down port %d...\n", pt_id);
+
+		for (index = count - 1 ; index >= 0 ; index--) {
+			printf("\nShutting down port %d...\n", ethports[index]);
 			fflush(stdout);
-			close_port(pt_id);
+			close_port(ethports[index]);
 		}
 	}
 
Signature · 1 line
2.25.1
Acked-by Aman Singh Acked-by on v2 1/1 Applied
#7 lore raw
Quoted 4 lines · Ke Zhang

When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory.

Quoted 8 lines

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

Fixes 08fd782b8454 ("app/testpmd: fix quit to stop all ports before close")

Applied to dpdk-next-net/main, thanks.

Quoted 9 lines
---
  app/test-pmd/testpmd.c | 26 +++++++++++++++++++++-----
  1 file changed, 21 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +0 -0
index 04c39adc21..c01ecf7279 100644

app/test-pmd/testpmd.c pmd_test_exit(void) · line 3498

Quoted 7 lines
app/test-pmd/testpmd.c +3 -0
@@ -3492,16 +3492,32 @@ pmd_test_exit(void)
  	}
  #endif
  	if (ports != NULL) {
+		portid_t ethports[RTE_MAX_ETHPORTS];
+		int count = 0;
+		int index = 0;
  		no_link_check = 1;

No need to initialize 'index'.

And better to have an empty line after deceleration block.

Quoted 4 lines
app/test-pmd/testpmd.c +2 -1
+
+		/* Fetch the valid port id from port list*/
  		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nStopping port %d...\n", pt_id);

app/test-pmd/testpmd.c pmd_test_exit(void) · line 3511

Quoted 10 lines
app/test-pmd/testpmd.c +10 -0
+			ethports[count] = pt_id;
+			count++;
+		}
+
+		/*
+		 * Free the port from Reverse order, as general,
+		 * PF port < VF port, VF should be free before PF
+		 * be free.
+		 */
+		for (index = count - 1 ; index >= 0 ; index--) {

Space is not needed after ';'.

Since these are minor, I will fix while merging.

#8 lore raw

Sorry, this patch looks really wrong, I cannot pull it into the main branch. See below for an explanation.

21/06/2022 12:43, Ferruh Yigit:

Quoted 41 lines · Ke Zhang
Quoted 4 lines

When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory.

Quoted 8 lines

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

Fixes 08fd782b8454 ("app/testpmd: fix quit to stop all ports before close")

Applied to dpdk-next-net/main, thanks.

Quoted 9 lines
---
  app/test-pmd/testpmd.c | 26 +++++++++++++++++++++-----
  1 file changed, 21 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +0 -0
index 04c39adc21..c01ecf7279 100644

app/test-pmd/testpmd.c pmd_test_exit(void) · line 3498

Quoted 7 lines
app/test-pmd/testpmd.c +3 -0
@@ -3492,16 +3492,32 @@ pmd_test_exit(void)
  	}
  #endif
  	if (ports != NULL) {
+		portid_t ethports[RTE_MAX_ETHPORTS];
+		int count = 0;
+		int index = 0;
  		no_link_check = 1;

No need to initialize 'index'.

And better to have an empty line after deceleration block.

Quoted 12 lines

app/test-pmd/testpmd.c pmd_test_exit(void) · line 3509

Quoted 12 lines
app/test-pmd/testpmd.c +10 -1
+
+		/* Fetch the valid port id from port list*/
  		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nStopping port %d...\n", pt_id);
+			ethports[count] = pt_id;
+			count++;
+		}
+
+		/*
+		 * Free the port from Reverse order, as general,
+		 * PF port < VF port, VF should be free before PF
+		 * be free.

No sorry, this is wrong.
The port ID says nothing.
If a port is closed before creating a VF,
it can be VF < PF.

Quoted 7 lines

app/test-pmd/testpmd.c pmd_test_exit(void) · line 3511

Quoted 2 lines
app/test-pmd/testpmd.c +2 -0
+		 */
+		for (index = count - 1 ; index >= 0 ; index--) {

Space is not needed after ';'.

Since these are minor, I will fix while merging.

#9 lore raw

Adding more about this patch:

testpmd is a test application. It allows you to find some issues in some scenarios. It seems you found an issue and you decided to hide it in the test application. That's really wrong!

This kind of issue should be solved in the API or in the driver. In this case, I believe it should be handled in the driver which should release dependent ports.

22/06/2022 23:31, Thomas Monjalon:

Quoted 71 lines

Sorry, this patch looks really wrong, I cannot pull it into the main branch. See below for an explanation.

21/06/2022 12:43, Ferruh Yigit:

Quoted 41 lines · Ke Zhang
Quoted 4 lines

When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory.

Quoted 8 lines

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

Fixes 08fd782b8454 ("app/testpmd: fix quit to stop all ports before close")

Applied to dpdk-next-net/main, thanks.

Quoted 9 lines
---
  app/test-pmd/testpmd.c | 26 +++++++++++++++++++++-----
  1 file changed, 21 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +0 -0
index 04c39adc21..c01ecf7279 100644

app/test-pmd/testpmd.c pmd_test_exit(void) · line 3498

Quoted 7 lines
app/test-pmd/testpmd.c +3 -0
@@ -3492,16 +3492,32 @@ pmd_test_exit(void)
  	}
  #endif
  	if (ports != NULL) {
+		portid_t ethports[RTE_MAX_ETHPORTS];
+		int count = 0;
+		int index = 0;
  		no_link_check = 1;

No need to initialize 'index'.

And better to have an empty line after deceleration block.

Quoted 12 lines

app/test-pmd/testpmd.c pmd_test_exit(void) · line 3509

Quoted 12 lines
app/test-pmd/testpmd.c +10 -1
+
+		/* Fetch the valid port id from port list*/
  		RTE_ETH_FOREACH_DEV(pt_id) {
-			printf("\nStopping port %d...\n", pt_id);
+			ethports[count] = pt_id;
+			count++;
+		}
+
+		/*
+		 * Free the port from Reverse order, as general,
+		 * PF port < VF port, VF should be free before PF
+		 * be free.

No sorry, this is wrong.
The port ID says nothing.
If a port is closed before creating a VF,
it can be VF < PF.

Quoted 7 lines

app/test-pmd/testpmd.c pmd_test_exit(void) · line 3511

Quoted 2 lines
app/test-pmd/testpmd.c +2 -0
+		 */
+		for (index = count - 1 ; index >= 0 ; index--) {

Space is not needed after ';'.

Since these are minor, I will fix while merging.

author
#10 lore raw

PATCH v3 1/1 app/testpmd: fix quit testpmd with vfs and pf

In reply to Ke Zhang

A segmentation fault occurs when testpmd exit.

This is due to fetching the device name from PF
, PF is freed firstly and then VF representor
is called later.

This commit fixes the bug by fetching the device
name from vf representor not PF.

Fixes e391a7b7f815 ("net/i40e: fix multi-process shared data")

---
v3: Change the design and fix code in driver
v2: Change the testpmd code to fix this issue
---

---
 drivers/net/i40e/i40e_vf_representor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/i40e/i40e_vf_representor.c +1 -3
index 7f8e81858e..bcd445bcdd 100644
@@ -29,8 +29,6 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_vf_representor *representor = ethdev->data->dev_private;
-	struct rte_eth_dev_data *pf_dev_data =
-		representor->adapter->pf.dev_data;
 
 	/* get dev info for the vdev */
 	dev_info->device = ethdev->device;
@@ -104,7 +102,7 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	};
 
 	dev_info->switch_info.name =
-		rte_eth_devices[pf_dev_data->port_id].device->name;
+		rte_eth_devices[ethdev->data->port_id].device->name;
 	dev_info->switch_info.domain_id = representor->switch_domain_id;
 	dev_info->switch_info.port_id = representor->vf_id;
 
Signature · 1 line
2.25.1
#11 lore raw

13/07/2022 09:11, Ke Zhang:

Quoted 1 line

A segmentation fault occurs when testpmd exit.

The title talks about testpmd, but the change is in i40e. Please update.

Quoted 3 lines

This is due to fetching the device name from PF
, PF is freed firstly and then VF representor
is called later.

For info, a comma must follow the previous word without any space. It is strange to see a comma at the beginning of a line.

Quoted 2 lines

This commit fixes the bug by fetching the device
name from vf representor not PF.

vf should be VF uppercase

Quoted 12 lines
Fixes e391a7b7f815 ("net/i40e: fix multi-process shared data")

---
v3: Change the design and fix code in driver
v2: Change the testpmd code to fix this issue
---

---
 drivers/net/i40e/i40e_vf_representor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
author
#12 lore raw

PATCH v4 1/1 net/i40e: fix the issue caused by PF and VF release order

In reply to Ke Zhang

A segmentation fault occurs when testpmd exit.

This is due to fetching the device name from PF, PF is freed firstly and then VF representor is called later.

This commit fixes the bug by fetching the device name from VF representor not PF.

Fixes e391a7b7f815 ("net/i40e: fix multi-process shared data")

---
v4: Update the commit log
v3: Change the design and fix code in driver
v2: Change the testpmd code to fix this issue
---

---
 drivers/net/i40e/i40e_vf_representor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/i40e/i40e_vf_representor.c +1 -3
index 7f8e81858e..bcd445bcdd 100644
@@ -29,8 +29,6 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_vf_representor *representor = ethdev->data->dev_private;
-	struct rte_eth_dev_data *pf_dev_data =
-		representor->adapter->pf.dev_data;
 
 	/* get dev info for the vdev */
 	dev_info->device = ethdev->device;
@@ -104,7 +102,7 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	};
 
 	dev_info->switch_info.name =
-		rte_eth_devices[pf_dev_data->port_id].device->name;
+		rte_eth_devices[ethdev->data->port_id].device->name;
 	dev_info->switch_info.domain_id = representor->switch_domain_id;
 	dev_info->switch_info.port_id = representor->vf_id;
 
Signature · 1 line
2.25.1
Acked-by on v4 1/1
#13 lore raw

RE: [PATCH v4] net/i40e: fix the issue caused by PF and VF release order

Hi Ke,

Please update commit log.
LGTM.

Quoted 9 lines

-----Original Message-----
From: Zhang, Ke1X <[email protected]>
Sent: Friday, July 15, 2022 5:04 PM
To: [email protected]; Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; [email protected]
Cc: Zhang, Ke1X <[email protected]>; [email protected]
Subject: [PATCH v4] net/i40e: fix the issue caused by PF and VF release order

Quoted 7 lines

A segmentation fault occurs when testpmd exit.

This is due to fetching the device name from PF, PF is freed firstly and then VF representor is called later.

This commit fixes the bug by fetching the device name from VF representor not PF.

instead of PF

Quoted 5 lines
Fixes e391a7b7f815 ("net/i40e: fix multi-process shared data")
Quoted 38 lines

---
v4: Update the commit log
v3: Change the design and fix code in driver
v2: Change the testpmd code to fix this issue
---

---
 drivers/net/i40e/i40e_vf_representor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/i40e/i40e_vf_representor.c +0 -2
index 7f8e81858e..bcd445bcdd 100644
@@ -29,8 +29,6 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev
 *ethdev,
 	struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_vf_representor *representor = ethdev->data-
 >dev_private;
-	struct rte_eth_dev_data *pf_dev_data =
-		representor->adapter->pf.dev_data;
 
drivers/net/i40e/i40e_vf_representor.c +1 -2
 	/* get dev info for the vdev */
 	dev_info->device = ethdev->device;
@@ -104,7 +102,7 @@ i40e_vf_representor_dev_infos_get(struct
 rte_eth_dev *ethdev,
 	};
 
 	dev_info->switch_info.name =
-		rte_eth_devices[pf_dev_data->port_id].device->name;
+		rte_eth_devices[ethdev->data->port_id].device->name;
 	dev_info->switch_info.domain_id = representor->switch_domain_id;
 	dev_info->switch_info.port_id = representor->vf_id;
 
--

2.25.1

Applied
#14 lore raw

RE: [PATCH v4] net/i40e: fix the issue caused by PF and VF release order

Quoted 35 lines

-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: Tuesday, August 2, 2022 10:16 AM
To: Zhang, Ke1X <[email protected]>; [email protected]; Xing, Beilei <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v4] net/i40e: fix the issue caused by PF and VF release order

Hi Ke,

Please update commit log.
LGTM.

Quoted 10 lines

-----Original Message-----
From: Zhang, Ke1X <[email protected]>
Sent: Friday, July 15, 2022 5:04 PM
To: [email protected]; Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; [email protected]
Cc: Zhang, Ke1X <[email protected]>; [email protected]
Subject: [PATCH v4] net/i40e: fix the issue caused by PF and VF release order

Quoted 7 lines

A segmentation fault occurs when testpmd exit.

This is due to fetching the device name from PF, PF is freed firstly and then VF representor is called later.

This commit fixes the bug by fetching the device name from VF representor not PF.

Quoted 8 lines

instead of PF

Quoted 5 lines
Fixes e391a7b7f815 ("net/i40e: fix multi-process shared data")

Applied to dpdk-next-net-intel.

Thanks
Qi

#15 lore raw

RE: [PATCH v4] net/i40e: fix the issue caused by PF and VF release order

Quoted 51 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, August 8, 2022 8:06 AM
To: Zhang, Yuying <[email protected]>; Zhang, Ke1X <[email protected]>; [email protected]; Xing, Beilei <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v4] net/i40e: fix the issue caused by PF and VF release order

Quoted 36 lines

-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: Tuesday, August 2, 2022 10:16 AM
To: Zhang, Ke1X <[email protected]>; [email protected]; Xing, Beilei <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v4] net/i40e: fix the issue caused by PF and VF release order

Hi Ke,

Please update commit log.
LGTM.

Quoted 10 lines

-----Original Message-----
From: Zhang, Ke1X <[email protected]>
Sent: Friday, July 15, 2022 5:04 PM
To: [email protected]; Zhang, Yuying <[email protected]>; Xing, Beilei <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; [email protected]
Cc: Zhang, Ke1X <[email protected]>; [email protected]
Subject: [PATCH v4] net/i40e: fix the issue caused by PF and VF release order

Quoted 7 lines

A segmentation fault occurs when testpmd exit.

This is due to fetching the device name from PF, PF is freed firstly and then VF representor is called later.

This commit fixes the bug by fetching the device name from VF representor not PF.

instead of PF

Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Fixes e391a7b7f815 ("net/i40e: fix multi-process shared data")

Applied to dpdk-next-net-intel.

Overwritten by v5 with refined commit log

Quoted 3 lines

Thanks
Qi

author
#16 lore raw

PATCH v5 1/1 net/i40e: fix the issue caused by PF and VF release order

In reply to Ke Zhang

A segmentation fault occurs when testpmd exit.

This is due to fetching the device name from PF, PF is freed firstly and then VF representor is called later.

This commit fixes the bug by fetching the device name from VF representor instead of PF.

Fixes e391a7b7f815 ("net/i40e: fix multi-process shared data")

---
v5: Update the commit log
v4: Update the commit log
v3: Change the design and fix code in driver
v2: Change the testpmd code to fix this issue
---

---
 drivers/net/i40e/i40e_vf_representor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/i40e/i40e_vf_representor.c +1 -3
index 7f8e81858e..bcd445bcdd 100644
@@ -29,8 +29,6 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_vf_representor *representor = ethdev->data->dev_private;
-	struct rte_eth_dev_data *pf_dev_data =
-		representor->adapter->pf.dev_data;
 
 	/* get dev info for the vdev */
 	dev_info->device = ethdev->device;
@@ -104,7 +102,7 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	};
 
 	dev_info->switch_info.name =
-		rte_eth_devices[pf_dev_data->port_id].device->name;
+		rte_eth_devices[ethdev->data->port_id].device->name;
 	dev_info->switch_info.domain_id = representor->switch_domain_id;
 	dev_info->switch_info.port_id = representor->vf_id;
 
Signature · 1 line
2.25.1
Applied
#17 lore raw

RE: [PATCH v5] net/i40e: fix the issue caused by PF and VF release order

Quoted 15 lines

-----Original Message-----
From: Ke Zhang <[email protected]>
Sent: Thursday, August 4, 2022 5:50 PM
To: Xing, Beilei <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Cc: Zhang, Ke1X <[email protected]>; [email protected]
Subject: [PATCH v5] net/i40e: fix the issue caused by PF and VF release order

A segmentation fault occurs when testpmd exit.

This is due to fetching the device name from PF, PF is freed firstly and then VF representor is called later.

Quoted 8 lines

This commit fixes the bug by fetching the device name from VF representor instead of PF.

Fixes e391a7b7f815 ("net/i40e: fix multi-process shared data")

Applied to dpdk-next-net-intel.

Thanks
Qi

Quoted 38 lines

---
v5: Update the commit log
v4: Update the commit log
v3: Change the design and fix code in driver
v2: Change the testpmd code to fix this issue
---

---
 drivers/net/i40e/i40e_vf_representor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/i40e/i40e_vf_representor.c +0 -2
index 7f8e81858e..bcd445bcdd 100644
@@ -29,8 +29,6 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev
 *ethdev,
 	struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_vf_representor *representor = ethdev->data-
 >dev_private;
-	struct rte_eth_dev_data *pf_dev_data =
-		representor->adapter->pf.dev_data;
 
drivers/net/i40e/i40e_vf_representor.c +1 -2
 	/* get dev info for the vdev */
 	dev_info->device = ethdev->device;
@@ -104,7 +102,7 @@ i40e_vf_representor_dev_infos_get(struct
 rte_eth_dev *ethdev,
 	};
 
 	dev_info->switch_info.name =
-		rte_eth_devices[pf_dev_data->port_id].device->name;
+		rte_eth_devices[ethdev->data->port_id].device->name;
 	dev_info->switch_info.domain_id = representor->switch_domain_id;
 	dev_info->switch_info.port_id = representor->vf_id;
 
--

2.25.1