diff options
-rw-r--r-- | drivers/scsi/scsi_transport_sas.c | 53 | ||||
-rw-r--r-- | include/scsi/scsi_transport_sas.h | 2 |
2 files changed, 53 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index 205542988e29..eab5c7c6f3c7 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2005 Dell Inc. | 2 | * Copyright (C) 2005-2006 Dell Inc. |
3 | * Released under GPL v2. | 3 | * Released under GPL v2. |
4 | * | 4 | * |
5 | * Serial Attached SCSI (SAS) transport class. | 5 | * Serial Attached SCSI (SAS) transport class. |
@@ -38,7 +38,7 @@ | |||
38 | 38 | ||
39 | #define SAS_HOST_ATTRS 0 | 39 | #define SAS_HOST_ATTRS 0 |
40 | #define SAS_PORT_ATTRS 17 | 40 | #define SAS_PORT_ATTRS 17 |
41 | #define SAS_RPORT_ATTRS 5 | 41 | #define SAS_RPORT_ATTRS 7 |
42 | 42 | ||
43 | struct sas_internal { | 43 | struct sas_internal { |
44 | struct scsi_transport_template t; | 44 | struct scsi_transport_template t; |
@@ -533,6 +533,53 @@ show_sas_rphy_device_type(struct class_device *cdev, char *buf) | |||
533 | static SAS_CLASS_DEVICE_ATTR(rphy, device_type, S_IRUGO, | 533 | static SAS_CLASS_DEVICE_ATTR(rphy, device_type, S_IRUGO, |
534 | show_sas_rphy_device_type, NULL); | 534 | show_sas_rphy_device_type, NULL); |
535 | 535 | ||
536 | static ssize_t | ||
537 | show_sas_rphy_enclosure_identifier(struct class_device *cdev, char *buf) | ||
538 | { | ||
539 | struct sas_rphy *rphy = transport_class_to_rphy(cdev); | ||
540 | struct sas_phy *phy = dev_to_phy(rphy->dev.parent); | ||
541 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); | ||
542 | struct sas_internal *i = to_sas_internal(shost->transportt); | ||
543 | u64 identifier; | ||
544 | int error; | ||
545 | |||
546 | /* | ||
547 | * Only devices behind an expander are supported, because the | ||
548 | * enclosure identifier is a SMP feature. | ||
549 | */ | ||
550 | if (phy->local_attached) | ||
551 | return -EINVAL; | ||
552 | |||
553 | error = i->f->get_enclosure_identifier(rphy, &identifier); | ||
554 | if (error) | ||
555 | return error; | ||
556 | return sprintf(buf, "0x%llx\n", (unsigned long long)identifier); | ||
557 | } | ||
558 | |||
559 | static SAS_CLASS_DEVICE_ATTR(rphy, enclosure_identifier, S_IRUGO, | ||
560 | show_sas_rphy_enclosure_identifier, NULL); | ||
561 | |||
562 | static ssize_t | ||
563 | show_sas_rphy_bay_identifier(struct class_device *cdev, char *buf) | ||
564 | { | ||
565 | struct sas_rphy *rphy = transport_class_to_rphy(cdev); | ||
566 | struct sas_phy *phy = dev_to_phy(rphy->dev.parent); | ||
567 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); | ||
568 | struct sas_internal *i = to_sas_internal(shost->transportt); | ||
569 | int val; | ||
570 | |||
571 | if (phy->local_attached) | ||
572 | return -EINVAL; | ||
573 | |||
574 | val = i->f->get_bay_identifier(rphy); | ||
575 | if (val < 0) | ||
576 | return val; | ||
577 | return sprintf(buf, "%d\n", val); | ||
578 | } | ||
579 | |||
580 | static SAS_CLASS_DEVICE_ATTR(rphy, bay_identifier, S_IRUGO, | ||
581 | show_sas_rphy_bay_identifier, NULL); | ||
582 | |||
536 | sas_rphy_protocol_attr(identify.initiator_port_protocols, | 583 | sas_rphy_protocol_attr(identify.initiator_port_protocols, |
537 | initiator_port_protocols); | 584 | initiator_port_protocols); |
538 | sas_rphy_protocol_attr(identify.target_port_protocols, target_port_protocols); | 585 | sas_rphy_protocol_attr(identify.target_port_protocols, target_port_protocols); |
@@ -845,6 +892,8 @@ sas_attach_transport(struct sas_function_template *ft) | |||
845 | SETUP_RPORT_ATTRIBUTE(rphy_device_type); | 892 | SETUP_RPORT_ATTRIBUTE(rphy_device_type); |
846 | SETUP_RPORT_ATTRIBUTE(rphy_sas_address); | 893 | SETUP_RPORT_ATTRIBUTE(rphy_sas_address); |
847 | SETUP_RPORT_ATTRIBUTE(rphy_phy_identifier); | 894 | SETUP_RPORT_ATTRIBUTE(rphy_phy_identifier); |
895 | SETUP_RPORT_ATTRIBUTE(rphy_enclosure_identifier); | ||
896 | SETUP_RPORT_ATTRIBUTE(rphy_bay_identifier); | ||
848 | i->rphy_attrs[count] = NULL; | 897 | i->rphy_attrs[count] = NULL; |
849 | 898 | ||
850 | return &i->t; | 899 | return &i->t; |
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h index b91400bfb02a..ccef5d2cf478 100644 --- a/include/scsi/scsi_transport_sas.h +++ b/include/scsi/scsi_transport_sas.h | |||
@@ -94,6 +94,8 @@ struct sas_rphy { | |||
94 | /* The functions by which the transport class and the driver communicate */ | 94 | /* The functions by which the transport class and the driver communicate */ |
95 | struct sas_function_template { | 95 | struct sas_function_template { |
96 | int (*get_linkerrors)(struct sas_phy *); | 96 | int (*get_linkerrors)(struct sas_phy *); |
97 | int (*get_enclosure_identifier)(struct sas_rphy *, u64 *); | ||
98 | int (*get_bay_identifier)(struct sas_rphy *); | ||
97 | int (*phy_reset)(struct sas_phy *, int); | 99 | int (*phy_reset)(struct sas_phy *, int); |
98 | }; | 100 | }; |
99 | 101 | ||