Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

vipsetmemattributes.c

Go to the documentation of this file.
00001 /********************************************************
00002  * Myricom VI-GM  networking software and documentation *
00003  * Copyright (c) 2001 by Myricom, Inc.                  *
00004  * All rights reserved.                                 *
00005  * See the file `COPYING' for copyright notice.         *
00006  ********************************************************/
00007 
00013 #include "vipl_priv.h"
00014 
00015 
00051 VIP_ENTRY_POINT VIP_RETURN
00052 VipSetMemAttributes (VIP_NIC_HANDLE NicHandle,
00053                      VIP_PVOID Address,
00054                      VIP_MEM_HANDLE MemHandle,
00055                      VIP_MEM_ATTRIBUTES * MemAttribs)
00056 {
00057   VIP_MEM *vip_mem_ptr;
00058   VIP_NIC *vip_nic_ptr;
00059   VIP_PTAG *new_vip_ptag_ptr;
00060   VIP_DEBUG_LABEL (("VipSetMemAttributes"));
00061 
00062   if (Address == NULL)
00063     {
00064       VIP_DEBUG (("Address is null"));
00065       return VIP_INVALID_PARAMETER;
00066     }
00067 
00068   if ((MemHandle == 0) || (MemHandle > VI_GM_MAX_REGISTER_REGIONS))
00069     {
00070       VIP_DEBUG (("MemHandle is invalid"));
00071       return VIP_INVALID_PARAMETER;
00072     }
00073 
00074   if (MemAttribs == NULL)
00075     {
00076       VIP_DEBUG (("MemAttribs is null"));
00077       return VIP_INVALID_PARAMETER;
00078     }
00079 
00080   if (MemAttribs->EnableRdmaRead != VI_GM_ENABLE_RDMAREAD)
00081     {
00082       VIP_DEBUG (("Invalid EnableRdmaRead in MemAttribs"));
00083       return VIP_INVALID_RDMAREAD;
00084     }
00085 
00086   if ((MemAttribs->EnableRdmaWrite != VIP_TRUE)
00087       && (MemAttribs->EnableRdmaWrite != VIP_FALSE))
00088     {
00089       VIP_DEBUG (("Invalid EnableRdmaWrite in MemAttribs"));
00090       return VIP_INVALID_PARAMETER;
00091     }
00092 
00093   /* check nic handle */
00094   vip_nic_ptr = (VIP_NIC *) NicHandle;
00095   if (VIP_INVALID_NIC_HANDLE (vip_nic_ptr))
00096     {
00097       VIP_DEBUG (("Invalid NIC handle"));
00098       return VIP_INVALID_PARAMETER;
00099     }
00100   VIP_MUTEX_LOCK (&(vip_nic_ptr->lock));
00101 
00102   /* check regmem handle */
00103   vip_mem_ptr = (VIP_MEM *) (vip_nic_ptr->vip_mem_handle_ptrs[MemHandle]);
00104   if (VIP_INVALID_MEM_HANDLE (vip_mem_ptr))
00105     {
00106       VIP_DEBUG (("Invalid MEM handle"));
00107       VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00108       return VIP_INVALID_PARAMETER;
00109     }
00110 
00111   /* check virtual address consistency */
00112   if (vip_mem_ptr->address != Address)
00113     {
00114       VIP_DEBUG (("Inconsistent virtual address"));
00115       VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00116       return VIP_INVALID_PARAMETER;
00117     }
00118 
00119   /* check new ptag */
00120   new_vip_ptag_ptr = MemAttribs->Ptag;
00121   if (VIP_INVALID_PTAG_HANDLE (new_vip_ptag_ptr))
00122     {
00123       VIP_DEBUG (("Invalid new PTAG handle"));
00124       VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00125       return VIP_INVALID_PTAG;
00126     }
00127 
00128   /* check new ptag's NIC */
00129   if (new_vip_ptag_ptr->handle.vip_nic_ptr != vip_nic_ptr)
00130     {
00131       VIP_DEBUG (("PTAG handle's NIC inconsistency"));
00132       VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00133       return VIP_INVALID_PTAG;
00134     }
00135 
00136   /* update the ptag */
00137   if (vip_mem_ptr->vip_ptag_ptr != new_vip_ptag_ptr)
00138     {
00139       VIP_ASSERT (vip_mem_ptr->vip_ptag_ptr->handle.ref_count > 0);
00140       vip_mem_ptr->vip_ptag_ptr->handle.ref_count--;
00141       new_vip_ptag_ptr->handle.ref_count++;
00142     }
00143 
00144   vip_mem_ptr->vip_ptag_ptr = new_vip_ptag_ptr;
00145   vip_mem_ptr->rdma_write = MemAttribs->EnableRdmaWrite;
00146 
00147   VIP_DEBUG (("Success"));
00148   VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00149   return VIP_SUCCESS;
00150 }
VI-GM-1.3 by Myricom © 1997-2006. Documentation generated on 20 May 2006 by doxygen 1.4.4.