From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Jiri Pirko <jiri@mellanox.com>,
Saeed Mahameed <saeedm@mellanox.com>,
Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next 3/6] net/mlxfw: Improve FSM err message reporting and return codes
Date: Fri, 22 Nov 2019 21:51:53 +0000 [thread overview]
Message-ID: <20191122215111.21723-4-saeedm@mellanox.com> (raw)
In-Reply-To: <20191122215111.21723-1-saeedm@mellanox.com>
Report unique and standard error codes corresponding to the specific
FW flash error and report more detailed error messages to netlink.
Before:
$ devlink dev flash pci/0000:05:00.0 file ...
Error: mlxfw: Firmware flash failed.
devlink answers: Invalid argument
After:
$ devlink dev flash pci/0000:05:00.0 file ...
Error: mlxfw: Firmware flash failed: pending reset.
devlink answers: Operation already in progress
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
---
.../net/ethernet/mellanox/mlxfw/mlxfw_fsm.c | 55 +++++++++++++++++--
1 file changed, 49 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
index afcdc579578c..ba1e5b276c54 100644
--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
+++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
@@ -39,6 +39,52 @@ static const char * const mlxfw_fsm_state_err_str[] = {
"unknown error"
};
+static int mlxfw_fsm_state_err(struct netlink_ext_ack *extack,
+ enum mlxfw_fsm_state_err fsm_state_err)
+{
+#define MLXFW_ERR_PRFX "Firmware flash failed: "
+#define MLXFW_FSM_STATE_ERR_NL(extack, msg) \
+ NL_SET_ERR_MSG_MOD((extack), MLXFW_ERR_PRFX msg)
+
+ fsm_state_err = min_t(enum mlxfw_fsm_state_err, fsm_state_err,
+ MLXFW_FSM_STATE_ERR_MAX);
+ pr_err(MLXFW_ERR_PRFX "%s\n", mlxfw_fsm_state_err_str[fsm_state_err]);
+ switch (fsm_state_err) {
+ case MLXFW_FSM_STATE_ERR_ERROR:
+ MLXFW_FSM_STATE_ERR_NL(extack, "general error");
+ return -EREMOTEIO;
+ case MLXFW_FSM_STATE_ERR_REJECTED_DIGEST_ERR:
+ MLXFW_FSM_STATE_ERR_NL(extack, "component hash mismatch");
+ return -EBADMSG;
+ case MLXFW_FSM_STATE_ERR_REJECTED_NOT_APPLICABLE:
+ MLXFW_FSM_STATE_ERR_NL(extack, "component not applicable");
+ return -ENOENT;
+ case MLXFW_FSM_STATE_ERR_REJECTED_UNKNOWN_KEY:
+ MLXFW_FSM_STATE_ERR_NL(extack, "unknown key");
+ return -ENOKEY;
+ case MLXFW_FSM_STATE_ERR_REJECTED_AUTH_FAILED:
+ MLXFW_FSM_STATE_ERR_NL(extack, "authentication failed");
+ return -EACCES;
+ case MLXFW_FSM_STATE_ERR_REJECTED_UNSIGNED:
+ MLXFW_FSM_STATE_ERR_NL(extack, "component was not signed");
+ return -EKEYREVOKED;
+ case MLXFW_FSM_STATE_ERR_REJECTED_KEY_NOT_APPLICABLE:
+ MLXFW_FSM_STATE_ERR_NL(extack, "key not applicable");
+ return -EKEYREJECTED;
+ case MLXFW_FSM_STATE_ERR_REJECTED_BAD_FORMAT:
+ MLXFW_FSM_STATE_ERR_NL(extack, "bad format");
+ return -ENOEXEC;
+ case MLXFW_FSM_STATE_ERR_BLOCKED_PENDING_RESET:
+ MLXFW_FSM_STATE_ERR_NL(extack, "pending reset");
+ return -EALREADY;
+ case MLXFW_FSM_STATE_ERR_OK: /* should never happen */
+ case MLXFW_FSM_STATE_ERR_MAX:
+ MLXFW_FSM_STATE_ERR_NL(extack, "unknown error");
+ return -EINVAL;
+ }
+ return -EINVAL;
+};
+
static void mlxfw_status_notify(struct mlxfw_dev *mlxfw_dev,
const char *msg, const char *comp_name,
u32 done_bytes, u32 total_bytes)
@@ -63,12 +109,9 @@ static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
if (err)
return err;
- if (fsm_state_err != MLXFW_FSM_STATE_ERR_OK) {
- pr_err("Firmware flash failed: %s\n",
- mlxfw_fsm_state_err_str[fsm_state_err]);
- NL_SET_ERR_MSG_MOD(extack, "Firmware flash failed");
- return -EINVAL;
- }
+ if (fsm_state_err != MLXFW_FSM_STATE_ERR_OK)
+ return mlxfw_fsm_state_err(extack, fsm_state_err);
+
if (curr_fsm_state != fsm_state) {
if (--times == 0) {
pr_err("Timeout reached on FSM state change");
--
2.21.0
next prev parent reply other threads:[~2019-11-22 21:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-22 21:51 [PATCH net-next 0/6] mlxfw: Improve error reporting Saeed Mahameed
2019-11-22 21:51 ` [PATCH net-next 1/6] netlink: Convert extack msg to a formattable buffer Saeed Mahameed
2019-11-22 21:51 ` [PATCH net-next 2/6] net/mlxfw: Generic mlx FW flash status notify Saeed Mahameed
2019-11-22 21:51 ` Saeed Mahameed [this message]
2019-11-22 22:17 ` [PATCH net-next 3/6] net/mlxfw: Improve FSM err message reporting and return codes Saeed Mahameed
2019-11-22 21:51 ` [PATCH net-next 4/6] net/mlxfw: Convert pr_* to dev_* in mlxfw_fsm.c Saeed Mahameed
2019-11-22 21:51 ` [PATCH net-next 5/6] net/mlxfw: More error messages coverage Saeed Mahameed
2019-11-22 21:51 ` [PATCH net-next 6/6] net/mlxfw: Macro for error reporting Saeed Mahameed
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=20191122215111.21723-4-saeedm@mellanox.com \
--to=saeedm@mellanox.com \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).