[ofw] [PATCH] fix av verbs with valid grh

Reuven Amitai reuven at mellanox.co.il
Tue Sep 2 05:29:01 PDT 2008


Hi Leonid, 
 
The patch fix the behavior of av verbs in case that sgid isn't found at
the gid_table.
Instead of exit with IB_INVALID_GID it sets the index to 0. Please note
IB spec 11.2.2.2 regarding av verbs definition.
 
The patch also used grh.resv2 (rather than resv1) to avoid C4328 warning
(improper member alignment).
 
Signed-off-by: Reuven Amitai reuven at mellanox.co.il
 
Thanks, Reuven.
 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\
Index: core/al/user/ual_av.c
===================================================================
--- core/al/user/ual_av.c (revision 1540)
+++ core/al/user/ual_av.c (working copy)
@@ -46,31 +46,28 @@
 #endif
 
 
-static ib_api_status_t
+static void
 ual_get_gid_index(
  IN  struct _al_ci_ca     *p_ci_ca,
  IN  uint8_t        port_num,
  IN  ib_gid_t       *p_gid,
-  OUT uint16_t       *p_index)
+  OUT uint8_t       *p_index)
 {
  ib_port_attr_t  *p_port_attr;
- ib_api_status_t  status = IB_INVALID_GID;
- uint16_t   i;
+ uint8_t   i;
 
  ci_ca_lock_attr( p_ci_ca );
  p_port_attr = &p_ci_ca->p_pnp_attr->p_port_attr[port_num-1];
+ *p_index = 0;
  for( i = 0; i < p_port_attr->num_gids; i++ )
  {
   if( !cl_memcmp(p_gid, &p_port_attr->p_gid_table[i], sizeof(ib_gid_t))
)
   {
    *p_index = i;
-   status = IB_SUCCESS;
    break;
   }
  }
  ci_ca_unlock_attr( p_ci_ca );
-
- return status;
 }
 
 ib_api_status_t
@@ -85,7 +82,6 @@
  ib_api_status_t   status = IB_ERROR;
  uvp_interface_t   uvp_intf = h_pd->obj.p_ci_ca->verbs.user_verbs;
  ib_av_attr_t   av_attr;
- uint16_t    index;
 
  AL_ENTER( AL_DBG_AV );
  /* Clear the ioctl_buf */
@@ -97,11 +93,8 @@
  {
   if( p_av_attr->grh_valid )
   {
-   status = ual_get_gid_index(h_pd->obj.p_ci_ca, av_attr.port_num,
-            &av_attr.grh.src_gid, &index);
-   if( status != IB_SUCCESS )
-    goto out;
-   av_attr.grh.resv1 = index;
+   ual_get_gid_index(h_pd->obj.p_ci_ca, av_attr.port_num, 
+        &av_attr.grh.src_gid, &av_attr.grh.resv2);
   }
 
   status = uvp_intf.pre_create_av( h_pd->h_ci_pd,
@@ -136,7 +129,6 @@
    status, &h_av->h_ci_av, &ioctl_buf.out.umv_buf);
  }
 
-out:
  AL_EXIT( AL_DBG_AV );
  return status;
 }
@@ -269,7 +261,6 @@
  ib_av_t*    p_av = (ib_av_t*) h_av;
  uvp_interface_t   uvp_intf = p_av->obj.p_ci_ca->verbs.user_verbs;
  ib_av_attr_t   av_attr;
- uint16_t    index;
 
  AL_ENTER( AL_DBG_AV );
  /* Clear the ioctl_buf */
@@ -281,11 +272,8 @@
  {
   if( p_av_attr->grh_valid )
   {
-   status = ual_get_gid_index(p_av->obj.p_ci_ca, av_attr.port_num,
-            &av_attr.grh.src_gid, &index);
-   if( status != IB_SUCCESS )
-    goto out;
-   av_attr.grh.resv1 = index;
+   ual_get_gid_index(p_av->obj.p_ci_ca, av_attr.port_num, 
+        &av_attr.grh.src_gid, &av_attr.grh.resv2);
   }
 
   /* Pre call to the UVP library */
@@ -336,7 +324,6 @@
    p_av->h_ci_av, status, &ioctl_buf.out.umv_buf );
  }
 
-out:
  AL_EXIT( AL_DBG_AV );
  return status;
 }
Index: hw/mlx4/user/hca/verbs.c
===================================================================
--- hw/mlx4/user/hca/verbs.c (revision 1540)
+++ hw/mlx4/user/hca/verbs.c (working copy)
@@ -1088,7 +1088,7 @@
   p_attr->grh.hop_limit = p_av_attr->grh.hop_limit;
   __grh_get_ver_class_flow( p_av_attr->grh.ver_class_flow, NULL,
         &p_attr->grh.traffic_class, &p_attr->grh.flow_label );
-  p_attr->grh.sgid_index = (uint8_t) p_av_attr->grh.resv1;
+  p_attr->grh.sgid_index = p_av_attr->grh.resv2;
   cl_memcpy (p_attr->grh.dgid.raw, p_av_attr->grh.dest_gid.raw, 16);
  }
  else
Index: hw/mthca/user/mlnx_ual_av.c
===================================================================
--- hw/mthca/user/mlnx_ual_av.c (revision 1540)
+++ hw/mthca/user/mlnx_ual_av.c (working copy)
@@ -70,7 +70,7 @@
   p_attr->grh.hop_limit   = p_av_attr->grh.hop_limit;
   ib_grh_get_ver_class_flow( p_av_attr->grh.ver_class_flow, NULL,
    &p_attr->grh.traffic_class, &p_attr->grh.flow_label );
-  p_attr->grh.sgid_index = (uint8_t) p_av_attr->grh.resv1;
+  p_attr->grh.sgid_index = p_av_attr->grh.resv2;
   cl_memcpy (p_attr->grh.dgid.raw, p_av_attr->grh.dest_gid.raw, 
    sizeof (IB_gid_t));
  }else{

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080902/0a183b98/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grh.patch
Type: application/octet-stream
Size: 3769 bytes
Desc: grh.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080902/0a183b98/attachment.obj>


More information about the ofw mailing list