NTSTATUS NICWritePacket( IN PFDO_DATA FdoData, IN WDFDMATRANSACTION DmaTransaction, IN PSCATTER_GATHER_LIST SGList ) /*++ Routine Description: Do the work to send a packet Assumption: This function is called with the Send SPINLOCK held. Arguments: FdoData Pointer to our FdoData Return Value: --*/ { PMP_TCB pMpTcb = NULL; NTSTATUS status; TraceEvents(TRACE_LEVEL_VERBOSE, DBG_WRITE, "--> NICWritePacket: SGList %p\n", SGList); // // Initialize the Transfer Control Block. // pMpTcb = FdoData->CurrSendTail; ASSERT(!MP_TEST_FLAG(pMpTcb, fMP_TCB_IN_USE)); pMpTcb->DmaTransaction = DmaTransaction; MP_SET_FLAG(pMpTcb, fMP_TCB_IN_USE); // // Call the send handler, it only needs to deal with the ScatterGather list // status = NICSendPacket(FdoData, pMpTcb, SGList); if(!NT_SUCCESS(status)){ MP_CLEAR_FLAG(pMpTcb, fMP_TCB_IN_USE); return status; } FdoData->nBusySend++; ASSERT(FdoData->nBusySend <= FdoData->NumTcb); FdoData->CurrSendTail = FdoData->CurrSendTail->Next; TraceEvents(TRACE_LEVEL_VERBOSE, DBG_WRITE, "<-- NICWritePacket\n"); return status; }
VOID NICWritePacket( __in PFDO_DATA FdoData, __in PIRP Irp, __in BOOLEAN bFromQueue ) /*++ Routine Description: Do the work to send a packet Assumption: Send spinlock has been acquired Arguments: FdoData Pointer to our FdoData Packet The packet bFromQueue TRUE if it's taken from the send wait queue Return Value: --*/ { PMP_TCB pMpTcb = NULL; ULONG packetLength; PVOID virtualAddress; DebugPrint(TRACE, DBG_WRITE, "--> NICWritePacket, Irp= %p\n", Irp); // // Get the next free TCB and initialize it to represent the // request buffer. // pMpTcb = FdoData->CurrSendTail; ASSERT(!MP_TEST_FLAG(pMpTcb, fMP_TCB_IN_USE)); // // If the adapter is not ready, fail the request. // if(MP_IS_NOT_READY(FdoData)) { MP_FREE_SEND_PACKET(FdoData, pMpTcb, STATUS_DEVICE_NOT_READY); return; } pMpTcb->FirstBuffer = Irp->MdlAddress; virtualAddress = MmGetMdlVirtualAddress(Irp->MdlAddress); pMpTcb->BufferCount = 1; pMpTcb->PacketLength = packetLength = MmGetMdlByteCount(Irp->MdlAddress); pMpTcb->PhysBufCount = ADDRESS_AND_SIZE_TO_SPAN_PAGES(virtualAddress, packetLength); pMpTcb->Irp = Irp; MP_SET_FLAG(pMpTcb, fMP_TCB_IN_USE); // // Call the send handler, it only needs to deal with the frag list // NICSendPacket(FdoData, pMpTcb, Irp->Tail.Overlay.DriverContext[3]); FdoData->nBusySend++; ASSERT(FdoData->nBusySend <= FdoData->NumTcb); FdoData->CurrSendTail = FdoData->CurrSendTail->Next; DebugPrint(TRACE, DBG_WRITE, "<-- NICWritePacket\n"); return; }