static int ca_stat(char *ca_name, int portnum, int no_ports) { umad_ca_t ca; int r; if ((r = umad_get_ca(ca_name, &ca)) < 0) return r; if (!ca.node_type) return 0; if (!no_ports && portnum >= 0) { if (portnum > ca.numports || !ca.ports[portnum]) { IBWARN("%s: '%s' has no port number %d - max (%d)", ((uint)ca.node_type <= IB_NODE_MAX ? node_type_str[ca.node_type] : "???"), ca_name, portnum, ca.numports); return -1; } printf("%s: '%s'\n", ((uint)ca.node_type <= IB_NODE_MAX ? node_type_str[ca.node_type] : "???"), ca.ca_name); port_dump(ca.ports[portnum], 1); return 0; } /* print ca header */ ca_dump(&ca); if (no_ports) return 0; for (portnum = 0; portnum <= ca.numports; portnum++) port_dump(ca.ports[portnum], 0); return 0; }
/// For debugging support - dumps contents of a CA to stderr /// @param[in] ca the object pointer /*static*/ void ca_dump(ca_o ca) { CCS hdr; CCS stars = "******************************************************\n"; CCS subsep = "@@@@@@@@@@@\n"; assert(ca); fputs(stars, stderr); hdr = ca_format_header(ca); fputs(hdr, stderr); putil_free(hdr); if (ca->ca_raw_pa_dict) { (void)ca_foreach_raw_pa(ca, _ca_dump_pa, "RAW: "); } if (ca->ca_cooked_pa_dict) { (void)ca_foreach_cooked_pa(ca, _ca_dump_pa, "COOKED: "); } if (ca->ca_group_hash) { hscan_t hscan; hnode_t *hnp; hash_scan_begin(&hscan, ca->ca_group_hash); for (hnp = hash_scan_next(&hscan); hnp; hnp = hash_scan_next(&hscan)) { ca_o sub; fputs(subsep, stderr); sub = (ca_o)hnode_get(hnp); ca_dump(sub); } } fputs(stars, stderr); }