From patchwork Wed Apr 16 21:41:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 14055228 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DF9D22B5B5 for ; Thu, 17 Apr 2025 10:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744884859; cv=none; b=PhpKVSysgF4pk/fBhWzIRt2wjFNMMYGpOYprJzvNRmGWOkDBL+bAJ/MJLgMHXTAIJaZ91WVih/Nf6ZvvEv6Eh/UmPJ85Mw9gqi4gcu7+0/CfMTCtdSei++ZVHw9KmhWnuEGQHlrxBEzQnVXfOmkr5Ji4gr5Lc4/pyZE8jcWHUjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744884859; c=relaxed/simple; bh=yuBKB5F1xxTcBVtR6dshTMhNOoc2QskdeL4oHDc/e7I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j7RDKxhCl/jfuDdm8so32/kgMuj/hYFdC72YWWzvdyUOJu1N5Trc1kUsn8e+nHJgeW3IeCMYvW6b0JcKaP8oftHmohumZQHTqPw8CQjMXl6TLiy4ZUs49REinpcma8LJrp7usbOy8LFC//2QyOTxCdHbh0FslSeDpgRsB8OcaSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=GrSKXIBV; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="GrSKXIBV" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-43ce71582e9so4337775e9.1 for ; Thu, 17 Apr 2025 03:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1744884855; x=1745489655; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pSbJvphKhtV8mfmUJ+DjEluf1DEIsa5Ni2vvDcwuDeY=; b=GrSKXIBVGdHw4gH9HgjD+qoQbrd3sXq99/CUsYa2TUJr9Y8Kna0VdzkQmK93i46ZsH OJacXYswDdvXH4wYTyaEEU2UDvoxwZyVcDLv0zWqlX7Xz7Y3TjWuLGOpMoCV2UXmdCap DssXQx2/EcbAUvvM1H9pyKdjou1tx4GJz2eiPqdxbsivvx3JiSAV/uAdz87nXbBpGRPI YNk53VuPll+kGtGuMW9P7pxQKGEjRCe4nTgZFRIFjVi+0z6BbNIz7Bd5ahdZ61c+kXz+ yqm91AjDeJfDXNEqKsBpDGgxdcN7TzvFQ5VrVp9nPfM/+7RBUKXeHJoNAlfked4KJuqJ vWgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744884855; x=1745489655; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pSbJvphKhtV8mfmUJ+DjEluf1DEIsa5Ni2vvDcwuDeY=; b=aIKC1VqiOxqA0tW4G6AIjZQEadcKIbnUapp6bTWCRSBclIDTeCAzRUcYUA60KPRo5I gtE6ir/pN4kJqb1t5O0qaYHPoYWnitm+IJF5RpdM7E/KkVdf5NQbKflF216LtAU9RGZL 7PFDL6wA/7V46ZfsQiKGJJ3Bl4Xi3Vw21e87SwFx5m1B/K5ahdcnyuoJl5M/ynQDvyOi I/CHSusr61EWqd5qpixErSzB2JexiAW+PVNmDF0FjAlXbpetZWHGgv/s9IducpsmcNrA M/wkp0UjumMmNf4sRwBMWsFBV5RhQSl664e6MZp55zazCUPpuV8qo6WhGR4u2jf8+wT4 nC7A== X-Gm-Message-State: AOJu0YycdHXqmTncnvU8Mhl0NpwuW56JVMrhH8ZAUi9KGQiTPt7pEQ4+ nKM5h/hmV3IDv3u6G0laG43jULbBs1bYVnyooVB9xKF3wI8v4UO4TRDZuqYQhvcpES10a/qsvaT u X-Gm-Gg: ASbGnctYQxNE9s889fH5KOE/kcwmu/M0pqPMjIDKhsZstihSjopNSk3i/QULc3Ybc60 RHmzFV6GLpddogBBMStloHZQv1Y5DpyDRkS/PH3A6tv01jaX27J7WlCkvsJmPuEFezc8UbmgjYd VcQEHNkQTw16b31gfXOHhsn76tjUqIqrosX0WruVrVIzMtMFnhaP9yrUIuqF3TNa+T3qIoKlLfH XV6CgJgxrwrzUUG0HeNRipomorfuzTlB+oCPfuxb9A0zYaCxobEwxyChNY3K1AwoOgioxvsHMMl gX3OOn8jn4X9mBzfXNA1RnRrgb+8a3e+ig== X-Google-Smtp-Source: AGHT+IFtH1EYIO8G72x63cQmefNMtuxlqu62nzXPuHUia+049ncycCEawzZ9gj4ARrFWs7mjnISVlg== X-Received: by 2002:a05:600c:1d86:b0:43c:f050:fed3 with SMTP id 5b1f17b1804b1-4405d616afamr47043475e9.11.1744884854650; Thu, 17 Apr 2025 03:14:14 -0700 (PDT) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4405b5abc3fsm48280615e9.37.2025.04.17.03.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Apr 2025 03:14:14 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com, andrew+netdev@lunn.ch, horms@kernel.org, donald.hunter@gmail.com, parav@nvidia.com, kalesh-anakkur.purayil@broadcom.com Subject: [PATCH net-next v3 1/3] net/mlx5: Expose serial numbers in devlink info Date: Wed, 16 Apr 2025 23:41:31 +0200 Message-ID: <20250416214133.10582-2-jiri@resnulli.us> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250416214133.10582-1-jiri@resnulli.us> References: <20250416214133.10582-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Devlink info allows to expose serial number and board serial number Get the values from PCI VPD and expose it. $ devlink dev info pci/0000:08:00.0: driver mlx5_core serial_number e4397f872caeed218000846daa7d2f49 board.serial_number MT2314XZ00YA versions: fixed: fw.psid MT_0000000894 running: fw.version 28.41.1000 fw 28.41.1000 stored: fw.version 28.41.1000 fw 28.41.1000 auxiliary/mlx5_core.eth.0: driver mlx5_core.eth pci/0000:08:00.1: driver mlx5_core serial_number e4397f872caeed218000846daa7d2f49 board.serial_number MT2314XZ00YA versions: fixed: fw.psid MT_0000000894 running: fw.version 28.41.1000 fw 28.41.1000 stored: fw.version 28.41.1000 fw 28.41.1000 auxiliary/mlx5_core.eth.1: driver mlx5_core.eth Signed-off-by: Jiri Pirko Reviewed-by: Parav Pandit Reviewed-by: Simon Horman Reviewed-by: Kalesh AP Acked-by: Tariq Toukan --- v2->v3: - do not continue in case devlink_info_*serial_number_put() returns error v1->v2: - fixed possibly uninitialized variable "err" --- .../net/ethernet/mellanox/mlx5/core/devlink.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index 73cd74644378..42218834183a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -35,6 +35,55 @@ static u16 mlx5_fw_ver_subminor(u32 version) return version & 0xffff; } +static int mlx5_devlink_serial_numbers_put(struct mlx5_core_dev *dev, + struct devlink_info_req *req, + struct netlink_ext_ack *extack) +{ + struct pci_dev *pdev = dev->pdev; + unsigned int vpd_size, kw_len; + char *str, *end; + u8 *vpd_data; + int err = 0; + int start; + + vpd_data = pci_vpd_alloc(pdev, &vpd_size); + if (IS_ERR(vpd_data)) + return 0; + + start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size, + PCI_VPD_RO_KEYWORD_SERIALNO, &kw_len); + if (start >= 0) { + str = kstrndup(vpd_data + start, kw_len, GFP_KERNEL); + if (!str) { + err = -ENOMEM; + goto end; + } + end = strchrnul(str, ' '); + *end = '\0'; + err = devlink_info_board_serial_number_put(req, str); + kfree(str); + if (err) + goto end; + } + + start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size, "V3", &kw_len); + if (start >= 0) { + str = kstrndup(vpd_data + start, kw_len, GFP_KERNEL); + if (!str) { + err = -ENOMEM; + goto end; + } + err = devlink_info_serial_number_put(req, str); + kfree(str); + if (err) + goto end; + } + +end: + kfree(vpd_data); + return err; +} + #define DEVLINK_FW_STRING_LEN 32 static int @@ -49,6 +98,10 @@ mlx5_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, if (!mlx5_core_is_pf(dev)) return 0; + err = mlx5_devlink_serial_numbers_put(dev, req, extack); + if (err) + return err; + err = devlink_info_version_fixed_put(req, "fw.psid", dev->board_id); if (err) return err; From patchwork Wed Apr 16 21:41:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 14055229 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6BDE22D4C3 for ; Thu, 17 Apr 2025 10:14:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744884863; cv=none; b=b6DsDIF1/+2xXtUhhVsx3oybfSbUrg6TPveNCiNiJ1fkqbam6CiU6Vw9aK7p6DSJO/UQYjHkgWIMcHWmcMx04fOEi6h+kTTHfu3ozo4wtmAJQ5gZAYgmMXirlCZZ2YV9jMUdIDrGPJCynJEEhE1RAUq3e8/MVSvvtqmOyNpEL8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744884863; c=relaxed/simple; bh=25f8SIJju/5ivilnPjUhfmqcpVjfTVqI74xcOmF1hQc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r5XCsf2eZhiYtMi9Eb+UYw4hyBj4TOisz6lNLOrg2+NgsFlH7Z31xUzuT6Uvyvhxkp7Krc3nD3DbtZCyU0OT4MnCjUNJqk0m9B525pH0f3b3Of0d2973XXYxnJtHWtcrRhMSvx8VdMP/IU/fKZpcPhKKhS54CjXF0W+bNCWzn2Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=VAHNcqlS; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="VAHNcqlS" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43cfa7e7f54so3899005e9.1 for ; Thu, 17 Apr 2025 03:14:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1744884859; x=1745489659; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FztzwBNl0ZFpHfxwLXmfn6WleVneBnBReFpn/yDBVsA=; b=VAHNcqlSr0D9pXwJxGBhm4f5/u+1laZQ5+TJjdCQr3hucp0Ptd7JSKBFuKI34YmbPq zHRgWeWpdiZmj8lphOM/isOzDvECMb+ItUIzNJQHGRuLJx1/6z1LIoTBSlynfWryKm8g LO1tOECnjTPOKAFkvNCD2JnQ3zg22GKvwPoJoyiN741i862CJ2Wdj4ViFh/oejanylcl m8CVw0uTTCiHPmQIprmJpCzDPyNR6NSeGmWgmAADaqn5XvcpzqycJM4CvFDvP0LJok1m ltJ5lPFYuemaSF4cgRM0F+vxWe0GCursw+HizuVGpppMwN2PgpNY+ZerqQ/ISNK378UK w+xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744884859; x=1745489659; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FztzwBNl0ZFpHfxwLXmfn6WleVneBnBReFpn/yDBVsA=; b=HmYxDhHtwjK+qHvbuuHJIz/iiGrkkpOY8tKMSI9RCSftOMCsNzgWhO8cTgPhRWChUc Q/9cZsVzPAXfc0uk4enny3GE7PDwo9rUIKl4l6/7OjqrfhVLgFdda/r6Wz/NOLGCr6Ck HPn95FRcYZ1J1ivaOXXuF3o4kX026lQdrdsvsj0weqI9irlXCG+ts8FcQhHzYtTbtGp7 nUczEZY4rBnR1x5IXoR7jt0CCH5mdJCBW+ApQMGGHsZODKyLYrxtRbnyldHXybP8JC7H XKlVYoTRqTp3ClYI5UB/JABKPWx1je7ay5I/3bQZQo58thVRHhcDECFFES5sLsf29mxK ZX/g== X-Gm-Message-State: AOJu0YwGOrQQkEl1Si9CgWU0ckexDpMv3So/07hfO/N+kv7TeSHzASw3 loSzvx8/fote8WiKd7DVFDRMjpaTSkedRU5vWycvB5WPLvMoZ+5a/hSdFZ9jn6PpbhxH5AG9KmA Z X-Gm-Gg: ASbGncswhCtpVvpxoGREuS7qt8/1UObOOWDRogIBqNny4yWV4+M6rCA6XW+K/qb7jnj 2ehF5YJD0gUD40R5Jfzb6DGHc1FaNOUrq2hjxWKx1d/WSIAXWwRF1R5zv7TcExDejcs7akwVD7J +9zy+hGI/cwSCFA4cyRqvbFjnNHj5bqYHbLQ1ERY8pXkvGCT6afQ3nLa2KBXF+ZUnQnc0mQV4WH DCbIUXil+BwosnjrGqNaNH0kwE8efQUN4hNEGF7P1mDx7S/57+jVlK86BxPWkcjGHiJml+uQwsd +Sb3vsqBB6CypnqrLmexDlVQiYF8ioEX2g== X-Google-Smtp-Source: AGHT+IHL+m8ta+aas00bRsxmilCNCmsvQcQDfnOJB0XvA4U3pkqP88fMxTcKUxqe18jKF4rTAKjx2w== X-Received: by 2002:a05:600c:6a19:b0:43d:5264:3cf0 with SMTP id 5b1f17b1804b1-4406351b347mr16613845e9.11.1744884858806; Thu, 17 Apr 2025 03:14:18 -0700 (PDT) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4404352a5f0sm52455795e9.1.2025.04.17.03.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Apr 2025 03:14:18 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com, andrew+netdev@lunn.ch, horms@kernel.org, donald.hunter@gmail.com, parav@nvidia.com, kalesh-anakkur.purayil@broadcom.com Subject: [PATCH net-next v3 2/3] devlink: add function unique identifier to devlink dev info Date: Wed, 16 Apr 2025 23:41:32 +0200 Message-ID: <20250416214133.10582-3-jiri@resnulli.us> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250416214133.10582-1-jiri@resnulli.us> References: <20250416214133.10582-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko A physical device may consists of several PCI physical functions. Each of this PCI function's "serial_number" is same because they are part of single board. From this serial number, PCI function cannot be uniquely referenced in a system. Expanding this in slightly more complex system of multi-host "board.serial_number" is not even now unique across two hosts. Further expanding this for DPU based board, a DPU board has PCI functions on the external host as well as DPU internal host. Such DPU side PCI physical functions also have the same "serial_number". There is a need to identify each PCI function uniquely in a factory. We are presently missing this function unique identifier. Hence, introduce a function unique identifier, which is uniquely identifies a function across one or multiple hosts, also has unique identifier with/without DPU based NICs. Signed-off-by: Jiri Pirko Reviewed-by: Parav Pandit Reviewed-by: Simon Horman Reviewed-by: Kalesh AP --- v2->v3: - extended patch description - extended documentation --- Documentation/netlink/specs/devlink.yaml | 4 ++++ .../networking/devlink/devlink-info.rst | 20 +++++++++++++++++++ include/net/devlink.h | 2 ++ include/uapi/linux/devlink.h | 2 ++ net/devlink/dev.c | 9 +++++++++ 5 files changed, 37 insertions(+) diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index bd9726269b4f..5d39eb68aefb 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -820,6 +820,9 @@ attribute-sets: - name: region-direct type: flag + - + name: info-function-uid + type: string - name: dl-dev-stats @@ -1869,6 +1872,7 @@ operations: - info-version-running - info-version-stored - info-board-serial-number + - info-function-uid dump: reply: *info-get-reply diff --git a/Documentation/networking/devlink/devlink-info.rst b/Documentation/networking/devlink/devlink-info.rst index dd6adc4d0559..d0d4e17df148 100644 --- a/Documentation/networking/devlink/devlink-info.rst +++ b/Documentation/networking/devlink/devlink-info.rst @@ -50,6 +50,26 @@ versions is generally discouraged - here, and via any other Linux API. This is usually the serial number of the board, often available in PCI *Vital Product Data*. + * - ``function.uid`` + - Function uniqueue identifier. + + A physical device may consists of several PCI physical functions. + Each of this PCI function's ``serial_number`` is same because they are + part of single board. From this serial number, PCI function cannot be + uniquely referenced in a system. + + Expanding this in slightly more complex system of multi-host + ``board.serial_number`` is not even now unique across two hosts. + + Further expanding this for DPU based board, a DPU board has PCI + functions on the external host as well as DPU internal host. + Such DPU side PCI physical functions also have the same + ``serial_number``. + + The function unique identifier uniquely identifies a function + across one or multiple hosts, also has unique identifier + with/without DPU based NICs. + * - ``fixed`` - Group for hardware identifiers, and versions of components which are not field-updatable. diff --git a/include/net/devlink.h b/include/net/devlink.h index b8783126c1ed..a0b84efd4740 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1846,6 +1846,8 @@ int devlink_info_serial_number_put(struct devlink_info_req *req, const char *sn); int devlink_info_board_serial_number_put(struct devlink_info_req *req, const char *bsn); +int devlink_info_function_uid_put(struct devlink_info_req *req, + const char *fuid); enum devlink_info_version_type { DEVLINK_INFO_VERSION_TYPE_NONE, diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index 9401aa343673..816339790409 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -614,6 +614,8 @@ enum devlink_attr { DEVLINK_ATTR_REGION_DIRECT, /* flag */ + DEVLINK_ATTR_INFO_FUNCTION_UID, /* string */ + /* Add new attributes above here, update the spec in * Documentation/netlink/specs/devlink.yaml and re-generate * net/devlink/netlink_gen.c. diff --git a/net/devlink/dev.c b/net/devlink/dev.c index 02602704bdea..581a8ad7a568 100644 --- a/net/devlink/dev.c +++ b/net/devlink/dev.c @@ -763,6 +763,15 @@ int devlink_info_board_serial_number_put(struct devlink_info_req *req, } EXPORT_SYMBOL_GPL(devlink_info_board_serial_number_put); +int devlink_info_function_uid_put(struct devlink_info_req *req, + const char *fuid) +{ + if (!req->msg) + return 0; + return nla_put_string(req->msg, DEVLINK_ATTR_INFO_FUNCTION_UID, fuid); +} +EXPORT_SYMBOL_GPL(devlink_info_function_uid_put); + static int devlink_info_version_put(struct devlink_info_req *req, int attr, const char *version_name, const char *version_value, From patchwork Wed Apr 16 21:41:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 14055230 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7B1E22D4C3 for ; Thu, 17 Apr 2025 10:14:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744884867; cv=none; b=pxg/lby7JRZBdfuTnXAR5g+iTUzHeOYFgztSBmhmnYid6bq+yyQcUZBsNznWl/haSQijtZH/4bmVmP9Ga2Lt57LAk/cjzLS271HYBxB+yU+YQ0c25P9yWBsrp1BG4njOJ/fbst7MF08sfa3YajuoIU2y5X4nPVnblJZEuUIzJxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744884867; c=relaxed/simple; bh=bzV6fcWZXtviJFecIdH+4FWEvBdsX5ENw/cnrisySpM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R24nobacuKsrJQN7/Xy3FK1t8ksizB2uwMchJr8r1pfZ/z/IKZEX9bCkERBrIzVPvZH1gykO5Tp1MqWoPc+UtUW4rcpuwlW6M0EajgxrpBSY6042i+So+cRzzfXKDaD/T/COCcH8AzdEKPS3dZeBXnSAFn9U1ZDxxkIc07Cpj2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=Yz3eXjDe; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="Yz3eXjDe" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-43cf06eabdaso5769555e9.2 for ; Thu, 17 Apr 2025 03:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1744884864; x=1745489664; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H4ZB/gV1wmFw+78kuVh8efwdsnURVwVY4fkiwGcxVGQ=; b=Yz3eXjDe6blbBumYvOxojr3qiZ7p7O8HlPXfxAruMrnXxn36QV15uoNh5AIwwDqKHM 4sNMOIBu/q9kisSBe8+Q5btd/LC5sgrIPlYsNxNxon6Sr5025LJxjqiPG1uurVb6y9T/ WBG06ffPc1hp0N1HdzPyAAUTAJMGTMTcegeX0RdNX1G80n9xryViZl2g3JE9ln8sWhOy I6tpx85z2minaArY8IQX/H0Huc5oT1YP8tXzJiihTKKxcLhgOi2SOK8Jj3en0rejEC4i HtpGSs8kk6futyDqWvjSSg6f7XH6vF+IE4GDQWWtpfCXu6USAelPMVNEkaW6ViGqgTmz rsVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744884864; x=1745489664; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H4ZB/gV1wmFw+78kuVh8efwdsnURVwVY4fkiwGcxVGQ=; b=Fhgh3P5fk2KC0aSSunCCQzixh/sGV/adDC6NGZhlaZIj8U/nXEpu0V76iCs/V4fkk3 6DGhISIfb5DaKARUJn71QAAlT2lY9yzlXVNOKbN1EAiyXDp8ihNbT7JDcRGFBomKNNQY N7Nl8FenG/LXyCSz+GsXSJHpzWqXn7dmtNJyfbxmTsXKpufK9pNk6fi9JC9gYEsVcvDV BvgqFG3iOvmzjQQp6vIpQY2axv7Y7SYp7JGC0ADztrHlS24BoslZW8UKVbiaCiEaD/8g AAmvgnWiyQ+nDaAYREGCAKM7ygMY4f/o9D6l3bxyqkXES6PQh4HkyTlWVj4ByfL9WziX XlaA== X-Gm-Message-State: AOJu0Yxi9vWuBQsMXypKjG1dbj3zzsqOlQZ9bL/sWi2rwaQRBSTI2zfW tCdCDUgoj/XCMjt2ElkKZN3XLQV4z5rHfuo3Pqv+11YLQ1xTf5P1YwRQxCTR4XTEgG8+60ooyF5 7 X-Gm-Gg: ASbGnctYXULOcpCXm3ZHxqySkvBpOye0pVsh6bvyLFf+62I242KG5lQLinBSQ2gF2GA 8Q0l6ffSA2ohNzxfr0chrZXIuwmOjbWg1B7/wOrUGwsHdwrcnp9PVRpLk2phZ+7acu2ppolL8Qh dI5mZqgymS6NDAbnAtBugO+1sl03DpsMnhTDgQ5Bu5Ymox2t5Py565kjxHG0L92Q+8EEo/RCOUY 9O2gRQXv5cmR7MRFx6ugnnU5jVjh2cekH6VsL/8yVl5wZFKR8yZ3yGWH4POjAFN87R9dMlHicd6 /S9ZF2TacC8Iwo48h2VkY0/XQD2SyjStog== X-Google-Smtp-Source: AGHT+IE2ydrjS+s2VPGiUd+ESX6XztTnZ6UUu0zE7sDxXBCOaDZ2wemdMUpdXXH/cHPwFFMTlOI8MQ== X-Received: by 2002:a05:600c:b98:b0:43d:3df:42d8 with SMTP id 5b1f17b1804b1-4405d5fcc9emr45146215e9.6.1744884863951; Thu, 17 Apr 2025 03:14:23 -0700 (PDT) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4405b4d1236sm48383735e9.13.2025.04.17.03.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Apr 2025 03:14:23 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com, andrew+netdev@lunn.ch, horms@kernel.org, donald.hunter@gmail.com, parav@nvidia.com, kalesh-anakkur.purayil@broadcom.com Subject: [PATCH net-next v3 3/3] net/mlx5: Expose function UID in devlink info Date: Wed, 16 Apr 2025 23:41:33 +0200 Message-ID: <20250416214133.10582-4-jiri@resnulli.us> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250416214133.10582-1-jiri@resnulli.us> References: <20250416214133.10582-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Devlink info allows to expose function UID. Get the value from PCI VPD and expose it. $ devlink dev info pci/0000:08:00.0: driver mlx5_core serial_number e4397f872caeed218000846daa7d2f49 board.serial_number MT2314XZ00YA function.uid MT2314XZ00YAMLNXS0D0F0 versions: fixed: fw.psid MT_0000000894 running: fw.version 28.41.1000 fw 28.41.1000 stored: fw.version 28.41.1000 fw 28.41.1000 auxiliary/mlx5_core.eth.0: driver mlx5_core.eth pci/0000:08:00.1: driver mlx5_core serial_number e4397f872caeed218000846daa7d2f49 board.serial_number MT2314XZ00YA function.uid MT2314XZ00YAMLNXS0D0F1 versions: fixed: fw.psid MT_0000000894 running: fw.version 28.41.1000 fw 28.41.1000 stored: fw.version 28.41.1000 fw 28.41.1000 auxiliary/mlx5_core.eth.1: driver mlx5_core.eth Signed-off-by: Jiri Pirko Reviewed-by: Parav Pandit Reviewed-by: Simon Horman Reviewed-by: Kalesh AP Acked-by: Tariq Toukan --- v2->v3: - do not continue in case devlink_info_function_uid_put() returns error --- drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index 42218834183a..403c11694fa9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -79,6 +79,21 @@ static int mlx5_devlink_serial_numbers_put(struct mlx5_core_dev *dev, goto end; } + start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size, "VU", &kw_len); + if (start >= 0) { + str = kstrndup(vpd_data + start, kw_len, GFP_KERNEL); + if (!str) { + err = -ENOMEM; + goto end; + } + end = strchrnul(str, ' '); + *end = '\0'; + err = devlink_info_function_uid_put(req, str); + kfree(str); + if (err) + goto end; + } + end: kfree(vpd_data); return err;