Skip to content

Commit a996ea2

Browse files
authored
Merge pull request #12057 from OpenNuvoton/nuvoton_emac_max_recv
NUC472/M487: Limit EMAC receive frame length as 1518
2 parents f270146 + 42103f0 commit a996ea2

File tree

6 files changed

+9
-4
lines changed

6 files changed

+9
-4
lines changed

features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ void numaker_eth_init(uint8_t *mac_addr)
262262
EMAC_CAMCTL_ABP_Msk;
263263
EMAC->CAMEN = 1; // Enable CAM entry 0
264264

265+
/* Limit the max receive frame length to 1514 + 4 */
266+
EMAC->MRFL = NU_ETH_MAX_FLEN;
265267
reset_phy();
266268

267269
EMAC_ENABLE_RX();

features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
#define RX_DESCRIPTOR_NUM NU_RX_RING_LEN//4 //2 // 4: Max Number of Rx Frame Descriptors
8686
#define TX_DESCRIPTOR_NUM NU_TX_RING_LEN//4 //2 // 4: Max number of Tx Frame Descriptors
8787

88-
#define PACKET_BUFFER_SIZE NU_ETH_MAX_FLEN//1520
88+
#define PACKET_BUFFER_SIZE ( NU_ETH_MAX_FLEN + ((NU_ETH_MAX_FLEN%4) ? (4 - (NU_ETH_MAX_FLEN%4)) : 0) ) //For DMA 4 bytes alignment
8989

9090
#define CONFIG_PHY_ADDR 1
9191

features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ void numaker_eth_init(uint8_t *mac_addr)
228228
init_rx_desc();
229229

230230
numaker_set_mac_addr(mac_addr); // need to reconfigure hardware address 'cos we just RESET emc...
231+
232+
/* Limit the max receive frame length to 1514 + 4 */
233+
EMAC->MRFL = NU_ETH_MAX_FLEN;
231234
reset_phy();
232235

233236
EMAC->CTL |= EMAC_CTL_STRIPCRC_Msk | EMAC_CTL_RXON_Msk | EMAC_CTL_TXON_Msk | EMAC_CTL_RMIIEN_Msk | EMAC_CTL_RMIIRXCTL_Msk;

features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
#define RX_DESCRIPTOR_NUM NU_RX_RING_LEN//4 //2 // 4: Max Number of Rx Frame Descriptors
8585
#define TX_DESCRIPTOR_NUM NU_TX_RING_LEN//4 //2 // 4: Max number of Tx Frame Descriptors
8686

87-
#define PACKET_BUFFER_SIZE NU_ETH_MAX_FLEN//1520
87+
#define PACKET_BUFFER_SIZE ( NU_ETH_MAX_FLEN + ((NU_ETH_MAX_FLEN%4) ? (4 - (NU_ETH_MAX_FLEN%4)) : 0) ) //For DMA 4 bytes alignment
8888

8989
#define CONFIG_PHY_ADDR 1
9090

features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#define NU_BUFF_ALIGNMENT 4
4343
#define PHY_LINKED_STATE 1
4444
#define PHY_UNLINKED_STATE 0
45-
#define PACKET_BUFFER_SIZE NU_ETH_MAX_FLEN
45+
#define PACKET_BUFFER_SIZE ( NU_ETH_MAX_FLEN + ((NU_ETH_MAX_FLEN%4) ? (4 - (NU_ETH_MAX_FLEN%4)) : 0) ) //For DMA 4 bytes alignment
4646

4747
extern "C" void numaker_eth_rx_next(void);
4848
/* \brief Flags for worker thread */

features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define NU_RX_RING_LEN (8)
2323
#define NU_TX_RING_LEN (4)
2424

25-
#define NU_ETH_MAX_FLEN (1520)
25+
#define NU_ETH_MAX_FLEN (1518)
2626

2727
#define NU_HWADDR_SIZE (6)
2828

0 commit comments

Comments
 (0)