drivers/net/ethernet/mellanox/mlx5/core/fw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/fw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/fw.c- Extension
.c- Size
- 24879 bytes
- Lines
- 891
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mlx5/driver.hlinux/mlx5/eswitch.hmlx5_core.h../../mlxfw/mlxfw.hlib/tout.h
Detected Declarations
struct mlx5_mlxfw_devenum mlxsw_reg_mcc_instructionfunction mlx5_query_board_idfunction mlx5_core_query_vendor_idfunction mlx5_get_pcam_regfunction mlx5_get_mcam_access_reg_groupfunction mlx5_get_qcam_regfunction mlx5_query_hca_capsfunction mlx5_cmd_init_hcafunction mlx5_cmd_teardown_hcafunction mlx5_cmd_force_teardown_hcafunction mlx5_cmd_fast_teardown_hcafunction mlx5_reg_mcc_setfunction mlx5_reg_mcc_queryfunction mlx5_reg_mcda_setfunction mlx5_reg_mcqi_queryfunction mlx5_reg_mcqi_caps_queryfunction mlx5_component_queryfunction mlx5_fsm_lockfunction mlx5_fsm_component_updatefunction mlx5_fsm_block_downloadfunction mlx5_fsm_component_verifyfunction mlx5_fsm_activatefunction mlx5_fsm_query_statefunction mlx5_fsm_cancelfunction mlx5_fsm_releasefunction mlx5_fsm_reactivatefunction mlx5_firmware_flashfunction mlx5_reg_mcqi_version_queryfunction mlx5_reg_mcqs_queryfunction mlx5_get_boot_img_component_indexfunction mlx5_fw_image_pendingfunction mlx5_fw_version_queryexport mlx5_core_query_vendor_id
Annotated Snippet
struct mlx5_mlxfw_dev {
struct mlxfw_dev mlxfw_dev;
struct mlx5_core_dev *mlx5_core_dev;
};
static int mlx5_component_query(struct mlxfw_dev *mlxfw_dev,
u16 component_index, u32 *p_max_size,
u8 *p_align_bits, u16 *p_max_write_size)
{
struct mlx5_mlxfw_dev *mlx5_mlxfw_dev =
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
struct mlx5_core_dev *dev = mlx5_mlxfw_dev->mlx5_core_dev;
if (!MLX5_CAP_GEN(dev, mcam_reg) || !MLX5_CAP_MCAM_REG(dev, mcqi)) {
mlx5_core_warn(dev, "caps query isn't supported by running FW\n");
return -EOPNOTSUPP;
}
return mlx5_reg_mcqi_caps_query(dev, component_index, p_max_size,
p_align_bits, p_max_write_size);
}
static int mlx5_fsm_lock(struct mlxfw_dev *mlxfw_dev, u32 *fwhandle)
{
struct mlx5_mlxfw_dev *mlx5_mlxfw_dev =
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
struct mlx5_core_dev *dev = mlx5_mlxfw_dev->mlx5_core_dev;
u8 control_state, error_code;
int err;
*fwhandle = 0;
err = mlx5_reg_mcc_query(dev, fwhandle, &error_code, &control_state);
if (err)
return err;
if (control_state != MLXFW_FSM_STATE_IDLE)
return -EBUSY;
return mlx5_reg_mcc_set(dev, MLX5_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE,
0, *fwhandle, 0);
}
static int mlx5_fsm_component_update(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
u16 component_index, u32 component_size)
{
struct mlx5_mlxfw_dev *mlx5_mlxfw_dev =
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
struct mlx5_core_dev *dev = mlx5_mlxfw_dev->mlx5_core_dev;
return mlx5_reg_mcc_set(dev, MLX5_REG_MCC_INSTRUCTION_UPDATE_COMPONENT,
component_index, fwhandle, component_size);
}
static int mlx5_fsm_block_download(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
u8 *data, u16 size, u32 offset)
{
struct mlx5_mlxfw_dev *mlx5_mlxfw_dev =
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
struct mlx5_core_dev *dev = mlx5_mlxfw_dev->mlx5_core_dev;
return mlx5_reg_mcda_set(dev, fwhandle, offset, size, data);
}
static int mlx5_fsm_component_verify(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
u16 component_index)
{
struct mlx5_mlxfw_dev *mlx5_mlxfw_dev =
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
struct mlx5_core_dev *dev = mlx5_mlxfw_dev->mlx5_core_dev;
return mlx5_reg_mcc_set(dev, MLX5_REG_MCC_INSTRUCTION_VERIFY_COMPONENT,
component_index, fwhandle, 0);
}
static int mlx5_fsm_activate(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
{
struct mlx5_mlxfw_dev *mlx5_mlxfw_dev =
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
struct mlx5_core_dev *dev = mlx5_mlxfw_dev->mlx5_core_dev;
return mlx5_reg_mcc_set(dev, MLX5_REG_MCC_INSTRUCTION_ACTIVATE, 0,
fwhandle, 0);
}
static int mlx5_fsm_query_state(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
enum mlxfw_fsm_state *fsm_state,
enum mlxfw_fsm_state_err *fsm_state_err)
{
struct mlx5_mlxfw_dev *mlx5_mlxfw_dev =
container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
Annotation
- Immediate include surface: `linux/mlx5/driver.h`, `linux/mlx5/eswitch.h`, `mlx5_core.h`, `../../mlxfw/mlxfw.h`, `lib/tout.h`.
- Detected declarations: `struct mlx5_mlxfw_dev`, `enum mlxsw_reg_mcc_instruction`, `function mlx5_query_board_id`, `function mlx5_core_query_vendor_id`, `function mlx5_get_pcam_reg`, `function mlx5_get_mcam_access_reg_group`, `function mlx5_get_qcam_reg`, `function mlx5_query_hca_caps`, `function mlx5_cmd_init_hca`, `function mlx5_cmd_teardown_hca`.
- 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.