SMBD outstanding request, for example, a Send or Receive request.
        /// <summary>
        /// Post Receive request
        /// </summary>
        /// <param name="bufferSize"></param>
        /// <returns></returns>
        public NtStatus PostReceive(uint bufferSize)
        {
            if (receiveEntries[receiveIndex].IsOccupied)
            {
                this.LogEvent("No more entries");
                // return no more entries. The error code is the same with RDMA
                return(NtStatus.STATUS_NO_MORE_ENTRIES);
            }

            SmbdRequest receiveRequest = new SmbdRequest();

            receiveRequest.EntryIndex = receiveIndex;
            receiveRequest.Type       = RequestType.Receive;
            NtStatus ret = (NtStatus)rdmaEndpoint.Receive(
                new RdmaSegment[] { receiveEntries[receiveIndex].Segment },
                out receiveRequest.ResultId);

            if (ret != NtStatus.STATUS_SUCCESS)
            {
                this.LogEvent(string.Format("Raise receive request with error code {0}", ret));
                return(ret);
            }
            // receive request has been submitted
            requestCount++;
            rdmaNotificationSemaphore.Release();

            lock (locker)
            {
                receiveRequestList.Add(receiveRequest);
                ReceivePostedCount++;
            }

            this.LogEvent(
                string.Format(
                    "Post receive successfully with entry 0x{0:X} with memory handler 0x{1:X} notification id: 0x{2:X}",
                    receiveIndex,
                    receiveEntries[receiveIndex].Segment.MemoryHandler,
                    receiveRequest.ResultId));
            receiveEntries[receiveIndex].IsOccupied = true;

            // calculate the index of next receive entry
            receiveIndex++;
            if ((UInt64)receiveIndex >= inboundEntries)
            {
                receiveIndex = 0;
            }


            return(NtStatus.STATUS_SUCCESS);
        }
        /// <summary>
        /// Register memory windows
        /// </summary>
        /// <param name="size">Size of memory to register</param>
        /// <param name="flag"></param>
        /// <param name="reversed">if it is true, little-endian and big-endian will be reversed in bufferDescriptor</param>
        /// <param name="bufferDescriptor">Buffer Descriptor point to memory windows</param>
        /// <returns></returns>
        public NtStatus RegisterMemoryWindow(
            uint size,
            RdmaOperationReadWriteFlag flag,
            bool reversed,
            out RdmaBufferDescriptorV1 bufferDescriptor)
        {
            bufferDescriptor = new RdmaBufferDescriptorV1();

            // regiser the buffer
            SmbdMemoryWindow memoryWindow = new SmbdMemoryWindow();

            memoryWindow.IsValid = true;
            NtStatus status = (NtStatus)rdmaAdapter.RegisterMemory(size, out memoryWindow.MemoryHandlerId);

            if (status != NtStatus.STATUS_SUCCESS)
            {
                return(status);
            }

            // create memory window
            SmbdRequest invalidRequest = new SmbdRequest();

            invalidRequest.Type = RequestType.Invalid;
            status = (NtStatus)rdmaAdapter.CreateMemoryWindow(invalidRequest.ResultId,
                                                              out memoryWindow.RdmaMW);
            memoryWindow.InvalidResultId = invalidRequest.ResultId;
            if (status != NtStatus.STATUS_SUCCESS)
            {
                return(status);
            }
            // invalid notification request has been submitted
            requestCount++;
            rdmaNotificationSemaphore.Release();

            // bind
            UInt64 resultId;

            status = (NtStatus)rdmaEndpoint.Bind(
                memoryWindow.MemoryHandlerId,
                memoryWindow.RdmaMW,
                flag,
                reversed,
                out memoryWindow.BufferDescriptor, out resultId);

            if (status != NtStatus.STATUS_SUCCESS)
            {
                return(status);
            }
            lock (locker)
            {
                this.receiveRequestList.Add(invalidRequest);
            }

            SmbdRequestResult requestResult = GetRequestResult(new TimeSpan(0, 0, 5), RequestType.Bind);

            this.LogEvent(string.Format("Bind memory window with result id: {0}. And get notification with id: {1}, status: {2}",
                                        resultId,
                                        requestResult.ResultId,
                                        requestResult.ResultInfo.Status
                                        ));

            status = (NtStatus)requestResult.ResultInfo.Status;
            if (status != NtStatus.STATUS_SUCCESS)
            {
                return(status);
            }

            this.memoryWindowList.Add(memoryWindow);
            bufferDescriptor = memoryWindow.BufferDescriptor;
            return(status);
        }
        /// <summary>
        /// Register memory windows
        /// </summary>
        /// <param name="size">Size of memory to register</param>
        /// <param name="flag"></param>
        /// <param name="reversed">if it is true, little-endian and big-endian will be reversed in bufferDescriptor</param>
        /// <param name="bufferDescriptor">Buffer Descriptor point to memory windows</param>
        /// <returns></returns>
        public NtStatus RegisterMemoryWindow(
            uint size,
            RdmaOperationReadWriteFlag flag,
            bool reversed,
            out RdmaBufferDescriptorV1 bufferDescriptor)
        {
            bufferDescriptor = new RdmaBufferDescriptorV1();

            // regiser the buffer
            SmbdMemoryWindow memoryWindow = new SmbdMemoryWindow();
            memoryWindow.IsValid = true;
            NtStatus status = (NtStatus)rdmaAdapter.RegisterMemory(size, out memoryWindow.MemoryHandlerId);
            if (status != NtStatus.STATUS_SUCCESS)
            {
                return status;
            }

            // create memory window
            SmbdRequest invalidRequest = new SmbdRequest();
            invalidRequest.Type = RequestType.Invalid;
            status = (NtStatus)rdmaAdapter.CreateMemoryWindow(invalidRequest.ResultId,
                out memoryWindow.RdmaMW);
            memoryWindow.InvalidResultId = invalidRequest.ResultId;
            if (status != NtStatus.STATUS_SUCCESS)
            {
                return status;
            }
            // invalid notification request has been submitted
            requestCount++;
            rdmaNotificationSemaphore.Release();

            // bind
            UInt64 resultId;
            status = (NtStatus)rdmaEndpoint.Bind(
                memoryWindow.MemoryHandlerId,
                memoryWindow.RdmaMW,
                flag,
                reversed,
                out memoryWindow.BufferDescriptor, out resultId);

            if (status != NtStatus.STATUS_SUCCESS)
            {
                return status;
            }
            lock (locker)
            {
                this.receiveRequestList.Add(invalidRequest);
            }

            SmbdRequestResult requestResult = GetRequestResult(new TimeSpan(0, 0, 5), RequestType.Bind);
            this.LogEvent(string.Format("Bind memory window with result id: {0}. And get notification with id: {1}, status: {2}",
                resultId,
                requestResult.ResultId,
                requestResult.ResultInfo.Status
                ));

            status = (NtStatus)requestResult.ResultInfo.Status;
            if (status != NtStatus.STATUS_SUCCESS)
            {
                return status;
            }

            this.memoryWindowList.Add(memoryWindow);
            bufferDescriptor = memoryWindow.BufferDescriptor;
            return status;
        }
        /// <summary>
        /// Post Receive request
        /// </summary>
        /// <param name="bufferSize"></param>
        /// <returns></returns>
        public NtStatus PostReceive(uint bufferSize)
        {
            if (receiveEntries[receiveIndex].IsOccupied)
            {
                this.LogEvent("No more entries");
                // return no more entries. The error code is the same with RDMA
                return NtStatus.STATUS_NO_MORE_ENTRIES;
            }

            SmbdRequest receiveRequest = new SmbdRequest();
            receiveRequest.EntryIndex = receiveIndex;
            receiveRequest.Type = RequestType.Receive;
            NtStatus ret = (NtStatus)rdmaEndpoint.Receive(
                new RdmaSegment[] { receiveEntries[receiveIndex].Segment },
                out receiveRequest.ResultId);
            if (ret != NtStatus.STATUS_SUCCESS)
            {
                this.LogEvent(string.Format("Raise receive request with error code {0}", ret));
                return ret;
            }
            // receive request has been submitted
            requestCount++;
            rdmaNotificationSemaphore.Release();

            lock (locker)
            {
                receiveRequestList.Add(receiveRequest);
                ReceivePostedCount++;
            }

            this.LogEvent(
                string.Format(
                    "Post receive successfully with entry 0x{0:X} with memory handler 0x{1:X} notification id: 0x{2:X}",
                    receiveIndex,
                    receiveEntries[receiveIndex].Segment.MemoryHandler,
                    receiveRequest.ResultId));
            receiveEntries[receiveIndex].IsOccupied = true;

            // calculate the index of next receive entry
            receiveIndex++;
            if ((UInt64)receiveIndex >= inboundEntries)
            {
                receiveIndex = 0;
            }

            return NtStatus.STATUS_SUCCESS;
        }