From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D63B046AE8; Fri, 4 Jul 2025 20:34:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 170414066E; Fri, 4 Jul 2025 20:34:55 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by mails.dpdk.org (Postfix) with ESMTP id E31A74066F for ; Fri, 4 Jul 2025 20:34:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751654094; x=1783190094; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7dX/lrM4iZiLFNJCB5EcTz8XyNiR8qfLQlLlnrJnzj8=; b=QrzJ17DggLLLOluhOtUxoWq7E4IKNs8inmLqCdfQD42wDBGdaY7qnCoy bBSaMPj/9J8a5LUrMUe7H797SZ50Jp60Z5Mpm9mc+zSbu85z2O9al8L3K hla7cm3nr0I0HclExBQFcTldNhxNht8TjkdyLH0qWdjKryvq+N4/Yh3JE 7caCxzoWLDJwE4QOuNKy5c7iMXXftQ8jduUvSqzYeDGptbBT7rZdSb9Ol K3JA+7CVODvjSGVpERnNQwc2tSTbFDAeYYDJuRlxV0yC7I9phRss+yZwH 5rj1Wb+gKbWBYwVPqIkwsww5Z1sgL1USesILpLqXjWmvarjRFgr4ZC88E g==; X-CSE-ConnectionGUID: IqjkhaJnS2eNJifzGmXbFQ== X-CSE-MsgGUID: Y6AgwfpST6y+LOasrcaSTg== X-IronPort-AV: E=McAfee;i="6800,10657,11484"; a="41613074" X-IronPort-AV: E=Sophos;i="6.16,288,1744095600"; d="scan'208";a="41613074" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2025 11:34:54 -0700 X-CSE-ConnectionGUID: Fr/G7fDmTaKOq7FHrANWfw== X-CSE-MsgGUID: IBEyiBUBSTCAgzKs8Dyw9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,288,1744095600"; d="scan'208";a="159042656" Received: from silpixa00401385.ir.intel.com ([10.237.214.33]) by orviesa003.jf.intel.com with ESMTP; 04 Jul 2025 11:34:53 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Subject: [PATCH v2 2/3] app/testpmd: allow multiple commandline file parameters Date: Fri, 4 Jul 2025 19:34:35 +0100 Message-ID: <20250704183437.25901-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250704183437.25901-1-bruce.richardson@intel.com> References: <20250704140551.4151993-1-bruce.richardson@intel.com> <20250704183437.25901-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org While testpmd allows a set of pre-prepared commands to be passed into it at startup via the "cmdline-file" (and cmdline-file-noecho) parameters, this is currently limited to a single file. By extending this support to allow the parameter to be passed multiple (up to 16) times, we enable users to have a library of pre-canned cmdline files and pass multiple of these in to the same run, e.g. have one cmdline file per NIC feature and enable multiple features by passing in multiple filenames. Signed-off-by: Bruce Richardson --- app/test-pmd/parameters.c | 17 +++++++++++------ app/test-pmd/testpmd.c | 13 +++++++++---- app/test-pmd/testpmd.h | 13 +++++++++++-- doc/guides/testpmd_app_ug/run_app.rst | 3 ++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +++--- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 1132972913..ce2ba1c826 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -960,13 +960,18 @@ launch_args_parse(int argc, char** argv) exit(EXIT_SUCCESS); break; case TESTPMD_OPT_CMDLINE_FILE_NUM: - echo_cmdline_file = true; - /* fall-through */ case TESTPMD_OPT_CMDLINE_FILE_NOECHO_NUM: - printf("CLI commands to be read from %s\n", - optarg); - strlcpy(cmdline_filename, optarg, - sizeof(cmdline_filename)); + if (cmdline_file_count >= RTE_DIM(cmdline_files)) { + fprintf(stderr, "Too many cmdline files specified (maximum %zu)\n", + RTE_DIM(cmdline_files)); + exit(EXIT_FAILURE); + } + printf("CLI commands to be read from %s\n", optarg); + strlcpy(cmdline_files[cmdline_file_count].filename, optarg, + sizeof(cmdline_files[cmdline_file_count].filename)); + cmdline_files[cmdline_file_count].echo = + (opt == TESTPMD_OPT_CMDLINE_FILE_NUM); + cmdline_file_count++; break; case TESTPMD_OPT_TX_FIRST_NUM: printf("Ports to start sending a burst of " diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index b498e6d9fe..505e0283fa 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -105,8 +105,8 @@ int testpmd_logtype; /**< Log type for testpmd logs */ uint8_t interactive = 0; uint8_t auto_start = 0; uint8_t tx_first; -char cmdline_filename[PATH_MAX] = {0}; -bool echo_cmdline_file; +struct cmdline_file_info cmdline_files[MAX_CMDLINE_FILENAMES] = {0}; +unsigned int cmdline_file_count; /* * NUMA support configuration. @@ -4508,8 +4508,13 @@ main(int argc, char** argv) rte_exit(EXIT_FAILURE, "Could not initialise cmdline context.\n"); - if (strlen(cmdline_filename) != 0) - cmdline_read_from_file(cmdline_filename, echo_cmdline_file); + for (unsigned int i = 0; i < cmdline_file_count; i++) { + if (cmdline_read_from_file(cmdline_files[i].filename, cmdline_files[i].echo) != 0) { + fprintf(stderr, "Failed to process cmdline file: %s\n", + cmdline_files[i].filename); + break; + } + } if (interactive == 1) { if (auto_start) { diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 1d34f40deb..6ee229cb5c 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -36,6 +36,15 @@ extern uint8_t cl_quit; extern volatile uint8_t f_quit; +/* Max number of cmdline files we can take on testpmd cmdline */ +#define MAX_CMDLINE_FILENAMES 16 + +/* Structure to track cmdline files and their echo settings */ +struct cmdline_file_info { + char filename[PATH_MAX]; /**< Path to the cmdline file */ + bool echo; /**< Whether to echo commands from this file */ +}; + /* * It is used to allocate the memory for hash key. * The hash key size is NIC dependent. @@ -509,8 +518,8 @@ extern int testpmd_logtype; /**< Log type for testpmd logs */ extern uint8_t interactive; extern uint8_t auto_start; extern uint8_t tx_first; -extern char cmdline_filename[PATH_MAX]; /**< offline commands file */ -extern bool echo_cmdline_file; /** unset if cmdline-file-noecho is used */ +extern struct cmdline_file_info cmdline_files[MAX_CMDLINE_FILENAMES]; /**< offline commands files */ +extern unsigned int cmdline_file_count; /**< number of cmdline files */ extern uint8_t numa_support; /**< set by "--numa" parameter */ extern uint16_t port_topology; /**< set by "--port-topology" parameter */ extern uint8_t no_flush_rx; /**