DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: fix devargs format in port attach
@ 2025-10-30  9:20 Gregory Etelson
  2025-10-30 15:53 ` Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Gregory Etelson @ 2025-10-30  9:20 UTC (permalink / raw)
  To: dev
  Cc: getelson, mkashani, rasland, Dariusz Sosnowski, Aman Singh, Shani Peretz

The port attach procedure discarded PCI port devargs provided
by application.
The patch restores PCI port devargs.

Fixes: 12c2405989f6 ("app/testpmd: canonicalize short PCI name format")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 app/test-pmd/testpmd.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 2360da3a48..cc384f0b14 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3413,7 +3413,7 @@ reset_port(portid_t pid)
 }
 
 static char *
-convert_pci_address_format(const char *identifier, char *pci_buffer, size_t buf_size)
+convert_pci_address_format(const char *identifier, char *pci_buffer)
 {
 	struct rte_devargs da;
 	struct rte_pci_addr pci_addr;
@@ -3430,7 +3430,8 @@ convert_pci_address_format(const char *identifier, char *pci_buffer, size_t buf_
 	if (rte_pci_addr_parse(da.name, &pci_addr) != 0)
 		return NULL;
 
-	rte_pci_device_name(&pci_addr, pci_buffer, buf_size);
+	rte_pci_device_name(&pci_addr, pci_buffer, PCI_PRI_STR_SIZE);
+	sprintf(pci_buffer + strlen(pci_buffer), ",%s", da.args);
 	return pci_buffer;
 }
 
@@ -3439,8 +3440,7 @@ attach_port(char *identifier)
 {
 	portid_t pi;
 	struct rte_dev_iterator iterator;
-	char *long_identifier;
-	char long_format[PCI_PRI_STR_SIZE];
+	char *long_format, *long_identifier;
 
 	printf("Attaching a new port...\n");
 
@@ -3448,9 +3448,14 @@ attach_port(char *identifier)
 		fprintf(stderr, "Invalid parameters are specified\n");
 		return;
 	}
+	long_format = alloca(strlen(identifier) + PCI_PRI_STR_SIZE);
+	if (long_format == NULL) {
+		TESTPMD_LOG(ERR, "Failed to attach port %s - allocation failure\n", identifier);
+		return;
+	}
 
 	/* For PCI device convert to canonical format */
-	long_identifier = convert_pci_address_format(identifier, long_format, sizeof(long_format));
+	long_identifier = convert_pci_address_format(identifier, long_format);
 	if (long_identifier != NULL)
 		identifier = long_identifier;
 
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-10-31  6:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-30  9:20 [PATCH] app/testpmd: fix devargs format in port attach Gregory Etelson
2025-10-30 15:53 ` Stephen Hemminger
2025-10-30 17:17 ` [PATCH v2] " Gregory Etelson
2025-10-30 17:47   ` Stephen Hemminger
2025-10-31  6:18 ` [PATCH v3] " Gregory Etelson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).