Skip to contentSkip to conversation

net: add Faraday FTGMAC100 Gigabit Ethernet driver

PATCH Superseded Po-Yu Chuang 3 participants 16 messages Mar 10, 2011 – Jun 11, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: add Faraday FTGMAC100 Gigabit Ethernet driver

From: Po-Yu Chuang <[email protected]>

FTGMAC100 Ethernet Media Access Controller supports 10/100/1000 Mbps and MII/GMII. This driver has been working on some ARM/NDS32 SoC's including Faraday A369 and Andes AG102.

---
 drivers/net/Kconfig     |    9 +
 drivers/net/Makefile    |    1 +
 drivers/net/ftgmac100.c | 1365 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ftgmac100.h |  246 +++++++++
 4 files changed, 1621 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/ftgmac100.c
 create mode 100644 drivers/net/ftgmac100.h
drivers/net/Kconfig +9 -0
index 6b12274..b9da914 100644
@@ -2560,6 +2560,15 @@ config PCH_GBE
 	  to Gigabit Ethernet.
 	  This driver enables Gigabit Ethernet function.
 
+config FTGMAC100
+	tristate "Faraday FTGMAC100 Gigabit Ethernet support"
+	depends on ARM
+	select PHYLIB
+	help
+	  This driver supports the FTGMAC100 Gigabit Ethernet controller
+	  from Faraday. It is used on Faraday A369, Andes AG102 and some
+	  other ARM/NDS32 SoC's.
+
 endif # NETDEV_1000
 
 #
drivers/net/Makefile +1 -0
index 7c21711..a349b26 100644
@@ -147,6 +147,7 @@ obj-$(CONFIG_FORCEDETH) += forcedeth.o
 obj-$(CONFIG_NE_H8300) += ne-h8300.o 8390.o
 obj-$(CONFIG_AX88796) += ax88796.o
 obj-$(CONFIG_BCM63XX_ENET) += bcm63xx_enet.o
+obj-$(CONFIG_FTGMAC100) += ftgmac100.o
 obj-$(CONFIG_FTMAC100) += ftmac100.o
 
 obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o
drivers/net/ftgmac100.c new file +1365 -0

1,365 lines not on this page · raw message

drivers/net/ftgmac100.h new file +246 -0

246 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 6 lines · Po-Yu Chuang

From: Po-Yu Chuang <[email protected]>

FTGMAC100 Ethernet Media Access Controller supports 10/100/1000 Mbps and MII/GMII. This driver has been working on some ARM/NDS32 SoC's including Faraday A369 and Andes AG102.

Hi

It seems very close from drivers/net/ftmac100.c one. Are you sure a factorization is not possible ?

BTW, it seems I missed the fact that ftmac100_alloc_rx_page() used a GFP_KERNEL allocation, while its called from softirq context (from ftmac100_rx_packet())

Same problem of course in this Gigabit driver.

#2 lore raw

PATCH 1/1 ftmac100: use GFP_ATOMIC allocations where needed

Quoted 3 lines · Eric Dumazet

BTW, it seems I missed the fact that ftmac100_alloc_rx_page() used a GFP_KERNEL allocation, while its called from softirq context (from ftmac100_rx_packet())

Here is a patch against ftmac100

[PATCH net-next-2.6] ftmac100: use GFP_ATOMIC allocations where needed

When running in softirq context, we should use GFP_ATOMIC allocations instead of GFP_KERNEL ones.

---
 drivers/net/ftmac100.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ftmac100.c +7 -5
index df70368..76cf77a 100644
@@ -80,7 +80,8 @@ struct ftmac100 {
 	struct mii_if_info mii;
 };
 
-static int ftmac100_alloc_rx_page(struct ftmac100 *priv, struct ftmac100_rxdes *rxdes);
+static int ftmac100_alloc_rx_page(struct ftmac100 *priv,
+				  struct ftmac100_rxdes *rxdes, gfp_t gfp);
 
 /******************************************************************************
  * internal functions (hardware register access)
@@ -441,7 +442,7 @@ static bool ftmac100_rx_packet(struct ftmac100 *priv, int *processed)
 	skb->truesize += length;
 	__pskb_pull_tail(skb, min(length, 64));
 
-	ftmac100_alloc_rx_page(priv, rxdes);
+	ftmac100_alloc_rx_page(priv, rxdes, GFP_ATOMIC);
 
 	ftmac100_rx_pointer_advance(priv);
 
@@ -659,13 +660,14 @@ static int ftmac100_xmit(struct ftmac100 *priv, struct sk_buff *skb,
 /******************************************************************************
  * internal functions (buffer)
  *****************************************************************************/
-static int ftmac100_alloc_rx_page(struct ftmac100 *priv, struct ftmac100_rxdes *rxdes)
+static int ftmac100_alloc_rx_page(struct ftmac100 *priv,
+				  struct ftmac100_rxdes *rxdes, gtp_t gfp)
 {
 	struct net_device *netdev = priv->netdev;
 	struct page *page;
 	dma_addr_t map;
 
-	page = alloc_page(GFP_KERNEL);
+	page = alloc_page(gfp);
 	if (!page) {
 		if (net_ratelimit())
 			netdev_err(netdev, "failed to allocate rx page\n");
@@ -736,7 +738,7 @@ static int ftmac100_alloc_buffers(struct ftmac100 *priv)
 	for (i = 0; i < RX_QUEUE_ENTRIES; i++) {
 		struct ftmac100_rxdes *rxdes = &priv->descs->rxdes[i];
 
-		if (ftmac100_alloc_rx_page(priv, rxdes))
+		if (ftmac100_alloc_rx_page(priv, rxdes, GFP_KERNEL))
 			goto err;
 	}
 
#3 lore raw

Re: [PATCH net-next-2.6] ftmac100: use GFP_ATOMIC allocations where needed

Quoted 8 lines · Eric Dumazet
Quoted 3 lines · Eric Dumazet

BTW, it seems I missed the fact that ftmac100_alloc_rx_page() used a GFP_KERNEL allocation, while its called from softirq context (from ftmac100_rx_packet())

Here is a patch against ftmac100

Oops, one typo in it sorry

drivers/net/ftmac100.c static int ftmac100_xmit(struct ftmac100 *priv, struct sk_buff *skb, · line 664

Quoted 3 lines
drivers/net/ftmac100.c +2 -1
-static int ftmac100_alloc_rx_page(struct ftmac100 *priv, struct ftmac100_rxdes *rxdes)
+static int ftmac100_alloc_rx_page(struct ftmac100 *priv,
+				  struct ftmac100_rxdes *rxdes, gtp_t gfp)

Should be : gfp_t gfp

Please build and test the patch, I dont have an ARM testbed anyway.

Thanks

author Tested-by
#4 lore raw

Re: [PATCH net-next-2.6] ftmac100: use GFP_ATOMIC allocations where needed

Hi Eric,

Quoted 12 lines · Eric Dumazet
Quoted 8 lines · Eric Dumazet
Quoted 3 lines · Eric Dumazet

BTW, it seems I missed the fact that ftmac100_alloc_rx_page() used a GFP_KERNEL allocation, while its called from softirq context (from ftmac100_rx_packet())

Here is a patch against ftmac100

Oops, one typo in it sorry

Quoted 7 lines

drivers/net/ftmac100.c static int ftmac100_xmit(struct ftmac100 *priv, struct sk_buff *skb, · line 664

Quoted 3 lines
drivers/net/ftmac100.c +2 -1
-static int ftmac100_alloc_rx_page(struct ftmac100 *priv, struct ftmac100_rxdes *rxdes)
+static int ftmac100_alloc_rx_page(struct ftmac100 *priv,
+                               struct ftmac100_rxdes *rxdes, gtp_t gfp)

Should be :   gfp_t gfp

Please build and test the patch, I dont have an ARM testbed anyway.

Thank you,
Po-Yu Chuang

#7 lore raw
In reply to Eric Dumazet

Hi Eric,

Quoted 11 lines · Eric Dumazet
Quoted 5 lines · Po-Yu Chuang

From: Po-Yu Chuang <[email protected]>

FTGMAC100 Ethernet Media Access Controller supports 10/100/1000 Mbps and MII/GMII.  This driver has been working on some ARM/NDS32 SoC's including Faraday A369 and Andes AG102.

Hi

It seems very close from drivers/net/ftmac100.c one. Are you sure a factorization is not possible ?

First, the registers and descriptors of FTGMAC100 are not backward compatible to FTMAC100.

Second, FTGMAC100 HW has some features new to FTMAC100
(jumbo packet, checksum offload... etc.) and not all of them are supported in the current version. For example, NETIF_F_SG support might be the next step to improve.

IMHO, it will be easier for me to maintain them and to add new features to FTGMAC100 driver if we separate these two drivers. How do you think?

Quoted 3 lines

BTW, it seems I missed the fact that ftmac100_alloc_rx_page() used a GFP_KERNEL allocation, while its called from softirq context (from ftmac100_rx_packet())

Tested. Thank you.

Quoted 1 line

Same problem of course in this Gigabit driver.

Will fix it.

Best regards,
Po-Yu Chuang

#5 lore raw

PATCH v2 1/1 ftmac100: use GFP_ATOMIC allocations where needed

In reply to Po-Yu Chuang

When running in softirq context, we should use GFP_ATOMIC allocations instead of GFP_KERNEL ones.

---
v2: fixed a typo

 drivers/net/ftmac100.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ftmac100.c +7 -5
index df70368..1d6f4b8 100644
@@ -80,7 +80,8 @@ struct ftmac100 {
 	struct mii_if_info mii;
 };
 
-static int ftmac100_alloc_rx_page(struct ftmac100 *priv, struct ftmac100_rxdes *rxdes);
+static int ftmac100_alloc_rx_page(struct ftmac100 *priv,
+				  struct ftmac100_rxdes *rxdes, gfp_t gfp);
 
 /******************************************************************************
  * internal functions (hardware register access)
@@ -441,7 +442,7 @@ static bool ftmac100_rx_packet(struct ftmac100 *priv, int *processed)
 	skb->truesize += length;
 	__pskb_pull_tail(skb, min(length, 64));
 
-	ftmac100_alloc_rx_page(priv, rxdes);
+	ftmac100_alloc_rx_page(priv, rxdes, GFP_ATOMIC);
 
 	ftmac100_rx_pointer_advance(priv);
 
@@ -659,13 +660,14 @@ static int ftmac100_xmit(struct ftmac100 *priv, struct sk_buff *skb,
 /******************************************************************************
  * internal functions (buffer)
  *****************************************************************************/
-static int ftmac100_alloc_rx_page(struct ftmac100 *priv, struct ftmac100_rxdes *rxdes)
+static int ftmac100_alloc_rx_page(struct ftmac100 *priv,
+				  struct ftmac100_rxdes *rxdes, gfp_t gfp)
 {
 	struct net_device *netdev = priv->netdev;
 	struct page *page;
 	dma_addr_t map;
 
-	page = alloc_page(GFP_KERNEL);
+	page = alloc_page(gfp);
 	if (!page) {
 		if (net_ratelimit())
 			netdev_err(netdev, "failed to allocate rx page\n");
@@ -736,7 +738,7 @@ static int ftmac100_alloc_buffers(struct ftmac100 *priv)
 	for (i = 0; i < RX_QUEUE_ENTRIES; i++) {
 		struct ftmac100_rxdes *rxdes = &priv->descs->rxdes[i];
 
-		if (ftmac100_alloc_rx_page(priv, rxdes))
+		if (ftmac100_alloc_rx_page(priv, rxdes, GFP_KERNEL))
 			goto err;
 	}
 
#8 lore raw

PATCH v2 1/1 net: add Faraday FTGMAC100 Gigabit Ethernet driver

In reply to Po-Yu Chuang

From: Po-Yu Chuang <[email protected]>

FTGMAC100 Ethernet Media Access Controller supports 10/100/1000 Mbps and MII/GMII. This driver has been working on some ARM/NDS32 SoC's including Faraday A369 and Andes AG102.

---
v2:
fix checkpatch.pl found error
use GFP_ATOMIC allocations where needed

 drivers/net/Kconfig     |    9 +
 drivers/net/Makefile    |    1 +
 drivers/net/ftgmac100.c | 1365 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ftgmac100.h |  246 +++++++++
 4 files changed, 1621 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/ftgmac100.c
 create mode 100644 drivers/net/ftgmac100.h
drivers/net/Kconfig +9 -0
index 6b12274..b9da914 100644
@@ -2560,6 +2560,15 @@ config PCH_GBE
 	  to Gigabit Ethernet.
 	  This driver enables Gigabit Ethernet function.
 
+config FTGMAC100
+	tristate "Faraday FTGMAC100 Gigabit Ethernet support"
+	depends on ARM
+	select PHYLIB
+	help
+	  This driver supports the FTGMAC100 Gigabit Ethernet controller
+	  from Faraday. It is used on Faraday A369, Andes AG102 and some
+	  other ARM/NDS32 SoC's.
+
 endif # NETDEV_1000
 
 #
drivers/net/Makefile +1 -0
index 7c21711..a349b26 100644
@@ -147,6 +147,7 @@ obj-$(CONFIG_FORCEDETH) += forcedeth.o
 obj-$(CONFIG_NE_H8300) += ne-h8300.o 8390.o
 obj-$(CONFIG_AX88796) += ax88796.o
 obj-$(CONFIG_BCM63XX_ENET) += bcm63xx_enet.o
+obj-$(CONFIG_FTGMAC100) += ftgmac100.o
 obj-$(CONFIG_FTMAC100) += ftmac100.o
 
 obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o
drivers/net/ftgmac100.c new file +1365 -0

1,365 lines not on this page · raw message

drivers/net/ftgmac100.h new file +246 -0

246 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#9 lore raw
Quoted 8 lines · Po-Yu Chuang

From: Po-Yu Chuang <[email protected]>

FTGMAC100 Ethernet Media Access Controller supports 10/100/1000 Mbps and MII/GMII. This driver has been working on some ARM/NDS32 SoC's including Faraday A369 and Andes AG102.

---

Did you tried GRO support ?

#10 lore raw

Hi Eric,

Quoted 11 lines · Eric Dumazet
Quoted 8 lines · Po-Yu Chuang

From: Po-Yu Chuang <[email protected]>

FTGMAC100 Ethernet Media Access Controller supports 10/100/1000 Mbps and MII/GMII.  This driver has been working on some ARM/NDS32 SoC's including Faraday A369 and Andes AG102.

---

Did you tried GRO support ?

No, I don't understand how to do that yet. Let me do some study first. I'd really appreciate it if you could provide me some pointers about GRO. :-) Is there any document about it?

best regards,
Po-Yu Chuang

#11 lore raw
Quoted 10 lines · Po-Yu Chuang

Hi Eric,

Quoted 7 lines · Eric Dumazet
Quoted 6 lines · Po-Yu Chuang

From: Po-Yu Chuang <[email protected]>

FTGMAC100 Ethernet Media Access Controller supports 10/100/1000 Mbps and MII/GMII. This driver has been working on some ARM/NDS32 SoC's including Faraday A369 and Andes AG102.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

---

Did you tried GRO support ?

No, I don't understand how to do that yet. Let me do some study first. I'd really appreciate it if you could provide me some pointers about GRO. :-) Is there any document about it?

Should be easy and might help performance too.

Take a look at commit :

2edae08e5b75269855fef3c74fe4292c066e7c33 (r8169: add gro support)

#12 lore raw

Hi Eric,

Quoted 18 lines · Eric Dumazet
Quoted 8 lines · Po-Yu Chuang
Quoted 7 lines · Eric Dumazet
Quoted 6 lines · Po-Yu Chuang

From: Po-Yu Chuang <[email protected]>

FTGMAC100 Ethernet Media Access Controller supports 10/100/1000 Mbps and MII/GMII.  This driver has been working on some ARM/NDS32 SoC's including Faraday A369 and Andes AG102.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

---

Did you tried GRO support ?

No, I don't understand how to do that yet. Let me do some study first. I'd really appreciate it if you could provide me some pointers about GRO. :-) Is there any document about it?

Quoted 5 lines

Should be easy and might help performance too.

Take a look at commit :

2edae08e5b75269855fef3c74fe4292c066e7c33 (r8169: add gro support)

It seems to work fine so far at least the driver is not broken, but I did not see much difference in performance though. How do I know if GRO is working indeed?

Best regards,
Po-Yu Chuang

#13 lore raw
Quoted 3 lines · Po-Yu Chuang

It seems to work fine so far at least the driver is not broken, but I did not see much difference in performance though. How do I know if GRO is working indeed?

maybe you receive one interrupt per incoming frame, and your cpu is fast enough to handle the load.

tcpdump should show big incoming TCP frames (multi segment)

(GRO only helps TCP receivers)

Example here :

09:16:32.372949 IP 192.168.20.110.55446 > 192.168.20.108.ssh: . 2372863:2374311(1448) ack 3136 win 73 <nop,nop,timestamp 317934201 257881345>

09:16:32.372975 IP 192.168.20.110.55446 > 192.168.20.108.ssh: . 2374311:2377207(2896) ack 3136 win 73 <nop,nop,timestamp 317934201 257881345>

Here, you can see GRO work, since 2nd "frame" is the result of two MTU sized frames.

#14 lore raw

PATCH v3 1/1 net: add Faraday FTGMAC100 Gigabit Ethernet driver

In reply to Po-Yu Chuang

From: Po-Yu Chuang <[email protected]>

FTGMAC100 Ethernet Media Access Controller supports 10/100/1000 Mbps and MII/GMII. This driver has been working on some ARM/NDS32 SoC's including Faraday A369 and Andes AG102.

---
Sorry for the long delay.

v2:
fix checkpatch.pl found error
use GFP_ATOMIC allocations where needed

v3:
use resource_size()
use napi_gro_receive()
fix scheduling while atomic

 drivers/net/Kconfig     |    9 +
 drivers/net/Makefile    |    1 +
 drivers/net/ftgmac100.c | 1365 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ftgmac100.h |  246 +++++++++
 4 files changed, 1621 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/ftgmac100.c
 create mode 100644 drivers/net/ftgmac100.h
drivers/net/Kconfig +9 -0
index 6b12274..b9da914 100644
@@ -2560,6 +2560,15 @@ config PCH_GBE
 	  to Gigabit Ethernet.
 	  This driver enables Gigabit Ethernet function.
 
+config FTGMAC100
+	tristate "Faraday FTGMAC100 Gigabit Ethernet support"
+	depends on ARM
+	select PHYLIB
+	help
+	  This driver supports the FTGMAC100 Gigabit Ethernet controller
+	  from Faraday. It is used on Faraday A369, Andes AG102 and some
+	  other ARM/NDS32 SoC's.
+
 endif # NETDEV_1000
 
 #
drivers/net/Makefile +1 -0
index 7c21711..a349b26 100644
@@ -147,6 +147,7 @@ obj-$(CONFIG_FORCEDETH) += forcedeth.o
 obj-$(CONFIG_NE_H8300) += ne-h8300.o 8390.o
 obj-$(CONFIG_AX88796) += ax88796.o
 obj-$(CONFIG_BCM63XX_ENET) += bcm63xx_enet.o
+obj-$(CONFIG_FTGMAC100) += ftgmac100.o
 obj-$(CONFIG_FTMAC100) += ftmac100.o
 
 obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o
drivers/net/ftgmac100.c new file +1365 -0

1,365 lines not on this page · raw message

drivers/net/ftgmac100.h new file +246 -0

246 lines not on this page · raw message

Signature · 1 line
1.6.3.3