]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/Lan9118Dxe: Ignore spurious RXE errors
authorRonald Cron <Ronald.Cron@arm.com>
Thu, 16 Jul 2015 11:24:42 +0000 (11:24 +0000)
committeroliviermartin <oliviermartin@Edk2>
Thu, 16 Jul 2015 11:24:42 +0000 (11:24 +0000)
Spurious error might appear during network transaction,
ignore them when there are not relevant.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <Ronald.Cron@arm.com>
Reviewed-by: Olivier Martin <Olivier.Martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18028 6f19259b-4bc3-4df7-8a09-765794883524

EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.c

index 5b7eda65c3b07a1fe518aeaa4bda9d415e1fa3f2..4de520489930767525a48bbe794ef65cc005e383 100644 (file)
@@ -14,7 +14,6 @@
 \r
 #include "Lan9118Dxe.h"\r
 \r
-\r
 typedef struct {\r
   MAC_ADDR_DEVICE_PATH      Lan9118;\r
   EFI_DEVICE_PATH_PROTOCOL  End;\r
@@ -1312,6 +1311,7 @@ SnpReceive (
   )\r
 {\r
   LAN9118_DRIVER  *LanDriver;\r
+  UINT32          IntSts;\r
   UINT32          RxFifoStatus;\r
   UINT32          NumPackets;\r
   UINT32          RxCfgValue;\r
@@ -1346,6 +1346,27 @@ SnpReceive (
     return EFI_NOT_STARTED;\r
   }\r
 \r
+  //\r
+  // If the receiver raised the RXE error bit, check if the receiver status\r
+  // FIFO is full and if not just acknowledge the error. The two other\r
+  // conditions to get a RXE error are :\r
+  // . the RX data FIFO is read whereas being empty.\r
+  // . the RX status FIFO is read whereas being empty.\r
+  // The RX data and status FIFO are read by this driver only in the following\r
+  // code of this function. After the readings, the RXE error bit is checked\r
+  // and if raised, the controller is reset. Thus, at this point, we consider\r
+  // that the only valid reason to get an RXE error is the receiver status\r
+  // FIFO being full. And if this is not the case, we consider that this is\r
+  // a spurious error and we just get rid of it. We experienced such 'spurious'\r
+  // errors when running the driver on an A57 on Juno. No valid reason to\r
+  // explain those errors has been found so far and everything seems to\r
+  // work perfectly when they are just ignored.\r
+  //\r
+  IntSts = MmioRead32 (LAN9118_INT_STS);\r
+  if ((IntSts & INSTS_RXE) && (!(IntSts & INSTS_RSFF))) {\r
+    MmioWrite32 (LAN9118_INT_STS, INSTS_RXE);\r
+  }\r
+\r
   // Count dropped frames\r
   DroppedFrames = MmioRead32 (LAN9118_RX_DROP);\r
   LanDriver->Stats.RxDroppedFrames += DroppedFrames;\r
@@ -1453,6 +1474,33 @@ SnpReceive (
     RawData[Count] = MmioRead32 (LAN9118_RX_DATA);\r
   }\r
 \r
+  // Get the destination address\r
+  if (DstAddr != NULL) {\r
+    Dst.Addr[0] = (RawData[0] & 0xFF);\r
+    Dst.Addr[1] = (RawData[0] & 0xFF00) >> 8;\r
+    Dst.Addr[2] = (RawData[0] & 0xFF0000) >> 16;\r
+    Dst.Addr[3] = (RawData[0] & 0xFF000000) >> 24;\r
+    Dst.Addr[4] = (RawData[1] & 0xFF);\r
+    Dst.Addr[5] = (RawData[1] & 0xFF00) >> 8;\r
+    CopyMem (DstAddr, &Dst, NET_ETHER_ADDR_LEN);\r
+  }\r
+\r
+  // Get the source address\r
+  if (SrcAddr != NULL) {\r
+    Src.Addr[0] = (RawData[1] & 0xFF0000) >> 16;\r
+    Src.Addr[1] = (RawData[1] & 0xFF000000) >> 24;\r
+    Src.Addr[2] = (RawData[2] & 0xFF);\r
+    Src.Addr[3] = (RawData[2] & 0xFF00) >> 8;\r
+    Src.Addr[4] = (RawData[2] & 0xFF0000) >> 16;\r
+    Src.Addr[5] = (RawData[2] & 0xFF000000) >> 24;\r
+    CopyMem (SrcAddr, &Src, NET_ETHER_ADDR_LEN);\r
+  }\r
+\r
+  // Get the protocol\r
+  if (Protocol != NULL) {\r
+    *Protocol = NTOHS (RawData[3] & 0xFFFF);\r
+  }\r
+\r
   // Check for Rx errors (worst possible error)\r
   if (MmioRead32 (LAN9118_INT_STS) & INSTS_RXE) {\r
     DEBUG ((EFI_D_WARN, "Warning: Receiver Error. Restarting...\n"));\r
@@ -1481,33 +1529,6 @@ SnpReceive (
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  // Get the destination address\r
-  if (DstAddr != NULL) {\r
-    Dst.Addr[0] = (RawData[0] & 0xFF);\r
-    Dst.Addr[1] = (RawData[0] & 0xFF00) >> 8;\r
-    Dst.Addr[2] = (RawData[0] & 0xFF0000) >> 16;\r
-    Dst.Addr[3] = (RawData[0] & 0xFF000000) >> 24;\r
-    Dst.Addr[4] = (RawData[1] & 0xFF);\r
-    Dst.Addr[5] = (RawData[1] & 0xFF00) >> 8;\r
-    CopyMem (DstAddr, &Dst, NET_ETHER_ADDR_LEN);\r
-  }\r
-\r
-  // Get the source address\r
-  if (SrcAddr != NULL) {\r
-    Src.Addr[0] = (RawData[1] & 0xFF0000) >> 16;\r
-    Src.Addr[1] = (RawData[1] & 0xFF000000) >> 24;\r
-    Src.Addr[2] = (RawData[2] & 0xFF);\r
-    Src.Addr[3] = (RawData[2] & 0xFF00) >> 8;\r
-    Src.Addr[4] = (RawData[2] & 0xFF0000) >> 16;\r
-    Src.Addr[5] = (RawData[2] & 0xFF000000) >> 24;\r
-    CopyMem (SrcAddr,&Src, NET_ETHER_ADDR_LEN);\r
-  }\r
-\r
-  // Get the protocol\r
-  if (Protocol != NULL) {\r
-    *Protocol = NTOHS (RawData[3] & 0xFFFF);\r
-  }\r
-\r
 #if defined(EVAL_PERFORMANCE)\r
   UINT64 EndClock = GetPerformanceCounter ();\r
   DEBUG ((EFI_D_ERROR, "Receive Time processing: %d counts @ %d Hz\n", StartClock - EndClock,Perf));\r