Commit 368b1d1c authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: store NSP ABI version in state structure

We read the status register on each NSP open, we can store the NSP
ABI version in the state structure so that we don't have to read
it again.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 64db09ed
...@@ -99,6 +99,10 @@ enum nfp_nsp_cmd { ...@@ -99,6 +99,10 @@ enum nfp_nsp_cmd {
struct nfp_nsp { struct nfp_nsp {
struct nfp_cpp *cpp; struct nfp_cpp *cpp;
struct nfp_resource *res; struct nfp_resource *res;
struct {
u16 major;
u16 minor;
} ver;
}; };
static int nfp_nsp_check(struct nfp_nsp *state) static int nfp_nsp_check(struct nfp_nsp *state)
...@@ -120,11 +124,12 @@ static int nfp_nsp_check(struct nfp_nsp *state) ...@@ -120,11 +124,12 @@ static int nfp_nsp_check(struct nfp_nsp *state)
return -ENODEV; return -ENODEV;
} }
if (FIELD_GET(NSP_STATUS_MAJOR, reg) != NSP_MAJOR || state->ver.major = FIELD_GET(NSP_STATUS_MAJOR, reg);
FIELD_GET(NSP_STATUS_MINOR, reg) < NSP_MINOR) { state->ver.minor = FIELD_GET(NSP_STATUS_MINOR, reg);
nfp_err(cpp, "Unsupported ABI %lld.%lld\n",
FIELD_GET(NSP_STATUS_MAJOR, reg), if (state->ver.major != NSP_MAJOR || state->ver.minor < NSP_MINOR) {
FIELD_GET(NSP_STATUS_MINOR, reg)); nfp_err(cpp, "Unsupported ABI %hu.%hu\n",
state->ver.major, state->ver.minor);
return -EINVAL; return -EINVAL;
} }
...@@ -301,15 +306,9 @@ static int nfp_nsp_command_buf(struct nfp_nsp *nsp, u16 code, u32 option, ...@@ -301,15 +306,9 @@ static int nfp_nsp_command_buf(struct nfp_nsp *nsp, u16 code, u32 option,
int ret, err; int ret, err;
u32 cpp_id; u32 cpp_id;
err = nfp_cpp_readq(cpp, nfp_resource_cpp_id(nsp->res), if (nsp->ver.minor < 13) {
nfp_resource_address(nsp->res) + NSP_STATUS, &reg); nfp_err(cpp, "NSP: Code 0x%04x with buffer not supported (ABI %hu.%hu)\n",
if (err < 0) code, nsp->ver.major, nsp->ver.minor);
return err;
if (FIELD_GET(NSP_STATUS_MINOR, reg) < 13) {
nfp_err(cpp, "NSP: Code 0x%04x with buffer not supported (ABI %lld.%lld)\n",
code, FIELD_GET(NSP_STATUS_MAJOR, reg),
FIELD_GET(NSP_STATUS_MINOR, reg));
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment