drivers/net/ethernet/huawei/hinic/hinic_devlink.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/huawei/hinic/hinic_devlink.c- Extension
.c- Size
- 15666 bytes
- Lines
- 482
- 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/netlink.hnet/devlink.hlinux/firmware.hhinic_port.hhinic_devlink.hhinic_hw_dev.h
Detected Declarations
function check_image_validfunction check_image_integrityfunction check_image_device_typefunction hinic_flash_fwfunction hinic_firmware_updatefunction hinic_devlink_flash_updatefunction hinic_devlink_freefunction hinic_devlink_registerfunction hinic_devlink_unregisterfunction chip_fault_showfunction fault_report_showfunction hinic_hw_reporter_dumpfunction mgmt_watchdog_report_showfunction hinic_fw_reporter_dumpfunction hinic_health_reporters_createfunction hinic_health_reporters_destroy
Annotated Snippet
if (collect_section_type & (1U << type)) {
dev_err(&priv->hwdev->hwif->pdev->dev, "Duplicate section type: %u\n",
type);
return false;
}
collect_section_type |= (1U << type);
}
if (update_type == FW_UPDATE_COLD &&
(((collect_section_type & _IMAGE_COLD_SUB_MODULES_MUST_IN) ==
_IMAGE_COLD_SUB_MODULES_MUST_IN) ||
collect_section_type == _IMAGE_CFG_SUB_MODULES_MUST_IN))
return true;
if (update_type == FW_UPDATE_HOT &&
(collect_section_type & _IMAGE_HOT_SUB_MODULES_MUST_IN) ==
_IMAGE_HOT_SUB_MODULES_MUST_IN)
return true;
if (update_type == FW_UPDATE_COLD)
dev_err(&priv->hwdev->hwif->pdev->dev, "Check file integrity failed, valid: 0x%x or 0x%lx, current: 0x%x\n",
_IMAGE_COLD_SUB_MODULES_MUST_IN,
_IMAGE_CFG_SUB_MODULES_MUST_IN, collect_section_type);
else
dev_err(&priv->hwdev->hwif->pdev->dev, "Check file integrity failed, valid:0x%x, current: 0x%x\n",
_IMAGE_HOT_SUB_MODULES_MUST_IN, collect_section_type);
return false;
}
static int check_image_device_type(struct hinic_devlink_priv *priv,
u32 image_device_type)
{
struct hinic_comm_board_info board_info = {0};
if (hinic_get_board_info(priv->hwdev, &board_info)) {
dev_err(&priv->hwdev->hwif->pdev->dev, "Get board info failed\n");
return false;
}
if (image_device_type == board_info.info.board_type)
return true;
dev_err(&priv->hwdev->hwif->pdev->dev, "The device type of upgrade file doesn't match the device type of current firmware, please check the upgrade file\n");
dev_err(&priv->hwdev->hwif->pdev->dev, "The image device type: 0x%x, firmware device type: 0x%x\n",
image_device_type, board_info.info.board_type);
return false;
}
static int hinic_flash_fw(struct hinic_devlink_priv *priv, const u8 *data,
struct host_image_st *host_image)
{
u32 section_remain_send_len, send_fragment_len, send_pos, up_total_len;
struct hinic_cmd_update_fw *fw_update_msg = NULL;
u32 section_type, section_crc, section_version;
u32 i, len, section_len, section_offset;
u16 out_size = sizeof(*fw_update_msg);
int total_len_flag = 0;
int err;
fw_update_msg = kzalloc_obj(*fw_update_msg);
if (!fw_update_msg)
return -ENOMEM;
up_total_len = host_image->image_info.up_total_len;
for (i = 0; i < host_image->section_type_num; i++) {
len = host_image->image_section_info[i].fw_section_len;
if (host_image->image_section_info[i].fw_section_type ==
UP_FW_UPDATE_BOOT) {
up_total_len = up_total_len - len;
break;
}
}
for (i = 0; i < host_image->section_type_num; i++) {
section_len =
host_image->image_section_info[i].fw_section_len;
section_offset =
host_image->image_section_info[i].fw_section_offset;
section_remain_send_len = section_len;
section_type =
host_image->image_section_info[i].fw_section_type;
section_crc = host_image->image_section_info[i].fw_section_crc;
section_version =
host_image->image_section_info[i].fw_section_version;
if (section_type == UP_FW_UPDATE_BOOT)
continue;
Annotation
- Immediate include surface: `linux/netlink.h`, `net/devlink.h`, `linux/firmware.h`, `hinic_port.h`, `hinic_devlink.h`, `hinic_hw_dev.h`.
- Detected declarations: `function check_image_valid`, `function check_image_integrity`, `function check_image_device_type`, `function hinic_flash_fw`, `function hinic_firmware_update`, `function hinic_devlink_flash_update`, `function hinic_devlink_free`, `function hinic_devlink_register`, `function hinic_devlink_unregister`, `function chip_fault_show`.
- 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.