Lines Matching +full:port +full:- +full:expander

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2005-2006 Dell Inc.
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
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.
51 #define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data)
100 return -EINVAL; \
127 { SAS_EDGE_EXPANDER_DEVICE, "edge expander" },
128 { SAS_FANOUT_EXPANDER_DEVICE, "fanout expander" },
151 { SAS_SATA_SPINUP_HOLD, "Spin-up hold" },
163 struct sas_rphy *rphy = target_to_rphy(sdev->sdev_target); in sas_bitfield_name_search()
166 BUG_ON(rphy->identify.device_type != SAS_END_DEVICE); in sas_bitfield_name_search()
174 struct Scsi_Host *shost = dev_to_shost(job->dev); in sas_smp_dispatch()
177 if (!scsi_is_host_device(job->dev)) in sas_smp_dispatch()
178 rphy = dev_to_rphy(job->dev); in sas_smp_dispatch()
180 if (!job->reply_payload.payload_len) { in sas_smp_dispatch()
181 dev_warn(job->dev, "space for a smp response is missing\n"); in sas_smp_dispatch()
182 bsg_job_done(job, -EINVAL, 0); in sas_smp_dispatch()
186 to_sas_internal(shost->transportt)->f->smp_handler(job, shost, rphy); in sas_smp_dispatch()
194 if (!to_sas_internal(shost->transportt)->f->smp_handler) { in sas_bsg_initialize()
195 printk("%s can't handle SMP requests\n", shost->hostt->name); in sas_bsg_initialize()
200 q = bsg_setup_queue(&rphy->dev, dev_name(&rphy->dev), NULL, in sas_bsg_initialize()
204 rphy->q = q; in sas_bsg_initialize()
208 snprintf(name, sizeof(name), "sas_host%d", shost->host_no); in sas_bsg_initialize()
209 q = bsg_setup_queue(&shost->shost_gendev, name, NULL, in sas_bsg_initialize()
213 to_sas_host_attrs(shost)->q = q; in sas_bsg_initialize()
228 struct device *dma_dev = shost->dma_dev; in sas_host_setup()
230 INIT_LIST_HEAD(&sas_host->rphy_list); in sas_host_setup()
231 mutex_init(&sas_host->lock); in sas_host_setup()
232 sas_host->next_target_id = 0; in sas_host_setup()
233 sas_host->next_expander_id = 0; in sas_host_setup()
234 sas_host->next_port_id = 0; in sas_host_setup()
238 shost->host_no); in sas_host_setup()
240 if (dma_dev->dma_mask) { in sas_host_setup()
241 shost->opt_sectors = min_t(unsigned int, shost->max_sectors, in sas_host_setup()
252 struct request_queue *q = to_sas_host_attrs(shost)->q; in sas_host_remove()
271 if (!shost->transportt) in sas_host_match()
273 if (shost->transportt->host_attrs.ac.class != in sas_host_match()
277 i = to_sas_internal(shost->transportt); in sas_host_match()
278 return &i->t.host_attrs.ac == cont; in sas_host_match()
293 * sas_remove_children - tear down a devices SAS data structures
306 * sas_remove_host - tear down a Scsi_Host's SAS data structures
317 sas_remove_children(&shost->shost_gendev); in sas_remove_host()
323 * sas_get_address - return the SAS address of the device
332 return rdev->rphy.identify.sas_address; in sas_get_address()
337 * sas_tlr_supported - checking TLR bit in vpd 0x90
360 * has a 4 byte header and then one entry per device port in sas_tlr_supported()
361 * the TLR bit is at offset 8 on each port entry in sas_tlr_supported()
362 * if we take the first port, that's at total offset 12 in sas_tlr_supported()
368 rdev->tlr_supported = ret; in sas_tlr_supported()
375 * sas_disable_tlr - setting TLR flags
386 rdev->tlr_enabled = 0; in sas_disable_tlr()
391 * sas_enable_tlr - setting TLR flags
405 rdev->tlr_enabled = 1; in sas_enable_tlr()
415 return rdev->tlr_enabled; in sas_is_tlr_enabled()
420 * sas_ata_ncq_prio_supported - Check for ATA NCQ command priority support
433 vpd = rcu_dereference(sdev->vpd_pg89); in sas_ata_ncq_prio_supported()
434 if (vpd && vpd->len >= 214) in sas_ata_ncq_prio_supported()
435 ncq_prio_supported = (vpd->data[213] >> 4) & 1; in sas_ata_ncq_prio_supported()
453 return snprintf(buf, 20, format_string, cast phy->field); \
467 if (!phy->field) \
469 return get_sas_protocol_names(phy->field, buf); \
483 return get_sas_linkspeed_names(phy->field, buf); \
494 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \
495 struct sas_internal *i = to_sas_internal(shost->transportt); \
504 error = i->f->set_phy_speed(phy, &rates); \
526 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \
527 struct sas_internal *i = to_sas_internal(shost->transportt); \
530 error = i->f->get_linkerrors ? i->f->get_linkerrors(phy) : 0; \
533 return snprintf(buf, 20, "%u\n", phy->field); \
547 if (!phy->identify.device_type) in show_sas_device_type()
549 return get_sas_device_type_names(phy->identify.device_type, buf); in show_sas_device_type()
557 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); in do_sas_phy_enable()
558 struct sas_internal *i = to_sas_internal(shost->transportt); in do_sas_phy_enable()
561 error = i->f->phy_enable(phy, enable); in do_sas_phy_enable()
564 phy->enabled = enable; in do_sas_phy_enable()
573 return -EINVAL; in store_sas_phy_enable()
583 return -EINVAL; in store_sas_phy_enable()
595 return snprintf(buf, 20, "%d\n", phy->enabled); in show_sas_phy_enable()
605 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); in do_sas_phy_reset()
606 struct sas_internal *i = to_sas_internal(shost->transportt); in do_sas_phy_reset()
609 error = i->f->phy_reset(phy, hard_reset); in do_sas_phy_reset()
612 phy->enabled = 1; in do_sas_phy_reset()
653 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); in sas_phy_setup()
654 struct sas_internal *i = to_sas_internal(shost->transportt); in sas_phy_setup()
656 if (i->f->phy_setup) in sas_phy_setup()
657 i->f->phy_setup(phy); in sas_phy_setup()
672 shost = dev_to_shost(dev->parent); in sas_phy_match()
674 if (!shost->transportt) in sas_phy_match()
676 if (shost->transportt->host_attrs.ac.class != in sas_phy_match()
680 i = to_sas_internal(shost->transportt); in sas_phy_match()
681 return &i->phy_attr_cont.ac == cont; in sas_phy_match()
687 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); in sas_phy_release()
688 struct sas_internal *i = to_sas_internal(shost->transportt); in sas_phy_release()
690 if (i->f->phy_release) in sas_phy_release()
691 i->f->phy_release(phy); in sas_phy_release()
692 put_device(dev->parent); in sas_phy_release()
697 * sas_phy_alloc - allocates and initialize a SAS PHY structure
717 phy->number = number; in sas_phy_alloc()
718 phy->enabled = 1; in sas_phy_alloc()
720 device_initialize(&phy->dev); in sas_phy_alloc()
721 phy->dev.parent = get_device(parent); in sas_phy_alloc()
722 phy->dev.release = sas_phy_release; in sas_phy_alloc()
723 INIT_LIST_HEAD(&phy->port_siblings); in sas_phy_alloc()
726 dev_set_name(&phy->dev, "phy-%d:%d:%d", shost->host_no, in sas_phy_alloc()
727 rphy->scsi_target_id, number); in sas_phy_alloc()
729 dev_set_name(&phy->dev, "phy-%d:%d", shost->host_no, number); in sas_phy_alloc()
731 transport_setup_device(&phy->dev); in sas_phy_alloc()
738 * sas_phy_add - add a SAS PHY to the device hierarchy
747 error = device_add(&phy->dev); in sas_phy_add()
751 error = transport_add_device(&phy->dev); in sas_phy_add()
753 device_del(&phy->dev); in sas_phy_add()
756 transport_configure_device(&phy->dev); in sas_phy_add()
763 * sas_phy_free - free a SAS PHY
774 transport_destroy_device(&phy->dev); in sas_phy_free()
775 put_device(&phy->dev); in sas_phy_free()
780 * sas_phy_delete - remove SAS PHY
789 struct device *dev = &phy->dev; in sas_phy_delete()
791 /* this happens if the phy is still part of a port when deleted */ in sas_phy_delete()
792 BUG_ON(!list_empty(&phy->port_siblings)); in sas_phy_delete()
802 * scsi_is_sas_phy - check if a struct device represents a SAS PHY
810 return dev->release == sas_phy_release; in scsi_is_sas_phy()
815 * SAS Port attributes
822 struct sas_port *port = transport_class_to_sas_port(dev); \
824 return snprintf(buf, 20, format_string, cast port->field); \
843 shost = dev_to_shost(dev->parent); in sas_port_match()
845 if (!shost->transportt) in sas_port_match()
847 if (shost->transportt->host_attrs.ac.class != in sas_port_match()
851 i = to_sas_internal(shost->transportt); in sas_port_match()
852 return &i->port_attr_cont.ac == cont; in sas_port_match()
858 struct sas_port *port = dev_to_sas_port(dev); in sas_port_release() local
860 BUG_ON(!list_empty(&port->phy_list)); in sas_port_release()
862 put_device(dev->parent); in sas_port_release()
863 kfree(port); in sas_port_release()
866 static void sas_port_create_link(struct sas_port *port, in sas_port_create_link() argument
871 res = sysfs_create_link(&port->dev.kobj, &phy->dev.kobj, in sas_port_create_link()
872 dev_name(&phy->dev)); in sas_port_create_link()
875 res = sysfs_create_link(&phy->dev.kobj, &port->dev.kobj, "port"); in sas_port_create_link()
880 printk(KERN_ERR "%s: Cannot create port links, err=%d\n", in sas_port_create_link()
884 static void sas_port_delete_link(struct sas_port *port, in sas_port_delete_link() argument
887 sysfs_remove_link(&port->dev.kobj, dev_name(&phy->dev)); in sas_port_delete_link()
888 sysfs_remove_link(&phy->dev.kobj, "port"); in sas_port_delete_link()
891 /** sas_port_alloc - allocate and initialize a SAS port structure
894 * @port_id: port number
896 * Allocates a SAS port structure. It will be added to the device tree
905 struct sas_port *port; in sas_port_alloc() local
907 port = kzalloc(sizeof(*port), GFP_KERNEL); in sas_port_alloc()
908 if (!port) in sas_port_alloc()
911 port->port_identifier = port_id; in sas_port_alloc()
913 device_initialize(&port->dev); in sas_port_alloc()
915 port->dev.parent = get_device(parent); in sas_port_alloc()
916 port->dev.release = sas_port_release; in sas_port_alloc()
918 mutex_init(&port->phy_list_mutex); in sas_port_alloc()
919 INIT_LIST_HEAD(&port->phy_list); in sas_port_alloc()
923 dev_set_name(&port->dev, "port-%d:%d:%d", shost->host_no, in sas_port_alloc()
924 rphy->scsi_target_id, port->port_identifier); in sas_port_alloc()
926 dev_set_name(&port->dev, "port-%d:%d", shost->host_no, in sas_port_alloc()
927 port->port_identifier); in sas_port_alloc()
929 transport_setup_device(&port->dev); in sas_port_alloc()
931 return port; in sas_port_alloc()
935 /** sas_port_alloc_num - allocate and initialize a SAS port structure
939 * Allocates a SAS port structure and a number to go with it. This
940 * interface is really for adapters where the port number has no
954 mutex_lock(&sas_host->lock); in sas_port_alloc_num()
959 index = exp->next_port_id++; in sas_port_alloc_num()
961 index = sas_host->next_port_id++; in sas_port_alloc_num()
962 mutex_unlock(&sas_host->lock); in sas_port_alloc_num()
968 * sas_port_add - add a SAS port to the device hierarchy
969 * @port: port to be added
971 * publishes a port to the rest of the system
973 int sas_port_add(struct sas_port *port) in sas_port_add() argument
978 BUG_ON(!list_empty(&port->phy_list)); in sas_port_add()
980 error = device_add(&port->dev); in sas_port_add()
985 transport_add_device(&port->dev); in sas_port_add()
986 transport_configure_device(&port->dev); in sas_port_add()
993 * sas_port_free - free a SAS PORT
994 * @port: SAS PORT to free
996 * Frees the specified SAS PORT.
999 * This function must only be called on a PORT that has not
1002 void sas_port_free(struct sas_port *port) in sas_port_free() argument
1004 transport_destroy_device(&port->dev); in sas_port_free()
1005 put_device(&port->dev); in sas_port_free()
1010 * sas_port_delete - remove SAS PORT
1011 * @port: SAS PORT to remove
1013 * Removes the specified SAS PORT. If the SAS PORT has an
1014 * associated phys, unlink them from the port as well.
1016 void sas_port_delete(struct sas_port *port) in sas_port_delete() argument
1018 struct device *dev = &port->dev; in sas_port_delete()
1021 if (port->rphy) { in sas_port_delete()
1022 sas_rphy_delete(port->rphy); in sas_port_delete()
1023 port->rphy = NULL; in sas_port_delete()
1026 mutex_lock(&port->phy_list_mutex); in sas_port_delete()
1027 list_for_each_entry_safe(phy, tmp_phy, &port->phy_list, in sas_port_delete()
1029 sas_port_delete_link(port, phy); in sas_port_delete()
1030 list_del_init(&phy->port_siblings); in sas_port_delete()
1032 mutex_unlock(&port->phy_list_mutex); in sas_port_delete()
1034 if (port->is_backlink) { in sas_port_delete()
1035 struct device *parent = port->dev.parent; in sas_port_delete()
1037 sysfs_remove_link(&port->dev.kobj, dev_name(parent)); in sas_port_delete()
1038 port->is_backlink = 0; in sas_port_delete()
1049 * scsi_is_sas_port - check if a struct device represents a SAS port
1053 * %1 if the device represents a SAS Port, %0 else
1057 return dev->release == sas_port_release; in scsi_is_sas_port()
1062 * sas_port_get_phy - try to take a reference on a port member
1063 * @port: port to check
1065 struct sas_phy *sas_port_get_phy(struct sas_port *port) in sas_port_get_phy() argument
1069 mutex_lock(&port->phy_list_mutex); in sas_port_get_phy()
1070 if (list_empty(&port->phy_list)) in sas_port_get_phy()
1073 struct list_head *ent = port->phy_list.next; in sas_port_get_phy()
1076 get_device(&phy->dev); in sas_port_get_phy()
1078 mutex_unlock(&port->phy_list_mutex); in sas_port_get_phy()
1085 * sas_port_add_phy - add another phy to a port to form a wide port
1086 * @port: port to add the phy to
1089 * When a port is initially created, it is empty (has no phys). All
1093 * connected to a remote device is a port, so ports must be formed on
1096 void sas_port_add_phy(struct sas_port *port, struct sas_phy *phy) in sas_port_add_phy() argument
1098 mutex_lock(&port->phy_list_mutex); in sas_port_add_phy()
1099 if (unlikely(!list_empty(&phy->port_siblings))) { in sas_port_add_phy()
1100 /* make sure we're already on this port */ in sas_port_add_phy()
1103 list_for_each_entry(tmp, &port->phy_list, port_siblings) in sas_port_add_phy()
1107 * part of a different port */ in sas_port_add_phy()
1109 …dev_printk(KERN_ERR, &port->dev, "trying to add phy %s fails: it's already part of another port\n", in sas_port_add_phy()
1110 dev_name(&phy->dev)); in sas_port_add_phy()
1114 sas_port_create_link(port, phy); in sas_port_add_phy()
1115 list_add_tail(&phy->port_siblings, &port->phy_list); in sas_port_add_phy()
1116 port->num_phys++; in sas_port_add_phy()
1118 mutex_unlock(&port->phy_list_mutex); in sas_port_add_phy()
1123 * sas_port_delete_phy - remove a phy from a port or wide port
1124 * @port: port to remove the phy from
1128 * done to every port or wide port before calling sas_port_delete.
1130 void sas_port_delete_phy(struct sas_port *port, struct sas_phy *phy) in sas_port_delete_phy() argument
1132 mutex_lock(&port->phy_list_mutex); in sas_port_delete_phy()
1133 sas_port_delete_link(port, phy); in sas_port_delete_phy()
1134 list_del_init(&phy->port_siblings); in sas_port_delete_phy()
1135 port->num_phys--; in sas_port_delete_phy()
1136 mutex_unlock(&port->phy_list_mutex); in sas_port_delete_phy()
1140 void sas_port_mark_backlink(struct sas_port *port) in sas_port_mark_backlink() argument
1143 struct device *parent = port->dev.parent->parent->parent; in sas_port_mark_backlink()
1145 if (port->is_backlink) in sas_port_mark_backlink()
1147 port->is_backlink = 1; in sas_port_mark_backlink()
1148 res = sysfs_create_link(&port->dev.kobj, &parent->kobj, in sas_port_mark_backlink()
1154 printk(KERN_ERR "%s: Cannot create port backlink, err=%d\n", in sas_port_mark_backlink()
1171 return snprintf(buf, 20, format_string, cast rphy->field); \
1186 if (!rphy->field) \
1188 return get_sas_protocol_names(rphy->field, buf); \
1202 if (!rphy->identify.device_type) in show_sas_rphy_device_type()
1205 rphy->identify.device_type, buf); in show_sas_rphy_device_type()
1216 struct sas_phy *phy = dev_to_phy(rphy->dev.parent); in show_sas_rphy_enclosure_identifier()
1217 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); in show_sas_rphy_enclosure_identifier()
1218 struct sas_internal *i = to_sas_internal(shost->transportt); in show_sas_rphy_enclosure_identifier()
1222 error = i->f->get_enclosure_identifier(rphy, &identifier); in show_sas_rphy_enclosure_identifier()
1236 struct sas_phy *phy = dev_to_phy(rphy->dev.parent); in show_sas_rphy_bay_identifier()
1237 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); in show_sas_rphy_bay_identifier()
1238 struct sas_internal *i = to_sas_internal(shost->transportt); in show_sas_rphy_bay_identifier()
1241 val = i->f->get_bay_identifier(rphy); in show_sas_rphy_bay_identifier()
1269 return -ENOMEM; in sas_read_port_mode_page()
1280 if (msdata - buffer > BUF_SIZE - 8) in sas_read_port_mode_page()
1285 rdev->ready_led_meaning = msdata[2] & 0x10 ? 1 : 0; in sas_read_port_mode_page()
1286 rdev->I_T_nexus_loss_timeout = (msdata[4] << 8) + msdata[5]; in sas_read_port_mode_page()
1287 rdev->initiator_response_timeout = (msdata[6] << 8) + msdata[7]; in sas_read_port_mode_page()
1306 return snprintf(buf, 20, format_string, cast rdev->field); \
1335 return snprintf(buf, 20, format_string, cast edev->field); \
1340 static SAS_DEVICE_ATTR(expander, name, S_IRUGO, \
1363 shost = dev_to_shost(dev->parent->parent); in sas_rphy_match()
1365 if (!shost->transportt) in sas_rphy_match()
1367 if (shost->transportt->host_attrs.ac.class != in sas_rphy_match()
1371 i = to_sas_internal(shost->transportt); in sas_rphy_match()
1372 return &i->rphy_attr_cont.ac == cont; in sas_rphy_match()
1384 shost = dev_to_shost(dev->parent->parent); in sas_end_dev_match()
1387 if (!shost->transportt) in sas_end_dev_match()
1389 if (shost->transportt->host_attrs.ac.class != in sas_end_dev_match()
1393 i = to_sas_internal(shost->transportt); in sas_end_dev_match()
1394 return &i->end_dev_attr_cont.ac == cont && in sas_end_dev_match()
1395 rphy->identify.device_type == SAS_END_DEVICE; in sas_end_dev_match()
1407 shost = dev_to_shost(dev->parent->parent); in sas_expander_match()
1410 if (!shost->transportt) in sas_expander_match()
1412 if (shost->transportt->host_attrs.ac.class != in sas_expander_match()
1416 i = to_sas_internal(shost->transportt); in sas_expander_match()
1417 return &i->expander_attr_cont.ac == cont && in sas_expander_match()
1418 (rphy->identify.device_type == SAS_EDGE_EXPANDER_DEVICE || in sas_expander_match()
1419 rphy->identify.device_type == SAS_FANOUT_EXPANDER_DEVICE); in sas_expander_match()
1427 put_device(dev->parent); in sas_expander_release()
1436 put_device(dev->parent); in sas_end_device_release()
1441 * sas_rphy_initialize - common rphy initialization
1449 INIT_LIST_HEAD(&rphy->list); in sas_rphy_initialize()
1453 * sas_end_device_alloc - allocate an rphy for an end device
1454 * @parent: which port
1463 struct Scsi_Host *shost = dev_to_shost(&parent->dev); in sas_end_device_alloc()
1471 device_initialize(&rdev->rphy.dev); in sas_end_device_alloc()
1472 rdev->rphy.dev.parent = get_device(&parent->dev); in sas_end_device_alloc()
1473 rdev->rphy.dev.release = sas_end_device_release; in sas_end_device_alloc()
1474 if (scsi_is_sas_expander_device(parent->dev.parent)) { in sas_end_device_alloc()
1475 struct sas_rphy *rphy = dev_to_rphy(parent->dev.parent); in sas_end_device_alloc()
1476 dev_set_name(&rdev->rphy.dev, "end_device-%d:%d:%d", in sas_end_device_alloc()
1477 shost->host_no, rphy->scsi_target_id, in sas_end_device_alloc()
1478 parent->port_identifier); in sas_end_device_alloc()
1480 dev_set_name(&rdev->rphy.dev, "end_device-%d:%d", in sas_end_device_alloc()
1481 shost->host_no, parent->port_identifier); in sas_end_device_alloc()
1482 rdev->rphy.identify.device_type = SAS_END_DEVICE; in sas_end_device_alloc()
1483 sas_rphy_initialize(&rdev->rphy); in sas_end_device_alloc()
1484 transport_setup_device(&rdev->rphy.dev); in sas_end_device_alloc()
1486 return &rdev->rphy; in sas_end_device_alloc()
1491 * sas_expander_alloc - allocate an rphy for an end device
1492 * @parent: which port
1503 struct Scsi_Host *shost = dev_to_shost(&parent->dev); in sas_expander_alloc()
1515 device_initialize(&rdev->rphy.dev); in sas_expander_alloc()
1516 rdev->rphy.dev.parent = get_device(&parent->dev); in sas_expander_alloc()
1517 rdev->rphy.dev.release = sas_expander_release; in sas_expander_alloc()
1518 mutex_lock(&sas_host->lock); in sas_expander_alloc()
1519 rdev->rphy.scsi_target_id = sas_host->next_expander_id++; in sas_expander_alloc()
1520 mutex_unlock(&sas_host->lock); in sas_expander_alloc()
1521 dev_set_name(&rdev->rphy.dev, "expander-%d:%d", in sas_expander_alloc()
1522 shost->host_no, rdev->rphy.scsi_target_id); in sas_expander_alloc()
1523 rdev->rphy.identify.device_type = type; in sas_expander_alloc()
1524 sas_rphy_initialize(&rdev->rphy); in sas_expander_alloc()
1525 transport_setup_device(&rdev->rphy.dev); in sas_expander_alloc()
1527 return &rdev->rphy; in sas_expander_alloc()
1532 * sas_rphy_add - add a SAS remote PHY to the device hierarchy
1539 struct sas_port *parent = dev_to_sas_port(rphy->dev.parent); in sas_rphy_add()
1540 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent); in sas_rphy_add()
1542 struct sas_identify *identify = &rphy->identify; in sas_rphy_add()
1545 if (parent->rphy) in sas_rphy_add()
1546 return -ENXIO; in sas_rphy_add()
1547 parent->rphy = rphy; in sas_rphy_add()
1549 error = device_add(&rphy->dev); in sas_rphy_add()
1552 transport_add_device(&rphy->dev); in sas_rphy_add()
1553 transport_configure_device(&rphy->dev); in sas_rphy_add()
1555 printk("fail to a bsg device %s\n", dev_name(&rphy->dev)); in sas_rphy_add()
1558 mutex_lock(&sas_host->lock); in sas_rphy_add()
1559 list_add_tail(&rphy->list, &sas_host->rphy_list); in sas_rphy_add()
1560 if (identify->device_type == SAS_END_DEVICE && in sas_rphy_add()
1561 (identify->target_port_protocols & in sas_rphy_add()
1563 rphy->scsi_target_id = sas_host->next_target_id++; in sas_rphy_add()
1564 else if (identify->device_type == SAS_END_DEVICE) in sas_rphy_add()
1565 rphy->scsi_target_id = -1; in sas_rphy_add()
1566 mutex_unlock(&sas_host->lock); in sas_rphy_add()
1568 if (identify->device_type == SAS_END_DEVICE && in sas_rphy_add()
1569 rphy->scsi_target_id != -1) { in sas_rphy_add()
1572 if (identify->target_port_protocols & SAS_PROTOCOL_SSP) in sas_rphy_add()
1577 scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, lun, in sas_rphy_add()
1586 * sas_rphy_free - free a SAS remote PHY
1598 struct device *dev = &rphy->dev; in sas_rphy_free()
1599 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent); in sas_rphy_free()
1602 mutex_lock(&sas_host->lock); in sas_rphy_free()
1603 list_del(&rphy->list); in sas_rphy_free()
1604 mutex_unlock(&sas_host->lock); in sas_rphy_free()
1613 * sas_rphy_delete - remove and free SAS remote PHY
1627 * sas_rphy_unlink - unlink SAS remote PHY
1628 * @rphy: SAS remote phy to unlink from its parent port
1630 * Removes port reference to an rphy
1634 struct sas_port *parent = dev_to_sas_port(rphy->dev.parent); in sas_rphy_unlink()
1636 parent->rphy = NULL; in sas_rphy_unlink()
1641 * sas_rphy_remove - remove SAS remote PHY
1649 struct device *dev = &rphy->dev; in sas_rphy_remove()
1651 switch (rphy->identify.device_type) { in sas_rphy_remove()
1664 bsg_remove_queue(rphy->q); in sas_rphy_remove()
1671 * scsi_is_sas_rphy - check if a struct device represents a SAS remote PHY
1679 return dev->release == sas_end_device_release || in scsi_is_sas_rphy()
1680 dev->release == sas_expander_release; in scsi_is_sas_rphy()
1695 mutex_lock(&sas_host->lock); in sas_user_scan()
1696 list_for_each_entry(rphy, &sas_host->rphy_list, list) { in sas_user_scan()
1697 if (rphy->identify.device_type != SAS_END_DEVICE || in sas_user_scan()
1698 rphy->scsi_target_id == -1) in sas_user_scan()
1702 (id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) { in sas_user_scan()
1703 scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, in sas_user_scan()
1707 mutex_unlock(&sas_host->lock); in sas_user_scan()
1718 i->private_##attrb[count] = dev_attr_##field; \
1719 i->private_##attrb[count].attr.mode = perm; \
1720 i->attrb[count] = &i->private_##attrb[count]; \
1725 i->private_##attrb[count] = dev_attr_##field; \
1726 i->private_##attrb[count].attr.mode = perm; \
1728 i->private_##attrb[count].attr.mode = ro_perm; \
1729 i->private_##attrb[count].store = NULL; \
1731 i->attrb[count] = &i->private_##attrb[count]; \
1739 SETUP_TEMPLATE(rphy_attrs, field, S_IRUGO, i->f->func)
1746 !i->f->set_phy_speed, S_IRUGO)
1750 !i->f->func, S_IRUGO)
1756 SETUP_TEMPLATE(phy_attrs, field, S_IRUGO, i->f->func)
1762 SETUP_TEMPLATE(phy_attrs, field, S_IWUSR, i->f->func)
1771 * sas_attach_transport - instantiate SAS transport template
1784 i->t.user_scan = sas_user_scan; in sas_attach_transport()
1786 i->t.host_attrs.ac.attrs = &i->host_attrs[0]; in sas_attach_transport()
1787 i->t.host_attrs.ac.class = &sas_host_class.class; in sas_attach_transport()
1788 i->t.host_attrs.ac.match = sas_host_match; in sas_attach_transport()
1789 transport_container_register(&i->t.host_attrs); in sas_attach_transport()
1790 i->t.host_size = sizeof(struct sas_host_attrs); in sas_attach_transport()
1792 i->phy_attr_cont.ac.class = &sas_phy_class.class; in sas_attach_transport()
1793 i->phy_attr_cont.ac.attrs = &i->phy_attrs[0]; in sas_attach_transport()
1794 i->phy_attr_cont.ac.match = sas_phy_match; in sas_attach_transport()
1795 transport_container_register(&i->phy_attr_cont); in sas_attach_transport()
1797 i->port_attr_cont.ac.class = &sas_port_class.class; in sas_attach_transport()
1798 i->port_attr_cont.ac.attrs = &i->port_attrs[0]; in sas_attach_transport()
1799 i->port_attr_cont.ac.match = sas_port_match; in sas_attach_transport()
1800 transport_container_register(&i->port_attr_cont); in sas_attach_transport()
1802 i->rphy_attr_cont.ac.class = &sas_rphy_class.class; in sas_attach_transport()
1803 i->rphy_attr_cont.ac.attrs = &i->rphy_attrs[0]; in sas_attach_transport()
1804 i->rphy_attr_cont.ac.match = sas_rphy_match; in sas_attach_transport()
1805 transport_container_register(&i->rphy_attr_cont); in sas_attach_transport()
1807 i->end_dev_attr_cont.ac.class = &sas_end_dev_class.class; in sas_attach_transport()
1808 i->end_dev_attr_cont.ac.attrs = &i->end_dev_attrs[0]; in sas_attach_transport()
1809 i->end_dev_attr_cont.ac.match = sas_end_dev_match; in sas_attach_transport()
1810 transport_container_register(&i->end_dev_attr_cont); in sas_attach_transport()
1812 i->expander_attr_cont.ac.class = &sas_expander_class.class; in sas_attach_transport()
1813 i->expander_attr_cont.ac.attrs = &i->expander_attrs[0]; in sas_attach_transport()
1814 i->expander_attr_cont.ac.match = sas_expander_match; in sas_attach_transport()
1815 transport_container_register(&i->expander_attr_cont); in sas_attach_transport()
1817 i->f = ft; in sas_attach_transport()
1838 i->phy_attrs[count] = NULL; in sas_attach_transport()
1842 i->port_attrs[count] = NULL; in sas_attach_transport()
1855 i->rphy_attrs[count] = NULL; in sas_attach_transport()
1863 i->end_dev_attrs[count] = NULL; in sas_attach_transport()
1873 i->expander_attrs[count] = NULL; in sas_attach_transport()
1875 return &i->t; in sas_attach_transport()
1880 * sas_release_transport - release SAS transport template instance
1887 transport_container_unregister(&i->t.host_attrs); in sas_release_transport()
1888 transport_container_unregister(&i->phy_attr_cont); in sas_release_transport()
1889 transport_container_unregister(&i->port_attr_cont); in sas_release_transport()
1890 transport_container_unregister(&i->rphy_attr_cont); in sas_release_transport()
1891 transport_container_unregister(&i->end_dev_attr_cont); in sas_release_transport()
1892 transport_container_unregister(&i->expander_attr_cont); in sas_release_transport()