From f6063c38969ae23ec066c8e67801c088fb82760f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 20 Jan 2015 15:14:29 -0600 Subject: [PATCH] Networking: Add missing raw/packet socket support to all Ethernet drivers --- arch/arm/src/c5471/c5471_ethernet.c | 10 ++++++++++ arch/arm/src/kinetis/kinetis_enet.c | 10 ++++++++++ arch/arm/src/lpc17xx/lpc17_ethernet.c | 12 ++++++++++++ arch/arm/src/sam34/sam_emac.c | 12 +++++++++++- arch/arm/src/sama5/sam_emaca.c | 12 +++++++++++- arch/arm/src/sama5/sam_emacb.c | 12 +++++++++++- arch/arm/src/sama5/sam_gmac.c | 12 +++++++++++- arch/arm/src/stm32/stm32_eth.c | 10 ++++++++-- arch/arm/src/tiva/lm3s_ethernet.c | 10 ++++++++++ arch/hc/src/m9s12/m9s12_ethernet.c | 10 ++++++++++ arch/mips/src/pic32mx/pic32mx-ethernet.c | 14 +++++++++++++- arch/sim/src/up_netdriver.c | 12 ++++++++++++ arch/z80/src/ez80/ez80_emac.c | 10 ++++++++++ 13 files changed, 139 insertions(+), 7 deletions(-) diff --git a/arch/arm/src/c5471/c5471_ethernet.c b/arch/arm/src/c5471/c5471_ethernet.c index 3f950c25ef6..7ea7e3d232b 100644 --- a/arch/arm/src/c5471/c5471_ethernet.c +++ b/arch/arm/src/c5471/c5471_ethernet.c @@ -62,6 +62,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "chip.h" #include "up_arch.h" #include "up_internal.h" @@ -1230,6 +1234,12 @@ static void c5471_receive(struct c5471_driver_s *c5471) nvdbg("Received packet, packetlen: %d type: %02x\n", packetlen, ntohs(BUF->type)); c5471_dumpbuffer("Received packet", dev->d_buf, dev->d_len); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index 08b273aa614..39aa02dea22 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -57,6 +57,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "chip.h" #include "kinetis_internal.h" @@ -514,6 +518,12 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv) putreg32(ENET_RDAR, KINETIS_ENET_RDAR); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/arm/src/lpc17xx/lpc17_ethernet.c b/arch/arm/src/lpc17xx/lpc17_ethernet.c index b37aed6c2d9..71ee88a435a 100644 --- a/arch/arm/src/lpc17xx/lpc17_ethernet.c +++ b/arch/arm/src/lpc17xx/lpc17_ethernet.c @@ -58,6 +58,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "chip.h" #include "chip/lpc17_syscon.h" @@ -872,6 +876,14 @@ static void lpc17_rxdone(struct lpc17_driver_s *priv) lpc17_dumppacket("Received packet", priv->lp_dev.d_buf, priv->lp_dev.d_len); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet + * tap. + */ + + pkt_input(&priv->lp_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c index 581a104c21e..45a3b333792 100644 --- a/arch/arm/src/sam34/sam_emac.c +++ b/arch/arm/src/sam34/sam_emac.c @@ -69,6 +69,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "up_internal.h" @@ -1136,8 +1140,14 @@ static void sam_receive(struct sam_emac_s *priv) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + continue; } - else + +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif /* We only accept IP packets of the configured type and ARP packets */ diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c index 51b1700fdd6..db362810741 100644 --- a/arch/arm/src/sama5/sam_emaca.c +++ b/arch/arm/src/sama5/sam_emaca.c @@ -70,6 +70,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "up_internal.h" #include "cache.h" @@ -1176,8 +1180,14 @@ static void sam_receive(struct sam_emac_s *priv) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + continue; } - else + +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif /* We only accept IP packets of the configured type and ARP packets */ diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c index 37fb8ea3388..7f0c3b4d60e 100644 --- a/arch/arm/src/sama5/sam_emacb.c +++ b/arch/arm/src/sama5/sam_emacb.c @@ -84,6 +84,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "up_internal.h" #include "cache.h" @@ -1502,8 +1506,14 @@ static void sam_receive(struct sam_emac_s *priv) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + continue; } - else + +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif /* We only accept IP packets of the configured type and ARP packets */ diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c index 1ed1e4b6029..689c614c4af 100644 --- a/arch/arm/src/sama5/sam_gmac.c +++ b/arch/arm/src/sama5/sam_gmac.c @@ -67,6 +67,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "up_internal.h" #include "cache.h" @@ -1106,8 +1110,14 @@ static void sam_receive(struct sam_gmac_s *priv) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + continue; } - else + +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif /* We only accept IP packets of the configured type and ARP packets */ diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index 4b3b982d909..22b22e43cbe 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -53,8 +53,8 @@ #include #include #include -#include +#include #include #include #if defined(CONFIG_NET_PKT) @@ -1612,8 +1612,14 @@ static void stm32_receive(FAR struct stm32_ethmac_s *priv) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + continue; } - else + +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif /* We only accept IP packets of the configured type and ARP packets */ diff --git a/arch/arm/src/tiva/lm3s_ethernet.c b/arch/arm/src/tiva/lm3s_ethernet.c index 6d1bdaa4fa1..bcfd7dd9c11 100644 --- a/arch/arm/src/tiva/lm3s_ethernet.c +++ b/arch/arm/src/tiva/lm3s_ethernet.c @@ -56,6 +56,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "chip.h" #include "up_arch.h" @@ -766,6 +770,12 @@ static void tiva_receive(struct tiva_driver_s *priv) priv->ld_dev.d_len = pktlen - 6; tiva_dumppacket("Received packet", priv->ld_dev.d_buf, priv->ld_dev.d_len); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->ld_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/hc/src/m9s12/m9s12_ethernet.c b/arch/hc/src/m9s12/m9s12_ethernet.c index caa25af5c93..bbba9d70993 100644 --- a/arch/hc/src/m9s12/m9s12_ethernet.c +++ b/arch/hc/src/m9s12/m9s12_ethernet.c @@ -55,6 +55,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + /**************************************************************************** * Definitions ****************************************************************************/ @@ -256,6 +260,12 @@ static void emac_receive(FAR struct emac_driver_s *priv) * amount of data in priv->d_dev.d_len */ +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->d_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/mips/src/pic32mx/pic32mx-ethernet.c b/arch/mips/src/pic32mx/pic32mx-ethernet.c index 872e68434f6..0d301db1d8d 100644 --- a/arch/mips/src/pic32mx/pic32mx-ethernet.c +++ b/arch/mips/src/pic32mx/pic32mx-ethernet.c @@ -60,6 +60,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include #include @@ -69,7 +73,7 @@ #include "pic32mx-ethernet.h" #include "pic32mx-internal.h" -/* Does this chip have and ethernet controller? */ +/* Does this chip have and Ethernet controller? */ #if CHIP_NETHERNET > 0 @@ -1429,6 +1433,14 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv) pic32mx_dumppacket("Received packet", priv->pd_dev.d_buf, priv->pd_dev.d_len); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet + * tap. + */ + + pkt_input(&priv->pd_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/sim/src/up_netdriver.c b/arch/sim/src/up_netdriver.c index 7f40cabb4bc..abffefc4326 100644 --- a/arch/sim/src/up_netdriver.c +++ b/arch/sim/src/up_netdriver.c @@ -56,6 +56,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_internal.h" /**************************************************************************** @@ -157,6 +161,14 @@ void netdriver_loop(void) if (g_sim_dev.d_len > ETH_HDRLEN && up_comparemac(BUF->ether_dhost, &g_sim_dev.d_mac) == 0) { +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet + * tap. + */ + + pkt_input(&g_sim_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/z80/src/ez80/ez80_emac.c b/arch/z80/src/ez80/ez80_emac.c index 7c2e935d010..488dd18235e 100644 --- a/arch/z80/src/ez80/ez80_emac.c +++ b/arch/z80/src/ez80/ez80_emac.c @@ -60,6 +60,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include #include "chip.h" @@ -1268,6 +1272,12 @@ static int ez80emac_receive(struct ez80emac_driver_s *priv) ez80emac_rrp(), rwp, inp(EZ80_EMAC_BLKSLFT_H), inp(EZ80_EMAC_BLKSLFT_L)); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4