netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Cc: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com,
	netdev@vger.kernel.org,
	Mateusz Polchlopek <mateusz.polchlopek@intel.com>
Subject: Re: [PATCH iwl-next v1 02/13] ixgbe: add handler for devlink .info_get()
Date: Sun, 9 Feb 2025 16:27:22 +0000	[thread overview]
Message-ID: <20250209162722.GD554665@kernel.org> (raw)
In-Reply-To: <20250203150328.4095-3-jedrzej.jagielski@intel.com>

On Mon, Feb 03, 2025 at 04:03:17PM +0100, Jedrzej Jagielski wrote:
> 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 <mateusz.polchlopek@intel.com>
> Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>

...

> diff --git a/drivers/net/ethernet/intel/ixgbe/devlink/devlink.c b/drivers/net/ethernet/intel/ixgbe/devlink/devlink.c

...

> +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;
> +
> +	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);

Hi Jedrzej,

If neither of the conditions above are met then it seems that ctx->buf will
contain whatever string was present when the function was called. Is
something like the following needed here?

	ctx->buf[0] = '\0';

> +}
> +
> +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)
> +		return;

Likewise, here.

> +
> +	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 = ixgbe_devlink_info_put(req, IXGBE_DL_VERSION_RUNNING,
> +				     DEVLINK_INFO_VERSION_GENERIC_FW_UNDI,
> +				     ctx->buf);
> +	if (err)
> +		goto free_ctx;
> +
> +	ixgbe_info_eetrack(adapter, ctx);
> +	err = ixgbe_devlink_info_put(req, IXGBE_DL_VERSION_RUNNING,
> +				     DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID,
> +				     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 = ixgbe_devlink_info_put(req, IXGBE_DL_VERSION_FIXED,
> +				     DEVLINK_INFO_VERSION_GENERIC_BOARD_ID,
> +				     ctx->buf);
> +free_ctx:
> +	kfree(ctx);
> +	return err;
> +}

...

  reply	other threads:[~2025-02-09 16:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-03 15:03 [PATCH iwl-next v1 00/13] ixgbe: Add basic devlink support Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 01/13] ixgbe: add initial " Jedrzej Jagielski
2025-02-06 21:39   ` Tony Nguyen
2025-02-07 10:47   ` Simon Horman
2025-02-10 11:08     ` Jagielski, Jedrzej
2025-02-09 11:13   ` Simon Horman
2025-02-03 15:03 ` [PATCH iwl-next v1 02/13] ixgbe: add handler for devlink .info_get() Jedrzej Jagielski
2025-02-09 16:27   ` Simon Horman [this message]
2025-02-10 11:06     ` Jagielski, Jedrzej
2025-02-03 15:03 ` [PATCH iwl-next v1 03/13] ixgbe: add E610 functions for acquiring flash data Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 04/13] ixgbe: read the OROM version information Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 05/13] ixgbe: read the netlist " Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 06/13] ixgbe: add .info_get extension specific for E610 devices Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 07/13] ixgbe: add E610 functions getting PBA and FW ver info Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 08/13] ixgbe: extend .info_get with stored versions Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 09/13] ixgbe: add device flash update via devlink Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 10/13] ixgbe: add support for devlink reload Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 11/13] ixgbe: add FW API version check Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 12/13] ixgbe: add E610 implementation of FW recovery mode Jedrzej Jagielski
2025-02-03 15:03 ` [PATCH iwl-next v1 13/13] ixgbe: add support for FW rollback mode Jedrzej Jagielski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250209162722.GD554665@kernel.org \
    --to=horms@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jedrzej.jagielski@intel.com \
    --cc=mateusz.polchlopek@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).