}
static int fw_mgmt_interface_fw_version_operation(struct fw_mgmt *fw_mgmt,
- struct fw_mgmt_ioc_get_fw *fw_info)
+ struct fw_mgmt_ioc_get_intf_version *fw_info)
{
struct gb_connection *connection = fw_mgmt->connection;
struct gb_fw_mgmt_interface_fw_version_response response;
}
static int fw_mgmt_backend_fw_version_operation(struct fw_mgmt *fw_mgmt,
- struct fw_mgmt_ioc_get_fw *fw_info)
+ struct fw_mgmt_ioc_get_backend_version *fw_info)
{
struct gb_connection *connection = fw_mgmt->connection;
struct gb_fw_mgmt_backend_fw_version_request request;
return ret;
}
- fw_info->major = le16_to_cpu(response.major);
- fw_info->minor = le16_to_cpu(response.minor);
+ fw_info->status = response.status;
+
+ /* Reset version as that should be non-zero only for success case */
+ fw_info->major = 0;
+ fw_info->minor = 0;
+
+ switch (fw_info->status) {
+ case GB_FW_BACKEND_VERSION_STATUS_SUCCESS:
+ fw_info->major = le16_to_cpu(response.major);
+ fw_info->minor = le16_to_cpu(response.minor);
+ break;
+ case GB_FW_BACKEND_VERSION_STATUS_NOT_AVAILABLE:
+ case GB_FW_BACKEND_VERSION_STATUS_RETRY:
+ break;
+ case GB_FW_BACKEND_VERSION_STATUS_NOT_SUPPORTED:
+ dev_err(fw_mgmt->parent,
+ "Firmware with tag %s is not supported by Interface\n",
+ fw_info->firmware_tag);
+ break;
+ default:
+ dev_err(fw_mgmt->parent, "Invalid status received: %u\n",
+ fw_info->status);
+ }
return 0;
}
static int fw_mgmt_ioctl(struct fw_mgmt *fw_mgmt, unsigned int cmd,
void __user *buf)
{
- struct fw_mgmt_ioc_get_fw fw_info;
+ struct fw_mgmt_ioc_get_intf_version intf_fw_info;
+ struct fw_mgmt_ioc_get_backend_version backend_fw_info;
struct fw_mgmt_ioc_intf_load_and_validate intf_load;
struct fw_mgmt_ioc_backend_fw_update backend_update;
unsigned int timeout;
switch (cmd) {
case FW_MGMT_IOC_GET_INTF_FW:
- ret = fw_mgmt_interface_fw_version_operation(fw_mgmt, &fw_info);
+ ret = fw_mgmt_interface_fw_version_operation(fw_mgmt,
+ &intf_fw_info);
if (ret)
return ret;
- if (copy_to_user(buf, &fw_info, sizeof(fw_info)))
+ if (copy_to_user(buf, &intf_fw_info, sizeof(intf_fw_info)))
return -EFAULT;
return 0;
case FW_MGMT_IOC_GET_BACKEND_FW:
- if (copy_from_user(&fw_info, buf, sizeof(fw_info)))
+ if (copy_from_user(&backend_fw_info, buf,
+ sizeof(backend_fw_info)))
return -EFAULT;
- ret = fw_mgmt_backend_fw_version_operation(fw_mgmt, &fw_info);
+ ret = fw_mgmt_backend_fw_version_operation(fw_mgmt,
+ &backend_fw_info);
if (ret)
return ret;
- if (copy_to_user(buf, &fw_info, sizeof(fw_info)))
+ if (copy_to_user(buf, &backend_fw_info,
+ sizeof(backend_fw_info)))
return -EFAULT;
return 0;
#define GB_FW_U_BACKEND_FW_STATUS_FAIL_FETCH 0x03
#define GB_FW_U_BACKEND_FW_STATUS_FAIL_WRITE 0x04
#define GB_FW_U_BACKEND_FW_STATUS_INT 0x05
+#define GB_FW_U_BACKEND_FW_STATUS_RETRY 0x06
+#define GB_FW_U_BACKEND_FW_STATUS_NOT_SUPPORTED 0x07
+
+#define GB_FW_U_BACKEND_VERSION_STATUS_SUCCESS 0x01
+#define GB_FW_U_BACKEND_VERSION_STATUS_NOT_AVAILABLE 0x02
+#define GB_FW_U_BACKEND_VERSION_STATUS_NOT_SUPPORTED 0x03
+#define GB_FW_U_BACKEND_VERSION_STATUS_RETRY 0x04
+#define GB_FW_U_BACKEND_VERSION_STATUS_FAIL_INT 0x05
/* IOCTL support */
-struct fw_mgmt_ioc_get_fw {
+struct fw_mgmt_ioc_get_intf_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
__u16 major;
__u16 minor;
} __attribute__ ((__packed__));
+struct fw_mgmt_ioc_get_backend_version {
+ __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
+ __u16 major;
+ __u16 minor;
+ __u8 status;
+} __attribute__ ((__packed__));
+
struct fw_mgmt_ioc_intf_load_and_validate {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
__u8 load_method;
} __attribute__ ((__packed__));
#define FW_MGMT_IOCTL_BASE 'F'
-#define FW_MGMT_IOC_GET_INTF_FW _IOR(FW_MGMT_IOCTL_BASE, 0, struct fw_mgmt_ioc_get_fw)
-#define FW_MGMT_IOC_GET_BACKEND_FW _IOWR(FW_MGMT_IOCTL_BASE, 1, struct fw_mgmt_ioc_get_fw)
+#define FW_MGMT_IOC_GET_INTF_FW _IOR(FW_MGMT_IOCTL_BASE, 0, struct fw_mgmt_ioc_get_intf_version)
+#define FW_MGMT_IOC_GET_BACKEND_FW _IOWR(FW_MGMT_IOCTL_BASE, 1, struct fw_mgmt_ioc_get_backend_version)
#define FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE _IOWR(FW_MGMT_IOCTL_BASE, 2, struct fw_mgmt_ioc_intf_load_and_validate)
#define FW_MGMT_IOC_INTF_BACKEND_FW_UPDATE _IOWR(FW_MGMT_IOCTL_BASE, 3, struct fw_mgmt_ioc_backend_fw_update)
#define FW_MGMT_IOC_SET_TIMEOUT_MS _IOW(FW_MGMT_IOCTL_BASE, 4, unsigned int)
#define GB_FW_BACKEND_FW_STATUS_RETRY 0x06
#define GB_FW_BACKEND_FW_STATUS_NOT_SUPPORTED 0x07
+#define GB_FW_BACKEND_VERSION_STATUS_SUCCESS 0x01
+#define GB_FW_BACKEND_VERSION_STATUS_NOT_AVAILABLE 0x02
+#define GB_FW_BACKEND_VERSION_STATUS_NOT_SUPPORTED 0x03
+#define GB_FW_BACKEND_VERSION_STATUS_RETRY 0x04
+#define GB_FW_BACKEND_VERSION_STATUS_FAIL_INT 0x05
+
/* firmware management interface firmware version request has no payload */
struct gb_fw_mgmt_interface_fw_version_response {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
struct gb_fw_mgmt_backend_fw_version_response {
__le16 major;
__le16 minor;
+ __u8 status;
} __packed;
/* firmware management backend firmware update request */