arch/arm/src/sam34 and sama5: Port Anthony Merlino's fix of commit ee840c74da to similar Ethernet drivers for parts in other SAM families.

This commit is contained in:
Gregory Nutt
2019-02-02 16:14:43 -06:00
parent ee840c74da
commit d8943be51c
5 changed files with 98 additions and 42 deletions
+21 -7
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/sam34/sam_emac.c * 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 <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* This logic derives from the SAM34D3 Ethernet driver. * This logic derives from the SAM34D3 Ethernet driver.
@@ -292,10 +292,10 @@ struct sam_emac_s
/* Debug stuff */ /* Debug stuff */
#ifdef CONFIG_SAM34_EMAC_REGDEBUG #ifdef CONFIG_SAM34_EMAC_REGDEBUG
bool wrlast; /* Last was a write */ bool wrlast; /* Last was a write */
uintptr_t addrlast; /* Last address */ uintptr_t addrlast; /* Last address */
uint32_t vallast; /* Last value */ uint32_t vallast; /* Last value */
int ntimes; /* Number of times */ int ntimes; /* Number of times */
#endif #endif
}; };
@@ -1163,9 +1163,23 @@ static int sam_recvframe(struct sam_emac_s *priv)
(uintptr_t)rxdesc + sizeof(struct emac_rxdesc_s)); (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); ninfo("rxndx: %d\n", priv->rxndx);
return -EAGAIN; return -EAGAIN;
} }
+21 -7
View File
@@ -4,7 +4,7 @@
* 10/100 Base-T Ethernet driver for the SAMA5D3. Denoted as 'A' to * 10/100 Base-T Ethernet driver for the SAMA5D3. Denoted as 'A' to
* distinguish it from the SAMA5D4 EMAC driver. * 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 <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* References: * References:
@@ -297,10 +297,10 @@ struct sam_emac_s
/* Debug stuff */ /* Debug stuff */
#ifdef CONFIG_SAMA5_EMACA_REGDEBUG #ifdef CONFIG_SAMA5_EMACA_REGDEBUG
bool wrlast; /* Last was a write */ bool wrlast; /* Last was a write */
uintptr_t addrlast; /* Last address */ uintptr_t addrlast; /* Last address */
uint32_t vallast; /* Last value */ uint32_t vallast; /* Last value */
int ntimes; /* Number of times */ int ntimes; /* Number of times */
#endif #endif
}; };
@@ -1201,9 +1201,23 @@ static int sam_recvframe(struct sam_emac_s *priv)
(uintptr_t)rxdesc + sizeof(struct emac_rxdesc_s)); (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); ninfo("rxndx: %d\n", priv->rxndx);
return -EAGAIN; return -EAGAIN;
} }
+21 -7
View File
@@ -8,7 +8,7 @@
* separate (mostly because the 'B' driver needs to support two EMAC blocks. * separate (mostly because the 'B' driver needs to support two EMAC blocks.
* But the 'B' driver should replace the 'A' driver someday. * 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 <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* This logic derives from the SAM4E Ethernet driver which, in turn, derived * This logic derives from the SAM4E Ethernet driver which, in turn, derived
@@ -441,10 +441,10 @@ struct sam_emac_s
/* Debug stuff */ /* Debug stuff */
#ifdef CONFIG_SAMA5_EMACB_REGDEBUG #ifdef CONFIG_SAMA5_EMACB_REGDEBUG
bool wrlast; /* Last was a write */ bool wrlast; /* Last was a write */
uintptr_t addrlast; /* Last address */ uintptr_t addrlast; /* Last address */
uint32_t vallast; /* Last value */ uint32_t vallast; /* Last value */
int ntimes; /* Number of times */ int ntimes; /* Number of times */
#endif #endif
}; };
@@ -1536,9 +1536,23 @@ static int sam_recvframe(struct sam_emac_s *priv)
(uintptr_t)rxdesc + sizeof(struct emac_rxdesc_s)); (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); ninfo("rxndx: %d\n", priv->rxndx);
return -EAGAIN; return -EAGAIN;
} }
+21 -7
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/sama5/sam_gmac.c * 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 <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* References: * References:
@@ -223,10 +223,10 @@ struct sam_gmac_s
/* Debug stuff */ /* Debug stuff */
#ifdef CONFIG_SAMA5_GMAC_REGDEBUG #ifdef CONFIG_SAMA5_GMAC_REGDEBUG
bool wrlast; /* Last was a write */ bool wrlast; /* Last was a write */
uintptr_t addrlast; /* Last address */ uintptr_t addrlast; /* Last address */
uint32_t vallast; /* Last value */ uint32_t vallast; /* Last value */
int ntimes; /* Number of times */ int ntimes; /* Number of times */
#endif #endif
}; };
@@ -1131,9 +1131,23 @@ static int sam_recvframe(struct sam_gmac_s *priv)
(uintptr_t)rxdesc + sizeof(struct gmac_rxdesc_s)); (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); ninfo("rxndx: %d\n", priv->rxndx);
return -EAGAIN; return -EAGAIN;
} }
+14 -14
View File
@@ -550,13 +550,13 @@ struct sam_emac_s
struct sam_queue_s xfrq[EMAC_NQUEUES_MAX]; struct sam_queue_s xfrq[EMAC_NQUEUES_MAX];
/* Debug stuff */ /* Debug stuff */
#ifdef CONFIG_SAMV7_EMAC_REGDEBUG #ifdef CONFIG_SAMV7_EMAC_REGDEBUG
bool wrlast; /* Last was a write */ bool wrlast; /* Last was a write */
uintptr_t addrlast; /* Last address */ uintptr_t addrlast; /* Last address */
uint32_t vallast; /* Last value */ uint32_t vallast; /* Last value */
int ntimes; /* Number of times */ int ntimes; /* Number of times */
#endif #endif
}; };
@@ -1873,16 +1873,16 @@ static int sam_recvframe(struct sam_emac_s *priv, int qid)
(uintptr_t)rxdesc + sizeof(struct emac_rxdesc_s)); (uintptr_t)rxdesc + sizeof(struct emac_rxdesc_s));
} }
/* isframe indicates that we have found a SOF. If we've received a SOF, but not /* isframe indicates that we have found a SOF. If we've received a SOF,
* an EOF in the sequential buffers we own, it must mean that we have a partial * but not an EOF in the sequential buffers we own, it must mean that we
* packet. This should only happen if there was a Buffer Not Available (BNA) error. * have a partial packet. This should only happen if there was a Buffer
* When bursts of data come in, quickly filling the available buffers, before our * Not Available (BNA) error. When bursts of data come in, quickly
* interrupts can even service them. Eventually, the ring buffer loops back on * filling the available buffers, before our interrupts can even service
* itself and the peripheral sees it cannot write the next fragment of the packet. * 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.
* *
* 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) if (!isframe)