drivers/net/ethernet/broadcom/bnge/bnge_devlink.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnge/bnge_devlink.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/broadcom/bnge/bnge_devlink.c
Extension
.c
Size
8349 bytes
Lines
307
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 (rc) {
			NL_SET_ERR_MSG_MOD(extack, "Failed to set dsn");
			return rc;
		}
	}

	if (strlen(bd->board_serialno)) {
		rc = devlink_info_board_serial_number_put(req,
							  bd->board_serialno);
		if (rc) {
			NL_SET_ERR_MSG_MOD(extack,
					   "Failed to set board serial number");
			return rc;
		}
	}

	rc = bnge_dl_info_put(bd, req, BNGE_VERSION_FIXED,
			      DEVLINK_INFO_VERSION_GENERIC_BOARD_ID,
			      bd->board_partno);
	if (rc) {
		NL_SET_ERR_MSG_MOD(extack, "Failed to set board part number");
		return rc;
	}

	/* More information from HWRM ver get command */
	sprintf(buf, "%X", bd->chip_num);
	rc = bnge_dl_info_put(bd, req, BNGE_VERSION_FIXED,
			      DEVLINK_INFO_VERSION_GENERIC_ASIC_ID, buf);
	if (rc) {
		NL_SET_ERR_MSG_MOD(extack, "Failed to set asic id");
		return rc;
	}

	ver_resp = &bd->ver_resp;
	sprintf(buf, "%c%d", 'A' + ver_resp->chip_rev, ver_resp->chip_metal);
	rc = bnge_dl_info_put(bd, req, BNGE_VERSION_FIXED,
			      DEVLINK_INFO_VERSION_GENERIC_ASIC_REV, buf);
	if (rc) {
		NL_SET_ERR_MSG_MOD(extack, "Failed to set asic info");
		return rc;
	}

	rc = bnge_dl_info_put(bd, req, BNGE_VERSION_RUNNING,
			      DEVLINK_INFO_VERSION_GENERIC_FW_PSID,
			      bd->nvm_cfg_ver);
	if (rc) {
		NL_SET_ERR_MSG_MOD(extack, "Failed to set firmware version");
		return rc;
	}

	buf[0] = 0;
	strncat(buf, ver_resp->active_pkg_name, HWRM_FW_VER_STR_LEN);
	rc = bnge_dl_info_put(bd, req, BNGE_VERSION_RUNNING,
			      DEVLINK_INFO_VERSION_GENERIC_FW, buf);
	if (rc) {
		NL_SET_ERR_MSG_MOD(extack,
				   "Failed to set firmware generic version");
		return rc;
	}

	if (ver_resp->flags & VER_GET_RESP_FLAGS_EXT_VER_AVAIL) {
		snprintf(mgmt_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
			 ver_resp->hwrm_fw_major, ver_resp->hwrm_fw_minor,
			 ver_resp->hwrm_fw_build, ver_resp->hwrm_fw_patch);

		snprintf(ncsi_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
			 ver_resp->mgmt_fw_major, ver_resp->mgmt_fw_minor,
			 ver_resp->mgmt_fw_build, ver_resp->mgmt_fw_patch);

		snprintf(roce_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
			 ver_resp->roce_fw_major, ver_resp->roce_fw_minor,
			 ver_resp->roce_fw_build, ver_resp->roce_fw_patch);
	} else {
		snprintf(mgmt_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
			 ver_resp->hwrm_fw_maj_8b, ver_resp->hwrm_fw_min_8b,
			 ver_resp->hwrm_fw_bld_8b, ver_resp->hwrm_fw_rsvd_8b);

		snprintf(ncsi_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
			 ver_resp->mgmt_fw_maj_8b, ver_resp->mgmt_fw_min_8b,
			 ver_resp->mgmt_fw_bld_8b, ver_resp->mgmt_fw_rsvd_8b);

		snprintf(roce_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
			 ver_resp->roce_fw_maj_8b, ver_resp->roce_fw_min_8b,
			 ver_resp->roce_fw_bld_8b, ver_resp->roce_fw_rsvd_8b);
	}
	rc = bnge_dl_info_put(bd, req, BNGE_VERSION_RUNNING,
			      DEVLINK_INFO_VERSION_GENERIC_FW_MGMT, mgmt_ver);
	if (rc) {
		NL_SET_ERR_MSG_MOD(extack,
				   "Failed to set firmware mgmt version");

Annotation

Implementation Notes