Lines Matching refs:port

31 static bool phy_is_wideport_member(struct asd_sas_port *port, struct asd_sas_phy *phy)
35 if (memcmp(port->attached_sas_addr, phy->attached_sas_addr,
37 memcmp(port->sas_addr, phy->sas_addr, SAS_ADDR_SIZE) != 0))
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;
58 if (port) {
59 if (!phy_is_wideport_member(port, phy))
62 SAS_DPRINTK("%s: phy%d belongs to port%d already(%d)!\n",
63 __func__, phy->id, phy->port->id,
64 phy->port->num_phys);
69 /* see if the phy should be part of a wide port */
72 port = sas_ha->sas_port[i];
73 spin_lock(&port->phy_list_lock);
74 if (*(u64 *) port->sas_addr &&
75 phy_is_wideport_member(port, phy) && port->num_phys > 0) {
76 /* wide port */
77 SAS_DPRINTK("phy%d matched wide port%d\n", phy->id,
78 port->id);
81 spin_unlock(&port->phy_list_lock);
83 /* The phy does not match any existing port, create a new one */
86 port = sas_ha->sas_port[i];
87 spin_lock(&port->phy_list_lock);
88 if (*(u64 *)port->sas_addr == 0
89 && port->num_phys == 0) {
90 memcpy(port->sas_addr, phy->sas_addr,
94 spin_unlock(&port->phy_list_lock);
99 printk(KERN_NOTICE "%s: couldn't find a free port, bug?\n",
105 /* add the phy to the port */
106 list_add_tail(&phy->port_phy_el, &port->phy_list);
107 sas_phy_set_target(phy, port->port_dev);
108 phy->port = port;
109 port->num_phys++;
110 port->phy_mask |= (1U << phy->id);
112 if (*(u64 *)port->attached_sas_addr == 0) {
113 port->class = phy->class;
114 memcpy(port->attached_sas_addr, phy->attached_sas_addr,
116 port->iproto = phy->iproto;
117 port->tproto = phy->tproto;
118 port->oob_mode = phy->oob_mode;
119 port->linkrate = phy->linkrate;
121 port->linkrate = max(port->linkrate, phy->linkrate);
122 spin_unlock(&port->phy_list_lock);
125 if (!port->port) {
126 port->port = sas_port_alloc(phy->phy->dev.parent, port->id);
127 BUG_ON(!port->port);
128 sas_port_add(port->port);
130 sas_port_add_phy(port->port, phy->phy);
133 dev_name(&phy->phy->dev), dev_name(&port->port->dev),
134 port->phy_mask,
135 SAS_ADDR(port->attached_sas_addr));
137 if (port->port_dev)
138 port->port_dev->pathways = port->num_phys;
140 /* Tell the LLDD about this port formation. */
144 sas_discover_event(phy->port, DISCE_DISCOVER_DOMAIN);
148 * sas_deform_port -- remove this phy from the port it belongs to
157 struct asd_sas_port *port = phy->port;
163 if (!port)
166 dev = port->port_dev;
170 if (port->num_phys == 1) {
171 sas_unregister_domain_devices(port, gone);
172 sas_port_delete(port->port);
173 port->port = NULL;
175 sas_port_delete_phy(port->port, phy->phy);
176 sas_device_set_phy(dev, port->port);
183 spin_lock(&port->phy_list_lock);
187 phy->port = NULL;
188 port->num_phys--;
189 port->phy_mask &= ~(1U << phy->id);
191 if (port->num_phys == 0) {
192 INIT_LIST_HEAD(&port->phy_list);
193 memset(port->sas_addr, 0, SAS_ADDR_SIZE);
194 memset(port->attached_sas_addr, 0, SAS_ADDR_SIZE);
195 port->class = 0;
196 port->iproto = 0;
197 port->tproto = 0;
198 port->oob_mode = 0;
199 port->phy_mask = 0;
201 spin_unlock(&port->phy_list_lock);
207 /* ---------- SAS port events ---------- */
233 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN);
266 /* ---------- SAS port registration ---------- */
268 static void sas_init_port(struct asd_sas_port *port,
271 memset(port, 0, sizeof(*port));
272 port->id = i;
273 INIT_LIST_HEAD(&port->dev_list);
274 INIT_LIST_HEAD(&port->disco_list);
275 INIT_LIST_HEAD(&port->destroy_list);
276 spin_lock_init(&port->phy_list_lock);
277 INIT_LIST_HEAD(&port->phy_list);
278 port->ha = sas_ha;
280 spin_lock_init(&port->dev_list_lock);
289 struct asd_sas_port *port = sas_ha->sas_port[i];
291 sas_init_port(port, sas_ha, i);
292 sas_init_disc(&port->disc, port);
302 if (sas_ha->sas_phy[i]->port)