Skip to contentSkip to conversation

Gemini: Gigabit ethernet driver

RFC PATCH Superseded Michał Mirosław 6 participants 11 messages Dec 27, 2010 – Dec 29, 2010

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 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).

---

Hans, please drop previous mail from the gemini-board-dev queue - it had broken headers.

Thanks,
Michał Mirosław

---

This depends on commit 83097f22d1f91a748bb2c066d049d0d1d2843ef2

Gemini: create platform device for ethernet in Raidsonic IB-4220B

from git://git.berlios.de/gemini-board

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)

TODO:
- MTU changing (jumbo frames?)
- use napi_gro_frags()?
- netpoll (netconsole)

 MAINTAINERS             |    9 +
 drivers/net/Kconfig     |   10 +
 drivers/net/Makefile    |    1 +
 drivers/net/sl351x.c    | 1877 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/sl351x_hw.h | 1423 +++++++++++++++++++++++++++++++++++
 5 files changed, 3320 insertions(+), 0 deletions(-)
MAINTAINERS +9 -0
index 71e40f9..694de04 100644
@@ -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
index 4f1755b..0336c4f 100644
@@ -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
index b90738d..2d3491b 100644
@@ -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 +1877 -0

1,877 lines not on this page · raw message

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

1,085 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.

#1 lore raw
Quoted 4 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.

Quoted 8 lines

Tested on Raidsonic IcyBox 4220-B (dual SATA NAS).

---

Hans, please drop previous mail from the gemini-board-dev queue - it had broken headers.

mail is already out.

drivers/net/sl351x.c line 363

Quoted 5 lines
drivers/net/sl351x.c new file +5 -0
+		.dis_tx = 1,
+		.dis_rx = 1,
+		.max_len = 2,	/* magic; 512 << max_len? */
+		.ipv4_rx_chksum = 1,
+		.ipv6_rx_chksum = 1,

This is what I found in some netbsd code for maxlen

#define CONFIG0_MAXLEN_MASK __BITS(8,10)
#define CONFIG0_MAXLEN_GET(x) (((x) >> 8) &
CONFIG0_MAXLEN_MASK)
#define CONFIG0_MAXLEN(x) (((x) &
CONFIG0_MAXLEN_MASK) << 8)
#define CONFIG0_MAXLEN_1536 0
#define CONFIG0_MAXLEN_1518 1
#define CONFIG0_MAXLEN_1522 2
#define CONFIG0_MAXLEN_1548 3
#define CONFIG0_MAXLEN_JUMBO 4

spec. for the SL3616 says jumbo is 9k frames, but i didn't proved this.

BTW:

Why u64_stats ?
I see only a few driver are using u64_stats. vlan, br_device and some intel driver
no gigabit driver for marvell devices uses u64_stats

Ulli

#2 lore raw

On Mon, 2010-12-27 at 20:21 +0100, Hans Ulli Kroll wrote:
[...]

Quoted 6 lines

BTW:

Why u64_stats ?
I see only a few driver are using u64_stats. vlan, br_device and some intel driver
no gigabit driver for marvell devices uses u64_stats

All new net drivers should implement 64-bit stats. net_device_stats is kept for backward compatibility because we couldn't change all the existing drivers at once (it's not a simple change for all of them).

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#3 lore raw

----- Original Message -----

Quoted 9 lines · Hans Ulli Kroll

[...]

Quoted 6 lines

BTW:

Why u64_stats ?
I see only a few driver are using u64_stats. vlan, br_device and some intel driver
no gigabit driver for marvell devices uses u64_stats

Quoted 5 lines

All new net drivers should implement 64-bit stats. net_device_stats is kept for backward compatibility because we couldn't change all the existing drivers at once (it's not a simple change for all of them).

Ben.

BS. drivers with old stats are fine. 64 bit only really matters at higher speed. Anyway, it is the kind of thing that can easily be fixed later after driver is merged.

#4 lore raw
Quoted 16 lines · Stephen Hemminger

----- Original Message -----

Quoted 13 lines · Hans Ulli Kroll

[...]

Quoted 6 lines

BTW:

Why u64_stats ?
I see only a few driver are using u64_stats. vlan, br_device and some intel driver
no gigabit driver for marvell devices uses u64_stats

All new net drivers should implement 64-bit stats. net_device_stats is kept for backward compatibility because we couldn't change all the existing drivers at once (it's not a simple change for all of them).

Quoted 7 lines
Quoted 1 line

Ben.

BS. drivers with old stats are fine. 64 bit only really matters at higher speed. Anyway, it is the kind of thing that can easily be fixed later after driver is merged.

I've readed the Intel driver.

So we must also implement to old net_stats interface, for backward compatibility ?

Ulli

#5 lore raw
Quoted 27 lines · Hans Ulli Kroll
Quoted 16 lines · Stephen Hemminger

----- Original Message -----

Quoted 13 lines · Hans Ulli Kroll

[...]

Quoted 6 lines

BTW:

Why u64_stats ?
I see only a few driver are using u64_stats. vlan, br_device and some intel driver
no gigabit driver for marvell devices uses u64_stats

All new net drivers should implement 64-bit stats. net_device_stats is kept for backward compatibility because we couldn't change all the existing drivers at once (it's not a simple change for all of them).

Quoted 7 lines
Quoted 1 line

Ben.

BS. drivers with old stats are fine. 64 bit only really matters at higher speed. Anyway, it is the kind of thing that can easily be fixed later after driver is merged.

Quoted 4 lines

I've readed the Intel driver.

So we must also implement to old net_stats interface, for backward compatibility ?

If you implement new (64bit) stats, old one is not used at all.

Check net/core/dev.c : dev_get_stats()

If ndo_get_stats64() method is implemented, its called, and legacy interfaces are ignored.

#6 lore raw
Quoted 33 lines · On Wed, 29 Dec 2010 19:30:41 +0100 Eric Dumazet <[email protected]> wrote:
Quoted 27 lines · Hans Ulli Kroll
Quoted 16 lines · Stephen Hemminger

----- Original Message -----

Quoted 13 lines · Hans Ulli Kroll

[...]

Quoted 6 lines

BTW:

Why u64_stats ?
I see only a few driver are using u64_stats. vlan, br_device and some intel driver
no gigabit driver for marvell devices uses u64_stats

All new net drivers should implement 64-bit stats. net_device_stats is kept for backward compatibility because we couldn't change all the existing drivers at once (it's not a simple change for all of them).

Quoted 7 lines
Quoted 1 line

Ben.

BS. drivers with old stats are fine. 64 bit only really matters at higher speed. Anyway, it is the kind of thing that can easily be fixed later after driver is merged.

Quoted 4 lines

I've readed the Intel driver.

So we must also implement to old net_stats interface, for backward compatibility ?

Quoted 6 lines

If you implement new (64bit) stats, old one is not used at all.

Check net/core/dev.c : dev_get_stats()

If ndo_get_stats64() method is implemented, its called, and legacy interfaces are ignored.

It looks like the comment/documentation in netdevice.h is incorrect.

* struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
* Called when a user wants to get the network device usage
* statistics. Drivers must do one of the following:
* 1. Define @ndo_get_stats64 to fill in a zero-initialised
* rtnl_link_stats64 structure passed by the caller.
* 2. Define @ndo_get_stats to update a net_device_stats structure

 *	   (which should normally be dev->stats) and return a pointer to
 *	   it. The structure may be changed asynchronously only if each
 *	   field is written atomically.

* 3. Update dev->stats asynchronously and atomically, and define
* neither operation.

#7 lore raw
Quoted 8 lines · Stephen Hemminger

It looks like the comment/documentation in netdevice.h is incorrect.

* struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
* Called when a user wants to get the network device usage
* statistics. Drivers must do one of the following:
* 1. Define @ndo_get_stats64 to fill in a zero-initialised
* rtnl_link_stats64 structure passed by the caller.
* 2. Define @ndo_get_stats to update a net_device_stats structure

Quoted 6 lines
 *	   (which should normally be dev->stats) and return a pointer to
 *	   it. The structure may be changed asynchronously only if each
 *	   field is written atomically.

* 3. Update dev->stats asynchronously and atomically, and define
* neither operation.

You mean we should insert a new line ?
I believe this documentation is up to date.

include/linux/netdevice.h +3 -1
index cc916c5..3add243 100644
@@ -721,7 +721,9 @@ struct xps_dev_maps {
  *                      struct rtnl_link_stats64 *storage);
  * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
  *	Called when a user wants to get the network device usage
- *	statistics. Drivers must do one of the following:
+ *	statistics.
+ *
+ * Drivers must do one of the following:
  *	1. Define @ndo_get_stats64 to fill in a zero-initialised
  *	   rtnl_link_stats64 structure passed by the caller.
  *	2. Define @ndo_get_stats to update a net_device_stats structure
#8 lore raw
Quoted 26 lines · On Wed, 29 Dec 2010 20:52:26 +0100 Eric Dumazet <[email protected]> wrote:
Quoted 8 lines · Stephen Hemminger

It looks like the comment/documentation in netdevice.h is incorrect.

* struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
* Called when a user wants to get the network device usage
* statistics. Drivers must do one of the following:
* 1. Define @ndo_get_stats64 to fill in a zero-initialised
* rtnl_link_stats64 structure passed by the caller.
* 2. Define @ndo_get_stats to update a net_device_stats structure

Quoted 6 lines
 *	   (which should normally be dev->stats) and return a pointer to
 *	   it. The structure may be changed asynchronously only if each
 *	   field is written atomically.

* 3. Update dev->stats asynchronously and atomically, and define
* neither operation.

You mean we should insert a new line ?
I believe this documentation is up to date.

include/linux/netdevice.h +0 -0
index cc916c5..3add243 100644

include/linux/netdevice.h struct xps_dev_maps { · line 726

Quoted 7 lines
include/linux/netdevice.h +3 -1
@@ -721,7 +721,9 @@ struct xps_dev_maps {
  *                      struct rtnl_link_stats64 *storage);
  * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
  *	Called when a user wants to get the network device usage
- *	statistics. Drivers must do one of the following:
+ *	statistics.
+ *
+ * Drivers must do one of the following:
                     ^
                    only

Need to make it clear that get_stats is not needed if get_stats64 is defined.

#9 lore raw
In reply to Eric Dumazet
Quoted 17 lines · Eric Dumazet
Quoted 8 lines · Stephen Hemminger

It looks like the comment/documentation in netdevice.h is incorrect.

* struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
* Called when a user wants to get the network device usage
* statistics. Drivers must do one of the following:
* 1. Define @ndo_get_stats64 to fill in a zero-initialised
* rtnl_link_stats64 structure passed by the caller.
* 2. Define @ndo_get_stats to update a net_device_stats structure

Quoted 6 lines
 *	   (which should normally be dev->stats) and return a pointer to
 *	   it. The structure may be changed asynchronously only if each
 *	   field is written atomically.

* 3. Update dev->stats asynchronously and atomically, and define
* neither operation.

Quoted 2 lines

You mean we should insert a new line ?
I believe this documentation is up to date.

[...]

It would also be worth explicitly stating that there is no serialisation of calls to these operations, so drivers may need to use a spinlock in their implementation. I wrote this description under the mistaken belief that there was some serialisation, and point 2 reflects that.

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#10 lore raw
In reply to Hans Ulli Kroll
Quoted 20 lines · Hans Ulli Kroll

drivers/net/sl351x.c line 363

Quoted 5 lines · Michał Mirosław
drivers/net/sl351x.c new file +5 -0
+		.dis_tx = 1,
+		.dis_rx = 1,
+		.max_len = 2,	/* magic; 512 << max_len? */
+		.ipv4_rx_chksum = 1,
+		.ipv6_rx_chksum = 1,

This is what I found in some netbsd code for maxlen

#define CONFIG0_MAXLEN_MASK __BITS(8,10)
#define CONFIG0_MAXLEN_GET(x) (((x) >> 8) &
CONFIG0_MAXLEN_MASK)
#define CONFIG0_MAXLEN(x) (((x) &
CONFIG0_MAXLEN_MASK) << 8)
#define CONFIG0_MAXLEN_1536 0
#define CONFIG0_MAXLEN_1518 1
#define CONFIG0_MAXLEN_1522 2
#define CONFIG0_MAXLEN_1548 3
#define CONFIG0_MAXLEN_JUMBO 4

Quoted 1 line

spec. for the SL3616 says jumbo is 9k frames, but i didn't proved this.

This is what I got after quick testing:

max_len rx_max

0       1536
1       1518
2       1522
3       1542
4       9212
5       10236
6       1518
7       1518

rx_max is total packet's length (MAC header + (VLAN) + payload).

Best Regards,
Michał Mirosław