This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Zero lenght ethernet frames on cs8900a
- From: Bob Koninckx <bob dot koninckx at o-3s dot com>
- To: ecos-patches at sources dot redhat dot com
- Date: Fri, 07 May 2004 23:39:34 +0200
- Subject: Zero lenght ethernet frames on cs8900a
- Organization: o-3s
- Reply-to: bob dot koninckx at o-3s dot com
Attached patch makes sure the cs8900a driver ignores spooky ethernet
frames which have not really been received.
Index: if_cs8900a.c
===================================================================
RCS file: /cvs/o3s/software/ecos/packages/devs/eth/cl/cs8900a/current/src/if_cs8900a.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -5 -r1.4 -r1.5
--- if_cs8900a.c 19 Apr 2004 08:08:14 -0000 1.4
+++ if_cs8900a.c 7 May 2004 21:10:45 -0000 1.5
@@ -531,29 +531,34 @@
// 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 @@
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: ChangeLog
===================================================================
RCS file: /cvs/o3s/software/ecos/packages/devs/eth/cl/cs8900a/current/ChangeLog,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -5 -r1.3 -r1.4
--- ChangeLog 19 Apr 2004 08:08:14 -0000 1.3
+++ ChangeLog 7 May 2004 21:10:45 -0000 1.4
@@ -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>