aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/scsi_transport_sas.c36
-rw-r--r--include/scsi/scsi_transport_sas.h4
2 files changed, 38 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index dd075627e605..9bb4e37a1a61 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -41,6 +41,7 @@ struct sas_host_attrs {
41 struct mutex lock; 41 struct mutex lock;
42 u32 next_target_id; 42 u32 next_target_id;
43 u32 next_expander_id; 43 u32 next_expander_id;
44 int next_port_id;
44}; 45};
45#define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data) 46#define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data)
46 47
@@ -146,6 +147,7 @@ static int sas_host_setup(struct transport_container *tc, struct device *dev,
146 mutex_init(&sas_host->lock); 147 mutex_init(&sas_host->lock);
147 sas_host->next_target_id = 0; 148 sas_host->next_target_id = 0;
148 sas_host->next_expander_id = 0; 149 sas_host->next_expander_id = 0;
150 sas_host->next_port_id = 0;
149 return 0; 151 return 0;
150} 152}
151 153
@@ -327,7 +329,7 @@ sas_phy_protocol_attr(identify.target_port_protocols,
327sas_phy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n", 329sas_phy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n",
328 unsigned long long); 330 unsigned long long);
329sas_phy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8); 331sas_phy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8);
330//sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", u8); 332//sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", int);
331sas_phy_linkspeed_attr(negotiated_linkrate); 333sas_phy_linkspeed_attr(negotiated_linkrate);
332sas_phy_linkspeed_attr(minimum_linkrate_hw); 334sas_phy_linkspeed_attr(minimum_linkrate_hw);
333sas_phy_linkspeed_attr(minimum_linkrate); 335sas_phy_linkspeed_attr(minimum_linkrate);
@@ -590,6 +592,38 @@ struct sas_port *sas_port_alloc(struct device *parent, int port_id)
590} 592}
591EXPORT_SYMBOL(sas_port_alloc); 593EXPORT_SYMBOL(sas_port_alloc);
592 594
595/** sas_port_alloc_num - allocate and initialize a SAS port structure
596 *
597 * @parent: parent device
598 *
599 * Allocates a SAS port structure and a number to go with it. This
600 * interface is really for adapters where the port number has no
601 * meansing, so the sas class should manage them. It will be added to
602 * the device tree below the device specified by @parent which must be
603 * either a Scsi_Host or a sas_expander_device.
604 *
605 * Returns %NULL on error
606 */
607struct sas_port *sas_port_alloc_num(struct device *parent)
608{
609 int index;
610 struct Scsi_Host *shost = dev_to_shost(parent);
611 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
612
613 /* FIXME: use idr for this eventually */
614 mutex_lock(&sas_host->lock);
615 if (scsi_is_sas_expander_device(parent)) {
616 struct sas_rphy *rphy = dev_to_rphy(parent);
617 struct sas_expander_device *exp = rphy_to_expander_device(rphy);
618
619 index = exp->next_port_id++;
620 } else
621 index = sas_host->next_port_id++;
622 mutex_unlock(&sas_host->lock);
623 return sas_port_alloc(parent, index);
624}
625EXPORT_SYMBOL(sas_port_alloc_num);
626
593/** 627/**
594 * sas_port_add - add a SAS port to the device hierarchy 628 * sas_port_add - add a SAS port to the device hierarchy
595 * 629 *
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
index e3c503cd175e..f5772ff61d0d 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -106,6 +106,7 @@ struct sas_end_device {
106 106
107struct sas_expander_device { 107struct sas_expander_device {
108 int level; 108 int level;
109 int next_port_id;
109 110
110 #define SAS_EXPANDER_VENDOR_ID_LEN 8 111 #define SAS_EXPANDER_VENDOR_ID_LEN 8
111 char vendor_id[SAS_EXPANDER_VENDOR_ID_LEN+1]; 112 char vendor_id[SAS_EXPANDER_VENDOR_ID_LEN+1];
@@ -127,7 +128,7 @@ struct sas_expander_device {
127struct sas_port { 128struct sas_port {
128 struct device dev; 129 struct device dev;
129 130
130 u8 port_identifier; 131 int port_identifier;
131 int num_phys; 132 int num_phys;
132 133
133 /* the other end of the link */ 134 /* the other end of the link */
@@ -168,6 +169,7 @@ extern void sas_rphy_delete(struct sas_rphy *);
168extern int scsi_is_sas_rphy(const struct device *); 169extern int scsi_is_sas_rphy(const struct device *);
169 170
170struct sas_port *sas_port_alloc(struct device *, int); 171struct sas_port *sas_port_alloc(struct device *, int);
172struct sas_port *sas_port_alloc_num(struct device *);
171int sas_port_add(struct sas_port *); 173int sas_port_add(struct sas_port *);
172void sas_port_free(struct sas_port *); 174void sas_port_free(struct sas_port *);
173void sas_port_delete(struct sas_port *); 175void sas_port_delete(struct sas_port *);