drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c- Extension
.c- Size
- 27265 bytes
- Lines
- 949
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
devlink.hfw_reset.hdiag/fw_tracer.hlib/tout.hsf/sf.h
Detected Declarations
struct mlx5_fw_resetfunction mlx5_get_fw_rst_statefunction mlx5_set_fw_rst_ackfunction mlx5_fw_reset_enable_remote_dev_reset_setfunction mlx5_fw_reset_enable_remote_dev_reset_getfunction mlx5_reg_mfrl_setfunction mlx5_reg_mfrl_queryfunction mlx5_fw_reset_queryfunction mlx5_fw_reset_in_progressfunction mlx5_fw_reset_get_reset_methodfunction mlx5_fw_reset_get_reset_state_errfunction mlx5_fw_reset_set_reset_syncfunction mlx5_fw_reset_verify_fw_completefunction mlx5_fw_reset_set_live_patchfunction mlx5_fw_reset_complete_reloadfunction mlx5_stop_sync_reset_pollfunction mlx5_sync_reset_clear_reset_requestedfunction mlx5_sync_reset_reload_workfunction poll_sync_resetfunction mlx5_start_sync_reset_pollfunction mlx5_fw_reset_set_reset_sync_ackfunction mlx5_fw_reset_set_reset_sync_nackfunction mlx5_sync_reset_set_reset_requestedfunction mlx5_fw_live_patch_eventfunction mlx5_check_hotplug_interruptfunction mlx5_is_mgt_ifc_pci_devicefunction mlx5_check_dev_idsfunction mlx5_is_reset_now_capablefunction mlx5_sync_reset_request_eventfunction test_bitfunction pendingfunction mlx5_pci_link_togglefunction list_for_each_entryfunction mlx5_pci_reset_busfunction mlx5_sync_pci_resetfunction mlx5_sync_reset_unload_flowfunction mlx5_sync_reset_now_eventfunction mlx5_sync_reset_unload_eventfunction mlx5_sync_reset_abort_eventfunction mlx5_sync_reset_events_handlefunction mlx5_sync_reset_timeout_workfunction fw_reset_event_notifierfunction mlx5_fw_reset_wait_reset_donefunction mlx5_fw_reset_events_startfunction mlx5_fw_reset_events_stopfunction mlx5_drain_fw_resetfunction mlx5_fw_reset_initfunction mlx5_fw_reset_cleanup
Annotated Snippet
struct mlx5_fw_reset {
struct mlx5_core_dev *dev;
struct mlx5_nb nb;
struct workqueue_struct *wq;
struct work_struct fw_live_patch_work;
struct work_struct reset_request_work;
struct work_struct reset_unload_work;
struct work_struct reset_reload_work;
struct work_struct reset_now_work;
struct work_struct reset_abort_work;
struct delayed_work reset_timeout_work;
unsigned long reset_flags;
u8 reset_method;
struct timer_list timer;
struct completion done;
int ret;
};
enum {
MLX5_FW_RST_STATE_IDLE = 0,
MLX5_FW_RST_STATE_TOGGLE_REQ = 4,
MLX5_FW_RST_STATE_DROP_MODE = 5,
};
enum {
MLX5_RST_STATE_BIT_NUM = 12,
MLX5_RST_ACK_BIT_NUM = 22,
};
static u8 mlx5_get_fw_rst_state(struct mlx5_core_dev *dev)
{
return (ioread32be(&dev->iseg->initializing) >> MLX5_RST_STATE_BIT_NUM) & 0xF;
}
static void mlx5_set_fw_rst_ack(struct mlx5_core_dev *dev)
{
iowrite32be(BIT(MLX5_RST_ACK_BIT_NUM), &dev->iseg->initializing);
}
static int mlx5_fw_reset_enable_remote_dev_reset_set(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx,
struct netlink_ext_ack *extack)
{
struct mlx5_core_dev *dev = devlink_priv(devlink);
struct mlx5_fw_reset *fw_reset;
fw_reset = dev->priv.fw_reset;
if (ctx->val.vbool)
clear_bit(MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST, &fw_reset->reset_flags);
else
set_bit(MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST, &fw_reset->reset_flags);
return 0;
}
static int mlx5_fw_reset_enable_remote_dev_reset_get(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx,
struct netlink_ext_ack *extack)
{
struct mlx5_core_dev *dev = devlink_priv(devlink);
struct mlx5_fw_reset *fw_reset;
fw_reset = dev->priv.fw_reset;
ctx->val.vbool = !test_bit(MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST,
&fw_reset->reset_flags);
return 0;
}
static int mlx5_reg_mfrl_set(struct mlx5_core_dev *dev, u8 reset_level,
u8 reset_type_sel, u8 sync_resp, bool sync_start)
{
u32 out[MLX5_ST_SZ_DW(mfrl_reg)] = {};
u32 in[MLX5_ST_SZ_DW(mfrl_reg)] = {};
MLX5_SET(mfrl_reg, in, reset_level, reset_level);
MLX5_SET(mfrl_reg, in, rst_type_sel, reset_type_sel);
MLX5_SET(mfrl_reg, in, pci_sync_for_fw_update_resp, sync_resp);
MLX5_SET(mfrl_reg, in, pci_sync_for_fw_update_start, sync_start);
return mlx5_core_access_reg(dev, in, sizeof(in), out, sizeof(out), MLX5_REG_MFRL, 0, 1);
}
static int mlx5_reg_mfrl_query(struct mlx5_core_dev *dev, u8 *reset_level,
u8 *reset_type, u8 *reset_state, u8 *reset_method)
{
u32 out[MLX5_ST_SZ_DW(mfrl_reg)] = {};
u32 in[MLX5_ST_SZ_DW(mfrl_reg)] = {};
int err;
Annotation
- Immediate include surface: `devlink.h`, `fw_reset.h`, `diag/fw_tracer.h`, `lib/tout.h`, `sf/sf.h`.
- Detected declarations: `struct mlx5_fw_reset`, `function mlx5_get_fw_rst_state`, `function mlx5_set_fw_rst_ack`, `function mlx5_fw_reset_enable_remote_dev_reset_set`, `function mlx5_fw_reset_enable_remote_dev_reset_get`, `function mlx5_reg_mfrl_set`, `function mlx5_reg_mfrl_query`, `function mlx5_fw_reset_query`, `function mlx5_fw_reset_in_progress`, `function mlx5_fw_reset_get_reset_method`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.