diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c index 486b0fb770f..bb7efc789b7 100644 --- a/arch/arm/src/sam34/sam_emac.c +++ b/arch/arm/src/sam34/sam_emac.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/sam34/sam_emac.c * - * Copyright (C) 2014-2015, 2017-2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015, 2017-2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * This logic derives from the SAM34D3 Ethernet driver. @@ -292,10 +292,10 @@ struct sam_emac_s /* Debug stuff */ #ifdef CONFIG_SAM34_EMAC_REGDEBUG - bool wrlast; /* Last was a write */ - uintptr_t addrlast; /* Last address */ - uint32_t vallast; /* Last value */ - int ntimes; /* Number of times */ + bool wrlast; /* Last was a write */ + uintptr_t addrlast; /* Last address */ + uint32_t vallast; /* Last value */ + int ntimes; /* Number of times */ #endif }; @@ -1163,9 +1163,23 @@ static int sam_recvframe(struct sam_emac_s *priv) (uintptr_t)rxdesc + sizeof(struct emac_rxdesc_s)); } - /* No packet was found */ + /* isframe indicates that we have found a SOF. If we've received a SOF, + * but not an EOF in the sequential buffers we own, it must mean that we + * have a partial packet. This should only happen if there was a Buffer + * Not Available (BNA) error. When bursts of data come in, quickly + * filling the available buffers, before our interrupts can even service + * them. Eventually, the ring buffer loops back on itself and the + * peripheral sees it cannot write the next fragment of the packet. + * + * In this case, we keep the rxndx at the start of the last frame, since + * the peripheral will finish writing the packet there next. + */ + + if (!isframe) + { + priv->rxndx = rxndx; + } - priv->rxndx = rxndx; ninfo("rxndx: %d\n", priv->rxndx); return -EAGAIN; } diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c index 1555242e531..033bc69c379 100644 --- a/arch/arm/src/sama5/sam_emaca.c +++ b/arch/arm/src/sama5/sam_emaca.c @@ -4,7 +4,7 @@ * 10/100 Base-T Ethernet driver for the SAMA5D3. Denoted as 'A' to * distinguish it from the SAMA5D4 EMAC driver. * - * Copyright (C) 2013-2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -297,10 +297,10 @@ struct sam_emac_s /* Debug stuff */ #ifdef CONFIG_SAMA5_EMACA_REGDEBUG - bool wrlast; /* Last was a write */ - uintptr_t addrlast; /* Last address */ - uint32_t vallast; /* Last value */ - int ntimes; /* Number of times */ + bool wrlast; /* Last was a write */ + uintptr_t addrlast; /* Last address */ + uint32_t vallast; /* Last value */ + int ntimes; /* Number of times */ #endif }; @@ -1201,9 +1201,23 @@ static int sam_recvframe(struct sam_emac_s *priv) (uintptr_t)rxdesc + sizeof(struct emac_rxdesc_s)); } - /* No packet was found */ + /* isframe indicates that we have found a SOF. If we've received a SOF, + * but not an EOF in the sequential buffers we own, it must mean that we + * have a partial packet. This should only happen if there was a Buffer + * Not Available (BNA) error. When bursts of data come in, quickly + * filling the available buffers, before our interrupts can even service + * them. Eventually, the ring buffer loops back on itself and the + * peripheral sees it cannot write the next fragment of the packet. + * + * In this case, we keep the rxndx at the start of the last frame, since + * the peripheral will finish writing the packet there next. + */ + + if (!isframe) + { + priv->rxndx = rxndx; + } - priv->rxndx = rxndx; ninfo("rxndx: %d\n", priv->rxndx); return -EAGAIN; } diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c index e2fbaa8015e..1fda59cb126 100644 --- a/arch/arm/src/sama5/sam_emacb.c +++ b/arch/arm/src/sama5/sam_emacb.c @@ -8,7 +8,7 @@ * separate (mostly because the 'B' driver needs to support two EMAC blocks. * But the 'B' driver should replace the 'A' driver someday. * - * Copyright (C) 2014-2015, 2017-2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015, 2017-2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * This logic derives from the SAM4E Ethernet driver which, in turn, derived @@ -441,10 +441,10 @@ struct sam_emac_s /* Debug stuff */ #ifdef CONFIG_SAMA5_EMACB_REGDEBUG - bool wrlast; /* Last was a write */ - uintptr_t addrlast; /* Last address */ - uint32_t vallast; /* Last value */ - int ntimes; /* Number of times */ + bool wrlast; /* Last was a write */ + uintptr_t addrlast; /* Last address */ + uint32_t vallast; /* Last value */ + int ntimes; /* Number of times */ #endif }; @@ -1536,9 +1536,23 @@ static int sam_recvframe(struct sam_emac_s *priv) (uintptr_t)rxdesc + sizeof(struct emac_rxdesc_s)); } - /* No packet was found */ + /* isframe indicates that we have found a SOF. If we've received a SOF, + * but not an EOF in the sequential buffers we own, it must mean that we + * have a partial packet. This should only happen if there was a Buffer + * Not Available (BNA) error. When bursts of data come in, quickly + * filling the available buffers, before our interrupts can even service + * them. Eventually, the ring buffer loops back on itself and the + * peripheral sees it cannot write the next fragment of the packet. + * + * In this case, we keep the rxndx at the start of the last frame, since + * the peripheral will finish writing the packet there next. + */ + + if (!isframe) + { + priv->rxndx = rxndx; + } - priv->rxndx = rxndx; ninfo("rxndx: %d\n", priv->rxndx); return -EAGAIN; } diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c index 6b37ba686dd..9206e13eaf0 100644 --- a/arch/arm/src/sama5/sam_gmac.c +++ b/arch/arm/src/sama5/sam_gmac.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/sama5/sam_gmac.c * - * Copyright (C) 2013-2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -223,10 +223,10 @@ struct sam_gmac_s /* Debug stuff */ #ifdef CONFIG_SAMA5_GMAC_REGDEBUG - bool wrlast; /* Last was a write */ - uintptr_t addrlast; /* Last address */ - uint32_t vallast; /* Last value */ - int ntimes; /* Number of times */ + bool wrlast; /* Last was a write */ + uintptr_t addrlast; /* Last address */ + uint32_t vallast; /* Last value */ + int ntimes; /* Number of times */ #endif }; @@ -1131,9 +1131,23 @@ static int sam_recvframe(struct sam_gmac_s *priv) (uintptr_t)rxdesc + sizeof(struct gmac_rxdesc_s)); } - /* No packet was found */ + /* isframe indicates that we have found a SOF. If we've received a SOF, + * but not an EOF in the sequential buffers we own, it must mean that we + * have a partial packet. This should only happen if there was a Buffer + * Not Available (BNA) error. When bursts of data come in, quickly + * filling the available buffers, before our interrupts can even service + * them. Eventually, the ring buffer loops back on itself and the + * peripheral sees it cannot write the next fragment of the packet. + * + * In this case, we keep the rxndx at the start of the last frame, since + * the peripheral will finish writing the packet there next. + */ + + if (!isframe) + { + priv->rxndx = rxndx; + } - priv->rxndx = rxndx; ninfo("rxndx: %d\n", priv->rxndx); return -EAGAIN; } diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c index 3cad26a4932..1bc31289e0d 100644 --- a/arch/arm/src/samv7/sam_emac.c +++ b/arch/arm/src/samv7/sam_emac.c @@ -550,13 +550,13 @@ struct sam_emac_s struct sam_queue_s xfrq[EMAC_NQUEUES_MAX]; - /* Debug stuff */ + /* Debug stuff */ #ifdef CONFIG_SAMV7_EMAC_REGDEBUG - bool wrlast; /* Last was a write */ - uintptr_t addrlast; /* Last address */ - uint32_t vallast; /* Last value */ - int ntimes; /* Number of times */ + bool wrlast; /* Last was a write */ + uintptr_t addrlast; /* Last address */ + uint32_t vallast; /* Last value */ + int ntimes; /* Number of times */ #endif }; @@ -1873,16 +1873,16 @@ static int sam_recvframe(struct sam_emac_s *priv, int qid) (uintptr_t)rxdesc + sizeof(struct emac_rxdesc_s)); } - /* isframe indicates that we have found a SOF. If we've received a SOF, but not - * an EOF in the sequential buffers we own, it must mean that we have a partial - * packet. This should only happen if there was a Buffer Not Available (BNA) error. - * When bursts of data come in, quickly filling the available buffers, before our - * interrupts can even service them. Eventually, the ring buffer loops back on - * itself and the peripheral sees it cannot write the next fragment of the packet. - * - * In this case, we keep the rxndx at the start of the last frame, since the peripheral - * will finish writing the packet there next. + /* isframe indicates that we have found a SOF. If we've received a SOF, + * but not an EOF in the sequential buffers we own, it must mean that we + * have a partial packet. This should only happen if there was a Buffer + * Not Available (BNA) error. When bursts of data come in, quickly + * filling the available buffers, before our interrupts can even service + * them. Eventually, the ring buffer loops back on itself and the + * peripheral sees it cannot write the next fragment of the packet. * + * In this case, we keep the rxndx at the start of the last frame, since + * the peripheral will finish writing the packet there next. */ if (!isframe)