nfp: add support for indirect HWinfo lookup
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>
This commit is contained in:
parent
ac86da0546
commit
34243f5909
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user