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>
This commit is contained in:

committed by
David S. Miller

parent
18abed211c
commit
e28def3329
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user