From 033d961906bb82df29ccd51ec1f4b388eca146ec Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Tue, 17 Mar 2026 11:07:00 -0700 Subject: [PATCH] cndm: Report firmware information via devlink APIs Signed-off-by: Alex Forencich --- src/cndm/modules/cndm/cndm_devlink.c | 32 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/cndm/modules/cndm/cndm_devlink.c b/src/cndm/modules/cndm/cndm_devlink.c index bb45859..2d1a1f6 100644 --- a/src/cndm/modules/cndm/cndm_devlink.c +++ b/src/cndm/modules/cndm/cndm_devlink.c @@ -25,36 +25,58 @@ static int cndm_devlink_info_get(struct devlink *devlink, return ret; #endif - snprintf(str, sizeof(str), "%08x", 0); // TODO + snprintf(str, sizeof(str), "%08x", cdev->fpga_id); ret = devlink_info_version_fixed_put(req, "fpga.id", str); if (ret) return ret; - snprintf(str, sizeof(str), "%08x", 0); // TODO + snprintf(str, sizeof(str), "%08x", cdev->board_id); ret = devlink_info_version_fixed_put(req, DEVLINK_INFO_VERSION_GENERIC_BOARD_ID, str); if (ret) return ret; - snprintf(str, sizeof(str), "%08x", 0); // TODO + snprintf(str, sizeof(str), "%d.%d.%d", cdev->board_ver >> 20, + (cdev->board_ver >> 12) & 0xff, cdev->board_ver & 0xfff); ret = devlink_info_version_fixed_put(req, DEVLINK_INFO_VERSION_GENERIC_BOARD_REV, str); if (ret) return ret; - snprintf(str, sizeof(str), "%08x", 0); // TODO + snprintf(str, sizeof(str), "%08x", cdev->fw_id); ret = devlink_info_version_running_put(req, "fw.id", str); if (ret) return ret; - snprintf(str, sizeof(str), "%08x", 0); // TODO + snprintf(str, sizeof(str), "%d.%d.%d", cdev->fw_ver >> 20, + (cdev->fw_ver >> 12) & 0xff, cdev->fw_ver & 0xfff); + + ret = devlink_info_version_running_put(req, "fw.version", str); + if (ret) + return ret; ret = devlink_info_version_running_put(req, DEVLINK_INFO_VERSION_GENERIC_FW, str); if (ret) return ret; + ret = devlink_info_version_running_put(req, "fw.build_date", cdev->build_date_str); + if (ret) + return ret; + + snprintf(str, sizeof(str), "%08x", cdev->git_hash); + + ret = devlink_info_version_running_put(req, "fw.git_hash", str); + if (ret) + return ret; + + snprintf(str, sizeof(str), "%08x", cdev->release_info); + + ret = devlink_info_version_running_put(req, "fw.rel_info", str); + if (ret) + return ret; + return ret; }