drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c- Extension
.c- Size
- 12753 bytes
- Lines
- 435
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/delay.hmlxfw.hmlxfw_mfa2.h
Detected Declarations
function mlxfw_fsm_state_errfunction mlxfw_fsm_state_waitfunction mlxfw_fsm_reactivate_errfunction mlxfw_fsm_reactivatefunction mlxfw_status_notifyfunction MLXFW_ALIGN_DOWNfunction mlxfw_flash_componentsfunction mlxfw_firmware_flashexport mlxfw_firmware_flash
Annotated Snippet
if (--times == 0) {
MLXFW_ERR_MSG(mlxfw_dev, extack,
"Timeout reached on FSM state change", -ETIMEDOUT);
return -ETIMEDOUT;
}
msleep(MLXFW_FSM_STATE_WAIT_CYCLE_MS);
goto retry;
}
return 0;
}
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)
{
u8 status;
int err;
if (!mlxfw_dev->ops->fsm_reactivate)
return 0;
err = mlxfw_dev->ops->fsm_reactivate(mlxfw_dev, &status);
if (err == -EOPNOTSUPP) {
*supported = false;
return 0;
}
if (err) {
MLXFW_ERR_MSG(mlxfw_dev, extack,
"Could not reactivate firmware flash", err);
return err;
}
if (status == MLXFW_FSM_REACTIVATE_STATUS_OK ||
status == MLXFW_FSM_REACTIVATE_STATUS_FW_ALREADY_ACTIVATED)
return 0;
return mlxfw_fsm_reactivate_err(mlxfw_dev, extack, status);
}
static void mlxfw_status_notify(struct mlxfw_dev *mlxfw_dev,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/delay.h`, `mlxfw.h`, `mlxfw_mfa2.h`.
- Detected declarations: `function mlxfw_fsm_state_err`, `function mlxfw_fsm_state_wait`, `function mlxfw_fsm_reactivate_err`, `function mlxfw_fsm_reactivate`, `function mlxfw_status_notify`, `function MLXFW_ALIGN_DOWN`, `function mlxfw_flash_components`, `function mlxfw_firmware_flash`, `export mlxfw_firmware_flash`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.