This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Zero lenght ethernet frames on cs8900a


On Fri, 2004-05-07 at 15:39, Bob Koninckx wrote:
> Attached patch makes sure the cs8900a driver ignores spooky ethernet
> frames which have not really been received.

I'll commit this as soon as the CVS machine is back up, thanks.

Next time, please send patches relative to the "packages" directory
as in the attached version.  This makes it much simpler and safer
to apply.

-- 
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: devs/eth/cl/cs8900a/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/cl/cs8900a/current/ChangeLog,v
retrieving revision 1.9
diff -u -5 -p -r1.9 ChangeLog
--- devs/eth/cl/cs8900a/current/ChangeLog	21 Apr 2004 17:03:23 -0000	1.9
+++ devs/eth/cl/cs8900a/current/ChangeLog	8 May 2004 11:18:04 -0000
@@ -1,5 +1,8 @@
+2004-05-07  Bob Koninckx <bob.koninckx@o-3s.com>
+	* src/if_cs8900a.c: Drop "ghost" frames with zero length
+
 2004-04-19  Bob Koninckx <bob.koninckx@o-3s.com>
 	* src/if_cs8900a.c: function cs8900a_int_vector, return the vector
 	instead of a boolean.
 
 2004-04-08  Bob Koninckx <bob.koninckx@o-3s.com>
Index: devs/eth/cl/cs8900a/current/src/if_cs8900a.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/cl/cs8900a/current/src/if_cs8900a.c,v
retrieving revision 1.9
diff -u -5 -p -r1.9 if_cs8900a.c
--- devs/eth/cl/cs8900a/current/src/if_cs8900a.c	21 Apr 2004 17:03:24 -0000	1.9
+++ devs/eth/cl/cs8900a/current/src/if_cs8900a.c	8 May 2004 11:18:13 -0000
@@ -531,29 +531,34 @@ cs8900a_send(struct eth_drv_sc *sc, stru
 // to prepare to unload the packet from the hardware.  Once the length of
 // the packet is known, the upper layer of the driver can be told.  When
 // the upper layer is ready to unload the packet, the internal function
 // 'cs8900a_recv' will be called to actually fetch it from the hardware.
 static void
-cs8900a_RxEvent(struct eth_drv_sc *sc)
+cs8900a_RxEvent(struct eth_drv_sc *sc, int stat)
 {
     cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private;
     cyg_addrword_t base = cpd->base;
-    cyg_uint16 stat, len;
+    cyg_uint16 len;
 
-    HAL_READ_UINT16(base+CS8900A_RTDATA, stat);
-    HAL_READ_UINT16(base+CS8900A_RTDATA, len);
+    if(stat & PP_RxCFG_RxOK) {
+        // Only start reading a message if one has been received
+        HAL_READ_UINT16(base+CS8900A_RTDATA, stat);
+        HAL_READ_UINT16(base+CS8900A_RTDATA, len);
 
 #ifdef CYGIMP_DEVS_ETH_CL_CS8900A_DATABUS_BYTE_SWAPPED
-    len = CYG_SWAP16(len);
+        len = CYG_SWAP16(len);
 #endif
+
+        CYG_ASSERT(len > 0, "Zero length ethernet frame received");
         
 #ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG
-    if (cyg_io_eth_net_debug) {
-        diag_printf("RxEvent - stat: %x, len: %d\n", stat, len);
-    }
+        if (cyg_io_eth_net_debug) {
+            diag_printf("RxEvent - stat: %x, len: %d\n", stat, len);
+        }
 #endif
-    (sc->funs->eth_drv->recv)(sc, len);
+        (sc->funs->eth_drv->recv)(sc, len);
+    }
 }
 
 // This function is called as a result of the "eth_drv_recv()" call above.
 // It's job is to actually fetch data for a packet from the hardware once
 // memory buffers have been allocated for the packet.  Note that the buffers
@@ -634,11 +639,11 @@ cs8900a_poll(struct eth_drv_sc *sc)
 
     HAL_READ_UINT16(base+CS8900A_ISQ, event);
     while (event != 0) {
         switch (event & ISQ_EventMask) {
         case ISQ_RxEvent:
-            cs8900a_RxEvent(sc);
+            cs8900a_RxEvent(sc, event);
             break;
         case ISQ_TxEvent:
             cs8900a_TxEvent(sc, event);
             break;
         case ISQ_BufEvent:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]