Lines Matching refs:port

108 release_port(umad_port_t *port)
110 free(port->pkeys);
111 port->pkeys = NULL;
112 port->pkeys_size = 0;
125 get_port(char *ca_name, char *dir, int portnum, umad_port_t *port)
132 strncpy(port->ca_name, ca_name, sizeof port->ca_name - 1);
133 port->portnum = portnum;
134 port->pkeys = NULL;
140 if (sys_read_uint(port_dir, SYS_PORT_LMC, &port->lmc) < 0)
142 if (sys_read_uint(port_dir, SYS_PORT_SMLID, &port->sm_lid) < 0)
144 if (sys_read_uint(port_dir, SYS_PORT_SMSL, &port->sm_sl) < 0)
146 if (sys_read_uint(port_dir, SYS_PORT_LID, &port->base_lid) < 0)
148 if (sys_read_uint(port_dir, SYS_PORT_STATE, &port->state) < 0)
150 if (sys_read_uint(port_dir, SYS_PORT_PHY_STATE, &port->phys_state) < 0)
152 if (sys_read_uint(port_dir, SYS_PORT_RATE, &port->rate) < 0)
154 if (sys_read_uint64(port_dir, SYS_PORT_CAPMASK, &port->capmask) < 0)
157 port->capmask = htonl(port->capmask);
162 memcpy(&port->gid_prefix, gid, sizeof port->gid_prefix);
163 memcpy(&port->port_guid, gid + 8, sizeof port->port_guid);
169 port->ca_name, port->portnum, port_dir);
172 port->pkeys = calloc(ret, sizeof(port->pkeys[0]));
173 if (!port->pkeys) {
181 port->pkeys[idx] = val;
184 port->pkeys_size = ret;
199 if (port->pkeys)
200 free(port->pkeys);
220 * if *port > 0, check ca[port] state. Otherwise set *port to
221 * the first port that is active, and if such is not found, to
222 * the first port that is link up and if none are linkup, then
223 * the first port that is not disabled. Otherwise return -1.
226 resolve_ca_port(char *ca_name, int *port)
238 *port = 0; /* switch sma port 0 */
242 if (*port > 0) { /* check only the port the user wants */
243 if (*port > ca.numports)
245 if (!ca.ports[*port])
247 if (ca.ports[*port]->state == 4)
249 if (ca.ports[*port]->phys_state != 3)
255 DEBUG("checking port %d", i);
259 up = *port = i;
261 active = *port = i;
262 DEBUG("found active port %d", i);
267 if (active == -1 && up == -1) { /* no active or linkup port found */
269 DEBUG("checking port %d", i);
273 up = *port = i;
292 int phys_found = -1, port_found = 0, port, port_type;
308 /* Find the first existing CA with an active port */
312 port = best_port ? *best_port : 0;
313 if ((port_type = resolve_ca_port(names[caidx], &port)) < 0)
316 DEBUG("found ca %s with port %d type %d",
317 names[caidx], port, port_type);
321 *best_port = port;
322 DEBUG("found ca %s with active port %d",
323 names[caidx], port);
329 port_found = port;
333 DEBUG("phys found %d on %s port %d",
443 umad_id_to_dev(int umad_id, char *dev, unsigned *port)
453 if ((r = sys_read_uint(path, SYS_IB_MAD_PORT, port)) < 0)
460 dev_to_umad_id(char *dev, unsigned port)
471 if (port != umad_port)
474 DEBUG("mapped %s %d to %d", dev, port, id);
560 TRACE("ca name %s max port guids %d", ca_name, max);
588 TRACE("ca %s port %d", ca_name, portnum);
607 TRACE("ca %s port %d", ca_name, portnum);
612 DEBUG("opening %s port %d", ca_name, portnum);
670 umad_get_port(char *ca_name, int portnum, umad_port_t *port)
682 return get_port(ca_name, dir_name, portnum, port);
686 umad_release_port(umad_port_t *port)
690 TRACE("port %s:%d", port->ca_name, port->portnum);
691 if (!port)
694 if ((r = release_port(port)) < 0)
697 DEBUG("releasing %s:%d", port->ca_name, port->portnum);