diff options
author | Don Brace <don.brace@pmcs.com> | 2015-12-22 11:36:48 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-01-06 15:10:36 -0500 |
commit | cca8f13b4fdaf3583e103ae7f96fda948839b265 (patch) | |
tree | 1de29e2b10886cb1092b2e3d8dd63b67cf140ae2 | |
parent | 09371d623c9c3dc6ed7f53ec8ab01d25f0c6c697 (diff) |
hpsa: Add box and bay information for enclosure devices
Adding a new method to display enclosure device information.
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/hpsa.c | 107 | ||||
-rw-r--r-- | drivers/scsi/hpsa_cmd.h | 13 |
2 files changed, 113 insertions, 7 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 9ad546e8e148..17a39761b05d 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -750,7 +750,6 @@ static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev, | |||
750 | } | 750 | } |
751 | 751 | ||
752 | #define MAX_PATHS 8 | 752 | #define MAX_PATHS 8 |
753 | |||
754 | static ssize_t path_info_show(struct device *dev, | 753 | static ssize_t path_info_show(struct device *dev, |
755 | struct device_attribute *attr, char *buf) | 754 | struct device_attribute *attr, char *buf) |
756 | { | 755 | { |
@@ -792,9 +791,7 @@ static ssize_t path_info_show(struct device *dev, | |||
792 | hdev->bus, hdev->target, hdev->lun, | 791 | hdev->bus, hdev->target, hdev->lun, |
793 | scsi_device_type(hdev->devtype)); | 792 | scsi_device_type(hdev->devtype)); |
794 | 793 | ||
795 | if (hdev->external || | 794 | if (hdev->devtype == TYPE_RAID || is_logical_device(hdev)) { |
796 | hdev->devtype == TYPE_RAID || | ||
797 | is_logical_device(hdev)) { | ||
798 | output_len += scnprintf(buf + output_len, | 795 | output_len += scnprintf(buf + output_len, |
799 | PAGE_SIZE - output_len, | 796 | PAGE_SIZE - output_len, |
800 | "%s\n", active); | 797 | "%s\n", active); |
@@ -808,8 +805,7 @@ static ssize_t path_info_show(struct device *dev, | |||
808 | phys_connector[0] = '0'; | 805 | phys_connector[0] = '0'; |
809 | if (phys_connector[1] < '0') | 806 | if (phys_connector[1] < '0') |
810 | phys_connector[1] = '0'; | 807 | phys_connector[1] = '0'; |
811 | if (hdev->phys_connector[i] > 0) | 808 | output_len += scnprintf(buf + output_len, |
812 | output_len += scnprintf(buf + output_len, | ||
813 | PAGE_SIZE - output_len, | 809 | PAGE_SIZE - output_len, |
814 | "PORT: %.2s ", | 810 | "PORT: %.2s ", |
815 | phys_connector); | 811 | phys_connector); |
@@ -3191,6 +3187,87 @@ out: | |||
3191 | return rc; | 3187 | return rc; |
3192 | } | 3188 | } |
3193 | 3189 | ||
3190 | /* | ||
3191 | * get enclosure information | ||
3192 | * struct ReportExtendedLUNdata *rlep - Used for BMIC drive number | ||
3193 | * struct hpsa_scsi_dev_t *encl_dev - device entry for enclosure | ||
3194 | * Uses id_physical_device to determine the box_index. | ||
3195 | */ | ||
3196 | static void hpsa_get_enclosure_info(struct ctlr_info *h, | ||
3197 | unsigned char *scsi3addr, | ||
3198 | struct ReportExtendedLUNdata *rlep, int rle_index, | ||
3199 | struct hpsa_scsi_dev_t *encl_dev) | ||
3200 | { | ||
3201 | int rc = -1; | ||
3202 | struct CommandList *c = NULL; | ||
3203 | struct ErrorInfo *ei = NULL; | ||
3204 | struct bmic_sense_storage_box_params *bssbp = NULL; | ||
3205 | struct bmic_identify_physical_device *id_phys = NULL; | ||
3206 | struct ext_report_lun_entry *rle = &rlep->LUN[rle_index]; | ||
3207 | u16 bmic_device_index = 0; | ||
3208 | |||
3209 | bmic_device_index = GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]); | ||
3210 | |||
3211 | if (bmic_device_index == 0xFF00) | ||
3212 | goto out; | ||
3213 | |||
3214 | bssbp = kzalloc(sizeof(*bssbp), GFP_KERNEL); | ||
3215 | if (!bssbp) | ||
3216 | goto out; | ||
3217 | |||
3218 | id_phys = kzalloc(sizeof(*id_phys), GFP_KERNEL); | ||
3219 | if (!id_phys) | ||
3220 | goto out; | ||
3221 | |||
3222 | rc = hpsa_bmic_id_physical_device(h, scsi3addr, bmic_device_index, | ||
3223 | id_phys, sizeof(*id_phys)); | ||
3224 | if (rc) { | ||
3225 | dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", | ||
3226 | __func__, encl_dev->external, bmic_device_index); | ||
3227 | goto out; | ||
3228 | } | ||
3229 | |||
3230 | c = cmd_alloc(h); | ||
3231 | |||
3232 | rc = fill_cmd(c, BMIC_SENSE_STORAGE_BOX_PARAMS, h, bssbp, | ||
3233 | sizeof(*bssbp), 0, RAID_CTLR_LUNID, TYPE_CMD); | ||
3234 | |||
3235 | if (rc) | ||
3236 | goto out; | ||
3237 | |||
3238 | if (id_phys->phys_connector[1] == 'E') | ||
3239 | c->Request.CDB[5] = id_phys->box_index; | ||
3240 | else | ||
3241 | c->Request.CDB[5] = 0; | ||
3242 | |||
3243 | rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, PCI_DMA_FROMDEVICE, | ||
3244 | NO_TIMEOUT); | ||
3245 | if (rc) | ||
3246 | goto out; | ||
3247 | |||
3248 | ei = c->err_info; | ||
3249 | if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { | ||
3250 | rc = -1; | ||
3251 | goto out; | ||
3252 | } | ||
3253 | |||
3254 | encl_dev->box[id_phys->active_path_number] = bssbp->phys_box_on_port; | ||
3255 | memcpy(&encl_dev->phys_connector[id_phys->active_path_number], | ||
3256 | bssbp->phys_connector, sizeof(bssbp->phys_connector)); | ||
3257 | |||
3258 | rc = IO_OK; | ||
3259 | out: | ||
3260 | kfree(bssbp); | ||
3261 | kfree(id_phys); | ||
3262 | |||
3263 | if (c) | ||
3264 | cmd_free(h, c); | ||
3265 | |||
3266 | if (rc != IO_OK) | ||
3267 | hpsa_show_dev_msg(KERN_INFO, h, encl_dev, | ||
3268 | "Error, could not get enclosure information\n"); | ||
3269 | } | ||
3270 | |||
3194 | static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h, | 3271 | static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h, |
3195 | unsigned char *scsi3addr) | 3272 | unsigned char *scsi3addr) |
3196 | { | 3273 | { |
@@ -4032,7 +4109,8 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h) | |||
4032 | 4109 | ||
4033 | /* skip masked non-disk devices */ | 4110 | /* skip masked non-disk devices */ |
4034 | if (MASKED_DEVICE(lunaddrbytes) && physical_device && | 4111 | if (MASKED_DEVICE(lunaddrbytes) && physical_device && |
4035 | (physdev_list->LUN[phys_dev_index].device_flags & 0x01)) | 4112 | (physdev_list->LUN[phys_dev_index].device_type != 0x06) && |
4113 | (physdev_list->LUN[phys_dev_index].device_flags & 0x01)) | ||
4036 | continue; | 4114 | continue; |
4037 | 4115 | ||
4038 | /* Get device type, vendor, model, device id */ | 4116 | /* Get device type, vendor, model, device id */ |
@@ -4116,7 +4194,12 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h) | |||
4116 | break; | 4194 | break; |
4117 | case TYPE_TAPE: | 4195 | case TYPE_TAPE: |
4118 | case TYPE_MEDIUM_CHANGER: | 4196 | case TYPE_MEDIUM_CHANGER: |
4197 | ncurrent++; | ||
4198 | break; | ||
4119 | case TYPE_ENCLOSURE: | 4199 | case TYPE_ENCLOSURE: |
4200 | hpsa_get_enclosure_info(h, lunaddrbytes, | ||
4201 | physdev_list, phys_dev_index, | ||
4202 | this_device); | ||
4120 | ncurrent++; | 4203 | ncurrent++; |
4121 | break; | 4204 | break; |
4122 | case TYPE_RAID: | 4205 | case TYPE_RAID: |
@@ -6629,6 +6712,16 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, | |||
6629 | c->Request.CDB[7] = (size >> 16) & 0xFF; | 6712 | c->Request.CDB[7] = (size >> 16) & 0xFF; |
6630 | c->Request.CDB[8] = (size >> 8) & 0XFF; | 6713 | c->Request.CDB[8] = (size >> 8) & 0XFF; |
6631 | break; | 6714 | break; |
6715 | case BMIC_SENSE_STORAGE_BOX_PARAMS: | ||
6716 | c->Request.CDBLen = 10; | ||
6717 | c->Request.type_attr_dir = | ||
6718 | TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ); | ||
6719 | c->Request.Timeout = 0; | ||
6720 | c->Request.CDB[0] = BMIC_READ; | ||
6721 | c->Request.CDB[6] = BMIC_SENSE_STORAGE_BOX_PARAMS; | ||
6722 | c->Request.CDB[7] = (size >> 16) & 0xFF; | ||
6723 | c->Request.CDB[8] = (size >> 8) & 0XFF; | ||
6724 | break; | ||
6632 | case BMIC_IDENTIFY_CONTROLLER: | 6725 | case BMIC_IDENTIFY_CONTROLLER: |
6633 | c->Request.CDBLen = 10; | 6726 | c->Request.CDBLen = 10; |
6634 | c->Request.type_attr_dir = | 6727 | c->Request.type_attr_dir = |
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h index d92ef0d352b5..6a919ada96b3 100644 --- a/drivers/scsi/hpsa_cmd.h +++ b/drivers/scsi/hpsa_cmd.h | |||
@@ -291,6 +291,7 @@ struct SenseSubsystem_info { | |||
291 | #define BMIC_SENSE_DIAG_OPTIONS 0xF5 | 291 | #define BMIC_SENSE_DIAG_OPTIONS 0xF5 |
292 | #define HPSA_DIAG_OPTS_DISABLE_RLD_CACHING 0x40000000 | 292 | #define HPSA_DIAG_OPTS_DISABLE_RLD_CACHING 0x40000000 |
293 | #define BMIC_SENSE_SUBSYSTEM_INFORMATION 0x66 | 293 | #define BMIC_SENSE_SUBSYSTEM_INFORMATION 0x66 |
294 | #define BMIC_SENSE_STORAGE_BOX_PARAMS 0x65 | ||
294 | 295 | ||
295 | /* Command List Structure */ | 296 | /* Command List Structure */ |
296 | union SCSI3Addr { | 297 | union SCSI3Addr { |
@@ -842,5 +843,17 @@ struct bmic_sense_subsystem_info { | |||
842 | u8 pad[332]; | 843 | u8 pad[332]; |
843 | }; | 844 | }; |
844 | 845 | ||
846 | struct bmic_sense_storage_box_params { | ||
847 | u8 reserved[36]; | ||
848 | u8 inquiry_valid; | ||
849 | u8 reserved_1[68]; | ||
850 | u8 phys_box_on_port; | ||
851 | u8 reserved_2[22]; | ||
852 | u16 connection_info; | ||
853 | u8 reserver_3[84]; | ||
854 | u8 phys_connector[2]; | ||
855 | u8 reserved_4[296]; | ||
856 | }; | ||
857 | |||
845 | #pragma pack() | 858 | #pragma pack() |
846 | #endif /* HPSA_CMD_H */ | 859 | #endif /* HPSA_CMD_H */ |