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.

Dependency Surface

Detected Declarations

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

Implementation Notes