lab 3

Revision:
29:4380f0749039
Parent:
28:72f8b097fbf3
--- a/arch/TARGET_RZ_A1H/rza1_emac.c	Thu Aug 13 10:45:29 2015 +0100
+++ b/arch/TARGET_RZ_A1H/rza1_emac.c	Tue Nov 10 09:31:00 2015 +0000
@@ -24,33 +24,38 @@
     struct eth_hdr *ethhdr;
     u16_t          recv_size;
     struct pbuf    *p;
+    int            cnt;
 
     while (1) {
         sys_arch_sem_wait(&recv_ready_sem, 0);
-        recv_size = ethernet_receive();
-        if (recv_size != 0) {
-            p = pbuf_alloc(PBUF_RAW, recv_size, PBUF_RAM);
-            if (p != NULL) {
-                (void)ethernet_read((char *)p->payload, p->len);
-                ethhdr = p->payload;
-                switch (htons(ethhdr->type)) {
-                    case ETHTYPE_IP:
-                    case ETHTYPE_ARP:
+        for (cnt = 0; cnt < 16; cnt++) {
+            recv_size = ethernet_receive();
+            if (recv_size != 0) {
+                p = pbuf_alloc(PBUF_RAW, recv_size, PBUF_RAM);
+                if (p != NULL) {
+                    (void)ethernet_read((char *)p->payload, p->len);
+                    ethhdr = p->payload;
+                    switch (htons(ethhdr->type)) {
+                        case ETHTYPE_IP:
+                        case ETHTYPE_ARP:
 #if PPPOE_SUPPORT
-                    case ETHTYPE_PPPOEDISC:
-                    case ETHTYPE_PPPOE:
+                        case ETHTYPE_PPPOEDISC:
+                        case ETHTYPE_PPPOE:
 #endif /* PPPOE_SUPPORT */
-                        /* full packet send to tcpip_thread to process */
-                        if (netif->input(p, netif) != ERR_OK) {
-                            /* Free buffer */
+                            /* full packet send to tcpip_thread to process */
+                            if (netif->input(p, netif) != ERR_OK) {
+                                /* Free buffer */
+                                pbuf_free(p);
+                            }
+                            break;
+                        default:
+                            /* Return buffer */
                             pbuf_free(p);
-                        }
-                        break;
-                    default:
-                        /* Return buffer */
-                        pbuf_free(p);
-                        break;
+                            break;
+                    }
                 }
+            } else {
+                break;
             }
         }
     }