Gemini: Gigabit ethernet driver
Subsystems (2)
PATCH v3 1/1 Gemini: Gigabit ethernet driver
Driver for SL351x (Gemini) SoC ethernet peripheral. Based in part on work by Paulius Zaleckas and GPLd code from Raidsonic and other NAS vendors.
Tested on Raidsonic IcyBox 4220-B (dual SATA NAS).
---
Against: v2.6.37-rc8
This depends on commit 83097f22d1f91a748bb2c066d049d0d1d2843ef2
Gemini: create platform device for ethernet in Raidsonic IB-4220B
from git://git.berlios.de/gemini-board
Note for testers: you may tweak DEFAULT_RX_BUF_ORDER (=log2(buffer size), at most a page - so in range [6..12]) and RX_MAX_ALLOC_ORDER (max allocated rx buffer page order) to find best memory usage/performance settings apart from what is available via ethtool. For TX, there's not much you can do when offloads are disabled.
Changes from v2:
- converted to page buffers and napi_gro_frags()
- later IRQ acking and NAPI exits
- larger rings by default
- tx-interrupt coalescing
- MTU changing
- jumbo frames support
- ringparam and coalesce settings via ethtool
- more fixes/cleanups
Changes from v1:
- fixed stats (now using u64_stats_sync; no-op on UP anyway)
- pre-load mdio-gpio if built as module
- disable TX checksum offload by default (unreliable HW)
- convert to NAPI+GRO (netperf TCP STREAM RX test:
before: 156mbit/s, now: 185mbit/s)
Later TODO:
- netpoll (netconsole)
--- MAINTAINERS | 9 + drivers/net/Kconfig | 10 + drivers/net/Makefile | 1 + drivers/net/sl351x.c | 2287 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/sl351x_hw.h | 1435 +++++++++++++++++++++++++++++ 5 files changed, 3742 insertions(+), 0 deletions(-)
MAINTAINERS +9 -0
@@ -5439,6 +5439,15 @@ S: Maintained F: drivers/net/skge.* F: drivers/net/sky2.* +SL351X (STORLINK GEMINI SOC) GIGABIT ETHERNET DRIVER +M: Michał Mirosław <[email protected]> +L: [email protected] +L: [email protected] +T: git git://git.berlios.de/gemini-board +S: Maintained +F: driver/net/sl351x.c +F: driver/net/sl351x_hw.h + SLAB ALLOCATOR M: Christoph Lameter <[email protected]> M: Pekka Enberg <[email protected]>
drivers/net/Kconfig +10 -0
@@ -2068,6 +2068,16 @@ config ACENIC_OMIT_TIGON_I The safe and default value for this is N. +config GEMINI_SL351X + tristate "StorLink SL351x Gigabit Ethernet support" + depends on ARCH_GEMINI + select PHYLIB + select MDIO_BITBANG + select MDIO_GPIO + select CRC32 + help + This driver supports StorLink SL351x (Gemini) dual Gigabit Ethernet. + config DL2K tristate "DL2000/TC902x-based Gigabit Ethernet support" depends on PCI
drivers/net/Makefile +1 -0
@@ -257,6 +257,7 @@ obj-$(CONFIG_MLX4_CORE) += mlx4/ obj-$(CONFIG_ENC28J60) += enc28j60.o obj-$(CONFIG_ETHOC) += ethoc.o obj-$(CONFIG_GRETH) += greth.o +obj-$(CONFIG_GEMINI_SL351X) += sl351x.o obj-$(CONFIG_XTENSA_XT2000_SONIC) += xtsonic.o
drivers/net/sl351x.c new file +2287 -0
2,287 lines not on this page · raw message
drivers/net/sl351x_hw.h new file +1435 -0
675 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH v4 1/1 Gemini: Gigabit ethernet driver
Driver for SL351x (Gemini) SoC ethernet peripheral. Based in part on work by Paulius Zaleckas and GPLd code from Raidsonic and other NAS vendors.
Tested on Raidsonic IcyBox 4220-B (dual SATA NAS).
---
Against: v2.6.37-rc8
This depends on commit 83097f22d1f91a748bb2c066d049d0d1d2843ef2
Gemini: create platform device for ethernet in Raidsonic IB-4220B
from git://git.berlios.de/gemini-board
Note for testers: you may tweak DEFAULT_RX_BUF_ORDER (=log2(buffer size), at most a page - so in range [6..12]) and RX_MAX_ALLOC_ORDER (max allocated rx buffer page order) to find best memory usage/performance settings apart from what is available via ethtool. For TX, there's not much you can do when offloads are disabled.
MAC address needs to be set by userspace from flash VCTL partition (mtd4 on my box).
Changes from v3:
- fixed remaining tx_queue_len misuse bugs
- bulk RX DMA page map/unmap
- whitespace changes to make checkpatch happier (please ignore remaining complaints - long lines in .c and typedefs/whitespace/long lines in .h)
Changes from v2:
- converted to page buffers and napi_gro_frags()
- later IRQ acking and NAPI exits
- larger rings by default
- tx-interrupt coalescing
- MTU changing
- jumbo frames support
- ringparam and coalesce settings via ethtool
- more fixes/cleanups
Changes from v1:
- fixed stats (now using u64_stats_sync; no-op on UP anyway)
- pre-load mdio-gpio if built as module
- disable TX checksum offload by default (unreliable HW)
- convert to NAPI+GRO (netperf TCP STREAM RX test:
before: 156mbit/s, now: 185mbit/s)
Later TODO:
- netpoll (netconsole)
- parse MAC address from flash settings and pass it through platform data
--- MAINTAINERS | 9 + drivers/net/Kconfig | 10 + drivers/net/Makefile | 1 + drivers/net/sl351x.c | 2323 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/sl351x_hw.h | 1436 +++++++++++++++++++++++++++++ 5 files changed, 3779 insertions(+), 0 deletions(-)
MAINTAINERS +9 -0
@@ -5439,6 +5439,15 @@ S: Maintained F: drivers/net/skge.* F: drivers/net/sky2.* +SL351X (STORLINK GEMINI SOC) GIGABIT ETHERNET DRIVER +M: Michał Mirosław <[email protected]> +L: [email protected] +L: [email protected] +T: git git://git.berlios.de/gemini-board +S: Maintained +F: driver/net/sl351x.c +F: driver/net/sl351x_hw.h + SLAB ALLOCATOR M: Christoph Lameter <[email protected]> M: Pekka Enberg <[email protected]>
drivers/net/Kconfig +10 -0
@@ -2068,6 +2068,16 @@ config ACENIC_OMIT_TIGON_I The safe and default value for this is N. +config GEMINI_SL351X + tristate "StorLink SL351x Gigabit Ethernet support" + depends on ARCH_GEMINI + select PHYLIB + select MDIO_BITBANG + select MDIO_GPIO + select CRC32 + help + This driver supports StorLink SL351x (Gemini) dual Gigabit Ethernet. + config DL2K tristate "DL2000/TC902x-based Gigabit Ethernet support" depends on PCI
drivers/net/Makefile +1 -0
@@ -257,6 +257,7 @@ obj-$(CONFIG_MLX4_CORE) += mlx4/ obj-$(CONFIG_ENC28J60) += enc28j60.o obj-$(CONFIG_ETHOC) += ethoc.o obj-$(CONFIG_GRETH) += greth.o +obj-$(CONFIG_GEMINI_SL351X) += sl351x.o obj-$(CONFIG_XTENSA_XT2000_SONIC) += xtsonic.o
drivers/net/sl351x.c new file +2323 -0
2,323 lines not on this page · raw message
drivers/net/sl351x_hw.h new file +1436 -0
639 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
drivers/net/sl351x.c
Quoted 5 lines · Michał Mirosław
Driver for SL351x (Gemini) SoC ethernet peripheral. Based in part on work by Paulius Zaleckas and GPLd code from Raidsonic and other NAS vendors.
Signed-off-by Michał Mirosław <[email protected]>drivers/net/sl351x.c +0
-0
Output trivia:
Quoted 1 line
+static void
gmac_tx_interrupt(struct net_device *dev, unsigned txq_num)
[]
drivers/net/sl351x.c line 610
Quoted 2 lines
drivers/net/sl351x.c +2
-0+netif_info (gmac, tx_done, dev,"txirq%u: %u,%u,%u\n" , + txq_num, txq->cptr,GET_RPTR (ptr_reg),GET_WPTR (ptr_reg));
pointers as decimal?
There seems to be a lot of output using %u where I expected %08x.
Quoted 1 line
+static int
gmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
[]
drivers/net/sl351x.c line 791
Quoted 3 lines
drivers/net/sl351x.c +3
-0+netif_info (gmac, tx_queued, dev,"txq%u: %u,%u,%u ? %p (%u @ %p) /%u\n" , + txq_num, txq->cptr,GET_RPTR (ptr_reg),GET_WPTR (ptr_reg), + skb, skb->len, skb->data,skb_shinfo (skb)->gso_size);
[]
drivers/net/sl351x.c line 838
Quoted 2 lines
drivers/net/sl351x.c +2
-0+netif_info (gmac, tx_queued, dev,"txq%u: %u,%u,%u + %p\n" , + txq_num, txq->cptr,GET_RPTR (ptr_reg), w, skb);
[]
Quoted 1 line
+static unsigned
gmac_rx(struct net_device *dev, unsigned budget)
[]
drivers/net/sl351x.c line 945
Quoted 2 lines
drivers/net/sl351x.c +2
-0+netif_info (gmac, rx_status, dev,"rxq: %u,%u\n" , +GET_RPTR (ptr_reg),GET_WPTR (ptr_reg));
etc...
Quoted 9 lines · Joe Perches
drivers/net/sl351x.c
Quoted 5 lines · Michał Mirosław
Driver for SL351x (Gemini) SoC ethernet peripheral. Based in part on work by Paulius Zaleckas and GPLd code from Raidsonic and other NAS vendors.
Signed-off-by Michał Mirosław <[email protected]>drivers/net/sl351x.c +0
-0Output trivia:
Quoted 7 lines
Quoted 1 line
+static void
gmac_tx_interrupt(struct net_device *dev, unsigned txq_num)[]
drivers/net/sl351x.c line 610
Quoted 2 lines
drivers/net/sl351x.c +2
-0+netif_info (gmac, tx_done, dev,"txirq%u: %u,%u,%u\n" , + txq_num, txq->cptr,GET_RPTR (ptr_reg),GET_WPTR (ptr_reg));pointers as decimal?
There seems to be a lot of output using %u where I expected %08x.
These are indexes into TX/RX/RXbuf(FreeQ) rings. It's usually easier to read them in decimal by humans. ;) I kept the notation of 'PTR' from the original hardware register names.
Best Regards,
Michał Mirosław
Quoted 9 lines · Michał Mirosław
Driver for SL351x (Gemini) SoC ethernet peripheral. Based in part on work by Paulius Zaleckas and GPLd code from Raidsonic and other NAS vendors.
Tested on Raidsonic IcyBox 4220-B (dual SATA NAS).
Signed-off-by Michał Mirosław <[email protected]>---
Hi Michał,
I've make a quick compile and run test on my IB4220 Looks good.
But we must include the file gmac.h fromarch/arm/mach-gemini/include/mach.
We break the build, if we don't do this.
Other issue is the __raw_writel and __raw_readl functions, we can switch to readl and writel. This is due some mistake of the original developer (Stormlinksemi) who doesn't understand endianes on ARM
I've tested this driver on my IB4220 only in 100MBit/s mode. PHY is broken.
I have another IB4220 at my home with working PHY
Ulli
PATCH v5 1/1 Gemini: Gigabit ethernet driver
In reply to Michał MirosławDriver for SL351x (Gemini) SoC ethernet peripheral. Based in part on work by Paulius Zaleckas and GPLd code from Raidsonic and other NAS vendors.
Tested on Raidsonic IcyBox 4220-B (dual SATA NAS).
---
Against: v2.6.38-rc2+
This depends on following commits from
git://git.berlios.de/gemini-board
1. 732ae5221a89db85626c7c636bd2520fa98768d2
ARM: Gemini: add missing gmac.h for gigabit driver
2. feda237215382063b4174929ac18701976353418
ARM: Gemini: add gmac platform driver o IB4220B
Note for testers: you may tweak DEFAULT_RX_BUF_ORDER (=log2(buffer size), at most a page - so in range [6..12]) and RX_MAX_ALLOC_ORDER (max allocated rx buffer page order) to find best memory usage/performance settings apart from what is available via ethtool. For TX, there's not much you can do when offloads are disabled.
MAC address needs to be set by userspace after parsing VCTL flash partition (mtd4 on my box).
Changes from v4:
- rebased on upcoming 2.6.38 (removal of page_to_dma() and per-txq stats)
- removed setting last_rx and trans_start as that's handled by net core
- changed __raw_read/writel() to read/writel()
- added setting of AHB_WEIGHT register (didn't improve anything, I'm afraid)
- fixed DMA unmapping bug
- added limit of packet size for TX offload (HW checks only 13 bits of mtu_size field)
- reduced RX_MAX_ALLOC_ORDER as it caused a lot of order 4 allocation failures under load
- cleanups
Changes from v3:
- fixed remaining tx_queue_len misuse bugs
- bulk RX DMA page map/unmap
- whitespace changes to make checkpatch happier (please ignore remaining complaints - long lines in .c and typedefs/whitespace/long lines in .h)
Changes from v2:
- converted to page buffers and napi_gro_frags()
- later IRQ acking and NAPI exits
- larger rings by default
- tx-interrupt coalescing
- MTU changing
- jumbo frames support
- ringparam and coalesce settings via ethtool
- more fixes/cleanups
Changes from v1:
- fixed stats (now using u64_stats_sync; no-op on UP anyway)
- pre-load mdio-gpio if built as module
- disable TX checksum offload by default (unreliable HW)
- convert to NAPI+GRO (netperf TCP STREAM RX test:
before: 156mbit/s, now: 185mbit/s)
Later TODO:
- netpoll (netconsole)
- parse MAC address from flash settings and pass it through platform data
- move TX completion to NAPI poll
- maybe implement rx copybreak
MAINTAINERS +9 -0
@@ -5670,6 +5670,15 @@ S: Maintained F: drivers/net/skge.* F: drivers/net/sky2.* +SL351X (STORLINK GEMINI SOC) GIGABIT ETHERNET DRIVER +M: Michał Mirosław <[email protected]> +L: [email protected] +L: [email protected] +T: git git://git.berlios.de/gemini-board +S: Maintained +F: driver/net/sl351x.c +F: driver/net/sl351x_hw.h + SLAB ALLOCATOR M: Christoph Lameter <[email protected]> M: Pekka Enberg <[email protected]>
drivers/net/sl351x.c new file +2363 -0
2,363 lines not on this page · raw message
drivers/net/sl351x_hw.h new file +1436 -0
622 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
David Miller
maintainerFrom: Michał Mirosław <[email protected]>
Date: Thu, 27 Jan 2011 00:24:19 +0100 (CET)
drivers/net/sl351x.c line 57
Quoted 4 lines
drivers/net/sl351x.c new file +4
-0+#define NETIF_TSO_FEATURES \ + (NETIF_F_TSO|NETIF_F_TSO_ECN|NETIF_F_TSO6) +#define GMAC_TX_OFFLOAD_FEATURES \ + (NETIF_TSO_FEATURES|NETIF_F_ALL_CSUM)
Please, when definiting macros locally for your driver, do not name them with prefixes that match those defined generically by the network stack. Otherwise it is confusing for people reading the driver.
One should be able to see "NETIF_XXX" somewhere and expect to find it's definition somewhere in the generic networking driver interfaces, not in the driver itself.
drivers/net/sl351x.c line 180
Quoted 4 lines
drivers/net/sl351x.c new file +4
-0+static struct toe_private *netdev_to_toe (struct net_device *dev) +{ +return dev->ml_priv; +}
There is no reason to use ->ml_priv just to have a common backpointer to a structure shared between multiple interfaces.
Simply add a "struct toe_private *" to your "struct gmac_private" and stick it there.
The cost of the dereference is identical in both cases, so there is not even a performance incentive to use ->ml_priv.
drivers/net/sl351x.c line 200
Quoted 4 lines
drivers/net/sl351x.c new file +4
-0+static void __iomem *gmac_ctl_reg (struct net_device *dev,unsigned int reg) +{ +return (void __iomem *)dev->base_addr + reg; +}
Please do not abuse dev->base_addr in this way, simply define another "void __iomem *" pointer in your gmac_private and use that.
drivers/net/sl351x.c line 210
Quoted 1 line
drivers/net/sl351x.c new file +1
-0+ page =pfn_to_page (dma_to_pfn (toe->dev, rx->word2.buf_adr));
Please do not use non-portable routines such as dma_to_pfn() unless it is absolutely unavoidable. Instead, use schemes for page struct lookup like those used by drivers such as drivers/net/niu.c, which uses a hash table to find pages based upon DMA address.
I'd like you to be able to enable this driver on as many platforms as possible, not just ARM, so we can be build testing your driver as we make changes to various network driver APIs, and we can't do that if you put ARM specific stuff in here.
drivers/net/sl351x.c line 369
Quoted 1 line
drivers/net/sl351x.c new file +1
-0+dev_err (&dev->dev,"Unsupported MII interface\n" );
Please use "netdev_err(dev, ..."
Please use netdev_*() when possible elsewhere in this driver too.
drivers/net/sl351x.c line 693
Quoted 4 lines
drivers/net/sl351x.c new file +4
-0+writel ( + (GMAC0_SWTQ00_EOF_INT_BIT |GMAC0_SWTQ00_FIN_INT_BIT ) + << (6 * dev->dev_id + txq_num), +toe_reg (toe,GLOBAL_INTERRUPT_STATUS_0_REG ));
Please format this more reasonably, this looks awful.
drivers/net/sl351x.c line 750
Quoted 4 lines
drivers/net/sl351x.c new file +4
-0+ txq->ring[w].word0.bits32 =skb_headlen (skb); + txq->ring[w].word1.bits32 = skb->len | tss_flags; + txq->ring[w].word2.bits32 = mapping; + txq->ring[w].word3.bits32 =tss_pkt_len (skb) |SOF_BIT ;
What is the endinness of the RX and TX descriptors of this chipset? Please use "__be32", "__le32", and the endianness conversion interfaces as needed.
Quoted 12 lines · David Miller
From: Michał Mirosław <[email protected]>
Date: Thu, 27 Jan 2011 00:24:19 +0100 (CET)drivers/net/sl351x.c line 57
Quoted 4 lines
drivers/net/sl351x.c new file +4
-0+#define NETIF_TSO_FEATURES \ + (NETIF_F_TSO|NETIF_F_TSO_ECN|NETIF_F_TSO6) +#define GMAC_TX_OFFLOAD_FEATURES \ + (NETIF_TSO_FEATURES|NETIF_F_ALL_CSUM)Please, when definiting macros locally for your driver, do not name them with prefixes that match those defined generically by the network stack. Otherwise it is confusing for people reading the driver.
Quoted 3 lines
One should be able to see "
NETIF_XXX" somewhere and expect to find it's definition somewhere in the generic networking driver interfaces, not in the driver itself.
Sure. Renamed to GMAC_TSO_FEATURES for next versions.
Quoted 8 lines
drivers/net/sl351x.c line 180
Quoted 4 lines
drivers/net/sl351x.c new file +4
-0+static struct toe_private *netdev_to_toe (struct net_device *dev) +{ +return dev->ml_priv; +}There is no reason to use ->ml_priv just to have a common backpointer to a structure shared between multiple interfaces.
Quoted 5 lines
Simply add a "struct
toe_private*" to your "structgmac_private" and stick it there.The cost of the dereference is identical in both cases, so there is not even a performance incentive to use ->ml_priv.
What is the correct use of ml_priv? I saw that a few drivers use it for same or similar purpose (pointer to state shared between network devices).
Quoted 6 lines
drivers/net/sl351x.c line 200
Quoted 4 lines
drivers/net/sl351x.c new file +4
-0+static void __iomem *gmac_ctl_reg (struct net_device *dev,unsigned int reg) +{ +return (void __iomem *)dev->base_addr + reg; +}Please do not abuse
dev->base_addrin this way, simply define another "void__iomem*" pointer in yourgmac_privateand use that.
The field is unused for memory-mapped devices. Still, that's why I wrap this kind of things in one-liners - I can easily change it.
Quoted 10 lines
drivers/net/sl351x.c line 210
Quoted 1 line
drivers/net/sl351x.c new file +1
-0+ page =pfn_to_page (dma_to_pfn (toe->dev, rx->word2.buf_adr));Please do not use non-portable routines such as
dma_to_pfn()unless it is absolutely unavoidable. Instead, use schemes for page struct lookup like those used by drivers such asdrivers/net/niu.c, which uses a hash table to find pages based upon DMA address.I'd like you to be able to enable this driver on as many platforms as possible, not just ARM, so we can be build testing your driver as we make changes to various network driver APIs, and we can't do that if you put ARM specific stuff in here.
To make it build I need to add a bunch of #ifdefs to compile out other platform-specific code. I see no reason to make it inefficient on the only platform it's supposed to work. I have isolated the code to another one-liner functions in case this happens to be bigger problem.
If I make it buildable (NOT working) on other archs is it enough I add Kconfig dependency on (ARCH_GEMINI || BROKEN) to allow it to be build-tested there?
Quoted 3 lines
drivers/net/sl351x.c line 369
Quoted 1 line
drivers/net/sl351x.c new file +1
-0+dev_err (&dev->dev,"Unsupported MII interface\n" );Please use "netdev_err(dev, ..."
Please use netdev_*() when possible elsewhere in this driver too.
Fixed. This is called before the netdev is registered, though.
Quoted 5 lines
drivers/net/sl351x.c line 693
Quoted 4 lines
drivers/net/sl351x.c new file +4
-0+writel ( + (GMAC0_SWTQ00_EOF_INT_BIT |GMAC0_SWTQ00_FIN_INT_BIT ) + << (6 * dev->dev_id + txq_num), +toe_reg (toe,GLOBAL_INTERRUPT_STATUS_0_REG ));Please format this more reasonably, this looks awful.
Fixed.
Quoted 7 lines
drivers/net/sl351x.c line 750
Quoted 4 lines
drivers/net/sl351x.c new file +4
-0+ txq->ring[w].word0.bits32 =skb_headlen (skb); + txq->ring[w].word1.bits32 = skb->len | tss_flags; + txq->ring[w].word2.bits32 = mapping; + txq->ring[w].word3.bits32 =tss_pkt_len (skb) |SOF_BIT ;What is the endinness of the RX and TX descriptors of this chipset? Please use "
__be32", "__le32", and the endianness conversion interfaces as needed.
StorLink people who wrote original spaghetti-code probably didn't know either. The SoC has beed used only in little-endian mode so it isn't even possible for me to test how would it work in big-endian mode.
Best Regards,
Michał Mirosław
Quoted 3 lines · Michał Mirosław
If I make it buildable (NOT working) on other archs is it enough I add
Kconfigdependency on (ARCH_GEMINI|| BROKEN) to allow it to be build-tested there?
Hmm. CONFIG_BROKEN is not easily selectable anymore, so it's unlikely that many people will even know about it. What's the correct way to make a driver be built but not installed by default? I can use:
default m if ARCH_GEMINI
default n
But that will make it get installed on x86 allmodconfig even if it won't ever work there - so will pollute modules for other arches unless distribution managers remember that not every driver built needs to be included.
Best Regards,
Michał Mirosław