diff --git a/cpu/sam0_common/periph/eth.c b/cpu/sam0_common/periph/eth.c index 7d1af599fe4fa..812505db2187c 100644 --- a/cpu/sam0_common/periph/eth.c +++ b/cpu/sam0_common/periph/eth.c @@ -246,7 +246,7 @@ int sam0_eth_send(const struct iolist *iolist) tx_curr->status |= DESC_TX_STATUS_WRAP; tx_idx = 0; } - __DSB(); + __DMB(); /* Start transmission */ GMAC->NCR.reg |= GMAC_NCR_TSTART; /* Set the next buffer */ @@ -258,6 +258,12 @@ int sam0_eth_send(const struct iolist *iolist) return len; } +unsigned _sam0_eth_get_last_len(void) +{ + unsigned idx = tx_idx ? tx_idx - 1 : ETH_TX_BUFFER_COUNT - 1; + return tx_desc[idx].status & DESC_TX_STATUS_LEN_MASK; +} + static int _try_receive(char* data, unsigned max_len, int block) { (void)block; @@ -386,7 +392,8 @@ int sam0_eth_init(void) GMAC->RSR.reg = GMAC_RSR_HNO | GMAC_RSR_RXOVR | GMAC_RSR_REC | GMAC_RSR_BNA; GMAC->TSR.reg = 0xFFFF; /* Enable needed interrupts */ - GMAC->IER.reg = GMAC_IER_RCOMP | GMAC_IER_TCOMP; + GMAC->IER.reg = GMAC_IER_RCOMP + | GMAC_IER_TCOMP | GMAC_IER_TFC | GMAC_IER_RLEX; GMAC->NCFGR.reg = GMAC_NCFGR_MTIHEN | GMAC_NCFGR_RXCOEN | GMAC_NCFGR_MAXFS | GMAC_NCFGR_CAF diff --git a/cpu/sam0_common/sam0_eth/eth-netdev.c b/cpu/sam0_common/sam0_eth/eth-netdev.c index 9571339233088..3b1ce6166a047 100644 --- a/cpu/sam0_common/sam0_eth/eth-netdev.c +++ b/cpu/sam0_common/sam0_eth/eth-netdev.c @@ -226,12 +226,13 @@ static int _sam0_eth_confirm_send(netdev_t *netdev, void *info) return -EBUSY; } - /* Transmit Frame Corruption, Collision Occurred, Transmit Underrun */ - if (tsr & (GMAC_TSR_TFC | GMAC_TSR_COL | GMAC_TSR_UND)) { + /* Transmit Frame Corruption, Collision Occurred */ + if (tsr & (GMAC_TSR_TFC | GMAC_TSR_COL)) { return -EIO; } - return 1; + extern unsigned _sam0_eth_get_last_len(void); + return _sam0_eth_get_last_len(); } static int _sam0_eth_get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)