drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c- Extension
.c- Size
- 16654 bytes
- Lines
- 590
- 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
linux/kernel.hlinux/module.hlinux/netlink.hlinux/vmalloc.hlinux/xz.hmlxfw_mfa2.hmlxfw_mfa2_file.hmlxfw_mfa2_tlv.hmlxfw_mfa2_format.hmlxfw_mfa2_tlv_multi.h
Detected Declarations
struct mlxfw_mfa2_comp_datafunction mlxfw_mfa2_checkfunction mlxfw_mfa2_tlv_multi_validatefunction mlxfw_mfa2_file_dev_validatefunction mlxfw_mfa2_file_comp_validatefunction mlxfw_mfa2_file_validatefunction mlxfw_mfa2_tlv_dev_getfunction mlxfw_mfa2_file_component_countfunction mlxfw_mfa2_xz_dec_runfunction mlxfw_mfa2_file_cb_offset_xzfunction mlxfw_mfa2_file_component_tlv_getfunction mlxfw_mfa2_file_component_findfunction mlxfw_mfa2_file_component_getfunction mlxfw_mfa2_file_component_putfunction mlxfw_mfa2_file_fini
Annotated Snippet
struct mlxfw_mfa2_comp_data {
struct mlxfw_mfa2_component comp;
u8 buff[];
};
static const struct mlxfw_mfa2_tlv_component_descriptor *
mlxfw_mfa2_file_component_find(const struct mlxfw_mfa2_file *mfa2_file,
const char *psid, int psid_size,
int component_index)
{
const struct mlxfw_mfa2_tlv_component_ptr *cptr;
const struct mlxfw_mfa2_tlv_multi *dev_multi;
const struct mlxfw_mfa2_tlv *cptr_tlv;
u16 comp_idx;
dev_multi = mlxfw_mfa2_tlv_dev_get(mfa2_file, psid, psid_size);
if (!dev_multi)
return NULL;
cptr_tlv = mlxfw_mfa2_tlv_multi_child_find(mfa2_file, dev_multi,
MLXFW_MFA2_TLV_COMPONENT_PTR,
component_index);
if (!cptr_tlv)
return NULL;
cptr = mlxfw_mfa2_tlv_component_ptr_get(mfa2_file, cptr_tlv);
if (!cptr)
return NULL;
comp_idx = be16_to_cpu(cptr->component_index);
return mlxfw_mfa2_file_component_tlv_get(mfa2_file, comp_idx);
}
struct mlxfw_mfa2_component *
mlxfw_mfa2_file_component_get(const struct mlxfw_mfa2_file *mfa2_file,
const char *psid, int psid_size,
int component_index)
{
const struct mlxfw_mfa2_tlv_component_descriptor *comp;
struct mlxfw_mfa2_comp_data *comp_data;
u32 comp_buf_size;
off_t cb_offset;
u32 comp_size;
int err;
comp = mlxfw_mfa2_file_component_find(mfa2_file, psid, psid_size,
component_index);
if (!comp)
return ERR_PTR(-EINVAL);
cb_offset = (u64) be32_to_cpu(comp->cb_offset_h) << 32 |
be32_to_cpu(comp->cb_offset_l);
comp_size = be32_to_cpu(comp->size);
comp_buf_size = comp_size + mlxfw_mfa2_comp_magic_len;
comp_data = vzalloc(sizeof(*comp_data) + comp_buf_size);
if (!comp_data)
return ERR_PTR(-ENOMEM);
comp_data->comp.data_size = comp_size;
comp_data->comp.index = be16_to_cpu(comp->identifier);
err = mlxfw_mfa2_file_cb_offset_xz(mfa2_file, cb_offset, comp_buf_size,
comp_data->buff);
if (err) {
pr_err("Component could not be reached in CB\n");
goto err_out;
}
if (memcmp(comp_data->buff, mlxfw_mfa2_comp_magic,
mlxfw_mfa2_comp_magic_len) != 0) {
pr_err("Component has wrong magic\n");
err = -EINVAL;
goto err_out;
}
comp_data->comp.data = comp_data->buff + mlxfw_mfa2_comp_magic_len;
return &comp_data->comp;
err_out:
vfree(comp_data);
return ERR_PTR(err);
}
void mlxfw_mfa2_file_component_put(struct mlxfw_mfa2_component *comp)
{
const struct mlxfw_mfa2_comp_data *comp_data;
comp_data = container_of(comp, struct mlxfw_mfa2_comp_data, comp);
vfree(comp_data);
}
void mlxfw_mfa2_file_fini(struct mlxfw_mfa2_file *mfa2_file)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/netlink.h`, `linux/vmalloc.h`, `linux/xz.h`, `mlxfw_mfa2.h`, `mlxfw_mfa2_file.h`, `mlxfw_mfa2_tlv.h`.
- Detected declarations: `struct mlxfw_mfa2_comp_data`, `function mlxfw_mfa2_check`, `function mlxfw_mfa2_tlv_multi_validate`, `function mlxfw_mfa2_file_dev_validate`, `function mlxfw_mfa2_file_comp_validate`, `function mlxfw_mfa2_file_validate`, `function mlxfw_mfa2_tlv_dev_get`, `function mlxfw_mfa2_file_component_count`, `function mlxfw_mfa2_xz_dec_run`, `function mlxfw_mfa2_file_cb_offset_xz`.
- 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.