Skip to content

Commit 85eb97d

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: add extended error messages
Allow NSP to set option code even when error is reported. This provides a way for NSP to give user more precise information about why command failed. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e890ae8 commit 85eb97d

File tree

1 file changed

+29
-8
lines changed
  • drivers/net/ethernet/netronome/nfp/nfpcore

1 file changed

+29
-8
lines changed

drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ enum nfp_nsp_cmd {
9797
__MAX_SPCODE,
9898
};
9999

100+
static const struct {
101+
int code;
102+
const char *msg;
103+
} nsp_errors[] = {
104+
{ 0, "success" } /* placeholder to avoid warnings */
105+
};
106+
100107
struct nfp_nsp {
101108
struct nfp_cpp *cpp;
102109
struct nfp_resource *res;
@@ -149,6 +156,18 @@ void nfp_nsp_config_clear_state(struct nfp_nsp *state)
149156
state->idx = 0;
150157
}
151158

159+
static void nfp_nsp_print_extended_error(struct nfp_nsp *state, u32 ret_val)
160+
{
161+
int i;
162+
163+
if (!ret_val)
164+
return;
165+
166+
for (i = 0; i < ARRAY_SIZE(nsp_errors); i++)
167+
if (ret_val == nsp_errors[i].code)
168+
nfp_err(state->cpp, "err msg: %s\n", nsp_errors[i].msg);
169+
}
170+
152171
static int nfp_nsp_check(struct nfp_nsp *state)
153172
{
154173
struct nfp_cpp *cpp = state->cpp;
@@ -282,7 +301,7 @@ nfp_nsp_wait_reg(struct nfp_cpp *cpp, u64 *reg,
282301
static int nfp_nsp_command(struct nfp_nsp *state, u16 code, u32 option,
283302
u32 buff_cpp, u64 buff_addr)
284303
{
285-
u64 reg, nsp_base, nsp_buffer, nsp_status, nsp_command;
304+
u64 reg, ret_val, nsp_base, nsp_buffer, nsp_status, nsp_command;
286305
struct nfp_cpp *cpp = state->cpp;
287306
u32 nsp_cpp;
288307
int err;
@@ -335,18 +354,20 @@ static int nfp_nsp_command(struct nfp_nsp *state, u16 code, u32 option,
335354
return err;
336355
}
337356

357+
err = nfp_cpp_readq(cpp, nsp_cpp, nsp_command, &ret_val);
358+
if (err < 0)
359+
return err;
360+
ret_val = FIELD_GET(NSP_COMMAND_OPTION, ret_val);
361+
338362
err = FIELD_GET(NSP_STATUS_RESULT, reg);
339363
if (err) {
340-
nfp_warn(cpp, "Result (error) code set: %d command: %d\n",
341-
-err, code);
364+
nfp_warn(cpp, "Result (error) code set: %d (%d) command: %d\n",
365+
-err, (int)ret_val, code);
366+
nfp_nsp_print_extended_error(state, ret_val);
342367
return -err;
343368
}
344369

345-
err = nfp_cpp_readq(cpp, nsp_cpp, nsp_command, &reg);
346-
if (err < 0)
347-
return err;
348-
349-
return FIELD_GET(NSP_COMMAND_OPTION, reg);
370+
return ret_val;
350371
}
351372

352373
static int nfp_nsp_command_buf(struct nfp_nsp *nsp, u16 code, u32 option,

0 commit comments

Comments
 (0)