Lines Matching +full:port +full:- +full:config
2 * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
5 * Copyright (c) 2010-2011 Mellanox Technologies LTD. All rights reserved.
17 * - Redistributions of source code must retain the above
21 * - Redistributions in binary form must reproduce the above
38 #include <config.h>
75 memcpy(node->switchinfo, switch_info, sizeof(node->switchinfo)); in recv_switch_info()
76 mad_decode_field(node->switchinfo, IB_SW_ENHANCED_PORT0_F, in recv_switch_info()
77 &node->smaenhsp0); in recv_switch_info()
84 node->smaenhsp0 = 0; /* assume base SP0 */ in query_switch_info()
91 if (path->cnt > sizeof(path->p) - 2) in add_port_to_dpath()
92 return -1; in add_port_to_dpath()
93 ++path->cnt; in add_port_to_dpath()
94 path->p[path->cnt] = (uint8_t) nextport; in add_port_to_dpath()
95 return path->cnt; in add_port_to_dpath()
100 ibnd_scan_t *scan = engine->user_data; in retract_dpath()
101 f_internal_t *f_int = scan->f_int; in retract_dpath()
103 if (scan->cfg->max_hops && in retract_dpath()
104 f_int->fabric.maxhops_discovered > scan->cfg->max_hops) in retract_dpath()
112 f_int->fabric.maxhops_discovered++; in retract_dpath()
113 portid->drpath.p[portid->drpath.cnt] = 0; in retract_dpath()
114 portid->drpath.cnt--; in retract_dpath()
121 ibnd_scan_t *scan = engine->user_data; in extend_dpath()
122 f_internal_t *f_int = scan->f_int; in extend_dpath()
124 if (scan->cfg->max_hops && in extend_dpath()
125 f_int->fabric.maxhops_discovered > scan->cfg->max_hops) in extend_dpath()
128 if (portid->lid) { in extend_dpath()
130 portid->drpath.drslid = (uint16_t) scan->selfportid.lid; in extend_dpath()
131 portid->drpath.drdlid = 0xFFFF; in extend_dpath()
134 if (add_port_to_dpath(&portid->drpath, nextport) < 0) { in extend_dpath()
135 IBND_ERROR("add port %d to DR path failed; %s\n", nextport, in extend_dpath()
137 return -1; in extend_dpath()
140 if (((unsigned) portid->drpath.cnt - scan->initial_hops) > in extend_dpath()
141 f_int->fabric.maxhops_discovered) in extend_dpath()
142 f_int->fabric.maxhops_discovered++; in extend_dpath()
152 memcpy(node->nodedesc, node_desc, sizeof(node->nodedesc)); in recv_node_desc()
163 static void debug_port(ib_portid_t * portid, ibnd_port_t * port) in debug_port() argument
171 iwidth = mad_get_field(port->info, 0, IB_PORT_LINK_WIDTH_ACTIVE_F); in debug_port()
172 ispeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F); in debug_port()
173 fdr10 = mad_get_field(port->ext_info, 0, in debug_port()
176 if (port->node->type == IB_NODE_SWITCH) in debug_port()
177 info = (uint8_t *)&port->node->ports[0]->info; in debug_port()
179 info = (uint8_t *)&port->info; in debug_port()
182 espeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_EXT_ACTIVE_F); in debug_port()
187 portid2str(portid), port->portnum, port->base_lid, in debug_port()
188 mad_get_field(port->info, 0, IB_PORT_STATE_F), in debug_port()
189 mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F), in debug_port()
196 static int is_mlnx_ext_port_info_supported(ibnd_port_t * port) in is_mlnx_ext_port_info_supported() argument
198 uint16_t devid = (uint16_t) mad_get_field(port->node->info, 0, IB_NODE_DEVID_F); in is_mlnx_ext_port_info_supported()
199 uint32_t vendorid = (uint32_t) mad_get_field(port->node->info, 0, IB_NODE_VENDORID_F); in is_mlnx_ext_port_info_supported()
228 f_internal_t *f_int = ((ibnd_scan_t *) engine->user_data)->f_int; in mlnx_ext_port_info_err()
230 ibnd_port_t *port; in mlnx_ext_port_info_err() local
234 port = node->ports[port_num]; in mlnx_ext_port_info_err()
235 if (!port) { in mlnx_ext_port_info_err()
236 IBND_ERROR("Failed to find 0x%" PRIx64 " port %u\n", in mlnx_ext_port_info_err()
237 node->guid, port_num); in mlnx_ext_port_info_err()
238 return -1; in mlnx_ext_port_info_err()
241 local_port = (uint8_t) mad_get_field(port->info, 0, IB_PORT_LOCAL_PORT_F); in mlnx_ext_port_info_err()
242 debug_port(&smp->path, port); in mlnx_ext_port_info_err()
244 if (port_num && mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F) in mlnx_ext_port_info_err()
246 && ((node->type == IB_NODE_SWITCH && port_num != local_port) || in mlnx_ext_port_info_err()
247 (node == f_int->fabric.from_node && port_num == f_int->fabric.from_portnum))) { in mlnx_ext_port_info_err()
249 ib_portid_t path = smp->path; in mlnx_ext_port_info_err()
251 if (node->type != IB_NODE_SWITCH && in mlnx_ext_port_info_err()
252 node == f_int->fabric.from_node && in mlnx_ext_port_info_err()
257 if (path.lid == 0 || node->type == IB_NODE_SWITCH) in mlnx_ext_port_info_err()
263 cbdata->node = node; in mlnx_ext_port_info_err()
264 cbdata->port_num = port_num; in mlnx_ext_port_info_err()
275 f_internal_t *f_int = ((ibnd_scan_t *) engine->user_data)->f_int; in recv_mlnx_ext_port_info()
277 ibnd_port_t *port; in recv_mlnx_ext_port_info() local
282 port = node->ports[port_num]; in recv_mlnx_ext_port_info()
283 if (!port) { in recv_mlnx_ext_port_info()
284 IBND_ERROR("Failed to find 0x%" PRIx64 " port %u\n", in recv_mlnx_ext_port_info()
285 node->guid, port_num); in recv_mlnx_ext_port_info()
286 return -1; in recv_mlnx_ext_port_info()
289 memcpy(port->ext_info, ext_port_info, sizeof(port->ext_info)); in recv_mlnx_ext_port_info()
290 local_port = (uint8_t) mad_get_field(port->info, 0, IB_PORT_LOCAL_PORT_F); in recv_mlnx_ext_port_info()
291 debug_port(&smp->path, port); in recv_mlnx_ext_port_info()
293 if (port_num && mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F) in recv_mlnx_ext_port_info()
295 && ((node->type == IB_NODE_SWITCH && port_num != local_port) || in recv_mlnx_ext_port_info()
296 (node == f_int->fabric.from_node && port_num == f_int->fabric.from_portnum))) { in recv_mlnx_ext_port_info()
298 ib_portid_t path = smp->path; in recv_mlnx_ext_port_info()
300 if (node->type != IB_NODE_SWITCH && in recv_mlnx_ext_port_info()
301 node == f_int->fabric.from_node && in recv_mlnx_ext_port_info()
306 if (path.lid == 0 || node->type == IB_NODE_SWITCH) in recv_mlnx_ext_port_info()
312 cbdata->node = node; in recv_mlnx_ext_port_info()
313 cbdata->port_num = port_num; in recv_mlnx_ext_port_info()
324 IBND_DEBUG("Query MLNX Extended Port Info; %s (0x%" PRIx64 "):%d\n", in query_mlnx_ext_port_info()
325 portid2str(portid), node->guid, portnum); in query_mlnx_ext_port_info()
333 ibnd_scan_t *scan = (ibnd_scan_t *)engine->user_data; in recv_port_info()
334 f_internal_t *f_int = scan->f_int; in recv_port_info()
336 ibnd_port_t *port; in recv_port_info() local
347 port = node->ports[port_num]; in recv_port_info()
348 if (!port) { in recv_port_info()
349 port = node->ports[port_num] = calloc(1, sizeof(*port)); in recv_port_info()
350 if (!port) { in recv_port_info()
351 IBND_ERROR("Failed to allocate 0x%" PRIx64 " port %u\n", in recv_port_info()
352 node->guid, port_num); in recv_port_info()
353 return -1; in recv_port_info()
355 port->guid = in recv_port_info()
356 mad_get_field64(node->info, 0, IB_NODE_PORT_GUID_F); in recv_port_info()
359 memcpy(port->info, port_info, sizeof(port->info)); in recv_port_info()
360 port->node = node; in recv_port_info()
361 port->portnum = port_num; in recv_port_info()
362 port->ext_portnum = 0; in recv_port_info()
363 port->base_lid = (uint16_t) mad_get_field(port->info, 0, IB_PORT_LID_F); in recv_port_info()
364 port->lmc = (uint8_t) mad_get_field(port->info, 0, IB_PORT_LMC_F); in recv_port_info()
367 node->smalid = port->base_lid; in recv_port_info()
368 node->smalmc = port->lmc; in recv_port_info()
369 } else if (node->type == IB_NODE_SWITCH) { in recv_port_info()
370 port->base_lid = node->smalid; in recv_port_info()
371 port->lmc = node->smalmc; in recv_port_info()
374 int rc1 = add_to_portguid_hash(port, f_int->fabric.portstbl); in recv_port_info()
377 " to insert new port guid 0x%016" PRIx64 " to DB\n", in recv_port_info()
378 port->guid); in recv_port_info()
380 add_to_portlid_hash(port, f_int->lid2guid); in recv_port_info()
382 if ((scan->cfg->flags & IBND_CONFIG_MLX_EPI) in recv_port_info()
383 && is_mlnx_ext_port_info_supported(port)) { in recv_port_info()
384 phystate = mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F); in recv_port_info()
385 ispeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F); in recv_port_info()
386 if (port->node->type == IB_NODE_SWITCH) in recv_port_info()
387 info = (uint8_t *)&port->node->ports[0]->info; in recv_port_info()
389 info = (uint8_t *)&port->info; in recv_port_info()
392 espeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_EXT_ACTIVE_F); in recv_port_info()
399 query_mlnx_ext_port_info(engine, &smp->path, in recv_port_info()
405 debug_port(&smp->path, port); in recv_port_info()
407 if (port_num && mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F) in recv_port_info()
409 && ((node->type == IB_NODE_SWITCH && port_num != local_port) || in recv_port_info()
410 (node == f_int->fabric.from_node && port_num == f_int->fabric.from_portnum))) { in recv_port_info()
413 ib_portid_t path = smp->path; in recv_port_info()
415 if (node->type != IB_NODE_SWITCH && in recv_port_info()
416 node == f_int->fabric.from_node && in recv_port_info()
421 if (path.lid == 0 || node->type == IB_NODE_SWITCH) in recv_port_info()
427 cbdata->node = node; in recv_port_info()
428 cbdata->port_num = port_num; in recv_port_info()
444 for (i = 1; i <= node->numports; i++) in recv_port0_info()
445 query_port_info(engine, &smp->path, node, i); in recv_port0_info()
453 IBND_DEBUG("Query Port Info; %s (0x%" PRIx64 "):%d\n", in query_port_info()
454 portid2str(portid), node->guid, portnum); in query_port_info()
462 f_internal_t *f_int = ((ibnd_scan_t *) engine->user_data)->f_int; in create_node()
470 mad_decode_field(node_info, IB_NODE_GUID_F, &rc->guid); in create_node()
471 mad_decode_field(node_info, IB_NODE_TYPE_F, &rc->type); in create_node()
472 mad_decode_field(node_info, IB_NODE_NPORTS_F, &rc->numports); in create_node()
474 rc->ports = calloc(rc->numports + 1, sizeof(*rc->ports)); in create_node()
475 if (!rc->ports) { in create_node()
481 rc->path_portid = *path; in create_node()
482 memcpy(rc->info, node_info, sizeof(rc->info)); in create_node()
484 int rc1 = add_to_nodeguid_hash(rc, f_int->fabric.nodestbl); in create_node()
488 rc->guid); in create_node()
491 rc->next = f_int->fabric.nodes; in create_node()
492 f_int->fabric.nodes = rc; in create_node()
499 static void link_ports(ibnd_node_t * node, ibnd_port_t * port, in link_ports() argument
502 IBND_DEBUG("linking: 0x%" PRIx64 " %p->%p:%u and 0x%" PRIx64 in link_ports()
503 " %p->%p:%u\n", node->guid, node, port, port->portnum, in link_ports()
504 remotenode->guid, remotenode, remoteport, in link_ports()
505 remoteport->portnum); in link_ports()
506 if (port->remoteport) in link_ports()
507 port->remoteport->remoteport = NULL; in link_ports()
508 if (remoteport->remoteport) in link_ports()
509 remoteport->remoteport->remoteport = NULL; in link_ports()
510 port->remoteport = remoteport; in link_ports()
511 remoteport->remoteport = port; in link_ports()
515 ibnd_node_t * node, ibnd_port_t * port) in dump_endnode() argument
518 mad_dump_node_type(type, sizeof(type), &node->type, sizeof(int)); in dump_endnode()
519 printf("%s -> %s %s {%016" PRIx64 "} portnum %d lid %d-%d \"%s\"\n", in dump_endnode()
520 portid2str(path), prompt, type, node->guid, in dump_endnode()
521 node->type == IB_NODE_SWITCH ? 0 : port->portnum, in dump_endnode()
522 port->base_lid, port->base_lid + (1 << port->lmc) - 1, in dump_endnode()
523 node->nodedesc); in dump_endnode()
529 ibnd_scan_t *scan = engine->user_data; in recv_node_info()
530 f_internal_t *f_int = scan->f_int; in recv_node_info()
540 ibnd_port_t *port = NULL; in recv_node_info() local
543 rem_node = ni_cbdata->node; in recv_node_info()
544 rem_port_num = ni_cbdata->port_num; in recv_node_info()
548 node = ibnd_find_node_guid(&f_int->fabric, node_guid); in recv_node_info()
550 node = create_node(engine, &smp->path, node_info); in recv_node_info()
552 return -1; in recv_node_info()
556 node_is_new ? "new" : "old", node->guid, in recv_node_info()
557 portid2str(&smp->path)); in recv_node_info()
559 port = node->ports[port_num]; in recv_node_info()
560 if (!port) { in recv_node_info()
561 /* If we have not see this port before create a shell for it */ in recv_node_info()
562 port = node->ports[port_num] = calloc(1, sizeof(*port)); in recv_node_info()
563 if (!port) in recv_node_info()
564 return -1; in recv_node_info()
565 port->node = node; in recv_node_info()
566 port->portnum = port_num; in recv_node_info()
568 port->guid = port_guid; in recv_node_info()
570 if (scan->cfg->show_progress) in recv_node_info()
571 dump_endnode(&smp->path, node_is_new ? "new" : "known", in recv_node_info()
572 node, port); in recv_node_info()
575 f_int->fabric.from_node = node; in recv_node_info()
576 f_int->fabric.from_portnum = port_num; in recv_node_info()
579 if (!rem_node->ports[rem_port_num]) { in recv_node_info()
582 " Port %d no port created!?!?!?\n\n", in recv_node_info()
583 rem_node, rem_node->guid, rem_port_num); in recv_node_info()
584 return -1; in recv_node_info()
587 link_ports(node, port, rem_node, rem_node->ports[rem_port_num]); in recv_node_info()
591 query_node_desc(engine, &smp->path, node); in recv_node_info()
593 if (node->type == IB_NODE_SWITCH) { in recv_node_info()
594 query_switch_info(engine, &smp->path, node); in recv_node_info()
595 /* Query PortInfo on Switch Port 0 first */ in recv_node_info()
596 query_port_info(engine, &smp->path, node, 0); in recv_node_info()
600 if (node->type != IB_NODE_SWITCH) in recv_node_info()
601 query_port_info(engine, &smp->path, node, port_num); in recv_node_info()
624 for (node = fabric->nodestbl[hash]; node; node = node->htnext) in ibnd_find_node_guid()
625 if (node->guid == guid) in ibnd_find_node_guid()
634 return rc->node; in ibnd_find_node_dr()
641 int hash_idx = HASHGUID(node->guid) % HTSZ; in add_to_nodeguid_hash()
643 for (tblnode = hash[hash_idx]; tblnode; tblnode = tblnode->htnext) { in add_to_nodeguid_hash()
647 node->guid); in add_to_nodeguid_hash()
651 node->htnext = hash[hash_idx]; in add_to_nodeguid_hash()
656 int add_to_portguid_hash(ibnd_port_t * port, ibnd_port_t * hash[]) in add_to_portguid_hash() argument
660 int hash_idx = HASHGUID(port->guid) % HTSZ; in add_to_portguid_hash()
662 for (tblport = hash[hash_idx]; tblport; tblport = tblport->htnext) { in add_to_portguid_hash()
663 if (tblport == port) { in add_to_portguid_hash()
664 IBND_ERROR("Duplicate Port: Port with guid 0x%016" in add_to_portguid_hash()
666 port->guid); in add_to_portguid_hash()
670 port->htnext = hash[hash_idx]; in add_to_portguid_hash()
671 hash[hash_idx] = port; in add_to_portguid_hash()
677 f_int->lid2guid = g_hash_table_new_full(g_direct_hash, g_direct_equal, in create_lid2guid()
683 if (f_int->lid2guid) { in destroy_lid2guid()
684 g_hash_table_destroy(f_int->lid2guid); in destroy_lid2guid()
688 void add_to_portlid_hash(ibnd_port_t * port, GHashTable *htable) in add_to_portlid_hash() argument
690 uint16_t base_lid = port->base_lid; in add_to_portlid_hash()
691 uint16_t lid_mask = ((1 << port->lmc) -1); in add_to_portlid_hash()
695 /* We add the port for all lids in add_to_portlid_hash()
698 g_hash_table_insert(htable, GINT_TO_POINTER(lid), port); in add_to_portlid_hash()
705 ibnd_fabric_t *fabric = &f_int->fabric; in add_to_type_list()
706 switch (node->type) { in add_to_type_list()
708 node->type_next = fabric->ch_adapters; in add_to_type_list()
709 fabric->ch_adapters = node; in add_to_type_list()
712 node->type_next = fabric->switches; in add_to_type_list()
713 fabric->switches = node; in add_to_type_list()
716 node->type_next = fabric->routers; in add_to_type_list()
717 fabric->routers = node; in add_to_type_list()
722 static int set_config(struct ibnd_config *config, struct ibnd_config *cfg) in set_config() argument
724 if (!config) in set_config()
725 return (-EINVAL); in set_config()
728 memcpy(config, cfg, sizeof(*config)); in set_config()
730 if (!config->max_smps) in set_config()
731 config->max_smps = DEFAULT_MAX_SMP_ON_WIRE; in set_config()
732 if (!config->timeout_ms) in set_config()
733 config->timeout_ms = DEFAULT_TIMEOUT; in set_config()
734 if (!config->retries) in set_config()
735 config->retries = DEFAULT_RETRIES; in set_config()
753 struct ibnd_config config = { 0 }; in ibnd_discover_fabric() local
762 /* If not specified start from "my" port */ in ibnd_discover_fabric()
766 if (set_config(&config, cfg)) { in ibnd_discover_fabric()
779 scan.cfg = &config; in ibnd_discover_fabric()
780 scan.initial_hops = from->drpath.cnt; in ibnd_discover_fabric()
784 IBND_ERROR("can't open MAD port (%s:%d)\n", ca_name, ca_port); in ibnd_discover_fabric()
787 mad_rpc_set_timeout(ibmad_port, cfg->timeout_ms); in ibnd_discover_fabric()
788 mad_rpc_set_retries(ibmad_port, cfg->retries); in ibnd_discover_fabric()
789 smp_mkey_set(ibmad_port, cfg->mkey); in ibnd_discover_fabric()
799 if (smp_engine_init(&engine, ca_name, ca_port, &scan, &config)) { in ibnd_discover_fabric()
810 f_int->fabric.total_mads_used = engine.total_smps; in ibnd_discover_fabric()
811 f_int->fabric.maxhops_discovered += scan.initial_hops; in ibnd_discover_fabric()
813 if (group_nodes(&f_int->fabric)) in ibnd_discover_fabric()
820 ibnd_destroy_fabric(&f_int->fabric); in ibnd_discover_fabric()
828 if (node->ports) { in destroy_node()
829 for (p = 0; p <= node->numports; p++) in destroy_node()
830 free(node->ports[p]); in destroy_node()
831 free(node->ports); in destroy_node()
845 ch = fabric->chassis; in ibnd_destroy_fabric()
847 ch_next = ch->next; in ibnd_destroy_fabric()
851 node = fabric->nodes; in ibnd_destroy_fabric()
853 next = node->next; in ibnd_destroy_fabric()
876 for (cur = fabric->nodes; cur; cur = cur->next) in ibnd_iter_nodes()
898 list = fabric->switches; in ibnd_iter_nodes_type()
901 list = fabric->ch_adapters; in ibnd_iter_nodes_type()
904 list = fabric->routers; in ibnd_iter_nodes_type()
911 for (cur = list; cur; cur = cur->type_next) in ibnd_iter_nodes_type()
918 ibnd_port_t *port; in ibnd_find_port_lid() local
921 port = (ibnd_port_t *)g_hash_table_lookup(f->lid2guid, in ibnd_find_port_lid()
924 return port; in ibnd_find_port_lid()
930 ibnd_port_t *port; in ibnd_find_port_guid() local
937 for (port = fabric->portstbl[hash]; port; port = port->htnext) in ibnd_find_port_guid()
938 if (port->guid == guid) in ibnd_find_port_guid()
939 return port; in ibnd_find_port_guid()
961 cur_node = fabric->from_node; in ibnd_find_port_dr()
963 if (str2drpath(&path, dr_str, 0, 0) == -1) in ibnd_find_port_dr()
970 if (!cur_node->ports) in ibnd_find_port_dr()
973 remote_port = cur_node->ports[path.p[i]]->remoteport; in ibnd_find_port_dr()
978 cur_node = remote_port->node; in ibnd_find_port_dr()
1001 for (cur = fabric->portstbl[i]; cur; cur = cur->htnext) in ibnd_iter_ports()