Lines Matching refs:phy

169 static char sas_route_char(struct domain_device *dev, struct ex_phy *phy)  in sas_route_char()  argument
171 switch (phy->routing_attr) { in sas_route_char()
207 struct ex_phy *phy = &ex->ex_phy[phy_id]; in sas_set_ex_phy() local
209 bool new_phy = !phy->phy; in sas_set_ex_phy()
215 phy->phy = sas_phy_alloc(&rphy->dev, phy_id); in sas_set_ex_phy()
218 BUG_ON(!phy->phy); in sas_set_ex_phy()
223 phy->phy_state = PHY_VACANT; in sas_set_ex_phy()
226 phy->phy_state = PHY_NOT_PRESENT; in sas_set_ex_phy()
229 phy->phy_state = PHY_EMPTY; /* do not know yet */ in sas_set_ex_phy()
234 dev_type = phy->attached_dev_type; in sas_set_ex_phy()
235 linkrate = phy->linkrate; in sas_set_ex_phy()
236 memcpy(sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); in sas_set_ex_phy()
239 if (phy->phy_state == PHY_VACANT) { in sas_set_ex_phy()
240 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); in sas_set_ex_phy()
241 phy->attached_dev_type = SAS_PHY_UNUSED; in sas_set_ex_phy()
243 phy->phy_id = phy_id; in sas_set_ex_phy()
249 phy->attached_dev_type = to_dev_type(dr); in sas_set_ex_phy()
252 phy->phy_id = phy_id; in sas_set_ex_phy()
253 phy->linkrate = dr->linkrate; in sas_set_ex_phy()
254 phy->attached_sata_host = dr->attached_sata_host; in sas_set_ex_phy()
255 phy->attached_sata_dev = dr->attached_sata_dev; in sas_set_ex_phy()
256 phy->attached_sata_ps = dr->attached_sata_ps; in sas_set_ex_phy()
257 phy->attached_iproto = dr->iproto << 1; in sas_set_ex_phy()
258 phy->attached_tproto = dr->tproto << 1; in sas_set_ex_phy()
262 if (phy->attached_dev_type == SAS_PHY_UNUSED || in sas_set_ex_phy()
263 phy->linkrate < SAS_LINK_RATE_1_5_GBPS) in sas_set_ex_phy()
264 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); in sas_set_ex_phy()
266 memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE); in sas_set_ex_phy()
267 phy->attached_phy_id = dr->attached_phy_id; in sas_set_ex_phy()
268 phy->phy_change_count = dr->change_count; in sas_set_ex_phy()
269 phy->routing_attr = dr->routing_attr; in sas_set_ex_phy()
270 phy->virtual = dr->virtual; in sas_set_ex_phy()
271 phy->last_da_index = -1; in sas_set_ex_phy()
273 phy->phy->identify.sas_address = SAS_ADDR(phy->attached_sas_addr); in sas_set_ex_phy()
274 phy->phy->identify.device_type = dr->attached_dev_type; in sas_set_ex_phy()
275 phy->phy->identify.initiator_port_protocols = phy->attached_iproto; in sas_set_ex_phy()
276 phy->phy->identify.target_port_protocols = phy->attached_tproto; in sas_set_ex_phy()
277 if (!phy->attached_tproto && dr->attached_sata_dev) in sas_set_ex_phy()
278 phy->phy->identify.target_port_protocols = SAS_PROTOCOL_SATA; in sas_set_ex_phy()
279 phy->phy->identify.phy_identifier = phy_id; in sas_set_ex_phy()
280 phy->phy->minimum_linkrate_hw = dr->hmin_linkrate; in sas_set_ex_phy()
281 phy->phy->maximum_linkrate_hw = dr->hmax_linkrate; in sas_set_ex_phy()
282 phy->phy->minimum_linkrate = dr->pmin_linkrate; in sas_set_ex_phy()
283 phy->phy->maximum_linkrate = dr->pmax_linkrate; in sas_set_ex_phy()
284 phy->phy->negotiated_linkrate = phy->linkrate; in sas_set_ex_phy()
288 if (sas_phy_add(phy->phy)) { in sas_set_ex_phy()
289 sas_phy_free(phy->phy); in sas_set_ex_phy()
294 switch (phy->attached_dev_type) { in sas_set_ex_phy()
302 if (phy->attached_iproto) { in sas_set_ex_phy()
303 if (phy->attached_tproto) in sas_set_ex_phy()
325 if (new_phy || phy->attached_dev_type != dev_type || in sas_set_ex_phy()
326 phy->linkrate != linkrate || in sas_set_ex_phy()
327 SAS_ADDR(phy->attached_sas_addr) != SAS_ADDR(sas_addr)) in sas_set_ex_phy()
341 SAS_ADDR(dev->sas_addr), phy->phy_id, in sas_set_ex_phy()
342 sas_route_char(dev, phy), phy->linkrate, in sas_set_ex_phy()
343 SAS_ADDR(phy->attached_sas_addr), type); in sas_set_ex_phy()
615 struct ex_phy *phy = &ex->ex_phy[phy_id]; in sas_ex_disable_phy() local
618 phy->linkrate = SAS_PHY_DISABLED; in sas_ex_disable_phy()
627 struct ex_phy *phy = &ex->ex_phy[i]; in sas_ex_disable_port() local
629 if (phy->phy_state == PHY_VACANT || in sas_ex_disable_port()
630 phy->phy_state == PHY_NOT_PRESENT) in sas_ex_disable_port()
633 if (SAS_ADDR(phy->attached_sas_addr) == SAS_ADDR(sas_addr)) in sas_ex_disable_port()
654 int sas_smp_get_phy_events(struct sas_phy *phy) in sas_smp_get_phy_events() argument
659 struct sas_rphy *rphy = dev_to_rphy(phy->dev.parent); in sas_smp_get_phy_events()
673 req[9] = phy->number; in sas_smp_get_phy_events()
681 phy->invalid_dword_count = scsi_to_u32(&resp[12]); in sas_smp_get_phy_events()
682 phy->running_disparity_error_count = scsi_to_u32(&resp[16]); in sas_smp_get_phy_events()
683 phy->loss_of_dword_sync_count = scsi_to_u32(&resp[20]); in sas_smp_get_phy_events()
684 phy->phy_reset_problem_count = scsi_to_u32(&resp[24]); in sas_smp_get_phy_events()
751 struct ex_phy *phy = &parent_ex->ex_phy[i]; in sas_ex_get_linkrate() local
753 if (phy->phy_state == PHY_VACANT || in sas_ex_get_linkrate()
754 phy->phy_state == PHY_NOT_PRESENT) in sas_ex_get_linkrate()
757 if (SAS_ADDR(phy->attached_sas_addr) == in sas_ex_get_linkrate()
761 phy->linkrate); in sas_ex_get_linkrate()
763 phy->linkrate); in sas_ex_get_linkrate()
765 sas_port_add_phy(port, phy->phy); in sas_ex_get_linkrate()
776 struct ex_phy *phy = &parent_ex->ex_phy[phy_id]; in sas_ex_discover_end_dev() local
781 if (phy->attached_sata_host || phy->attached_sata_ps) in sas_ex_discover_end_dev()
791 child->iproto = phy->attached_iproto; in sas_ex_discover_end_dev()
792 memcpy(child->sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); in sas_ex_discover_end_dev()
794 if (!phy->port) { in sas_ex_discover_end_dev()
795 phy->port = sas_port_alloc(&parent->rphy->dev, phy_id); in sas_ex_discover_end_dev()
796 if (unlikely(!phy->port)) in sas_ex_discover_end_dev()
798 if (unlikely(sas_port_add(phy->port) != 0)) { in sas_ex_discover_end_dev()
799 sas_port_free(phy->port); in sas_ex_discover_end_dev()
803 sas_ex_get_linkrate(parent, child, phy); in sas_ex_discover_end_dev()
804 sas_device_set_phy(child, phy->port); in sas_ex_discover_end_dev()
807 if ((phy->attached_tproto & SAS_PROTOCOL_STP) || phy->attached_sata_dev) { in sas_ex_discover_end_dev()
808 res = sas_get_ata_info(child, phy); in sas_ex_discover_end_dev()
816 rphy = sas_end_device_alloc(phy->port); in sas_ex_discover_end_dev()
835 if (phy->attached_tproto & SAS_PROTOCOL_SSP) { in sas_ex_discover_end_dev()
837 rphy = sas_end_device_alloc(phy->port); in sas_ex_discover_end_dev()
841 child->tproto = phy->attached_tproto; in sas_ex_discover_end_dev()
860 phy->attached_tproto, SAS_ADDR(parent->sas_addr), in sas_ex_discover_end_dev()
875 sas_port_delete(phy->port); in sas_ex_discover_end_dev()
877 phy->port = NULL; in sas_ex_discover_end_dev()
885 struct ex_phy *phy = &parent->ex_dev.ex_phy[phy_id]; in sas_ex_join_wide_port() local
891 if (ephy == phy) in sas_ex_join_wide_port()
894 if (!memcmp(phy->attached_sas_addr, ephy->attached_sas_addr, in sas_ex_join_wide_port()
896 sas_port_add_phy(ephy->port, phy->phy); in sas_ex_join_wide_port()
897 phy->port = ephy->port; in sas_ex_join_wide_port()
898 phy->phy_state = PHY_DEVICE_DISCOVERED; in sas_ex_join_wide_port()
910 struct ex_phy *phy = &parent->ex_dev.ex_phy[phy_id]; in sas_ex_discover_expander() local
917 if (phy->routing_attr == DIRECT_ROUTING) { in sas_ex_discover_expander()
921 SAS_ADDR(phy->attached_sas_addr), in sas_ex_discover_expander()
922 phy->attached_phy_id); in sas_ex_discover_expander()
929 phy->port = sas_port_alloc(&parent->rphy->dev, phy_id); in sas_ex_discover_expander()
931 BUG_ON(sas_port_add(phy->port) != 0); in sas_ex_discover_expander()
934 switch (phy->attached_dev_type) { in sas_ex_discover_expander()
936 rphy = sas_expander_alloc(phy->port, in sas_ex_discover_expander()
940 rphy = sas_expander_alloc(phy->port, in sas_ex_discover_expander()
951 child->dev_type = phy->attached_dev_type; in sas_ex_discover_expander()
955 child->iproto = phy->attached_iproto; in sas_ex_discover_expander()
956 child->tproto = phy->attached_tproto; in sas_ex_discover_expander()
957 memcpy(child->sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); in sas_ex_discover_expander()
959 sas_ex_get_linkrate(parent, child, phy); in sas_ex_discover_expander()
1108 struct ex_phy *phy = &ex->ex_phy[i]; in sas_find_sub_addr() local
1110 if (phy->phy_state == PHY_VACANT || in sas_find_sub_addr()
1111 phy->phy_state == PHY_NOT_PRESENT) in sas_find_sub_addr()
1114 if ((phy->attached_dev_type == SAS_EDGE_EXPANDER_DEVICE || in sas_find_sub_addr()
1115 phy->attached_dev_type == SAS_FANOUT_EXPANDER_DEVICE) && in sas_find_sub_addr()
1116 phy->routing_attr == SUBTRACTIVE_ROUTING) { in sas_find_sub_addr()
1118 memcpy(sub_addr, phy->attached_sas_addr,SAS_ADDR_SIZE); in sas_find_sub_addr()
1215 struct ex_phy *phy = &ex->ex_phy[i]; in sas_check_ex_subtractive_boundary() local
1217 if (phy->phy_state == PHY_VACANT || in sas_check_ex_subtractive_boundary()
1218 phy->phy_state == PHY_NOT_PRESENT) in sas_check_ex_subtractive_boundary()
1221 if ((phy->attached_dev_type == SAS_FANOUT_EXPANDER_DEVICE || in sas_check_ex_subtractive_boundary()
1222 phy->attached_dev_type == SAS_EDGE_EXPANDER_DEVICE) && in sas_check_ex_subtractive_boundary()
1223 phy->routing_attr == SUBTRACTIVE_ROUTING) { in sas_check_ex_subtractive_boundary()
1226 sub_sas_addr = &phy->attached_sas_addr[0]; in sas_check_ex_subtractive_boundary()
1228 SAS_ADDR(phy->attached_sas_addr)) { in sas_check_ex_subtractive_boundary()
1234 SAS_ADDR(phy->attached_sas_addr), in sas_check_ex_subtractive_boundary()
1392 struct ex_phy *phy = &ex->ex_phy[phy_id]; in sas_configure_present() local
1444 phy->last_da_index < i) { in sas_configure_present()
1445 phy->last_da_index = i; in sas_configure_present()
1545 struct ex_phy *phy = &ex_parent->ex_phy[i]; in sas_configure_parent() local
1547 if ((phy->routing_attr == TABLE_ROUTING) && in sas_configure_parent()
1548 (SAS_ADDR(phy->attached_sas_addr) == in sas_configure_parent()
1882 struct ex_phy *phy = &ex_dev->ex_phy[phy_id]; in sas_unregister_devs_sas_addr() local
1888 SAS_ADDR(phy->attached_sas_addr)) { in sas_unregister_devs_sas_addr()
1899 sas_disable_routing(parent, phy->attached_sas_addr); in sas_unregister_devs_sas_addr()
1901 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); in sas_unregister_devs_sas_addr()
1902 if (phy->port) { in sas_unregister_devs_sas_addr()
1903 sas_port_delete_phy(phy->port, phy->phy); in sas_unregister_devs_sas_addr()
1904 sas_device_set_phy(found, phy->port); in sas_unregister_devs_sas_addr()
1905 if (phy->port->num_phys == 0) in sas_unregister_devs_sas_addr()
1906 sas_port_delete(phy->port); in sas_unregister_devs_sas_addr()
1907 phy->port = NULL; in sas_unregister_devs_sas_addr()
2000 struct ex_phy *phy = &ex->ex_phy[phy_id]; in sas_rediscover_dev() local
2009 phy->phy_state = PHY_NOT_PRESENT; in sas_rediscover_dev()
2013 phy->phy_state = PHY_VACANT; in sas_rediscover_dev()
2025 phy->phy_state = PHY_EMPTY; in sas_rediscover_dev()
2028 } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) && in sas_rediscover_dev()
2029 dev_type_flutter(type, phy->attached_dev_type)) { in sas_rediscover_dev()
2035 if (ata_dev && phy->attached_dev_type == SAS_SATA_PENDING) in sas_rediscover_dev()
2043 if (SAS_ADDR(phy->attached_sas_addr) && in sas_rediscover_dev()
2044 SAS_ADDR(sas_addr) != SAS_ADDR(phy->attached_sas_addr)) { in sas_rediscover_dev()
2047 SAS_ADDR(phy->attached_sas_addr)); in sas_rediscover_dev()
2081 struct ex_phy *phy = &ex->ex_phy[i]; in sas_rediscover() local
2085 if (SAS_ADDR(phy->attached_sas_addr) == in sas_rediscover()