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 9577F458ED; Tue, 3 Sep 2024 07:53:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6766A40E3E; Tue, 3 Sep 2024 07:53:12 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2111.outbound.protection.outlook.com [40.107.94.111]) by mails.dpdk.org (Postfix) with ESMTP id 8075740295 for ; Tue, 3 Sep 2024 07:53:04 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RZnSIMbLptXZi2c9/XvMcvB9VmzSffY35kL7SWP1FuP7289UPyG9A/8UWXea4CumyPIV3wi3KPMvHj7Qf/7BS0WXZBP0c0gjuyLBFur/NUoZhnXDnm3usKcM+enPGH42pqtUPkS18lCPDehLCdpVvyI0r/k+igHj406QA74RX/xrxy8bbCy/iHGMh2XOq1TNlHBjtcngV9UF5p35zy873xrzn+Qmjq9tTDo4PNIO0q7u/Eb32pADZyCq2+7Z1C2cGFW906Yh10MYrbAUQ3uhlWijCZhSVaAaLcj4tPeKwCE1Dd18l0jQJn9c8KWqqioNNaAKOU9GPP2lli9wbwD/0w== 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=BagBIIV6+WSC554+crCoWPGyxnLsTbYck1Kj74C2WwY=; b=pq2zLCKO6ybj/VL1BwpppievXCbW4wm/5siruSGt9MwgZL52q6FYSFq//TOjLcyFzjZ0QKK6diPpk4p6OmgNVUawe2fHcYUrJMLupepII8/8R2C0u3uyLfNIQ/reLwhodS3xPbv1/ucW3/D6x4jCU0iUqU814QfM/7kdh0BpTNkv79KFztw9l4ooSRDFI19+w3Q78RMrKA5652OkYWXnw5DV9iI0L/8e5x4f5Yy0RPF9hki6F8QSL+Pf3QrCbAxx1Yx9JzLegwviypvc0BX6jOisWTE5lm0ZwPa4ZOQpQwaYrBRpJg6i5Cr2X0cQTb2AheCNoFBh4EMo68np5Mjt1g== 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=BagBIIV6+WSC554+crCoWPGyxnLsTbYck1Kj74C2WwY=; b=BY8qNJAqvm6Vi5+EE2a6VS57V0kMSd+s5MXJxh4B8R9BDyt1/gObNppICVLjqR3VUfqA1JAZ72rcBpZU0BFsfRGHQ6r/MnZM6otnRWifi5z1yQdZv+43qg6rSDkjcIVmogZs9ymTSCPxZACNT/tXqxx8AkqafSidrQ/c/jcVavw= 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 SA1PR13MB6126.namprd13.prod.outlook.com (2603:10b6:806:335::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Tue, 3 Sep 2024 05:53:03 +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.7918.020; Tue, 3 Sep 2024 05:53:02 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 2/3] net/nfp: add two APIs of the NSP module Date: Tue, 3 Sep 2024 13:52:38 +0800 Message-Id: <20240903055239.2642656-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240903055239.2642656-1-chaoyong.he@corigine.com> References: <20240903055239.2642656-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0334.namprd03.prod.outlook.com (2603:10b6:a03:39c::9) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA1PR13MB6126:EE_ X-MS-Office365-Filtering-Correlation-Id: ed5bb82a-fe1d-4887-44a9-08dccbdcac73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?qfo9u2tvyrR4FlyX8gK1TSMoZpwMzYs39qWLfT6EMfqT6UUtkPNvraWKUQXH?= =?us-ascii?Q?bm7V6cL6/z40EHXHDqUm0V5PyrvEBuH1lN0XaD5F4/RgHJw/RSkXXzL+1Hpq?= =?us-ascii?Q?G59lAJWt69qCk2GIiMS8slUdbL7k6sNG1Ojnhpcns0FVdoTWEWo8+xZmLNLY?= =?us-ascii?Q?U1U0SnMersC+s2hZiP+gkUORyhUzxdP70PQN+JDgne55//eAFrRlbiige+Ll?= =?us-ascii?Q?AGAIogpA+Y3uaLD6Onxn+vxEPb6OTij00X8BS7J+9Jb8PcakFl4P/Wpxatd0?= =?us-ascii?Q?BJG1ExkbnsK25A7W9AqyneMXc+am9nX+zrolMdEneDoaVhe5RgUNoAAdsT5u?= =?us-ascii?Q?XsIXkMNKH0DWa9zqMeoWkIS7+VWfuuw6l3kdujs4h+YED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8WlWCioeoY4mkA+BumRdcrOJBTPLsqqyTGxgAksY5fpcnp6V4NUm?= =?us-ascii?Q?pnGX0Ds59q7Jd6TN5Ly784ogBG1mRXMBVVDbBOQeaG3T9T2n3/1YphThbGuu?= =?us-ascii?Q?uWO+BUr2tkRYVdiksMDL7mavPc4xAiq8ylHrKvFjgMS9Fm6zow=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)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?J37ob02CQSxOIdxDj34V4sbqmJ/SBo/cgNFP9JgzynWRSx6D6xkZtwh63aUG?= =?us-ascii?Q?Kjxr42uiVLx693VLGZ0QzN6yw7mYREch+qvJ4yYVEqCOeLlYbPzTO61dFIMW?= =?us-ascii?Q?sK9PiETaMe7sb5J/OeuvTJ51XZcIQSBmRDmSriwmU3mhE4k4eSKvtdB+KBYi?= =?us-ascii?Q?qkQJ/IfaTIIbJSaQHdlV+EjjtG9MOf2kkBUTT9vkNinJjmgxNjCl/J8CHKlg?= =?us-ascii?Q?1AAs+ZPwbRxyugGlKAy4UfNmBNkSNk26QY82o3Oo5nAisEPSpne2ZxDXg048?= =?us-ascii?Q?X4wjpwq/NSHjwEuKecWi0SH0ilQIR41ql7ioN6k3ohkrRrB/nd3CM+xx1AMA?= =?us-ascii?Q?tnjPsaR04VtzZQhuBQH05tnfEVx5VaASBRlC3N1Nm4xOUWb8ikLEFy8I/C/Q?= =?us-ascii?Q?fPysxnhFzlS+sV3QUPuFsqfURKnnTWxAjA6tkBJAk586RKQKhe6uDX22f71Q?= =?us-ascii?Q?uIV7aBqExBTvKv+B6eSeK0HuEv1DJffLpfAKqi8m0DF6oR/QLC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KTafu9/zsRTFRil2wo2lNGTzFJ+4YwfKy2afrMtHQKgifKmQ1jjV?= =?us-ascii?Q?0MlRNjckx+TXDvlk/OZu/UQ2XicpWpKnfnpI6nRBtwh14Q/NCZzcXlBbQt8x?= =?us-ascii?Q?YoAWgYcViCKNuOg3/9AGRtEuR9Q9N3AB9Pi3E7XVGYO3/J2osKHM8XL8Fi1p?= =?us-ascii?Q?4zay5RIrp0rAYirJvL7p2l6sde1UvKAiopSbhZPQM+7iAOJTyyIIBqbSIczI?= =?us-ascii?Q?Ng=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed5bb82a-fe1d-4887-44a9-08dccbdcac73 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 05:53:02.9039 (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: znWMLMYDEHim0gZ8MpROp0DJgWbJ56YXjJIqCt3owZbRKMv2eXivZ3esFEhC7nwkG7F0/qJCGNTxQw2B21U1QIvXI/J2UNOqD8LHEgIIT18= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR13MB6126 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 Add two APIs of the NSP module, also modify the logic to use the argument to control the log switch for NSP command. Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/nfpcore/nfp_nsp.c | 86 ++++++++++++++++++++++++++++++- drivers/net/nfp/nfpcore/nfp_nsp.h | 15 ++++++ 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c index 7dfb472723..2ac39b10b5 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp.c @@ -60,6 +60,8 @@ #define NFP_FW_LOAD_RET_MAJOR GENMASK_ULL(15, 8) #define NFP_FW_LOAD_RET_MINOR GENMASK_ULL(23, 16) +#define NFP_HWINFO_LOOKUP_SIZE GENMASK_ULL(11, 0) + enum nfp_nsp_cmd { SPCODE_NOOP = 0, /* No operation */ SPCODE_SOFT_RESET = 1, /* Soft reset the NFP */ @@ -477,7 +479,9 @@ nfp_nsp_command_buf_def(struct nfp_nsp *nsp, FIELD_PREP(NSP_BUFFER_ADDRESS, cpp_buf); ret = nfp_nsp_command_real(nsp, &arg->arg); if (ret < 0) { - PMD_DRV_LOG(ERR, "NSP command failed"); + if (!arg->arg.error_quiet) + PMD_DRV_LOG(ERR, "NSP command failed"); + return ret; } @@ -755,3 +759,83 @@ nfp_nsp_read_media(struct nfp_nsp *state, return nfp_nsp_command_buf(state, &media); } + +int +nfp_nsp_load_stored_fw(struct nfp_nsp *state) +{ + int ret; + struct nfp_nsp_command_buf_arg fw_stored = { + { + .code = SPCODE_FW_STORED, + .error_cb = nfp_nsp_load_fw_extended_msg, + }, + }; + + ret = nfp_nsp_command_buf(state, &fw_stored); + if (ret < 0) + return ret; + + nfp_nsp_load_fw_extended_msg(state, ret); + + return 0; +} + +static int +nfp_nsp_hwinfo_lookup_real(struct nfp_nsp *state, + void *buf, + size_t size, + bool optional) +{ + struct nfp_nsp_command_buf_arg hwinfo_lookup = { + { + .code = SPCODE_HWINFO_LOOKUP, + .option = size, + .error_quiet = optional, + }, + .in_buf = buf, + .in_size = size, + .out_buf = buf, + .out_size = size, + }; + + return nfp_nsp_command_buf(state, &hwinfo_lookup); +} + +int +nfp_nsp_hwinfo_lookup_optional(struct nfp_nsp *state, + void *buf, + size_t size, + const char *default_val) +{ + int ret; + size_t min_size; + + if (strnlen(default_val, size) == size) { + PMD_DRV_LOG(ERR, "NSP HWinfo default value not NULL terminated"); + return -EINVAL; + } + + if (!nfp_nsp_has_hwinfo_lookup(state)) + goto default_return; + + min_size = RTE_MIN(size, NFP_HWINFO_LOOKUP_SIZE); + ret = nfp_nsp_hwinfo_lookup_real(state, buf, min_size, true); + if (ret != 0) { + if (ret == -ENOENT) + goto default_return; + + PMD_DRV_LOG(ERR, "NSP HWinfo lookup failed: %d", ret); + return ret; + } + + if (strnlen(buf, min_size) == min_size) { + PMD_DRV_LOG(ERR, "NSP HWinfo value not NULL terminated"); + return -EINVAL; + } + + return 0; + +default_return: + strlcpy(buf, default_val, size); + return 0; +} diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.h b/drivers/net/nfp/nfpcore/nfp_nsp.h index 003cdc5fa3..cfb5066fc9 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp.h +++ b/drivers/net/nfp/nfpcore/nfp_nsp.h @@ -8,6 +8,18 @@ #include "nfp_cpp.h" +/* Defines the valid values of the 'abi_drv_reset' hwinfo key */ +#define NFP_NSP_DRV_RESET_DISK 0 +#define NFP_NSP_DRV_RESET_ALWAYS 1 +#define NFP_NSP_DRV_RESET_NEVER 2 +#define NFP_NSP_DRV_RESET_DEFAULT "0" + +/* Defines the valid values of the 'app_fw_from_flash' hwinfo key */ +#define NFP_NSP_APP_FW_LOAD_DISK 0 +#define NFP_NSP_APP_FW_LOAD_FLASH 1 +#define NFP_NSP_APP_FW_LOAD_PREF 2 +#define NFP_NSP_APP_FW_LOAD_DEFAULT "2" + struct nfp_nsp; struct nfp_nsp *nfp_nsp_open(struct nfp_cpp *cpp); @@ -225,6 +237,9 @@ enum nfp_nsp_sensor_id { int nfp_hwmon_read_sensor(struct nfp_cpp *cpp, enum nfp_nsp_sensor_id id, uint32_t *val); bool nfp_nsp_fw_loaded(struct nfp_nsp *state); +int nfp_nsp_load_stored_fw(struct nfp_nsp *state); +int nfp_nsp_hwinfo_lookup_optional(struct nfp_nsp *state, + void *buf, size_t size, const char *default_val); /* The buf used to receive bitmap of link modes */ struct nfp_eth_media_buf { -- 2.39.1