/*
* Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
IB_DRSMP_RPATH_F,
/*
- * PortInfo fields:
+ * PortInfo fields
*/
IB_PORT_FIRST_F,
IB_PORT_MKEY_F = IB_PORT_FIRST_F,
IB_PORT_LAST_F,
/*
- * NodeInfo fields:
+ * NodeInfo fields
*/
IB_NODE_FIRST_F,
IB_NODE_BASE_VERS_F = IB_NODE_FIRST_F,
IB_NODE_LAST_F,
/*
- * SwitchInfo fields:
+ * SwitchInfo fields
*/
IB_SW_FIRST_F,
IB_SW_LINEAR_FDB_CAP_F = IB_SW_FIRST_F,
IB_SW_LAST_F,
/*
- * SwitchLinearForwardingTable fields:
+ * SwitchLinearForwardingTable fields
*/
IB_LINEAR_FORW_TBL_F,
/*
- * SwitchMulticastForwardingTable fields:
+ * SwitchMulticastForwardingTable fields
*/
IB_MULTICAST_FORW_TBL_F,
/*
- * NodeDescription fields:
+ * NodeDescription fields
*/
IB_NODE_DESC_F,
*/
IB_GUID_GUID0_F,
+ /*
+ * ClassPortInfo fields
+ */
+ IB_CPI_BASEVER_F,
+ IB_CPI_CLASSVER_F,
+ IB_CPI_CAPMASK_F,
+ IB_CPI_CAPMASK2_F,
+ IB_CPI_RESP_TIME_VALUE_F,
+ IB_CPI_REDIRECT_GID_F,
+ IB_CPI_REDIRECT_TC_F,
+ IB_CPI_REDIRECT_SL_F,
+ IB_CPI_REDIRECT_FL_F,
+ IB_CPI_REDIRECT_LID_F,
+ IB_CPI_REDIRECT_PKEY_F,
+ IB_CPI_REDIRECT_QP_F,
+ IB_CPI_REDIRECT_QKEY_F,
+ IB_CPI_TRAP_GID_F,
+ IB_CPI_TRAP_TC_F,
+ IB_CPI_TRAP_SL_F,
+ IB_CPI_TRAP_FL_F,
+ IB_CPI_TRAP_LID_F,
+ IB_CPI_TRAP_PKEY_F,
+ IB_CPI_TRAP_HL_F,
+ IB_CPI_TRAP_QP_F,
+ IB_CPI_TRAP_QKEY_F,
+
IB_FIELD_LAST_ /* must be last */
};
#define MAD_DEF_RETRIES 3
#define MAD_DEF_TIMEOUT_MS 1000
-enum {
+enum MAD_DEST {
IB_DEST_LID,
IB_DEST_DRPATH,
IB_DEST_GUID,
IB_DEST_DRSLID,
};
-enum {
+enum MAD_NODE_TYPE {
IB_NODE_CA = 1,
IB_NODE_SWITCH,
IB_NODE_ROUTER,
}
/* fields.c */
-MAD_EXPORT uint32_t mad_get_field(void *buf, int base_offs, int field);
-MAD_EXPORT void mad_set_field(void *buf, int base_offs, int field,
+MAD_EXPORT uint32_t mad_get_field(void *buf, int base_offs, enum MAD_FIELDS field);
+MAD_EXPORT void mad_set_field(void *buf, int base_offs, enum MAD_FIELDS field,
uint32_t val);
/* field must be byte aligned */
-MAD_EXPORT uint64_t mad_get_field64(void *buf, int base_offs, int field);
-MAD_EXPORT void mad_set_field64(void *buf, int base_offs, int field,
+MAD_EXPORT uint64_t mad_get_field64(void *buf, int base_offs, enum MAD_FIELDS field);
+MAD_EXPORT void mad_set_field64(void *buf, int base_offs, enum MAD_FIELDS field,
uint64_t val);
-MAD_EXPORT void mad_set_array(void *buf, int base_offs, int field, void *val);
-MAD_EXPORT void mad_get_array(void *buf, int base_offs, int field, void *val);
-MAD_EXPORT void mad_decode_field(uint8_t * buf, int field, void *val);
-MAD_EXPORT void mad_encode_field(uint8_t * buf, int field, void *val);
-MAD_EXPORT int mad_print_field(int field, const char *name, void *val);
-MAD_EXPORT char *mad_dump_field(int field, char *buf, int bufsz, void *val);
-MAD_EXPORT char *mad_dump_val(int field, char *buf, int bufsz, void *val);
+MAD_EXPORT void mad_set_array(void *buf, int base_offs, enum MAD_FIELDS field, void *val);
+MAD_EXPORT void mad_get_array(void *buf, int base_offs, enum MAD_FIELDS field, void *val);
+MAD_EXPORT void mad_decode_field(uint8_t * buf, enum MAD_FIELDS field, void *val);
+MAD_EXPORT void mad_encode_field(uint8_t * buf, enum MAD_FIELDS field, void *val);
+MAD_EXPORT int mad_print_field(enum MAD_FIELDS field, const char *name, void *val);
+MAD_EXPORT char *mad_dump_field(enum MAD_FIELDS field, char *buf, int bufsz, void *val);
+MAD_EXPORT char *mad_dump_val(enum MAD_FIELDS field, char *buf, int bufsz, void *val);
/* mad.c */
MAD_EXPORT void *mad_encode(void *buf, ib_rpc_t * rpc, ib_dr_path_t * drpath,
unsigned mod, unsigned timeout);
MAD_EXPORT uint8_t *smp_set(void *buf, ib_portid_t * id, unsigned attrid,
unsigned mod, unsigned timeout);
-MAD_EXPORT uint8_t *smp_query_via(void *buf, ib_portid_t * id, unsigned attrid,
+uint8_t *smp_query_via(void *buf, ib_portid_t * id, unsigned attrid,
unsigned mod, unsigned timeout, const void *srcport);
uint8_t *smp_set_via(void *buf, ib_portid_t * id, unsigned attrid, unsigned mod,
unsigned timeout, const void *srcport);
MAD_EXPORT int ib_resolve_guid(ib_portid_t * portid, uint64_t * guid,
ib_portid_t * sm_id, int timeout);
MAD_EXPORT int ib_resolve_portid_str(ib_portid_t * portid, char *addr_str,
- int dest_type, ib_portid_t * sm_id);
+ enum MAD_DEST dest, ib_portid_t * sm_id);
MAD_EXPORT int ib_resolve_self(ib_portid_t * portid, int *portnum,
ibmad_gid_t * gid);
int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
ib_portid_t * sm_id, int timeout, const void *srcport);
int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
- int dest_type, ib_portid_t * sm_id,
+ enum MAD_DEST dest, ib_portid_t * sm_id,
const void *srcport);
int ib_resolve_self_via(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid,
const void *srcport);
exit(-1); \
} while(0)
-MAD_EXPORT void xdump(FILE * file, char *msg, void *p, int size);
+void xdump(FILE * file, char *msg, void *p, int size);
END_C_DECLS
#endif /* _MAD_H_ */
{
switch (valsz) {
case 1:
- snprintf(buf, bufsz, "%d", *(uint8_t *) val);
+ snprintf(buf, bufsz, "%d", *(uint32_t *) val & 0xff);
break;
case 2:
- snprintf(buf, bufsz, "%d", *(uint16_t *) val);
+ snprintf(buf, bufsz, "%d", *(uint32_t *) val & 0xffff);
break;
case 3:
case 4:
{
switch (valsz) {
case 1:
- snprintf(buf, bufsz, "%u", *(uint8_t *) val);
+ snprintf(buf, bufsz, "%u", *(uint32_t *) val & 0xff);
break;
case 2:
- snprintf(buf, bufsz, "%u", *(uint16_t *) val);
+ snprintf(buf, bufsz, "%u", *(uint32_t *) val & 0xffff);
break;
case 3:
case 4:
{
switch (valsz) {
case 1:
- snprintf(buf, bufsz, "0x%02x", *(uint8_t *) val);
+ snprintf(buf, bufsz, "0x%02x", *(uint32_t *) val & 0xff);
break;
case 2:
- snprintf(buf, bufsz, "0x%04x", *(uint16_t *) val);
+ snprintf(buf, bufsz, "0x%04x", *(uint32_t *) val & 0xffff);
break;
case 3:
snprintf(buf, bufsz, "0x%06x", *(uint32_t *) val & 0xffffff);
{
switch (valsz) {
case 1:
- snprintf(buf, bufsz, "%02x", *(uint8_t *) val);
+ snprintf(buf, bufsz, "%02x", *(uint32_t *) val & 0xff);
break;
case 2:
- snprintf(buf, bufsz, "%04x", *(uint16_t *) val);
+ snprintf(buf, bufsz, "%04x", *(uint32_t *) val & 0xffff);
break;
case 3:
snprintf(buf, bufsz, "%06x", *(uint32_t *) val & 0xffffff);
/*
* Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
{160, 32, "MadModifier", mad_dump_hex}, /* TODO: add dumper */
/* word 7,8 (24-31 bytes) */
- {196, 64, "MadMkey", mad_dump_hex},
+ {192, 64, "MadMkey", mad_dump_hex},
/* word 9 (32-37 bytes) */
{BE_OFFS(256, 16), "DrSmpDLID", mad_dump_hex},
{1536, 512, "DrSmpRetPath", mad_dump_hex},
/*
- * PortInfo fields:
+ * PortInfo fields
*/
{0, 64, "Mkey", mad_dump_hex},
{64, 64, "GidPrefix", mad_dump_hex},
{0, 0}, /* IB_PORT_LAST_F */
/*
- * NodeInfo fields:
+ * NodeInfo fields
*/
{BITSOFFS(0, 8), "BaseVers", mad_dump_uint},
{BITSOFFS(8, 8), "ClassVers", mad_dump_uint},
{0, 0}, /* IB_NODE_LAST_F */
/*
- * SwitchInfo fields:
+ * SwitchInfo fields
*/
{BITSOFFS(0, 16), "LinearFdbCap", mad_dump_uint},
{BITSOFFS(16, 16), "RandomFdbCap", mad_dump_uint},
{0, 0}, /* IB_SW_LAST_F */
/*
- * SwitchLinearForwardingTable fields:
+ * SwitchLinearForwardingTable fields
*/
{0, 512, "LinearForwTbl", mad_dump_array},
/*
- * SwitchMulticastForwardingTable fields:
+ * SwitchMulticastForwardingTable fields
*/
{0, 512, "MulticastForwTbl", mad_dump_array},
/*
- * NodeDescription fields:
+ * NodeDescription fields
*/
{0, 64 * 8, "NodeDesc", mad_dump_string},
* GUIDInfo fields
*/
{0, 64, "GUID0", mad_dump_hex},
+
+ /*
+ * ClassPortInfo fields
+ */
+ {BITSOFFS(0, 8), "BaseVersion", mad_dump_uint},
+ {BITSOFFS(8, 8), "ClassVersion", mad_dump_uint},
+ {BITSOFFS(16, 16), "CapabilityMask", mad_dump_hex},
+ {BITSOFFS(32, 27), "CapabilityMask2", mad_dump_hex},
+ {BITSOFFS(59, 5), "RespTimeVal", mad_dump_uint},
+ {64, 128, "RedirectGID", mad_dump_array},
+ {BITSOFFS(192, 8), "RedirectTC", mad_dump_hex},
+ {BITSOFFS(200, 4), "RedirectSL", mad_dump_uint},
+ {BITSOFFS(204, 20), "RedirectFL", mad_dump_hex},
+ {BITSOFFS(224, 16), "RedirectLID", mad_dump_hex},
+ {BITSOFFS(240, 16), "RedirectPKey", mad_dump_hex},
+ {BITSOFFS(264, 24), "RedirectQP", mad_dump_hex},
+ {288, 32, "RedirectQKey", mad_dump_hex},
+ {320, 128, "TrapGID", mad_dump_array},
+ {BITSOFFS(448, 8), "TrapTC", mad_dump_hex},
+ {BITSOFFS(456, 4), "TrapSL", mad_dump_uint},
+ {BITSOFFS(460, 20), "TrapFL", mad_dump_hex},
+ {BITSOFFS(480, 16), "TrapLID", mad_dump_hex},
+ {BITSOFFS(496, 16), "TrapPKey", mad_dump_hex},
+ {BITSOFFS(512, 8), "TrapHL", mad_dump_uint},
+ {BITSOFFS(520, 24), "TrapQP", mad_dump_hex},
+ {544, 32, "TrapQKey", mad_dump_hex},
+
{0, 0} /* IB_FIELD_LAST_ */
};
memcpy(val, (uint8_t *) buf + base_offs + bitoffs / 8, f->bitlen / 8);
}
-uint32_t mad_get_field(void *buf, int base_offs, int field)
+uint32_t mad_get_field(void *buf, int base_offs, enum MAD_FIELDS field)
{
return _get_field(buf, base_offs, ib_mad_f + field);
}
-void mad_set_field(void *buf, int base_offs, int field, uint32_t val)
+void mad_set_field(void *buf, int base_offs, enum MAD_FIELDS field, uint32_t val)
{
_set_field(buf, base_offs, ib_mad_f + field, val);
}
-uint64_t mad_get_field64(void *buf, int base_offs, int field)
+uint64_t mad_get_field64(void *buf, int base_offs, enum MAD_FIELDS field)
{
return _get_field64(buf, base_offs, ib_mad_f + field);
}
-void mad_set_field64(void *buf, int base_offs, int field, uint64_t val)
+void mad_set_field64(void *buf, int base_offs, enum MAD_FIELDS field, uint64_t val)
{
_set_field64(buf, base_offs, ib_mad_f + field, val);
}
-void mad_set_array(void *buf, int base_offs, int field, void *val)
+void mad_set_array(void *buf, int base_offs, enum MAD_FIELDS field, void *val)
{
_set_array(buf, base_offs, ib_mad_f + field, val);
}
-void mad_get_array(void *buf, int base_offs, int field, void *val)
+void mad_get_array(void *buf, int base_offs, enum MAD_FIELDS field, void *val)
{
_get_array(buf, base_offs, ib_mad_f + field, val);
}
-void mad_decode_field(uint8_t * buf, int field, void *val)
+void mad_decode_field(uint8_t * buf, enum MAD_FIELDS field, void *val)
{
const ib_field_t *f = ib_mad_f + field;
_get_array(buf, 0, f, val);
}
-void mad_encode_field(uint8_t * buf, int field, void *val)
+void mad_encode_field(uint8_t * buf, enum MAD_FIELDS field, void *val)
{
const ib_field_t *f = ib_mad_f + field;
valsz ? valsz : ALIGN(f->bitlen, 8) / 8);
}
-int mad_print_field(int field, const char *name, void *val)
+int mad_print_field(enum MAD_FIELDS field, const char *name, void *val)
{
if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
return -1;
return _mad_print_field(ib_mad_f + field, name, val, 0);
}
-char *mad_dump_field(int field, char *buf, int bufsz, void *val)
+char *mad_dump_field(enum MAD_FIELDS field, char *buf, int bufsz, void *val)
{
if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
return 0;
return _mad_dump_field(ib_mad_f + field, 0, buf, bufsz, val);
}
-char *mad_dump_val(int field, char *buf, int bufsz, void *val)
+char *mad_dump_val(enum MAD_FIELDS field, char *buf, int bufsz, void *val)
{
if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
return 0;
ib_rpc_t rpc = { 0 };
int lid = dest->lid;
- DEBUG("lid %d port %d", lid, port);
+ DEBUG("lid %u port %d", lid, port);
if (lid == -1) {
IBWARN("only lid routed is supported");
ib_rpc_t rpc = { 0 };
int lid = dest->lid;
- DEBUG("lid %d port %d mask 0x%x", lid, port, mask);
+ DEBUG("lid %u port %d mask 0x%x", lid, port, mask);
if (lid == -1) {
IBWARN("only lid routed is supported");
--- /dev/null
+IBMAD_1.3 {
+ global:
+ xdump;
+ mad_dump_field;
+ mad_dump_val;
+ mad_print_field;
+ mad_dump_array;
+ mad_dump_bitfield;
+ mad_dump_hex;
+ mad_dump_int;
+ mad_dump_linkdowndefstate;
+ mad_dump_linkspeed;
+ mad_dump_linkspeeden;
+ mad_dump_linkspeedsup;
+ mad_dump_linkwidth;
+ mad_dump_linkwidthen;
+ mad_dump_linkwidthsup;
+ mad_dump_mtu;
+ mad_dump_node_type;
+ mad_dump_nodedesc;
+ mad_dump_nodeinfo;
+ mad_dump_opervls;
+ mad_dump_perfcounters;
+ mad_dump_perfcounters_ext;
+ mad_dump_physportstate;
+ mad_dump_portcapmask;
+ mad_dump_portinfo;
+ mad_dump_portstates;
+ mad_dump_portstate;
+ mad_dump_rhex;
+ mad_dump_sltovl;
+ mad_dump_string;
+ mad_dump_switchinfo;
+ mad_dump_uint;
+ mad_dump_vlarbitration;
+ mad_dump_vlcap;
+ mad_get_field;
+ mad_set_field;
+ mad_get_field64;
+ mad_set_field64;
+ mad_get_array;
+ mad_set_array;
+ perf_classportinfo_query;
+ port_performance_query;
+ port_performance_reset;
+ port_performance_ext_query;
+ port_performance_ext_reset;
+ port_samples_control_query;
+ port_samples_result_query;
+ mad_build_pkt;
+ mad_decode_field;
+ mad_encode;
+ mad_encode_field;
+ mad_trid;
+ portid2portnum;
+ portid2str;
+ str2drpath;
+ drpath2str;
+ mad_agent_class;
+ mad_class_agent;
+ mad_register_client;
+ mad_register_server;
+ ib_resolve_guid;
+ ib_resolve_portid_str;
+ ib_resolve_self;
+ ib_resolve_smlid;
+ ibdebug;
+ mad_rpc_open_port;
+ mad_rpc_close_port;
+ mad_rpc;
+ mad_rpc_rmpp;
+ madrpc;
+ madrpc_def_timeout;
+ madrpc_init;
+ madrpc_portid;
+ madrpc_rmpp;
+ madrpc_save_mad;
+ madrpc_set_retries;
+ madrpc_set_timeout;
+ madrpc_show_errors;
+ ib_path_query;
+ sa_call;
+ sa_rpc_call;
+ mad_alloc;
+ mad_free;
+ mad_receive;
+ mad_respond;
+ mad_send;
+ smp_query;
+ smp_set;
+ ib_vendor_call;
+ smp_query_via;
+ smp_set_via;
+ ib_path_query_via;
+ ib_resolve_smlid_via;
+ ib_resolve_guid_via;
+ ib_resolve_portid_str_via;
+ ib_resolve_self_via;
+ perf_classportinfo_query_via;
+ port_performance_query_via;
+ port_performance_reset_via;
+ port_performance_ext_query_via;
+ port_performance_ext_reset_via;
+ port_samples_control_query_via;
+ port_samples_result_query_via;
+ local: *;
+};
mad_set_field(buf, 0, IB_MAD_ATTRMOD_F, rpc->attr.mod);
/* words 7,8 */
- mad_set_field(buf, 0, IB_MAD_MKEY_F, (uint32_t) (rpc->mkey >> 32));
- mad_set_field(buf, 4, IB_MAD_MKEY_F,
- (uint32_t) (rpc->mkey & 0xffffffff));
+ mad_set_field64(buf, 0, IB_MAD_MKEY_F, rpc->mkey);
if (rpc->mgtclass == IB_SMI_DIRECT_CLASS) {
/* word 9 */
char *drpath2str(ib_dr_path_t * path, char *dstr, size_t dstr_size)
{
int i = 0;
- int rc = snprintf(dstr, dstr_size, "slid %d; dlid %d; %d",
+ int rc = snprintf(dstr, dstr_size, "slid %u; dlid %u; %d",
path->drslid, path->drdlid, path->p[0]);
if (rc >= (int)dstr_size)
return dstr;
}
int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
- int dest_type, ib_portid_t * sm_id,
+ enum MAD_DEST dest_type, ib_portid_t * sm_id,
const void *srcport)
{
uint64_t guid;
return -1;
}
-int ib_resolve_portid_str(ib_portid_t * portid, char *addr_str, int dest_type,
- ib_portid_t * sm_id)
+int ib_resolve_portid_str(ib_portid_t * portid, char *addr_str,
+ enum MAD_DEST dest_type, ib_portid_t * sm_id)
{
return ib_resolve_portid_str_via(portid, addr_str, dest_type,
sm_id, NULL);