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 6784045984; Sat, 14 Sep 2024 03:49:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A457F40695; Sat, 14 Sep 2024 03:49:40 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2092.outbound.protection.outlook.com [40.107.237.92]) by mails.dpdk.org (Postfix) with ESMTP id 324A44026C for ; Sat, 14 Sep 2024 03:49:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lR+tQ075XKEHdsZai4Wlcti0emX4ksl67cMVi1Z7gZA1s/mSOJKnI2Nsvylc8eHc9Z3BxkX2kMJaMwilSh2YG5XDsHasMbJdOy3QCL1HxWJyiftK1JdISvxVl2EiSHnqS09PuDsnbk0OYFSndqJJl1ri/3ZKcQtdfgrZ+b9pZNyeQ37C8QRyH7gIiC4DtjmkW1H8y+HRopXu8vMgbdtK7cQZ+J6vlbkisDsoH3i2rwn6kYT4l0SaJzcg4tzCBxcJ5ae4VJZYYEr5JODSyTbCoyaq87v/dXUizs2ZU1WDATIIgMDllIcU88wAHVVeW2J7zyRrZG0Pe/tie0mnU+19jQ== 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=5HhxpvtdHk1Ho0iEfMOI6eLUC9EVj1+uJZjjbsyG0nE=; b=VtsZZbqPO4L1lg9plud84e2nE/W0pNgCfwwuD2nx6iqoBYqDvReTphNiZmWaP7YXH4vRbAI7hbq5cJpl+isWeyvSpYq6E+KfFiMXPdi3QK72bYvrO/5h+XbmVgA0bj9bsQGEwv3LxR/u4QNN80vPTwJYOCPsWnoY5w3Ch11x992sFAgDdCSHwQD1XF40JXV0108c+DQ8nJJvqaZ5hn/dpwEpGHVVOi95ZtteyQgj6WeyhYpOtdk/kqM3ISR1idHiM2vOgOq/JcUP37pfKm5QBs7RCgvKrW9oINzGRdbBt/nSA4xYXqYWjLNNTDtGSCZeQ3KEz3W9oMQMMd7CEIuuIg== 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=5HhxpvtdHk1Ho0iEfMOI6eLUC9EVj1+uJZjjbsyG0nE=; b=pJWQjyb/fRxVV3TaaWGTfV9S1cqbTZqc9Fv+sijBvX82CY+h4UKjm9J1gcs+i9/WBCCAGqcTb+CFBl8Dsx39yobxCSht+8H1S6Yh6keQIE87UwQXgbhCJyS/KeT66pB7Vxujr4mEioM6WrJRe21zFprqr5P1npo8jYLweg8rou4= 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 PH7PR13MB6243.namprd13.prod.outlook.com (2603:10b6:510:246::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Sat, 14 Sep 2024 01:49:33 +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.7939.022; Sat, 14 Sep 2024 01:49:33 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, James Hershaw , Chaoyong He Subject: [PATCH v3 1/2] app/testpmd: add support for setting device EEPROM Date: Sat, 14 Sep 2024 09:49:12 +0800 Message-Id: <20240914014913.2886626-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240914014913.2886626-1-chaoyong.he@corigine.com> References: <20240912065459.2858959-1-chaoyong.he@corigine.com> <20240914014913.2886626-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR03CA0128.apcprd03.prod.outlook.com (2603:1096:4:91::32) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB6243:EE_ X-MS-Office365-Filtering-Correlation-Id: adbefb51-3653-4709-b3bf-08dcd45f7b5e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?SRucV7Iz1JzFJ3J/w+/Xd5zYlWORYVtwL9uUsLJ6rkKAz4wTopK6zx92zGXr?= =?us-ascii?Q?+zmoLkpO2LURaH/Kj0uC8426i8wT2pwZCf0HzM164pUFOdhwoI77YEerOf63?= =?us-ascii?Q?XvDxSGEOwS8xdDe+pX+Y+1Fz08gFleaTQpKNeU85T7imfxMnop2DRXHMzhmK?= =?us-ascii?Q?OUlpMgWvn9gxkV55S27J1BnVJaBVSxyw19kTP8JdGOhpVkDd/i9XpfkrXHMr?= =?us-ascii?Q?8Y5ehLV9qhqPOrWghekXqSMK9D0DWTExmmOq34/2or5kSygnD00XUfBBhQ8S?= =?us-ascii?Q?uuGQAe5adVk76fAo1HYHo/qvmwGRQP9Iua04rkhUJdkGvarOiDqUC7ZaGIM4?= =?us-ascii?Q?3iyI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uwoP3OXBCCkTGC5?= =?us-ascii?Q?byYJsGwubqzFrO5mTB/VPEO72dCbKx4/TSRX+lTwupx22EKfmxuYEn/d7P6N?= =?us-ascii?Q?8Fva+cZHVtR7YdkRrXJmoAt69ZIV8aZgcILStm18pj9zTw=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)(366016)(52116014)(376014)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?FxA/i0nspkGwgnlJHOjDEtnu/sxRbuNoUcT3JUN1CRo28yrJaI+uytsUEpfn?= =?us-ascii?Q?l7U5LE4/LYeaOppmyzgbD0I9UtzyjCTKuAnG6EXPYvHXu0pw+7nP/TZzJJBG?= =?us-ascii?Q?TnwvOQNT9Eub56MrFoxoPgs4P8a1iSrXjkr60AvjrxmbqbbjHshouDydLodT?= =?us-ascii?Q?ucKZBMfo/LBDkQDkmiKsmn8VVoG3ZG8pOyOq93Hcs7N1UulXRg6qZ35CLKbm?= =?us-ascii?Q?wjUEb7CFg1GlxG/0S6qb4lO2vVEavU6ACh/g67GuvPaj82LFGuhcR6KWB/8o?= =?us-ascii?Q?czhdwSpaQNIaTGrvGnRaDl18kj0Hj8oeld9P1TxntLm/Emp8RgZXnuyqHqWh?= =?us-ascii?Q?bWrKWlW7i/MqYrBQVkdp3ZVWJE4ehDOM4OAnWcwifrYSkdKOGl53KEA0Qnjl?= =?us-ascii?Q?7pw2sLcm7u4PD+UJeb+wEDz2O73cok6SD11OWNhJWOyqIfojnhIcAxbF1Auq?= =?us-ascii?Q?CPbGMktZtyikO7gCUmmQi3BXT8lHAoUUeLGO/xPtZ9Okqxyp6/kLCgBJIWFW?= =?us-ascii?Q?58iufLvgh1nLMi5nsDY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UyV9HKRU5NYyaLbF9oethDKe5GZCd4W/spHrrTnEXKKMCo+6GR+JRzGgZw0?= =?us-ascii?Q?KPw7eUn3984xuKLwyq0s04D/K38pEHUGi3Et3WZmn/k+ZOcCgWpSOHZkdu6J?= =?us-ascii?Q?hCrNarULDQTVq8WLEzN+JTHe+65pgAWXPf66Fd3RKvg7BF3D4GXt7UJ/VTC2?= =?us-ascii?Q?9w=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: adbefb51-3653-4709-b3bf-08dcd45f7b5e X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2024 01:49:33.8229 (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: pYV1t7zdfhgRRjYQMfThHhWLlNbkaYmC6uQBT677EcA9xbTZ28uPX+1RSb/GDzfqNGInIeH0xbMraW0MqbUurD/DlkcUzBkD885XEi7tCis= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6243 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 | 122 ++++++++++++++++++++ app/test-pmd/config.c | 66 +++++++++++ app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 16 +++ 4 files changed, 206 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 358319c20a..51c72b0826 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,118 @@ 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) +{ + char *token; + char *token_str; + uint32_t length; + uint32_t offset = 0; + struct cmd_seteeprom_result *res = parsed_result; + + 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\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\n", token); + 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 */ + char *end; + token = strtok_r(token_str, " \f\n\r\t\v", &token_str); + if (token == NULL) { + fprintf(stderr, "No offset specified\n"); + return; + } + 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 +13274,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..fb1a1485e2 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1063,6 +1063,72 @@ 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) +{ + int ret; + int len_eeprom; + struct rte_dev_eeprom_info einfo; + + 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) { + switch (len_eeprom) { + case -ENODEV: + fprintf(stderr, "port index %d invalid\n", port_id); + break; + case -ENOTSUP: + fprintf(stderr, "operation not supported by device\n"); + break; + case -EIO: + fprintf(stderr, "device is removed\n"); + break; + default: + fprintf(stderr, "Unable to get EEPROM: %d\n", + len_eeprom); + break; + } + 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) { + switch (ret) { + case -ENODEV: + fprintf(stderr, "port index %d invalid\n", port_id); + break; + case -ENOTSUP: + fprintf(stderr, "operation not supported by device\n"); + break; + case -EIO: + fprintf(stderr, "device is removed\n"); + break; + default: + fprintf(stderr, "Unable to get EEPROM: %d\n", ret); + break; + } + } +} + 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..f9dd380ea0 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1359,6 +1359,22 @@ 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 eeprom magic \ + value 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 that 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