Lines Matching refs:port
15 static bool phy_is_wideport_member(struct asd_sas_port *port, struct asd_sas_phy *phy) in phy_is_wideport_member() argument
19 if (memcmp(port->attached_sas_addr, phy->attached_sas_addr, in phy_is_wideport_member()
21 memcmp(port->sas_addr, phy->sas_addr, SAS_ADDR_SIZE) != 0)) in phy_is_wideport_member()
29 struct asd_sas_port *port = phy->port; in sas_resume_port() local
36 if (port->suspended) in sas_resume_port()
37 port->suspended = 0; in sas_resume_port()
47 list_for_each_entry_safe(dev, n, &port->dev_list, dev_list_node) { in sas_resume_port()
52 sas_unregister_dev(port, dev); in sas_resume_port()
53 sas_destruct_devices(port); in sas_resume_port()
67 sas_discover_event(port, DISCE_RESUME); in sas_resume_port()
70 static void sas_form_port_add_phy(struct asd_sas_port *port, in sas_form_port_add_phy() argument
73 list_add_tail(&phy->port_phy_el, &port->phy_list); in sas_form_port_add_phy()
74 sas_phy_set_target(phy, port->port_dev); in sas_form_port_add_phy()
75 phy->port = port; in sas_form_port_add_phy()
76 port->num_phys++; in sas_form_port_add_phy()
77 port->phy_mask |= (1U << phy->id); in sas_form_port_add_phy()
81 port->id); in sas_form_port_add_phy()
83 memcpy(port->sas_addr, phy->sas_addr, SAS_ADDR_SIZE); in sas_form_port_add_phy()
85 if (*(u64 *)port->attached_sas_addr == 0) { in sas_form_port_add_phy()
86 memcpy(port->attached_sas_addr, phy->attached_sas_addr, in sas_form_port_add_phy()
88 port->iproto = phy->iproto; in sas_form_port_add_phy()
89 port->tproto = phy->tproto; in sas_form_port_add_phy()
90 port->oob_mode = phy->oob_mode; in sas_form_port_add_phy()
91 port->linkrate = phy->linkrate; in sas_form_port_add_phy()
93 port->linkrate = max(port->linkrate, phy->linkrate); in sas_form_port_add_phy()
108 struct asd_sas_port *port = phy->port; in sas_form_port() local
114 if (port) { in sas_form_port()
115 if (!phy_is_wideport_member(port, phy)) in sas_form_port()
126 __func__, phy->id, phy->port->id, in sas_form_port()
127 phy->port->num_phys); in sas_form_port()
135 port = sas_ha->sas_port[i]; in sas_form_port()
136 spin_lock(&port->phy_list_lock); in sas_form_port()
137 if (*(u64 *) port->sas_addr && in sas_form_port()
138 phy_is_wideport_member(port, phy) && port->num_phys > 0) { in sas_form_port()
140 port_dev = port->port_dev; in sas_form_port()
141 sas_form_port_add_phy(port, phy, true); in sas_form_port()
142 spin_unlock(&port->phy_list_lock); in sas_form_port()
145 spin_unlock(&port->phy_list_lock); in sas_form_port()
150 port = sas_ha->sas_port[i]; in sas_form_port()
151 spin_lock(&port->phy_list_lock); in sas_form_port()
152 if (*(u64 *)port->sas_addr == 0 in sas_form_port()
153 && port->num_phys == 0) { in sas_form_port()
154 port_dev = port->port_dev; in sas_form_port()
155 sas_form_port_add_phy(port, phy, false); in sas_form_port()
156 spin_unlock(&port->phy_list_lock); in sas_form_port()
159 spin_unlock(&port->phy_list_lock); in sas_form_port()
171 if (!port->port) { in sas_form_port()
172 port->port = sas_port_alloc(phy->phy->dev.parent, port->id); in sas_form_port()
173 BUG_ON(!port->port); in sas_form_port()
174 sas_port_add(port->port); in sas_form_port()
176 sas_port_add_phy(port->port, phy->phy); in sas_form_port()
179 dev_name(&phy->phy->dev), dev_name(&port->port->dev), in sas_form_port()
180 port->phy_mask, in sas_form_port()
181 SAS_ADDR(port->attached_sas_addr)); in sas_form_port()
184 port_dev->pathways = port->num_phys; in sas_form_port()
190 sas_discover_event(phy->port, DISCE_DISCOVER_DOMAIN); in sas_form_port()
196 sas_discover_event(port, DISCE_REVALIDATE_DOMAIN); in sas_form_port()
212 struct asd_sas_port *port = phy->port; in sas_deform_port() local
218 if (!port) in sas_deform_port()
221 dev = port->port_dev; in sas_deform_port()
225 if (port->num_phys == 1) { in sas_deform_port()
226 sas_unregister_domain_devices(port, gone); in sas_deform_port()
227 sas_destruct_devices(port); in sas_deform_port()
228 sas_port_delete(port->port); in sas_deform_port()
229 port->port = NULL; in sas_deform_port()
231 sas_port_delete_phy(port->port, phy->phy); in sas_deform_port()
232 sas_device_set_phy(dev, port->port); in sas_deform_port()
239 spin_lock(&port->phy_list_lock); in sas_deform_port()
243 phy->port = NULL; in sas_deform_port()
244 port->num_phys--; in sas_deform_port()
245 port->phy_mask &= ~(1U << phy->id); in sas_deform_port()
247 if (port->num_phys == 0) { in sas_deform_port()
248 INIT_LIST_HEAD(&port->phy_list); in sas_deform_port()
249 memset(port->sas_addr, 0, SAS_ADDR_SIZE); in sas_deform_port()
250 memset(port->attached_sas_addr, 0, SAS_ADDR_SIZE); in sas_deform_port()
251 port->iproto = 0; in sas_deform_port()
252 port->tproto = 0; in sas_deform_port()
253 port->oob_mode = 0; in sas_deform_port()
254 port->phy_mask = 0; in sas_deform_port()
256 spin_unlock(&port->phy_list_lock); in sas_deform_port()
260 if (port->port && dev && dev_is_expander(dev->dev_type)) { in sas_deform_port()
264 sas_discover_event(port, DISCE_REVALIDATE_DOMAIN); in sas_deform_port()
293 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN); in sas_porte_broadcast_rcvd()
295 if (phy->port) in sas_porte_broadcast_rcvd()
296 flush_workqueue(phy->port->ha->disco_q); in sas_porte_broadcast_rcvd()
325 static void sas_init_port(struct asd_sas_port *port, in sas_init_port() argument
328 memset(port, 0, sizeof(*port)); in sas_init_port()
329 port->id = i; in sas_init_port()
330 INIT_LIST_HEAD(&port->dev_list); in sas_init_port()
331 INIT_LIST_HEAD(&port->disco_list); in sas_init_port()
332 INIT_LIST_HEAD(&port->destroy_list); in sas_init_port()
333 INIT_LIST_HEAD(&port->sas_port_del_list); in sas_init_port()
334 spin_lock_init(&port->phy_list_lock); in sas_init_port()
335 INIT_LIST_HEAD(&port->phy_list); in sas_init_port()
336 port->ha = sas_ha; in sas_init_port()
338 spin_lock_init(&port->dev_list_lock); in sas_init_port()
347 struct asd_sas_port *port = sas_ha->sas_port[i]; in sas_register_ports() local
349 sas_init_port(port, sas_ha, i); in sas_register_ports()
350 sas_init_disc(&port->disc, port); in sas_register_ports()
360 if (sas_ha->sas_phy[i]->port) in sas_unregister_ports()