scsi: smartpqi: Add support for long firmware version
authorKevin Barnett <kevin.barnett@microchip.com>
Thu, 11 Mar 2021 20:15:45 +0000 (14:15 -0600)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 6 Apr 2021 03:02:29 +0000 (23:02 -0400)
Add support for new "long" firmware version which requires minor driver
changes to expose.

Link: https://lore.kernel.org/r/161549374508.25025.15467221395888158022.stgit@brunhilda
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Kevin Barnett <kevin.barnett@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/smartpqi/smartpqi.h
drivers/scsi/smartpqi/smartpqi_init.c

index 35e89257977319c4371ad1778078414bc75bb430..aaafaced596be7085368815131960a8e8e89e940 100644 (file)
@@ -1226,7 +1226,7 @@ struct pqi_event {
 struct pqi_ctrl_info {
        unsigned int    ctrl_id;
        struct pci_dev  *pci_dev;
-       char            firmware_version[11];
+       char            firmware_version[32];
        char            serial_number[17];
        char            model[17];
        char            vendor[9];
@@ -1404,7 +1404,7 @@ enum pqi_ctrl_mode {
 struct bmic_identify_controller {
        u8      configured_logical_drive_count;
        __le32  configuration_signature;
-       u8      firmware_version[4];
+       u8      firmware_version_short[4];
        u8      reserved[145];
        __le16  extended_logical_unit_count;
        u8      reserved1[34];
@@ -1412,11 +1412,17 @@ struct bmic_identify_controller {
        u8      reserved2[8];
        u8      vendor_id[8];
        u8      product_id[16];
-       u8      reserved3[68];
+       u8      reserved3[62];
+       __le32  extra_controller_flags;
+       u8      reserved4[2];
        u8      controller_mode;
-       u8      reserved4[32];
+       u8      spare_part_number[32];
+       u8      firmware_version_long[32];
 };
 
+/* constants for extra_controller_flags field of bmic_identify_controller */
+#define BMIC_IDENTIFY_EXTRA_FLAGS_LONG_FW_VERSION_SUPPORTED    0x20000000
+
 struct bmic_sense_subsystem_info {
        u8      reserved[44];
        u8      ctrl_serial_number[16];
index 82f75a6be71cb16c63ea96eb35d89d8250b55b81..6cc953dd9961cfdc1b89625668f91d547344e95e 100644 (file)
@@ -7228,13 +7228,24 @@ static int pqi_get_ctrl_product_details(struct pqi_ctrl_info *ctrl_info)
        if (rc)
                goto out;
 
-       memcpy(ctrl_info->firmware_version, identify->firmware_version,
-               sizeof(identify->firmware_version));
-       ctrl_info->firmware_version[sizeof(identify->firmware_version)] = '\0';
-       snprintf(ctrl_info->firmware_version +
-               strlen(ctrl_info->firmware_version),
-               sizeof(ctrl_info->firmware_version),
-               "-%u", get_unaligned_le16(&identify->firmware_build_number));
+       if (get_unaligned_le32(&identify->extra_controller_flags) &
+               BMIC_IDENTIFY_EXTRA_FLAGS_LONG_FW_VERSION_SUPPORTED) {
+               memcpy(ctrl_info->firmware_version,
+                       identify->firmware_version_long,
+                       sizeof(identify->firmware_version_long));
+       } else {
+               memcpy(ctrl_info->firmware_version,
+                       identify->firmware_version_short,
+                       sizeof(identify->firmware_version_short));
+               ctrl_info->firmware_version
+                       [sizeof(identify->firmware_version_short)] = '\0';
+               snprintf(ctrl_info->firmware_version +
+                       strlen(ctrl_info->firmware_version),
+                       sizeof(ctrl_info->firmware_version) -
+                       sizeof(identify->firmware_version_short),
+                       "-%u",
+                       get_unaligned_le16(&identify->firmware_build_number));
+       }
 
        memcpy(ctrl_info->model, identify->product_id,
                sizeof(identify->product_id));
@@ -9612,13 +9623,23 @@ static void __attribute__((unused)) verify_structures(void)
        BUILD_BUG_ON(offsetof(struct bmic_identify_controller,
                configuration_signature) != 1);
        BUILD_BUG_ON(offsetof(struct bmic_identify_controller,
-               firmware_version) != 5);
+               firmware_version_short) != 5);
        BUILD_BUG_ON(offsetof(struct bmic_identify_controller,
                extended_logical_unit_count) != 154);
        BUILD_BUG_ON(offsetof(struct bmic_identify_controller,
                firmware_build_number) != 190);
+       BUILD_BUG_ON(offsetof(struct bmic_identify_controller,
+               vendor_id) != 200);
+       BUILD_BUG_ON(offsetof(struct bmic_identify_controller,
+               product_id) != 208);
+       BUILD_BUG_ON(offsetof(struct bmic_identify_controller,
+               extra_controller_flags) != 286);
        BUILD_BUG_ON(offsetof(struct bmic_identify_controller,
                controller_mode) != 292);
+       BUILD_BUG_ON(offsetof(struct bmic_identify_controller,
+               spare_part_number) != 293);
+       BUILD_BUG_ON(offsetof(struct bmic_identify_controller,
+               firmware_version_long) != 325);
 
        BUILD_BUG_ON(offsetof(struct bmic_identify_physical_device,
                phys_bay_in_box) != 115);