#define pr_fmt(fmt) …
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include "mlxfw.h"
#include "mlxfw_mfa2.h"
#define MLXFW_FSM_STATE_WAIT_CYCLE_MS …
#define MLXFW_FSM_STATE_WAIT_TIMEOUT_MS …
#define MLXFW_FSM_STATE_WAIT_ROUNDS …
#define MLXFW_FSM_MAX_COMPONENT_SIZE …
static const int mlxfw_fsm_state_errno[] = …;
#define MLXFW_ERR_PRFX …
#define MLXFW_ERR_MSG(fwdev, extack, msg, err) …
static int mlxfw_fsm_state_err(struct mlxfw_dev *mlxfw_dev,
struct netlink_ext_ack *extack,
enum mlxfw_fsm_state_err err)
{
enum mlxfw_fsm_state_err fsm_state_err;
fsm_state_err = min_t(enum mlxfw_fsm_state_err, err,
MLXFW_FSM_STATE_ERR_MAX);
switch (fsm_state_err) {
case MLXFW_FSM_STATE_ERR_ERROR:
MLXFW_ERR_MSG(mlxfw_dev, extack, "general error", err);
break;
case MLXFW_FSM_STATE_ERR_REJECTED_DIGEST_ERR:
MLXFW_ERR_MSG(mlxfw_dev, extack, "component hash mismatch", err);
break;
case MLXFW_FSM_STATE_ERR_REJECTED_NOT_APPLICABLE:
MLXFW_ERR_MSG(mlxfw_dev, extack, "component not applicable", err);
break;
case MLXFW_FSM_STATE_ERR_REJECTED_UNKNOWN_KEY:
MLXFW_ERR_MSG(mlxfw_dev, extack, "unknown key", err);
break;
case MLXFW_FSM_STATE_ERR_REJECTED_AUTH_FAILED:
MLXFW_ERR_MSG(mlxfw_dev, extack, "authentication failed", err);
break;
case MLXFW_FSM_STATE_ERR_REJECTED_UNSIGNED:
MLXFW_ERR_MSG(mlxfw_dev, extack, "component was not signed", err);
break;
case MLXFW_FSM_STATE_ERR_REJECTED_KEY_NOT_APPLICABLE:
MLXFW_ERR_MSG(mlxfw_dev, extack, "key not applicable", err);
break;
case MLXFW_FSM_STATE_ERR_REJECTED_BAD_FORMAT:
MLXFW_ERR_MSG(mlxfw_dev, extack, "bad format", err);
break;
case MLXFW_FSM_STATE_ERR_BLOCKED_PENDING_RESET:
MLXFW_ERR_MSG(mlxfw_dev, extack, "pending reset", err);
break;
case MLXFW_FSM_STATE_ERR_OK:
case MLXFW_FSM_STATE_ERR_MAX:
MLXFW_ERR_MSG(mlxfw_dev, extack, "unknown error", err);
break;
}
return mlxfw_fsm_state_errno[fsm_state_err];
};
static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
enum mlxfw_fsm_state fsm_state,
struct netlink_ext_ack *extack)
{ … }
static int
mlxfw_fsm_reactivate_err(struct mlxfw_dev *mlxfw_dev,
struct netlink_ext_ack *extack, u8 err)
{
enum mlxfw_fsm_reactivate_status status;
#define MXFW_REACT_PRFX "Reactivate FSM: "
#define MLXFW_REACT_ERR(msg, err) \
MLXFW_ERR_MSG(mlxfw_dev, extack, MXFW_REACT_PRFX msg, err)
status = min_t(enum mlxfw_fsm_reactivate_status, err,
MLXFW_FSM_REACTIVATE_STATUS_MAX);
switch (status) {
case MLXFW_FSM_REACTIVATE_STATUS_BUSY:
MLXFW_REACT_ERR("busy", err);
break;
case MLXFW_FSM_REACTIVATE_STATUS_PROHIBITED_FW_VER_ERR:
MLXFW_REACT_ERR("prohibited fw ver", err);
break;
case MLXFW_FSM_REACTIVATE_STATUS_FIRST_PAGE_COPY_FAILED:
MLXFW_REACT_ERR("first page copy failed", err);
break;
case MLXFW_FSM_REACTIVATE_STATUS_FIRST_PAGE_ERASE_FAILED:
MLXFW_REACT_ERR("first page erase failed", err);
break;
case MLXFW_FSM_REACTIVATE_STATUS_FIRST_PAGE_RESTORE_FAILED:
MLXFW_REACT_ERR("first page restore failed", err);
break;
case MLXFW_FSM_REACTIVATE_STATUS_CANDIDATE_FW_DEACTIVATION_FAILED:
MLXFW_REACT_ERR("candidate fw deactivation failed", err);
break;
case MLXFW_FSM_REACTIVATE_STATUS_ERR_DEVICE_RESET_REQUIRED:
MLXFW_REACT_ERR("device reset required", err);
break;
case MLXFW_FSM_REACTIVATE_STATUS_ERR_FW_PROGRAMMING_NEEDED:
MLXFW_REACT_ERR("fw programming needed", err);
break;
case MLXFW_FSM_REACTIVATE_STATUS_FW_ALREADY_ACTIVATED:
MLXFW_REACT_ERR("fw already activated", err);
break;
case MLXFW_FSM_REACTIVATE_STATUS_OK:
case MLXFW_FSM_REACTIVATE_STATUS_MAX:
MLXFW_REACT_ERR("unexpected error", err);
break;
}
return -EREMOTEIO;
};
static int mlxfw_fsm_reactivate(struct mlxfw_dev *mlxfw_dev,
struct netlink_ext_ack *extack,
bool *supported)
{ … }
static void mlxfw_status_notify(struct mlxfw_dev *mlxfw_dev,
const char *msg, const char *comp_name,
u32 done_bytes, u32 total_bytes)
{ … }
#define MLXFW_ALIGN_DOWN(x, align_bits) …
#define MLXFW_ALIGN_UP(x, align_bits) …
static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
u32 fwhandle,
struct mlxfw_mfa2_component *comp,
bool reactivate_supp,
struct netlink_ext_ack *extack)
{ … }
static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
struct mlxfw_mfa2_file *mfa2_file,
bool reactivate_supp,
struct netlink_ext_ack *extack)
{ … }
int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
const struct firmware *firmware,
struct netlink_ext_ack *extack)
{ … }
EXPORT_SYMBOL(…);
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;