[ofw] [PATCH] Remove pointers from ci_umv_buf_t

Fab Tillier ftillier at windows.microsoft.com
Fri Jul 11 13:06:34 PDT 2008


Part of cleaning up the __ptr64 stuff properly - rather than use the TO_LONG_PTR in the ci_umv_buf_t structure, use uint64_t.

The problem with using TO_LONG_PTR in structures that are exchanged between 32-bit clients and 64-bit drivers is that care must be taken to ensure that the upper 'padding' bytes are cleared properly.

Making the field a uint64_t makes it fool proof (though it does require casting, but at least the compiler will trap errors unlike for the padding.)

Signed-off-by: Fab Tillier <ftillier at microsoft.com>

diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\core\al\kernel\al_proxy_verbs.c trunk\core\al\kernel\al_proxy_verbs.c
--- old\core\al\kernel\al_proxy_verbs.c Fri Jul 11 13:03:58 2008
+++ trunk\core\al\kernel\al_proxy_verbs.c       Fri Jul 11 12:55:49 2008
@@ -89,15 +89,15 @@ cpyin_umvbuf(

        if( p_src->p_inout_buf )
        {
-               if( p_src->input_size &&
-                       cl_check_for_read( p_src->p_inout_buf, (size_t)p_src->input_size )
+               if( p_src->input_size && cl_check_for_read(
+                       (void*)(ULONG_PTR)p_src->p_inout_buf, (size_t)p_src->input_size )
                        != CL_SUCCESS )
                {
                        /* user-supplied memory area not readable */
                        return IB_INVALID_PERMISSION;
                }
-               if( p_src->output_size &&
-                       cl_check_for_write( p_src->p_inout_buf, (size_t)p_src->output_size )
+               if( p_src->output_size && cl_check_for_write(
+                       (void*)(ULONG_PTR)p_src->p_inout_buf, (size_t)p_src->output_size )
                        != CL_SUCCESS )
                {
                        /* user-supplied memory area not writeable */
@@ -111,12 +111,13 @@ cpyin_umvbuf(
        /* Copy the umv_buf structure. */
        *p_dest = *p_src;
        if( p_src->p_inout_buf )
-               p_dest->p_inout_buf = (void*)(p_dest + 1);
+               p_dest->p_inout_buf = (ULONG_PTR)(p_dest + 1);

        /* Setup the buffer - either we have an input or output buffer */
        if( p_src->input_size )
        {
-               if( cl_copy_from_user( p_dest->p_inout_buf, p_src->p_inout_buf,
+               if( cl_copy_from_user( (void*)(ULONG_PTR)p_dest->p_inout_buf,
+                       (void*)(ULONG_PTR)p_src->p_inout_buf,
                        (size_t)p_src->input_size ) != CL_SUCCESS )
                {
                        cl_free( p_dest );
@@ -158,7 +159,9 @@ cpyout_umvbuf(

                        out_size = MIN( p_dest->output_size, p_src->output_size );

-                       if( cl_copy_to_user( p_dest->p_inout_buf, p_src->p_inout_buf,
+                       if( cl_copy_to_user(
+                               (void*)(ULONG_PTR)p_dest->p_inout_buf,
+                               (void*)(ULONG_PTR)p_src->p_inout_buf,
                                out_size ) != CL_SUCCESS )
                        {
                                p_dest->output_size = 0;
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mlx4\kernel\hca\data.h trunk\hw\mlx4\kernel\hca\data.h
--- old\hw\mlx4\kernel\hca\data.h       Fri Jul 11 13:03:58 2008
+++ trunk\hw\mlx4\kernel\hca\data.h     Fri Jul 11 12:55:49 2008
@@ -278,7 +278,7 @@ to_qp_acl(

 static inline int from_umv_buf(void *dest, ci_umv_buf_t* const p_umv_buf, size_t len)
 {
-       RtlCopyMemory(dest, p_umv_buf->p_inout_buf,  len);
+       RtlCopyMemory(dest, (void*)(ULONG_PTR)p_umv_buf->p_inout_buf,  len);
        return 0;
 }

@@ -289,7 +289,7 @@ static inline int to_umv_buf(ci_umv_buf_
                p_umv_buf->output_size = 0;
                return -EFAULT;
        }
-       RtlCopyMemory(p_umv_buf->p_inout_buf,  src, len);
+       RtlCopyMemory( (void*)(ULONG_PTR)p_umv_buf->p_inout_buf,  src, len);
        p_umv_buf->status = IB_SUCCESS;
        p_umv_buf->output_size = (uint32_t)len;
        return 0;
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mlx4\kernel\hca\mr.c trunk\hw\mlx4\kernel\hca\mr.c
--- old\hw\mlx4\kernel\hca\mr.c Tue Jul 01 09:31:01 2008
+++ trunk\hw\mlx4\kernel\hca\mr.c       Fri Jul 11 12:55:49 2008
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
  * Copyright (c) 2004-2005 Mellanox Technologies, Inc. All rights reserved.
+ * Portions Copyright (c) 2008 Microsoft Corporation.  All rights reserved.
  *
  * This software is available to you under the OpenIB.org BSD license
  * below:
@@ -55,7 +56,7 @@ mlnx_register_mr (
        int err;
        struct ib_mr *p_ib_mr;
        struct ib_pd *p_ib_pd = (struct ib_pd *)h_pd;
-       ci_umv_buf_t umv_buf = { 0, 0, 0, 0, NULL };
+       ci_umv_buf_t umv_buf = { 0, 0, 0, 0, 0 };

        HCA_ENTER(HCA_DBG_MEMORY);

diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mlx4\kernel\hca\pd.c trunk\hw\mlx4\kernel\hca\pd.c
--- old\hw\mlx4\kernel\hca\pd.c Thu Jun 26 20:35:14 2008
+++ trunk\hw\mlx4\kernel\hca\pd.c       Fri Jul 11 12:55:49 2008
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Portions Copyright (c) 2008 Microsoft Corporation.  All rights reserved.
  *
  * This software is available to you under the OpenIB.org BSD license
  * below:
@@ -74,7 +75,7 @@ mlnx_allocate_pd (
                        }

                        // prepare user parameters
-                       p_resp = (struct ibv_alloc_pd_resp*)(void*)p_umv_buf->p_inout_buf;
+                       p_resp = (struct ibv_alloc_pd_resp*)(ULONG_PTR)p_umv_buf->p_inout_buf;
                        INIT_UDATA(&udata, NULL, &p_resp->pdn,
                                0, sizeof(p_resp->pdn));
                }
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mlx4\kernel\hca\qp.c trunk\hw\mlx4\kernel\hca\qp.c
--- old\hw\mlx4\kernel\hca\qp.c Thu Jun 26 20:35:14 2008
+++ trunk\hw\mlx4\kernel\hca\qp.c       Fri Jul 11 12:55:49 2008
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Portions Copyright (c) 2008 Microsoft Corporation.  All rights reserved.
  *
  * This software is available to you under the OpenIB.org BSD license
  * below:
@@ -112,7 +113,7 @@ __create_qp (
                        status = IB_INVALID_PARAMETER;
                        goto err_inval_params;
                }
-               p_req = (struct ibv_create_qp*)(void*)p_umv_buf->p_inout_buf;
+               p_req = (struct ibv_create_qp*)(ULONG_PTR)p_umv_buf->p_inout_buf;
                p_uctx = p_ib_pd->p_uctx;
        }

@@ -330,7 +331,7 @@ mlnx_ndi_modify_qp (
        umv_buf.command = TRUE; /* special case for NDI. Usually it's TRUE */
        umv_buf.input_size = 0;
        umv_buf.output_size = sizeof(struct ibv_modify_qp_resp);
-       umv_buf.p_inout_buf = buf;
+       umv_buf.p_inout_buf = (ULONG_PTR)buf;

        status = mlnx_modify_qp ( h_qp, p_modify_attr, p_qp_attr, &umv_buf );

diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mlx4\kernel\hca\verbs.c trunk\hw\mlx4\kernel\hca\verbs.c
--- old\hw\mlx4\kernel\hca\verbs.c      Wed Jul 09 09:44:28 2008
+++ trunk\hw\mlx4\kernel\hca\verbs.c    Fri Jul 11 12:55:49 2008
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
  * Copyright (c) 2004-2005 Mellanox Technologies, Inc. All rights reserved.
+ * Portions Copyright (c) 2008 Microsoft Corporation.  All rights reserved.
  *
  * This software is available to you under the OpenIB.org BSD license
  * below:
@@ -178,8 +179,8 @@ struct ib_cq *ibv_create_cq(struct ib_de

        if ( p_uctx && p_umv_buf && p_umv_buf->p_inout_buf ) {
                // prepare user parameters
-               p_req = (struct ibv_create_cq*)(void*)p_umv_buf->p_inout_buf;
-               p_resp = (struct ibv_create_cq_resp*)(void*)
+               p_req = (struct ibv_create_cq*)(ULONG_PTR)p_umv_buf->p_inout_buf;
+               p_resp = (struct ibv_create_cq_resp*)(ULONG_PTR)
                        p_umv_buf->p_inout_buf;
                INIT_UDATA(&udata, &p_req->buf_addr, &p_resp->cqn,
                        sizeof(struct mlx4_ib_create_cq), sizeof(struct mlx4_ib_create_cq_resp));
@@ -272,8 +273,8 @@ struct ib_qp *ibv_create_qp(struct ib_pd

        if ( p_uctx && p_umv_buf && p_umv_buf->command ) {
                // prepare user parameters
-               p_req = (struct ibv_create_qp*)(void*)p_umv_buf->p_inout_buf;
-               p_resp = (struct ibv_create_qp_resp*)(void*)p_umv_buf->p_inout_buf;
+               p_req = (struct ibv_create_qp*)(ULONG_PTR)p_umv_buf->p_inout_buf;
+               p_resp = (struct ibv_create_qp_resp*)(ULONG_PTR)p_umv_buf->p_inout_buf;
                INIT_UDATA(&udata, &p_req->buf_addr, NULL,
                        sizeof(struct mlx4_ib_create_qp), 0);
        }
@@ -392,8 +393,8 @@ struct ib_srq *ibv_create_srq(struct ib_

        if ( p_uctx && p_umv_buf && p_umv_buf->p_inout_buf) {
                // prepare user parameters
-               p_req = (struct ibv_create_srq*)(void*)p_umv_buf->p_inout_buf;
-               p_resp = (struct ibv_create_srq_resp*)(void*)p_umv_buf->p_inout_buf;
+               p_req = (struct ibv_create_srq*)(ULONG_PTR)p_umv_buf->p_inout_buf;
+               p_resp = (struct ibv_create_srq_resp*)(ULONG_PTR)p_umv_buf->p_inout_buf;
                INIT_UDATA(&udata, &p_req->buf_addr, &p_resp->srqn,
                        sizeof(struct ibv_create_srq), sizeof(struct ibv_create_srq_resp));
        }
@@ -561,7 +562,7 @@ ib_api_status_t ibv_um_open(
                goto err_alloc_ucontext;
        }
        p_muctx = to_mucontext(p_uctx);
-       p_uresp = (struct ibv_get_context_resp *)(void*)p_umv_buf->p_inout_buf;
+       p_uresp = (struct ibv_get_context_resp *)(ULONG_PTR)p_umv_buf->p_inout_buf;

        // fill the rest of ib_ucontext fields
        p_uctx->device = p_ibdev;
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mlx4\kernel\hca\vp.c trunk\hw\mlx4\kernel\hca\vp.c
--- old\hw\mlx4\kernel\hca\vp.c Thu Jun 26 20:35:14 2008
+++ trunk\hw\mlx4\kernel\hca\vp.c       Fri Jul 11 12:55:49 2008
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
  * Copyright (c) 2004-2005 Mellanox Technologies, Inc. All rights reserved.
+ * Portions Copyright (c) 2008 Microsoft Corporation.  All rights reserved.
  *
  * This software is available to you under the OpenIB.org BSD license
  * below:
@@ -84,7 +85,7 @@ mlnx_um_open(
        }

        // fill more parameters for user (sanity checks are in mthca_alloc_ucontext)
-       p_uresp = (struct ibv_get_context_resp *)(void*)p_umv_buf->p_inout_buf;
+       p_uresp = (struct ibv_get_context_resp *)(ULONG_PTR)p_umv_buf->p_inout_buf;
        p_uresp->vend_id                 = (uint32_t)p_fdo->bus_ib_ifc.pdev->ven_id;
        p_uresp->dev_id                  = (uint16_t)p_fdo->bus_ib_ifc.pdev->dev_id;
        p_uresp->max_qp_wr               = hca2mdev(p_hca)->caps.max_wqes;
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mlx4\user\hca\verbs.c trunk\hw\mlx4\user\hca\verbs.c
--- old\hw\mlx4\user\hca\verbs.c        Fri Jul 11 13:03:58 2008
+++ trunk\hw\mlx4\user\hca\verbs.c      Fri Jul 11 12:58:00 2008
@@ -1,11 +1,9 @@
 /*
  * Copyright (c) 2007 Cisco, Inc.  All rights reserved.
+ * Portions Copyright (c) 2008 Microsoft Corporation.  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
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
  *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
@@ -61,7 +59,8 @@ mlx4_pre_open_ca (
        {
                if( !p_umv_buf->p_inout_buf )
                {
-                       p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_get_context_resp) );
+                       p_umv_buf->p_inout_buf =
+                               (ULONG_PTR)cl_zalloc( sizeof(struct ibv_get_context_resp) );
                        if( !p_umv_buf->p_inout_buf )
                        {
                                status = IB_INSUFFICIENT_MEMORY;
@@ -94,7 +93,7 @@ mlx4_post_open_ca (

        CL_ASSERT(p_umv_buf && p_umv_buf->p_inout_buf);

-       p_resp = p_umv_buf->p_inout_buf;
+       p_resp = (struct ibv_get_context_resp*)(ULONG_PTR)p_umv_buf->p_inout_buf;

        if (IB_SUCCESS == ioctl_status)
        {
@@ -131,7 +130,7 @@ mlx4_pre_query_ca (
         */
        if ( p_ca_attr != NULL )
        {
-               p_umv_buf->p_inout_buf = cl_malloc(byte_count);
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc(byte_count);
                if ( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_RESOURCES;
@@ -194,7 +193,7 @@ mlx4_post_query_ca (

                if (context->p_hca_attr)
                        cl_free(context->p_hca_attr);
-               context->p_hca_attr = p_umv_buf->p_inout_buf;
+               context->p_hca_attr = (ib_ca_attr_t*)(ULONG_PTR)p_umv_buf->p_inout_buf;
                cl_memcpy( context->p_hca_attr, p_ca_attr, p_ca_attr->size );
                __fixup_ca_attr( context->p_hca_attr, p_ca_attr );

@@ -202,7 +201,7 @@ mlx4_post_query_ca (
        }
        else if (p_umv_buf->p_inout_buf)
        {
-               cl_free(p_umv_buf->p_inout_buf);
+               cl_free( (void*)(ULONG_PTR)p_umv_buf->p_inout_buf );
        }
 }

@@ -235,7 +234,7 @@ mlx4_pre_alloc_pd (

        if( !p_umv_buf->p_inout_buf )
        {
-               p_umv_buf->p_inout_buf = cl_malloc( sizeof(struct ibv_alloc_pd_resp) );
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc( sizeof(struct ibv_alloc_pd_resp) );
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
@@ -277,7 +276,7 @@ mlx4_post_alloc_pd (

        CL_ASSERT(p_umv_buf && p_umv_buf->p_inout_buf);

-       p_resp = p_umv_buf->p_inout_buf;
+       p_resp = (struct ibv_alloc_pd_resp*)(ULONG_PTR)p_umv_buf->p_inout_buf;

        if (IB_SUCCESS == ioctl_status)
        {
@@ -335,7 +334,7 @@ mlx4_pre_create_cq (

        if( !p_umv_buf->p_inout_buf )
        {
-               p_umv_buf->p_inout_buf = cl_malloc( size );
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc( size );
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
@@ -346,7 +345,7 @@ mlx4_pre_create_cq (
        p_umv_buf->output_size = sizeof(struct ibv_create_cq_resp);
        p_umv_buf->command = TRUE;

-       p_create_cq = p_umv_buf->p_inout_buf;
+       p_create_cq = (struct ibv_create_cq*)(ULONG_PTR)p_umv_buf->p_inout_buf;

        // Mlx4 code:

@@ -401,7 +400,7 @@ err_lock:
        cl_free(cq);
 err_cq:
 err_cqe_size:
-       cl_free(p_umv_buf->p_inout_buf);
+       cl_free( (void*)(ULONG_PTR)p_umv_buf->p_inout_buf );
 err_umv_buf:
 end:
        return status;
@@ -423,7 +422,7 @@ mlx4_post_create_cq (

        CL_ASSERT(p_umv_buf && p_umv_buf->p_inout_buf);

-       p_resp = p_umv_buf->p_inout_buf;
+       p_resp = (struct ibv_create_cq_resp*)(ULONG_PTR)p_umv_buf->p_inout_buf;

        if (IB_SUCCESS == ioctl_status)
        {
@@ -492,7 +491,7 @@ mlx4_pre_create_srq (

        if( !p_umv_buf->p_inout_buf )
        {
-               p_umv_buf->p_inout_buf = cl_malloc( size );
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc( size );
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
@@ -503,7 +502,7 @@ mlx4_pre_create_srq (
        p_umv_buf->output_size = sizeof(struct ibv_create_srq_resp);
        p_umv_buf->command = TRUE;

-       p_create_srq = p_umv_buf->p_inout_buf;
+       p_create_srq = (struct ibv_create_srq*)(ULONG_PTR)p_umv_buf->p_inout_buf;

        // Mlx4 code:

@@ -563,7 +562,7 @@ err_alloc_buf:
 err_lock:
        cl_free(srq);
 err_alloc_srq:
-       cl_free(p_umv_buf->p_inout_buf);
+       cl_free( (void*)(ULONG_PTR)p_umv_buf->p_inout_buf );
 err_params: err_memory:
 end:
        return status;
@@ -584,7 +583,7 @@ mlx4_post_create_srq (

        CL_ASSERT(p_umv_buf && p_umv_buf->p_inout_buf);

-       p_resp = p_umv_buf->p_inout_buf;
+       p_resp = (struct ibv_create_srq_resp*)(ULONG_PTR)p_umv_buf->p_inout_buf;

        if (IB_SUCCESS == ioctl_status)
        {
@@ -694,7 +693,7 @@ mlx4_pre_create_qp (

        if( !p_umv_buf->p_inout_buf )
        {
-               p_umv_buf->p_inout_buf = cl_malloc(size);
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc(size);
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
@@ -705,7 +704,7 @@ mlx4_pre_create_qp (
        p_umv_buf->output_size = sizeof(struct ibv_create_qp_resp);
        p_umv_buf->command = TRUE;

-       p_create_qp = p_umv_buf->p_inout_buf;
+       p_create_qp = (struct ibv_create_qp*)(ULONG_PTR)p_umv_buf->p_inout_buf;

        /* convert attributes */
        memset( &attr, 0, sizeof(attr) );
@@ -843,7 +842,7 @@ err_spinlock_sq:
 err_alloc_qp_buff:
        cl_free(qp);
 err_alloc_qp:
-       cl_free(p_umv_buf->p_inout_buf);
+       cl_free( (void*)(ULONG_PTR)p_umv_buf->p_inout_buf );
 err_memory:
 end:
        return status;
@@ -864,7 +863,7 @@ mlx4_post_create_qp (

        CL_ASSERT(p_umv_buf && p_umv_buf->p_inout_buf);

-       p_resp = p_umv_buf->p_inout_buf;
+       p_resp = (struct ibv_create_qp_resp*)(ULONG_PTR)p_umv_buf->p_inout_buf;

        if (IB_SUCCESS == ioctl_status)
        {
@@ -928,7 +927,7 @@ mlx4_pre_modify_qp (

        if( !p_umv_buf->p_inout_buf )
        {
-               p_umv_buf->p_inout_buf = cl_malloc(sizeof(struct ibv_modify_qp_resp));
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc(sizeof(struct ibv_modify_qp_resp));
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
@@ -975,7 +974,7 @@ mlx4_post_modify_qp (

        CL_ASSERT(p_umv_buf && p_umv_buf->p_inout_buf);

-       p_resp = p_umv_buf->p_inout_buf;
+       p_resp = (struct ibv_modify_qp_resp*)(ULONG_PTR)p_umv_buf->p_inout_buf;

        if (IB_SUCCESS == ioctl_status)
        {
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\kernel\hca_verbs.c trunk\hw\mthca\kernel\hca_verbs.c
--- old\hw\mthca\kernel\hca_verbs.c     Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\kernel\hca_verbs.c   Fri Jul 11 12:55:52 2008
@@ -454,7 +454,7 @@ mlnx_um_open(
        umv_buf.command = 1;
        umv_buf.input_size = umv_buf.status = 0;
        umv_buf.output_size = sizeof(struct ibv_alloc_pd_resp);
-       umv_buf.p_inout_buf = &resp;
+       umv_buf.p_inout_buf = (ULONG_PTR)&resp;
        //NB: Pay attention ! Ucontext parameter is important here:
        // when it is present (i.e. - for user space) - mthca_alloc_pd won't create MR
        p_context->pd = ibv_alloc_pd(ib_dev, p_context, &umv_buf);
@@ -467,7 +467,7 @@ mlnx_um_open(
        }

        // fill more parameters for user (sanity checks are in mthca_alloc_ucontext)
-       uresp_p = (struct ibv_get_context_resp *)(void*)p_umv_buf->p_inout_buf;
+       uresp_p = (struct ibv_get_context_resp *)(ULONG_PTR)p_umv_buf->p_inout_buf;
        uresp_p->uar_addr = (uint64_t)(UINT_PTR)p_context->user_uar;
        uresp_p->pd_handle = resp.pd_handle;
        uresp_p->pdn = resp.pdn;
@@ -1249,7 +1249,7 @@ mlnx_ndi_modify_qp (
        umv_buf.command = TRUE; /* special case for NDI. Usually it's TRUE */
        umv_buf.input_size = 0;
        umv_buf.output_size = sizeof(struct ibv_modify_qp_resp);
-       umv_buf.p_inout_buf = buf;
+       umv_buf.p_inout_buf = (ULONG_PTR)buf;

        status = mlnx_modify_qp ( h_qp, p_modify_attr, p_qp_attr, &umv_buf );

diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\kernel\mt_verbs.c trunk\hw\mthca\kernel\mt_verbs.c
--- old\hw\mthca\kernel\mt_verbs.c      Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\kernel\mt_verbs.c    Fri Jul 11 12:55:54 2008
@@ -162,7 +162,7 @@ struct ib_ah *ibv_create_ah(struct ib_pd

        // for user call we need also allocate MR
        if (context && p_umv_buf && p_umv_buf->p_inout_buf) {
-               struct ibv_create_ah *create_ah = (struct ibv_create_ah *)(void*)p_umv_buf->p_inout_buf;
+               struct ibv_create_ah *create_ah = (struct ibv_create_ah *)(ULONG_PTR)p_umv_buf->p_inout_buf;

                // create region; destroy will be done on dealloc_pd
                ib_mr   = ibv_reg_mr(
@@ -189,7 +189,7 @@ struct ib_ah *ibv_create_ah(struct ib_pd

        /* fill obligatory fields */
        if (context && p_umv_buf && p_umv_buf->p_inout_buf) {
-               create_ah_resp = (struct ibv_create_ah_resp *)(void*)p_umv_buf->p_inout_buf;
+               create_ah_resp = (struct ibv_create_ah_resp *)(ULONG_PTR)p_umv_buf->p_inout_buf;
                create_ah_resp->user_handle = user_handle;
        }

@@ -209,7 +209,7 @@ struct ib_ah *ibv_create_ah(struct ib_pd

        // fill results for user
        if (context && p_umv_buf && p_umv_buf->p_inout_buf) {
-               struct ibv_create_ah_resp *create_ah_resp = (struct ibv_create_ah_resp *)(void*)p_umv_buf->p_inout_buf;
+               struct ibv_create_ah_resp *create_ah_resp = (struct ibv_create_ah_resp *)(ULONG_PTR)p_umv_buf->p_inout_buf;
                create_ah_resp->start = start;
                create_ah_resp->mr.lkey = ib_mr->lkey;
                create_ah_resp->mr.rkey = ib_mr->rkey;
@@ -322,7 +322,7 @@ struct ib_srq *ibv_create_srq(struct ib_

        // for user call we need also allocate MR
        if (context && p_umv_buf && p_umv_buf->p_inout_buf) {
-               struct ibv_create_srq *create_srp = (struct ibv_create_srq *)(void*)p_umv_buf->p_inout_buf;
+               struct ibv_create_srq *create_srp = (struct ibv_create_srq *)(ULONG_PTR)p_umv_buf->p_inout_buf;

                // create region
                ib_mr = ibv_reg_mr(
@@ -343,7 +343,7 @@ struct ib_srq *ibv_create_srq(struct ib_

        /* fill obligatory fields */
        if (context && p_umv_buf && p_umv_buf->p_inout_buf) {
-               create_srq_resp = (struct ibv_create_srq_resp *)(void*)p_umv_buf->p_inout_buf;
+               create_srq_resp = (struct ibv_create_srq_resp *)(ULONG_PTR)p_umv_buf->p_inout_buf;
                create_srq_resp->user_handle = user_handle;
        }

@@ -444,7 +444,7 @@ struct ib_qp *ibv_create_qp(struct ib_pd

        // for user call we need also allocate MR
        if (context && p_umv_buf && p_umv_buf->p_inout_buf) {
-               struct ibv_create_qp *create_qp = (struct ibv_create_qp *)(void*)p_umv_buf->p_inout_buf;
+               struct ibv_create_qp *create_qp = (struct ibv_create_qp *)(ULONG_PTR)p_umv_buf->p_inout_buf;

                // create region
                ib_mr   = ibv_reg_mr(
@@ -498,7 +498,7 @@ struct ib_qp *ibv_create_qp(struct ib_pd
        // fill results for user
        if (context && p_umv_buf && p_umv_buf->p_inout_buf) {
                struct mthca_qp *qp = (struct mthca_qp *)ib_qp;
-               struct ibv_create_qp_resp *create_qp_resp = (struct ibv_create_qp_resp *)(void*)p_umv_buf->p_inout_buf;
+               struct ibv_create_qp_resp *create_qp_resp = (struct ibv_create_qp_resp *)(ULONG_PTR)p_umv_buf->p_inout_buf;
                ib_qp->ib_mr = ib_mr;
                create_qp_resp->qpn = ib_qp->qp_num;
                create_qp_resp->user_handle = user_handle;
@@ -589,7 +589,7 @@ struct ib_cq *ibv_create_cq(struct ib_de

        // for user call we need also allocate MR
        if (context && p_umv_buf && p_umv_buf->p_inout_buf) {
-               struct ibv_create_cq *create_cq = (struct ibv_create_cq *)(void*)p_umv_buf->p_inout_buf;
+               struct ibv_create_cq *create_cq = (struct ibv_create_cq *)(ULONG_PTR)p_umv_buf->p_inout_buf;

                // create region
                ib_mr   = ibv_reg_mr(
@@ -626,7 +626,7 @@ struct ib_cq *ibv_create_cq(struct ib_de

        // fill results
        if (context && p_umv_buf && p_umv_buf->p_inout_buf) {
-               struct ibv_create_cq_resp *create_cq_resp = (struct ibv_create_cq_resp *)(void*)p_umv_buf->p_inout_buf;
+               struct ibv_create_cq_resp *create_cq_resp = (struct ibv_create_cq_resp *)(ULONG_PTR)p_umv_buf->p_inout_buf;
                cq->ib_mr = ib_mr;
                create_cq_resp->user_handle = user_handle;
                create_cq_resp->mr.lkey = ib_mr->lkey;
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\kernel\mthca_provider.c trunk\hw\mthca\kernel\mthca_provider.c
--- old\hw\mthca\kernel\mthca_provider.c        Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\kernel\mthca_provider.c      Fri Jul 11 12:55:55 2008
@@ -802,8 +802,8 @@ static struct ib_cq *mthca_create_cq(str
        if (err)
                goto err_free;

-       if (context ) {
-               struct ibv_create_cq_resp *create_cq_resp = (struct ibv_create_cq_resp *)(void*)p_umv_buf->p_inout_buf;
+       if (context) {
+               struct ibv_create_cq_resp *create_cq_resp = (struct ibv_create_cq_resp *)(ULONG_PTR)p_umv_buf->p_inout_buf;
                create_cq_resp->cqn = cq->cqn;
        }

diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\kernel\mthca_provider.h trunk\hw\mthca\kernel\mthca_provider.h
--- old\hw\mthca\kernel\mthca_provider.h        Thu Jun 26 20:35:15 2008
+++ trunk\hw\mthca\kernel\mthca_provider.h      Fri Jul 11 12:55:55 2008
@@ -348,7 +348,7 @@ static inline uint8_t end_port(struct ib

 static inline int ib_copy_from_umv_buf(void *dest, ci_umv_buf_t* const p_umv_buf, size_t len)
 {
-       RtlCopyMemory(dest, p_umv_buf->p_inout_buf,  len);
+       RtlCopyMemory(dest, (void*)(ULONG_PTR)p_umv_buf->p_inout_buf,  len);
        return 0;
 }

@@ -359,7 +359,7 @@ static inline int ib_copy_to_umv_buf(ci_
                p_umv_buf->output_size = 0;
                return -EFAULT;
        }
-       RtlCopyMemory(p_umv_buf->p_inout_buf,  src, len);
+       RtlCopyMemory((void*)(ULONG_PTR)p_umv_buf->p_inout_buf, src, len);
        p_umv_buf->status = IB_SUCCESS;
        p_umv_buf->output_size = (uint32_t)len;
        return 0;
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\user\mlnx_ual_av.c trunk\hw\mthca\user\mlnx_ual_av.c
--- old\hw\mthca\user\mlnx_ual_av.c     Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\user\mlnx_ual_av.c   Fri Jul 11 12:55:56 2008
@@ -170,7 +170,7 @@ __pre_create_av (

        // allocate parameters
        if( !p_umv_buf->p_inout_buf ) {
-               p_umv_buf->p_inout_buf = cl_zalloc( size );
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\user\mlnx_ual_ca.c trunk\hw\mthca\user\mlnx_ual_ca.c
--- old\hw\mthca\user\mlnx_ual_ca.c     Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\user\mlnx_ual_ca.c   Fri Jul 11 12:55:57 2008
@@ -58,7 +58,8 @@ __pre_open_ca (
        {
                if( !p_umv_buf->p_inout_buf )
                {
-                       p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_get_context_resp) );
+                       p_umv_buf->p_inout_buf =
+                               (ULONG_PTR)cl_zalloc( sizeof(struct ibv_get_context_resp) );
                        if( !p_umv_buf->p_inout_buf )
                        {
                                status = IB_INSUFFICIENT_MEMORY;
@@ -151,7 +152,7 @@ __pre_query_ca (
                 */
                if ( p_ca_attr != NULL )
                {
-                       p_umv_buf->p_inout_buf = cl_zalloc(byte_count);
+                       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc(byte_count);
                        if ( !p_umv_buf->p_inout_buf )
                        {
                                UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM ,
@@ -185,12 +186,12 @@ __post_query_ca (
                byte_count && !h_uvp_ca->p_hca_attr )
        {
                CL_ASSERT( byte_count >= p_ca_attr->size );
-               h_uvp_ca->p_hca_attr = p_umv_buf->p_inout_buf;
+               h_uvp_ca->p_hca_attr = (ib_ca_attr_t*)(ULONG_PTR)p_umv_buf->p_inout_buf;
                ib_copy_ca_attr( h_uvp_ca->p_hca_attr, p_ca_attr );
        }
        else if (p_umv_buf->p_inout_buf)
        {
-               cl_free (p_umv_buf->p_inout_buf);
+               cl_free( (void*)(ULONG_PTR)p_umv_buf->p_inout_buf );
        }

        UVP_EXIT(UVP_DBG_SHIM);
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\user\mlnx_ual_cq.c trunk\hw\mthca\user\mlnx_ual_cq.c
--- old\hw\mthca\user\mlnx_ual_cq.c     Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\user\mlnx_ual_cq.c   Fri Jul 11 12:55:58 2008
@@ -65,7 +65,7 @@ __pre_create_cq (

        if( !p_umv_buf->p_inout_buf )
        {
-               p_umv_buf->p_inout_buf = cl_zalloc( size );
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
@@ -89,7 +89,7 @@ __pre_create_cq (
        goto end;

 err_alloc_cq:
-       cl_free(p_umv_buf->p_inout_buf);
+       cl_free((void*)(ULONG_PTR)p_umv_buf->p_inout_buf);
 err_memory:
 end:
        UVP_EXIT(UVP_DBG_CQ);
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\user\mlnx_ual_data.h trunk\hw\mthca\user\mlnx_ual_data.h
--- old\hw\mthca\user\mlnx_ual_data.h   Thu Jun 26 20:35:15 2008
+++ trunk\hw\mthca\user\mlnx_ual_data.h Fri Jul 11 12:55:58 2008
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
+ * Portions Copyright (c) 2008 Microsoft Corporation.  All rights reserved.
  *
  * This software is available to you under the OpenIB.org BSD license
  * below:
@@ -49,10 +50,4 @@ typedef struct _ib_pd
        struct ibv_pd *ibv_pd;
        mlnx_ual_hobul_t        *p_hobul;
 } mlnx_ual_pd_info_t;
-
-typedef struct _ib_mw
-{
-TO_LONG_PTR(   ib_pd_handle_t ,                h_uvp_pd) ;
-       uint32_t                        rkey;
-} mlnx_ual_mw_info_t;

diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\user\mlnx_ual_mcast.c trunk\hw\mthca\user\mlnx_ual_mcast.c
--- old\hw\mthca\user\mlnx_ual_mcast.c  Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\user\mlnx_ual_mcast.c        Fri Jul 11 12:55:59 2008
@@ -49,7 +49,7 @@ __pre_attach_mcast (

        UVP_ENTER(UVP_DBG_SHIM);
        CL_ASSERT(p_umv_buf);
-       p_umv_buf->p_inout_buf = NULL;;
+       p_umv_buf->p_inout_buf = 0;;
        p_umv_buf->input_size = 0;
        p_umv_buf->output_size = 0;
        p_umv_buf->command = TRUE;
@@ -81,7 +81,7 @@ __pre_detach_mcast (
        UVP_ENTER(UVP_DBG_SHIM);

        CL_ASSERT(p_umv_buf);
-       p_umv_buf->p_inout_buf = NULL;;
+       p_umv_buf->p_inout_buf = 0;
        p_umv_buf->input_size = 0;
        p_umv_buf->output_size = 0;

diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\user\mlnx_ual_mrw.c trunk\hw\mthca\user\mlnx_ual_mrw.c
--- old\hw\mthca\user\mlnx_ual_mrw.c    Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\user\mlnx_ual_mrw.c  Fri Jul 11 12:56:00 2008
@@ -49,7 +49,7 @@ __pre_register_mr (

     UVP_ENTER(UVP_DBG_SHIM);
     CL_ASSERT(p_umv_buf);
-    p_umv_buf->p_inout_buf = NULL;;
+    p_umv_buf->p_inout_buf = 0;
     p_umv_buf->input_size = 0;
     p_umv_buf->output_size = 0;

@@ -80,7 +80,7 @@ __pre_query_mr (
 {
     UVP_ENTER(UVP_DBG_SHIM);
     CL_ASSERT(p_umv_buf);
-    p_umv_buf->p_inout_buf = NULL;;
+    p_umv_buf->p_inout_buf = 0;
     p_umv_buf->input_size = 0;
     p_umv_buf->output_size = 0;

@@ -112,7 +112,7 @@ __pre_modify_mr (
 {
     UVP_ENTER(UVP_DBG_SHIM);
     CL_ASSERT(p_umv_buf);
-    p_umv_buf->p_inout_buf = NULL;;
+    p_umv_buf->p_inout_buf = 0;
     p_umv_buf->input_size = 0;
     p_umv_buf->output_size = 0;

@@ -146,7 +146,7 @@ __pre_register_smr (
 {
     UVP_ENTER(UVP_DBG_SHIM);
     CL_ASSERT(p_umv_buf);
-    p_umv_buf->p_inout_buf = NULL;;
+    p_umv_buf->p_inout_buf = 0;
     p_umv_buf->input_size = 0;
     p_umv_buf->output_size = 0;

diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\user\mlnx_ual_pd.c trunk\hw\mthca\user\mlnx_ual_pd.c
--- old\hw\mthca\user\mlnx_ual_pd.c     Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\user\mlnx_ual_pd.c   Fri Jul 11 12:56:01 2008
@@ -57,7 +57,7 @@ __pre_allocate_pd (

        if( !p_umv_buf->p_inout_buf )
        {
-               p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_alloc_pd_resp) );
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( sizeof(struct ibv_alloc_pd_resp) );
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\user\mlnx_ual_qp.c trunk\hw\mthca\user\mlnx_ual_qp.c
--- old\hw\mthca\user\mlnx_ual_qp.c     Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\user\mlnx_ual_qp.c   Fri Jul 11 12:56:02 2008
@@ -102,7 +102,7 @@ __pre_create_qp (

        if( !p_umv_buf->p_inout_buf )
        {
-               p_umv_buf->p_inout_buf = cl_zalloc( size );
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
@@ -142,7 +142,7 @@ __pre_create_qp (
        goto end;

 err_alloc_qp:
-       cl_free(p_umv_buf->p_inout_buf);
+       cl_free((void*)(ULONG_PTR)p_umv_buf->p_inout_buf);
 err_memory:
 end:
                UVP_EXIT(UVP_DBG_QP);
@@ -209,7 +209,8 @@ __pre_modify_qp (

        if( !p_umv_buf->p_inout_buf )
        {
-               p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_modify_qp_resp) );
+               p_umv_buf->p_inout_buf =
+                       (ULONG_PTR)cl_zalloc( sizeof(struct ibv_modify_qp_resp) );
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\user\mlnx_ual_srq.c trunk\hw\mthca\user\mlnx_ual_srq.c
--- old\hw\mthca\user\mlnx_ual_srq.c    Fri Jul 11 13:03:58 2008
+++ trunk\hw\mthca\user\mlnx_ual_srq.c  Fri Jul 11 12:56:03 2008
@@ -95,7 +95,7 @@ __pre_create_srq (

        if( !p_umv_buf->p_inout_buf )
        {
-               p_umv_buf->p_inout_buf = cl_zalloc( size );
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );
                if( !p_umv_buf->p_inout_buf )
                {
                        status = IB_INSUFFICIENT_MEMORY;
@@ -162,7 +162,7 @@ err_alloc_buf:
 err_lock:
        cl_free(srq);
 err_alloc_srq:
-       cl_free(p_umv_buf->p_inout_buf);
+       cl_free((void*)(ULONG_PTR)p_umv_buf->p_inout_buf);
 err_memory:
 err_params:
 end:
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\hw\mthca\user\mlnx_uvp.h trunk\hw\mthca\user\mlnx_uvp.h
--- old\hw\mthca\user\mlnx_uvp.h        Thu Jun 26 20:35:15 2008
+++ trunk\hw\mthca\user\mlnx_uvp.h      Fri Jul 11 12:56:03 2008
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Cisco Systems.  All rights reserved.
+ * Portions Copyright (c) 2008 Microsoft Corporation.  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
@@ -199,7 +200,7 @@ struct mthca_av {
 struct mthca_ah {
        struct mthca_av      *av;
        ib_av_attr_t            av_attr;
-TO_LONG_PTR(   ib_pd_handle_t ,        h_uvp_pd) ;
+       ib_pd_handle_t  h_uvp_pd;
        struct mthca_ah_page *page;
        uint32_t              key;
        int     in_kernel;
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\inc\iba\ib_ci.h trunk\inc\iba\ib_ci.h
--- old\inc\iba\ib_ci.h Tue Jul 01 09:31:01 2008
+++ trunk\inc\iba\ib_ci.h       Fri Jul 11 12:56:03 2008
@@ -138,7 +138,7 @@ typedef struct _umv_buf
        uint32_t                status;
        uint32_t                input_size;
        uint32_t                output_size;
-       TO_LONG_PTR(void* ,     p_inout_buf) ;
+       uint64_t                p_inout_buf;
 } ci_umv_buf_t;
 /******/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: umvbuf.patch
Type: application/octet-stream
Size: 31966 bytes
Desc: umvbuf.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080711/ae1f4b93/attachment.obj>


More information about the ofw mailing list