comparison packages/devs/eth/cl/cs8900a/current/src/if_cs8900a.c @ 1659:e2264d5f9337

* src/if_cs8900a.c: Drop "ghost" frames with zero length
author jlarmour
date Thu, 27 May 2004 06:48:47 +0000
parents bf994e1a516c
children 67ee34ead3f4
comparison
equal deleted inserted replaced
1658:79f7073a7a00 1659:e2264d5f9337
531 // to prepare to unload the packet from the hardware. Once the length of 531 // to prepare to unload the packet from the hardware. Once the length of
532 // the packet is known, the upper layer of the driver can be told. When 532 // the packet is known, the upper layer of the driver can be told. When
533 // the upper layer is ready to unload the packet, the internal function 533 // the upper layer is ready to unload the packet, the internal function
534 // 'cs8900a_recv' will be called to actually fetch it from the hardware. 534 // 'cs8900a_recv' will be called to actually fetch it from the hardware.
535 static void 535 static void
536 cs8900a_RxEvent(struct eth_drv_sc *sc) 536 cs8900a_RxEvent(struct eth_drv_sc *sc, int stat)
537 { 537 {
538 cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private; 538 cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private;
539 cyg_addrword_t base = cpd->base; 539 cyg_addrword_t base = cpd->base;
540 cyg_uint16 stat, len; 540 cyg_uint16 len;
541 541
542 HAL_READ_UINT16(base+CS8900A_RTDATA, stat); 542 if(stat & PP_RxCFG_RxOK) {
543 HAL_READ_UINT16(base+CS8900A_RTDATA, len); 543 // Only start reading a message if one has been received
544 HAL_READ_UINT16(base+CS8900A_RTDATA, stat);
545 HAL_READ_UINT16(base+CS8900A_RTDATA, len);
544 546
545 #ifdef CYGIMP_DEVS_ETH_CL_CS8900A_DATABUS_BYTE_SWAPPED 547 #ifdef CYGIMP_DEVS_ETH_CL_CS8900A_DATABUS_BYTE_SWAPPED
546 len = CYG_SWAP16(len); 548 len = CYG_SWAP16(len);
547 #endif 549 #endif
550
551 CYG_ASSERT(len > 0, "Zero length ethernet frame received");
548 552
549 #ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG 553 #ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG
550 if (cyg_io_eth_net_debug) { 554 if (cyg_io_eth_net_debug) {
551 diag_printf("RxEvent - stat: %x, len: %d\n", stat, len); 555 diag_printf("RxEvent - stat: %x, len: %d\n", stat, len);
552 } 556 }
553 #endif 557 #endif
554 (sc->funs->eth_drv->recv)(sc, len); 558 (sc->funs->eth_drv->recv)(sc, len);
559 }
555 } 560 }
556 561
557 // This function is called as a result of the "eth_drv_recv()" call above. 562 // This function is called as a result of the "eth_drv_recv()" call above.
558 // It's job is to actually fetch data for a packet from the hardware once 563 // It's job is to actually fetch data for a packet from the hardware once
559 // memory buffers have been allocated for the packet. Note that the buffers 564 // memory buffers have been allocated for the packet. Note that the buffers
634 639
635 HAL_READ_UINT16(base+CS8900A_ISQ, event); 640 HAL_READ_UINT16(base+CS8900A_ISQ, event);
636 while (event != 0) { 641 while (event != 0) {
637 switch (event & ISQ_EventMask) { 642 switch (event & ISQ_EventMask) {
638 case ISQ_RxEvent: 643 case ISQ_RxEvent:
639 cs8900a_RxEvent(sc); 644 cs8900a_RxEvent(sc, event);
640 break; 645 break;
641 case ISQ_TxEvent: 646 case ISQ_TxEvent:
642 cs8900a_TxEvent(sc, event); 647 cs8900a_TxEvent(sc, event);
643 break; 648 break;
644 case ISQ_BufEvent: 649 case ISQ_BufEvent: