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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
/*
|
|
|
|
* net/dsa/slave.c - Slave device handling
|
dsa: add switch chip cascading support
The initial version of the DSA driver only supported a single switch
chip per network interface, while DSA-capable switch chips can be
interconnected to form a tree of switch chips. This patch adds support
for multiple switch chips on a network interface.
An example topology for a 16-port device with an embedded CPU is as
follows:
+-----+ +--------+ +--------+
| |eth0 10| switch |9 10| switch |
| CPU +----------+ +-------+ |
| | | chip 0 | | chip 1 |
+-----+ +---++---+ +---++---+
|| ||
|| ||
||1000baseT ||1000baseT
||ports 1-8 ||ports 9-16
This requires a couple of interdependent changes in the DSA layer:
- The dsa platform driver data needs to be extended: there is still
only one netdevice per DSA driver instance (eth0 in the example
above), but each of the switch chips in the tree needs its own
mii_bus device pointer, MII management bus address, and port name
array. (include/net/dsa.h) The existing in-tree dsa users need
some small changes to deal with this. (arch/arm)
- The DSA and Ethertype DSA tagging modules need to be extended to
use the DSA device ID field on receive and demultiplex the packet
accordingly, and fill in the DSA device ID field on transmit
according to which switch chip the packet is heading to.
(net/dsa/tag_{dsa,edsa}.c)
- The concept of "CPU port", which is the switch chip port that the
CPU is connected to (port 10 on switch chip 0 in the example), needs
to be extended with the concept of "upstream port", which is the
port on the switch chip that will bring us one hop closer to the CPU
(port 10 for both switch chips in the example above).
- The dsa platform data needs to specify which ports on which switch
chips are links to other switch chips, so that we can enable DSA
tagging mode on them. (For inter-switch links, we always use
non-EtherType DSA tagging, since it has lower overhead. The CPU
link uses dsa or edsa tagging depending on what the 'root' switch
chip supports.) This is done by specifying "dsa" for the given
port in the port array.
- The dsa platform data needs to be extended with information on via
which port to reach any given switch chip from any given switch chip.
This info is specified via the per-switch chip data struct ->rtable[]
array, which gives the nexthop ports for each of the other switches
in the tree.
For the example topology above, the dsa platform data would look
something like this:
static struct dsa_chip_data sw[2] = {
{
.mii_bus = &foo,
.sw_addr = 1,
.port_names[0] = "p1",
.port_names[1] = "p2",
.port_names[2] = "p3",
.port_names[3] = "p4",
.port_names[4] = "p5",
.port_names[5] = "p6",
.port_names[6] = "p7",
.port_names[7] = "p8",
.port_names[9] = "dsa",
.port_names[10] = "cpu",
.rtable = (s8 []){ -1, 9, },
}, {
.mii_bus = &foo,
.sw_addr = 2,
.port_names[0] = "p9",
.port_names[1] = "p10",
.port_names[2] = "p11",
.port_names[3] = "p12",
.port_names[4] = "p13",
.port_names[5] = "p14",
.port_names[6] = "p15",
.port_names[7] = "p16",
.port_names[10] = "dsa",
.rtable = (s8 []){ 10, -1, },
},
},
static struct dsa_platform_data pd = {
.netdev = &foo,
.nr_switches = 2,
.sw = sw,
};
Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Tested-by: Gary Thomas <gary@mlbassoc.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-20 09:52:09 +00:00
|
|
|
* Copyright (c) 2008-2009 Marvell Semiconductor
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
2008-11-11 05:53:12 +00:00
|
|
|
#include <linux/etherdevice.h>
|
2015-02-24 21:15:33 +00:00
|
|
|
#include <linux/netdevice.h>
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
#include <linux/phy.h>
|
2014-10-17 23:02:13 +00:00
|
|
|
#include <linux/phy_fixed.h>
|
2014-08-28 00:04:51 +00:00
|
|
|
#include <linux/of_net.h>
|
|
|
|
#include <linux/of_mdio.h>
|
2016-01-06 19:11:18 +00:00
|
|
|
#include <linux/mdio.h>
|
2015-02-24 21:15:33 +00:00
|
|
|
#include <net/rtnetlink.h>
|
2015-03-16 04:07:15 +00:00
|
|
|
#include <net/switchdev.h>
|
2015-02-24 21:15:33 +00:00
|
|
|
#include <linux/if_bridge.h>
|
2015-07-31 18:42:57 +00:00
|
|
|
#include <linux/netpoll.h>
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
#include "dsa_priv.h"
|
|
|
|
|
|
|
|
/* slave mii_bus handling ***************************************************/
|
|
|
|
static int dsa_slave_phy_read(struct mii_bus *bus, int addr, int reg)
|
|
|
|
{
|
|
|
|
struct dsa_switch *ds = bus->priv;
|
|
|
|
|
2014-08-28 00:04:51 +00:00
|
|
|
if (ds->phys_mii_mask & (1 << addr))
|
2016-08-23 16:38:56 +00:00
|
|
|
return ds->ops->phy_read(ds, addr, reg);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
return 0xffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_phy_write(struct mii_bus *bus, int addr, int reg, u16 val)
|
|
|
|
{
|
|
|
|
struct dsa_switch *ds = bus->priv;
|
|
|
|
|
2014-08-28 00:04:51 +00:00
|
|
|
if (ds->phys_mii_mask & (1 << addr))
|
2016-08-23 16:38:56 +00:00
|
|
|
return ds->ops->phy_write(ds, addr, reg, val);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dsa_slave_mii_bus_init(struct dsa_switch *ds)
|
|
|
|
{
|
|
|
|
ds->slave_mii_bus->priv = (void *)ds;
|
|
|
|
ds->slave_mii_bus->name = "dsa slave smi";
|
|
|
|
ds->slave_mii_bus->read = dsa_slave_phy_read;
|
|
|
|
ds->slave_mii_bus->write = dsa_slave_phy_write;
|
2016-06-07 23:32:38 +00:00
|
|
|
snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d.%d",
|
|
|
|
ds->dst->tree, ds->index);
|
2016-05-10 21:27:23 +00:00
|
|
|
ds->slave_mii_bus->parent = ds->dev;
|
net: dsa: set slave MII bus PHY mask
When registering a mdio bus, Linux assumes than every port has a PHY and tries
to scan it. If a switch port has no PHY registered, DSA will fail to register
the slave MII bus. To fix this, set the slave MII bus PHY mask to the switch
PHYs mask.
As an example, if we use a Marvell MV88E6352 (which is a 7-port switch with no
registered PHYs for port 5 and port 6), with the following declared names:
static struct dsa_chip_data switch_cdata = {
[...]
.port_names[0] = "sw0",
.port_names[1] = "sw1",
.port_names[2] = "sw2",
.port_names[3] = "sw3",
.port_names[4] = "sw4",
.port_names[5] = "cpu",
};
DSA will fail to create the switch instance. With the PHY mask set for the
slave MII bus, only the PHY for ports 0-4 will be scanned and the instance will
be successfully created.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-01-21 00:13:32 +00:00
|
|
|
ds->slave_mii_bus->phy_mask = ~ds->phys_mii_mask;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* slave device handling ****************************************************/
|
2015-04-02 15:07:08 +00:00
|
|
|
static int dsa_slave_get_iflink(const struct net_device *dev)
|
dsa: set ->iflink on slave interfaces to the ifindex of the parent
..so that we can parse the DSA topology from 'ip link' output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
4: lan1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue
5: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
6: lan3@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
7: lan4@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-20 09:49:49 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
return p->dp->ds->dst->master_netdev->ifindex;
|
dsa: set ->iflink on slave interfaces to the ifindex of the parent
..so that we can parse the DSA topology from 'ip link' output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
4: lan1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue
5: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
6: lan3@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
7: lan4@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-20 09:49:49 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 20:29:40 +00:00
|
|
|
static inline bool dsa_port_is_bridged(struct dsa_port *dp)
|
2015-02-24 21:15:33 +00:00
|
|
|
{
|
2017-01-27 20:29:40 +00:00
|
|
|
return !!dp->bridge_dev;
|
2015-02-24 21:15:33 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 20:49:21 +00:00
|
|
|
static void dsa_port_set_stp_state(struct dsa_switch *ds, int port, u8 state)
|
|
|
|
{
|
2016-09-22 20:49:22 +00:00
|
|
|
struct dsa_port *dp = &ds->ports[port];
|
|
|
|
|
2016-09-22 20:49:21 +00:00
|
|
|
if (ds->ops->port_stp_state_set)
|
|
|
|
ds->ops->port_stp_state_set(ds, port, state);
|
2016-09-22 20:49:22 +00:00
|
|
|
|
|
|
|
if (ds->ops->port_fast_age) {
|
|
|
|
/* Fast age FDB entries or flush appropriate forwarding database
|
|
|
|
* for the given port, if we are moving it from Learning or
|
|
|
|
* Forwarding state, to Disabled or Blocking or Listening state.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((dp->stp_state == BR_STATE_LEARNING ||
|
|
|
|
dp->stp_state == BR_STATE_FORWARDING) &&
|
|
|
|
(state == BR_STATE_DISABLED ||
|
|
|
|
state == BR_STATE_BLOCKING ||
|
|
|
|
state == BR_STATE_LISTENING))
|
|
|
|
ds->ops->port_fast_age(ds, port);
|
|
|
|
}
|
|
|
|
|
|
|
|
dp->stp_state = state;
|
2016-09-22 20:49:21 +00:00
|
|
|
}
|
|
|
|
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
static int dsa_slave_open(struct net_device *dev)
|
|
|
|
{
|
2008-11-11 05:53:12 +00:00
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct net_device *master = p->dp->ds->dst->master_netdev;
|
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2017-01-27 20:29:40 +00:00
|
|
|
u8 stp_state = dsa_port_is_bridged(p->dp) ?
|
2015-02-24 21:15:33 +00:00
|
|
|
BR_STATE_BLOCKING : BR_STATE_FORWARDING;
|
2008-11-11 05:53:12 +00:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!(master->flags & IFF_UP))
|
|
|
|
return -ENETDOWN;
|
|
|
|
|
dsa: Convert compare_ether_addr to ether_addr_equal
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Done via cocci script:
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-05-08 18:56:57 +00:00
|
|
|
if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) {
|
2010-04-01 21:22:09 +00:00
|
|
|
err = dev_uc_add(master, dev->dev_addr);
|
2008-11-11 05:53:12 +00:00
|
|
|
if (err < 0)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dev->flags & IFF_ALLMULTI) {
|
|
|
|
err = dev_set_allmulti(master, 1);
|
|
|
|
if (err < 0)
|
|
|
|
goto del_unicast;
|
|
|
|
}
|
|
|
|
if (dev->flags & IFF_PROMISC) {
|
|
|
|
err = dev_set_promiscuity(master, 1);
|
|
|
|
if (err < 0)
|
|
|
|
goto clear_allmulti;
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->port_enable) {
|
2017-01-27 20:29:39 +00:00
|
|
|
err = ds->ops->port_enable(ds, p->dp->index, p->phy);
|
2014-09-25 00:05:18 +00:00
|
|
|
if (err)
|
|
|
|
goto clear_promisc;
|
|
|
|
}
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
dsa_port_set_stp_state(ds, p->dp->index, stp_state);
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2014-09-25 00:05:17 +00:00
|
|
|
if (p->phy)
|
|
|
|
phy_start(p->phy);
|
|
|
|
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
return 0;
|
2008-11-11 05:53:12 +00:00
|
|
|
|
2014-09-25 00:05:18 +00:00
|
|
|
clear_promisc:
|
|
|
|
if (dev->flags & IFF_PROMISC)
|
2015-06-25 13:50:13 +00:00
|
|
|
dev_set_promiscuity(master, -1);
|
2008-11-11 05:53:12 +00:00
|
|
|
clear_allmulti:
|
|
|
|
if (dev->flags & IFF_ALLMULTI)
|
|
|
|
dev_set_allmulti(master, -1);
|
|
|
|
del_unicast:
|
dsa: Convert compare_ether_addr to ether_addr_equal
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Done via cocci script:
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-05-08 18:56:57 +00:00
|
|
|
if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
|
2010-04-01 21:22:09 +00:00
|
|
|
dev_uc_del(master, dev->dev_addr);
|
2008-11-11 05:53:12 +00:00
|
|
|
out:
|
|
|
|
return err;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_close(struct net_device *dev)
|
|
|
|
{
|
2008-11-11 05:53:12 +00:00
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct net_device *master = p->dp->ds->dst->master_netdev;
|
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2008-11-11 05:53:12 +00:00
|
|
|
|
2014-09-25 00:05:17 +00:00
|
|
|
if (p->phy)
|
|
|
|
phy_stop(p->phy);
|
|
|
|
|
2008-11-11 05:53:12 +00:00
|
|
|
dev_mc_unsync(master, dev);
|
2010-04-01 21:22:09 +00:00
|
|
|
dev_uc_unsync(master, dev);
|
2008-11-11 05:53:12 +00:00
|
|
|
if (dev->flags & IFF_ALLMULTI)
|
|
|
|
dev_set_allmulti(master, -1);
|
|
|
|
if (dev->flags & IFF_PROMISC)
|
|
|
|
dev_set_promiscuity(master, -1);
|
|
|
|
|
dsa: Convert compare_ether_addr to ether_addr_equal
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Done via cocci script:
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-05-08 18:56:57 +00:00
|
|
|
if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
|
2010-04-01 21:22:09 +00:00
|
|
|
dev_uc_del(master, dev->dev_addr);
|
2008-11-11 05:53:12 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->port_disable)
|
2017-01-27 20:29:39 +00:00
|
|
|
ds->ops->port_disable(ds, p->dp->index, p->phy);
|
2014-09-25 00:05:18 +00:00
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
dsa_port_set_stp_state(ds, p->dp->index, BR_STATE_DISABLED);
|
2015-02-24 21:15:33 +00:00
|
|
|
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dsa_slave_change_rx_flags(struct net_device *dev, int change)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct net_device *master = p->dp->ds->dst->master_netdev;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
if (change & IFF_ALLMULTI)
|
|
|
|
dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1);
|
|
|
|
if (change & IFF_PROMISC)
|
|
|
|
dev_set_promiscuity(master, dev->flags & IFF_PROMISC ? 1 : -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dsa_slave_set_rx_mode(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct net_device *master = p->dp->ds->dst->master_netdev;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
dev_mc_sync(master, dev);
|
2010-04-01 21:22:09 +00:00
|
|
|
dev_uc_sync(master, dev);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-11 05:53:12 +00:00
|
|
|
static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
{
|
2008-11-11 05:53:12 +00:00
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct net_device *master = p->dp->ds->dst->master_netdev;
|
2008-11-11 05:53:12 +00:00
|
|
|
struct sockaddr *addr = a;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!is_valid_ether_addr(addr->sa_data))
|
|
|
|
return -EADDRNOTAVAIL;
|
|
|
|
|
|
|
|
if (!(dev->flags & IFF_UP))
|
|
|
|
goto out;
|
|
|
|
|
dsa: Convert compare_ether_addr to ether_addr_equal
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Done via cocci script:
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-05-08 18:56:57 +00:00
|
|
|
if (!ether_addr_equal(addr->sa_data, master->dev_addr)) {
|
2010-04-01 21:22:09 +00:00
|
|
|
err = dev_uc_add(master, addr->sa_data);
|
2008-11-11 05:53:12 +00:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
dsa: Convert compare_ether_addr to ether_addr_equal
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Done via cocci script:
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-05-08 18:56:57 +00:00
|
|
|
if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
|
2010-04-01 21:22:09 +00:00
|
|
|
dev_uc_del(master, dev->dev_addr);
|
2008-11-11 05:53:12 +00:00
|
|
|
|
|
|
|
out:
|
2014-01-20 17:52:20 +00:00
|
|
|
ether_addr_copy(dev->dev_addr, addr->sa_data);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-08-13 16:52:17 +00:00
|
|
|
static int dsa_slave_port_vlan_add(struct net_device *dev,
|
2015-10-01 09:03:43 +00:00
|
|
|
const struct switchdev_obj_port_vlan *vlan,
|
2015-09-24 08:02:42 +00:00
|
|
|
struct switchdev_trans *trans)
|
2015-08-13 16:52:17 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_port *dp = p->dp;
|
|
|
|
struct dsa_switch *ds = dp->ds;
|
2015-08-13 16:52:17 +00:00
|
|
|
|
2015-09-24 08:02:48 +00:00
|
|
|
if (switchdev_trans_ph_prepare(trans)) {
|
2016-08-23 16:38:56 +00:00
|
|
|
if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add)
|
2015-08-13 16:52:17 +00:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
return ds->ops->port_vlan_prepare(ds, dp->index, vlan, trans);
|
2015-08-13 16:52:17 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
ds->ops->port_vlan_add(ds, dp->index, vlan, trans);
|
2016-04-06 15:55:05 +00:00
|
|
|
|
2015-08-13 16:52:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_port_vlan_del(struct net_device *dev,
|
2015-10-01 09:03:43 +00:00
|
|
|
const struct switchdev_obj_port_vlan *vlan)
|
2015-08-13 16:52:17 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-08-13 16:52:17 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (!ds->ops->port_vlan_del)
|
2015-08-13 16:52:17 +00:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
return ds->ops->port_vlan_del(ds, p->dp->index, vlan);
|
2015-08-13 16:52:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_port_vlan_dump(struct net_device *dev,
|
2015-10-01 09:03:43 +00:00
|
|
|
struct switchdev_obj_port_vlan *vlan,
|
2015-10-01 09:03:45 +00:00
|
|
|
switchdev_obj_dump_cb_t *cb)
|
2015-08-13 16:52:17 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-08-13 16:52:17 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->port_vlan_dump)
|
2017-01-27 20:29:39 +00:00
|
|
|
return ds->ops->port_vlan_dump(ds, p->dp->index, vlan, cb);
|
2016-02-23 17:13:54 +00:00
|
|
|
|
2016-02-23 17:13:56 +00:00
|
|
|
return -EOPNOTSUPP;
|
2015-08-13 16:52:17 +00:00
|
|
|
}
|
|
|
|
|
2015-08-10 13:09:53 +00:00
|
|
|
static int dsa_slave_port_fdb_add(struct net_device *dev,
|
2015-10-01 09:03:44 +00:00
|
|
|
const struct switchdev_obj_port_fdb *fdb,
|
2015-09-24 08:02:42 +00:00
|
|
|
struct switchdev_trans *trans)
|
2015-08-11 19:00:37 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-10-08 15:35:12 +00:00
|
|
|
|
2016-04-06 15:55:04 +00:00
|
|
|
if (switchdev_trans_ph_prepare(trans)) {
|
2016-08-23 16:38:56 +00:00
|
|
|
if (!ds->ops->port_fdb_prepare || !ds->ops->port_fdb_add)
|
2016-04-06 15:55:04 +00:00
|
|
|
return -EOPNOTSUPP;
|
2015-08-11 19:00:37 +00:00
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
return ds->ops->port_fdb_prepare(ds, p->dp->index, fdb, trans);
|
2016-04-06 15:55:04 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
ds->ops->port_fdb_add(ds, p->dp->index, fdb, trans);
|
2015-08-11 19:00:37 +00:00
|
|
|
|
2016-04-06 15:55:04 +00:00
|
|
|
return 0;
|
2015-08-11 19:00:37 +00:00
|
|
|
}
|
|
|
|
|
2015-08-10 13:09:53 +00:00
|
|
|
static int dsa_slave_port_fdb_del(struct net_device *dev,
|
2015-10-01 09:03:44 +00:00
|
|
|
const struct switchdev_obj_port_fdb *fdb)
|
2015-08-11 19:00:37 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-08-11 19:00:37 +00:00
|
|
|
int ret = -EOPNOTSUPP;
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->port_fdb_del)
|
2017-01-27 20:29:39 +00:00
|
|
|
ret = ds->ops->port_fdb_del(ds, p->dp->index, fdb);
|
2015-08-11 19:00:37 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-08-10 13:09:53 +00:00
|
|
|
static int dsa_slave_port_fdb_dump(struct net_device *dev,
|
2015-10-01 09:03:44 +00:00
|
|
|
struct switchdev_obj_port_fdb *fdb,
|
2015-10-01 09:03:45 +00:00
|
|
|
switchdev_obj_dump_cb_t *cb)
|
2015-08-11 19:00:37 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-08-11 19:00:37 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->port_fdb_dump)
|
2017-01-27 20:29:39 +00:00
|
|
|
return ds->ops->port_fdb_dump(ds, p->dp->index, fdb, cb);
|
2015-10-22 13:34:38 +00:00
|
|
|
|
2015-10-22 13:34:43 +00:00
|
|
|
return -EOPNOTSUPP;
|
2015-08-11 19:00:37 +00:00
|
|
|
}
|
|
|
|
|
2016-08-31 15:50:03 +00:00
|
|
|
static int dsa_slave_port_mdb_add(struct net_device *dev,
|
|
|
|
const struct switchdev_obj_port_mdb *mdb,
|
|
|
|
struct switchdev_trans *trans)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2016-08-31 15:50:03 +00:00
|
|
|
|
|
|
|
if (switchdev_trans_ph_prepare(trans)) {
|
|
|
|
if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
return ds->ops->port_mdb_prepare(ds, p->dp->index, mdb, trans);
|
2016-08-31 15:50:03 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
ds->ops->port_mdb_add(ds, p->dp->index, mdb, trans);
|
2016-08-31 15:50:03 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_port_mdb_del(struct net_device *dev,
|
|
|
|
const struct switchdev_obj_port_mdb *mdb)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2016-08-31 15:50:03 +00:00
|
|
|
|
|
|
|
if (ds->ops->port_mdb_del)
|
2017-01-27 20:29:39 +00:00
|
|
|
return ds->ops->port_mdb_del(ds, p->dp->index, mdb);
|
2016-08-31 15:50:03 +00:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_port_mdb_dump(struct net_device *dev,
|
|
|
|
struct switchdev_obj_port_mdb *mdb,
|
|
|
|
switchdev_obj_dump_cb_t *cb)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2016-08-31 15:50:03 +00:00
|
|
|
|
|
|
|
if (ds->ops->port_mdb_dump)
|
2017-01-27 20:29:39 +00:00
|
|
|
return ds->ops->port_mdb_dump(ds, p->dp->index, mdb, cb);
|
2016-08-31 15:50:03 +00:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
|
|
|
|
|
|
|
if (p->phy != NULL)
|
2010-07-17 08:48:55 +00:00
|
|
|
return phy_mii_ioctl(p->phy, ifr, cmd);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2016-04-06 15:55:03 +00:00
|
|
|
static int dsa_slave_stp_state_set(struct net_device *dev,
|
|
|
|
const struct switchdev_attr *attr,
|
|
|
|
struct switchdev_trans *trans)
|
2015-02-24 21:15:33 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2016-04-06 15:55:03 +00:00
|
|
|
if (switchdev_trans_ph_prepare(trans))
|
2016-08-23 16:38:56 +00:00
|
|
|
return ds->ops->port_stp_state_set ? 0 : -EOPNOTSUPP;
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
dsa_port_set_stp_state(ds, p->dp->index, attr->u.stp_state);
|
2016-04-06 15:55:03 +00:00
|
|
|
|
|
|
|
return 0;
|
2015-02-24 21:15:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-26 18:16:00 +00:00
|
|
|
static int dsa_slave_vlan_filtering(struct net_device *dev,
|
|
|
|
const struct switchdev_attr *attr,
|
|
|
|
struct switchdev_trans *trans)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2016-02-26 18:16:00 +00:00
|
|
|
|
|
|
|
/* bridge skips -EOPNOTSUPP, so skip the prepare phase */
|
|
|
|
if (switchdev_trans_ph_prepare(trans))
|
|
|
|
return 0;
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->port_vlan_filtering)
|
2017-01-27 20:29:39 +00:00
|
|
|
return ds->ops->port_vlan_filtering(ds, p->dp->index,
|
2016-02-26 18:16:00 +00:00
|
|
|
attr->u.vlan_filtering);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-19 00:45:38 +00:00
|
|
|
static int dsa_fastest_ageing_time(struct dsa_switch *ds,
|
|
|
|
unsigned int ageing_time)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2017-01-27 20:29:37 +00:00
|
|
|
for (i = 0; i < ds->num_ports; ++i) {
|
2016-07-19 00:45:38 +00:00
|
|
|
struct dsa_port *dp = &ds->ports[i];
|
|
|
|
|
|
|
|
if (dp && dp->ageing_time && dp->ageing_time < ageing_time)
|
|
|
|
ageing_time = dp->ageing_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ageing_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_ageing_time(struct net_device *dev,
|
|
|
|
const struct switchdev_attr *attr,
|
|
|
|
struct switchdev_trans *trans)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2016-07-19 00:45:38 +00:00
|
|
|
unsigned long ageing_jiffies = clock_t_to_jiffies(attr->u.ageing_time);
|
|
|
|
unsigned int ageing_time = jiffies_to_msecs(ageing_jiffies);
|
|
|
|
|
|
|
|
/* bridge skips -EOPNOTSUPP, so skip the prepare phase */
|
|
|
|
if (switchdev_trans_ph_prepare(trans))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Keep the fastest ageing time in case of multiple bridges */
|
2017-01-27 20:29:39 +00:00
|
|
|
p->dp->ageing_time = ageing_time;
|
2016-07-19 00:45:38 +00:00
|
|
|
ageing_time = dsa_fastest_ageing_time(ds, ageing_time);
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->set_ageing_time)
|
|
|
|
return ds->ops->set_ageing_time(ds, ageing_time);
|
2016-07-19 00:45:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-10 16:47:51 +00:00
|
|
|
static int dsa_slave_port_attr_set(struct net_device *dev,
|
2015-10-14 17:40:49 +00:00
|
|
|
const struct switchdev_attr *attr,
|
2015-09-24 08:02:41 +00:00
|
|
|
struct switchdev_trans *trans)
|
2015-05-10 16:47:51 +00:00
|
|
|
{
|
2015-09-29 16:38:36 +00:00
|
|
|
int ret;
|
2015-05-10 16:47:51 +00:00
|
|
|
|
|
|
|
switch (attr->id) {
|
2015-10-01 09:03:42 +00:00
|
|
|
case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
|
2016-04-06 15:55:03 +00:00
|
|
|
ret = dsa_slave_stp_state_set(dev, attr, trans);
|
2015-05-10 16:47:51 +00:00
|
|
|
break;
|
2016-02-26 18:16:00 +00:00
|
|
|
case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
|
|
|
|
ret = dsa_slave_vlan_filtering(dev, attr, trans);
|
|
|
|
break;
|
2016-07-19 00:45:38 +00:00
|
|
|
case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
|
|
|
|
ret = dsa_slave_ageing_time(dev, attr, trans);
|
|
|
|
break;
|
2015-05-10 16:47:51 +00:00
|
|
|
default:
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-08-10 13:09:53 +00:00
|
|
|
static int dsa_slave_port_obj_add(struct net_device *dev,
|
2015-10-01 09:03:45 +00:00
|
|
|
const struct switchdev_obj *obj,
|
2015-09-24 08:02:41 +00:00
|
|
|
struct switchdev_trans *trans)
|
2015-08-10 13:09:53 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
/* For the prepare phase, ensure the full set of changes is feasable in
|
|
|
|
* one go in order to signal a failure properly. If an operation is not
|
|
|
|
* supported, return -EOPNOTSUPP.
|
|
|
|
*/
|
|
|
|
|
2015-10-01 09:03:46 +00:00
|
|
|
switch (obj->id) {
|
2015-10-01 09:03:41 +00:00
|
|
|
case SWITCHDEV_OBJ_ID_PORT_FDB:
|
2015-10-01 09:03:45 +00:00
|
|
|
err = dsa_slave_port_fdb_add(dev,
|
|
|
|
SWITCHDEV_OBJ_PORT_FDB(obj),
|
|
|
|
trans);
|
2015-08-10 13:09:53 +00:00
|
|
|
break;
|
2016-08-31 15:50:03 +00:00
|
|
|
case SWITCHDEV_OBJ_ID_PORT_MDB:
|
|
|
|
err = dsa_slave_port_mdb_add(dev, SWITCHDEV_OBJ_PORT_MDB(obj),
|
|
|
|
trans);
|
|
|
|
break;
|
2015-10-01 09:03:41 +00:00
|
|
|
case SWITCHDEV_OBJ_ID_PORT_VLAN:
|
2015-10-01 09:03:45 +00:00
|
|
|
err = dsa_slave_port_vlan_add(dev,
|
|
|
|
SWITCHDEV_OBJ_PORT_VLAN(obj),
|
|
|
|
trans);
|
2015-08-13 16:52:17 +00:00
|
|
|
break;
|
2015-08-10 13:09:53 +00:00
|
|
|
default:
|
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_port_obj_del(struct net_device *dev,
|
2015-10-01 09:03:45 +00:00
|
|
|
const struct switchdev_obj *obj)
|
2015-08-10 13:09:53 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2015-10-01 09:03:46 +00:00
|
|
|
switch (obj->id) {
|
2015-10-01 09:03:41 +00:00
|
|
|
case SWITCHDEV_OBJ_ID_PORT_FDB:
|
2015-10-01 09:03:45 +00:00
|
|
|
err = dsa_slave_port_fdb_del(dev,
|
|
|
|
SWITCHDEV_OBJ_PORT_FDB(obj));
|
2015-08-10 13:09:53 +00:00
|
|
|
break;
|
2016-08-31 15:50:03 +00:00
|
|
|
case SWITCHDEV_OBJ_ID_PORT_MDB:
|
|
|
|
err = dsa_slave_port_mdb_del(dev, SWITCHDEV_OBJ_PORT_MDB(obj));
|
|
|
|
break;
|
2015-10-01 09:03:41 +00:00
|
|
|
case SWITCHDEV_OBJ_ID_PORT_VLAN:
|
2015-10-01 09:03:45 +00:00
|
|
|
err = dsa_slave_port_vlan_del(dev,
|
|
|
|
SWITCHDEV_OBJ_PORT_VLAN(obj));
|
2015-08-13 16:52:17 +00:00
|
|
|
break;
|
2015-08-10 13:09:53 +00:00
|
|
|
default:
|
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_port_obj_dump(struct net_device *dev,
|
2015-10-01 09:03:45 +00:00
|
|
|
struct switchdev_obj *obj,
|
|
|
|
switchdev_obj_dump_cb_t *cb)
|
2015-08-10 13:09:53 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2015-10-01 09:03:46 +00:00
|
|
|
switch (obj->id) {
|
2015-10-01 09:03:41 +00:00
|
|
|
case SWITCHDEV_OBJ_ID_PORT_FDB:
|
2015-10-01 09:03:45 +00:00
|
|
|
err = dsa_slave_port_fdb_dump(dev,
|
|
|
|
SWITCHDEV_OBJ_PORT_FDB(obj),
|
|
|
|
cb);
|
2015-08-10 13:09:53 +00:00
|
|
|
break;
|
2016-08-31 15:50:03 +00:00
|
|
|
case SWITCHDEV_OBJ_ID_PORT_MDB:
|
|
|
|
err = dsa_slave_port_mdb_dump(dev, SWITCHDEV_OBJ_PORT_MDB(obj),
|
|
|
|
cb);
|
|
|
|
break;
|
2015-10-01 09:03:41 +00:00
|
|
|
case SWITCHDEV_OBJ_ID_PORT_VLAN:
|
2015-10-01 09:03:45 +00:00
|
|
|
err = dsa_slave_port_vlan_dump(dev,
|
|
|
|
SWITCHDEV_OBJ_PORT_VLAN(obj),
|
|
|
|
cb);
|
2015-08-13 16:52:17 +00:00
|
|
|
break;
|
2015-08-10 13:09:53 +00:00
|
|
|
default:
|
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2015-02-24 21:15:33 +00:00
|
|
|
static int dsa_slave_bridge_port_join(struct net_device *dev,
|
|
|
|
struct net_device *br)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-02-24 21:15:33 +00:00
|
|
|
int ret = -EOPNOTSUPP;
|
|
|
|
|
2017-01-27 20:29:40 +00:00
|
|
|
p->dp->bridge_dev = br;
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->port_bridge_join)
|
2017-01-27 20:29:39 +00:00
|
|
|
ret = ds->ops->port_bridge_join(ds, p->dp->index, br);
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2016-03-13 20:21:34 +00:00
|
|
|
return ret == -EOPNOTSUPP ? 0 : ret;
|
2015-02-24 21:15:33 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 20:29:41 +00:00
|
|
|
static void dsa_slave_bridge_port_leave(struct net_device *dev,
|
|
|
|
struct net_device *br)
|
2015-02-24 21:15:33 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2017-01-27 20:29:41 +00:00
|
|
|
p->dp->bridge_dev = NULL;
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->port_bridge_leave)
|
2017-01-27 20:29:41 +00:00
|
|
|
ds->ops->port_bridge_leave(ds, p->dp->index, br);
|
2015-02-24 21:15:33 +00:00
|
|
|
|
|
|
|
/* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer,
|
|
|
|
* so allow it to be in BR_STATE_FORWARDING to be kept functional
|
|
|
|
*/
|
2017-01-27 20:29:39 +00:00
|
|
|
dsa_port_set_stp_state(ds, p->dp->index, BR_STATE_FORWARDING);
|
2015-02-24 21:15:33 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 16:47:49 +00:00
|
|
|
static int dsa_slave_port_attr_get(struct net_device *dev,
|
|
|
|
struct switchdev_attr *attr)
|
2015-02-24 21:15:33 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2015-05-10 16:47:49 +00:00
|
|
|
switch (attr->id) {
|
2015-10-01 09:03:42 +00:00
|
|
|
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
|
2015-05-13 18:16:50 +00:00
|
|
|
attr->u.ppid.id_len = sizeof(ds->index);
|
|
|
|
memcpy(&attr->u.ppid.id, &ds->index, attr->u.ppid.id_len);
|
2015-05-10 16:47:49 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2015-02-24 21:15:33 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-31 18:42:57 +00:00
|
|
|
static inline netdev_tx_t dsa_netpoll_send_skb(struct dsa_slave_priv *p,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_NET_POLL_CONTROLLER
|
|
|
|
if (p->netpoll)
|
|
|
|
netpoll_send_skb(p->netpoll, skb);
|
|
|
|
#else
|
|
|
|
BUG();
|
|
|
|
#endif
|
|
|
|
return NETDEV_TX_OK;
|
|
|
|
}
|
|
|
|
|
2014-08-28 00:04:46 +00:00
|
|
|
static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2015-07-31 18:42:56 +00:00
|
|
|
struct sk_buff *nskb;
|
2014-08-28 00:04:46 +00:00
|
|
|
|
2015-07-31 18:42:56 +00:00
|
|
|
dev->stats.tx_packets++;
|
|
|
|
dev->stats.tx_bytes += skb->len;
|
2014-08-28 00:04:46 +00:00
|
|
|
|
2015-07-31 18:42:56 +00:00
|
|
|
/* Transmit function may have to reallocate the original SKB */
|
|
|
|
nskb = p->xmit(skb, dev);
|
|
|
|
if (!nskb)
|
|
|
|
return NETDEV_TX_OK;
|
2014-08-28 00:04:52 +00:00
|
|
|
|
2015-07-31 18:42:57 +00:00
|
|
|
/* SKB for netpoll still need to be mangled with the protocol-specific
|
|
|
|
* tag to be successfully transmitted
|
|
|
|
*/
|
|
|
|
if (unlikely(netpoll_tx_running(dev)))
|
|
|
|
return dsa_netpoll_send_skb(p, nskb);
|
|
|
|
|
2015-07-31 18:42:56 +00:00
|
|
|
/* Queue the SKB for transmission on the parent interface, but
|
|
|
|
* do not modify its EtherType
|
|
|
|
*/
|
2017-01-27 20:29:39 +00:00
|
|
|
nskb->dev = p->dp->ds->dst->master_netdev;
|
2015-07-31 18:42:56 +00:00
|
|
|
dev_queue_xmit(nskb);
|
2014-08-28 00:04:52 +00:00
|
|
|
|
|
|
|
return NETDEV_TX_OK;
|
|
|
|
}
|
|
|
|
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
/* ethtool operations *******************************************************/
|
|
|
|
static int
|
2016-10-09 15:00:53 +00:00
|
|
|
dsa_slave_get_link_ksettings(struct net_device *dev,
|
|
|
|
struct ethtool_link_ksettings *cmd)
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
if (p->phy != NULL) {
|
|
|
|
err = phy_read_status(p->phy);
|
|
|
|
if (err == 0)
|
2016-10-09 15:00:53 +00:00
|
|
|
err = phy_ethtool_ksettings_get(p->phy, cmd);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-10-09 15:00:53 +00:00
|
|
|
dsa_slave_set_link_ksettings(struct net_device *dev,
|
|
|
|
const struct ethtool_link_ksettings *cmd)
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
|
|
|
|
|
|
|
if (p->phy != NULL)
|
2016-10-09 15:00:53 +00:00
|
|
|
return phy_ethtool_ksettings_set(p->phy, cmd);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dsa_slave_get_drvinfo(struct net_device *dev,
|
|
|
|
struct ethtool_drvinfo *drvinfo)
|
|
|
|
{
|
2013-01-06 00:44:26 +00:00
|
|
|
strlcpy(drvinfo->driver, "dsa", sizeof(drvinfo->driver));
|
|
|
|
strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
|
|
|
|
strlcpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info));
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
2014-10-29 17:45:04 +00:00
|
|
|
static int dsa_slave_get_regs_len(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-10-29 17:45:04 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->get_regs_len)
|
2017-01-27 20:29:39 +00:00
|
|
|
return ds->ops->get_regs_len(ds, p->dp->index);
|
2014-10-29 17:45:04 +00:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dsa_slave_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *_p)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-10-29 17:45:04 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->get_regs)
|
2017-01-27 20:29:39 +00:00
|
|
|
ds->ops->get_regs(ds, p->dp->index, regs, _p);
|
2014-10-29 17:45:04 +00:00
|
|
|
}
|
|
|
|
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
static int dsa_slave_nway_reset(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
|
|
|
|
|
|
|
if (p->phy != NULL)
|
|
|
|
return genphy_restart_aneg(p->phy);
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 dsa_slave_get_link(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
|
|
|
|
|
|
|
if (p->phy != NULL) {
|
|
|
|
genphy_update_link(p->phy);
|
|
|
|
return p->phy->link;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2014-10-29 17:45:01 +00:00
|
|
|
static int dsa_slave_get_eeprom_len(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-10-29 17:45:01 +00:00
|
|
|
|
2016-06-04 19:16:52 +00:00
|
|
|
if (ds->cd && ds->cd->eeprom_len)
|
2016-05-10 21:27:24 +00:00
|
|
|
return ds->cd->eeprom_len;
|
2014-10-29 17:45:01 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->get_eeprom_len)
|
|
|
|
return ds->ops->get_eeprom_len(ds);
|
2014-10-29 17:45:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_get_eeprom(struct net_device *dev,
|
|
|
|
struct ethtool_eeprom *eeprom, u8 *data)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-10-29 17:45:01 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->get_eeprom)
|
|
|
|
return ds->ops->get_eeprom(ds, eeprom, data);
|
2014-10-29 17:45:01 +00:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_set_eeprom(struct net_device *dev,
|
|
|
|
struct ethtool_eeprom *eeprom, u8 *data)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-10-29 17:45:01 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->set_eeprom)
|
|
|
|
return ds->ops->set_eeprom(ds, eeprom, data);
|
2014-10-29 17:45:01 +00:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
static void dsa_slave_get_strings(struct net_device *dev,
|
|
|
|
uint32_t stringset, uint8_t *data)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
if (stringset == ETH_SS_STATS) {
|
|
|
|
int len = ETH_GSTRING_LEN;
|
|
|
|
|
|
|
|
strncpy(data, "tx_packets", len);
|
|
|
|
strncpy(data + len, "tx_bytes", len);
|
|
|
|
strncpy(data + 2 * len, "rx_packets", len);
|
|
|
|
strncpy(data + 3 * len, "rx_bytes", len);
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->get_strings)
|
2017-01-27 20:29:39 +00:00
|
|
|
ds->ops->get_strings(ds, p->dp->index, data + 4 * len);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
net: dsa: Provide CPU port statistics to master netdev
This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
include switch-side statistics, which is useful for debugging purposes,
when the switch is not properly connected to the Ethernet MAC (duplex
mismatch, (RG)MII electrical issues etc.).
We accomplish this by retaining the original copy of the master netdev's
ethtool_ops, and just overload the 3 operations we care about:
get_sset_count, get_strings and get_ethtool_stats so as to intercept
these calls and call into the original master_netdev ethtool_ops, plus
our own.
We take this approach as opposed to providing a set of DSA helper
functions that would retrive the CPU port's statistics, because the
entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
used as CPU conduit interfaces, therefore, statistics overlay in such
drivers would simply not scale.
The new ethtool -S <iface> output would therefore look like this now:
<iface> statistics
p<2 digits cpu port number>_<switch MIB counter names>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-27 18:45:14 +00:00
|
|
|
static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
|
|
|
|
struct ethtool_stats *stats,
|
|
|
|
uint64_t *data)
|
|
|
|
{
|
|
|
|
struct dsa_switch_tree *dst = dev->dsa_ptr;
|
2017-01-18 01:41:39 +00:00
|
|
|
struct dsa_switch *ds = dst->cpu_switch;
|
net: dsa: Provide CPU port statistics to master netdev
This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
include switch-side statistics, which is useful for debugging purposes,
when the switch is not properly connected to the Ethernet MAC (duplex
mismatch, (RG)MII electrical issues etc.).
We accomplish this by retaining the original copy of the master netdev's
ethtool_ops, and just overload the 3 operations we care about:
get_sset_count, get_strings and get_ethtool_stats so as to intercept
these calls and call into the original master_netdev ethtool_ops, plus
our own.
We take this approach as opposed to providing a set of DSA helper
functions that would retrive the CPU port's statistics, because the
entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
used as CPU conduit interfaces, therefore, statistics overlay in such
drivers would simply not scale.
The new ethtool -S <iface> output would therefore look like this now:
<iface> statistics
p<2 digits cpu port number>_<switch MIB counter names>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-27 18:45:14 +00:00
|
|
|
s8 cpu_port = dst->cpu_port;
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if (dst->master_ethtool_ops.get_sset_count) {
|
|
|
|
count = dst->master_ethtool_ops.get_sset_count(dev,
|
|
|
|
ETH_SS_STATS);
|
|
|
|
dst->master_ethtool_ops.get_ethtool_stats(dev, stats, data);
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->get_ethtool_stats)
|
|
|
|
ds->ops->get_ethtool_stats(ds, cpu_port, data + count);
|
net: dsa: Provide CPU port statistics to master netdev
This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
include switch-side statistics, which is useful for debugging purposes,
when the switch is not properly connected to the Ethernet MAC (duplex
mismatch, (RG)MII electrical issues etc.).
We accomplish this by retaining the original copy of the master netdev's
ethtool_ops, and just overload the 3 operations we care about:
get_sset_count, get_strings and get_ethtool_stats so as to intercept
these calls and call into the original master_netdev ethtool_ops, plus
our own.
We take this approach as opposed to providing a set of DSA helper
functions that would retrive the CPU port's statistics, because the
entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
used as CPU conduit interfaces, therefore, statistics overlay in such
drivers would simply not scale.
The new ethtool -S <iface> output would therefore look like this now:
<iface> statistics
p<2 digits cpu port number>_<switch MIB counter names>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-27 18:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset)
|
|
|
|
{
|
|
|
|
struct dsa_switch_tree *dst = dev->dsa_ptr;
|
2017-01-18 01:41:39 +00:00
|
|
|
struct dsa_switch *ds = dst->cpu_switch;
|
net: dsa: Provide CPU port statistics to master netdev
This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
include switch-side statistics, which is useful for debugging purposes,
when the switch is not properly connected to the Ethernet MAC (duplex
mismatch, (RG)MII electrical issues etc.).
We accomplish this by retaining the original copy of the master netdev's
ethtool_ops, and just overload the 3 operations we care about:
get_sset_count, get_strings and get_ethtool_stats so as to intercept
these calls and call into the original master_netdev ethtool_ops, plus
our own.
We take this approach as opposed to providing a set of DSA helper
functions that would retrive the CPU port's statistics, because the
entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
used as CPU conduit interfaces, therefore, statistics overlay in such
drivers would simply not scale.
The new ethtool -S <iface> output would therefore look like this now:
<iface> statistics
p<2 digits cpu port number>_<switch MIB counter names>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-27 18:45:14 +00:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if (dst->master_ethtool_ops.get_sset_count)
|
|
|
|
count += dst->master_ethtool_ops.get_sset_count(dev, sset);
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (sset == ETH_SS_STATS && ds->ops->get_sset_count)
|
|
|
|
count += ds->ops->get_sset_count(ds);
|
net: dsa: Provide CPU port statistics to master netdev
This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
include switch-side statistics, which is useful for debugging purposes,
when the switch is not properly connected to the Ethernet MAC (duplex
mismatch, (RG)MII electrical issues etc.).
We accomplish this by retaining the original copy of the master netdev's
ethtool_ops, and just overload the 3 operations we care about:
get_sset_count, get_strings and get_ethtool_stats so as to intercept
these calls and call into the original master_netdev ethtool_ops, plus
our own.
We take this approach as opposed to providing a set of DSA helper
functions that would retrive the CPU port's statistics, because the
entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
used as CPU conduit interfaces, therefore, statistics overlay in such
drivers would simply not scale.
The new ethtool -S <iface> output would therefore look like this now:
<iface> statistics
p<2 digits cpu port number>_<switch MIB counter names>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-27 18:45:14 +00:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dsa_cpu_port_get_strings(struct net_device *dev,
|
|
|
|
uint32_t stringset, uint8_t *data)
|
|
|
|
{
|
|
|
|
struct dsa_switch_tree *dst = dev->dsa_ptr;
|
2017-01-18 01:41:39 +00:00
|
|
|
struct dsa_switch *ds = dst->cpu_switch;
|
net: dsa: Provide CPU port statistics to master netdev
This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
include switch-side statistics, which is useful for debugging purposes,
when the switch is not properly connected to the Ethernet MAC (duplex
mismatch, (RG)MII electrical issues etc.).
We accomplish this by retaining the original copy of the master netdev's
ethtool_ops, and just overload the 3 operations we care about:
get_sset_count, get_strings and get_ethtool_stats so as to intercept
these calls and call into the original master_netdev ethtool_ops, plus
our own.
We take this approach as opposed to providing a set of DSA helper
functions that would retrive the CPU port's statistics, because the
entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
used as CPU conduit interfaces, therefore, statistics overlay in such
drivers would simply not scale.
The new ethtool -S <iface> output would therefore look like this now:
<iface> statistics
p<2 digits cpu port number>_<switch MIB counter names>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-27 18:45:14 +00:00
|
|
|
s8 cpu_port = dst->cpu_port;
|
|
|
|
int len = ETH_GSTRING_LEN;
|
|
|
|
int mcount = 0, count;
|
|
|
|
unsigned int i;
|
|
|
|
uint8_t pfx[4];
|
|
|
|
uint8_t *ndata;
|
|
|
|
|
|
|
|
snprintf(pfx, sizeof(pfx), "p%.2d", cpu_port);
|
|
|
|
/* We do not want to be NULL-terminated, since this is a prefix */
|
|
|
|
pfx[sizeof(pfx) - 1] = '_';
|
|
|
|
|
|
|
|
if (dst->master_ethtool_ops.get_sset_count) {
|
|
|
|
mcount = dst->master_ethtool_ops.get_sset_count(dev,
|
|
|
|
ETH_SS_STATS);
|
|
|
|
dst->master_ethtool_ops.get_strings(dev, stringset, data);
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (stringset == ETH_SS_STATS && ds->ops->get_strings) {
|
net: dsa: Provide CPU port statistics to master netdev
This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
include switch-side statistics, which is useful for debugging purposes,
when the switch is not properly connected to the Ethernet MAC (duplex
mismatch, (RG)MII electrical issues etc.).
We accomplish this by retaining the original copy of the master netdev's
ethtool_ops, and just overload the 3 operations we care about:
get_sset_count, get_strings and get_ethtool_stats so as to intercept
these calls and call into the original master_netdev ethtool_ops, plus
our own.
We take this approach as opposed to providing a set of DSA helper
functions that would retrive the CPU port's statistics, because the
entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
used as CPU conduit interfaces, therefore, statistics overlay in such
drivers would simply not scale.
The new ethtool -S <iface> output would therefore look like this now:
<iface> statistics
p<2 digits cpu port number>_<switch MIB counter names>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-27 18:45:14 +00:00
|
|
|
ndata = data + mcount * len;
|
|
|
|
/* This function copies ETH_GSTRINGS_LEN bytes, we will mangle
|
|
|
|
* the output after to prepend our CPU port prefix we
|
|
|
|
* constructed earlier
|
|
|
|
*/
|
2016-08-23 16:38:56 +00:00
|
|
|
ds->ops->get_strings(ds, cpu_port, ndata);
|
|
|
|
count = ds->ops->get_sset_count(ds);
|
net: dsa: Provide CPU port statistics to master netdev
This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
include switch-side statistics, which is useful for debugging purposes,
when the switch is not properly connected to the Ethernet MAC (duplex
mismatch, (RG)MII electrical issues etc.).
We accomplish this by retaining the original copy of the master netdev's
ethtool_ops, and just overload the 3 operations we care about:
get_sset_count, get_strings and get_ethtool_stats so as to intercept
these calls and call into the original master_netdev ethtool_ops, plus
our own.
We take this approach as opposed to providing a set of DSA helper
functions that would retrive the CPU port's statistics, because the
entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
used as CPU conduit interfaces, therefore, statistics overlay in such
drivers would simply not scale.
The new ethtool -S <iface> output would therefore look like this now:
<iface> statistics
p<2 digits cpu port number>_<switch MIB counter names>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-27 18:45:14 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
memmove(ndata + (i * len + sizeof(pfx)),
|
|
|
|
ndata + i * len, len - sizeof(pfx));
|
|
|
|
memcpy(ndata + i * len, pfx, sizeof(pfx));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
static void dsa_slave_get_ethtool_stats(struct net_device *dev,
|
|
|
|
struct ethtool_stats *stats,
|
|
|
|
uint64_t *data)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
2016-04-18 20:10:24 +00:00
|
|
|
data[0] = dev->stats.tx_packets;
|
|
|
|
data[1] = dev->stats.tx_bytes;
|
|
|
|
data[2] = dev->stats.rx_packets;
|
|
|
|
data[3] = dev->stats.rx_bytes;
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->get_ethtool_stats)
|
2017-01-27 20:29:39 +00:00
|
|
|
ds->ops->get_ethtool_stats(ds, p->dp->index, data + 4);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_get_sset_count(struct net_device *dev, int sset)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
if (sset == ETH_SS_STATS) {
|
|
|
|
int count;
|
|
|
|
|
|
|
|
count = 4;
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->get_sset_count)
|
|
|
|
count += ds->ops->get_sset_count(ds);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2014-09-19 00:31:24 +00:00
|
|
|
static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-09-19 00:31:24 +00:00
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->get_wol)
|
2017-01-27 20:29:39 +00:00
|
|
|
ds->ops->get_wol(ds, p->dp->index, w);
|
2014-09-19 00:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-09-19 00:31:24 +00:00
|
|
|
int ret = -EOPNOTSUPP;
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->set_wol)
|
2017-01-27 20:29:39 +00:00
|
|
|
ret = ds->ops->set_wol(ds, p->dp->index, w);
|
2014-09-19 00:31:24 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-09-25 00:05:21 +00:00
|
|
|
static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-09-25 00:05:21 +00:00
|
|
|
int ret;
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (!ds->ops->set_eee)
|
2014-09-25 00:05:21 +00:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
ret = ds->ops->set_eee(ds, p->dp->index, p->phy, e);
|
2014-09-25 00:05:21 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (p->phy)
|
|
|
|
ret = phy_ethtool_set_eee(p->phy, e);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-09-25 00:05:21 +00:00
|
|
|
int ret;
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (!ds->ops->get_eee)
|
2014-09-25 00:05:21 +00:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
ret = ds->ops->get_eee(ds, p->dp->index, e);
|
2014-09-25 00:05:21 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (p->phy)
|
|
|
|
ret = phy_ethtool_get_eee(p->phy, e);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-07-31 18:42:57 +00:00
|
|
|
#ifdef CONFIG_NET_POLL_CONTROLLER
|
|
|
|
static int dsa_slave_netpoll_setup(struct net_device *dev,
|
|
|
|
struct netpoll_info *ni)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-07-31 18:42:57 +00:00
|
|
|
struct net_device *master = ds->dst->master_netdev;
|
|
|
|
struct netpoll *netpoll;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
netpoll = kzalloc(sizeof(*netpoll), GFP_KERNEL);
|
|
|
|
if (!netpoll)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
err = __netpoll_setup(netpoll, master);
|
|
|
|
if (err) {
|
|
|
|
kfree(netpoll);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
p->netpoll = netpoll;
|
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dsa_slave_netpoll_cleanup(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
|
|
|
struct netpoll *netpoll = p->netpoll;
|
|
|
|
|
|
|
|
if (!netpoll)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p->netpoll = NULL;
|
|
|
|
|
|
|
|
__netpoll_free_async(netpoll);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dsa_slave_poll_controller(struct net_device *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-01-10 20:32:36 +00:00
|
|
|
static int dsa_slave_get_phys_port_name(struct net_device *dev,
|
|
|
|
char *name, size_t len)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
if (snprintf(name, len, "p%d", p->dp->index) >= len)
|
2017-01-10 20:32:36 +00:00
|
|
|
return -EINVAL;
|
2016-12-29 22:20:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-07 23:32:41 +00:00
|
|
|
void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops)
|
|
|
|
{
|
|
|
|
ops->get_sset_count = dsa_cpu_port_get_sset_count;
|
|
|
|
ops->get_ethtool_stats = dsa_cpu_port_get_ethtool_stats;
|
|
|
|
ops->get_strings = dsa_cpu_port_get_strings;
|
|
|
|
}
|
|
|
|
|
2017-01-30 17:48:40 +00:00
|
|
|
static int dsa_slave_get_rxnfc(struct net_device *dev,
|
|
|
|
struct ethtool_rxnfc *nfc, u32 *rule_locs)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
|
|
|
|
|
|
|
if (!ds->ops->get_rxnfc)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return ds->ops->get_rxnfc(ds, p->dp->index, nfc, rule_locs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dsa_slave_set_rxnfc(struct net_device *dev,
|
|
|
|
struct ethtool_rxnfc *nfc)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
|
|
|
|
|
|
|
if (!ds->ops->set_rxnfc)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return ds->ops->set_rxnfc(ds, p->dp->index, nfc);
|
|
|
|
}
|
|
|
|
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
static const struct ethtool_ops dsa_slave_ethtool_ops = {
|
|
|
|
.get_drvinfo = dsa_slave_get_drvinfo,
|
2014-10-29 17:45:04 +00:00
|
|
|
.get_regs_len = dsa_slave_get_regs_len,
|
|
|
|
.get_regs = dsa_slave_get_regs,
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
.nway_reset = dsa_slave_nway_reset,
|
|
|
|
.get_link = dsa_slave_get_link,
|
2014-10-29 17:45:01 +00:00
|
|
|
.get_eeprom_len = dsa_slave_get_eeprom_len,
|
|
|
|
.get_eeprom = dsa_slave_get_eeprom,
|
|
|
|
.set_eeprom = dsa_slave_set_eeprom,
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
.get_strings = dsa_slave_get_strings,
|
|
|
|
.get_ethtool_stats = dsa_slave_get_ethtool_stats,
|
|
|
|
.get_sset_count = dsa_slave_get_sset_count,
|
2014-09-19 00:31:24 +00:00
|
|
|
.set_wol = dsa_slave_set_wol,
|
|
|
|
.get_wol = dsa_slave_get_wol,
|
2014-09-25 00:05:21 +00:00
|
|
|
.set_eee = dsa_slave_set_eee,
|
|
|
|
.get_eee = dsa_slave_get_eee,
|
2016-10-09 15:00:53 +00:00
|
|
|
.get_link_ksettings = dsa_slave_get_link_ksettings,
|
|
|
|
.set_link_ksettings = dsa_slave_set_link_ksettings,
|
2017-01-30 17:48:40 +00:00
|
|
|
.get_rxnfc = dsa_slave_get_rxnfc,
|
|
|
|
.set_rxnfc = dsa_slave_set_rxnfc,
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
};
|
|
|
|
|
2014-08-28 00:04:46 +00:00
|
|
|
static const struct net_device_ops dsa_slave_netdev_ops = {
|
2009-01-07 00:45:26 +00:00
|
|
|
.ndo_open = dsa_slave_open,
|
|
|
|
.ndo_stop = dsa_slave_close,
|
2014-08-28 00:04:46 +00:00
|
|
|
.ndo_start_xmit = dsa_slave_xmit,
|
2009-01-07 00:45:26 +00:00
|
|
|
.ndo_change_rx_flags = dsa_slave_change_rx_flags,
|
|
|
|
.ndo_set_rx_mode = dsa_slave_set_rx_mode,
|
|
|
|
.ndo_set_mac_address = dsa_slave_set_mac_address,
|
2015-08-10 13:09:53 +00:00
|
|
|
.ndo_fdb_add = switchdev_port_fdb_add,
|
|
|
|
.ndo_fdb_del = switchdev_port_fdb_del,
|
|
|
|
.ndo_fdb_dump = switchdev_port_fdb_dump,
|
2009-01-07 00:45:26 +00:00
|
|
|
.ndo_do_ioctl = dsa_slave_ioctl,
|
2015-04-02 15:07:08 +00:00
|
|
|
.ndo_get_iflink = dsa_slave_get_iflink,
|
2015-07-31 18:42:57 +00:00
|
|
|
#ifdef CONFIG_NET_POLL_CONTROLLER
|
|
|
|
.ndo_netpoll_setup = dsa_slave_netpoll_setup,
|
|
|
|
.ndo_netpoll_cleanup = dsa_slave_netpoll_cleanup,
|
|
|
|
.ndo_poll_controller = dsa_slave_poll_controller,
|
|
|
|
#endif
|
2015-08-13 16:52:17 +00:00
|
|
|
.ndo_bridge_getlink = switchdev_port_bridge_getlink,
|
|
|
|
.ndo_bridge_setlink = switchdev_port_bridge_setlink,
|
|
|
|
.ndo_bridge_dellink = switchdev_port_bridge_dellink,
|
2017-01-10 20:32:36 +00:00
|
|
|
.ndo_get_phys_port_name = dsa_slave_get_phys_port_name,
|
2015-03-16 04:07:15 +00:00
|
|
|
};
|
|
|
|
|
2015-05-10 16:47:47 +00:00
|
|
|
static const struct switchdev_ops dsa_slave_switchdev_ops = {
|
2015-05-10 16:47:49 +00:00
|
|
|
.switchdev_port_attr_get = dsa_slave_port_attr_get,
|
2015-05-10 16:47:51 +00:00
|
|
|
.switchdev_port_attr_set = dsa_slave_port_attr_set,
|
2015-08-10 13:09:53 +00:00
|
|
|
.switchdev_port_obj_add = dsa_slave_port_obj_add,
|
|
|
|
.switchdev_port_obj_del = dsa_slave_port_obj_del,
|
|
|
|
.switchdev_port_obj_dump = dsa_slave_port_obj_dump,
|
2009-01-07 00:45:26 +00:00
|
|
|
};
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
2015-09-24 01:19:58 +00:00
|
|
|
static struct device_type dsa_type = {
|
|
|
|
.name = "dsa",
|
|
|
|
};
|
|
|
|
|
2014-08-28 00:04:51 +00:00
|
|
|
static void dsa_slave_adjust_link(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-08-28 00:04:51 +00:00
|
|
|
unsigned int status_changed = 0;
|
|
|
|
|
|
|
|
if (p->old_link != p->phy->link) {
|
|
|
|
status_changed = 1;
|
|
|
|
p->old_link = p->phy->link;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p->old_duplex != p->phy->duplex) {
|
|
|
|
status_changed = 1;
|
|
|
|
p->old_duplex = p->phy->duplex;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p->old_pause != p->phy->pause) {
|
|
|
|
status_changed = 1;
|
|
|
|
p->old_pause = p->phy->pause;
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->adjust_link && status_changed)
|
2017-01-27 20:29:39 +00:00
|
|
|
ds->ops->adjust_link(ds, p->dp->index, p->phy);
|
2014-08-28 00:04:53 +00:00
|
|
|
|
2014-08-28 00:04:51 +00:00
|
|
|
if (status_changed)
|
|
|
|
phy_print_status(p->phy);
|
|
|
|
}
|
|
|
|
|
2014-08-28 00:04:54 +00:00
|
|
|
static int dsa_slave_fixed_link_update(struct net_device *dev,
|
|
|
|
struct fixed_phy_status *status)
|
|
|
|
{
|
2016-03-11 23:01:37 +00:00
|
|
|
struct dsa_slave_priv *p;
|
|
|
|
struct dsa_switch *ds;
|
|
|
|
|
|
|
|
if (dev) {
|
|
|
|
p = netdev_priv(dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
ds = p->dp->ds;
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->fixed_link_update)
|
2017-01-27 20:29:39 +00:00
|
|
|
ds->ops->fixed_link_update(ds, p->dp->index, status);
|
2016-03-11 23:01:37 +00:00
|
|
|
}
|
2014-08-28 00:04:54 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
/* slave device setup *******************************************************/
|
2015-03-10 23:57:12 +00:00
|
|
|
static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
|
2015-03-10 23:57:13 +00:00
|
|
|
struct net_device *slave_dev,
|
|
|
|
int addr)
|
2015-03-10 23:57:12 +00:00
|
|
|
{
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2015-03-10 23:57:12 +00:00
|
|
|
|
2016-01-06 19:11:18 +00:00
|
|
|
p->phy = mdiobus_get_phy(ds->slave_mii_bus, addr);
|
2015-10-03 17:09:07 +00:00
|
|
|
if (!p->phy) {
|
|
|
|
netdev_err(slave_dev, "no phy at %d\n", addr);
|
2015-03-10 23:57:12 +00:00
|
|
|
return -ENODEV;
|
2015-10-03 17:09:07 +00:00
|
|
|
}
|
2015-03-10 23:57:12 +00:00
|
|
|
|
|
|
|
/* Use already configured phy mode */
|
2015-08-08 19:58:57 +00:00
|
|
|
if (p->phy_interface == PHY_INTERFACE_MODE_NA)
|
|
|
|
p->phy_interface = p->phy->interface;
|
2017-01-21 00:05:05 +00:00
|
|
|
return phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
|
|
|
|
p->phy_interface);
|
2015-03-10 23:57:12 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 20:49:16 +00:00
|
|
|
static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
|
2014-08-28 00:04:51 +00:00
|
|
|
struct net_device *slave_dev)
|
|
|
|
{
|
2017-01-27 20:29:39 +00:00
|
|
|
struct dsa_switch *ds = p->dp->ds;
|
2014-08-28 00:04:51 +00:00
|
|
|
struct device_node *phy_dn, *port_dn;
|
2014-08-28 00:04:54 +00:00
|
|
|
bool phy_is_fixed = false;
|
2014-09-19 20:07:54 +00:00
|
|
|
u32 phy_flags = 0;
|
2015-02-17 05:23:51 +00:00
|
|
|
int mode, ret;
|
2014-08-28 00:04:51 +00:00
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
port_dn = p->dp->dn;
|
2015-02-17 05:23:51 +00:00
|
|
|
mode = of_get_phy_mode(port_dn);
|
|
|
|
if (mode < 0)
|
|
|
|
mode = PHY_INTERFACE_MODE_NA;
|
|
|
|
p->phy_interface = mode;
|
2014-08-28 00:04:51 +00:00
|
|
|
|
|
|
|
phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
|
2016-11-28 18:24:54 +00:00
|
|
|
if (!phy_dn && of_phy_is_fixed_link(port_dn)) {
|
2014-08-28 00:04:51 +00:00
|
|
|
/* In the case of a fixed PHY, the DT node associated
|
|
|
|
* to the fixed PHY is the Port DT node
|
|
|
|
*/
|
|
|
|
ret = of_phy_register_fixed_link(port_dn);
|
|
|
|
if (ret) {
|
2015-10-03 17:09:07 +00:00
|
|
|
netdev_err(slave_dev, "failed to register fixed PHY: %d\n", ret);
|
2014-12-11 20:49:16 +00:00
|
|
|
return ret;
|
2014-08-28 00:04:51 +00:00
|
|
|
}
|
2014-08-28 00:04:54 +00:00
|
|
|
phy_is_fixed = true;
|
2016-11-28 18:24:54 +00:00
|
|
|
phy_dn = of_node_get(port_dn);
|
2014-08-28 00:04:51 +00:00
|
|
|
}
|
|
|
|
|
2016-08-23 16:38:56 +00:00
|
|
|
if (ds->ops->get_phy_flags)
|
2017-01-27 20:29:39 +00:00
|
|
|
phy_flags = ds->ops->get_phy_flags(ds, p->dp->index);
|
2014-09-19 20:07:54 +00:00
|
|
|
|
2015-03-10 23:57:13 +00:00
|
|
|
if (phy_dn) {
|
2015-10-03 17:09:07 +00:00
|
|
|
int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn);
|
|
|
|
|
2015-03-10 23:57:13 +00:00
|
|
|
/* If this PHY address is part of phys_mii_mask, which means
|
|
|
|
* that we need to divert reads and writes to/from it, then we
|
|
|
|
* want to bind this device using the slave MII bus created by
|
|
|
|
* DSA to make that happen.
|
|
|
|
*/
|
2015-10-03 17:09:07 +00:00
|
|
|
if (!phy_is_fixed && phy_id >= 0 &&
|
|
|
|
(ds->phys_mii_mask & (1 << phy_id))) {
|
|
|
|
ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
|
|
|
|
if (ret) {
|
|
|
|
netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
|
2016-11-28 18:24:54 +00:00
|
|
|
of_node_put(phy_dn);
|
2015-03-10 23:57:13 +00:00
|
|
|
return ret;
|
2015-10-03 17:09:07 +00:00
|
|
|
}
|
2015-03-10 23:57:13 +00:00
|
|
|
} else {
|
|
|
|
p->phy = of_phy_connect(slave_dev, phy_dn,
|
|
|
|
dsa_slave_adjust_link,
|
|
|
|
phy_flags,
|
|
|
|
p->phy_interface);
|
|
|
|
}
|
2016-11-28 18:24:54 +00:00
|
|
|
|
|
|
|
of_node_put(phy_dn);
|
2015-03-10 23:57:13 +00:00
|
|
|
}
|
2014-08-28 00:04:51 +00:00
|
|
|
|
2014-08-28 00:04:54 +00:00
|
|
|
if (p->phy && phy_is_fixed)
|
|
|
|
fixed_phy_set_link_update(p->phy, dsa_slave_fixed_link_update);
|
|
|
|
|
2014-08-28 00:04:51 +00:00
|
|
|
/* We could not connect to a designated PHY, so use the switch internal
|
|
|
|
* MDIO bus instead
|
|
|
|
*/
|
2014-11-05 18:47:28 +00:00
|
|
|
if (!p->phy) {
|
2017-01-27 20:29:39 +00:00
|
|
|
ret = dsa_slave_phy_connect(p, slave_dev, p->dp->index);
|
2015-10-03 17:09:07 +00:00
|
|
|
if (ret) {
|
2017-01-27 20:29:39 +00:00
|
|
|
netdev_err(slave_dev, "failed to connect to port %d: %d\n",
|
|
|
|
p->dp->index, ret);
|
2016-11-28 18:25:09 +00:00
|
|
|
if (phy_is_fixed)
|
|
|
|
of_phy_deregister_fixed_link(port_dn);
|
2015-03-10 23:57:12 +00:00
|
|
|
return ret;
|
2015-10-03 17:09:07 +00:00
|
|
|
}
|
2014-11-05 18:47:28 +00:00
|
|
|
}
|
2014-12-11 20:49:16 +00:00
|
|
|
|
2016-01-06 19:11:13 +00:00
|
|
|
phy_attached_info(p->phy);
|
|
|
|
|
2014-12-11 20:49:16 +00:00
|
|
|
return 0;
|
2014-08-28 00:04:51 +00:00
|
|
|
}
|
|
|
|
|
2015-05-05 23:09:56 +00:00
|
|
|
static struct lock_class_key dsa_slave_netdev_xmit_lock_key;
|
|
|
|
static void dsa_slave_set_lockdep_class_one(struct net_device *dev,
|
|
|
|
struct netdev_queue *txq,
|
|
|
|
void *_unused)
|
|
|
|
{
|
|
|
|
lockdep_set_class(&txq->_xmit_lock,
|
|
|
|
&dsa_slave_netdev_xmit_lock_key);
|
|
|
|
}
|
|
|
|
|
2014-09-19 00:31:22 +00:00
|
|
|
int dsa_slave_suspend(struct net_device *slave_dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(slave_dev);
|
|
|
|
|
2017-01-25 17:10:41 +00:00
|
|
|
netif_device_detach(slave_dev);
|
|
|
|
|
2014-09-19 00:31:22 +00:00
|
|
|
if (p->phy) {
|
|
|
|
phy_stop(p->phy);
|
|
|
|
p->old_pause = -1;
|
|
|
|
p->old_link = -1;
|
|
|
|
p->old_duplex = -1;
|
|
|
|
phy_suspend(p->phy);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dsa_slave_resume(struct net_device *slave_dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(slave_dev);
|
|
|
|
|
|
|
|
netif_device_attach(slave_dev);
|
|
|
|
|
|
|
|
if (p->phy) {
|
|
|
|
phy_resume(p->phy);
|
|
|
|
phy_start(p->phy);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-24 21:15:32 +00:00
|
|
|
int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
|
2016-06-04 19:17:07 +00:00
|
|
|
int port, const char *name)
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
{
|
net: dsa: Provide CPU port statistics to master netdev
This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
include switch-side statistics, which is useful for debugging purposes,
when the switch is not properly connected to the Ethernet MAC (duplex
mismatch, (RG)MII electrical issues etc.).
We accomplish this by retaining the original copy of the master netdev's
ethtool_ops, and just overload the 3 operations we care about:
get_sset_count, get_strings and get_ethtool_stats so as to intercept
these calls and call into the original master_netdev ethtool_ops, plus
our own.
We take this approach as opposed to providing a set of DSA helper
functions that would retrive the CPU port's statistics, because the
entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
used as CPU conduit interfaces, therefore, statistics overlay in such
drivers would simply not scale.
The new ethtool -S <iface> output would therefore look like this now:
<iface> statistics
p<2 digits cpu port number>_<switch MIB counter names>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-27 18:45:14 +00:00
|
|
|
struct dsa_switch_tree *dst = ds->dst;
|
2016-06-04 19:17:07 +00:00
|
|
|
struct net_device *master;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
struct net_device *slave_dev;
|
|
|
|
struct dsa_slave_priv *p;
|
|
|
|
int ret;
|
|
|
|
|
2016-06-04 19:17:07 +00:00
|
|
|
master = ds->dst->master_netdev;
|
|
|
|
if (ds->master_netdev)
|
|
|
|
master = ds->master_netdev;
|
|
|
|
|
net: set name_assign_type in alloc_netdev()
Extend alloc_netdev{,_mq{,s}}() to take name_assign_type as argument, and convert
all users to pass NET_NAME_UNKNOWN.
Coccinelle patch:
@@
expression sizeof_priv, name, setup, txqs, rxqs, count;
@@
(
-alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs)
+alloc_netdev_mqs(sizeof_priv, name, NET_NAME_UNKNOWN, setup, txqs, rxqs)
|
-alloc_netdev_mq(sizeof_priv, name, setup, count)
+alloc_netdev_mq(sizeof_priv, name, NET_NAME_UNKNOWN, setup, count)
|
-alloc_netdev(sizeof_priv, name, setup)
+alloc_netdev(sizeof_priv, name, NET_NAME_UNKNOWN, setup)
)
v9: move comments here from the wrong commit
Signed-off-by: Tom Gundersen <teg@jklm.no>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-07-14 14:37:24 +00:00
|
|
|
slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name,
|
|
|
|
NET_NAME_UNKNOWN, ether_setup);
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
if (slave_dev == NULL)
|
2015-02-24 21:15:32 +00:00
|
|
|
return -ENOMEM;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
|
|
|
|
slave_dev->features = master->vlan_features;
|
2014-05-11 00:12:32 +00:00
|
|
|
slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
|
2013-08-30 16:08:46 +00:00
|
|
|
eth_hw_addr_inherit(slave_dev, master);
|
2015-08-18 08:30:41 +00:00
|
|
|
slave_dev->priv_flags |= IFF_NO_QUEUE;
|
2014-08-28 00:04:46 +00:00
|
|
|
slave_dev->netdev_ops = &dsa_slave_netdev_ops;
|
2015-05-10 16:47:47 +00:00
|
|
|
slave_dev->switchdev_ops = &dsa_slave_switchdev_ops;
|
2016-10-21 03:25:27 +00:00
|
|
|
slave_dev->min_mtu = 0;
|
|
|
|
slave_dev->max_mtu = ETH_MAX_MTU;
|
2015-09-24 01:19:58 +00:00
|
|
|
SET_NETDEV_DEVTYPE(slave_dev, &dsa_type);
|
2009-01-07 00:45:26 +00:00
|
|
|
|
2015-05-05 23:09:56 +00:00
|
|
|
netdev_for_each_tx_queue(slave_dev, dsa_slave_set_lockdep_class_one,
|
|
|
|
NULL);
|
|
|
|
|
2014-09-15 17:00:19 +00:00
|
|
|
SET_NETDEV_DEV(slave_dev, parent);
|
2016-06-04 19:16:58 +00:00
|
|
|
slave_dev->dev.of_node = ds->ports[port].dn;
|
2014-09-15 17:00:19 +00:00
|
|
|
slave_dev->vlan_features = master->vlan_features;
|
|
|
|
|
|
|
|
p = netdev_priv(slave_dev);
|
2017-01-27 20:29:39 +00:00
|
|
|
p->dp = &ds->ports[port];
|
2016-06-04 19:17:03 +00:00
|
|
|
p->xmit = dst->tag_ops->xmit;
|
2009-01-07 00:45:26 +00:00
|
|
|
|
2014-08-28 00:04:51 +00:00
|
|
|
p->old_pause = -1;
|
|
|
|
p->old_link = -1;
|
|
|
|
p->old_duplex = -1;
|
|
|
|
|
2016-06-04 19:16:57 +00:00
|
|
|
ds->ports[port].netdev = slave_dev;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
ret = register_netdev(slave_dev);
|
|
|
|
if (ret) {
|
2014-11-10 00:32:46 +00:00
|
|
|
netdev_err(master, "error %d registering interface %s\n",
|
|
|
|
ret, slave_dev->name);
|
2016-06-04 19:16:57 +00:00
|
|
|
ds->ports[port].netdev = NULL;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
free_netdev(slave_dev);
|
2015-02-24 21:15:32 +00:00
|
|
|
return ret;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
netif_carrier_off(slave_dev);
|
|
|
|
|
2016-01-06 19:11:20 +00:00
|
|
|
ret = dsa_slave_phy_setup(p, slave_dev);
|
|
|
|
if (ret) {
|
|
|
|
netdev_err(master, "error %d setting up slave phy\n", ret);
|
2016-02-18 02:43:22 +00:00
|
|
|
unregister_netdev(slave_dev);
|
2016-01-06 19:11:20 +00:00
|
|
|
free_netdev(slave_dev);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-02-24 21:15:32 +00:00
|
|
|
return 0;
|
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 <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-10-07 13:44:02 +00:00
|
|
|
}
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2015-12-07 12:57:35 +00:00
|
|
|
void dsa_slave_destroy(struct net_device *slave_dev)
|
|
|
|
{
|
|
|
|
struct dsa_slave_priv *p = netdev_priv(slave_dev);
|
2016-11-28 18:25:09 +00:00
|
|
|
struct device_node *port_dn;
|
|
|
|
|
2017-01-27 20:29:39 +00:00
|
|
|
port_dn = p->dp->dn;
|
2015-12-07 12:57:35 +00:00
|
|
|
|
|
|
|
netif_carrier_off(slave_dev);
|
2016-11-28 18:25:09 +00:00
|
|
|
if (p->phy) {
|
2015-12-07 12:57:35 +00:00
|
|
|
phy_disconnect(p->phy);
|
2016-11-28 18:25:09 +00:00
|
|
|
|
|
|
|
if (of_phy_is_fixed_link(port_dn))
|
|
|
|
of_phy_deregister_fixed_link(port_dn);
|
|
|
|
}
|
2015-12-07 12:57:35 +00:00
|
|
|
unregister_netdev(slave_dev);
|
|
|
|
free_netdev(slave_dev);
|
|
|
|
}
|
|
|
|
|
2015-02-24 21:15:33 +00:00
|
|
|
static bool dsa_slave_dev_check(struct net_device *dev)
|
|
|
|
{
|
|
|
|
return dev->netdev_ops == &dsa_slave_netdev_ops;
|
|
|
|
}
|
|
|
|
|
2016-03-13 20:21:34 +00:00
|
|
|
static int dsa_slave_port_upper_event(struct net_device *dev,
|
|
|
|
unsigned long event, void *ptr)
|
2015-02-24 21:15:33 +00:00
|
|
|
{
|
2016-03-13 20:21:34 +00:00
|
|
|
struct netdev_notifier_changeupper_info *info = ptr;
|
|
|
|
struct net_device *upper = info->upper_dev;
|
2015-02-24 21:15:33 +00:00
|
|
|
int err = 0;
|
|
|
|
|
2016-03-13 20:21:34 +00:00
|
|
|
switch (event) {
|
|
|
|
case NETDEV_CHANGEUPPER:
|
|
|
|
if (netif_is_bridge_master(upper)) {
|
|
|
|
if (info->linking)
|
|
|
|
err = dsa_slave_bridge_port_join(dev, upper);
|
|
|
|
else
|
2017-01-27 20:29:41 +00:00
|
|
|
dsa_slave_bridge_port_leave(dev, upper);
|
2016-03-13 20:21:34 +00:00
|
|
|
}
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2016-03-13 20:21:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return notifier_from_errno(err);
|
2015-02-24 21:15:33 +00:00
|
|
|
}
|
|
|
|
|
2016-03-13 20:21:34 +00:00
|
|
|
static int dsa_slave_port_event(struct net_device *dev, unsigned long event,
|
|
|
|
void *ptr)
|
2015-02-24 21:15:33 +00:00
|
|
|
{
|
|
|
|
switch (event) {
|
|
|
|
case NETDEV_CHANGEUPPER:
|
2016-03-13 20:21:34 +00:00
|
|
|
return dsa_slave_port_upper_event(dev, event, ptr);
|
|
|
|
}
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2016-03-13 20:21:34 +00:00
|
|
|
return NOTIFY_DONE;
|
|
|
|
}
|
2015-02-24 21:15:33 +00:00
|
|
|
|
2016-03-13 20:21:34 +00:00
|
|
|
int dsa_slave_netdevice_event(struct notifier_block *unused,
|
|
|
|
unsigned long event, void *ptr)
|
|
|
|
{
|
|
|
|
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
|
|
|
|
|
|
|
|
if (dsa_slave_dev_check(dev))
|
|
|
|
return dsa_slave_port_event(dev, event, ptr);
|
2015-02-24 21:15:33 +00:00
|
|
|
|
|
|
|
return NOTIFY_DONE;
|
|
|
|
}
|