diff options
author | Yu Pei <pei.yu@intel.com> | 2013-06-27 05:07:29 +0000 |
---|---|---|
committer | qianouyang <qianouyang@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-06-27 05:07:29 +0000 |
commit | 4986bbaf1151d1cccc1f2589bd13a86b539676b2 (patch) | |
tree | 978f1316e6cd66d885ed3de0974d860bb196ae4e /OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772/Ax88772.c | |
parent | ca243131657ba03f58206a417b938aa14cff585c (diff) | |
download | edk2-4986bbaf1151d1cccc1f2589bd13a86b539676b2.zip edk2-4986bbaf1151d1cccc1f2589bd13a86b539676b2.tar.gz edk2-4986bbaf1151d1cccc1f2589bd13a86b539676b2.tar.bz2 |
Ax88772: Add logic to separate packet, fix MTU issue. Ax88772b: Fix driver model unload function, fix SCT test failures.
Signed-off-by: Yu Pei <pei.yu@intel.com>
Reviewed-by: Ouyang Qian <qian.ouyang@intel.com>
Reviewed-by: Leahy, Leroy P <Leroy.P.Leahy@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14443 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772/Ax88772.c')
-rw-r--r-- | OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772/Ax88772.c | 102 |
1 files changed, 82 insertions, 20 deletions
diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772/Ax88772.c b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772/Ax88772.c index 746a509..dd18a95 100644 --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772/Ax88772.c +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772/Ax88772.c @@ -656,6 +656,78 @@ Ax88772Reset ( }
+VOID
+FillPkt2Queue (
+ IN NIC_DEVICE * pNicDevice,
+ IN UINTN BufLength)
+{
+
+ UINT16 * pLength;
+ UINT16 * pLengthBar;
+ UINT8* pData;
+ UINT32 offset;
+ RX_TX_PACKET * pRxPacket;
+ UINTN LengthInBytes;
+ EFI_STATUS Status;
+
+ for ( offset = 0; offset < BufLength; ){
+ pLength = (UINT16*) (pNicDevice->pBulkInBuff + offset);
+ pLengthBar = (UINT16*) (pNicDevice->pBulkInBuff + offset +2);
+
+ *pLength &= 0x7ff;
+ *pLengthBar &= 0x7ff;
+ *pLengthBar |= 0xf800;
+
+ if ((*pLength ^ *pLengthBar ) != 0xFFFF) {
+ DEBUG (( EFI_D_ERROR , "Pkt length error. BufLength = %d\n", BufLength));
+ return;
+ }
+
+ pRxPacket = pNicDevice->pRxFree;
+ LengthInBytes = sizeof ( *pRxPacket ) - sizeof ( pRxPacket->pNext );
+ if ( NULL == pRxPacket ) {
+ Status = gBS->AllocatePool ( EfiRuntimeServicesData,
+ sizeof( RX_TX_PACKET ),
+ (VOID **) &pRxPacket );
+ if ( !EFI_ERROR ( Status )) {
+ //
+ // Add this packet to the free packet list
+ //
+ pNicDevice->pRxFree = pRxPacket;
+ pRxPacket->pNext = NULL;
+ }
+ else {
+ //
+ // Use the discard packet buffer
+ //
+ //pRxPacket = &Packet;
+ }
+ }
+
+
+ pData = pNicDevice->pBulkInBuff + offset + 4;
+ pRxPacket->Length = *pLength;
+ pRxPacket->LengthBar = *(UINT16*) (pNicDevice->pBulkInBuff + offset +2);
+ CopyMem (&pRxPacket->Data[0], pData, *pLength);
+ //DEBUG((DEBUG_INFO, "Packet [%d]\n", *pLength));
+
+ pNicDevice->pRxFree = pRxPacket->pNext;
+ pRxPacket->pNext = NULL;
+
+ if ( NULL == pNicDevice->pRxTail ) {
+ pNicDevice->pRxHead = pRxPacket;
+ }
+ else {
+ pNicDevice->pRxTail->pNext = pRxPacket;
+ }
+ pNicDevice->pRxTail = pRxPacket;
+ offset += (*pLength + 4);
+
+ }
+}
+
+
+
/**
Receive a frame from the network.
@@ -760,10 +832,10 @@ Ax88772Rx ( // Locate a packet for use
//
pRxPacket = pNicDevice->pRxFree;
- LengthInBytes = sizeof ( *pRxPacket ) - sizeof ( pRxPacket->pNext );
+ LengthInBytes = MAX_BULKIN_SIZE;
if ( NULL == pRxPacket ) {
Status = gBS->AllocatePool ( EfiRuntimeServicesData,
- LengthInBytes,
+ sizeof ( *pRxPacket ),
(VOID **) &pRxPacket );
if ( !EFI_ERROR ( Status )) {
//
@@ -783,16 +855,22 @@ Ax88772Rx ( //
// Attempt to receive a packet
//
+ SetMem (&pNicDevice->pBulkInBuff[0], MAX_BULKIN_SIZE, 0);
pUsbIo = pNicDevice->pUsbIo;
Status = pUsbIo->UsbBulkTransfer ( pUsbIo,
USB_ENDPOINT_DIR_IN | BULK_IN_ENDPOINT,
- &pRxPacket->Length,
+ &pNicDevice->pBulkInBuff[0],
&LengthInBytes,
2,
&TransferStatus );
+ if ( LengthInBytes > 0 ) {
+ FillPkt2Queue(pNicDevice, LengthInBytes);
+ }
+ pRxPacket = pNicDevice->pRxHead;
if (( !EFI_ERROR ( Status ))
&& ( 0 < pRxPacket->Length )
- && ( pRxPacket->Length <= sizeof ( pRxPacket->Data ))) {
+ && ( pRxPacket->Length <= sizeof ( pRxPacket->Data ))
+ && ( LengthInBytes > 0)) {
//
// Determine if the packet should be received
@@ -869,22 +947,6 @@ Ax88772Rx ( LengthInBytes ));
}
- //
- // Remove this packet from the free packet list
- //
- pNicDevice->pRxFree = pRxPacket->pNext;
- pRxPacket->pNext = NULL;
-
- //
- // Append this packet to the receive list
- //
- if ( NULL == pNicDevice->pRxTail ) {
- pNicDevice->pRxHead = pRxPacket;
- }
- else {
- pNicDevice->pRxTail->pNext = pRxPacket;
- }
- pNicDevice->pRxTail = pRxPacket;
}
else {
//
|