File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
src/esp8266/sdk_lwip/src/netif Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1299,6 +1299,12 @@ etharp_request(struct netif *netif, ip_addr_t *ipaddr)
1299
1299
}
1300
1300
#endif /* LWIP_ARP */
1301
1301
1302
+ struct wdevctl {
1303
+ uint16_t num_free_bufs ;
1304
+ };
1305
+
1306
+ extern struct wdevctl wDevCtrl ;
1307
+
1302
1308
/**
1303
1309
* Process received ethernet frames. Using this function instead of directly
1304
1310
* calling ip_input and passing ARP frames through etharp in ethernetif_input,
@@ -1373,11 +1379,27 @@ ethernet_input(struct pbuf *p, struct netif *netif)
1373
1379
LWIP_ASSERT ("Can't move over header in packet" , 0 );
1374
1380
goto free_and_return ;
1375
1381
} else {
1382
+ /*
1383
+ * SDK maintains a pool of 5 buffers. The number of free + 1
1384
+ * is the first field in the wDevCtrl struct. When it gets down to 1
1385
+ * the SDK prints "LmacRxBlk:1" and drops incoming packets.
1386
+ * If getting close to the limit, we start making copies to avoid pressure.
1387
+ */
1388
+ if (wDevCtrl .num_free_bufs <= 3 ) {
1389
+ struct pbuf * p2 = pbuf_alloc (PBUF_RAW , p -> tot_len , PBUF_RAM );
1390
+ if (p2 != NULL ) {
1391
+ pbuf_copy (p2 , p );
1392
+ pbuf_free (p );
1393
+ p = p2 ;
1394
+ } else {
1395
+ goto free_and_return ;
1396
+ }
1397
+ }
1376
1398
/* pass to IP layer */
1377
1399
ip_input (p , netif );
1378
1400
}
1379
1401
break ;
1380
-
1402
+
1381
1403
case PP_HTONS (ETHTYPE_ARP ):
1382
1404
if (!(netif -> flags & NETIF_FLAG_ETHARP )) {
1383
1405
goto free_and_return ;
You can’t perform that action at this time.
0 commit comments