Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1352164 > unrolled thread
| Started by | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| First post | 2016-03-08 00:30 +0100 |
| Last post | 2016-03-10 22:20 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH net-next] net: dsa: mv88e6xxx: read then write PVID Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-03-08 00:30 +0100
Re: [PATCH net-next] net: dsa: mv88e6xxx: read then write PVID Andrew Lunn <andrew@lunn.ch> - 2016-03-08 15:40 +0100
Re: [PATCH net-next] net: dsa: mv88e6xxx: read then write PVID David Miller <davem@davemloft.net> - 2016-03-10 22:20 +0100
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Date | 2016-03-08 00:30 +0100 |
| Subject | [PATCH net-next] net: dsa: mv88e6xxx: read then write PVID |
| Message-ID | <racL8-13y-13@gated-at.bofh.it> |
The port register 0x07 contains more options than just the default VID,
even though they are not used yet. So prefer a read then write operation
over a direct write.
This also allows to keep track of the change through dynamic debug.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 3a58a8a..1aee42d 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1166,23 +1166,45 @@ int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state)
return 0;
}
-static int _mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid)
+static int _mv88e6xxx_port_pvid(struct dsa_switch *ds, int port, u16 *new,
+ u16 *old)
{
+ u16 pvid;
int ret;
ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_DEFAULT_VLAN);
if (ret < 0)
return ret;
- *pvid = ret & PORT_DEFAULT_VLAN_MASK;
+ pvid = ret & PORT_DEFAULT_VLAN_MASK;
+
+ if (new) {
+ ret &= ~PORT_DEFAULT_VLAN_MASK;
+ ret |= *new & PORT_DEFAULT_VLAN_MASK;
+
+ ret = _mv88e6xxx_reg_write(ds, REG_PORT(port),
+ PORT_DEFAULT_VLAN, ret);
+ if (ret < 0)
+ return ret;
+
+ netdev_dbg(ds->ports[port], "DefaultVID %d (was %d)\n", *new,
+ pvid);
+ }
+
+ if (old)
+ *old = pvid;
return 0;
}
+static int _mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid)
+{
+ return _mv88e6xxx_port_pvid(ds, port, NULL, pvid);
+}
+
static int _mv88e6xxx_port_pvid_set(struct dsa_switch *ds, int port, u16 pvid)
{
- return _mv88e6xxx_reg_write(ds, REG_PORT(port), PORT_DEFAULT_VLAN,
- pvid & PORT_DEFAULT_VLAN_MASK);
+ return _mv88e6xxx_port_pvid(ds, port, &pvid, NULL);
}
static int _mv88e6xxx_vtu_wait(struct dsa_switch *ds)
--
2.7.2
[toc] | [next] | [standalone]
| From | Andrew Lunn <andrew@lunn.ch> |
|---|---|
| Date | 2016-03-08 15:40 +0100 |
| Message-ID | <raqXL-25J-5@gated-at.bofh.it> |
| In reply to | #1352164 |
On Mon, Mar 07, 2016 at 06:24:39PM -0500, Vivien Didelot wrote:
> The port register 0x07 contains more options than just the default VID,
> even though they are not used yet. So prefer a read then write operation
> over a direct write.
>
> This also allows to keep track of the change through dynamic debug.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Tested-by: Andrew Lunn <andrew@lunn.ch>
Thanks
Andrew
> ---
> drivers/net/dsa/mv88e6xxx.c | 30 ++++++++++++++++++++++++++----
> 1 file changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index 3a58a8a..1aee42d 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -1166,23 +1166,45 @@ int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state)
> return 0;
> }
>
> -static int _mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid)
> +static int _mv88e6xxx_port_pvid(struct dsa_switch *ds, int port, u16 *new,
> + u16 *old)
> {
> + u16 pvid;
> int ret;
>
> ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_DEFAULT_VLAN);
> if (ret < 0)
> return ret;
>
> - *pvid = ret & PORT_DEFAULT_VLAN_MASK;
> + pvid = ret & PORT_DEFAULT_VLAN_MASK;
> +
> + if (new) {
> + ret &= ~PORT_DEFAULT_VLAN_MASK;
> + ret |= *new & PORT_DEFAULT_VLAN_MASK;
> +
> + ret = _mv88e6xxx_reg_write(ds, REG_PORT(port),
> + PORT_DEFAULT_VLAN, ret);
> + if (ret < 0)
> + return ret;
> +
> + netdev_dbg(ds->ports[port], "DefaultVID %d (was %d)\n", *new,
> + pvid);
> + }
> +
> + if (old)
> + *old = pvid;
>
> return 0;
> }
>
> +static int _mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid)
> +{
> + return _mv88e6xxx_port_pvid(ds, port, NULL, pvid);
> +}
> +
> static int _mv88e6xxx_port_pvid_set(struct dsa_switch *ds, int port, u16 pvid)
> {
> - return _mv88e6xxx_reg_write(ds, REG_PORT(port), PORT_DEFAULT_VLAN,
> - pvid & PORT_DEFAULT_VLAN_MASK);
> + return _mv88e6xxx_port_pvid(ds, port, &pvid, NULL);
> }
>
> static int _mv88e6xxx_vtu_wait(struct dsa_switch *ds)
> --
> 2.7.2
>
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-03-10 22:20 +0100 |
| Message-ID | <rbg9Y-4gf-5@gated-at.bofh.it> |
| In reply to | #1352164 |
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Date: Mon, 7 Mar 2016 18:24:39 -0500 > The port register 0x07 contains more options than just the default VID, > even though they are not used yet. So prefer a read then write operation > over a direct write. > > This also allows to keep track of the change through dynamic debug. > > Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Applied.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web