Lines Matching full:port
2 * Serial Attached SCSI (SAS) Port class
31 static bool phy_is_wideport_member(struct asd_sas_port *port, struct asd_sas_phy *phy) in phy_is_wideport_member() argument
35 if (memcmp(port->attached_sas_addr, phy->attached_sas_addr, in phy_is_wideport_member()
37 memcmp(port->sas_addr, phy->sas_addr, SAS_ADDR_SIZE) != 0)) in phy_is_wideport_member()
43 * sas_form_port -- add this phy to a port
46 * This function adds this phy to an existing port, thus creating a wide
47 * port, or it creates a port and adds the phy to the port.
53 struct asd_sas_port *port = phy->port; in sas_form_port() local
58 if (port) { in sas_form_port()
59 if (!phy_is_wideport_member(port, phy)) in sas_form_port()
62 SAS_DPRINTK("%s: phy%d belongs to port%d already(%d)!\n", in sas_form_port()
63 __func__, phy->id, phy->port->id, in sas_form_port()
64 phy->port->num_phys); in sas_form_port()
69 /* see if the phy should be part of a wide port */ in sas_form_port()
72 port = sas_ha->sas_port[i]; in sas_form_port()
73 spin_lock(&port->phy_list_lock); in sas_form_port()
74 if (*(u64 *) port->sas_addr && in sas_form_port()
75 phy_is_wideport_member(port, phy) && port->num_phys > 0) { in sas_form_port()
76 /* wide port */ in sas_form_port()
77 SAS_DPRINTK("phy%d matched wide port%d\n", phy->id, in sas_form_port()
78 port->id); in sas_form_port()
81 spin_unlock(&port->phy_list_lock); in sas_form_port()
83 /* The phy does not match any existing port, create a new one */ in sas_form_port()
86 port = sas_ha->sas_port[i]; in sas_form_port()
87 spin_lock(&port->phy_list_lock); in sas_form_port()
88 if (*(u64 *)port->sas_addr == 0 in sas_form_port()
89 && port->num_phys == 0) { in sas_form_port()
90 memcpy(port->sas_addr, phy->sas_addr, in sas_form_port()
94 spin_unlock(&port->phy_list_lock); in sas_form_port()
99 printk(KERN_NOTICE "%s: couldn't find a free port, bug?\n", in sas_form_port()
105 /* add the phy to the port */ in sas_form_port()
106 list_add_tail(&phy->port_phy_el, &port->phy_list); in sas_form_port()
107 phy->port = port; in sas_form_port()
108 port->num_phys++; in sas_form_port()
109 port->phy_mask |= (1U << phy->id); in sas_form_port()
111 if (!port->phy) in sas_form_port()
112 port->phy = phy->phy; in sas_form_port()
114 if (*(u64 *)port->attached_sas_addr == 0) { in sas_form_port()
115 port->class = phy->class; in sas_form_port()
116 memcpy(port->attached_sas_addr, phy->attached_sas_addr, in sas_form_port()
118 port->iproto = phy->iproto; in sas_form_port()
119 port->tproto = phy->tproto; in sas_form_port()
120 port->oob_mode = phy->oob_mode; in sas_form_port()
121 port->linkrate = phy->linkrate; in sas_form_port()
123 port->linkrate = max(port->linkrate, phy->linkrate); in sas_form_port()
124 spin_unlock(&port->phy_list_lock); in sas_form_port()
127 if (!port->port) { in sas_form_port()
128 port->port = sas_port_alloc(phy->phy->dev.parent, port->id); in sas_form_port()
129 BUG_ON(!port->port); in sas_form_port()
130 sas_port_add(port->port); in sas_form_port()
132 sas_port_add_phy(port->port, phy->phy); in sas_form_port()
135 dev_name(&phy->phy->dev), dev_name(&port->port->dev), in sas_form_port()
136 port->phy_mask, in sas_form_port()
137 SAS_ADDR(port->attached_sas_addr)); in sas_form_port()
139 if (port->port_dev) in sas_form_port()
140 port->port_dev->pathways = port->num_phys; in sas_form_port()
142 /* Tell the LLDD about this port formation. */ in sas_form_port()
146 sas_discover_event(phy->port, DISCE_DISCOVER_DOMAIN); in sas_form_port()
150 * sas_deform_port -- remove this phy from the port it belongs to
159 struct asd_sas_port *port = phy->port; in sas_deform_port() local
165 if (!port) in sas_deform_port()
168 dev = port->port_dev; in sas_deform_port()
172 if (port->num_phys == 1) { in sas_deform_port()
175 sas_unregister_domain_devices(port); in sas_deform_port()
176 sas_port_delete(port->port); in sas_deform_port()
177 port->port = NULL; in sas_deform_port()
179 sas_port_delete_phy(port->port, phy->phy); in sas_deform_port()
185 spin_lock(&port->phy_list_lock); in sas_deform_port()
188 phy->port = NULL; in sas_deform_port()
189 port->num_phys--; in sas_deform_port()
190 port->phy_mask &= ~(1U << phy->id); in sas_deform_port()
192 if (port->num_phys == 0) { in sas_deform_port()
193 INIT_LIST_HEAD(&port->phy_list); in sas_deform_port()
194 memset(port->sas_addr, 0, SAS_ADDR_SIZE); in sas_deform_port()
195 memset(port->attached_sas_addr, 0, SAS_ADDR_SIZE); in sas_deform_port()
196 port->class = 0; in sas_deform_port()
197 port->iproto = 0; in sas_deform_port()
198 port->tproto = 0; in sas_deform_port()
199 port->oob_mode = 0; in sas_deform_port()
200 port->phy_mask = 0; in sas_deform_port()
202 spin_unlock(&port->phy_list_lock); in sas_deform_port()
208 /* ---------- SAS port events ---------- */
238 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN); in sas_porte_broadcast_rcvd()
277 /* ---------- SAS port registration ---------- */
279 static void sas_init_port(struct asd_sas_port *port, in sas_init_port() argument
282 memset(port, 0, sizeof(*port)); in sas_init_port()
283 port->id = i; in sas_init_port()
284 INIT_LIST_HEAD(&port->dev_list); in sas_init_port()
285 spin_lock_init(&port->phy_list_lock); in sas_init_port()
286 INIT_LIST_HEAD(&port->phy_list); in sas_init_port()
287 port->ha = sas_ha; in sas_init_port()
289 spin_lock_init(&port->dev_list_lock); in sas_init_port()
298 struct asd_sas_port *port = sas_ha->sas_port[i]; in sas_register_ports() local
300 sas_init_port(port, sas_ha, i); in sas_register_ports()
301 sas_init_disc(&port->disc, port); in sas_register_ports()
311 if (sas_ha->sas_phy[i]->port) in sas_unregister_ports()