summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-15 09:31:23 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-15 09:31:23 -0600
commit80c7601e254be30121a1b0922f70827d42ce262f (patch)
treeb9d7db8538c9721c05ee612bfac32b2340bdbf80
parente466893e7f9302c1dfa0a6662320aba2f86ae0ef (diff)
downloadpx4-nuttx-80c7601e254be30121a1b0922f70827d42ce262f.tar.gz
px4-nuttx-80c7601e254be30121a1b0922f70827d42ce262f.tar.bz2
px4-nuttx-80c7601e254be30121a1b0922f70827d42ce262f.zip
Networking: All Ethernet drivers: Call ipv6_input if IPv6 is enabled and an IPv6 packet is received
-rw-r--r--nuttx/arch/arm/src/c5471/c5471_ethernet.c63
-rw-r--r--nuttx/arch/arm/src/kinetis/kinetis_enet.c58
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c64
-rw-r--r--nuttx/arch/arm/src/sam34/sam_emac.c62
-rw-r--r--nuttx/arch/arm/src/sama5/sam_emaca.c58
-rw-r--r--nuttx/arch/arm/src/sama5/sam_emacb.c62
-rw-r--r--nuttx/arch/arm/src/sama5/sam_gmac.c62
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_eth.c62
-rw-r--r--nuttx/arch/arm/src/tiva/lm3s_ethernet.c66
-rw-r--r--nuttx/arch/arm/src/tiva/tm4c_ethernet.c62
-rw-r--r--nuttx/arch/hc/src/m9s12/m9s12_ethernet.c64
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c66
-rw-r--r--nuttx/arch/sim/src/up_netdriver.c63
-rw-r--r--nuttx/arch/z80/src/ez80/ez80_emac.c81
14 files changed, 766 insertions, 127 deletions
diff --git a/nuttx/arch/arm/src/c5471/c5471_ethernet.c b/nuttx/arch/arm/src/c5471/c5471_ethernet.c
index eab048188..f52856662 100644
--- a/nuttx/arch/arm/src/c5471/c5471_ethernet.c
+++ b/nuttx/arch/arm/src/c5471/c5471_ethernet.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/c5471/c5471_ethernet.c
*
- * Copyright (C) 2007, 2009-2010, 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009-2010, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Based one a C5471 Linux driver and released under this BSD license with
@@ -1232,12 +1232,15 @@ static void c5471_receive(struct c5471_driver_s *c5471)
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
+#ifdef CONFIG_NET_IPv4
if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
{
+ nllvdbg("IPv4 frame\n");
+
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
+
arp_ipin(dev);
ipv4_input(dev);
@@ -1250,10 +1253,56 @@ static void c5471_receive(struct c5471_driver_s *c5471)
if (dev->d_len > 0 &&
(EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
{
- arp_out(dev);
- c5471_transmit(c5471);
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(dev);
+ }
+
+ /* And send the packet */
+
+ c5471_transmit(c5471);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ * Send that data now if ESM has let go of the RX descriptor giving us
+ * access rights to submit another Ethernet frame.
+ */
+
+ if (dev->d_len > 0 &&
+ (EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
+ {
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ c5471_transmit(c5471);
}
}
+ else
+#endif
#ifdef CONFIG_NET_ARP
else if (BUF->type == HTONS(ETHTYPE_ARP))
{
diff --git a/nuttx/arch/arm/src/kinetis/kinetis_enet.c b/nuttx/arch/arm/src/kinetis/kinetis_enet.c
index de015e707..9b365c311 100644
--- a/nuttx/arch/arm/src/kinetis/kinetis_enet.c
+++ b/nuttx/arch/arm/src/kinetis/kinetis_enet.c
@@ -516,12 +516,15 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv)
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
+#ifdef CONFIG_NET_IPv4
if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
{
+ nllvdbg("IPv4 frame\n");
+
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
+
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@@ -531,12 +534,55 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv)
if (priv->dev.d_len > 0)
{
- arp_out(&priv->dev);
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->dev);
+ }
+
+ /* And send the packet */
+
kinetis_transmit(priv);
}
}
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(&priv->dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (priv->dev.d_len > 0)
+ {
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ kinetis_transmit(priv);
+ }
+ }
+ else
+#endif
#ifdef CONFIG_NET_ARP
- else if (BUF->type == htons(ETHTYPE_ARP))
+ if (BUF->type == htons(ETHTYPE_ARP))
{
arp_arpin(&priv->dev);
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c b/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c
index 07717977c..3b4ac7d5d 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c
@@ -230,7 +230,12 @@ struct lpc17_statistics_s
uint32_t rx_ovrerrors; /* Number of Rx overrun error interrupts */
uint32_t rx_errors; /* Number of Rx error interrupts (OR of other errors) */
uint32_t rx_packets; /* Number of packets received (sum of the following): */
- uint32_t rx_ip; /* Number of Rx IP packets received */
+#ifdef CONFIG_NET_IPv4
+ uint32_t rx_ip; /* Number of Rx IPv4 packets received */
+#endif
+#ifdef CONFIG_NET_IPv6
+ uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */
+#endif
uint32_t rx_arp; /* Number of Rx ARP packets received */
uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */
uint32_t rx_pkterr; /* Number of dropped, error in Rx descriptor */
@@ -869,13 +874,14 @@ static void lpc17_rxdone(struct lpc17_driver_s *priv)
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
+#ifdef CONFIG_NET_IPv4
if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
{
- /* Handle the incoming Rx packet */
+ nllvdbg("IPv4 frame\n");
+
+ /* Handle ARP on input then give the IPv4 packet to the
+ * network layer
+ */
EMAC_STAT(priv, rx_ip);
arp_ipin(&priv->lp_dev);
@@ -888,11 +894,55 @@ static void lpc17_rxdone(struct lpc17_driver_s *priv)
if (priv->lp_dev.d_len > 0)
{
- arp_out(&priv->lp_dev);
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->lp_dev);
+ }
+
+ /* And send the packet */
+
lpc17_response(priv);
}
}
else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ EMAC_STAT(priv, rx_ipv6);
+ ipv6_input(&priv->lp_dev);
+
+ /* If the above function invocation resulted in data that
+ * should be sent out on the network, the field d_len will
+ * set to a value > 0.
+ */
+
+ if (priv->lp_dev.d_len > 0)
+ {
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->lp_dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ lpc17_response(priv);
+ }
+ }
+ else
+#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{
diff --git a/nuttx/arch/arm/src/sam34/sam_emac.c b/nuttx/arch/arm/src/sam34/sam_emac.c
index f43819c99..85676a9ef 100644
--- a/nuttx/arch/arm/src/sam34/sam_emac.c
+++ b/nuttx/arch/arm/src/sam34/sam_emac.c
@@ -1137,18 +1137,18 @@ static void sam_receive(struct sam_emac_s *priv)
{
nlldbg("DROPPED: Too big: %d\n", dev->d_len);
}
+ else
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- else if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
- else if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
+#ifdef CONFIG_NET_IPv4
+ if (BUF->type == HTONS(ETHTYPE_IP))
{
- nllvdbg("IP frame\n");
+ nllvdbg("IPv4 frame\n");
- /* Handle ARP on input then give the IP packet to uIP */
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@@ -1158,12 +1158,54 @@ static void sam_receive(struct sam_emac_s *priv)
*/
if (priv->dev.d_len > 0)
+ {
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->dev);
+ }
+
+ /* And send the packet */
+
+ sam_transmit(priv);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(&priv->dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (priv->dev.d_len > 0)
{
- arp_out(&priv->dev);
- sam_transmit(priv);
- }
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ sam_transmit(priv);
+ }
}
else
+#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{
diff --git a/nuttx/arch/arm/src/sama5/sam_emaca.c b/nuttx/arch/arm/src/sama5/sam_emaca.c
index a1a9c7bba..00e324482 100644
--- a/nuttx/arch/arm/src/sama5/sam_emaca.c
+++ b/nuttx/arch/arm/src/sama5/sam_emaca.c
@@ -1177,18 +1177,18 @@ static void sam_receive(struct sam_emac_s *priv)
{
nlldbg("DROPPED: Too big: %d\n", dev->d_len);
}
+ else
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- else if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
- else if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
+#ifdef CONFIG_NET_IPv4
+ if (BUF->type == HTONS(ETHTYPE_IP))
{
- nllvdbg("IP frame\n");
+ nllvdbg("IPv4 frame\n");
- /* Handle ARP on input then give the IP packet to uIP */
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@@ -1198,12 +1198,54 @@ static void sam_receive(struct sam_emac_s *priv)
*/
if (priv->dev.d_len > 0)
+ {
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->dev);
+ }
+
+ /* And send the packet */
+
+ sam_transmit(priv);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(&priv->dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (priv->dev.d_len > 0)
{
- arp_out(&priv->dev);
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->dev);
+ }
+#endif
+
+ /* And send the packet */
+
sam_transmit(priv);
}
}
else
+#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{
diff --git a/nuttx/arch/arm/src/sama5/sam_emacb.c b/nuttx/arch/arm/src/sama5/sam_emacb.c
index 922b88bf8..98af0f834 100644
--- a/nuttx/arch/arm/src/sama5/sam_emacb.c
+++ b/nuttx/arch/arm/src/sama5/sam_emacb.c
@@ -1503,18 +1503,18 @@ static void sam_receive(struct sam_emac_s *priv)
{
nlldbg("DROPPED: Too big: %d\n", dev->d_len);
}
+ else
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- else if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
- else if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
+#ifdef CONFIG_NET_IPv4
+ if (BUF->type == HTONS(ETHTYPE_IP))
{
- nllvdbg("IP frame\n");
+ nllvdbg("IPv4 frame\n");
- /* Handle ARP on input then give the IP packet to uIP */
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@@ -1524,12 +1524,54 @@ static void sam_receive(struct sam_emac_s *priv)
*/
if (priv->dev.d_len > 0)
+ {
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->dev);
+ }
+
+ /* And send the packet */
+
+ sam_transmit(priv);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(&priv->dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (priv->dev.d_len > 0)
{
- arp_out(&priv->dev);
- sam_transmit(priv);
- }
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ sam_transmit(priv);
+ }
}
else
+#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{
diff --git a/nuttx/arch/arm/src/sama5/sam_gmac.c b/nuttx/arch/arm/src/sama5/sam_gmac.c
index 69a1a62ab..ba5789324 100644
--- a/nuttx/arch/arm/src/sama5/sam_gmac.c
+++ b/nuttx/arch/arm/src/sama5/sam_gmac.c
@@ -1107,18 +1107,18 @@ static void sam_receive(struct sam_gmac_s *priv)
{
nlldbg("DROPPED: Too big: %d\n", dev->d_len);
}
+ else
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- else if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
- else if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
+#ifdef CONFIG_NET_IPv4
+ if (BUF->type == HTONS(ETHTYPE_IP))
{
- nllvdbg("IP frame\n");
+ nllvdbg("IPv4 frame\n");
- /* Handle ARP on input then give the IP packet to uIP */
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@@ -1128,12 +1128,54 @@ static void sam_receive(struct sam_gmac_s *priv)
*/
if (priv->dev.d_len > 0)
+ {
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->dev);
+ }
+
+ /* And send the packet */
+
+ sam_transmit(priv);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(&priv->dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (priv->dev.d_len > 0)
{
- arp_out(&priv->dev);
- sam_transmit(priv);
- }
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ sam_transmit(priv);
+ }
}
else
+#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{
diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c
index 4fbd1c4ab..d78719e6c 100644
--- a/nuttx/arch/arm/src/stm32/stm32_eth.c
+++ b/nuttx/arch/arm/src/stm32/stm32_eth.c
@@ -1613,18 +1613,18 @@ static void stm32_receive(FAR struct stm32_ethmac_s *priv)
{
nlldbg("DROPPED: Too big: %d\n", dev->d_len);
}
+ else
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- else if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
- else if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
+#ifdef CONFIG_NET_IPv4
+ if (BUF->type == HTONS(ETHTYPE_IP))
{
- nllvdbg("IP frame\n");
+ nllvdbg("IPv4 frame\n");
- /* Handle ARP on input then give the IP packet to uIP */
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@@ -1634,12 +1634,54 @@ static void stm32_receive(FAR struct stm32_ethmac_s *priv)
*/
if (priv->dev.d_len > 0)
+ {
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->dev);
+ }
+
+ /* And send the packet */
+
+ stm32_transmit(priv);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(&priv->dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (priv->dev.d_len > 0)
{
- arp_out(&priv->dev);
- stm32_transmit(priv);
- }
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ stm32_transmit(priv);
+ }
}
else
+#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{
diff --git a/nuttx/arch/arm/src/tiva/lm3s_ethernet.c b/nuttx/arch/arm/src/tiva/lm3s_ethernet.c
index 059d1c34c..5c1e70104 100644
--- a/nuttx/arch/arm/src/tiva/lm3s_ethernet.c
+++ b/nuttx/arch/arm/src/tiva/lm3s_ethernet.c
@@ -172,7 +172,12 @@ struct tiva_statistics_s
{
uint32_t rx_int; /* Number of Rx interrupts received */
uint32_t rx_packets; /* Number of packets received (sum of the following): */
- uint32_t rx_ip; /* Number of Rx IP packets received */
+#ifdef CONFIG_NET_IPv4
+ uint32_t rx_ip; /* Number of Rx IPv4 packets received */
+#endif
+#ifdef CONFIG_NET_IPv6
+ uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */
+#endif
uint32_t rx_arp; /* Number of Rx ARP packets received */
uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */
uint32_t rx_pktsize; /* Number of dropped, too small or too big */
@@ -763,15 +768,16 @@ static void tiva_receive(struct tiva_driver_s *priv)
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- if (ETHBUF->type == HTONS(ETHTYPE_IP6))
-#else
+#ifdef CONFIG_NET_IPv4
if (ETHBUF->type == HTONS(ETHTYPE_IP))
-#endif
{
- nllvdbg("IP packet received (%02x)\n", ETHBUF->type);
- EMAC_STAT(priv, rx_ip);
+ nllvdbg("IPv4 frame\n");
+
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
+ EMAC_STAT(priv, rx_ip);
arp_ipin(&priv->ld_dev);
ipv4_input(&priv->ld_dev);
@@ -781,11 +787,55 @@ static void tiva_receive(struct tiva_driver_s *priv)
if (priv->ld_dev.d_len > 0)
{
- arp_out(&priv->ld_dev);
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (ETHBUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->ld_dev);
+ }
+
+ /* And send the packet */
+
tiva_transmit(priv);
}
}
else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (ETHBUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ EMAC_STAT(priv, rx_ipv6);
+ arp_ipin(&priv->ld_dev);
+ ipv6_input(&priv->ld_dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (priv->dev.d_len > 0)
+ {
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (ETHBUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->ld_dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ tiva_transmit(priv);
+ }
+ }
+ else
+#endif
#ifdef CONFIG_NET_ARP
if (ETHBUF->type == htons(ETHTYPE_ARP))
{
diff --git a/nuttx/arch/arm/src/tiva/tm4c_ethernet.c b/nuttx/arch/arm/src/tiva/tm4c_ethernet.c
index 10116b0c7..992f0bffc 100644
--- a/nuttx/arch/arm/src/tiva/tm4c_ethernet.c
+++ b/nuttx/arch/arm/src/tiva/tm4c_ethernet.c
@@ -1680,18 +1680,18 @@ static void tiva_receive(FAR struct tiva_ethmac_s *priv)
{
nlldbg("DROPPED: Too big: %d\n", dev->d_len);
}
+ else
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- else if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
- else if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
+#ifdef CONFIG_NET_IPv4
+ if (BUF->type == HTONS(ETHTYPE_IP))
{
- nvdbg("IP frame\n");
+ nllvdbg("IPv4 frame\n");
- /* Handle ARP on input then give the IP packet to uIP */
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@@ -1701,12 +1701,54 @@ static void tiva_receive(FAR struct tiva_ethmac_s *priv)
*/
if (priv->dev.d_len > 0)
+ {
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->dev);
+ }
+
+ /* And send the packet */
+
+ tiva_transmit(priv);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(&priv->dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (priv->dev.d_len > 0)
{
- arp_out(&priv->dev);
- tiva_transmit(priv);
- }
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ tiva_transmit(priv);
+ }
}
else
+#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{
diff --git a/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c b/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c
index b0dd07106..efa408c8b 100644
--- a/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c
+++ b/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c
@@ -1,7 +1,7 @@
/****************************************************************************
* drivers/net/m9s12_ethernet.c
*
- * Copyright (C) 2011, 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -258,12 +258,15 @@ static void emac_receive(FAR struct emac_driver_s *priv)
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
+#ifdef CONFIG_NET_IPv4
if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
{
+ nllvdbg("IPv4 frame\n");
+
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
+
arp_ipin(&priv->d_dev);
ipv4_input(&priv->d_dev);
@@ -272,13 +275,56 @@ static void emac_receive(FAR struct emac_driver_s *priv)
*/
if (priv->d_dev.d_len > 0)
+ {
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->d_dev);
+ }
+
+ /* And send the packet */
+
+ emac_transmit(priv);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(&priv->d_dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (priv->d_dev.d_len > 0)
{
- arp_out(&priv->d_dev);
- emac_transmit(priv);
- }
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->d_dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ emac_transmit(priv);
+ }
}
+ else
+#endif
#ifdef CONFIG_NET_ARP
- else if (BUF->type == htons(ETHTYPE_ARP))
+ if (BUF->type == htons(ETHTYPE_ARP))
{
arp_arpin(&priv->d_dev);
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c b/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c
index 7e66facea..d704814d6 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/pic32mx/pic32mx_ethernet.c
*
- * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* This driver derives from the PIC32MX Ethernet Driver
@@ -297,7 +297,12 @@ struct pic32mx_statistics_s
uint32_t rx_bufna; /* Number of Rx buffer not available errors */
uint32_t rx_buse; /* Number of Rx BVCI bus errors */
uint32_t rx_packets; /* Number of packets received (sum of the following): */
- uint32_t rx_ip; /* Number of Rx IP packets received */
+#ifdef CONFIG_NET_IPv4
+ uint32_t rx_ip; /* Number of Rx IPv4 packets received */
+#endif
+#ifdef CONFIG_NET_IPv6
+ uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */
+#endif
uint32_t rx_arp; /* Number of Rx ARP packets received */
uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */
uint32_t rx_pkterr; /* Number of dropped, error in Rx descriptor */
@@ -1426,13 +1431,14 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv)
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
+#ifdef CONFIG_NET_IPv4
if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
{
- /* Handle the incoming IP packet */
+ nllvdbg("IPv4 frame\n");
+
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
EMAC_STAT(priv, rx_ip);
arp_ipin(&priv->pd_dev);
@@ -1445,11 +1451,55 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv)
if (priv->pd_dev.d_len > 0)
{
- arp_out(&priv->pd_dev);
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->pd_dev);
+ }
+
+ /* And send the packet */
+
+ pic32mx_response(priv);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ EMAC_STAT(priv, rx_ipv6);
+ ipv6_input(&priv->pd_dev);
+
+ /* If the above function invocation resulted in data that
+ * should be sent out on the network, the field d_len will
+ * set to a value > 0.
+ */
+
+ if (priv->pd_dev.d_len > 0)
+ {
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->pd_dev);
+ }
+#endif
+
+ /* And send the packet */
+
pic32mx_response(priv);
}
}
else
+#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{
diff --git a/nuttx/arch/sim/src/up_netdriver.c b/nuttx/arch/sim/src/up_netdriver.c
index 78431a37d..eec433ac2 100644
--- a/nuttx/arch/sim/src/up_netdriver.c
+++ b/nuttx/arch/sim/src/up_netdriver.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/sim/src/up_netdriver.c
*
- * Copyright (C) 2007, 2009-2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009-2012, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Based on code from uIP which also has a BSD-like license:
@@ -159,12 +159,15 @@ void netdriver_loop(void)
{
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- if (BUF->ether_type == htons(ETHTYPE_IP6))
-#else
- if (BUF->ether_type == htons(ETHTYPE_IP))
-#endif
+#ifdef CONFIG_NET_IPv4
+ if (BUF->type == HTONS(ETHTYPE_IP))
{
+ nllvdbg("IPv4 frame\n");
+
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
+
arp_ipin(&g_sim_dev);
ipv4_input(&g_sim_dev);
@@ -175,12 +178,56 @@ void netdriver_loop(void)
if (g_sim_dev.d_len > 0)
{
- arp_out(&g_sim_dev);
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&g_sim_dev);
+ }
+
+ /* And send the packet */
+
+ netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(&g_sim_dev);
+
+ /* If the above function invocation resulted in data that
+ * should be sent out on the network, the global variable
+ * d_len is set to a value > 0.
+ */
+
+ if (g_sim_dev.d_len > 0)
+ {
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&g_sim_dev);
+ }
+#endif
+
+ /* And send the packet */
+
netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
}
}
+ else
+#endif
#ifdef CONFIG_NET_ARP
- else if (BUF->ether_type == htons(ETHTYPE_ARP))
+ if (BUF->ether_type == htons(ETHTYPE_ARP))
{
arp_arpin(&g_sim_dev);
diff --git a/nuttx/arch/z80/src/ez80/ez80_emac.c b/nuttx/arch/z80/src/ez80/ez80_emac.c
index 845d431fd..2a65638ec 100644
--- a/nuttx/arch/z80/src/ez80/ez80_emac.c
+++ b/nuttx/arch/z80/src/ez80/ez80_emac.c
@@ -1,7 +1,7 @@
/****************************************************************************
* drivers/net/ez80_emac.c
*
- * Copyright (C) 2009-2010, 2012, 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010, 2012, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@@ -246,18 +246,23 @@ struct ez80mac_statistics_s
{
uint32_t rx_int; /* Number of Rx interrupts received */
uint32_t rx_packets; /* Number of packets received (sum of the following): */
- uint32_t rx_ip; /* Number of Rx IP packets received */
- uint32_t rx_arp; /* Number of Rx ARP packets received */
- uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */
- uint32_t rx_nok; /* Number of Rx packets received without OK bit */
+#ifdef CONFIG_NET_IPv4
+ uint32_t rx_ip; /* Number of Rx IPv4 packets received */
+#endif
+#ifdef CONFIG_NET_IPv6
+ uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */
+#endif
+ uint32_t rx_arp; /* Number of Rx ARP packets received */
+ uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */
+ uint32_t rx_nok; /* Number of Rx packets received without OK bit */
uint32_t rx_errors; /* Number of Rx errors (rx_overerrors + rx_nok) */
- uint32_t rx_ovrerrors; /* Number of FIFO overrun errors */
+ uint32_t rx_ovrerrors; /* Number of FIFO overrun errors */
uint32_t tx_int; /* Number of Tx interrupts received */
uint32_t tx_packets; /* Number of Tx descriptors queued */
uint32_t tx_errors; /* Number of Tx errors (sum of the following) */
- uint32_t tx_abterrors; /* Number of aborted Tx descriptors */
- uint32_t tx_fsmerrors; /* Number of Tx state machine errors */
- uint32_t tx_timeouts; /* Number of Tx timeout errors */
+ uint32_t tx_abterrors; /* Number of aborted Tx descriptors */
+ uint32_t tx_fsmerrors; /* Number of Tx state machine errors */
+ uint32_t tx_timeouts; /* Number of Tx timeout errors */
uint32_t sys_int; /* Number of system interrupts received */
};
# define _MKFIELD(a,b,c) a->b##c
@@ -1265,15 +1270,16 @@ static int ez80emac_receive(struct ez80emac_driver_s *priv)
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- if (ETHBUF->type == HTONS(ETHTYPE_IP6))
-#else
+#ifdef CONFIG_NET_IPv4
if (ETHBUF->type == HTONS(ETHTYPE_IP))
-#endif
{
- nvdbg("IP packet received (%02x)\n", ETHBUF->type);
- EMAC_STAT(priv, rx_ip);
+ nllvdbg("IPv4 frame\n");
+
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
+ EMAC_STAT(priv, rx_ip);
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@@ -1283,11 +1289,54 @@ static int ez80emac_receive(struct ez80emac_driver_s *priv)
if (priv->dev.d_len > 0)
{
- arp_out(&priv->dev);
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (ETHBUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->dev);
+ }
+
+ /* And send the packet */
+
ez80emac_transmit(priv);
}
}
else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (ETHBUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ EMAC_STAT(priv, rx_ip);
+ ipv6_input(&priv->dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (priv->dev.d_len > 0)
+ {
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (ETHBUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->dev);
+ }
+#endif
+
+ /* And send the packet */
+
+ ez80emac_transmit(priv);
+ }
+ }
+ else
+#endif
#ifdef CONFIG_NET_ARP
if (ETHBUF->type == htons(ETHTYPE_ARP))
{