2 * Copyright (C) 2005 Dell Inc.
3 * Released under GPL v2.
5 * Serial Attached SCSI (SAS) transport class.
7 * The SAS transport class contains common code to deal with SAS HBAs,
8 * an aproximated representation of SAS topologies in the driver model,
9 * and various sysfs attributes to expose these topologies and managment
10 * interfaces to userspace.
12 * In addition to the basic SCSI core objects this transport class
13 * introduces two additional intermediate objects: The SAS PHY
14 * as represented by struct sas_phy defines an "outgoing" PHY on
15 * a SAS HBA or Expander, and the SAS remote PHY represented by
16 * struct sas_rphy defines an "incoming" PHY on a SAS Expander or
17 * end device. Note that this is purely a software concept, the
18 * underlying hardware for a PHY and a remote PHY is the exactly
21 * There is no concept of a SAS port in this code, users can see
22 * what PHYs form a wide port based on the port_identifier attribute,
23 * which is the same for all PHYs in a port.
26 #include <linux/init.h>
27 #include <linux/module.h>
28 #include <linux/err.h>
30 #include <scsi/scsi_device.h>
31 #include <scsi/scsi_host.h>
32 #include <scsi/scsi_transport.h>
33 #include <scsi/scsi_transport_sas.h>
36 #define SAS_HOST_ATTRS 0
37 #define SAS_PORT_ATTRS 15
38 #define SAS_RPORT_ATTRS 5
41 struct scsi_transport_template t;
42 struct sas_function_template *f;
44 struct class_device_attribute private_host_attrs[SAS_HOST_ATTRS];
45 struct class_device_attribute private_phy_attrs[SAS_PORT_ATTRS];
46 struct class_device_attribute private_rphy_attrs[SAS_RPORT_ATTRS];
48 struct transport_container phy_attr_cont;
49 struct transport_container rphy_attr_cont;
52 * The array of null terminated pointers to attributes
53 * needed by scsi_sysfs.c
55 struct class_device_attribute *host_attrs[SAS_HOST_ATTRS + 1];
56 struct class_device_attribute *phy_attrs[SAS_PORT_ATTRS + 1];
57 struct class_device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1];
59 #define to_sas_internal(tmpl) container_of(tmpl, struct sas_internal, t)
61 struct sas_host_attrs {
62 struct list_head rphy_list;
66 #define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data)
70 * Hack to allow attributes of the same name in different objects.
72 #define SAS_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
73 struct class_device_attribute class_device_attr_##_prefix##_##_name = \
74 __ATTR(_name,_mode,_show,_store)
78 * Pretty printing helpers
81 #define sas_bitfield_name_match(title, table) \
83 get_sas_##title##_names(u32 table_key, char *buf) \
89 for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) { \
90 if (table[i].value & table_key) { \
91 len += sprintf(buf + len, "%s%s", \
92 prefix, table[i].name); \
96 len += sprintf(buf + len, "\n"); \
100 #define sas_bitfield_name_search(title, table) \
102 get_sas_##title##_names(u32 table_key, char *buf) \
107 for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) { \
108 if (table[i].value == table_key) { \
109 len += sprintf(buf + len, "%s", \
114 len += sprintf(buf + len, "\n"); \
121 } sas_device_type_names[] = {
122 { SAS_PHY_UNUSED, "unused" },
123 { SAS_END_DEVICE, "end device" },
124 { SAS_EDGE_EXPANDER_DEVICE, "edge expander" },
125 { SAS_FANOUT_EXPANDER_DEVICE, "fanout expander" },
127 sas_bitfield_name_search(device_type, sas_device_type_names)
133 } sas_protocol_names[] = {
134 { SAS_PROTOCOL_SATA, "sata" },
135 { SAS_PROTOCOL_SMP, "smp" },
136 { SAS_PROTOCOL_STP, "stp" },
137 { SAS_PROTOCOL_SSP, "ssp" },
139 sas_bitfield_name_match(protocol, sas_protocol_names)
144 } sas_linkspeed_names[] = {
145 { SAS_LINK_RATE_UNKNOWN, "Unknown" },
146 { SAS_PHY_DISABLED, "Phy disabled" },
147 { SAS_LINK_RATE_FAILED, "Link Rate failed" },
148 { SAS_SATA_SPINUP_HOLD, "Spin-up hold" },
149 { SAS_LINK_RATE_1_5_GBPS, "1.5 Gbit" },
150 { SAS_LINK_RATE_3_0_GBPS, "3.0 Gbit" },
152 sas_bitfield_name_search(linkspeed, sas_linkspeed_names)
156 * SAS host attributes
159 static int sas_host_setup(struct transport_container *tc, struct device *dev,
160 struct class_device *cdev)
162 struct Scsi_Host *shost = dev_to_shost(dev);
163 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
165 INIT_LIST_HEAD(&sas_host->rphy_list);
166 spin_lock_init(&sas_host->lock);
167 sas_host->next_target_id = 0;
171 static DECLARE_TRANSPORT_CLASS(sas_host_class,
172 "sas_host", sas_host_setup, NULL, NULL);
174 static int sas_host_match(struct attribute_container *cont,
177 struct Scsi_Host *shost;
178 struct sas_internal *i;
180 if (!scsi_is_host_device(dev))
182 shost = dev_to_shost(dev);
184 if (!shost->transportt)
186 if (shost->transportt->host_attrs.ac.class !=
187 &sas_host_class.class)
190 i = to_sas_internal(shost->transportt);
191 return &i->t.host_attrs.ac == cont;
194 static int do_sas_phy_delete(struct device *dev, void *data)
196 if (scsi_is_sas_phy(dev))
197 sas_phy_delete(dev_to_phy(dev));
202 * sas_remove_host -- tear down a Scsi_Host's SAS data structures
203 * @shost: Scsi Host that is torn down
205 * Removes all SAS PHYs and remote PHYs for a given Scsi_Host.
206 * Must be called just before scsi_remove_host for SAS HBAs.
208 void sas_remove_host(struct Scsi_Host *shost)
210 device_for_each_child(&shost->shost_gendev, NULL, do_sas_phy_delete);
212 EXPORT_SYMBOL(sas_remove_host);
216 * SAS Port attributes
219 #define sas_phy_show_simple(field, name, format_string, cast) \
221 show_sas_phy_##name(struct class_device *cdev, char *buf) \
223 struct sas_phy *phy = transport_class_to_phy(cdev); \
225 return snprintf(buf, 20, format_string, cast phy->field); \
228 #define sas_phy_simple_attr(field, name, format_string, type) \
229 sas_phy_show_simple(field, name, format_string, (type)) \
230 static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL)
232 #define sas_phy_show_protocol(field, name) \
234 show_sas_phy_##name(struct class_device *cdev, char *buf) \
236 struct sas_phy *phy = transport_class_to_phy(cdev); \
239 return snprintf(buf, 20, "none\n"); \
240 return get_sas_protocol_names(phy->field, buf); \
243 #define sas_phy_protocol_attr(field, name) \
244 sas_phy_show_protocol(field, name) \
245 static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL)
247 #define sas_phy_show_linkspeed(field) \
249 show_sas_phy_##field(struct class_device *cdev, char *buf) \
251 struct sas_phy *phy = transport_class_to_phy(cdev); \
253 return get_sas_linkspeed_names(phy->field, buf); \
256 #define sas_phy_linkspeed_attr(field) \
257 sas_phy_show_linkspeed(field) \
258 static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL)
260 #define sas_phy_show_linkerror(field) \
262 show_sas_phy_##field(struct class_device *cdev, char *buf) \
264 struct sas_phy *phy = transport_class_to_phy(cdev); \
265 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \
266 struct sas_internal *i = to_sas_internal(shost->transportt); \
269 if (!phy->local_attached) \
272 error = i->f->get_linkerrors(phy); \
275 return snprintf(buf, 20, "%u\n", phy->field); \
278 #define sas_phy_linkerror_attr(field) \
279 sas_phy_show_linkerror(field) \
280 static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL)
284 show_sas_device_type(struct class_device *cdev, char *buf)
286 struct sas_phy *phy = transport_class_to_phy(cdev);
288 if (!phy->identify.device_type)
289 return snprintf(buf, 20, "none\n");
290 return get_sas_device_type_names(phy->identify.device_type, buf);
293 static CLASS_DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL);
295 sas_phy_protocol_attr(identify.initiator_port_protocols,
296 initiator_port_protocols);
297 sas_phy_protocol_attr(identify.target_port_protocols,
298 target_port_protocols);
299 sas_phy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n",
301 sas_phy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8);
302 sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", u8);
303 sas_phy_linkspeed_attr(negotiated_linkrate);
304 sas_phy_linkspeed_attr(minimum_linkrate_hw);
305 sas_phy_linkspeed_attr(minimum_linkrate);
306 sas_phy_linkspeed_attr(maximum_linkrate_hw);
307 sas_phy_linkspeed_attr(maximum_linkrate);
308 sas_phy_linkerror_attr(invalid_dword_count);
309 sas_phy_linkerror_attr(running_disparity_error_count);
310 sas_phy_linkerror_attr(loss_of_dword_sync_count);
311 sas_phy_linkerror_attr(phy_reset_problem_count);
314 static DECLARE_TRANSPORT_CLASS(sas_phy_class,
315 "sas_phy", NULL, NULL, NULL);
317 static int sas_phy_match(struct attribute_container *cont, struct device *dev)
319 struct Scsi_Host *shost;
320 struct sas_internal *i;
322 if (!scsi_is_sas_phy(dev))
324 shost = dev_to_shost(dev->parent);
326 if (!shost->transportt)
328 if (shost->transportt->host_attrs.ac.class !=
329 &sas_host_class.class)
332 i = to_sas_internal(shost->transportt);
333 return &i->phy_attr_cont.ac == cont;
336 static void sas_phy_release(struct device *dev)
338 struct sas_phy *phy = dev_to_phy(dev);
340 put_device(dev->parent);
345 * sas_phy_alloc -- allocates and initialize a SAS PHY structure
346 * @parent: Parent device
347 * @number: Port number
349 * Allocates an SAS PHY structure. It will be added in the device tree
350 * below the device specified by @parent, which has to be either a Scsi_Host
354 * SAS PHY allocated or %NULL if the allocation failed.
356 struct sas_phy *sas_phy_alloc(struct device *parent, int number)
358 struct Scsi_Host *shost = dev_to_shost(parent);
361 phy = kmalloc(sizeof(*phy), GFP_KERNEL);
364 memset(phy, 0, sizeof(*phy));
368 phy->number = number;
370 device_initialize(&phy->dev);
371 phy->dev.parent = get_device(parent);
372 phy->dev.release = sas_phy_release;
373 sprintf(phy->dev.bus_id, "phy-%d:%d", shost->host_no, number);
375 transport_setup_device(&phy->dev);
379 EXPORT_SYMBOL(sas_phy_alloc);
382 * sas_phy_add -- add a SAS PHY to the device hierachy
383 * @phy: The PHY to be added
385 * Publishes a SAS PHY to the rest of the system.
387 int sas_phy_add(struct sas_phy *phy)
391 error = device_add(&phy->dev);
393 transport_add_device(&phy->dev);
394 transport_configure_device(&phy->dev);
399 EXPORT_SYMBOL(sas_phy_add);
402 * sas_phy_free -- free a SAS PHY
403 * @phy: SAS PHY to free
405 * Frees the specified SAS PHY.
408 * This function must only be called on a PHY that has not
409 * sucessfully been added using sas_phy_add().
411 void sas_phy_free(struct sas_phy *phy)
413 transport_destroy_device(&phy->dev);
414 put_device(phy->dev.parent);
415 put_device(phy->dev.parent);
416 put_device(phy->dev.parent);
419 EXPORT_SYMBOL(sas_phy_free);
422 * sas_phy_delete -- remove SAS PHY
423 * @phy: SAS PHY to remove
425 * Removes the specified SAS PHY. If the SAS PHY has an
426 * associated remote PHY it is removed before.
429 sas_phy_delete(struct sas_phy *phy)
431 struct device *dev = &phy->dev;
434 sas_rphy_delete(phy->rphy);
436 transport_remove_device(dev);
438 transport_destroy_device(dev);
439 put_device(dev->parent);
441 EXPORT_SYMBOL(sas_phy_delete);
444 * scsi_is_sas_phy -- check if a struct device represents a SAS PHY
445 * @dev: device to check
448 * %1 if the device represents a SAS PHY, %0 else
450 int scsi_is_sas_phy(const struct device *dev)
452 return dev->release == sas_phy_release;
454 EXPORT_SYMBOL(scsi_is_sas_phy);
457 * SAS remote PHY attributes.
460 #define sas_rphy_show_simple(field, name, format_string, cast) \
462 show_sas_rphy_##name(struct class_device *cdev, char *buf) \
464 struct sas_rphy *rphy = transport_class_to_rphy(cdev); \
466 return snprintf(buf, 20, format_string, cast rphy->field); \
469 #define sas_rphy_simple_attr(field, name, format_string, type) \
470 sas_rphy_show_simple(field, name, format_string, (type)) \
471 static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \
472 show_sas_rphy_##name, NULL)
474 #define sas_rphy_show_protocol(field, name) \
476 show_sas_rphy_##name(struct class_device *cdev, char *buf) \
478 struct sas_rphy *rphy = transport_class_to_rphy(cdev); \
481 return snprintf(buf, 20, "none\n"); \
482 return get_sas_protocol_names(rphy->field, buf); \
485 #define sas_rphy_protocol_attr(field, name) \
486 sas_rphy_show_protocol(field, name) \
487 static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \
488 show_sas_rphy_##name, NULL)
491 show_sas_rphy_device_type(struct class_device *cdev, char *buf)
493 struct sas_rphy *rphy = transport_class_to_rphy(cdev);
495 if (!rphy->identify.device_type)
496 return snprintf(buf, 20, "none\n");
497 return get_sas_device_type_names(
498 rphy->identify.device_type, buf);
501 static SAS_CLASS_DEVICE_ATTR(rphy, device_type, S_IRUGO,
502 show_sas_rphy_device_type, NULL);
504 sas_rphy_protocol_attr(identify.initiator_port_protocols,
505 initiator_port_protocols);
506 sas_rphy_protocol_attr(identify.target_port_protocols, target_port_protocols);
507 sas_rphy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n",
509 sas_rphy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8);
511 static DECLARE_TRANSPORT_CLASS(sas_rphy_class,
512 "sas_rphy", NULL, NULL, NULL);
514 static int sas_rphy_match(struct attribute_container *cont, struct device *dev)
516 struct Scsi_Host *shost;
517 struct sas_internal *i;
519 if (!scsi_is_sas_rphy(dev))
521 shost = dev_to_shost(dev->parent->parent);
523 if (!shost->transportt)
525 if (shost->transportt->host_attrs.ac.class !=
526 &sas_host_class.class)
529 i = to_sas_internal(shost->transportt);
530 return &i->rphy_attr_cont.ac == cont;
533 static void sas_rphy_release(struct device *dev)
535 struct sas_rphy *rphy = dev_to_rphy(dev);
537 put_device(dev->parent);
542 * sas_rphy_alloc -- allocates and initialize a SAS remote PHY structure
543 * @parent: SAS PHY this remote PHY is conneted to
545 * Allocates an SAS remote PHY structure, connected to @parent.
548 * SAS PHY allocated or %NULL if the allocation failed.
550 struct sas_rphy *sas_rphy_alloc(struct sas_phy *parent)
552 struct Scsi_Host *shost = dev_to_shost(&parent->dev);
553 struct sas_rphy *rphy;
555 rphy = kmalloc(sizeof(*rphy), GFP_KERNEL);
557 put_device(&parent->dev);
560 memset(rphy, 0, sizeof(*rphy));
562 device_initialize(&rphy->dev);
563 rphy->dev.parent = get_device(&parent->dev);
564 rphy->dev.release = sas_rphy_release;
565 sprintf(rphy->dev.bus_id, "rphy-%d:%d",
566 shost->host_no, parent->number);
567 transport_setup_device(&rphy->dev);
571 EXPORT_SYMBOL(sas_rphy_alloc);
574 * sas_rphy_add -- add a SAS remote PHY to the device hierachy
575 * @rphy: The remote PHY to be added
577 * Publishes a SAS remote PHY to the rest of the system.
579 int sas_rphy_add(struct sas_rphy *rphy)
581 struct sas_phy *parent = dev_to_phy(rphy->dev.parent);
582 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
583 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
584 struct sas_identify *identify = &rphy->identify;
591 error = device_add(&rphy->dev);
594 transport_add_device(&rphy->dev);
595 transport_configure_device(&rphy->dev);
597 spin_lock(&sas_host->lock);
598 list_add_tail(&rphy->list, &sas_host->rphy_list);
599 if (identify->device_type == SAS_END_DEVICE &&
600 (identify->target_port_protocols &
601 (SAS_PROTOCOL_SSP|SAS_PROTOCOL_STP|SAS_PROTOCOL_SATA)))
602 rphy->scsi_target_id = sas_host->next_target_id++;
604 rphy->scsi_target_id = -1;
605 spin_unlock(&sas_host->lock);
607 if (rphy->scsi_target_id != -1) {
608 scsi_scan_target(&rphy->dev, parent->number,
609 rphy->scsi_target_id, ~0, 0);
614 EXPORT_SYMBOL(sas_rphy_add);
617 * sas_rphy_free -- free a SAS remote PHY
618 * @rphy SAS remote PHY to free
620 * Frees the specified SAS remote PHY.
623 * This function must only be called on a remote
624 * PHY that has not sucessfully been added using
627 void sas_rphy_free(struct sas_rphy *rphy)
629 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent);
630 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
632 spin_lock(&sas_host->lock);
633 list_del(&rphy->list);
634 spin_unlock(&sas_host->lock);
636 transport_destroy_device(&rphy->dev);
637 put_device(rphy->dev.parent);
638 put_device(rphy->dev.parent);
639 put_device(rphy->dev.parent);
642 EXPORT_SYMBOL(sas_rphy_free);
645 * sas_rphy_delete -- remove SAS remote PHY
646 * @rphy: SAS remote PHY to remove
648 * Removes the specified SAS remote PHY.
651 sas_rphy_delete(struct sas_rphy *rphy)
653 struct device *dev = &rphy->dev;
654 struct sas_phy *parent = dev_to_phy(dev->parent);
655 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
656 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
658 scsi_remove_target(dev);
660 transport_remove_device(dev);
662 transport_destroy_device(dev);
664 spin_lock(&sas_host->lock);
665 list_del(&rphy->list);
666 spin_unlock(&sas_host->lock);
668 put_device(&parent->dev);
670 EXPORT_SYMBOL(sas_rphy_delete);
673 * scsi_is_sas_rphy -- check if a struct device represents a SAS remote PHY
674 * @dev: device to check
677 * %1 if the device represents a SAS remote PHY, %0 else
679 int scsi_is_sas_rphy(const struct device *dev)
681 return dev->release == sas_rphy_release;
683 EXPORT_SYMBOL(scsi_is_sas_rphy);
690 static struct device *sas_target_parent(struct Scsi_Host *shost,
691 int channel, uint id)
693 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
694 struct sas_rphy *rphy;
695 struct device *dev = NULL;
697 spin_lock(&sas_host->lock);
698 list_for_each_entry(rphy, &sas_host->rphy_list, list) {
699 struct sas_phy *parent = dev_to_phy(rphy->dev.parent);
700 if (parent->number == channel &&
701 rphy->scsi_target_id == id)
704 spin_unlock(&sas_host->lock);
711 * Setup / Teardown code
714 #define SETUP_RPORT_ATTRIBUTE(field) \
715 i->private_rphy_attrs[count] = class_device_attr_##field; \
716 i->private_rphy_attrs[count].attr.mode = S_IRUGO; \
717 i->private_rphy_attrs[count].store = NULL; \
718 i->rphy_attrs[count] = &i->private_rphy_attrs[count]; \
721 #define SETUP_PORT_ATTRIBUTE(field) \
722 i->private_phy_attrs[count] = class_device_attr_##field; \
723 i->private_phy_attrs[count].attr.mode = S_IRUGO; \
724 i->private_phy_attrs[count].store = NULL; \
725 i->phy_attrs[count] = &i->private_phy_attrs[count]; \
730 * sas_attach_transport -- instantiate SAS transport template
731 * @ft: SAS transport class function template
733 struct scsi_transport_template *
734 sas_attach_transport(struct sas_function_template *ft)
736 struct sas_internal *i;
739 i = kmalloc(sizeof(struct sas_internal), GFP_KERNEL);
742 memset(i, 0, sizeof(struct sas_internal));
744 i->t.target_parent = sas_target_parent;
746 i->t.host_attrs.ac.attrs = &i->host_attrs[0];
747 i->t.host_attrs.ac.class = &sas_host_class.class;
748 i->t.host_attrs.ac.match = sas_host_match;
749 transport_container_register(&i->t.host_attrs);
750 i->t.host_size = sizeof(struct sas_host_attrs);
752 i->phy_attr_cont.ac.class = &sas_phy_class.class;
753 i->phy_attr_cont.ac.attrs = &i->phy_attrs[0];
754 i->phy_attr_cont.ac.match = sas_phy_match;
755 transport_container_register(&i->phy_attr_cont);
757 i->rphy_attr_cont.ac.class = &sas_rphy_class.class;
758 i->rphy_attr_cont.ac.attrs = &i->rphy_attrs[0];
759 i->rphy_attr_cont.ac.match = sas_rphy_match;
760 transport_container_register(&i->rphy_attr_cont);
765 i->host_attrs[count] = NULL;
768 SETUP_PORT_ATTRIBUTE(initiator_port_protocols);
769 SETUP_PORT_ATTRIBUTE(target_port_protocols);
770 SETUP_PORT_ATTRIBUTE(device_type);
771 SETUP_PORT_ATTRIBUTE(sas_address);
772 SETUP_PORT_ATTRIBUTE(phy_identifier);
773 SETUP_PORT_ATTRIBUTE(port_identifier);
774 SETUP_PORT_ATTRIBUTE(negotiated_linkrate);
775 SETUP_PORT_ATTRIBUTE(minimum_linkrate_hw);
776 SETUP_PORT_ATTRIBUTE(minimum_linkrate);
777 SETUP_PORT_ATTRIBUTE(maximum_linkrate_hw);
778 SETUP_PORT_ATTRIBUTE(maximum_linkrate);
780 SETUP_PORT_ATTRIBUTE(invalid_dword_count);
781 SETUP_PORT_ATTRIBUTE(running_disparity_error_count);
782 SETUP_PORT_ATTRIBUTE(loss_of_dword_sync_count);
783 SETUP_PORT_ATTRIBUTE(phy_reset_problem_count);
784 i->phy_attrs[count] = NULL;
787 SETUP_RPORT_ATTRIBUTE(rphy_initiator_port_protocols);
788 SETUP_RPORT_ATTRIBUTE(rphy_target_port_protocols);
789 SETUP_RPORT_ATTRIBUTE(rphy_device_type);
790 SETUP_RPORT_ATTRIBUTE(rphy_sas_address);
791 SETUP_RPORT_ATTRIBUTE(rphy_phy_identifier);
792 i->rphy_attrs[count] = NULL;
796 EXPORT_SYMBOL(sas_attach_transport);
799 * sas_release_transport -- release SAS transport template instance
800 * @t: transport template instance
802 void sas_release_transport(struct scsi_transport_template *t)
804 struct sas_internal *i = to_sas_internal(t);
806 transport_container_unregister(&i->t.host_attrs);
807 transport_container_unregister(&i->phy_attr_cont);
808 transport_container_unregister(&i->rphy_attr_cont);
812 EXPORT_SYMBOL(sas_release_transport);
814 static __init int sas_transport_init(void)
818 error = transport_class_register(&sas_host_class);
821 error = transport_class_register(&sas_phy_class);
823 goto out_unregister_transport;
824 error = transport_class_register(&sas_rphy_class);
826 goto out_unregister_phy;
831 transport_class_unregister(&sas_phy_class);
832 out_unregister_transport:
833 transport_class_unregister(&sas_host_class);
839 static void __exit sas_transport_exit(void)
841 transport_class_unregister(&sas_host_class);
842 transport_class_unregister(&sas_phy_class);
843 transport_class_unregister(&sas_rphy_class);
846 MODULE_AUTHOR("Christoph Hellwig");
847 MODULE_DESCRIPTION("SAS Transphy Attributes");
848 MODULE_LICENSE("GPL");
850 module_init(sas_transport_init);
851 module_exit(sas_transport_exit);