[ofw] [PATCH] osmtest - use ib_get_attr_offset() routine instead of it's implementation.

Smith, Stan stan.smith at intel.com
Thu May 20 14:57:11 PDT 2010


Code cleanup by replacing 'cl_ntoh16((uint16_t) (attr_size >> 3))' expression with a call to the inline function  'ib_get_attr_offset(attr_size)'; takes advantage of (debug build) attr offset size checking.
Validates input attr_size is a multiple of 8 bytes per IB spec.
Function returns same value as the expression plus it isolates the implementation to a single point to ease future changes.

signed-off-by: stan smith <stan.smith at intel.com>

--- b/ulp/opensm/user/osmtest/osmtest.c Thu May 20 14:44:52 2010
+++ b/ulp/opensm/user/osmtest/osmtest.c Thu May 20 14:45:29 2010
@@ -579,7 +579,7 @@

        p_context->p_osmt = p_osmt;
        user.attr_id = attr_id;
-       user.attr_offset = cl_ntoh16((uint16_t) (attr_size >> 3));
+       user.attr_offset = ib_get_attr_offset(attr_size);

        req.query_type = OSMV_QUERY_USER_DEFINED;
        req.timeout_ms = p_osmt->opt.transaction_timeout;
@@ -739,7 +739,7 @@
        p_context->p_osmt = p_osmt;
        user.comp_mask = IB_NR_COMPMASK_NODEGUID;
        user.attr_id = IB_MAD_ATTR_NODE_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
        user.p_attr = &record;

        req.query_type = OSMV_QUERY_USER_DEFINED;
@@ -813,7 +813,7 @@
        p_context->p_osmt = p_osmt;
        user.comp_mask = IB_NR_COMPMASK_LID;
        user.attr_id = IB_MAD_ATTR_NODE_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
        user.p_attr = &record;

        req.query_type = OSMV_QUERY_USER_DEFINED;
@@ -1085,7 +1085,7 @@
        p_context->p_osmt = p_osmt;
        user.comp_mask = IB_PIR_COMPMASK_LID;
        user.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
        user.p_attr = &record;

        req.query_type = OSMV_QUERY_USER_DEFINED;
@@ -2043,7 +2043,7 @@
        req.sm_key = 0;

        OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
-               "Query for path from 0x%X to 0x%X\n", slid, dlid);
+               "Query for path (by lid pair) from 0x%X to 0x%X\n", slid, dlid);
        status = osmv_query_sa(p_osmt->h_bind, &req);
        if (status != IB_SUCCESS) {
                OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0053: "
@@ -2269,7 +2269,7 @@
        return (status);
 }

-#else
+#else /* !VENDOR_RMPP_SUPPORT */
 /*
  * NON RMPP BASED QUERY FOR ALL NODES: BASED ON THE MAX LID GIVEN BY THE USER
  */
@@ -4269,7 +4269,7 @@
        if (to_lid)
                user.comp_mask |= IB_LR_COMPMASK_TO_LID;
        user.attr_id = IB_MAD_ATTR_LINK_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
        user.p_attr = &record;

        req.query_type = OSMV_QUERY_USER_DEFINED;
@@ -4347,7 +4347,7 @@
        p_context->p_osmt = p_osmt;
        user.comp_mask = IB_GIR_COMPMASK_LID;
        user.attr_id = IB_MAD_ATTR_GUIDINFO_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
        user.p_attr = &record;

        req.query_type = OSMV_QUERY_USER_DEFINED;
@@ -4426,7 +4426,7 @@
        p_context->p_osmt = p_osmt;
        user.comp_mask = IB_PKEY_COMPMASK_LID;
        user.attr_id = IB_MAD_ATTR_PKEY_TBL_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
        user.p_attr = &record;

        req.query_type = OSMV_QUERY_USER_DEFINED;
@@ -4505,7 +4505,7 @@
        if (lid)
                user.comp_mask = IB_SWIR_COMPMASK_LID;
        user.attr_id = IB_MAD_ATTR_SWITCH_INFO_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
        user.p_attr = &record;

        req.query_type = OSMV_QUERY_USER_DEFINED;
@@ -4584,7 +4584,7 @@
        if (lid)
                user.comp_mask = IB_LFTR_COMPMASK_LID;
        user.attr_id = IB_MAD_ATTR_LFT_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
        user.p_attr = &record;

        req.query_type = OSMV_QUERY_USER_DEFINED;
@@ -4663,7 +4663,7 @@
        if (lid)
                user.comp_mask = IB_MFTR_COMPMASK_LID;
        user.attr_id = IB_MAD_ATTR_MFT_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
        user.p_attr = &record;

        req.query_type = OSMV_QUERY_USER_DEFINED;
@@ -4737,7 +4737,7 @@

        p_context->p_osmt = p_osmt;
        user.attr_id = IB_MAD_ATTR_SMINFO_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
        p_sm_info_opt = p_options;
        if (p_sm_info_opt->sm_guid != 0) {
                record.sm_info.guid = p_sm_info_opt->sm_guid;
@@ -4839,7 +4839,7 @@
        p_context->p_osmt = p_osmt;
        user.attr_id = attr_id;
        if (attr_id == IB_MAD_ATTR_INFORM_INFO_RECORD) {
-               user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+               user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
                p_inform_info_rec_opt = p_options;
                if (p_inform_info_rec_opt->subscriber_gid.unicast.prefix != 0 &&
                    p_inform_info_rec_opt->subscriber_gid.unicast.
@@ -4853,7 +4853,7 @@
                user.comp_mask |= IB_IIR_COMPMASK_ENUM;
                user.p_attr = &record;
        } else {
-               user.attr_offset = cl_ntoh16((uint16_t) (sizeof(rec) >> 3));
+               user.attr_offset = ib_get_attr_offset((uint16_t) (sizeof(record)));
                /* comp mask bits below are for InformInfoRecord rather than InformInfo */
                /* as currently no comp mask bits defined for InformInfo!!! */
                user.comp_mask = IB_IIR_COMPMASK_SUBSCRIBE;
@@ -5006,7 +5006,7 @@
        context.p_osmt = p_osmt;
        user.comp_mask = IB_NR_COMPMASK_LID;
        user.attr_id = IB_MAD_ATTR_NODE_RECORD;
-       user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
+       user.attr_offset = ib_get_attr_offset((uint16_t) sizeof(record));
        user.p_attr = &record;

        req.query_type = OSMV_QUERY_USER_DEFINED;



More information about the ofw mailing list