static int send_144_node_desc_update(void) { ib_portid_t sm_port; ib_portid_t selfportid; int selfport; ib_rpc_t trap_rpc; ib_mad_notice_attr_t notice; if (ib_resolve_self(&selfportid, &selfport, NULL)) IBERROR("can't resolve self"); if (ib_resolve_smlid(&sm_port, 0)) IBERROR("can't resolve SM destination port"); memset(&trap_rpc, 0, sizeof(trap_rpc)); trap_rpc.mgtclass = IB_SMI_CLASS; trap_rpc.method = IB_MAD_METHOD_TRAP; trap_rpc.trid = mad_trid(); trap_rpc.attr.id = NOTICE; trap_rpc.datasz = IB_SMP_DATA_SIZE; trap_rpc.dataoffs = IB_SMP_DATA_OFFS; memset(¬ice, 0, sizeof(notice)); notice.generic_type = 0x80 | IB_NOTICE_TYPE_INFO; notice.g_or_v.generic.prod_type_lsb = cl_hton16(IB_NODE_TYPE_CA); notice.g_or_v.generic.trap_num = cl_hton16(144); notice.issuer_lid = cl_hton16(selfportid.lid); notice.data_details.ntc_144.lid = cl_hton16(selfportid.lid); notice.data_details.ntc_144.local_changes = TRAP_144_MASK_OTHER_LOCAL_CHANGES; notice.data_details.ntc_144.change_flgs = TRAP_144_MASK_NODE_DESCRIPTION_CHANGE; return (mad_send(&trap_rpc, &sm_port, NULL, ¬ice)); }
int ib_path_query_via(const struct ibmad_port *srcport, ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf) { ib_sa_call_t sa = { 0 }; uint8_t *p; int dlid; memset(&sa, 0, sizeof sa); sa.method = IB_MAD_METHOD_GET; sa.attrid = IB_SA_ATTR_PATHRECORD; sa.mask = IB_PR_DEF_MASK; sa.trid = mad_trid(); memset(buf, 0, IB_SA_PR_RECSZ); mad_encode_field(buf, IB_SA_PR_DGID_F, destgid); mad_encode_field(buf, IB_SA_PR_SGID_F, srcgid); p = sa_rpc_call(srcport, buf, sm_id, &sa, 0); if (!p) { IBWARN("sa call path_query failed"); return -1; } mad_decode_field(p, IB_SA_PR_DLID_F, &dlid); return dlid; }
static int send_trap(const char *name, void (*build) (ib_mad_notice_attr_t *, ib_portid_t *)) { ib_portid_t sm_port; ib_portid_t selfportid; int selfport; ib_rpc_t trap_rpc; ib_mad_notice_attr_t notice; if (resolve_self(ibd_ca, ibd_ca_port, &selfportid, &selfport, NULL)) IBEXIT("can't resolve self"); if (resolve_sm_portid(ibd_ca, ibd_ca_port, &sm_port)) IBEXIT("can't resolve SM destination port"); memset(&trap_rpc, 0, sizeof(trap_rpc)); trap_rpc.mgtclass = IB_SMI_CLASS; trap_rpc.method = IB_MAD_METHOD_TRAP; trap_rpc.trid = mad_trid(); trap_rpc.attr.id = NOTICE; trap_rpc.datasz = IB_SMP_DATA_SIZE; trap_rpc.dataoffs = IB_SMP_DATA_OFFS; memset(¬ice, 0, sizeof(notice)); build(¬ice, &selfportid); return mad_send_via(&trap_rpc, &sm_port, NULL, ¬ice, srcport); }
int ib_node_query_via(const struct ibmad_port *srcport, uint64_t guid, ib_portid_t * sm_id, void *buf) { ib_sa_call_t sa = { 0 }; uint8_t *p; memset(&sa, 0, sizeof sa); sa.method = IB_MAD_METHOD_GET; sa.attrid = IB_SA_ATTR_NODERECORD; sa.mask = IB_NR_DEF_MASK; sa.trid = mad_trid(); memset(buf, 0, IB_SA_NR_RECSZ); mad_encode_field(buf, IB_SA_NR_PORT_GUID_F, &guid); p = sa_rpc_call(srcport, buf, sm_id, &sa, 0); if (!p) { IBWARN("sa call node_query failed"); return -1; } return 0; }