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 ED665459C5; Wed, 18 Sep 2024 04:39:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 21B9E40BA2; Wed, 18 Sep 2024 04:39:15 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2125.outbound.protection.outlook.com [40.107.93.125]) by mails.dpdk.org (Postfix) with ESMTP id 3FF7C4029B for ; Wed, 18 Sep 2024 04:39:12 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uIf0r/M2IIEdD3DoY2UQMFgu71IZD48QijpsOg3HVd0r3LztWWB1p7N5yi3TCLMUWQ5U+xqLPOCzC9/gyasFFrmy1tCg4IhVEAYcjSfodkVLLbyzzc+1mgk2iaQPWDeMVS9D0WSWFH0NNUc/YPT1bDYny1/3KAX54eVB1bSBRK6hsl9lBNQI+tz0F2mxCB6BCsf6MYLmkgfj0E2gXIamEGZdBeHiol4uLdbgZRFIlXWWy7jlHSGY4iwxBBFsjkUhUZsaBnwkxErBQslvbKGrU8/Dm6PDMs4L16oTC/XuQxwVTF6RPfBphh0gojcSTGgvUtWhURzDYFKv8HscX004Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rA+U2XMxjTI/LJnHCSt3HaVl0ScYy5hE9sMN7Qc2gKA=; b=NaxpDG+qbU5xNJpDKBpLb2gI90buqQUArF9DpyGccOh0lPUWCnfgc0wqSaCz07McKH+Tkfr990yAOVwirIVKxXzn6vGOy+zl1uubJ3ccfMdf46EXupmfceCPP5gMwT3NukOb2kJ0KWYjNRtP9eION1yPDYjlJ1lFb9GHmldpuibIcXonU+QvRY2EzqYQSrvuh77FyQ5RlW3HCXGL/pcmTx1SFctvhEcE5AU9+3DjbfIjUOZPC/9sjyZ1byXlXvR82/9SGf6hWniTQrEayPFXWjq+wEaDNTFBZ0j/v+cHwcSKFVoNagE8q6OrtMZWUSseNjEV+G5XG3eh5NZvVA9aIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rA+U2XMxjTI/LJnHCSt3HaVl0ScYy5hE9sMN7Qc2gKA=; b=pZUOY2P6wxXebLyK7LEmSCYDU/hCM0mUKqvmYLFnQfIyOUIQqsFJJ+KuoOvzHbMlxJR+ejsMuiHqDYFs30MmZKvV6nN13Q8UigrIQnuX78ydQzFVA9PaLRjUnSj352CrjFCJ0/Oomik8S1159kA2zCjHPRX05Hpq2vKb6VM52gQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by BY1PR13MB6939.namprd13.prod.outlook.com (2603:10b6:a03:5ae::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.16; Wed, 18 Sep 2024 02:39:10 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%4]) with mapi id 15.20.7982.012; Wed, 18 Sep 2024 02:39:10 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, James Hershaw , Chaoyong He Subject: [PATCH v4 1/2] app/testpmd: add support for setting device EEPROM Date: Wed, 18 Sep 2024 10:38:46 +0800 Message-Id: <20240918023847.2964100-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240918023847.2964100-1-chaoyong.he@corigine.com> References: <20240914014913.2886626-1-chaoyong.he@corigine.com> <20240918023847.2964100-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0083.apcprd02.prod.outlook.com (2603:1096:4:90::23) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BY1PR13MB6939:EE_ X-MS-Office365-Filtering-Correlation-Id: 06726d2a-800f-4f3c-8f06-08dcd78b135a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5UK9SZCdnSR9M1snlXHcqTtYtXGid7BJkcmJ92OJ/QH4oopw8sY24nDLZzEf?= =?us-ascii?Q?0rmrVyGQkyFaKzAT9lHMIoelGbvCuKAN0eHgLANrDek7YBko/NMyWloQV7U1?= =?us-ascii?Q?9uNsvbxV6d/WbbROz8FweEX/hBxxzZu+ddlZccYEp8jCqMZwZKAJut7zw7Sz?= =?us-ascii?Q?ocQrcmQElObyfmf0VYogdr27Ss28C+c9fwgtVKmR5XE8JGiBFNU2XZD2dkao?= =?us-ascii?Q?ydbyiOZt77Ym2BoxLxQpgnH0kqrDw+krZVykIRVn7/F6nnaoefms/aeRwNVA?= =?us-ascii?Q?fSAGSLJMg3EGLWE5vDqqsoSDrfvFXipmZo9wsXw94VR58dH1lCINdZ+hkEWx?= =?us-ascii?Q?TB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= =?us-ascii?Q?TY3gZJuWQSuKpqKYBXfKcnEGsdx2rr2gWCxCMdJqRlaEdgqIBPgnmwYnhH5t?= =?us-ascii?Q?5zCa0LrcP/OfKEMtO+vzYSGdwCA2mngCFbTqXQiOBWTGqA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(52116014)(366016)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?9Hz+dbSc4u+DdpqiynQXGOph0fbM+97A28gjVCMieMNeSpAD6JdbAHiToeXo?= =?us-ascii?Q?croUF3/I8x0UgmT12n4qoZIoN6sIHYMUn7r565JqkW0bzrGo4tTStj7e+Z+F?= =?us-ascii?Q?yWjXX2nTgyjwd93LHtkQU4fPwC0khxyI6BMx81DyIL0GJEvkcoK68iXhfPMQ?= =?us-ascii?Q?3hsqdScZhKM1SSHEb6OiJgey7J5c3hHqSg4pe0BKHedUD1h/nDHAM4cctjdK?= =?us-ascii?Q?t0h8mbjCokYiXM7KdtV/Cr3FgnZ7EpPZaeh+3eWnYlc4dIsrnMSkTHEblHBr?= =?us-ascii?Q?XqCVipva2PSEhwKYyofHWv9sJ2DgmtNMFL62HSeMURYJOUGp8co0MEyJm3UG?= =?us-ascii?Q?/IISEKMvg8lZMOe+WzngwEzxiW3eL7U9cSwNJ6WMk/hB3iktKN/Z+gh5Yh+b?= =?us-ascii?Q?RDZZhIKsO/9yFn1MgG/EuwzLNqZvBpJE6xO9hn0WytZbz8MUl0I8DVoY8Egg?= =?us-ascii?Q?jj9Fkvd7JD+tBmGg/vwx31tYCgQeUqGQajwXSFxpNEpEghfzNU7jMqj21eSP?= =?us-ascii?Q?Ihwygyadp/DxLIBzp9GRw6u0F/A0Zk3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R9?= =?us-ascii?Q?NvUn/6cO8+9BKlB3+I7679xeftig8EVUuuGNJAyw+CBBoFx/SP6mDVmza1Gj?= =?us-ascii?Q?b6vUT+986I8Bv7VHL8LzsXIeqxiXo4TwAJn8Pc8VLFrI1doMT1ETMkbsdNgJ?= =?us-ascii?Q?6PNqoc2Dp+jSss4BHSCKWU4pCbKim3hnQA/q2jqp7f25bG+l0lTPO7+lvaTs?= =?us-ascii?Q?xg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06726d2a-800f-4f3c-8f06-08dcd78b135a X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2024 02:39:10.6665 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: exGG6dAIVB+kFFJIYGoFN4BkXvvhngIyGcBVFGvh6cpvmLpAPYAtgPT57zUEJ2/nl6DNkrwmeFMZdFKTb7wIY8DolHwXiW01WQKJqFDbEog= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR13MB6939 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 From: James Hershaw There is currently no means to test the .set_eeprom function callback of a given PMD in drivers/net/. This patch adds functionality to allow a user to set device eeprom from the testpmd cmdline. Usage: testpmd> set port eeprom magic \ value offset - is a fixed string that is required from the user to acknowledge the risk involved in using this command and accepting the reposibility for that. - is a decimal - is a hex-as-string with no leading "0x" - is a decimal (this field is optional and defaults to 0 if not specified.) Signed-off-by: James Hershaw Reviewed-by: Chaoyong He --- app/test-pmd/cmdline.c | 123 ++++++++++++++++++++ app/test-pmd/config.c | 39 +++++++ app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 18 +++ 4 files changed, 182 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 358319c20a..a227d3cdc5 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -514,6 +514,15 @@ static void cmd_help_long_parsed(void *parsed_result, "set eth-peer (port_id) (peer_addr)\n" " set the peer address for certain port.\n\n" + "set port (port_id) eeprom (confirm) magic (magic_num)" + " value (value) offset (offset)\n" + " Set the device eeprom for certain port.\nNote:\n" + " This is a high-risk command and its misuse may" + " result in unexpected behaviour from the NIC.\n" + " By inserting \"confirm\" into the command, the" + " user is acknowledging and taking responsibility for" + " this risk.\n\n" + "set port (port_id) uta (mac_address|all) (on|off)\n" " Add/Remove a or all unicast hash filter(s)" "from port X.\n\n" @@ -7488,6 +7497,119 @@ static cmdline_parse_inst_t cmd_set_fwd_eth_peer = { }, }; +/* *** SET PORT EEPROM *** */ +struct cmd_seteeprom_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + uint16_t portnum; + cmdline_fixed_string_t eeprom; + cmdline_fixed_string_t confirm_str; + cmdline_fixed_string_t magic_str; + uint32_t magic; + cmdline_fixed_string_t value; + cmdline_multi_string_t token_str; +}; + +static void cmd_seteeprom_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_seteeprom_result *res = parsed_result; + uint32_t offset = 0; + uint32_t length; + char *token_str; + char *token; + + token_str = res->token_str; + token = strtok_r(token_str, " \f\n\r\t\v", &token_str); + + /* Parse Hex string to Byte data */ + if (strlen(token) % 2 != 0) { + fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n", + token); + return; + } + + length = strlen(token) / 2; + uint8_t value[length]; + for (int count = 0; count < (int)(length); count++) { + if (sscanf(token, "%2hhx", &value[count]) != 1) { + fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n", + token - (count + 1)); + return; + } + token += 2; + } + + /* Second token: offset string */ + token = strtok_r(token_str, " \f\n\r\t\v", &token_str); + if (token != NULL) { + if (strcmp(token, "offset") == 0) { + /* Third token: offset */ + token = strtok_r(token_str, " \f\n\r\t\v", &token_str); + if (token == NULL) { + fprintf(stderr, "No offset specified\n"); + return; + } + + char *end; + offset = strtoul(token, &end, 10); + if (offset == 0 && strcmp(end, "") != 0) { + fprintf(stderr, "Bad Argument: %s\n", token); + return; + } + } else { + fprintf(stderr, "Bad Argument: %s\n", token); + return; + } + } + + port_eeprom_set(res->portnum, res->magic, offset, length, value); +} + +static cmdline_parse_token_string_t cmd_seteeprom_set = + TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set"); +static cmdline_parse_token_string_t cmd_seteeprom_port = + TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port"); +static cmdline_parse_token_num_t cmd_seteeprom_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16); +static cmdline_parse_token_string_t cmd_seteeprom_eeprom = + TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom"); +static cmdline_parse_token_string_t cmd_seteeprom_confirm_str = + TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "confirm"); +static cmdline_parse_token_string_t cmd_seteeprom_magic_str = + TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic"); +static cmdline_parse_token_num_t cmd_seteeprom_magic = + TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32); +static cmdline_parse_token_string_t cmd_seteeprom_value = + TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value"); +static cmdline_parse_token_string_t cmd_seteeprom_token_str = + TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI); + +static cmdline_parse_inst_t cmd_seteeprom = { + .f = cmd_seteeprom_parsed, + .data = NULL, + .help_str = "set port eeprom magic " + "value offset : Set eeprom value for port_id.\n" + "Note:\n" + "This is a high-risk command and its misuse may result in " + "unexpected behaviour from the NIC.\n" + "By inserting \"confirm\" into the command, the user is " + "acknowledging and taking responsibility for this risk.", + .tokens = { + (void *)&cmd_seteeprom_set, + (void *)&cmd_seteeprom_port, + (void *)&cmd_seteeprom_portnum, + (void *)&cmd_seteeprom_eeprom, + (void *)&cmd_seteeprom_confirm_str, + (void *)&cmd_seteeprom_magic_str, + (void *)&cmd_seteeprom_magic, + (void *)&cmd_seteeprom_value, + (void *)&cmd_seteeprom_token_str, + NULL, + }, +}; + /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ struct cmd_set_qmap_result { cmdline_fixed_string_t set; @@ -13153,6 +13275,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { &cmd_showport, &cmd_showqueue, &cmd_showeeprom, + &cmd_seteeprom, &cmd_showportall, &cmd_representor_info, &cmd_showdevice, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 6f0beafa27..73549b2b57 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1063,6 +1063,45 @@ port_eeprom_display(portid_t port_id) free(einfo.data); } +void +port_eeprom_set(portid_t port_id, + uint32_t magic, + uint32_t offset, + uint32_t length, + uint8_t *value) +{ + struct rte_dev_eeprom_info einfo; + int len_eeprom; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) { + print_valid_ports(); + return; + } + + len_eeprom = rte_eth_dev_get_eeprom_length(port_id); + if (len_eeprom < 0) { + fprintf(stderr, "Unable to get EEPROM length: %s\n", + rte_strerror(-len_eeprom)); + return; + } + + einfo.data = value; + einfo.magic = magic; + einfo.length = length; + einfo.offset = offset; + + if (einfo.offset + einfo.length > (uint32_t)(len_eeprom)) { + fprintf(stderr, "offset and length exceed capabilities of EEPROM length: %d\n", + len_eeprom); + return; + } + + ret = rte_eth_dev_set_eeprom(port_id, &einfo); + if (ret != 0) + fprintf(stderr, "Unable to set EEPROM: %s\n", rte_strerror(-ret)); +} + void port_module_eeprom_display(portid_t port_id) { diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 9facd7f281..1292d1a0a7 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -927,6 +927,8 @@ void device_infos_display(const char *identifier); void port_infos_display(portid_t port_id); void port_summary_display(portid_t port_id); void port_eeprom_display(portid_t port_id); +void port_eeprom_set(portid_t port_id, uint32_t magic, uint32_t offset, + uint32_t length, uint8_t *value); void port_module_eeprom_display(portid_t port_id); void port_summary_header_display(void); void rx_queue_infos_display(portid_t port_idi, uint16_t queue_id); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index f00ab07605..5c33d610ea 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1359,6 +1359,24 @@ Set the forwarding peer address for certain port:: This is equivalent to the ``--eth-peer`` command-line option. +set eeprom +~~~~~~~~~~ + +Write a value to the device eeprom of a port at a specific offset:: + + testpmd> set port (port_id) eeprom (confirm) magic (magic_num) value (value) \ + offset (offset) + +Value should be given in the form of a hex-as-string, with no leading ``0x``. +The offset field here is optional, if not specified then the offset will default +to 0. + +.. note:: + + This is a high-risk command and its misuse may result in unexpected + behaviour from the NIC. By inserting "confirm" into the command, the user is + acknowledging and taking responsibility for this risk. + set port-uta ~~~~~~~~~~~~ -- 2.39.1