Re: [PATCH] osmtest/SA client: Only set attribute offset for RMPP operations

2010-09-01 Thread Sasha Khapyorsky
Hi Hal,

On 08:37 Fri 27 Aug , Hal Rosenstock wrote:
 

The patch description would be very useful.

What is motivation for such changes?

Sasha

 Signed-off-by: Hal Rosenstock hal.rosenst...@gmail.com
 ---
 diff --git a/opensm/libvendor/osm_vendor_ibumad_sa.c 
 b/opensm/libvendor/osm_vendor_ibumad_sa.c
 index 3a7d54a..a81a6b7 100644
 --- a/opensm/libvendor/osm_vendor_ibumad_sa.c
 +++ b/opensm/libvendor/osm_vendor_ibumad_sa.c
 @@ -2,7 +2,7 @@
   * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
   * Copyright (c) 2002-2007,2009 Mellanox Technologies LTD. All rights 
 reserved.
   * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
 - * Copyright (c) 2009 HNR Consulting. All rights reserved.
 + * Copyright (c) 2009,2010 HNR Consulting. All rights reserved.
   *
   * This software is available to you under a choice of one of two
   * licenses.  You may choose to be licensed under the terms of the GNU
 @@ -342,6 +342,7 @@ __osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
   static atomic32_t trans_id;
   boolean_t sync;
   osmv_query_req_t *p_query_req_copy;
 + uint32_t sa_size;
  
   OSM_LOG_ENTER(p_log);
  
 @@ -401,8 +402,8 @@ __osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
   p_sa_mad-rmpp_flags = IB_RMPP_FLAG_ACTIVE;
  #endif
   if (p_sa_mad-comp_mask) {
 - memcpy(p_sa_mad-data, p_sa_mad_data-p_attr,
 -ib_get_attr_size(p_sa_mad_data-attr_offset));
 + p_sa_mad_data-attr_offset ? (sa_size = 
 ib_get_attr_size(p_sa_mad_data-attr_offset)) : (sa_size = IB_SA_DATA_SIZE);
 + memcpy(p_sa_mad-data, p_sa_mad_data-p_attr, sa_size);
   }
  
   /*
 @@ -488,6 +489,7 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
   /* Set the request information. */
   sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
   sa_mad_data.attr_mod = 0;
 + sa_mad_data.attr_offset = 0;
  
   /* Set the MAD attributes and component mask correctly. */
   switch (p_query_req-query_type) {
 @@ -497,7 +499,11 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
   p_user_query = (osmv_user_query_t *) p_query_req-p_query_input;
   if (p_user_query-method)
   sa_mad_data.method = p_user_query-method;
 - sa_mad_data.attr_offset = p_user_query-attr_offset;
 +#ifdef DUAL_SIDED_RMPP
 + if (sa_mad_data.method == IB_MAD_METHOD_GETMULTI ||
 + sa_mad_data.method == IB_MAD_METHOD_GETTRACETABLE)
 + sa_mad_data.attr_offset = p_user_query-attr_offset;
 +#endif
   sa_mad_data.attr_id = p_user_query-attr_id;
   sa_mad_data.attr_mod = p_user_query-attr_mod;
   sa_mad_data.comp_mask = p_user_query-comp_mask;
 @@ -507,8 +513,6 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
   case OSMV_QUERY_ALL_SVC_RECS:
   OSM_LOG(p_log, OSM_LOG_DEBUG, DBG:001 SVC_REC_BY_NAME\n);
   sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
 - sa_mad_data.attr_offset =
 - ib_get_attr_offset(sizeof(ib_service_record_t));
   sa_mad_data.comp_mask = 0;
   sa_mad_data.p_attr = u.svc_rec;
   break;
 @@ -518,8 +522,6 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
   sa_mad_data.method = IB_MAD_METHOD_GET;
   sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
   sa_mad_data.comp_mask = IB_SR_COMPMASK_SNAME;
 - sa_mad_data.attr_offset =
 - ib_get_attr_offset(sizeof(ib_service_record_t));
   sa_mad_data.p_attr = u.svc_rec;
   memcpy(u.svc_rec.service_name, p_query_req-p_query_input,
  sizeof(ib_svc_name_t));
 @@ -529,8 +531,6 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
   OSM_LOG(p_log, OSM_LOG_DEBUG, DBG:001 SVC_REC_BY_ID\n);
   sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
   sa_mad_data.comp_mask = IB_SR_COMPMASK_SID;
 - sa_mad_data.attr_offset =
 - ib_get_attr_offset(sizeof(ib_service_record_t));
   sa_mad_data.p_attr = u.svc_rec;
   u.svc_rec.service_id =
   *(ib_net64_t *) (p_query_req-p_query_input);
 @@ -540,8 +540,6 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
   OSM_LOG(p_log, OSM_LOG_DEBUG, DBG:001 CLASS_PORT_INFO\n);
   sa_mad_data.method = IB_MAD_METHOD_GET;
   sa_mad_data.attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
 - sa_mad_data.attr_offset =
 - ib_get_attr_offset(sizeof(ib_class_port_info_t));
   sa_mad_data.comp_mask = 0;
   sa_mad_data.p_attr = u.class_port_info;
   break;
 @@ -549,8 +547,6 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
   case OSMV_QUERY_NODE_REC_BY_NODE_GUID:
   OSM_LOG(p_log, OSM_LOG_DEBUG, DBG:001 
 NODE_REC_BY_NODE_GUID\n);
   sa_mad_data.attr_id = 

[PATCH] osmtest/SA client: Only set attribute offset for RMPP operations

2010-08-27 Thread Hal Rosenstock

Signed-off-by: Hal Rosenstock hal.rosenst...@gmail.com
---
diff --git a/opensm/libvendor/osm_vendor_ibumad_sa.c 
b/opensm/libvendor/osm_vendor_ibumad_sa.c
index 3a7d54a..a81a6b7 100644
--- a/opensm/libvendor/osm_vendor_ibumad_sa.c
+++ b/opensm/libvendor/osm_vendor_ibumad_sa.c
@@ -2,7 +2,7 @@
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2007,2009 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009,2010 HNR Consulting. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -342,6 +342,7 @@ __osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
static atomic32_t trans_id;
boolean_t sync;
osmv_query_req_t *p_query_req_copy;
+   uint32_t sa_size;
 
OSM_LOG_ENTER(p_log);
 
@@ -401,8 +402,8 @@ __osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
p_sa_mad-rmpp_flags = IB_RMPP_FLAG_ACTIVE;
 #endif
if (p_sa_mad-comp_mask) {
-   memcpy(p_sa_mad-data, p_sa_mad_data-p_attr,
-  ib_get_attr_size(p_sa_mad_data-attr_offset));
+   p_sa_mad_data-attr_offset ? (sa_size = 
ib_get_attr_size(p_sa_mad_data-attr_offset)) : (sa_size = IB_SA_DATA_SIZE);
+   memcpy(p_sa_mad-data, p_sa_mad_data-p_attr, sa_size);
}
 
/*
@@ -488,6 +489,7 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
/* Set the request information. */
sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
sa_mad_data.attr_mod = 0;
+   sa_mad_data.attr_offset = 0;
 
/* Set the MAD attributes and component mask correctly. */
switch (p_query_req-query_type) {
@@ -497,7 +499,11 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
p_user_query = (osmv_user_query_t *) p_query_req-p_query_input;
if (p_user_query-method)
sa_mad_data.method = p_user_query-method;
-   sa_mad_data.attr_offset = p_user_query-attr_offset;
+#ifdef DUAL_SIDED_RMPP
+   if (sa_mad_data.method == IB_MAD_METHOD_GETMULTI ||
+   sa_mad_data.method == IB_MAD_METHOD_GETTRACETABLE)
+   sa_mad_data.attr_offset = p_user_query-attr_offset;
+#endif
sa_mad_data.attr_id = p_user_query-attr_id;
sa_mad_data.attr_mod = p_user_query-attr_mod;
sa_mad_data.comp_mask = p_user_query-comp_mask;
@@ -507,8 +513,6 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
case OSMV_QUERY_ALL_SVC_RECS:
OSM_LOG(p_log, OSM_LOG_DEBUG, DBG:001 SVC_REC_BY_NAME\n);
sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
-   sa_mad_data.attr_offset =
-   ib_get_attr_offset(sizeof(ib_service_record_t));
sa_mad_data.comp_mask = 0;
sa_mad_data.p_attr = u.svc_rec;
break;
@@ -518,8 +522,6 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
sa_mad_data.method = IB_MAD_METHOD_GET;
sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
sa_mad_data.comp_mask = IB_SR_COMPMASK_SNAME;
-   sa_mad_data.attr_offset =
-   ib_get_attr_offset(sizeof(ib_service_record_t));
sa_mad_data.p_attr = u.svc_rec;
memcpy(u.svc_rec.service_name, p_query_req-p_query_input,
   sizeof(ib_svc_name_t));
@@ -529,8 +531,6 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
OSM_LOG(p_log, OSM_LOG_DEBUG, DBG:001 SVC_REC_BY_ID\n);
sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
sa_mad_data.comp_mask = IB_SR_COMPMASK_SID;
-   sa_mad_data.attr_offset =
-   ib_get_attr_offset(sizeof(ib_service_record_t));
sa_mad_data.p_attr = u.svc_rec;
u.svc_rec.service_id =
*(ib_net64_t *) (p_query_req-p_query_input);
@@ -540,8 +540,6 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
OSM_LOG(p_log, OSM_LOG_DEBUG, DBG:001 CLASS_PORT_INFO\n);
sa_mad_data.method = IB_MAD_METHOD_GET;
sa_mad_data.attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
-   sa_mad_data.attr_offset =
-   ib_get_attr_offset(sizeof(ib_class_port_info_t));
sa_mad_data.comp_mask = 0;
sa_mad_data.p_attr = u.class_port_info;
break;
@@ -549,8 +547,6 @@ osmv_query_sa(IN osm_bind_handle_t h_bind,
case OSMV_QUERY_NODE_REC_BY_NODE_GUID:
OSM_LOG(p_log, OSM_LOG_DEBUG, DBG:001 
NODE_REC_BY_NODE_GUID\n);
sa_mad_data.attr_id = IB_MAD_ATTR_NODE_RECORD;
-   sa_mad_data.attr_offset =
-