drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/core_linecards.c- Extension
.c- Size
- 46628 bytes
- Lines
- 1604
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/kernel.hlinux/module.hlinux/err.hlinux/types.hlinux/string.hlinux/workqueue.hlinux/gfp.hlinux/slab.hlinux/list.hlinux/vmalloc.hcore.h../mlxfw/mlxfw.h
Detected Declarations
struct mlxsw_linecard_ini_filestruct mlxsw_linecard_types_infostruct mlxsw_linecard_device_fw_infostruct mlxsw_linecards_event_ops_itemstruct mlxsw_linecard_status_eventstruct mlxsw_linecard_bct_eventfunction mlxsw_linecard_status_event_to_schedulefunction mlxsw_linecard_status_event_donefunction mlxsw_linecard_types_lookupfunction mlxsw_linecard_device_fw_component_queryfunction mlxsw_linecard_device_fw_fsm_lockfunction mlxsw_linecard_device_fw_fsm_component_updatefunction mlxsw_linecard_device_fw_fsm_block_downloadfunction mlxsw_linecard_device_fw_fsm_component_verifyfunction mlxsw_linecard_device_fw_fsm_activatefunction mlxsw_linecard_device_fw_fsm_query_statefunction mlxsw_linecard_device_fw_fsm_cancelfunction mlxsw_linecard_device_fw_fsm_releasefunction mlxsw_linecard_flash_updatefunction mlxsw_linecard_device_psid_getfunction mlxsw_linecard_device_info_updatefunction mlxsw_linecard_provision_failfunction mlxsw_linecard_event_op_callfunction mlxsw_linecard_active_ops_callfunction mlxsw_linecard_inactive_ops_callfunction mlxsw_linecards_event_ops_register_callfunction mlxsw_linecards_event_ops_unregister_callfunction mlxsw_linecards_event_ops_registerfunction mlxsw_linecards_event_ops_unregisterfunction mlxsw_linecard_devlink_info_getfunction mlxsw_linecard_provision_setfunction mlxsw_linecard_provision_clearfunction mlxsw_linecard_ready_setfunction mlxsw_linecard_ready_clearfunction mlxsw_linecard_active_setfunction mlxsw_linecard_active_clearfunction mlxsw_linecard_status_processfunction mlxsw_linecard_status_get_and_processfunction mlxsw_linecards_irq_event_handlerfunction mlxsw_linecard_status_event_to_workfunction __mlxsw_linecard_fix_fsm_statefunction mlxsw_linecard_fix_fsm_statefunction mlxsw_linecard_query_ini_statusfunction mlxsw_linecard_ini_transferfunction mlxsw_linecard_ini_erasefunction mlxsw_linecard_bct_processfunction mlxsw_linecard_ini_activatefunction mlxsw_linecard_ini_in_use_wait
Annotated Snippet
struct mlxsw_linecard_ini_file {
__le16 size;
union {
u8 data[0];
struct {
__be16 hw_revision;
__be16 ini_version;
u8 __dontcare[3];
u8 type;
u8 name[20];
} format;
};
};
struct mlxsw_linecard_types_info {
struct mlxsw_linecard_ini_file **ini_files;
unsigned int count;
size_t data_size;
char *data;
};
#define MLXSW_LINECARD_STATUS_EVENT_TO (10 * MSEC_PER_SEC)
static void
mlxsw_linecard_status_event_to_schedule(struct mlxsw_linecard *linecard,
enum mlxsw_linecard_status_event_type status_event_type)
{
cancel_delayed_work_sync(&linecard->status_event_to_dw);
linecard->status_event_type_to = status_event_type;
mlxsw_core_schedule_dw(&linecard->status_event_to_dw,
msecs_to_jiffies(MLXSW_LINECARD_STATUS_EVENT_TO));
}
static void
mlxsw_linecard_status_event_done(struct mlxsw_linecard *linecard,
enum mlxsw_linecard_status_event_type status_event_type)
{
if (linecard->status_event_type_to == status_event_type)
cancel_delayed_work_sync(&linecard->status_event_to_dw);
}
static const char *
mlxsw_linecard_types_lookup(struct mlxsw_linecards *linecards, u8 card_type)
{
struct mlxsw_linecard_types_info *types_info;
struct mlxsw_linecard_ini_file *ini_file;
int i;
types_info = linecards->types_info;
if (!types_info)
return NULL;
for (i = 0; i < types_info->count; i++) {
ini_file = linecards->types_info->ini_files[i];
if (ini_file->format.type == card_type)
return ini_file->format.name;
}
return NULL;
}
static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard)
{
struct mlxsw_core *mlxsw_core = linecard->linecards->mlxsw_core;
char mddq_pl[MLXSW_REG_MDDQ_LEN];
int err;
mlxsw_reg_mddq_slot_name_pack(mddq_pl, linecard->slot_index);
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl);
if (err)
return ERR_PTR(err);
mlxsw_reg_mddq_slot_name_unpack(mddq_pl, linecard->name);
return linecard->name;
}
struct mlxsw_linecard_device_fw_info {
struct mlxfw_dev mlxfw_dev;
struct mlxsw_core *mlxsw_core;
struct mlxsw_linecard *linecard;
};
static int mlxsw_linecard_device_fw_component_query(struct mlxfw_dev *mlxfw_dev,
u16 component_index,
u32 *p_max_size,
u8 *p_align_bits,
u16 *p_max_write_size)
{
struct mlxsw_linecard_device_fw_info *info =
container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
mlxfw_dev);
struct mlxsw_linecard *linecard = info->linecard;
struct mlxsw_core *mlxsw_core = info->mlxsw_core;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/err.h`, `linux/types.h`, `linux/string.h`, `linux/workqueue.h`, `linux/gfp.h`, `linux/slab.h`.
- Detected declarations: `struct mlxsw_linecard_ini_file`, `struct mlxsw_linecard_types_info`, `struct mlxsw_linecard_device_fw_info`, `struct mlxsw_linecards_event_ops_item`, `struct mlxsw_linecard_status_event`, `struct mlxsw_linecard_bct_event`, `function mlxsw_linecard_status_event_to_schedule`, `function mlxsw_linecard_status_event_done`, `function mlxsw_linecard_types_lookup`, `function mlxsw_linecard_device_fw_component_query`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.