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; }
void handle_dump(queue_t *q, mblk_t *mp) { struct ctrl_args *ctrl_args; struct ctrl_device *ctrlfd; minor_t minor; int sum; unsigned char *buf; if ((mp->b_cont = allocb(MAXPRINTBUF, BPRI_MED)) == NULL) { printf("handle_ctrl: out of message blocks\n"); qreply(q, mp); return; } buf = DB_BASE(mp->b_cont); sum = rpc_dump(buf, buf + MAXPRINTBUF); sum += port_dump(buf + sum, buf + MAXPRINTBUF); sum += kid_dump(buf + sum, buf + MAXPRINTBUF); sum += flip_netdump(buf + sum, buf + MAXPRINTBUF); sum += int_dump(buf + sum, buf + MAXPRINTBUF); sum += adr_dump(buf + sum, buf + MAXPRINTBUF); sum += ff_dump(buf + sum, buf + MAXPRINTBUF); mp->b_cont->b_rptr = DB_BASE(mp->b_cont); mp->b_cont->b_wptr = mp->b_cont->b_rptr + sum; ctrl_args = (struct ctrl_args *) DB_BASE(mp); ctrl_args->ctrl_status = sum; mp->b_rptr = DB_BASE(mp); mp->b_wptr = mp->b_rptr + sizeof(struct ctrl_args); DB_TYPE(mp) = M_PROTO; qreply(q, mp); }