Skip to content

Commit 91da11f

Browse files
buytenhdavem330
authored andcommitted
net: Distributed Switch Architecture protocol support
Distributed Switch Architecture is a protocol for managing hardware switch chips. It consists of a set of MII management registers and commands to configure the switch, and an ethernet header format to signal which of the ports of the switch a packet was received from or is intended to be sent to. The switches that this driver supports are typically embedded in access points and routers, and a typical setup with a DSA switch looks something like this: +-----------+ +-----------+ | | RGMII | | | +-------+ +------ 1000baseT MDI ("WAN") | | | 6-port +------ 1000baseT MDI ("LAN1") | CPU | | ethernet +------ 1000baseT MDI ("LAN2") | |MIImgmt| switch +------ 1000baseT MDI ("LAN3") | +-------+ w/5 PHYs +------ 1000baseT MDI ("LAN4") | | | | +-----------+ +-----------+ The switch driver presents each port on the switch as a separate network interface to Linux, polls the switch to maintain software link state of those ports, forwards MII management interface accesses to those network interfaces (e.g. as done by ethtool) to the switch, and exposes the switch's hardware statistics counters via the appropriate Linux kernel interfaces. This initial patch supports the MII management interface register layout of the Marvell 88E6123, 88E6161 and 88E6165 switch chips, and supports the "Ethertype DSA" packet tagging format. (There is no officially registered ethertype for the Ethertype DSA packet format, so we just grab a random one. The ethertype to use is programmed into the switch, and the switch driver uses the value of ETH_P_EDSA for this, so this define can be changed at any time in the future if the one we chose is allocated to another protocol or if Ethertype DSA gets its own officially registered ethertype, and everything will continue to work.) Signed-off-by: Lennert Buytenhek <[email protected]> Tested-by: Nicolas Pitre <[email protected]> Tested-by: Byron Bradley <[email protected]> Tested-by: Tim Ellis <[email protected]> Tested-by: Peter van Valderen <[email protected]> Tested-by: Dirk Teurlings <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 176eaa5 commit 91da11f

File tree

14 files changed

+1931
-0
lines changed

14 files changed

+1931
-0
lines changed

include/linux/if_ether.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
7878
#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */
7979
#define ETH_P_TIPC 0x88CA /* TIPC */
80+
#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
8081

8182
/*
8283
* Non DIX types. Won't clash for 1500 types.

include/linux/netdevice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ struct net_device
607607

608608
/* Protocol specific pointers */
609609

610+
#ifdef CONFIG_NET_DSA
611+
void *dsa_ptr; /* dsa specific data */
612+
#endif
610613
void *atalk_ptr; /* AppleTalk link */
611614
void *ip_ptr; /* IPv4 specific data */
612615
void *dn_ptr; /* DECnet specific data */

include/net/dsa.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* include/net/dsa.h - Driver for Distributed Switch Architecture switch chips
3+
* Copyright (c) 2008 Marvell Semiconductor
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 2 of the License, or
8+
* (at your option) any later version.
9+
*/
10+
11+
#ifndef __LINUX_NET_DSA_H
12+
#define __LINUX_NET_DSA_H
13+
14+
#define DSA_MAX_PORTS 12
15+
16+
struct dsa_platform_data {
17+
/*
18+
* Reference to a Linux network interface that connects
19+
* to the switch chip.
20+
*/
21+
struct device *netdev;
22+
23+
/*
24+
* How to access the switch configuration registers, and
25+
* the names of the switch ports (use "cpu" to designate
26+
* the switch port that the cpu is connected to).
27+
*/
28+
struct device *mii_bus;
29+
int sw_addr;
30+
char *port_names[DSA_MAX_PORTS];
31+
};
32+
33+
34+
#endif

net/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ source "net/tipc/Kconfig"
180180
source "net/atm/Kconfig"
181181
source "net/802/Kconfig"
182182
source "net/bridge/Kconfig"
183+
source "net/dsa/Kconfig"
183184
source "net/8021q/Kconfig"
184185
source "net/decnet/Kconfig"
185186
source "net/llc/Kconfig"

net/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ obj-$(CONFIG_PACKET) += packet/
2626
obj-$(CONFIG_NET_KEY) += key/
2727
obj-$(CONFIG_NET_SCHED) += sched/
2828
obj-$(CONFIG_BRIDGE) += bridge/
29+
obj-$(CONFIG_NET_DSA) += dsa/
2930
obj-$(CONFIG_IPX) += ipx/
3031
obj-$(CONFIG_ATALK) += appletalk/
3132
obj-$(CONFIG_WAN_ROUTER) += wanrouter/

net/dsa/Kconfig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
menuconfig NET_DSA
2+
bool "Distributed Switch Architecture support"
3+
default n
4+
depends on EXPERIMENTAL
5+
---help---
6+
This allows you to use hardware switch chips that use
7+
the Distributed Switch Architecture.
8+
9+
10+
if NET_DSA
11+
12+
# tagging formats
13+
config NET_DSA_TAG_EDSA
14+
bool
15+
default n
16+
17+
18+
# switch drivers
19+
config NET_DSA_MV88E6XXX
20+
bool
21+
default n
22+
23+
config NET_DSA_MV88E6123_61_65
24+
bool "Marvell 88E6123/6161/6165 ethernet switch chip support"
25+
select NET_DSA_MV88E6XXX
26+
select NET_DSA_TAG_EDSA
27+
---help---
28+
This enables support for the Marvell 88E6123/6161/6165
29+
ethernet switch chips.
30+
31+
endif

net/dsa/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# tagging formats
2+
obj-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
3+
4+
# switch drivers
5+
obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx.o
6+
obj-$(CONFIG_NET_DSA_MV88E6123_61_65) += mv88e6123_61_65.o
7+
8+
# the core
9+
obj-$(CONFIG_NET_DSA) += dsa.o slave.o

0 commit comments

Comments
 (0)