Lines Matching defs:port

15 static bool phy_is_wideport_member(struct asd_sas_port *port, struct asd_sas_phy *phy)
19 if (memcmp(port->attached_sas_addr, phy->attached_sas_addr,
21 memcmp(port->sas_addr, phy->sas_addr, SAS_ADDR_SIZE) != 0))
29 struct asd_sas_port *port = phy->port;
36 if (port->suspended)
37 port->suspended = 0;
43 /* if the port came back:
47 list_for_each_entry_safe(dev, n, &port->dev_list, dev_list_node) {
52 sas_unregister_dev(port, dev);
53 sas_destruct_devices(port);
67 sas_discover_event(port, DISCE_RESUME);
70 static void sas_form_port_add_phy(struct asd_sas_port *port,
73 list_add_tail(&phy->port_phy_el, &port->phy_list);
74 sas_phy_set_target(phy, port->port_dev);
75 phy->port = port;
76 port->num_phys++;
77 port->phy_mask |= (1U << phy->id);
80 pr_debug("phy%d matched wide port%d\n", phy->id,
81 port->id);
83 memcpy(port->sas_addr, phy->sas_addr, SAS_ADDR_SIZE);
85 if (*(u64 *)port->attached_sas_addr == 0) {
86 memcpy(port->attached_sas_addr, phy->attached_sas_addr,
88 port->iproto = phy->iproto;
89 port->tproto = phy->tproto;
90 port->oob_mode = phy->oob_mode;
91 port->linkrate = phy->linkrate;
93 port->linkrate = max(port->linkrate, phy->linkrate);
98 * sas_form_port - add this phy to a port
101 * This function adds this phy to an existing port, thus creating a wide
102 * port, or it creates a port and adds the phy to the port.
108 struct asd_sas_port *port = phy->port;
114 if (port) {
115 if (!phy_is_wideport_member(port, phy))
125 pr_info("%s: phy%d belongs to port%d already(%d)!\n",
126 __func__, phy->id, phy->port->id,
127 phy->port->num_phys);
132 /* see if the phy should be part of a wide port */
135 port = sas_ha->sas_port[i];
136 spin_lock(&port->phy_list_lock);
137 if (*(u64 *) port->sas_addr &&
138 phy_is_wideport_member(port, phy) && port->num_phys > 0) {
139 /* wide port */
140 port_dev = port->port_dev;
141 sas_form_port_add_phy(port, phy, true);
142 spin_unlock(&port->phy_list_lock);
145 spin_unlock(&port->phy_list_lock);
147 /* The phy does not match any existing port, create a new one */
150 port = sas_ha->sas_port[i];
151 spin_lock(&port->phy_list_lock);
152 if (*(u64 *)port->sas_addr == 0
153 && port->num_phys == 0) {
154 port_dev = port->port_dev;
155 sas_form_port_add_phy(port, phy, false);
156 spin_unlock(&port->phy_list_lock);
159 spin_unlock(&port->phy_list_lock);
163 pr_err("%s: couldn't find a free port, bug?\n",
171 if (!port->port) {
172 port->port = sas_port_alloc(phy->phy->dev.parent, port->id);
173 BUG_ON(!port->port);
174 sas_port_add(port->port);
176 sas_port_add_phy(port->port, phy->phy);
179 dev_name(&phy->phy->dev), dev_name(&port->port->dev),
180 port->phy_mask,
181 SAS_ADDR(port->attached_sas_addr));
184 port_dev->pathways = port->num_phys;
186 /* Tell the LLDD about this port formation. */
190 sas_discover_event(phy->port, DISCE_DISCOVER_DOMAIN);
196 sas_discover_event(port, DISCE_REVALIDATE_DOMAIN);
202 * sas_deform_port - remove this phy from the port it belongs to
212 struct asd_sas_port *port = phy->port;
218 if (!port)
221 dev = port->port_dev;
225 if (port->num_phys == 1) {
226 sas_unregister_domain_devices(port, gone);
227 sas_destruct_devices(port);
228 sas_port_delete(port->port);
229 port->port = NULL;
231 sas_port_delete_phy(port->port, phy->phy);
232 sas_device_set_phy(dev, port->port);
239 spin_lock(&port->phy_list_lock);
243 phy->port = NULL;
244 port->num_phys--;
245 port->phy_mask &= ~(1U << phy->id);
247 if (port->num_phys == 0) {
248 INIT_LIST_HEAD(&port->phy_list);
249 memset(port->sas_addr, 0, SAS_ADDR_SIZE);
250 memset(port->attached_sas_addr, 0, SAS_ADDR_SIZE);
251 port->iproto = 0;
252 port->tproto = 0;
253 port->oob_mode = 0;
254 port->phy_mask = 0;
256 spin_unlock(&port->phy_list_lock);
259 /* Only insert revalidate event if the port still has members */
260 if (port->port && dev && dev_is_expander(dev->dev_type)) {
264 sas_discover_event(port, DISCE_REVALIDATE_DOMAIN);
271 /* ---------- SAS port events ---------- */
293 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN);
295 if (phy->port)
296 flush_workqueue(phy->port->ha->disco_q);
323 /* ---------- SAS port registration ---------- */
325 static void sas_init_port(struct asd_sas_port *port,
328 memset(port, 0, sizeof(*port));
329 port->id = i;
330 INIT_LIST_HEAD(&port->dev_list);
331 INIT_LIST_HEAD(&port->disco_list);
332 INIT_LIST_HEAD(&port->destroy_list);
333 INIT_LIST_HEAD(&port->sas_port_del_list);
334 spin_lock_init(&port->phy_list_lock);
335 INIT_LIST_HEAD(&port->phy_list);
336 port->ha = sas_ha;
338 spin_lock_init(&port->dev_list_lock);
347 struct asd_sas_port *port = sas_ha->sas_port[i];
349 sas_init_port(port, sas_ha, i);
350 sas_init_disc(&port->disc, port);
360 if (sas_ha->sas_phy[i]->port)