Skip to contentSkip to conversation

Gemini: Gigabit ethernet driver

PATCH In review Michał Mirosław 2 participants 2 messages Apr 10, 2011 – Apr 11, 2011

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

PATCH v5 1/1 Gemini: Gigabit ethernet driver

In-Reply-To: <[email protected]>

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.39-rc2+

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).

Later TODO:
- netpoll (netconsole)
- parse MAC address from flash settings and pass it through platform data
- move TX completion to NAPI poll
- implement rx copybreak
- remove DMA API abuse on RX (large map, small unmaps)
- better test multicast support

Changes from v5:
- merge arch setup code into the patch
- move platform data include to include/linux/platform_data/gemini_gmac.h
- use new hw_features instead of ethtool_ops for offload setting
- add some #ifdefs for build testing on other arches
- a bit of cleanups

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)

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).

---
 MAINTAINERS                               |    9 +
 arch/arm/mach-gemini/board-nas4220b.c     |   53 +
 arch/arm/mach-gemini/board-rut1xx.c       |   24 +
 arch/arm/mach-gemini/common.h             |    2 +
 arch/arm/mach-gemini/devices.c            |   52 +
 drivers/net/Kconfig                       |   10 +
 drivers/net/Makefile                      |    1 +
 drivers/net/sl351x.c                      | 2369 +++++++++++++++++++++++++++++
 drivers/net/sl351x_hw.h                   | 1436 +++++++++++++++++
 drivers/rtc/Kconfig                       |    9 +
 include/linux/platform_data/gemini_gmac.h |   21 +
 11 files changed, 3986 insertions(+), 0 deletions(-)
MAINTAINERS +9 -0
index 6b4b9cd..fed8d86 100644
@@ -5715,6 +5715,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]>
arch/arm/mach-gemini/board-nas4220b.c +53 -0

73 lines not on this page · raw message

arch/arm/mach-gemini/board-rut1xx.c +24 -0
index 4fa09af..78c0cb0 100644
@@ -14,13 +14,35 @@
 #include <linux/leds.h>
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
+#include <linux/mdio-gpio.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 
+#include <linux/platform_data/gemini_gmac.h>
+
 #include "common.h"
 
+static struct mdio_gpio_platform_data rut1xx_mdio = {
+	.mdc		= 22,
+	.mdio		= 21,
+	.phy_mask	= ~(1 << 1),
+};
+
+static struct platform_device rut1xx_phy_device = {
+	.name	= "mdio-gpio",
+	.id	= 0,
+	.dev	= {
+		.platform_data = &rut1xx_mdio,
+	},
+};
+
+static struct gemini_gmac_platform_data gmac_data = {
+	.bus_id[0] = "0:01",
+	.interface[0] = PHY_INTERFACE_MODE_MII,
+};
+
 static struct gpio_keys_button rut1xx_keys[] = {
 	{
 		.code		= KEY_SETUP,
@@ -83,6 +105,8 @@ static void __init rut1xx_init(void)
 	platform_device_register(&rut1xx_leds);
 	platform_device_register(&rut1xx_keys_device);
 	platform_register_rtc();
+	platform_device_register(&rut1xx_phy_device);
+	platform_register_ethernet(&gmac_data);
 }
 
 MACHINE_START(RUT100, "Teltonika RUT100")
arch/arm/mach-gemini/common.h +2 -0
index 7670c39..4d58957 100644
@@ -13,6 +13,7 @@
 #define __GEMINI_COMMON_H__
 
 struct mtd_partition;
+struct gemini_gmac_platform_data;
 
 extern void gemini_map_io(void);
 extern void gemini_init_irq(void);
@@ -22,6 +23,7 @@ extern void platform_register_rtc(void);
 
 /* Common platform devices registration functions */
 extern int platform_register_uart(void);
+extern int platform_register_ethernet(struct gemini_gmac_platform_data *pdata);
 extern int platform_register_pflash(unsigned int size,
 				    struct mtd_partition *parts,
 				    unsigned int nr_parts);
arch/arm/mach-gemini/devices.c +52 -0

64 lines not on this page · raw message

drivers/net/Kconfig +10 -0
index dc280bc..84718ef 100644
@@ -2071,6 +2071,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 || BROKEN
+	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
index 01b604a..a4f37e0 100644
@@ -259,6 +259,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 +2369 -0

2,369 lines not on this page · raw message

drivers/net/sl351x_hw.h new file +1436 -0

399 lines not on this page · raw message

drivers/rtc/Kconfig +9 -0
index e187887..05f90ba 100644

Lines of this file are not shown. View the raw message.

include/linux/platform_data/gemini_gmac.h new file +21 -0
new file mode 100644
index 0000000..04ca569

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.2.5

Part of the diff is not shown here. View the raw message.

maintainer Acked-by on v5 1/1
#1 lore raw

From: Michał Mirosław <[email protected]>
Date: Sun, 10 Apr 2011 18:05:01 +0200 (CEST)

Quoted 9 lines

In-Reply-To: <[email protected]>

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).

I'm pretty much fine with the networking parts:

but there are so many ARM, RTC, etc. pieces in here that I'd like to ask you to push this through whatever ARM tree is appropriate.

Thanks.