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

vippostsend.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 
00036 VIP_ENTRY_POINT VIP_RETURN
00037 VipPostSend (VIP_VI_HANDLE ViHandle,
00038              VIP_DESCRIPTOR * DescriptorPtr, VIP_MEM_HANDLE MemoryHandle)
00039 {
00040   VIP_VI *vip_vi_ptr;
00041   VIP_GM *vip_gm_ptr;
00042   VIP_NIC *vip_nic_ptr;
00043   VIP_UINT32 vip_vi_ptag_id;
00044   VIP_DEBUG_LABEL (("VipPostSend"));
00045 
00046   /* check VI handle */
00047   vip_vi_ptr = (VIP_VI *) ViHandle;
00048   if (VIP_INVALID_VI_HANDLE (vip_vi_ptr))
00049     {
00050       VIP_DEBUG (("Invalid VI handle"));
00051       return VIP_INVALID_PARAMETER;
00052     }
00053   vip_nic_ptr = vip_vi_ptr->handle.vip_nic_ptr;
00054   vip_gm_ptr = vip_nic_ptr->vip_gm_ptr;
00055   VIP_MUTEX_LOCK (&(vip_gm_ptr->lock));
00056   VIP_MUTEX_LOCK (&(vip_nic_ptr->lock));
00057 
00058   vip_vi_ptr->send_queue.total_count++;
00059 
00060   /* check descriptor */
00061   if (DescriptorPtr == NULL)
00062     {
00063       VIP_DEBUG (("Descriptor is NULL"));
00064       goto async_post_desc_error;
00065     }
00066 
00067   /* check VI PTAG handle */
00068   if (VIP_INVALID_PTAG_HANDLE (vip_vi_ptr->vip_ptag_ptr))
00069     {
00070       VIP_DEBUG (("Invalid VI PTAG handle"));
00071       goto async_post_desc_error;
00072     }
00073   vip_vi_ptag_id = vip_vi_ptr->vip_ptag_ptr->id;
00074 
00075   /* check MemoryHandle */
00076   if (vip_check_memory_handle (vip_nic_ptr, MemoryHandle,
00077                                (VIP_UINT64) ((VIP_UINTPTR) DescriptorPtr),
00078                                sizeof (VIP_CONTROL_SEGMENT),
00079                                vip_vi_ptag_id) != VIP_SUCCESS)
00080     {
00081       VIP_DEBUG (("Control segment Memory Handle check error"));
00082       goto async_post_desc_error;
00083     }
00084 
00085   DescriptorPtr->CS.Next.AddressBits = 0;
00086   DescriptorPtr->CS.NextHandle = 0;
00087   DescriptorPtr->CS.Status = 0;
00088 
00089   /* queue the send descriptor */
00090   if (vip_vi_ptr->send_queue.last != NULL)
00091     {
00092       /* there is already some descriptors in the queue */
00093       VIP_ASSERT (vip_vi_ptr->send_queue.first != NULL);
00094       VIP_ASSERT (vip_vi_ptr->send_queue.total_count > 1);
00095       vip_vi_ptr->send_queue.last->CS.Next.Address = DescriptorPtr;
00096       vip_vi_ptr->send_queue.last->CS.NextHandle = MemoryHandle;
00097       vip_vi_ptr->send_queue.last = DescriptorPtr;
00098 
00099       if (vip_vi_ptr->send_queue.count_to_process == 0)
00100         {
00101           VIP_ASSERT (vip_vi_ptr->send_queue.current_desc == NULL);
00102           vip_vi_ptr->send_queue.current_desc = DescriptorPtr;
00103           vip_vi_ptr->send_queue.current_mem = MemoryHandle;
00104         }
00105     }
00106   else
00107     {
00108       /* send queue is empty */
00109       VIP_ASSERT (vip_vi_ptr->send_queue.first == NULL);
00110       VIP_ASSERT (vip_vi_ptr->send_queue.current_desc == NULL);
00111       VIP_ASSERT (vip_vi_ptr->send_queue.count_to_process == 0);
00112       VIP_ASSERT (vip_vi_ptr->send_queue.total_count == 1);
00113       vip_vi_ptr->send_queue.first = DescriptorPtr;
00114       vip_vi_ptr->send_queue.last = DescriptorPtr;
00115       vip_vi_ptr->send_queue.current_desc = DescriptorPtr;
00116       vip_vi_ptr->send_queue.current_mem = MemoryHandle;
00117     }
00118 
00119   vip_vi_ptr->send_queue.count_to_process++;
00120 
00121   /* process the send descriptor, if it's the right moment for that */
00122   if (vip_vi_ptr->send_queue.current_desc == DescriptorPtr)
00123     {
00124       vip_process_send_desc (vip_vi_ptr);
00125     }
00126 
00127   VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00128   VIP_MUTEX_UNLOCK (&(vip_gm_ptr->lock));
00129   VIP_DEBUG (("Success"));
00130   return VIP_SUCCESS;
00131 
00132 async_post_desc_error:
00133   /* generate the asynchronous error */
00134   vip_generate_async_error (vip_nic_ptr, vip_vi_ptr, NULL, DescriptorPtr,
00135                             VIP_RESOURCE_DESCRIPTOR, VIP_ERROR_POST_DESC, 0);
00136 
00137   if (vip_vi_ptr->state != VIP_STATE_ERROR)
00138     {
00139       /* the VI transition to error state */
00140       vip_vi_transition_to_error_state (vip_vi_ptr, VIP_TRUE);
00141 
00142       /* a connection lost asynchronous error is generated */
00143       vip_generate_async_error (vip_nic_ptr, vip_vi_ptr, NULL, NULL,
00144                                 VIP_RESOURCE_VI, VIP_ERROR_CONN_LOST, 0);
00145     }
00146 
00147   VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00148   VIP_MUTEX_UNLOCK (&(vip_gm_ptr->lock));
00149   VIP_DEBUG (("Post Descriptor error"));
00150   return VIP_SUCCESS;
00151 }
VI-GM-1.3 by Myricom © 1997-2006. Documentation generated on 20 May 2006 by doxygen 1.4.4.