diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c index 5e4e348f6c0..a7a9bc21410 100644 --- a/arch/arm/src/sam34/sam_emac.c +++ b/arch/arm/src/sam34/sam_emac.c @@ -207,18 +207,7 @@ #endif -/* EMAC buffer sizes, number of buffers, and number of descriptors. - * - * REVISIT: The CONFIG_NET_MULTIBUFFER might be useful. It might be possible - * to use this option to send and receive messages directly into the DMA - * buffers, saving a copy. There might be complications on the receiving - * side, however, where buffers may wrap and where the size of the received - * frame will typically be smaller than a full packet. - */ - -#ifdef CONFIG_NET_MULTIBUFFER -# error CONFIG_NET_MULTIBUFFER must not be set -#endif +/* EMAC buffer sizes, number of buffers, and number of descriptors. *********/ #define EMAC_RX_UNITSIZE 128 /* Fixed size for RX buffer */ #define EMAC_TX_UNITSIZE CONFIG_NET_ETH_MTU /* MAX size for Ethernet packet */ @@ -312,6 +301,19 @@ struct sam_emac_s static struct sam_emac_s g_emac; +#ifdef CONFIG_NET_MULTIBUFFER +/* A single packet buffer is used + * + * REVISIT: It might be possible to use this option to send and receive + * messages directly into the DMA buffers, saving a copy. There might be + * complications on the receiving side, however, where buffers may wrap + * and where the size of the received frame will typically be smaller than + * a full packet. + */ + +static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE]; +#endif + #ifdef CONFIG_SAM34_EMAC_PREALLOCATE /* Preallocated data */ /* TX descriptors list */ @@ -3806,6 +3808,9 @@ void up_netinitialize(void) /* Initialize the driver structure */ memset(priv, 0, sizeof(struct sam_emac_s)); +#ifdef CONFIG_NET_MULTIBUFFER + priv->dev.d_buf = g_pktbuf; /* Single packet buffer */ +#endif priv->dev.d_ifup = sam_ifup; /* I/F up (new IP address) callback */ priv->dev.d_ifdown = sam_ifdown; /* I/F down callback */ priv->dev.d_txavail = sam_txavail; /* New TX data callback */ diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c index 3972f2324ac..672a3efc7fb 100644 --- a/arch/arm/src/sama5/sam_emaca.c +++ b/arch/arm/src/sama5/sam_emaca.c @@ -199,18 +199,7 @@ #endif -/* EMAC buffer sizes, number of buffers, and number of descriptors. - * - * REVISIT: The CONFIG_NET_MULTIBUFFER might be useful. It might be possible - * to use this option to send and receive messages directly into the DMA - * buffers, saving a copy. There might be complications on the receiving - * side, however, where buffers may wrap and where the size of the received - * frame will typically be smaller than a full packet. - */ - -#ifdef CONFIG_NET_MULTIBUFFER -# error CONFIG_NET_MULTIBUFFER must not be set -#endif +/* EMAC buffer sizes, number of buffers, and number of descriptors. *********/ #define EMAC_RX_UNITSIZE 128 /* Fixed size for RX buffer */ #define EMAC_TX_UNITSIZE CONFIG_NET_ETH_MTU /* MAX size for Ethernet packet */ @@ -301,6 +290,19 @@ struct sam_emac_s static struct sam_emac_s g_emac; +#ifdef CONFIG_NET_MULTIBUFFER +/* A single packet buffer is used + * + * REVISIT: It might be possible to use this option to send and receive + * messages directly into the DMA buffers, saving a copy. There might be + * complications on the receiving side, however, where buffers may wrap + * and where the size of the received frame will typically be smaller than + * a full packet. + */ + +static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE]; +#endif + #ifdef CONFIG_SAMA5_EMACA_PREALLOCATE /* Preallocated data */ /* TX descriptors list */ @@ -3484,6 +3486,9 @@ int sam_emac_initialize(void) /* Initialize the driver structure */ memset(priv, 0, sizeof(struct sam_emac_s)); +#ifdef CONFIG_NET_MULTIBUFFER + priv->dev.d_buf = g_pktbuf; /* Single packet buffer */ +#endif priv->dev.d_ifup = sam_ifup; /* I/F up (new IP address) callback */ priv->dev.d_ifdown = sam_ifdown; /* I/F down callback */ priv->dev.d_txavail = sam_txavail; /* New TX data callback */ diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c index 9b64fbc5ab9..ba118484e1f 100644 --- a/arch/arm/src/sama5/sam_emacb.c +++ b/arch/arm/src/sama5/sam_emacb.c @@ -305,18 +305,7 @@ # define sam_dumppacket(m,a,n) #endif -/* EMAC buffer sizes, number of buffers, and number of descriptors ********** - * - * REVISIT: The CONFIG_NET_MULTIBUFFER might be useful. It might be possible - * to use this option to send and receive messages directly into the DMA - * buffers, saving a copy. There might be complications on the receiving - * side, however, where buffers may wrap and where the size of the received - * frame will typically be smaller than a full packet. - */ - -#ifdef CONFIG_NET_MULTIBUFFER -# error CONFIG_NET_MULTIBUFFER must not be set -#endif +/* EMAC buffer sizes, number of buffers, and number of descriptors **********/ #define EMAC_RX_UNITSIZE 128 /* Fixed size for RX buffer */ #define EMAC_TX_UNITSIZE CONFIG_NET_ETH_MTU /* MAX size for Ethernet packet */ @@ -709,6 +698,21 @@ static const struct sam_emacattr_s g_emac0_attr = #endif }; +#ifdef CONFIG_NET_MULTIBUFFER +/* A single packet buffer is used + * + * REVISIT: It might be possible to use this option to send and receive + * messages directly into the DMA buffers, saving a copy. There might be + * complications on the receiving side, however, where buffers may wrap + * and where the size of the received frame will typically be smaller than + * a full packet. + */ + +static uint8_t g_pktbuf0[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE]; +#endif + +/* EMAC0 peripheral state */ + static struct sam_emac_s g_emac0; #endif @@ -777,6 +781,21 @@ static const struct sam_emacattr_s g_emac1_attr = #endif }; +#ifdef CONFIG_NET_MULTIBUFFER +/* A single packet buffer is used + * + * REVISIT: It might be possible to use this option to send and receive + * messages directly into the DMA buffers, saving a copy. There might be + * complications on the receiving side, however, where buffers may wrap + * and where the size of the received frame will typically be smaller than + * a full packet. + */ + +static uint8_t g_pktbuf1[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE]; +#endif + +/* EMAC1 peripheral state */ + static struct sam_emac_s g_emac1; #endif @@ -4515,6 +4534,9 @@ int sam_emac_initialize(int intf) { struct sam_emac_s *priv; const struct sam_emacattr_s *attr; +#ifdef CONFIG_NET_MULTIBUFFER + uint8_t *pktbuf; +#endif #if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) uint8_t phytype; #endif @@ -4526,6 +4548,10 @@ int sam_emac_initialize(int intf) priv = &g_emac0; attr = &g_emac0_attr; +#ifdef CONFIG_NET_MULTIBUFFER + pktbuf = g_pktbuf0; +#endif + #if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) phytype = SAMA5_EMAC0_PHY_TYPE; #endif @@ -4538,6 +4564,10 @@ int sam_emac_initialize(int intf) priv = &g_emac1; attr = &g_emac1_attr; +#ifdef CONFIG_NET_MULTIBUFFER + pktbuf = g_pktbuf1; +#endif + #if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) phytype = SAMA5_EMAC1_PHY_TYPE; #endif @@ -4553,6 +4583,9 @@ int sam_emac_initialize(int intf) memset(priv, 0, sizeof(struct sam_emac_s)); priv->attr = attr; /* Save the constant attributes */ +#ifdef CONFIG_NET_MULTIBUFFER + priv->dev.d_buf = pktbuf; /* Single packet buffer */ +#endif priv->dev.d_ifup = sam_ifup; /* I/F up (new IP address) callback */ priv->dev.d_ifdown = sam_ifdown; /* I/F down callback */ priv->dev.d_txavail = sam_txavail; /* New TX data callback */ diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c index 75a38365540..5442920ee03 100644 --- a/arch/arm/src/sama5/sam_gmac.c +++ b/arch/arm/src/sama5/sam_gmac.c @@ -118,18 +118,7 @@ # error Unknown PHY #endif -/* GMAC buffer sizes, number of buffers, and number of descriptors. - * - * REVISIT: The CONFIG_NET_MULTIBUFFER might be useful. It might be possible - * to use this option to send and receive messages directly into the DMA - * buffers, saving a copy. There might be complications on the receiving - * side, however, where buffers may wrap and where the size of the received - * frame will typically be smaller than a full packet. - */ - -#ifdef CONFIG_NET_MULTIBUFFER -# error CONFIG_NET_MULTIBUFFER must not be set -#endif +/* GMAC buffer sizes, number of buffers, and number of descriptors. *********/ #define GMAC_RX_UNITSIZE 128 /* Fixed size for RX buffer */ #define GMAC_TX_UNITSIZE CONFIG_NET_ETH_MTU /* MAX size for Ethernet packet */ @@ -227,6 +216,19 @@ struct sam_gmac_s static struct sam_gmac_s g_gmac; +#ifdef CONFIG_NET_MULTIBUFFER +/* A single packet buffer is used + * + * REVISIT: It might be possible to use this option to send and receive + * messages directly into the DMA buffers, saving a copy. There might be + * complications on the receiving side, however, where buffers may wrap + * and where the size of the received frame will typically be smaller than + * a full packet. + */ + +static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE]; +#endif + #ifdef CONFIG_SAMA5_GMAC_PREALLOCATE /* Preallocated data */ /* TX descriptors list */ @@ -3556,6 +3558,9 @@ int sam_gmac_initialize(void) /* Initialize the driver structure */ memset(priv, 0, sizeof(struct sam_gmac_s)); +#ifdef CONFIG_NET_MULTIBUFFER + priv->dev.d_buf = g_pktbuf; /* Single packet buffer */ +#endif priv->dev.d_ifup = sam_ifup; /* I/F up (new IP address) callback */ priv->dev.d_ifdown = sam_ifdown; /* I/F down callback */ priv->dev.d_txavail = sam_txavail; /* New TX data callback */ diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c index 7fcedd85716..c246140138d 100644 --- a/arch/arm/src/samv7/sam_emac.c +++ b/arch/arm/src/samv7/sam_emac.c @@ -317,18 +317,7 @@ # undef CONFIG_SAMV7_EMAC_REGDEBUG #endif -/* EMAC buffer sizes, number of buffers, and number of descriptors *********** - * - * REVISIT: The CONFIG_NET_MULTIBUFFER might be useful. It might be possible - * to use this option to send and receive messages directly into the DMA - * buffers, saving a copy. There might be complications on the receiving - * side, however, where buffers may wrap and where the size of the received - * frame will typically be smaller than a full packet. - */ - -#ifdef CONFIG_NET_MULTIBUFFER -# error CONFIG_NET_MULTIBUFFER must not be set -#endif +/* EMAC buffer sizes, number of buffers, and number of descriptors **********/ /* Queue identifiers/indices */ @@ -855,6 +844,21 @@ static const struct sam_emacattr_s g_emac0_attr = #endif }; +#ifdef CONFIG_NET_MULTIBUFFER +/* A single packet buffer is used + * + * REVISIT: It might be possible to use this option to send and receive + * messages directly into the DMA buffers, saving a copy. There might be + * complications on the receiving side, however, where buffers may wrap + * and where the size of the received frame will typically be smaller than + * a full packet. + */ + +static uint8_t g_pktbuf0[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE]; +#endif + +/* EMAC0 peripheral state */ + static struct sam_emac_s g_emac0; #endif @@ -923,6 +927,21 @@ static const struct sam_emacattr_s g_emac1_attr = #endif }; +#ifdef CONFIG_NET_MULTIBUFFER +/* A single packet buffer is used + * + * REVISIT: It might be possible to use this option to send and receive + * messages directly into the DMA buffers, saving a copy. There might be + * complications on the receiving side, however, where buffers may wrap + * and where the size of the received frame will typically be smaller than + * a full packet. + */ + +static uint8_t g_pktbuf1[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE]; +#endif + +/* EMAC1 peripheral state */ + static struct sam_emac_s g_emac1; #endif @@ -5081,6 +5100,9 @@ int sam_emac_initialize(int intf) { struct sam_emac_s *priv; const struct sam_emacattr_s *attr; +#ifdef CONFIG_NET_MULTIBUFFER + uint8_t *pktbuf; +#endif #if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) uint8_t phytype; #endif @@ -5092,6 +5114,10 @@ int sam_emac_initialize(int intf) priv = &g_emac0; attr = &g_emac0_attr; +#ifdef CONFIG_NET_MULTIBUFFER + pktbuf = g_pktbuf0; +#endif + #if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) phytype = SAMV7_EMAC0_PHY_TYPE; #endif @@ -5104,6 +5130,10 @@ int sam_emac_initialize(int intf) priv = &g_emac1; attr = &g_emac1_attr; +#ifdef CONFIG_NET_MULTIBUFFER + pktbuf = g_pktbuf1; +#endif + #if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) phytype = SAMV7_EMAC1_PHY_TYPE; #endif @@ -5119,6 +5149,9 @@ int sam_emac_initialize(int intf) memset(priv, 0, sizeof(struct sam_emac_s)); priv->attr = attr; /* Save the constant attributes */ +#ifdef CONFIG_NET_MULTIBUFFER + priv->dev.d_buf = pktbuf; /* Single packet buffer */ +#endif priv->dev.d_ifup = sam_ifup; /* I/F up (new IP address) callback */ priv->dev.d_ifdown = sam_ifdown; /* I/F down callback */ priv->dev.d_txavail = sam_txavail; /* New TX data callback */