
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 00038 VIP_ENTRY_POINT VIP_RETURN 00039 VipDestroyPtag (VIP_NIC_HANDLE NicHandle, VIP_PROTECTION_HANDLE ProtectionTag) 00040 { 00041 VIP_PTAG *vip_ptag_ptr; 00042 VIP_NIC *vip_nic_ptr; 00043 VIP_DEBUG_LABEL (("VipDestroyPtag")); 00044 00045 /* check nic handle */ 00046 vip_nic_ptr = (VIP_NIC *) NicHandle; 00047 if (VIP_INVALID_NIC_HANDLE (vip_nic_ptr)) 00048 { 00049 VIP_DEBUG (("Invalid NIC handle")); 00050 return VIP_INVALID_PARAMETER; 00051 } 00052 VIP_MUTEX_LOCK (&(vip_nic_ptr->lock)); 00053 00054 /* check ptag */ 00055 vip_ptag_ptr = (VIP_PTAG *) ProtectionTag; 00056 if (VIP_INVALID_PTAG_HANDLE (vip_ptag_ptr)) 00057 { 00058 VIP_DEBUG (("Invalid PTAG handle")); 00059 VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock)); 00060 return VIP_INVALID_PARAMETER; 00061 } 00062 00063 /* check ptag/nic association */ 00064 if (vip_ptag_ptr->handle.vip_nic_ptr != vip_nic_ptr) 00065 { 00066 VIP_DEBUG (("ProtectionTag not associated with NicHandle")); 00067 VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock)); 00068 return VIP_INVALID_PARAMETER; 00069 } 00070 00071 /* check ref_count is 0 */ 00072 if (vip_ptag_ptr->handle.ref_count > 0) 00073 { 00074 VIP_DEBUG (("PTag still in use")); 00075 VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock)); 00076 return VIP_ERROR_RESOURCE; 00077 } 00078 00079 /* free the ptag handle */ 00080 vip_free_handle (&(vip_nic_ptr->vip_ptag_set), (VIP_HANDLE *) vip_ptag_ptr); 00081 00082 VIP_DEBUG (("Success")); 00083 VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock)); 00084 return VIP_SUCCESS; 00085 }
1.4.4.