From 0218df553c02ee15fc9e75d27bca7a948fab5323 Mon Sep 17 00:00:00 2001 From: shefty Date: Fri, 23 Jan 2009 21:36:36 +0000 Subject: [PATCH] libibmad: sync with linux Signed-off-by: Sean Hefty git-svn-id: svn://openib.tc.cornell.edu/gen1@1867 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- .../ulp/libibmad/include/infiniband/mad.h | 353 +++++++++--------- branches/winverbs/ulp/libibmad/src/dump.c | 239 ++++++------ branches/winverbs/ulp/libibmad/src/fields.c | 212 ++++++----- branches/winverbs/ulp/libibmad/src/gs.c | 119 +++--- branches/winverbs/ulp/libibmad/src/mad.c | 44 ++- branches/winverbs/ulp/libibmad/src/portid.c | 29 +- branches/winverbs/ulp/libibmad/src/register.c | 54 ++- branches/winverbs/ulp/libibmad/src/resolve.c | 56 +-- branches/winverbs/ulp/libibmad/src/rpc.c | 82 ++-- branches/winverbs/ulp/libibmad/src/sa.c | 27 +- branches/winverbs/ulp/libibmad/src/serv.c | 36 +- branches/winverbs/ulp/libibmad/src/smp.c | 30 +- branches/winverbs/ulp/libibmad/src/vendor.c | 33 +- 13 files changed, 647 insertions(+), 667 deletions(-) diff --git a/branches/winverbs/ulp/libibmad/include/infiniband/mad.h b/branches/winverbs/ulp/libibmad/include/infiniband/mad.h index b6c75e3f..9ff4a3eb 100644 --- a/branches/winverbs/ulp/libibmad/include/infiniband/mad.h +++ b/branches/winverbs/ulp/libibmad/include/infiniband/mad.h @@ -33,82 +33,72 @@ #ifndef _MAD_H_ #define _MAD_H_ -#include - - - +#include #ifdef __cplusplus # define BEGIN_C_DECLS extern "C" { # define END_C_DECLS } -#else /* !__cplusplus */ +#else /* !__cplusplus */ # define BEGIN_C_DECLS # define END_C_DECLS -#endif /* __cplusplus */ +#endif /* __cplusplus */ BEGIN_C_DECLS #define IB_SUBNET_PATH_HOPS_MAX 64 #define IB_DEFAULT_SUBN_PREFIX 0xfe80000000000000ULL #define IB_DEFAULT_QP1_QKEY 0x80010000 - #define IB_MAD_SIZE 256 - #define IB_SMP_DATA_OFFS 64 #define IB_SMP_DATA_SIZE 64 - #define IB_VENDOR_RANGE1_DATA_OFFS 24 #define IB_VENDOR_RANGE1_DATA_SIZE (IB_MAD_SIZE - IB_VENDOR_RANGE1_DATA_OFFS) - #define IB_VENDOR_RANGE2_DATA_OFFS 40 #define IB_VENDOR_RANGE2_DATA_SIZE (IB_MAD_SIZE - IB_VENDOR_RANGE2_DATA_OFFS) - #define IB_SA_DATA_SIZE 200 #define IB_SA_DATA_OFFS 56 - #define IB_PC_DATA_OFFS 64 #define IB_PC_DATA_SZ (IB_MAD_SIZE - IB_PC_DATA_OFFS) - #define IB_SA_MCM_RECSZ 53 #define IB_SA_PR_RECSZ 64 enum MAD_CLASSES { - IB_SMI_CLASS = 0x1, - IB_SMI_DIRECT_CLASS = 0x81, - IB_SA_CLASS = 0x3, - IB_PERFORMANCE_CLASS = 0x4, - IB_BOARD_MGMT_CLASS = 0x5, - IB_DEVICE_MGMT_CLASS = 0x6, - IB_CM_CLASS = 0x7, - IB_SNMP_CLASS = 0x8, + IB_SMI_CLASS = 0x1, + IB_SMI_DIRECT_CLASS = 0x81, + IB_SA_CLASS = 0x3, + IB_PERFORMANCE_CLASS = 0x4, + IB_BOARD_MGMT_CLASS = 0x5, + IB_DEVICE_MGMT_CLASS = 0x6, + IB_CM_CLASS = 0x7, + IB_SNMP_CLASS = 0x8, IB_VENDOR_RANGE1_START_CLASS = 0x9, IB_VENDOR_RANGE1_END_CLASS = 0x0f, - IB_CC_CLASS = 0x21, + IB_CC_CLASS = 0x21, IB_VENDOR_RANGE2_START_CLASS = 0x30, IB_VENDOR_RANGE2_END_CLASS = 0x4f, }; enum MAD_METHODS { - IB_MAD_METHOD_GET = 0x1, - IB_MAD_METHOD_SET = 0x2, - IB_MAD_METHOD_GET_RESPONSE = 0x81, + IB_MAD_METHOD_GET = 0x1, + IB_MAD_METHOD_SET = 0x2, + IB_MAD_METHOD_GET_RESPONSE = 0x81, - IB_MAD_METHOD_SEND = 0x3, - IB_MAD_METHOD_TRAP = 0x5, - IB_MAD_METHOD_TRAP_REPRESS = 0x7, + IB_MAD_METHOD_SEND = 0x3, + IB_MAD_METHOD_TRAP = 0x5, + IB_MAD_METHOD_TRAP_REPRESS = 0x7, - IB_MAD_METHOD_REPORT = 0x6, + IB_MAD_METHOD_REPORT = 0x6, IB_MAD_METHOD_REPORT_RESPONSE = 0x86, - IB_MAD_METHOD_GET_TABLE = 0x12, + IB_MAD_METHOD_GET_TABLE = 0x12, IB_MAD_METHOD_GET_TABLE_RESPONSE = 0x92, IB_MAD_METHOD_GET_TRACE_TABLE = 0x13, IB_MAD_METHOD_GET_TRACE_TABLE_RESPONSE = 0x93, - IB_MAD_METHOD_GETMULTI = 0x14, + IB_MAD_METHOD_GETMULTI = 0x14, IB_MAD_METHOD_GETMULTI_RESPONSE = 0x94, - IB_MAD_METHOD_DELETE = 0x15, + IB_MAD_METHOD_DELETE = 0x15, IB_MAD_METHOD_DELETE_RESPONSE = 0x95, - IB_MAD_RESPONSE = 0x80, + IB_MAD_RESPONSE = 0x80, }; enum MAD_ATTR_ID { @@ -161,7 +151,7 @@ enum GSI_ATTR_ID { typedef uint8_t ibmad_gid_t[16]; #ifdef USE_DEPRECATED_IB_GID_T -typedef ibmad_gid_t ib_gid_t __attribute__((deprecated)); +typedef ibmad_gid_t ib_gid_t __attribute__ ((deprecated)); #endif typedef struct { @@ -184,11 +174,11 @@ typedef struct { int dataoffs; int datasz; uint64_t mkey; - uint64_t trid; /* used for out mad if nonzero, return real val */ - uint64_t mask; /* for sa mads */ - unsigned recsz; /* for sa mads (attribute offset) */ + uint64_t trid; /* used for out mad if nonzero, return real val */ + uint64_t mask; /* for sa mads */ + unsigned recsz; /* for sa mads (attribute offset) */ int timeout; - uint32_t oui; /* for vendor range 2 mads */ + uint32_t oui; /* for vendor range 2 mads */ } ib_rpc_t; typedef struct portid { @@ -202,7 +192,7 @@ typedef struct portid { unsigned pkey_idx; } ib_portid_t; -typedef void (ib_mad_dump_fn)(char *buf, int bufsz, void *val, int valsz); +typedef void (ib_mad_dump_fn) (char *buf, int bufsz, void *val, int valsz); #define IB_FIELD_NAME_LEN 32 @@ -442,8 +432,8 @@ enum MAD_FIELDS { IB_SA_RMPP_SEGNUM_F, /* data2 */ IB_SA_RMPP_D2_F, - IB_SA_RMPP_LEN_F, /* DATA: Payload len */ - IB_SA_RMPP_NEWWIN_F, /* ACK: new window last */ + IB_SA_RMPP_LEN_F, /* DATA: Payload len */ + IB_SA_RMPP_NEWWIN_F, /* ACK: new window last */ /* * SA Multi Path rec @@ -534,7 +524,7 @@ enum MAD_FIELDS { */ IB_GUID_GUID0_F, - IB_FIELD_LAST_ /* must be last */ + IB_FIELD_LAST_ /* must be last */ }; /* @@ -579,8 +569,8 @@ typedef struct ib_sa_call { uint64_t mask; unsigned method; - uint64_t trid; /* used for out mad if nonzero, return real val */ - unsigned recsz; /* return field */ + uint64_t trid; /* used for out mad if nonzero, return real val */ + unsigned recsz; /* return field */ ib_rmpp_hdr_t rmpp; } ib_sa_call_t; @@ -624,13 +614,13 @@ enum { /******************************************************************************/ /* portid.c */ -MAD_EXPORT char * portid2str(ib_portid_t *portid); -MAD_EXPORT int portid2portnum(ib_portid_t *portid); -MAD_EXPORT int str2drpath(ib_dr_path_t *path, char *routepath, int drslid, int drdlid); -MAD_EXPORT char * drpath2str(ib_dr_path_t *path, char *dstr, size_t dstr_size); +MAD_EXPORT char *portid2str(ib_portid_t * portid); +MAD_EXPORT int portid2portnum(ib_portid_t * portid); +MAD_EXPORT int str2drpath(ib_dr_path_t * path, char *routepath, int drslid, + int drdlid); +MAD_EXPORT char *drpath2str(ib_dr_path_t * path, char *dstr, size_t dstr_size); -static inline int -ib_portid_set(ib_portid_t *portid, int lid, int qp, int qkey) +static inline int ib_portid_set(ib_portid_t * portid, int lid, int qp, int qkey) { portid->lid = lid; portid->qp = qp; @@ -642,192 +632,204 @@ ib_portid_set(ib_portid_t *portid, int lid, int qp, int qkey) /* 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, uint32_t val); +MAD_EXPORT void mad_set_field(void *buf, int base_offs, int 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, uint64_t val); +MAD_EXPORT void mad_set_field64(void *buf, int base_offs, int 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 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.c */ -MAD_EXPORT void *mad_encode(void *buf, ib_rpc_t *rpc, ib_dr_path_t *drpath, void *data); +MAD_EXPORT void *mad_encode(void *buf, ib_rpc_t * rpc, ib_dr_path_t * drpath, + void *data); MAD_EXPORT uint64_t mad_trid(void); -MAD_EXPORT int mad_build_pkt(void *umad, ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp, void *data); +MAD_EXPORT int mad_build_pkt(void *umad, ib_rpc_t * rpc, ib_portid_t * dport, + ib_rmpp_hdr_t * rmpp, void *data); /* register.c */ -MAD_EXPORT int mad_register_port_client(int port_id, int mgmt, uint8_t rmpp_version); -MAD_EXPORT int mad_register_client(int mgmt, uint8_t rmpp_version); -MAD_EXPORT int mad_register_server(int mgmt, uint8_t rmpp_version, - long method_mask[16/sizeof(long)], - uint32_t class_oui); -MAD_EXPORT int mad_class_agent(int mgmt); -MAD_EXPORT int mad_agent_class(int agent); +MAD_EXPORT int mad_register_port_client(int port_id, int mgmt, + uint8_t rmpp_version); +MAD_EXPORT int mad_register_client(int mgmt, uint8_t rmpp_version); +MAD_EXPORT int mad_register_server(int mgmt, uint8_t rmpp_version, + long method_mask[16 / sizeof(long)], + uint32_t class_oui); +MAD_EXPORT int mad_class_agent(int mgmt); +MAD_EXPORT int mad_agent_class(int agent); /* serv.c */ -MAD_EXPORT int mad_send(ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp, - void *data); -MAD_EXPORT void * mad_receive(void *umad, int timeout); -MAD_EXPORT int mad_respond(void *umad, ib_portid_t *portid, uint32_t rstatus); -MAD_EXPORT void * mad_alloc(void); -MAD_EXPORT void mad_free(void *umad); +MAD_EXPORT int mad_send(ib_rpc_t * rpc, ib_portid_t * dport, + ib_rmpp_hdr_t * rmpp, void *data); +MAD_EXPORT void *mad_receive(void *umad, int timeout); +MAD_EXPORT int mad_respond(void *umad, ib_portid_t * portid, uint32_t rstatus); +MAD_EXPORT void *mad_alloc(void); +MAD_EXPORT void mad_free(void *umad); /* vendor.c */ -MAD_EXPORT uint8_t *ib_vendor_call(void *data, ib_portid_t *portid, - ib_vendor_call_t *call); +MAD_EXPORT uint8_t *ib_vendor_call(void *data, ib_portid_t * portid, + ib_vendor_call_t * call); -static inline int -mad_is_vendor_range1(int mgmt) +static inline int mad_is_vendor_range1(int mgmt) { return mgmt >= 0x9 && mgmt <= 0xf; } -static inline int -mad_is_vendor_range2(int mgmt) +static inline int mad_is_vendor_range2(int mgmt) { return mgmt >= 0x30 && mgmt <= 0x4f; } /* rpc.c */ -MAD_EXPORT int madrpc_portid(void); -MAD_EXPORT int madrpc_set_retries(int retries); -MAD_EXPORT int madrpc_set_timeout(int timeout); -void * madrpc(ib_rpc_t *rpc, ib_portid_t *dport, void *payload, void *rcvdata); -void * madrpc_rmpp(ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp, - void *data); -MAD_EXPORT void madrpc_init(char *dev_name, int dev_port, int *mgmt_classes, - int num_classes); -void madrpc_save_mad(void *madbuf, int len); -MAD_EXPORT void madrpc_show_errors(int set); - -void * mad_rpc_open_port(char *dev_name, int dev_port, int *mgmt_classes, - int num_classes); -void mad_rpc_close_port(void *ibmad_port); -void * mad_rpc(const void *ibmad_port, ib_rpc_t *rpc, ib_portid_t *dport, - void *payload, void *rcvdata); -void * mad_rpc_rmpp(const void *ibmad_port, ib_rpc_t *rpc, ib_portid_t *dport, - ib_rmpp_hdr_t *rmpp, void *data); +MAD_EXPORT int madrpc_portid(void); +MAD_EXPORT int madrpc_set_retries(int retries); +MAD_EXPORT int madrpc_set_timeout(int timeout); +void *madrpc(ib_rpc_t * rpc, ib_portid_t * dport, void *payload, void *rcvdata); +void *madrpc_rmpp(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp, + void *data); +MAD_EXPORT void madrpc_init(char *dev_name, int dev_port, int *mgmt_classes, + int num_classes); +void madrpc_save_mad(void *madbuf, int len); +MAD_EXPORT void madrpc_show_errors(int set); + +void *mad_rpc_open_port(char *dev_name, int dev_port, int *mgmt_classes, + int num_classes); +void mad_rpc_close_port(void *ibmad_port); +void *mad_rpc(const void *ibmad_port, ib_rpc_t * rpc, ib_portid_t * dport, + void *payload, void *rcvdata); +void *mad_rpc_rmpp(const void *ibmad_port, ib_rpc_t * rpc, ib_portid_t * dport, + ib_rmpp_hdr_t * rmpp, void *data); /* smp.c */ -MAD_EXPORT uint8_t * smp_query(void *buf, ib_portid_t *id, unsigned attrid, unsigned mod, - unsigned timeout); -MAD_EXPORT uint8_t * smp_set(void *buf, ib_portid_t *id, unsigned attrid, unsigned mod, - unsigned timeout); -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 uint8_t *smp_query(void *buf, ib_portid_t * id, unsigned attrid, + unsigned mod, unsigned timeout); +MAD_EXPORT uint8_t *smp_set(void *buf, ib_portid_t * id, unsigned attrid, + unsigned mod, unsigned timeout); +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); /* sa.c */ -uint8_t * sa_call(void *rcvbuf, ib_portid_t *portid, ib_sa_call_t *sa, - unsigned timeout); -uint8_t * sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t *portid, - ib_sa_call_t *sa, unsigned timeout); -MAD_EXPORT int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t *sm_id, - void *buf); /* returns lid */ -int ib_path_query_via(const void *srcport, ibmad_gid_t srcgid, - ibmad_gid_t destgid, ib_portid_t *sm_id, void *buf); +uint8_t *sa_call(void *rcvbuf, ib_portid_t * portid, ib_sa_call_t * sa, + unsigned timeout); +uint8_t *sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t * portid, + ib_sa_call_t * sa, unsigned timeout); +MAD_EXPORT int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf); /* returns lid */ +int ib_path_query_via(const void *srcport, ibmad_gid_t srcgid, + ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf); /* resolve.c */ -MAD_EXPORT int ib_resolve_smlid(ib_portid_t *sm_id, int timeout); -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); -MAD_EXPORT int ib_resolve_self(ib_portid_t *portid, int *portnum, ibmad_gid_t *gid); - -int ib_resolve_smlid_via(ib_portid_t *sm_id, int timeout, - const void *srcport); -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, - const void *srcport); -int ib_resolve_self_via(ib_portid_t *portid, int *portnum, ibmad_gid_t *gid, - const void *srcport); +MAD_EXPORT int ib_resolve_smlid(ib_portid_t * sm_id, int timeout); +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); +MAD_EXPORT int ib_resolve_self(ib_portid_t * portid, int *portnum, + ibmad_gid_t * gid); + +int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout, const void *srcport); +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, + const void *srcport); +int ib_resolve_self_via(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid, + const void *srcport); /* gs.c */ -MAD_EXPORT uint8_t *perf_classportinfo_query(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout); -MAD_EXPORT uint8_t *port_performance_query(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout); -MAD_EXPORT uint8_t *port_performance_reset(void *rcvbuf, ib_portid_t *dest, int port, - unsigned mask, unsigned timeout); -MAD_EXPORT uint8_t *port_performance_ext_query(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout); -MAD_EXPORT uint8_t *port_performance_ext_reset(void *rcvbuf, ib_portid_t *dest, int port, - unsigned mask, unsigned timeout); -MAD_EXPORT uint8_t *port_samples_control_query(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout); -MAD_EXPORT uint8_t *port_samples_result_query(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout); - -uint8_t *perf_classportinfo_query_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout, const void *srcport); -uint8_t *port_performance_query_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout, const void *srcport); -uint8_t *port_performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned mask, unsigned timeout, const void *srcport); -uint8_t *port_performance_ext_query_via(void *rcvbuf, ib_portid_t *dest, int port, +MAD_EXPORT uint8_t *perf_classportinfo_query(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout); +MAD_EXPORT uint8_t *port_performance_query(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout); +MAD_EXPORT uint8_t *port_performance_reset(void *rcvbuf, ib_portid_t * dest, + int port, unsigned mask, + unsigned timeout); +MAD_EXPORT uint8_t *port_performance_ext_query(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout); +MAD_EXPORT uint8_t *port_performance_ext_reset(void *rcvbuf, ib_portid_t * dest, + int port, unsigned mask, + unsigned timeout); +MAD_EXPORT uint8_t *port_samples_control_query(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout); +MAD_EXPORT uint8_t *port_samples_result_query(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout); + +uint8_t *perf_classportinfo_query_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout, + const void *srcport); +uint8_t *port_performance_query_via(void *rcvbuf, ib_portid_t * dest, int port, unsigned timeout, const void *srcport); -uint8_t *port_performance_ext_reset_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned mask, unsigned timeout, const void *srcport); -uint8_t *port_samples_control_query_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout, const void *srcport); -uint8_t *port_samples_result_query_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout, const void *srcport); +uint8_t *port_performance_reset_via(void *rcvbuf, ib_portid_t * dest, int port, + unsigned mask, unsigned timeout, + const void *srcport); +uint8_t *port_performance_ext_query_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout, + const void *srcport); +uint8_t *port_performance_ext_reset_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned mask, + unsigned timeout, const void *srcport); +uint8_t *port_samples_control_query_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout, + const void *srcport); +uint8_t *port_samples_result_query_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout, + const void *srcport); /* dump.c */ MAD_EXPORT ib_mad_dump_fn - mad_dump_int, mad_dump_uint, mad_dump_hex, mad_dump_rhex, - mad_dump_bitfield, mad_dump_array, mad_dump_string, - mad_dump_linkwidth, mad_dump_linkwidthsup, mad_dump_linkwidthen, - mad_dump_linkdowndefstate, - mad_dump_linkspeed, mad_dump_linkspeedsup, mad_dump_linkspeeden, - mad_dump_portstate, mad_dump_portstates, - mad_dump_physportstate, mad_dump_portcapmask, - mad_dump_mtu, mad_dump_vlcap, mad_dump_opervls, - mad_dump_node_type, - mad_dump_sltovl, mad_dump_vlarbitration, - mad_dump_nodedesc, mad_dump_nodeinfo, mad_dump_portinfo, mad_dump_switchinfo, - mad_dump_perfcounters, mad_dump_perfcounters_ext; + mad_dump_int, mad_dump_uint, mad_dump_hex, mad_dump_rhex, + mad_dump_bitfield, mad_dump_array, mad_dump_string, + mad_dump_linkwidth, mad_dump_linkwidthsup, mad_dump_linkwidthen, + mad_dump_linkdowndefstate, + mad_dump_linkspeed, mad_dump_linkspeedsup, mad_dump_linkspeeden, + mad_dump_portstate, mad_dump_portstates, + mad_dump_physportstate, mad_dump_portcapmask, + mad_dump_mtu, mad_dump_vlcap, mad_dump_opervls, + mad_dump_node_type, mad_dump_sltovl, mad_dump_vlarbitration, + mad_dump_nodedesc, mad_dump_nodeinfo, mad_dump_portinfo, + mad_dump_switchinfo, mad_dump_perfcounters, mad_dump_perfcounters_ext; extern int ibdebug; #if __BYTE_ORDER == __LITTLE_ENDIAN #ifndef ntohll -static inline uint64_t ntohll(uint64_t x) { +static inline uint64_t ntohll(uint64_t x) +{ return bswap_64(x); } #endif #ifndef htonll -static inline uint64_t htonll(uint64_t x) { +static inline uint64_t htonll(uint64_t x) +{ return bswap_64(x); } #endif #elif __BYTE_ORDER == __BIG_ENDIAN #ifndef ntohll -static inline uint64_t ntohll(uint64_t x) { +static inline uint64_t ntohll(uint64_t x) +{ return x; } #endif #ifndef htonll -static inline uint64_t htonll(uint64_t x) { +static inline uint64_t htonll(uint64_t x) +{ return x; } #endif -#endif /* __BYTE_ORDER == __BIG_ENDIAN */ +#endif /* __BYTE_ORDER == __BIG_ENDIAN */ /* Misc. macros: */ /** align value \a l to \a size (ceil) */ #define ALIGN(l, size) (((l) + ((size) - 1)) / (size) * (size)) -/** printf style warning MACRO, includes name of function and pid */ -#define IBWARN(fmt, ...) fprintf(stdout, "ibwarn: [%d] %s: " fmt "\n", getpid(), __func__, ## __VA_ARGS__) +/** printf style warning MACRO, includes name of function and pid */ +#define IBWARN(fmt, ...) fprintf(stdout, "ibwarn: [%d] %s: " fmt "\n", getpid(), __func__, ## __VA_ARGS__) /** printf style abort MACRO, includes name of function and pid */ #define IBPANIC(fmt, ...) do { \ @@ -835,8 +837,7 @@ static inline uint64_t htonll(uint64_t x) { exit(-1); \ } while(0) -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_ */ +#endif /* _MAD_H_ */ diff --git a/branches/winverbs/ulp/libibmad/src/dump.c b/branches/winverbs/ulp/libibmad/src/dump.c index a7575b9a..1cf52325 100644 --- a/branches/winverbs/ulp/libibmad/src/dump.c +++ b/branches/winverbs/ulp/libibmad/src/dump.c @@ -34,29 +34,32 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ -#include +#include +#include +#include -void -mad_dump_int(char *buf, int bufsz, void *val, int valsz) +#include + +void mad_dump_int(char *buf, int bufsz, void *val, int valsz) { switch (valsz) { case 1: - snprintf(buf, bufsz, "%d", *(uint8_t *)val); + snprintf(buf, bufsz, "%d", *(uint8_t *) val); break; case 2: - snprintf(buf, bufsz, "%d", *(uint16_t *)val); + snprintf(buf, bufsz, "%d", *(uint16_t *) val); break; case 3: case 4: - snprintf(buf, bufsz, "%d", *(uint32_t *)val); + snprintf(buf, bufsz, "%d", *(uint32_t *) val); break; case 5: case 6: case 7: case 8: - snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *)val); + snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *) val); break; default: IBWARN("bad int sz %d", valsz); @@ -64,25 +67,24 @@ mad_dump_int(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_uint(char *buf, int bufsz, void *val, int valsz) +void mad_dump_uint(char *buf, int bufsz, void *val, int valsz) { switch (valsz) { case 1: - snprintf(buf, bufsz, "%u", *(uint8_t *)val); + snprintf(buf, bufsz, "%u", *(uint8_t *) val); break; case 2: - snprintf(buf, bufsz, "%u", *(uint16_t *)val); + snprintf(buf, bufsz, "%u", *(uint16_t *) val); break; case 3: case 4: - snprintf(buf, bufsz, "%u", *(uint32_t *)val); + snprintf(buf, bufsz, "%u", *(uint32_t *) val); break; case 5: case 6: case 7: case 8: - snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *)val); + snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *) val); break; default: IBWARN("bad int sz %u", valsz); @@ -90,33 +92,35 @@ mad_dump_uint(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_hex(char *buf, int bufsz, void *val, int valsz) +void mad_dump_hex(char *buf, int bufsz, void *val, int valsz) { switch (valsz) { case 1: - snprintf(buf, bufsz, "0x%02x", *(uint8_t *)val); + snprintf(buf, bufsz, "0x%02x", *(uint8_t *) val); break; case 2: - snprintf(buf, bufsz, "0x%04x", *(uint16_t *)val); + snprintf(buf, bufsz, "0x%04x", *(uint16_t *) val); break; case 3: - snprintf(buf, bufsz, "0x%06x", *(uint32_t *)val & 0xffffff); + snprintf(buf, bufsz, "0x%06x", *(uint32_t *) val & 0xffffff); break; case 4: - snprintf(buf, bufsz, "0x%08x", *(uint32_t *)val); + snprintf(buf, bufsz, "0x%08x", *(uint32_t *) val); break; case 5: - snprintf(buf, bufsz, "0x%010" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffULL); + snprintf(buf, bufsz, "0x%010" PRIx64, + *(uint64_t *) val & (uint64_t) 0xffffffffffULL); break; case 6: - snprintf(buf, bufsz, "0x%012" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffULL); + snprintf(buf, bufsz, "0x%012" PRIx64, + *(uint64_t *) val & (uint64_t) 0xffffffffffffULL); break; case 7: - snprintf(buf, bufsz, "0x%014" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffffULL); + snprintf(buf, bufsz, "0x%014" PRIx64, + *(uint64_t *) val & (uint64_t) 0xffffffffffffffULL); break; case 8: - snprintf(buf, bufsz, "0x%016" PRIx64, *(uint64_t *)val); + snprintf(buf, bufsz, "0x%016" PRIx64, *(uint64_t *) val); break; default: IBWARN("bad int sz %d", valsz); @@ -124,33 +128,35 @@ mad_dump_hex(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_rhex(char *buf, int bufsz, void *val, int valsz) +void mad_dump_rhex(char *buf, int bufsz, void *val, int valsz) { switch (valsz) { case 1: - snprintf(buf, bufsz, "%02x", *(uint8_t *)val); + snprintf(buf, bufsz, "%02x", *(uint8_t *) val); break; case 2: - snprintf(buf, bufsz, "%04x", *(uint16_t *)val); + snprintf(buf, bufsz, "%04x", *(uint16_t *) val); break; case 3: - snprintf(buf, bufsz, "%06x", *(uint32_t *)val & 0xffffff); + snprintf(buf, bufsz, "%06x", *(uint32_t *) val & 0xffffff); break; case 4: - snprintf(buf, bufsz, "%08x", *(uint32_t *)val); + snprintf(buf, bufsz, "%08x", *(uint32_t *) val); break; case 5: - snprintf(buf, bufsz, "%010" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffULL); + snprintf(buf, bufsz, "%010" PRIx64, + *(uint64_t *) val & (uint64_t) 0xffffffffffULL); break; case 6: - snprintf(buf, bufsz, "%012" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffULL); + snprintf(buf, bufsz, "%012" PRIx64, + *(uint64_t *) val & (uint64_t) 0xffffffffffffULL); break; case 7: - snprintf(buf, bufsz, "%014" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffffULL); + snprintf(buf, bufsz, "%014" PRIx64, + *(uint64_t *) val & (uint64_t) 0xffffffffffffffULL); break; case 8: - snprintf(buf, bufsz, "%016" PRIx64, *(uint64_t *)val); + snprintf(buf, bufsz, "%016" PRIx64, *(uint64_t *) val); break; default: IBWARN("bad int sz %d", valsz); @@ -158,8 +164,7 @@ mad_dump_rhex(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_linkwidth(char *buf, int bufsz, void *val, int valsz) +void mad_dump_linkwidth(char *buf, int bufsz, void *val, int valsz) { int width = *(int *)val; @@ -182,8 +187,7 @@ mad_dump_linkwidth(char *buf, int bufsz, void *val, int valsz) } } -static void -dump_linkwidth(char *buf, int bufsz, int width) +static void dump_linkwidth(char *buf, int bufsz, int width) { int n = 0; @@ -201,17 +205,16 @@ dump_linkwidth(char *buf, int bufsz, int width) else if (width == 0 || (width >> 4)) snprintf(buf + n, bufsz - n, "undefined (%d)", width); else if (bufsz > 3) - buf[n-4] = '\0'; + buf[n - 4] = '\0'; } -void -mad_dump_linkwidthsup(char *buf, int bufsz, void *val, int valsz) +void mad_dump_linkwidthsup(char *buf, int bufsz, void *val, int valsz) { int width = *(int *)val; dump_linkwidth(buf, bufsz, width); - switch(width) { + switch (width) { case 1: case 3: case 7: @@ -227,16 +230,14 @@ mad_dump_linkwidthsup(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_linkwidthen(char *buf, int bufsz, void *val, int valsz) +void mad_dump_linkwidthen(char *buf, int bufsz, void *val, int valsz) { int width = *(int *)val; dump_linkwidth(buf, bufsz, width); } -void -mad_dump_linkspeed(char *buf, int bufsz, void *val, int valsz) +void mad_dump_linkspeed(char *buf, int bufsz, void *val, int valsz) { int speed = *(int *)val; @@ -256,8 +257,7 @@ mad_dump_linkspeed(char *buf, int bufsz, void *val, int valsz) } } -static void -dump_linkspeed(char *buf, int bufsz, int speed) +static void dump_linkspeed(char *buf, int bufsz, int speed) { int n = 0; @@ -275,7 +275,7 @@ dump_linkspeed(char *buf, int bufsz, int speed) if (n >= bufsz) return; } else if (bufsz > 3) { - buf[n-4] = '\0'; + buf[n - 4] = '\0'; n -= 4; } @@ -292,24 +292,21 @@ dump_linkspeed(char *buf, int bufsz, int speed) } } -void -mad_dump_linkspeedsup(char *buf, int bufsz, void *val, int valsz) +void mad_dump_linkspeedsup(char *buf, int bufsz, void *val, int valsz) { int speed = *(int *)val; dump_linkspeed(buf, bufsz, speed); } -void -mad_dump_linkspeeden(char *buf, int bufsz, void *val, int valsz) +void mad_dump_linkspeeden(char *buf, int bufsz, void *val, int valsz) { int speed = *(int *)val; dump_linkspeed(buf, bufsz, speed); } -void -mad_dump_portstate(char *buf, int bufsz, void *val, int valsz) +void mad_dump_portstate(char *buf, int bufsz, void *val, int valsz) { int state = *(int *)val; @@ -334,12 +331,11 @@ mad_dump_portstate(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_linkdowndefstate(char *buf, int bufsz, void *val, int valsz) +void mad_dump_linkdowndefstate(char *buf, int bufsz, void *val, int valsz) { int state = *(int *)val; - switch(state) { + switch (state) { case 0: snprintf(buf, bufsz, "NoChange"); break; @@ -355,8 +351,7 @@ mad_dump_linkdowndefstate(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_physportstate(char *buf, int bufsz, void *val, int valsz) +void mad_dump_physportstate(char *buf, int bufsz, void *val, int valsz) { int state = *(int *)val; @@ -390,8 +385,7 @@ mad_dump_physportstate(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_mtu(char *buf, int bufsz, void *val, int valsz) +void mad_dump_mtu(char *buf, int bufsz, void *val, int valsz) { int mtu = *(int *)val; @@ -417,8 +411,7 @@ mad_dump_mtu(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_vlcap(char *buf, int bufsz, void *val, int valsz) +void mad_dump_vlcap(char *buf, int bufsz, void *val, int valsz) { int vlcap = *(int *)val; @@ -443,8 +436,7 @@ mad_dump_vlcap(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_opervls(char *buf, int bufsz, void *val, int valsz) +void mad_dump_opervls(char *buf, int bufsz, void *val, int valsz) { int opervls = *(int *)val; @@ -472,8 +464,7 @@ mad_dump_opervls(char *buf, int bufsz, void *val, int valsz) } } -void -mad_dump_portcapmask(char *buf, int bufsz, void *val, int valsz) +void mad_dump_portcapmask(char *buf, int bufsz, void *val, int valsz) { unsigned mask = *(unsigned *)val; char *s = buf; @@ -500,7 +491,8 @@ mad_dump_portcapmask(char *buf, int bufsz, void *val, int valsz) if (mask & (1 << 11)) s += sprintf(s, "\t\t\t\tIsSystemImageGUIDsupported\n"); if (mask & (1 << 12)) - s += sprintf(s, "\t\t\t\tIsPkeySwitchExternalPortTrapSupported\n"); + s += sprintf(s, + "\t\t\t\tIsPkeySwitchExternalPortTrapSupported\n"); if (mask & (1 << 16)) s += sprintf(s, "\t\t\t\tIsCommunicatonManagementSupported\n"); if (mask & (1 << 17)) @@ -524,33 +516,31 @@ mad_dump_portcapmask(char *buf, int bufsz, void *val, int valsz) if (mask & (1 << 26)) s += sprintf(s, "\t\t\t\tIsOtherLocalChangesNoticeSupported\n"); if (mask & (1 << 27)) - s += sprintf(s, "\t\t\t\tIsLinkSpeedWidthPairsTableSupported\n"); + s += sprintf(s, + "\t\t\t\tIsLinkSpeedWidthPairsTableSupported\n"); if (s != buf) *(--s) = 0; } -void -mad_dump_bitfield(char *buf, int bufsz, void *val, int valsz) +void mad_dump_bitfield(char *buf, int bufsz, void *val, int valsz) { - snprintf(buf, bufsz, "0x%x", *(uint32_t *)val); + snprintf(buf, bufsz, "0x%x", *(uint32_t *) val); } -void -mad_dump_array(char *buf, int bufsz, void *val, int valsz) +void mad_dump_array(char *buf, int bufsz, void *val, int valsz) { uint8_t *p = val, *e; char *s = buf; - if (bufsz < valsz*2) - valsz = bufsz/2; + if (bufsz < valsz * 2) + valsz = bufsz / 2; for (p = val, e = p + valsz; p < e; p++, s += 2) sprintf(s, "%02x", *p); } -void -mad_dump_string(char *buf, int bufsz, void *val, int valsz) +void mad_dump_string(char *buf, int bufsz, void *val, int valsz) { if (bufsz < valsz) valsz = bufsz; @@ -558,19 +548,18 @@ mad_dump_string(char *buf, int bufsz, void *val, int valsz) snprintf(buf, valsz, "'%s'", (char *)val); } -void -mad_dump_node_type(char *buf, int bufsz, void *val, int valsz) +void mad_dump_node_type(char *buf, int bufsz, void *val, int valsz) { - int nodetype = *(int*)val; + int nodetype = *(int *)val; switch (nodetype) { - case 1: + case 1: snprintf(buf, bufsz, "Channel Adapter"); break; - case 2: + case 2: snprintf(buf, bufsz, "Switch"); break; - case 3: + case 3: snprintf(buf, bufsz, "Router"); break; default: @@ -586,10 +575,9 @@ typedef struct _ib_slvl_table { uint8_t vl_by_sl_num[IB_MAX_NUM_VLS_TO_U8]; } ib_slvl_table_t; -static inline void -ib_slvl_get_i(ib_slvl_table_t *tbl, int i, uint8_t *vl) +static inline void ib_slvl_get_i(ib_slvl_table_t * tbl, int i, uint8_t * vl) { - *vl = (tbl->vl_by_sl_num[i >> 1] >> ((!(i&1)) << 2)) & 0xf; + *vl = (tbl->vl_by_sl_num[i >> 1] >> ((!(i & 1)) << 2)) & 0xf; } #define IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK 32 @@ -601,16 +589,14 @@ typedef struct _ib_vl_arb_table { } vl_entry[IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK]; } ib_vl_arb_table_t; -static inline void -ib_vl_arb_get_vl(uint8_t res_vl, uint8_t *const vl ) +static inline void ib_vl_arb_get_vl(uint8_t res_vl, uint8_t * const vl) { *vl = res_vl & 0x0F; } -void -mad_dump_sltovl(char *buf, int bufsz, void *val, int valsz) +void mad_dump_sltovl(char *buf, int bufsz, void *val, int valsz) { - ib_slvl_table_t* p_slvl_tbl = val; + ib_slvl_table_t *p_slvl_tbl = val; uint8_t vl; int i, n = 0; n = snprintf(buf, bufsz, "|"); @@ -623,10 +609,9 @@ mad_dump_sltovl(char *buf, int bufsz, void *val, int valsz) snprintf(buf + n, bufsz - n, "\n"); } -void -mad_dump_vlarbitration(char *buf, int bufsz, void *val, int num) +void mad_dump_vlarbitration(char *buf, int bufsz, void *val, int num) { - ib_vl_arb_table_t* p_vla_tbl = val; + ib_vl_arb_table_t *p_vla_tbl = val; int i, n; uint8_t vl; @@ -655,8 +640,7 @@ mad_dump_vlarbitration(char *buf, int bufsz, void *val, int num) snprintf(buf + n, bufsz - n, "\n"); } -static int -_dump_fields(char *buf, int bufsz, void *data, int start, int end) +static int _dump_fields(char *buf, int bufsz, void *data, int start, int end) { char val[64]; char *s = buf; @@ -677,8 +661,7 @@ _dump_fields(char *buf, int bufsz, void *data, int start, int end) return (int)(s - buf); } -void -mad_dump_nodedesc(char *buf, int bufsz, void *val, int valsz) +void mad_dump_nodedesc(char *buf, int bufsz, void *val, int valsz) { strncpy(buf, val, bufsz); @@ -686,65 +669,59 @@ mad_dump_nodedesc(char *buf, int bufsz, void *val, int valsz) buf[valsz] = 0; } -void -mad_dump_nodeinfo(char *buf, int bufsz, void *val, int valsz) +void mad_dump_nodeinfo(char *buf, int bufsz, void *val, int valsz) { _dump_fields(buf, bufsz, val, IB_NODE_FIRST_F, IB_NODE_LAST_F); } -void -mad_dump_portinfo(char *buf, int bufsz, void *val, int valsz) +void mad_dump_portinfo(char *buf, int bufsz, void *val, int valsz) { _dump_fields(buf, bufsz, val, IB_PORT_FIRST_F, IB_PORT_LAST_F); } -void -mad_dump_portstates(char *buf, int bufsz, void *val, int valsz) +void mad_dump_portstates(char *buf, int bufsz, void *val, int valsz) { _dump_fields(buf, bufsz, val, IB_PORT_STATE_F, IB_PORT_LINK_DOWN_DEF_F); } -void -mad_dump_switchinfo(char *buf, int bufsz, void *val, int valsz) +void mad_dump_switchinfo(char *buf, int bufsz, void *val, int valsz) { _dump_fields(buf, bufsz, val, IB_SW_FIRST_F, IB_SW_LAST_F); } -void -mad_dump_perfcounters(char *buf, int bufsz, void *val, int valsz) +void mad_dump_perfcounters(char *buf, int bufsz, void *val, int valsz) { _dump_fields(buf, bufsz, val, IB_PC_FIRST_F, IB_PC_LAST_F); } -void -mad_dump_perfcounters_ext(char *buf, int bufsz, void *val, int valsz) +void mad_dump_perfcounters_ext(char *buf, int bufsz, void *val, int valsz) { _dump_fields(buf, bufsz, val, IB_PC_EXT_FIRST_F, IB_PC_EXT_LAST_F); } -void xdump(FILE *file, char *msg, void *p, int size) +void xdump(FILE * file, char *msg, void *p, int size) { #define HEX(x) ((x) < 10 ? '0' + (x) : 'a' + ((x) -10)) - uint8_t *cp = p; - int i; + uint8_t *cp = p; + int i; if (msg) fputs(msg, file); - for (i = 0; i < size;) { - fputc(HEX(*cp >> 4), file); - fputc(HEX(*cp & 0xf), file); - if (++i >= size) - break; - fputc(HEX(cp[1] >> 4), file); - fputc(HEX(cp[1] & 0xf), file); - if ((++i) % 16) - fputc(' ', file); - else - fputc('\n', file); - cp += 2; - } - if (i % 16) { - fputc('\n', file); - } + for (i = 0; i < size;) { + fputc(HEX(*cp >> 4), file); + fputc(HEX(*cp & 0xf), file); + if (++i >= size) + break; + fputc(HEX(cp[1] >> 4), file); + fputc(HEX(cp[1] & 0xf), file); + if ((++i) % 16) + fputc(' ', file); + else + fputc('\n', file); + cp += 2; + } + if (i % 16) { + fputc('\n', file); + } } diff --git a/branches/winverbs/ulp/libibmad/src/fields.c b/branches/winverbs/ulp/libibmad/src/fields.c index f913eb1f..1f2cec51 100644 --- a/branches/winverbs/ulp/libibmad/src/fields.c +++ b/branches/winverbs/ulp/libibmad/src/fields.c @@ -33,13 +33,13 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ #include #include #include -#include +#include /* * BITSOFFS and BE_OFFS are required due the fact that the bit offsets are inconsistently @@ -52,8 +52,8 @@ #define BE_OFFS(o, w) (o), (w) #define BE_TO_BITSOFFS(o, w) (((o) & ~31) | ((32 - ((o) & 31) - (w)))) -ib_field_t ib_mad_f [] = { - {0, 0}, /* IB_NO_FIELD - reserved as invalid */ +static const ib_field_t ib_mad_f[] = { + {0, 0}, /* IB_NO_FIELD - reserved as invalid */ {0, 64, "GidPrefix", mad_dump_rhex}, {64, 64, "GidGuid", mad_dump_rhex}, @@ -66,25 +66,25 @@ ib_field_t ib_mad_f [] = { */ /* first MAD word (0-3 bytes) */ - {BE_OFFS(0, 7), "MadMethod", mad_dump_hex}, /* TODO: add dumper */ - {BE_OFFS(7, 1), "MadIsResponse", mad_dump_uint}, /* TODO: add dumper */ + {BE_OFFS(0, 7), "MadMethod", mad_dump_hex}, /* TODO: add dumper */ + {BE_OFFS(7, 1), "MadIsResponse", mad_dump_uint}, /* TODO: add dumper */ {BE_OFFS(8, 8), "MadClassVersion", mad_dump_uint}, - {BE_OFFS(16, 8), "MadMgmtClass", mad_dump_uint}, /* TODO: add dumper */ + {BE_OFFS(16, 8), "MadMgmtClass", mad_dump_uint}, /* TODO: add dumper */ {BE_OFFS(24, 8), "MadBaseVersion", mad_dump_uint}, /* second MAD word (4-7 bytes) */ - {BE_OFFS(48, 16), "MadStatus", mad_dump_hex}, /* TODO: add dumper */ + {BE_OFFS(48, 16), "MadStatus", mad_dump_hex}, /* TODO: add dumper */ /* DR SMP only */ {BE_OFFS(32, 8), "DrSmpHopCnt", mad_dump_uint}, {BE_OFFS(40, 8), "DrSmpHopPtr", mad_dump_uint}, - {BE_OFFS(48, 15), "DrSmpStatus", mad_dump_hex}, /* TODO: add dumper */ - {BE_OFFS(63, 1), "DrSmpDirection", mad_dump_uint}, /* TODO: add dumper */ + {BE_OFFS(48, 15), "DrSmpStatus", mad_dump_hex}, /* TODO: add dumper */ + {BE_OFFS(63, 1), "DrSmpDirection", mad_dump_uint}, /* TODO: add dumper */ /* words 3,4,5,6 (8-23 bytes) */ {64, 64, "MadTRID", mad_dump_hex}, - {BE_OFFS(144, 16), "MadAttr", mad_dump_hex}, /* TODO: add dumper */ - {160, 32, "MadModifier", mad_dump_hex}, /* TODO: add dumper */ + {BE_OFFS(144, 16), "MadAttr", mad_dump_hex}, /* TODO: add dumper */ + {160, 32, "MadModifier", mad_dump_hex}, /* TODO: add dumper */ /* word 7,8 (24-31 bytes) */ {196, 64, "MadMkey", mad_dump_hex}, @@ -94,29 +94,29 @@ ib_field_t ib_mad_f [] = { {BE_OFFS(272, 16), "DrSmpSLID", mad_dump_hex}, /* word 10,11 (36-43 bytes) */ - {0, 0}, /* IB_SA_MKEY_F - reserved as invalid */ + {0, 0}, /* IB_SA_MKEY_F - reserved as invalid */ /* word 12 (44-47 bytes) */ - {BE_OFFS(46*8, 16), "SaAttrOffs", mad_dump_uint}, + {BE_OFFS(46 * 8, 16), "SaAttrOffs", mad_dump_uint}, /* word 13,14 (48-55 bytes) */ - {48*8, 64, "SaCompMask", mad_dump_hex}, + {48 * 8, 64, "SaCompMask", mad_dump_hex}, /* word 13,14 (56-255 bytes) */ - {56*8, (256-56)*8, "SaData", mad_dump_hex}, + {56 * 8, (256 - 56) * 8, "SaData", mad_dump_hex}, /* bytes 64 - 127 */ - {0, 0}, /* IB_SM_DATA_F - reserved as invalid */ - + {0, 0}, /* IB_SM_DATA_F - reserved as invalid */ + /* bytes 64 - 256 */ - {64*8, (256-64) * 8, "GsData", mad_dump_hex}, - + {64 * 8, (256 - 64) * 8, "GsData", mad_dump_hex}, + /* bytes 128 - 191 */ {1024, 512, "DrSmpPath", mad_dump_hex}, - + /* bytes 192 - 255 */ {1536, 512, "DrSmpRetPath", mad_dump_hex}, - + /* * PortInfo fields: */ @@ -166,25 +166,24 @@ ib_field_t ib_mad_f [] = { {BITSOFFS(428, 4), "OverrunErr", mad_dump_uint}, {BITSOFFS(432, 16), "MaxCreditHint", mad_dump_uint}, {BITSOFFS(456, 24), "RoundTrip", mad_dump_uint}, - {0, 0}, /* IB_PORT_LAST_F */ + {0, 0}, /* IB_PORT_LAST_F */ /* * NodeInfo fields: */ - {BITSOFFS(0,8), "BaseVers", mad_dump_uint}, - {BITSOFFS(8,8), "ClassVers", mad_dump_uint}, - {BITSOFFS(16,8), "NodeType", mad_dump_node_type}, - {BITSOFFS(24,8), "NumPorts", mad_dump_uint}, + {BITSOFFS(0, 8), "BaseVers", mad_dump_uint}, + {BITSOFFS(8, 8), "ClassVers", mad_dump_uint}, + {BITSOFFS(16, 8), "NodeType", mad_dump_node_type}, + {BITSOFFS(24, 8), "NumPorts", mad_dump_uint}, {32, 64, "SystemGuid", mad_dump_hex}, {96, 64, "Guid", mad_dump_hex}, {160, 64, "PortGuid", mad_dump_hex}, - {BITSOFFS(224,16), "PartCap", mad_dump_uint}, - {BITSOFFS(240,16), "DevId", mad_dump_hex}, + {BITSOFFS(224, 16), "PartCap", mad_dump_uint}, + {BITSOFFS(240, 16), "DevId", mad_dump_hex}, {256, 32, "Revision", mad_dump_hex}, - {BITSOFFS(288,8), "LocalPort", mad_dump_uint}, - {BITSOFFS(296,24), "VendorId", mad_dump_hex}, - {0, 0}, /* IB_NODE_LAST_F */ - + {BITSOFFS(288, 8), "LocalPort", mad_dump_uint}, + {BITSOFFS(296, 24), "VendorId", mad_dump_hex}, + {0, 0}, /* IB_NODE_LAST_F */ /* * SwitchInfo fields: @@ -198,14 +197,14 @@ ib_field_t ib_mad_f [] = { {BITSOFFS(80, 8), "DefMcastNotPrimPort", mad_dump_uint}, {BITSOFFS(88, 5), "LifeTime", mad_dump_uint}, {BITSOFFS(93, 1), "StateChange", mad_dump_uint}, - {BITSOFFS(96,16), "LidsPerPort", mad_dump_uint}, + {BITSOFFS(96, 16), "LidsPerPort", mad_dump_uint}, {BITSOFFS(112, 16), "PartEnforceCap", mad_dump_uint}, {BITSOFFS(128, 1), "InboundPartEnf", mad_dump_uint}, {BITSOFFS(129, 1), "OutboundPartEnf", mad_dump_uint}, {BITSOFFS(130, 1), "FilterRawInbound", mad_dump_uint}, {BITSOFFS(131, 1), "FilterRawOutbound", mad_dump_uint}, {BITSOFFS(132, 1), "EnhancedPort0", mad_dump_uint}, - {0, 0}, /* IB_SW_LAST_F */ + {0, 0}, /* IB_SW_LAST_F */ /* * SwitchLinearForwardingTable fields: @@ -220,7 +219,7 @@ ib_field_t ib_mad_f [] = { /* * NodeDescription fields: */ - {0, 64*8, "NodeDesc", mad_dump_string}, + {0, 64 * 8, "NodeDesc", mad_dump_string}, /* * Notice/Trap fields @@ -260,7 +259,7 @@ ib_field_t ib_mad_f [] = { {256, 32, "XmtPkts", mad_dump_uint}, {288, 32, "RcvPkts", mad_dump_uint}, {320, 32, "XmtWait", mad_dump_uint}, - {0, 0}, /* IB_PC_LAST_F */ + {0, 0}, /* IB_PC_LAST_F */ /* * SMInfo @@ -274,26 +273,26 @@ ib_field_t ib_mad_f [] = { /* * SA RMPP */ - {BE_OFFS(24*8+24, 8), "RmppVers", mad_dump_uint}, - {BE_OFFS(24*8+16, 8), "RmppType", mad_dump_uint}, - {BE_OFFS(24*8+11, 5), "RmppResp", mad_dump_uint}, - {BE_OFFS(24*8+8, 3), "RmppFlags", mad_dump_hex}, - {BE_OFFS(24*8+0, 8), "RmppStatus", mad_dump_hex}, + {BE_OFFS(24 * 8 + 24, 8), "RmppVers", mad_dump_uint}, + {BE_OFFS(24 * 8 + 16, 8), "RmppType", mad_dump_uint}, + {BE_OFFS(24 * 8 + 11, 5), "RmppResp", mad_dump_uint}, + {BE_OFFS(24 * 8 + 8, 3), "RmppFlags", mad_dump_hex}, + {BE_OFFS(24 * 8 + 0, 8), "RmppStatus", mad_dump_hex}, /* data1 */ - {28*8, 32, "RmppData1", mad_dump_hex}, - {28*8, 32, "RmppSegNum", mad_dump_uint}, + {28 * 8, 32, "RmppData1", mad_dump_hex}, + {28 * 8, 32, "RmppSegNum", mad_dump_uint}, /* data2 */ - {32*8, 32, "RmppData2", mad_dump_hex}, - {32*8, 32, "RmppPayload", mad_dump_uint}, - {32*8, 32, "RmppNewWin", mad_dump_uint}, - + {32 * 8, 32, "RmppData2", mad_dump_hex}, + {32 * 8, 32, "RmppPayload", mad_dump_uint}, + {32 * 8, 32, "RmppNewWin", mad_dump_uint}, + /* * SA Get Multi Path */ - {BITSOFFS(41,7), "MultiPathNumPath", mad_dump_uint}, - {BITSOFFS(120,8), "MultiPathNumSrc", mad_dump_uint}, - {BITSOFFS(128,8), "MultiPathNumDest", mad_dump_uint}, + {BITSOFFS(41, 7), "MultiPathNumPath", mad_dump_uint}, + {BITSOFFS(120, 8), "MultiPathNumSrc", mad_dump_uint}, + {BITSOFFS(128, 8), "MultiPathNumDest", mad_dump_uint}, {192, 128, "MultiPathGid", mad_dump_array}, /* @@ -301,9 +300,9 @@ ib_field_t ib_mad_f [] = { */ {64, 128, "PathRecDGid", mad_dump_array}, {192, 128, "PathRecSGid", mad_dump_array}, - {BITSOFFS(320,16), "PathRecDLid", mad_dump_hex}, - {BITSOFFS(336,16), "PathRecSLid", mad_dump_hex}, - {BITSOFFS(393,7), "PathRecNumPath", mad_dump_uint}, + {BITSOFFS(320, 16), "PathRecDLid", mad_dump_hex}, + {BITSOFFS(336, 16), "PathRecSLid", mad_dump_hex}, + {BITSOFFS(393, 7), "PathRecNumPath", mad_dump_uint}, /* * MC Member rec @@ -335,10 +334,10 @@ ib_field_t ib_mad_f [] = { /* * ATS SM record - within SA_SR_DATA */ - {12*8, 32, "ATSNodeAddr", mad_dump_hex}, - {BITSOFFS(16*8, 16), "ATSMagicKey", mad_dump_hex}, - {BITSOFFS(18*8, 16), "ATSNodeType", mad_dump_hex}, - {32*8, 32*8, "ATSNodeName", mad_dump_string}, + {12 * 8, 32, "ATSNodeAddr", mad_dump_hex}, + {BITSOFFS(16 * 8, 16), "ATSMagicKey", mad_dump_hex}, + {BITSOFFS(18 * 8, 16), "ATSNodeType", mad_dump_hex}, + {32 * 8, 32 * 8, "ATSNodeName", mad_dump_string}, /* * SLTOVL MAPPING TABLE @@ -353,8 +352,8 @@ ib_field_t ib_mad_f [] = { /* * IB vendor classes range 2 */ - {BE_OFFS(36*8, 24), "OUI", mad_dump_array}, - {40*8, (256-40)*8, "Vendor2Data", mad_dump_array}, + {BE_OFFS(36 * 8, 24), "OUI", mad_dump_array}, + {40 * 8, (256 - 40) * 8, "Vendor2Data", mad_dump_array}, /* * Extended port counters @@ -369,32 +368,36 @@ ib_field_t ib_mad_f [] = { {384, 64, "PortUnicastRcvPkts", mad_dump_uint}, {448, 64, "PortMulticastXmitPkts", mad_dump_uint}, {512, 64, "PortMulticastRcvPkts", mad_dump_uint}, - {0, 0}, /* IB_PC_EXT_LAST_F */ + {0, 0}, /* IB_PC_EXT_LAST_F */ /* * GUIDInfo fields */ {0, 64, "GUID0", mad_dump_hex}, - {0, 0} /* IB_FIELD_LAST_ */ + {0, 0} /* IB_FIELD_LAST_ */ }; -static void _set_field64(void *buf, int base_offs, const ib_field_t *f, uint64_t val) +static void _set_field64(void *buf, int base_offs, const ib_field_t * f, + uint64_t val) { uint64_t nval; nval = htonll(val); - memcpy((char *)buf + base_offs + f->bitoffs / 8, &nval, sizeof(uint64_t)); + memcpy((char *)buf + base_offs + f->bitoffs / 8, &nval, + sizeof(uint64_t)); } -static uint64_t _get_field64(void *buf, int base_offs, const ib_field_t *f) +static uint64_t _get_field64(void *buf, int base_offs, const ib_field_t * f) { uint64_t val; - memcpy(&val, ((char *)buf + base_offs + f->bitoffs / 8), sizeof(uint64_t)); + memcpy(&val, ((char *)buf + base_offs + f->bitoffs / 8), + sizeof(uint64_t)); return ntohll(val); } -static void _set_field(void *buf, int base_offs, const ib_field_t *f, uint32_t val) +static void _set_field(void *buf, int base_offs, const ib_field_t * f, + uint32_t val) { int prebits = (8 - (f->bitoffs & 7)) & 7; int postbits = (f->bitoffs + f->bitlen) & 7; @@ -403,73 +406,77 @@ static void _set_field(void *buf, int base_offs, const ib_field_t *f, uint32_t v char *p = (char *)buf; if (!bytelen && (f->bitoffs & 7) + f->bitlen < 8) { - p[3^idx] &= ~((((1 << f->bitlen) - 1)) << (f->bitoffs & 7)); - p[3^idx] |= (val & ((1 << f->bitlen) - 1)) << (f->bitoffs & 7); + p[3 ^ idx] &= ~((((1 << f->bitlen) - 1)) << (f->bitoffs & 7)); + p[3 ^ idx] |= + (val & ((1 << f->bitlen) - 1)) << (f->bitoffs & 7); return; } - if (prebits) { /* val lsb in byte msb */ - p[3^idx] &= (1 << (8 - prebits)) - 1; - p[3^idx++] |= (val & ((1 << prebits) - 1)) << (8 - prebits); + if (prebits) { /* val lsb in byte msb */ + p[3 ^ idx] &= (1 << (8 - prebits)) - 1; + p[3 ^ idx++] |= (val & ((1 << prebits) - 1)) << (8 - prebits); val >>= prebits; } /* BIG endian byte order */ for (; bytelen--; val >>= 8) - p[3^idx++] = val & 0xff; + p[3 ^ idx++] = val & 0xff; - if (postbits) { /* val msb in byte lsb */ - p[3^idx] &= ~((1 << postbits) - 1); - p[3^idx] |= val; + if (postbits) { /* val msb in byte lsb */ + p[3 ^ idx] &= ~((1 << postbits) - 1); + p[3 ^ idx] |= val; } } -static uint32_t _get_field(void *buf, int base_offs, const ib_field_t *f) +static uint32_t _get_field(void *buf, int base_offs, const ib_field_t * f) { int prebits = (8 - (f->bitoffs & 7)) & 7; int postbits = (f->bitoffs + f->bitlen) & 7; int bytelen = f->bitlen / 8; unsigned idx = base_offs + f->bitoffs / 8; - uint8_t *p = (uint8_t *)buf; + uint8_t *p = (uint8_t *) buf; uint32_t val = 0, v = 0, i; if (!bytelen && (f->bitoffs & 7) + f->bitlen < 8) - return (p[3^idx] >> (f->bitoffs & 7)) & ((1 << f->bitlen) - 1); + return (p[3 ^ idx] >> (f->bitoffs & 7)) & ((1 << f->bitlen) - + 1); - if (prebits) /* val lsb from byte msb */ - v = p[3^idx++] >> (8 - prebits); + if (prebits) /* val lsb from byte msb */ + v = p[3 ^ idx++] >> (8 - prebits); - if (postbits) { /* val msb from byte lsb */ + if (postbits) { /* val msb from byte lsb */ i = base_offs + (f->bitoffs + f->bitlen) / 8; - val = (p[3^i] & ((1 << postbits) - 1)); + val = (p[3 ^ i] & ((1 << postbits) - 1)); } /* BIG endian byte order */ for (idx += bytelen - 1; bytelen--; idx--) - val = (val << 8) | p[3^idx]; + val = (val << 8) | p[3 ^ idx]; return (val << prebits) | v; } /* field must be byte aligned */ -static void _set_array(void *buf, int base_offs, const ib_field_t *f, void *val) +static void _set_array(void *buf, int base_offs, const ib_field_t * f, + void *val) { int bitoffs = f->bitoffs; if (f->bitlen < 32) bitoffs = BE_TO_BITSOFFS(bitoffs, f->bitlen); - memcpy((uint8_t *)buf + base_offs + bitoffs / 8, val, f->bitlen / 8); + memcpy((uint8_t *) buf + base_offs + bitoffs / 8, val, f->bitlen / 8); } -static void _get_array(void *buf, int base_offs, const ib_field_t *f, void *val) +static void _get_array(void *buf, int base_offs, const ib_field_t * f, + void *val) { int bitoffs = f->bitoffs; if (f->bitlen < 32) bitoffs = BE_TO_BITSOFFS(bitoffs, f->bitlen); - memcpy(val, (uint8_t *)buf + base_offs + bitoffs / 8, f->bitlen / 8); + memcpy(val, (uint8_t *) buf + base_offs + bitoffs / 8, f->bitlen / 8); } uint32_t mad_get_field(void *buf, int base_offs, int field) @@ -502,7 +509,7 @@ void mad_get_array(void *buf, int base_offs, int 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, int field, void *val) { const ib_field_t *f = ib_mad_f + field; @@ -511,17 +518,17 @@ void mad_decode_field(uint8_t *buf, int field, void *val) return; } if (f->bitlen <= 32) { - *(uint32_t *)val = _get_field(buf, 0, f); + *(uint32_t *) val = _get_field(buf, 0, f); return; } if (f->bitlen == 64) { - *(uint64_t *)val = _get_field64(buf, 0, f); + *(uint64_t *) val = _get_field64(buf, 0, f); return; } _get_array(buf, 0, f, val); } -void mad_encode_field(uint8_t *buf, int field, void *val) +void mad_encode_field(uint8_t * buf, int field, void *val) { const ib_field_t *f = ib_mad_f + field; @@ -530,11 +537,11 @@ void mad_encode_field(uint8_t *buf, int field, void *val) return; } if (f->bitlen <= 32) { - _set_field(buf, 0, f, *(uint32_t *)val); + _set_field(buf, 0, f, *(uint32_t *) val); return; } if (f->bitlen == 64) { - _set_field64(buf, 0, f, *(uint64_t *)val); + _set_field64(buf, 0, f, *(uint64_t *) val); return; } _set_array(buf, 0, f, val); @@ -542,7 +549,8 @@ void mad_encode_field(uint8_t *buf, int field, void *val) /************************/ -static char *_mad_dump_val(const ib_field_t *f, char *buf, int bufsz, void *val) +static char *_mad_dump_val(const ib_field_t * f, char *buf, int bufsz, + void *val) { f->def_dump_fn(buf, bufsz, val, ALIGN(f->bitlen, 8) / 8); buf[bufsz - 1] = 0; @@ -550,13 +558,14 @@ static char *_mad_dump_val(const ib_field_t *f, char *buf, int bufsz, void *val) return buf; } -static char *_mad_dump_field(const ib_field_t *f, const char *name, char *buf, int bufsz, void *val) +static char *_mad_dump_field(const ib_field_t * f, const char *name, char *buf, + int bufsz, void *val) { char dots[128]; int l, n; if (bufsz <= 32) - return 0; /* buf too small */ + return 0; /* buf too small */ if (!name) name = f->name; @@ -574,7 +583,8 @@ static char *_mad_dump_field(const ib_field_t *f, const char *name, char *buf, i return buf; } -static int _mad_dump(ib_mad_dump_fn *fn, const char *name, void *val, int valsz) +static int _mad_dump(ib_mad_dump_fn * fn, const char *name, void *val, + int valsz) { ib_field_t f; char buf[512]; @@ -585,9 +595,11 @@ static int _mad_dump(ib_mad_dump_fn *fn, const char *name, void *val, int valsz) return printf("%s\n", _mad_dump_field(&f, name, buf, sizeof buf, val)); } -static int _mad_print_field(const ib_field_t *f, const char *name, void *val, int valsz) +static int _mad_print_field(const ib_field_t * f, const char *name, void *val, + int valsz) { - return _mad_dump(f->def_dump_fn, name ? name : f->name, val, valsz ? valsz : ALIGN(f->bitlen, 8) / 8); + return _mad_dump(f->def_dump_fn, name ? name : f->name, val, + valsz ? valsz : ALIGN(f->bitlen, 8) / 8); } int mad_print_field(int field, const char *name, void *val) diff --git a/branches/winverbs/ulp/libibmad/src/gs.c b/branches/winverbs/ulp/libibmad/src/gs.c index 05ee132b..4e347280 100644 --- a/branches/winverbs/ulp/libibmad/src/gs.c +++ b/branches/winverbs/ulp/libibmad/src/gs.c @@ -33,19 +33,23 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include -#include "mad.h" #include +#include #undef DEBUG #define DEBUG if (ibdebug) IBWARN -static uint8_t * -pma_query_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout, unsigned id, const void *srcport) +static uint8_t *pma_query_via(void *rcvbuf, ib_portid_t * dest, int port, + unsigned timeout, unsigned id, + const void *srcport) { - ib_rpc_t rpc = {0}; + ib_rpc_t rpc = { 0 }; int lid = dest->lid; DEBUG("lid %d port %d", lid, port); @@ -77,45 +81,44 @@ pma_query_via(void *rcvbuf, ib_portid_t *dest, int port, } } -uint8_t * -pma_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout, unsigned id) +uint8_t *pma_query(void *rcvbuf, ib_portid_t * dest, int port, unsigned timeout, + unsigned id) { return pma_query_via(rcvbuf, dest, port, timeout, id, NULL); } -uint8_t * -perf_classportinfo_query_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout, const void *srcport) +uint8_t *perf_classportinfo_query_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout, + const void *srcport) { return pma_query_via(rcvbuf, dest, port, timeout, CLASS_PORT_INFO, srcport); } -uint8_t * -perf_classportinfo_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout) +uint8_t *perf_classportinfo_query(void *rcvbuf, ib_portid_t * dest, int port, + unsigned timeout) { return pma_query(rcvbuf, dest, port, timeout, CLASS_PORT_INFO); } -uint8_t * -port_performance_query_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout, const void *srcport) +uint8_t *port_performance_query_via(void *rcvbuf, ib_portid_t * dest, int port, + unsigned timeout, const void *srcport) { return pma_query_via(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS, srcport); } -uint8_t * -port_performance_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout) +uint8_t *port_performance_query(void *rcvbuf, ib_portid_t * dest, int port, + unsigned timeout) { return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS); } -static uint8_t * -performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask, - unsigned timeout, unsigned id, const void *srcport) +static uint8_t *performance_reset_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned mask, unsigned timeout, + unsigned id, const void *srcport) { - ib_rpc_t rpc = {0}; + ib_rpc_t rpc = { 0 }; int lid = dest->lid; DEBUG("lid %d port %d mask 0x%x", lid, port, mask); @@ -137,6 +140,8 @@ performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask, /* Same for attribute IDs */ mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port); mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT_F, mask); + mask = mask >> 16; + mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT2_F, mask); rpc.attr.mod = 0; rpc.timeout = timeout; rpc.datasz = IB_PC_DATA_SZ; @@ -152,83 +157,83 @@ performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask, } } -static uint8_t * -performance_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask, - unsigned timeout, unsigned id) +static uint8_t *performance_reset(void *rcvbuf, ib_portid_t * dest, int port, + unsigned mask, unsigned timeout, unsigned id) { return performance_reset_via(rcvbuf, dest, port, mask, timeout, id, NULL); } -uint8_t * -port_performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned mask, unsigned timeout, const void *srcport) +uint8_t *port_performance_reset_via(void *rcvbuf, ib_portid_t * dest, int port, + unsigned mask, unsigned timeout, + const void *srcport) { return performance_reset_via(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS, srcport); } -uint8_t * -port_performance_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask, - unsigned timeout) +uint8_t *port_performance_reset(void *rcvbuf, ib_portid_t * dest, int port, + unsigned mask, unsigned timeout) { - return performance_reset(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS); + return performance_reset(rcvbuf, dest, port, mask, timeout, + IB_GSI_PORT_COUNTERS); } -uint8_t * -port_performance_ext_query_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout, const void *srcport) +uint8_t *port_performance_ext_query_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout, + const void *srcport) { return pma_query_via(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS_EXT, srcport); } -uint8_t * -port_performance_ext_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout) +uint8_t *port_performance_ext_query(void *rcvbuf, ib_portid_t * dest, int port, + unsigned timeout) { return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS_EXT); } -uint8_t * -port_performance_ext_reset_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned mask, unsigned timeout, - const void *srcport) +uint8_t *port_performance_ext_reset_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned mask, + unsigned timeout, const void *srcport) { return performance_reset_via(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS_EXT, srcport); } -uint8_t * -port_performance_ext_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask, - unsigned timeout) +uint8_t *port_performance_ext_reset(void *rcvbuf, ib_portid_t * dest, int port, + unsigned mask, unsigned timeout) { - return performance_reset(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS_EXT); + return performance_reset(rcvbuf, dest, port, mask, timeout, + IB_GSI_PORT_COUNTERS_EXT); } -uint8_t * -port_samples_control_query_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout, const void *srcport) +uint8_t *port_samples_control_query_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout, + const void *srcport) { return pma_query_via(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_CONTROL, srcport); } -uint8_t * -port_samples_control_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout) +uint8_t *port_samples_control_query(void *rcvbuf, ib_portid_t * dest, int port, + unsigned timeout) { - return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_CONTROL); + return pma_query(rcvbuf, dest, port, timeout, + IB_GSI_PORT_SAMPLES_CONTROL); } -uint8_t * -port_samples_result_query_via(void *rcvbuf, ib_portid_t *dest, int port, - unsigned timeout, const void *srcport) +uint8_t *port_samples_result_query_via(void *rcvbuf, ib_portid_t * dest, + int port, unsigned timeout, + const void *srcport) { return pma_query_via(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_RESULT, srcport); } -uint8_t * -port_samples_result_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout) +uint8_t *port_samples_result_query(void *rcvbuf, ib_portid_t * dest, int port, + unsigned timeout) { - return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_RESULT); + return pma_query(rcvbuf, dest, port, timeout, + IB_GSI_PORT_SAMPLES_RESULT); } diff --git a/branches/winverbs/ulp/libibmad/src/mad.c b/branches/winverbs/ulp/libibmad/src/mad.c index 4a12e6ca..d059a70f 100644 --- a/branches/winverbs/ulp/libibmad/src/mad.c +++ b/branches/winverbs/ulp/libibmad/src/mad.c @@ -33,25 +33,27 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ +#include +#include +#include #include -#include #include +#include #undef DEBUG #define DEBUG if (ibdebug) IBWARN -uint64_t -mad_trid(void) +uint64_t mad_trid(void) { static uint64_t base; static uint64_t trid; uint64_t next; if (!base) { - srandom((int)time(0)*getpid()); + srandom((int)time(0) * getpid()); base = random(); trid = random(); } @@ -59,15 +61,15 @@ mad_trid(void) return next; } -void * -mad_encode(void *buf, ib_rpc_t *rpc, ib_dr_path_t *drpath, void *data) +void *mad_encode(void *buf, ib_rpc_t * rpc, ib_dr_path_t * drpath, void *data) { int is_resp = rpc->method & IB_MAD_RESPONSE; /* first word */ mad_set_field(buf, 0, IB_MAD_METHOD_F, rpc->method); mad_set_field(buf, 0, IB_MAD_RESPONSE_F, is_resp ? 1 : 0); - mad_set_field(buf, 0, IB_MAD_CLASSVER_F, rpc->mgtclass == IB_SA_CLASS ? 2 : 1); + mad_set_field(buf, 0, IB_MAD_CLASSVER_F, + rpc->mgtclass == IB_SA_CLASS ? 2 : 1); mad_set_field(buf, 0, IB_MAD_MGMTCLASS_F, rpc->mgtclass); mad_set_field(buf, 0, IB_MAD_BASEVER_F, 1); @@ -78,7 +80,8 @@ mad_encode(void *buf, ib_rpc_t *rpc, ib_dr_path_t *drpath, void *data) return 0; } mad_set_field(buf, 0, IB_DRSMP_HOPCNT_F, drpath->cnt); - mad_set_field(buf, 0, IB_DRSMP_HOPPTR_F, is_resp ? drpath->cnt + 1 : 0x0); + mad_set_field(buf, 0, IB_DRSMP_HOPPTR_F, + is_resp ? drpath->cnt + 1 : 0x0); mad_set_field(buf, 0, IB_DRSMP_STATUS_F, rpc->rstatus); mad_set_field(buf, 0, IB_DRSMP_DIRECTION_F, is_resp ? 1 : 0); /* out */ } else @@ -93,15 +96,18 @@ mad_encode(void *buf, ib_rpc_t *rpc, ib_dr_path_t *drpath, void *data) 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_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)); if (rpc->mgtclass == IB_SMI_DIRECT_CLASS) { /* word 9 */ - mad_set_field(buf, 0, IB_DRSMP_DRDLID_F, drpath->drdlid ? drpath->drdlid : 0xffff); - mad_set_field(buf, 0, IB_DRSMP_DRSLID_F, drpath->drslid ? drpath->drslid : 0xffff); + mad_set_field(buf, 0, IB_DRSMP_DRDLID_F, + drpath->drdlid ? drpath->drdlid : 0xffff); + mad_set_field(buf, 0, IB_DRSMP_DRSLID_F, + drpath->drslid ? drpath->drslid : 0xffff); - /* bytes 128 - 256 - by default should be zero due to memset*/ + /* bytes 128 - 256 - by default should be zero due to memset */ if (is_resp) mad_set_array(buf, 0, IB_DRSMP_RPATH_F, drpath->p); else @@ -118,12 +124,11 @@ mad_encode(void *buf, ib_rpc_t *rpc, ib_dr_path_t *drpath, void *data) if (mad_is_vendor_range2(rpc->mgtclass)) mad_set_field(buf, 0, IB_VEND2_OUI_F, rpc->oui); - return (uint8_t *)buf + IB_MAD_SIZE; + return (uint8_t *) buf + IB_MAD_SIZE; } -int -mad_build_pkt(void *umad, ib_rpc_t *rpc, ib_portid_t *dport, - ib_rmpp_hdr_t *rmpp, void *data) +int mad_build_pkt(void *umad, ib_rpc_t * rpc, ib_portid_t * dport, + ib_rmpp_hdr_t * rmpp, void *data) { uint8_t *p, *mad; int lid_routed = rpc->mgtclass != IB_SMI_DIRECT_CLASS; @@ -132,7 +137,8 @@ mad_build_pkt(void *umad, ib_rpc_t *rpc, ib_portid_t *dport, struct ib_mad_addr addr; if (!is_smi) - umad_set_addr(umad, dport->lid, dport->qp, dport->sl, dport->qkey); + umad_set_addr(umad, dport->lid, dport->qp, dport->sl, + dport->qkey); else if (lid_routed) umad_set_addr(umad, dport->lid, dport->qp, 0, 0); else if ((dport->drpath.drslid != 0xffff) && (dport->lid > 0)) diff --git a/branches/winverbs/ulp/libibmad/src/portid.c b/branches/winverbs/ulp/libibmad/src/portid.c index 9a697287..1daf005b 100644 --- a/branches/winverbs/ulp/libibmad/src/portid.c +++ b/branches/winverbs/ulp/libibmad/src/portid.c @@ -33,19 +33,18 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ #include #include #include -#include +#include #undef DEBUG #define DEBUG if (ibdebug) IBWARN -int -portid2portnum(ib_portid_t *portid) +int portid2portnum(ib_portid_t * portid) { if (portid->lid > 0) return -1; @@ -53,11 +52,10 @@ portid2portnum(ib_portid_t *portid) if (portid->drpath.cnt == 0) return 0; - return portid->drpath.p[(portid->drpath.cnt-1)]; + return portid->drpath.p[(portid->drpath.cnt - 1)]; } -char * -portid2str(ib_portid_t *portid) +char *portid2str(ib_portid_t * portid) { static char buf[1024] = "local"; int n = 0; @@ -65,7 +63,8 @@ portid2str(ib_portid_t *portid) if (portid->lid > 0) { n += sprintf(buf + n, "Lid %d", portid->lid); if (portid->grh_present) { - char gid[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"]; + char gid[sizeof + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"]; if (inet_ntop(AF_INET6, portid->gid, gid, sizeof(gid))) n += sprintf(buf + n, " Gid %s", gid); } @@ -80,8 +79,7 @@ portid2str(ib_portid_t *portid) return buf; } -int -str2drpath(ib_dr_path_t *path, char *routepath, int drslid, int drdlid) +int str2drpath(ib_dr_path_t * path, char *routepath, int drslid, int drdlid) { char *s, *str = routepath; @@ -91,10 +89,10 @@ str2drpath(ib_dr_path_t *path, char *routepath, int drslid, int drdlid) while (str && *str) { if ((s = strchr(str, ','))) *s = 0; - path->p[++path->cnt] = (uint8_t)atoi(str); + path->p[++path->cnt] = (uint8_t) atoi(str); if (!s) break; - str = s+1; + str = s + 1; } path->drdlid = drdlid ? drdlid : 0xffff; @@ -103,16 +101,15 @@ str2drpath(ib_dr_path_t *path, char *routepath, int drslid, int drdlid) return path->cnt; } -char * -drpath2str(ib_dr_path_t *path, char *dstr, size_t dstr_size) +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", - path->drslid, path->drdlid, path->p[0]); + path->drslid, path->drdlid, path->p[0]); if (rc >= (int)dstr_size) return dstr; for (i = 1; i <= path->cnt; i++) { - rc += snprintf(dstr+rc, dstr_size-rc, ",%d", path->p[i]); + rc += snprintf(dstr + rc, dstr_size - rc, ",%d", path->p[i]); if (rc >= (int)dstr_size) break; } diff --git a/branches/winverbs/ulp/libibmad/src/register.c b/branches/winverbs/ulp/libibmad/src/register.c index ea916da8..4d91ff89 100644 --- a/branches/winverbs/ulp/libibmad/src/register.c +++ b/branches/winverbs/ulp/libibmad/src/register.c @@ -33,15 +33,15 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ #include #include #include #include -#include "mad.h" #include +#include #undef DEBUG #define DEBUG if (ibdebug) IBWARN @@ -52,8 +52,7 @@ static int class_agent[MAX_CLASS]; static int agent_class[MAX_AGENTS]; -static int -register_agent(int agent, int mclass) +static int register_agent(int agent, int mclass) { static int initialized; @@ -75,8 +74,7 @@ register_agent(int agent, int mclass) return 0; } -static int -mgmt_class_vers(int mgmt_class) +static int mgmt_class_vers(int mgmt_class) { if ((mgmt_class >= IB_VENDOR_RANGE1_START_CLASS && mgmt_class <= IB_VENDOR_RANGE1_END_CLASS) || @@ -84,41 +82,38 @@ mgmt_class_vers(int mgmt_class) mgmt_class <= IB_VENDOR_RANGE2_END_CLASS)) return 1; - switch(mgmt_class) { - case IB_SMI_CLASS: - case IB_SMI_DIRECT_CLASS: - return 1; - case IB_SA_CLASS: - return 2; - case IB_PERFORMANCE_CLASS: - return 1; - case IB_DEVICE_MGMT_CLASS: - return 1; - case IB_CC_CLASS: - return 2; + switch (mgmt_class) { + case IB_SMI_CLASS: + case IB_SMI_DIRECT_CLASS: + return 1; + case IB_SA_CLASS: + return 2; + case IB_PERFORMANCE_CLASS: + return 1; + case IB_DEVICE_MGMT_CLASS: + return 1; + case IB_CC_CLASS: + return 2; } return 0; } -int -mad_class_agent(int mgmt) +int mad_class_agent(int mgmt) { if (mgmt < 1 || mgmt > MAX_CLASS) return -1; return class_agent[mgmt]; } -int -mad_agent_class(int agent) +int mad_agent_class(int agent) { if (agent < 1 || agent > MAX_AGENTS) return -1; return agent_class[agent]; } -int -mad_register_port_client(int port_id, int mgmt, uint8_t rmpp_version) +int mad_register_port_client(int port_id, int mgmt, uint8_t rmpp_version) { int vers, agent; @@ -126,8 +121,7 @@ mad_register_port_client(int port_id, int mgmt, uint8_t rmpp_version) DEBUG("Unknown class %d mgmt_class", mgmt); return -1; } - if ((agent = umad_register(port_id, mgmt, - vers, rmpp_version, 0)) < 0) { + if ((agent = umad_register(port_id, mgmt, vers, rmpp_version, 0)) < 0) { DEBUG("Can't register agent for class %d", mgmt); return -1; } @@ -140,8 +134,7 @@ mad_register_port_client(int port_id, int mgmt, uint8_t rmpp_version) return agent; } -int -mad_register_client(int mgmt, uint8_t rmpp_version) +int mad_register_client(int mgmt, uint8_t rmpp_version) { int agent; @@ -156,12 +149,13 @@ int mad_register_server(int mgmt, uint8_t rmpp_version, long method_mask[], uint32_t class_oui) { - long class_method_mask[16/sizeof(long)]; + long class_method_mask[16 / sizeof(long)]; uint8_t oui[3]; int agent, vers, mad_portid; if (method_mask) - memcpy(class_method_mask, method_mask, sizeof class_method_mask); + memcpy(class_method_mask, method_mask, + sizeof class_method_mask); else memset(class_method_mask, 0xff, sizeof(class_method_mask)); diff --git a/branches/winverbs/ulp/libibmad/src/resolve.c b/branches/winverbs/ulp/libibmad/src/resolve.c index 2e373e6f..b62360b1 100644 --- a/branches/winverbs/ulp/libibmad/src/resolve.c +++ b/branches/winverbs/ulp/libibmad/src/resolve.c @@ -33,29 +33,27 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ #include #include #include -#include #include +#include #undef DEBUG #define DEBUG if (ibdebug) IBWARN -int -ib_resolve_smlid_via(ib_portid_t *sm_id, int timeout, const void *srcport) +int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout, const void *srcport) { - ib_portid_t self = {0}; + ib_portid_t self = { 0 }; uint8_t portinfo[64]; int lid; memset(sm_id, 0, sizeof(*sm_id)); - if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, - 0, 0, srcport)) + if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport)) return -1; mad_decode_field(portinfo, IB_PORT_SMLID_F, &lid); @@ -63,41 +61,44 @@ ib_resolve_smlid_via(ib_portid_t *sm_id, int timeout, const void *srcport) return ib_portid_set(sm_id, lid, 0, 0); } -int -ib_resolve_smlid(ib_portid_t *sm_id, int timeout) +int ib_resolve_smlid(ib_portid_t * sm_id, int timeout) { return ib_resolve_smlid_via(sm_id, timeout, NULL); } -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_guid_via(ib_portid_t * portid, uint64_t * guid, + ib_portid_t * sm_id, int timeout, const void *srcport) { ib_portid_t sm_portid; - char buf[IB_SA_DATA_SIZE] = {0}; + char buf[IB_SA_DATA_SIZE] = { 0 }; if (!sm_id) { sm_id = &sm_portid; if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0) return -1; } - if (*(uint64_t*)&portid->gid == 0) - mad_set_field64(portid->gid, 0, IB_GID_PREFIX_F, IB_DEFAULT_SUBN_PREFIX); + if (*(uint64_t *) & portid->gid == 0) + mad_set_field64(portid->gid, 0, IB_GID_PREFIX_F, + IB_DEFAULT_SUBN_PREFIX); if (guid) mad_set_field64(portid->gid, 0, IB_GID_GUID_F, *guid); - if ((portid->lid = ib_path_query_via(srcport, portid->gid, portid->gid, sm_id, buf)) < 0) + if ((portid->lid = + ib_path_query_via(srcport, portid->gid, portid->gid, sm_id, + buf)) < 0) return -1; return 0; } -int -ib_resolve_portid_str_via(ib_portid_t *portid, char *addr_str, int dest_type, ib_portid_t *sm_id, const void *srcport) +int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str, + int dest_type, ib_portid_t * sm_id, + const void *srcport) { uint64_t guid; int lid; char *routepath; - ib_portid_t selfportid = {0}; + ib_portid_t selfportid = { 0 }; int selfport = 0; switch (dest_type) { @@ -129,7 +130,8 @@ ib_resolve_portid_str_via(ib_portid_t *portid, char *addr_str, int dest_type, ib /* handle DR parsing and set DrSLID to local lid */ if (ib_resolve_self_via(&selfportid, &selfport, 0, srcport) < 0) return -1; - if (str2drpath(&portid->drpath, routepath, selfportid.lid, 0) < 0) + if (str2drpath(&portid->drpath, routepath, selfportid.lid, 0) < + 0) return -1; return 0; @@ -140,18 +142,17 @@ ib_resolve_portid_str_via(ib_portid_t *portid, char *addr_str, int dest_type, ib 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, int dest_type, + ib_portid_t * sm_id) { return ib_resolve_portid_str_via(portid, addr_str, dest_type, sm_id, NULL); } -int -ib_resolve_self_via(ib_portid_t *portid, int *portnum, ibmad_gid_t *gid, - const void *srcport) +int ib_resolve_self_via(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid, + const void *srcport) { - ib_portid_t self = {0}; + ib_portid_t self = { 0 }; uint8_t portinfo[64]; uint8_t nodeinfo[64]; uint64_t guid, prefix; @@ -175,8 +176,7 @@ ib_resolve_self_via(ib_portid_t *portid, int *portnum, ibmad_gid_t *gid, return 0; } -int -ib_resolve_self(ib_portid_t *portid, int *portnum, ibmad_gid_t *gid) +int ib_resolve_self(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid) { - return ib_resolve_self_via (portid, portnum, gid, NULL); + return ib_resolve_self_via(portid, portnum, gid, NULL); } diff --git a/branches/winverbs/ulp/libibmad/src/rpc.c b/branches/winverbs/ulp/libibmad/src/rpc.c index 3bf36406..e8115269 100644 --- a/branches/winverbs/ulp/libibmad/src/rpc.c +++ b/branches/winverbs/ulp/libibmad/src/rpc.c @@ -33,21 +33,21 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ #include #include #include #include -#include "mad.h" #include +#include #define MAX_CLASS 256 struct ibmad_port { - int port_id; /* file descriptor returned by umad_open() */ - int class_agents[MAX_CLASS]; /* class2agent mapper */ + int port_id; /* file descriptor returned by umad_open() */ + int class_agents[MAX_CLASS]; /* class2agent mapper */ }; int ibdebug; @@ -66,42 +66,36 @@ static int save_mad_len = 256; #define MAD_TID(mad) (*((uint64_t *)((char *)(mad) + 8))) -void -madrpc_show_errors(int set) +void madrpc_show_errors(int set) { iberrs = set; } -void -madrpc_save_mad(void *madbuf, int len) +void madrpc_save_mad(void *madbuf, int len) { save_mad = madbuf; save_mad_len = len; } -int -madrpc_set_retries(int retries) +int madrpc_set_retries(int retries) { if (retries > 0) madrpc_retries = retries; return madrpc_retries; } -int -madrpc_set_timeout(int timeout) +int madrpc_set_timeout(int timeout) { def_madrpc_timeout = timeout; return 0; } -int -madrpc_def_timeout(void) +int madrpc_def_timeout(void) { return def_madrpc_timeout; } -int -madrpc_portid(void) +int madrpc_portid(void) { return mad_portid; } @@ -110,7 +104,7 @@ static int _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len, int timeout) { - uint32_t trid; /* only low 32 bits */ + uint32_t trid; /* only low 32 bits */ int retries; int length, status; @@ -128,7 +122,8 @@ _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len, save_mad = 0; } - trid = (uint32_t)mad_get_field64(umad_get_mad(sndbuf), 0, IB_MAD_TRID_F); + trid = + (uint32_t) mad_get_field64(umad_get_mad(sndbuf), 0, IB_MAD_TRID_F); for (retries = 0; retries < madrpc_retries; retries++) { if (retries) { @@ -151,13 +146,16 @@ _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len, if (ibdebug > 1) { IBWARN("rcv buf:"); - xdump(stderr, "rcv buf\n", umad_get_mad(rcvbuf), IB_MAD_SIZE); + xdump(stderr, "rcv buf\n", umad_get_mad(rcvbuf), + IB_MAD_SIZE); } - } while ((uint32_t)mad_get_field64(umad_get_mad(rcvbuf), 0, IB_MAD_TRID_F) != trid); + } while ((uint32_t) + mad_get_field64(umad_get_mad(rcvbuf), 0, + IB_MAD_TRID_F) != trid); status = umad_status(rcvbuf); if (!status) - return length; /* done */ + return length; /* done */ if (status == ENOMEM) return length; } @@ -166,9 +164,8 @@ _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len, return -1; } -void * -mad_rpc(const void *port_id, ib_rpc_t *rpc, ib_portid_t *dport, void *payload, - void *rcvdata) +void *mad_rpc(const void *port_id, ib_rpc_t * rpc, ib_portid_t * dport, + void *payload, void *rcvdata) { const struct ibmad_port *p = port_id; int status, len; @@ -191,7 +188,7 @@ mad_rpc(const void *port_id, ib_rpc_t *rpc, ib_portid_t *dport, void *payload, if ((status = mad_get_field(mad, 0, IB_DRSMP_STATUS_F)) != 0) { ERRS("MAD completed with error status 0x%x; dport (%s)", - status, portid2str(dport)); + status, portid2str(dport)); return 0; } @@ -206,9 +203,8 @@ mad_rpc(const void *port_id, ib_rpc_t *rpc, ib_portid_t *dport, void *payload, return rcvdata; } -void * -mad_rpc_rmpp(const void *port_id, ib_rpc_t *rpc, ib_portid_t *dport, - ib_rmpp_hdr_t *rmpp, void *data) +void *mad_rpc_rmpp(const void *port_id, ib_rpc_t * rpc, ib_portid_t * dport, + ib_rmpp_hdr_t * rmpp, void *data) { const struct ibmad_port *p = port_id; int status, len; @@ -232,7 +228,7 @@ mad_rpc_rmpp(const void *port_id, ib_rpc_t *rpc, ib_portid_t *dport, if ((status = mad_get_field(mad, 0, IB_MAD_STATUS_F)) != 0) { ERRS("MAD completed with error status 0x%x; dport (%s)", - status, portid2str(dport)); + status, portid2str(dport)); return 0; } @@ -264,8 +260,7 @@ mad_rpc_rmpp(const void *port_id, ib_rpc_t *rpc, ib_portid_t *dport, return data; } -void * -madrpc(ib_rpc_t *rpc, ib_portid_t *dport, void *payload, void *rcvdata) +void *madrpc(ib_rpc_t * rpc, ib_portid_t * dport, void *payload, void *rcvdata) { struct ibmad_port port; @@ -274,8 +269,8 @@ madrpc(ib_rpc_t *rpc, ib_portid_t *dport, void *payload, void *rcvdata) return mad_rpc(&port, rpc, dport, payload, rcvdata); } -void * -madrpc_rmpp(ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp, void *data) +void *madrpc_rmpp(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp, + void *data) { struct ibmad_port port; @@ -303,13 +298,13 @@ madrpc_init(char *dev_name, int dev_port, int *mgmt_classes, int num_classes) if (mgmt == IB_SA_CLASS) rmpp_version = 1; if (mad_register_client(mgmt, rmpp_version) < 0) - IBPANIC("client_register for mgmt class %d failed", mgmt); + IBPANIC("client_register for mgmt class %d failed", + mgmt); } } -void * -mad_rpc_open_port(char *dev_name, int dev_port, - int *mgmt_classes, int num_classes) +void *mad_rpc_open_port(char *dev_name, int dev_port, + int *mgmt_classes, int num_classes) { struct ibmad_port *p; int port_id; @@ -352,11 +347,11 @@ mad_rpc_open_port(char *dev_name, int dev_port, (agent = mad_register_port_client(port_id, mgmt, rmpp_version)) < 0) { IBWARN("client_register for mgmt %d failed", mgmt); - if(!errno) + if (!errno) errno = EINVAL; umad_close_port(port_id); - free(p); - return NULL; + free(p); + return NULL; } p->class_agents[mgmt] = agent; } @@ -365,8 +360,7 @@ mad_rpc_open_port(char *dev_name, int dev_port, return p; } -void -mad_rpc_close_port(void *port_id) +void mad_rpc_close_port(void *port_id) { struct ibmad_port *p = port_id; @@ -374,8 +368,8 @@ mad_rpc_close_port(void *port_id) free(p); } -uint8_t * -sa_call(void *rcvbuf, ib_portid_t *portid, ib_sa_call_t *sa, unsigned timeout) +uint8_t *sa_call(void *rcvbuf, ib_portid_t * portid, ib_sa_call_t * sa, + unsigned timeout) { struct ibmad_port port; diff --git a/branches/winverbs/ulp/libibmad/src/sa.c b/branches/winverbs/ulp/libibmad/src/sa.c index c08a3921..7403d4f0 100644 --- a/branches/winverbs/ulp/libibmad/src/sa.c +++ b/branches/winverbs/ulp/libibmad/src/sa.c @@ -33,22 +33,21 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ #include #include #include -#include +#include #undef DEBUG #define DEBUG if (ibdebug) IBWARN -uint8_t * -sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t *portid, - ib_sa_call_t *sa, unsigned timeout) +uint8_t *sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t * portid, + ib_sa_call_t * sa, unsigned timeout) { - ib_rpc_t rpc = {0}; + ib_rpc_t rpc = { 0 }; uint8_t *p; DEBUG("attr 0x%x mod 0x%x route %s", sa->attrid, sa->mod, @@ -73,7 +72,7 @@ sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t *portid, if (!portid->qkey) portid->qkey = IB_DEFAULT_QP1_QKEY; - p = mad_rpc_rmpp(ibmad_port, &rpc, portid, 0/*&sa->rmpp*/, rcvbuf); /* TODO: RMPP */ + p = mad_rpc_rmpp(ibmad_port, &rpc, portid, 0 /*&sa->rmpp */ , rcvbuf); /* TODO: RMPP */ sa->recsz = rpc.recsz; @@ -107,15 +106,15 @@ sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t *portid, IB_PR_COMPMASK_SGID |\ IB_PR_COMPMASK_NUMBPATH) -int -ib_path_query_via(const void *srcport, ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t *sm_id, void *buf) +int ib_path_query_via(const void *srcport, ibmad_gid_t srcgid, + ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf) { int npath; - ib_sa_call_t sa = {0}; + ib_sa_call_t sa = { 0 }; uint8_t *p; int dlid; - npath = 1; /* only MAD_METHOD_GET is supported */ + npath = 1; /* only MAD_METHOD_GET is supported */ memset(&sa, 0, sizeof sa); sa.method = IB_MAD_METHOD_GET; sa.attrid = IB_SA_ATTR_PATHRECORD; @@ -129,7 +128,7 @@ ib_path_query_via(const void *srcport, ibmad_gid_t srcgid, ibmad_gid_t destgid, mad_encode_field(buf, IB_SA_PR_SGID_F, srcgid); if (srcport) { - p = sa_rpc_call (srcport, buf, sm_id, &sa, 0); + p = sa_rpc_call(srcport, buf, sm_id, &sa, 0); } else { p = sa_call(buf, sm_id, &sa, 0); } @@ -142,8 +141,8 @@ ib_path_query_via(const void *srcport, ibmad_gid_t srcgid, ibmad_gid_t destgid, return dlid; } -int -ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t *sm_id, void *buf) +int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t * sm_id, + void *buf) { return ib_path_query_via(NULL, srcgid, destgid, sm_id, buf); } diff --git a/branches/winverbs/ulp/libibmad/src/serv.c b/branches/winverbs/ulp/libibmad/src/serv.c index 611a93f8..c7631bb7 100644 --- a/branches/winverbs/ulp/libibmad/src/serv.c +++ b/branches/winverbs/ulp/libibmad/src/serv.c @@ -33,20 +33,20 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ #include #include #include -#include #include +#include #undef DEBUG #define DEBUG if (ibdebug) IBWARN int -mad_send(ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp, void *data) +mad_send(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp, void *data) { uint8_t pktbuf[1024]; void *umad = pktbuf; @@ -61,7 +61,7 @@ mad_send(ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp, void *data) if (ibdebug) { IBWARN("data offs %d sz %d", rpc->dataoffs, rpc->datasz); xdump(stderr, "mad send data\n", - (char *)umad_get_mad(umad) + rpc->dataoffs, rpc->datasz); + (char *)umad_get_mad(umad) + rpc->dataoffs, rpc->datasz); } if (umad_send(madrpc_portid(), mad_class_agent(rpc->mgtclass), @@ -73,12 +73,11 @@ mad_send(ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp, void *data) return 0; } -int -mad_respond(void *umad, ib_portid_t *portid, uint32_t rstatus) +int mad_respond(void *umad, ib_portid_t * portid, uint32_t rstatus) { uint8_t *mad = umad_get_mad(umad); ib_mad_addr_t *mad_addr; - ib_rpc_t rpc = {0}; + ib_rpc_t rpc = { 0 }; ib_portid_t rport; int is_smi; @@ -118,19 +117,20 @@ mad_respond(void *umad, ib_portid_t *portid, uint32_t rstatus) /* cleared by default: timeout, datasz, dataoffs, mkey, mask */ is_smi = rpc.mgtclass == IB_SMI_CLASS || - rpc.mgtclass == IB_SMI_DIRECT_CLASS; + rpc.mgtclass == IB_SMI_DIRECT_CLASS; if (is_smi) portid->qp = 0; else if (!portid->qp) - portid->qp = 1; + portid->qp = 1; if (!portid->qkey && portid->qp == 1) portid->qkey = IB_DEFAULT_QP1_QKEY; - DEBUG("qp 0x%x class 0x%x method %d attr 0x%x mod 0x%x datasz %d off %d qkey %x", - portid->qp, rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod, - rpc.datasz, rpc.dataoffs, portid->qkey); + DEBUG + ("qp 0x%x class 0x%x method %d attr 0x%x mod 0x%x datasz %d off %d qkey %x", + portid->qp, rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod, + rpc.datasz, rpc.dataoffs, portid->qkey); if (mad_build_pkt(umad, &rpc, portid, 0, 0) < 0) return -1; @@ -147,15 +147,13 @@ mad_respond(void *umad, ib_portid_t *portid, uint32_t rstatus) return 0; } -void * -mad_receive(void *umad, int timeout) +void *mad_receive(void *umad, int timeout) { void *mad = umad ? umad : umad_alloc(1, umad_size() + IB_MAD_SIZE); int agent; int length = IB_MAD_SIZE; - if ((agent = umad_recv(madrpc_portid(), mad, - &length, timeout)) < 0) { + if ((agent = umad_recv(madrpc_portid(), mad, &length, timeout)) < 0) { if (!umad) umad_free(mad); DEBUG("recv failed: %m"); @@ -165,14 +163,12 @@ mad_receive(void *umad, int timeout) return mad; } -void * -mad_alloc(void) +void *mad_alloc(void) { return umad_alloc(1, umad_size() + IB_MAD_SIZE); } -void -mad_free(void *umad) +void mad_free(void *umad) { umad_free(umad); } diff --git a/branches/winverbs/ulp/libibmad/src/smp.c b/branches/winverbs/ulp/libibmad/src/smp.c index e872602b..fad263c2 100644 --- a/branches/winverbs/ulp/libibmad/src/smp.c +++ b/branches/winverbs/ulp/libibmad/src/smp.c @@ -33,21 +33,21 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ #include #include #include -#include +#include #undef DEBUG #define DEBUG if (ibdebug) IBWARN -uint8_t * -smp_set_via(void *data, ib_portid_t *portid, unsigned attrid, unsigned mod, unsigned timeout, const void *srcport) +uint8_t *smp_set_via(void *data, ib_portid_t * portid, unsigned attrid, + unsigned mod, unsigned timeout, const void *srcport) { - ib_rpc_t rpc = {0}; + ib_rpc_t rpc = { 0 }; DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid)); if ((portid->lid <= 0) || @@ -55,7 +55,7 @@ smp_set_via(void *data, ib_portid_t *portid, unsigned attrid, unsigned mod, unsi (portid->drpath.drdlid == 0xffff)) rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */ else - rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */ + rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */ rpc.method = IB_MAD_METHOD_SET; rpc.attr.id = attrid; @@ -74,17 +74,16 @@ smp_set_via(void *data, ib_portid_t *portid, unsigned attrid, unsigned mod, unsi } } -uint8_t * -smp_set(void *data, ib_portid_t *portid, unsigned attrid, unsigned mod, unsigned timeout) +uint8_t *smp_set(void *data, ib_portid_t * portid, unsigned attrid, + unsigned mod, unsigned timeout) { return smp_set_via(data, portid, attrid, mod, timeout, NULL); } -uint8_t * -smp_query_via(void *rcvbuf, ib_portid_t *portid, unsigned attrid, unsigned mod, - unsigned timeout, const void *srcport) +uint8_t *smp_query_via(void *rcvbuf, ib_portid_t * portid, unsigned attrid, + unsigned mod, unsigned timeout, const void *srcport) { - ib_rpc_t rpc = {0}; + ib_rpc_t rpc = { 0 }; DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid)); rpc.method = IB_MAD_METHOD_GET; @@ -99,7 +98,7 @@ smp_query_via(void *rcvbuf, ib_portid_t *portid, unsigned attrid, unsigned mod, (portid->drpath.drdlid == 0xffff)) rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */ else - rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */ + rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */ portid->sl = 0; portid->qp = 0; @@ -111,9 +110,8 @@ smp_query_via(void *rcvbuf, ib_portid_t *portid, unsigned attrid, unsigned mod, } } -uint8_t * -smp_query(void *rcvbuf, ib_portid_t *portid, unsigned attrid, unsigned mod, - unsigned timeout) +uint8_t *smp_query(void *rcvbuf, ib_portid_t * portid, unsigned attrid, + unsigned mod, unsigned timeout) { return smp_query_via(rcvbuf, portid, attrid, mod, timeout, NULL); } diff --git a/branches/winverbs/ulp/libibmad/src/vendor.c b/branches/winverbs/ulp/libibmad/src/vendor.c index 7928a581..50a878e6 100644 --- a/branches/winverbs/ulp/libibmad/src/vendor.c +++ b/branches/winverbs/ulp/libibmad/src/vendor.c @@ -33,29 +33,27 @@ #if HAVE_CONFIG_H # include -#endif /* HAVE_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ #include #include #include -#include +#include #undef DEBUG #define DEBUG if (ibdebug) IBWARN -static inline int -response_expected(int method) +static inline int response_expected(int method) { return method == IB_MAD_METHOD_GET || - method == IB_MAD_METHOD_SET || - method == IB_MAD_METHOD_TRAP; + method == IB_MAD_METHOD_SET || method == IB_MAD_METHOD_TRAP; } -uint8_t * -ib_vendor_call(void *data, ib_portid_t *portid, ib_vendor_call_t *call) +uint8_t *ib_vendor_call(void *data, ib_portid_t * portid, + ib_vendor_call_t * call) { - ib_rpc_t rpc = {0}; + ib_rpc_t rpc = { 0 }; int range1 = 0, resp_expected; DEBUG("route %s data %p", portid2str(portid), data); @@ -74,22 +72,25 @@ ib_vendor_call(void *data, ib_portid_t *portid, ib_vendor_call_t *call) rpc.attr.id = call->attrid; rpc.attr.mod = call->mod; rpc.timeout = resp_expected ? call->timeout : 0; - rpc.datasz = range1 ? IB_VENDOR_RANGE1_DATA_SIZE : IB_VENDOR_RANGE2_DATA_SIZE; - rpc.dataoffs = range1 ? IB_VENDOR_RANGE1_DATA_OFFS : IB_VENDOR_RANGE2_DATA_OFFS; + rpc.datasz = + range1 ? IB_VENDOR_RANGE1_DATA_SIZE : IB_VENDOR_RANGE2_DATA_SIZE; + rpc.dataoffs = + range1 ? IB_VENDOR_RANGE1_DATA_OFFS : IB_VENDOR_RANGE2_DATA_OFFS; if (!range1) rpc.oui = call->oui; - DEBUG("class 0x%x method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d", - rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod, - rpc.datasz, rpc.dataoffs, resp_expected); + DEBUG + ("class 0x%x method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d", + rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod, rpc.datasz, + rpc.dataoffs, resp_expected); portid->qp = 1; if (!portid->qkey) portid->qkey = IB_DEFAULT_QP1_QKEY; if (resp_expected) - return madrpc_rmpp(&rpc, portid, 0, data); /* FIXME: no RMPP for now */ + return madrpc_rmpp(&rpc, portid, 0, data); /* FIXME: no RMPP for now */ - return mad_send(&rpc, portid, 0, data) < 0 ? 0 : data; /* FIXME: no RMPP for now */ + return mad_send(&rpc, portid, 0, data) < 0 ? 0 : data; /* FIXME: no RMPP for now */ } -- 2.46.0