diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2016-11-04 03:23:27 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-11-04 19:39:58 +0100 |
commit | e28def33291c2b1e3a53da2dddd46a04f9f985ab (patch) | |
tree | d1ad9dbee3a9fbc8c0f09d768eaa0766ccb5d305 /drivers/net/dsa/mv88e6xxx/port.c | |
parent | net: dsa: mv88e6xxx: add port files (diff) | |
download | linux-e28def33291c2b1e3a53da2dddd46a04f9f985ab.tar.xz linux-e28def33291c2b1e3a53da2dddd46a04f9f985ab.zip |
net: dsa: mv88e6xxx: add port state setter
Add the port STP state setter to the port files.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa/mv88e6xxx/port.c')
-rw-r--r-- | drivers/net/dsa/mv88e6xxx/port.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c index 3b36c9290ea8..8d59fe73a834 100644 --- a/drivers/net/dsa/mv88e6xxx/port.c +++ b/drivers/net/dsa/mv88e6xxx/port.c @@ -29,3 +29,34 @@ int mv88e6xxx_port_write(struct mv88e6xxx_chip *chip, int port, int reg, return mv88e6xxx_write(chip, addr, reg, val); } + +/* Offset 0x04: Port Control Register */ + +static const char * const mv88e6xxx_port_state_names[] = { + [PORT_CONTROL_STATE_DISABLED] = "Disabled", + [PORT_CONTROL_STATE_BLOCKING] = "Blocking/Listening", + [PORT_CONTROL_STATE_LEARNING] = "Learning", + [PORT_CONTROL_STATE_FORWARDING] = "Forwarding", +}; + +int mv88e6xxx_port_set_state(struct mv88e6xxx_chip *chip, int port, u8 state) +{ + u16 reg; + int err; + + err = mv88e6xxx_port_read(chip, port, PORT_CONTROL, ®); + if (err) + return err; + + reg &= ~PORT_CONTROL_STATE_MASK; + reg |= state; + + err = mv88e6xxx_port_write(chip, port, PORT_CONTROL, reg); + if (err) + return err; + + netdev_dbg(chip->ds->ports[port].netdev, "PortState set to %s\n", + mv88e6xxx_port_state_names[state]); + + return 0; +} |