From patchwork Wed Feb 12 13:14:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jedrzej Jagielski X-Patchwork-Id: 13971595 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16CE120E335 for ; Wed, 12 Feb 2025 13:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739366880; cv=none; b=E95mNBajp9O/8kzk7niFfHzKRdvBnrFzxl5bUEg5pacDoEvY1ry0BKUdhgcD0jITLDrEZYURG2gvS/xi7wPPcq7HBJEuxGrM2cP7eX0x7Q2DCMDsTU0H22QpGvevWVan5pf3CPtgDfAc4fUKV5KNNRzvMX+YilejuqG5fQVgQYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739366880; c=relaxed/simple; bh=FUdESCh7ICeJPPzcriQuRgfF5OStqby+3bMXfq88gBk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ub8Kwk7ZYgsB/GIlypUl8TPD8bjwm5mwODNv9kgdtAZb5WKhvLN2c4GrJHvCt6MyZeqVBi3d99x2y2TFP4BxYx5vDjQiOzJks1ab7PMUINhkWP3FXTWGTsvRDEaXFX6PkJ9KflUlOVSNFJCm1adObKiyP4ZvSMV3REvSo1iHA58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aBOhOV+K; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aBOhOV+K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739366879; x=1770902879; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FUdESCh7ICeJPPzcriQuRgfF5OStqby+3bMXfq88gBk=; b=aBOhOV+KK3GU3VlEtyvL65KZ40+lUvwsXbDA2Q9lGGADm/Flxsk/2ILE kgKjK9CFwOOCnUhtvfwsjC/DdH5iTUSaACEGBiCkM5EvCu5v18kGeRuW8 5mJgS678aSkOWsWKhqiL1hE6z7AU5NjZVe23pbErOqJcUrVUjTPtidMS2 79K2SCx3rWVA3mA6oyZWZc4b0F+SulGiz3Il0zjHFHKJVLLgIcF9ge1dB EGm6532AE+7sXJIsMgOGGw8p8QlEVVjPDewFXbY3vlPztyskjO7PBXr5X jQdHg8Dg7xL5PZoa4gVr71RYEFL4OtdI8K4YogHb1jQtz8LtWrZ4d4L81 Q==; X-CSE-ConnectionGUID: N7QU/7B/Qd69tF6v+nUe4A== X-CSE-MsgGUID: YF6nVJfiQEu9EC0uQaVmiw== X-IronPort-AV: E=McAfee;i="6700,10204,11342"; a="50665528" X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="50665528" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 05:27:59 -0800 X-CSE-ConnectionGUID: XUMYgKA4Q/GBVB7PqXVx0w== X-CSE-MsgGUID: MfSqbffuTkaj7au+gvp9+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="117830628" Received: from os-delivery.igk.intel.com ([10.102.18.218]) by orviesa004.jf.intel.com with ESMTP; 12 Feb 2025 05:27:56 -0800 From: Jedrzej Jagielski To: intel-wired-lan@lists.osuosl.org Cc: anthony.l.nguyen@intel.com, netdev@vger.kernel.org, jiri@resnulli.us, horms@kernel.org, Jedrzej Jagielski , Mateusz Polchlopek Subject: [PATCH iwl-next v3 03/14] ixgbe: add handler for devlink .info_get() Date: Wed, 12 Feb 2025 14:14:02 +0100 Message-Id: <20250212131413.91787-4-jedrzej.jagielski@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250212131413.91787-1-jedrzej.jagielski@intel.com> References: <20250212131413.91787-1-jedrzej.jagielski@intel.com> 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 Provide devlink .info_get() callback implementation to allow the driver to report detailed version information. The following info is reported: "serial_number" -> The PCI DSN of the adapter "fw.bundle_id" -> Unique identifier for the combined flash image "fw.undi" -> Version of the Option ROM containing the UEFI driver "board.id" -> The PBA ID string Reviewed-by: Mateusz Polchlopek Signed-off-by: Jedrzej Jagielski --- v3: use devlink_info_version_*_put() function --- --- Documentation/networking/devlink/ixgbe.rst | 32 ++++++ .../ethernet/intel/ixgbe/devlink/devlink.c | 103 ++++++++++++++++++ 2 files changed, 135 insertions(+) diff --git a/Documentation/networking/devlink/ixgbe.rst b/Documentation/networking/devlink/ixgbe.rst index c04ac51c6d85..b63645de37e8 100644 --- a/Documentation/networking/devlink/ixgbe.rst +++ b/Documentation/networking/devlink/ixgbe.rst @@ -6,3 +6,35 @@ ixgbe devlink support This document describes the devlink features implemented by the ``ixgbe`` device driver. + +Info versions +============= + +The ``ixgbe`` driver reports the following versions + +.. list-table:: devlink info versions implemented + :widths: 5 5 5 90 + + * - Name + - Type + - Example + - Description + * - ``board.id`` + - fixed + - H49289-000 + - The Product Board Assembly (PBA) identifier of the board. + * - ``fw.undi`` + - running + - 1.1937.0 + - Version of the Option ROM containing the UEFI driver. The version is + reported in ``major.minor.patch`` format. The major version is + incremented whenever a major breaking change occurs, or when the + minor version would overflow. The minor version is incremented for + non-breaking changes and reset to 1 when the major version is + incremented. The patch version is normally 0 but is incremented when + a fix is delivered as a patch against an older base Option ROM. + * - ``fw.bundle_id`` + - running + - 0x80000d0d + - Unique identifier of the firmware image file that was loaded onto + the device. Also referred to as the EETRACK identifier of the NVM. diff --git a/drivers/net/ethernet/intel/ixgbe/devlink/devlink.c b/drivers/net/ethernet/intel/ixgbe/devlink/devlink.c index c052e95c9496..f721ccde3bf8 100644 --- a/drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +++ b/drivers/net/ethernet/intel/ixgbe/devlink/devlink.c @@ -4,7 +4,110 @@ #include "ixgbe.h" #include "devlink.h" +struct ixgbe_info_ctx { + char buf[128]; +}; + +static void ixgbe_info_get_dsn(struct ixgbe_adapter *adapter, + struct ixgbe_info_ctx *ctx) +{ + u8 dsn[8]; + + /* Copy the DSN into an array in Big Endian format */ + put_unaligned_be64(pci_get_dsn(adapter->pdev), dsn); + + snprintf(ctx->buf, sizeof(ctx->buf), "%8phD", dsn); +} + +static void ixgbe_info_nvm_ver(struct ixgbe_adapter *adapter, + struct ixgbe_info_ctx *ctx) +{ + struct ixgbe_hw *hw = &adapter->hw; + struct ixgbe_nvm_version nvm_ver; + + ctx->buf[0] = '\0'; + + ixgbe_get_oem_prod_version(hw, &nvm_ver); + if (nvm_ver.oem_valid) { + snprintf(ctx->buf, sizeof(ctx->buf), "%x.%x.%x", + nvm_ver.oem_major, nvm_ver.oem_minor, + nvm_ver.oem_release); + + return; + } + + ixgbe_get_orom_version(hw, &nvm_ver); + if (nvm_ver.or_valid) + snprintf(ctx->buf, sizeof(ctx->buf), "%d.%d.%d", + nvm_ver.or_major, nvm_ver.or_build, nvm_ver.or_patch); +} + +static void ixgbe_info_eetrack(struct ixgbe_adapter *adapter, + struct ixgbe_info_ctx *ctx) +{ + struct ixgbe_hw *hw = &adapter->hw; + struct ixgbe_nvm_version nvm_ver; + + ixgbe_get_oem_prod_version(hw, &nvm_ver); + + /* No ETRACK version for OEM */ + if (nvm_ver.oem_valid) { + ctx->buf[0] = '\0'; + return; + } + + ixgbe_get_etk_id(hw, &nvm_ver); + snprintf(ctx->buf, sizeof(ctx->buf), "0x%08x", nvm_ver.etk_id); +} + +static int ixgbe_devlink_info_get(struct devlink *devlink, + struct devlink_info_req *req, + struct netlink_ext_ack *extack) +{ + struct ixgbe_devlink_priv *devlink_private = devlink_priv(devlink); + struct ixgbe_adapter *adapter = devlink_private->adapter; + struct ixgbe_hw *hw = &adapter->hw; + struct ixgbe_info_ctx *ctx; + int err; + + ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + ixgbe_info_get_dsn(adapter, ctx); + err = devlink_info_serial_number_put(req, ctx->buf); + if (err) + goto free_ctx; + + ixgbe_info_nvm_ver(adapter, ctx); + err = devlink_info_version_running_put(req, + DEVLINK_INFO_VERSION_GENERIC_FW_UNDI, + ctx->buf); + if (err) + goto free_ctx; + + ixgbe_info_eetrack(adapter, ctx); + err = devlink_info_version_running_put(req, + DEVLINK_INFO_VERSION_GENERIC_FW_UNDI, + ctx->buf); + if (err) + goto free_ctx; + + err = ixgbe_read_pba_string_generic(hw, ctx->buf, sizeof(ctx->buf)); + if (err) + goto free_ctx; + + err = devlink_info_version_fixed_put(req, + DEVLINK_INFO_VERSION_GENERIC_FW_UNDI, + ctx->buf); + +free_ctx: + kfree(ctx); + return err; +} + static const struct devlink_ops ixgbe_devlink_ops = { + .info_get = ixgbe_devlink_info_get, }; /**