All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next 04/15] nfp: add support for indirect HWinfo lookup
Date: Tue, 28 Aug 2018 13:20:36 -0700	[thread overview]
Message-ID: <20180828202047.1305-5-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180828202047.1305-1-jakub.kicinski@netronome.com>

Management FW can adjust some of the information in the HWinfo table
at runtime.  In some cases reading the table directly will not yield
correct results.  Add a NSP command for looking up information.
Up until now we weren't making use of any of the values which may
get adjusted.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
 .../ethernet/netronome/nfp/nfpcore/nfp_nsp.c  | 38 +++++++++++++++++++
 .../ethernet/netronome/nfp/nfpcore/nfp_nsp.h  |  6 +++
 2 files changed, 44 insertions(+)

diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
index 9eb7b5a91bb1..bf593a6b26a1 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
@@ -90,6 +90,8 @@
 #define NFP_FW_LOAD_RET_MAJOR	GENMASK(15, 8)
 #define NFP_FW_LOAD_RET_MINOR	GENMASK(23, 16)
 
+#define NFP_HWINFO_LOOKUP_SIZE	GENMASK(11, 0)
+
 enum nfp_nsp_cmd {
 	SPCODE_NOOP		= 0, /* No operation */
 	SPCODE_SOFT_RESET	= 1, /* Soft reset the NFP */
@@ -104,6 +106,7 @@ enum nfp_nsp_cmd {
 	SPCODE_NSP_SENSORS	= 12, /* Read NSP sensor(s) */
 	SPCODE_NSP_IDENTIFY	= 13, /* Read NSP version */
 	SPCODE_FW_STORED	= 16, /* If no FW loaded, load flash app FW */
+	SPCODE_HWINFO_LOOKUP	= 17, /* Lookup HWinfo with overwrites etc. */
 };
 
 static const struct {
@@ -703,3 +706,38 @@ int nfp_nsp_load_stored_fw(struct nfp_nsp *state)
 	nfp_nsp_load_fw_extended_msg(state, ret);
 	return 0;
 }
+
+static int
+__nfp_nsp_hwinfo_lookup(struct nfp_nsp *state, void *buf, unsigned int size)
+{
+	struct nfp_nsp_command_buf_arg hwinfo_lookup = {
+		{
+			.code		= SPCODE_HWINFO_LOOKUP,
+			.option		= size,
+		},
+		.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(struct nfp_nsp *state, void *buf, unsigned int size)
+{
+	int err;
+
+	size = min_t(u32, size, NFP_HWINFO_LOOKUP_SIZE);
+
+	err = __nfp_nsp_hwinfo_lookup(state, buf, size);
+	if (err)
+		return err;
+
+	if (strnlen(buf, size) == size) {
+		nfp_err(state->cpp, "NSP HWinfo value not NULL-terminated\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h
index 65f2d4a6de02..bd6c9071c8e9 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h
@@ -51,6 +51,7 @@ int nfp_nsp_load_fw(struct nfp_nsp *state, const struct firmware *fw);
 int nfp_nsp_write_flash(struct nfp_nsp *state, const struct firmware *fw);
 int nfp_nsp_mac_reinit(struct nfp_nsp *state);
 int nfp_nsp_load_stored_fw(struct nfp_nsp *state);
+int nfp_nsp_hwinfo_lookup(struct nfp_nsp *state, void *buf, unsigned int size);
 
 static inline bool nfp_nsp_has_mac_reinit(struct nfp_nsp *state)
 {
@@ -62,6 +63,11 @@ static inline bool nfp_nsp_has_stored_fw_load(struct nfp_nsp *state)
 	return nfp_nsp_get_abi_ver_minor(state) > 23;
 }
 
+static inline bool nfp_nsp_has_hwinfo_lookup(struct nfp_nsp *state)
+{
+	return nfp_nsp_get_abi_ver_minor(state) > 24;
+}
+
 enum nfp_eth_interface {
 	NFP_INTERFACE_NONE	= 0,
 	NFP_INTERFACE_SFP	= 1,
-- 
2.17.1

  parent reply	other threads:[~2018-08-29  0:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28 20:20 [PATCH net-next 00/15] nfp: add NFP5000 support Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 01/15] nfp: encapsulate NSP command arguments into structs Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 02/15] nfp: attempt FW load from flash Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 03/15] nfp: interpret extended FW load result codes Jakub Kicinski
2018-08-28 20:20 ` Jakub Kicinski [this message]
2018-08-28 20:20 ` [PATCH net-next 05/15] nfp: abm: look up MAC addresses via management FW Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 06/15] nfp: add support for NFP5000 Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 07/15] nfp: refactor the per-chip PCIe config Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 08/15] nfp: save the MU locality field offset Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 09/15] nfp: add basic errors messages to target logic Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 10/15] nfp: add RTsym access helpers Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 11/15] nfp: pass cpp_id to nfp_cpp_map_area() Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 12/15] nfp: convert existing RTsym helpers to full target decoding Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 13/15] nfp: convert all RTsym users to use new read/write helpers Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 14/15] nfp: support access to absolute RTsyms Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 15/15] nfp: make RTsym users handle absolute symbols correctly Jakub Kicinski
2018-08-29  0:01 ` [PATCH net-next 00/15] nfp: add NFP5000 support David Miller

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=20180828202047.1305-5-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.