Skip to content

Commit

Permalink
nfp: add support for indirect HWinfo lookup
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Aug 28, 2018
1 parent ac86da0 commit 34243f5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
38 changes: 38 additions & 0 deletions drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}
6 changes: 6 additions & 0 deletions drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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,
Expand Down

0 comments on commit 34243f5

Please sign in to comment.