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

vipcqdone.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 
00060 VIP_ENTRY_POINT VIP_RETURN
00061 VipCQDone (VIP_CQ_HANDLE CQHandle,
00062            VIP_VI_HANDLE * ViHandle, VIP_BOOLEAN * RecvQueue)
00063 {
00064   VIP_CQ *vip_cq_ptr;
00065   VIP_GM *vip_gm_ptr;
00066   VIP_NIC *vip_nic_ptr;
00067   VIP_CQ_ENTRY *vip_cq_entry_ptr;
00068   VIP_DEBUG_LABEL (("VipCQDone"));
00069 
00070   /* check CQ handle */
00071   vip_cq_ptr = (VIP_CQ *) CQHandle;
00072   if (VIP_INVALID_CQ_HANDLE (vip_cq_ptr))
00073     {
00074       VIP_DEBUG (("Invalid CQ handle"));
00075       return VIP_INVALID_PARAMETER;
00076     }
00077   vip_nic_ptr = vip_cq_ptr->handle.vip_nic_ptr;
00078   vip_gm_ptr = vip_nic_ptr->vip_gm_ptr;
00079   VIP_MUTEX_LOCK (&(vip_gm_ptr->lock));
00080   VIP_PROGRESSION (vip_gm_ptr);
00081   VIP_MUTEX_LOCK (&(vip_nic_ptr->lock));
00082 
00083   /* check if first entry is complete */
00084   VIP_ASSERT (vip_cq_ptr->next_poll < vip_cq_ptr->count);
00085   vip_cq_entry_ptr = &(vip_cq_ptr->queue[vip_cq_ptr->next_poll]);
00086   if ((vip_cq_ptr->event_count > 0) ||
00087       (vip_cq_entry_ptr->completed == VIP_FALSE))
00088     {
00089       VIP_DEBUG (("Completion Queue entry is not complete"));
00090       VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00091       VIP_MUTEX_UNLOCK (&(vip_gm_ptr->lock));
00092       return VIP_NOT_DONE;
00093     }
00094 
00095   /* dequeue the completion queue entry */
00096   if ((vip_cq_ptr->next_poll + 1) < vip_cq_ptr->count)
00097     {
00098       vip_cq_ptr->next_poll++;
00099     }
00100   else
00101     {
00102       vip_cq_ptr->next_poll = 0;
00103     }
00104 
00105   /* return usefull information */
00106   VIP_ASSERT (vip_cq_entry_ptr->vip_vi_ptr != NULL);
00107   *ViHandle = (VIP_VI_HANDLE) (vip_cq_entry_ptr->vip_vi_ptr);
00108   *RecvQueue = vip_cq_entry_ptr->recv_queue;
00109 
00110   /* invalid the cq entry */
00111   vip_cq_entry_ptr->vip_vi_ptr = NULL;
00112   vip_cq_entry_ptr->completed = VIP_FALSE;
00113 
00114   VIP_DEBUG (("Success"));
00115   VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00116   VIP_MUTEX_UNLOCK (&(vip_gm_ptr->lock));
00117   return VIP_SUCCESS;
00118 }
VI-GM-1.3 by Myricom © 1997-2006. Documentation generated on 20 May 2006 by doxygen 1.4.4.