Hi all,
I am trying to build a packet to be received by netvmini adapter. In
initialization phrase, I allocate the packet buffer bool and packet
descripter pool:
//
// Allocate a buffer pool for receive buffers. by lchen
//
NdisAllocateBufferPool(
&Status,
&Adapter->RecvBufferPool,
1024 );
if(Status != NDIS_STATUS_SUCCESS)
{
DEBUGP(MP_ERROR, ("NdisAllocateBufferPool for recv buffer
failed\n"));
break;
}
//
// Allocate packet pool for receive indications
//
NdisAllocatePacketPool(
&Status,
&Adapter->RecvPacketPool,
1024,
PROTOCOL_RESERVED_SIZE_IN_PACKET);
if(Status != NDIS_STATUS_SUCCESS)
{
DEBUGP(MP_ERROR, ("NdisAllocatePacketPool failed\n"));
break;
}
When I build my packet triggered by the IoControl from my application, I
allocate memory, NDIS_BUFFER and NDIS_PACKET:
status = NdisAllocateMemoryWithTag( &pBufVA, uBufLen, NIC_TAG );
if( status != NDIS_STATUS_SUCCESS )
{
DEBUGP(MP_ERROR, ("Fail to allocate memory for the generated
packet.\n"));
break;
}
//
// Allocate packet buffer
//
NdisAllocateBuffer(
&status,
&pNdisBuffer,
pAdapter->RecvBufferPool,
pBufVA,
NIC_BUFFER_SIZE );
if(status != NDIS_STATUS_SUCCESS)
{
DEBUGP(MP_ERROR, ("NdisAllocateBuffer failed, status =
0x%x\n", status));
break;
}
//
// Allocate a packet descriptor for receive packets from a preallocated pool.
//
NdisAllocatePacket(
&status,
&MyPacket,
pAdapter->RecvPacketPool );
if( status != NDIS_STATUS_SUCCESS )
{
DEBUGP(MP_ERROR, ("NdisAllocatePacket failed, status = 0x%x\n",
status));
break;
}
NdisChainBufferAtFront( MyPacket, pNdisBuffer );
MyPacket->Private.Head->Next =NULL;
MyPacket->Private.Tail=NULL;
NdisMIndicateReceivePacket(
pAdapter->AdapterHandle,
&MyPacket,
1);
NdisFreeBuffer( pNdisBuffer );
pNdisBuffer = NULL;
NdisDprFreePacket(MyPacket);
However, the driver crashes due to the page fault error, when calling
NdisAllocatePacket(
&status,
&MyPacket,
pAdapter->RecvPacketPool );
How can I fix the bug?
Thanks!
-Liang