diff mbox

[OpenWrt-Devel] ramips: mt7621: add support for disabling flow control

Message ID 1459866124-17771-1-git-send-email-cristian@samknows.com
State Changes Requested
Headers show

Commit Message

Cristian Morales Vega April 5, 2016, 2:22 p.m. UTC
Signed-off-by: Cristian Morales Vega <cristian@samknows.com>
---
 ...diatek-add-swconfig-driver-for-gsw_mt762x.patch | 54 +++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

Comments

John Crispin April 9, 2016, 9:14 a.m. UTC | #1
should this not be part of ethtool ? swconfig is aimed at setting switch
configs and not the config of the attached phys. imho ethtool can
already do this with the existing code

	John

On 05/04/2016 16:22, Cristian Morales Vega wrote:
> Signed-off-by: Cristian Morales Vega <cristian@samknows.com>
> ---
>  ...diatek-add-swconfig-driver-for-gsw_mt762x.patch | 54 +++++++++++++++++++++-
>  1 file changed, 53 insertions(+), 1 deletion(-)
> 
> diff --git a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
> index bbad8cc..d056551 100644
> --- a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
> +++ b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
> @@ -28,7 +28,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
>   obj-$(CONFIG_NET_MEDIATEK_SOC)			+= mtk-eth-soc.o
>  --- /dev/null
>  +++ b/drivers/net/ethernet/mediatek/mt7530.c
> -@@ -0,0 +1,804 @@
> +@@ -0,0 +1,856 @@
>  +/*
>  + * This program is free software; you can redistribute it and/or
>  + * modify it under the terms of the GNU General Public License
> @@ -709,6 +709,50 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
>  +	return 0;
>  +}
>  +
> ++static int mt7621_sw_get_port_fc(struct switch_dev *dev,
> ++				 const struct switch_attr *attr,
> ++				 struct switch_val *val)
> ++{
> ++	u32 reg;
> ++	struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
> ++
> ++	if (val->port_vlan >= MT7530_NUM_PORTS)
> ++		return -EINVAL;
> ++
> ++	reg = mdiobus_read(priv->bus, val->port_vlan, 4);
> ++	reg &= BIT(10);
> ++
> ++	val->value.i = reg ? 1 : 0;
> ++
> ++	return 0;
> ++}
> ++
> ++static int mt7621_sw_set_port_fc(struct switch_dev *dev,
> ++				 const struct switch_attr *attr,
> ++				 struct switch_val *val)
> ++{
> ++	u32 reg;
> ++	struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
> ++
> ++	if (val->port_vlan >= MT7530_NUM_PORTS)
> ++		return -EINVAL;
> ++
> ++	reg = mdiobus_read(priv->bus, val->port_vlan, 4);
> ++	if(val->value.i) {
> ++		reg |= BIT(10);
> ++	} else {
> ++		reg &= ~BIT(10);
> ++	}
> ++	mdiobus_write(priv->bus, val->port_vlan, 4, reg);
> ++
> ++	/* Restart auto-negotiation */
> ++	reg = mdiobus_read(priv->bus, val->port_vlan, 0);
> ++	reg |= BIT(9);
> ++	mdiobus_write(priv->bus, val->port_vlan, 0, reg);
> ++
> ++	return 0;
> ++}
> ++
>  +static const struct switch_attr mt7621_port[] = {
>  +	{
>  +		.type = SWITCH_TYPE_STRING,
> @@ -717,6 +761,14 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
>  +		.get = mt7621_sw_get_port_mib,
>  +		.set = NULL,
>  +	},
> ++	{
> ++		.type = SWITCH_TYPE_INT,
> ++		.name = "flow_ctl",
> ++		.description = "Flow Control",
> ++		.get = mt7621_sw_get_port_fc,
> ++		.set = mt7621_sw_set_port_fc,
> ++		.max = 1,
> ++	},
>  +};
>  +
>  +static const struct switch_attr mt7530_port[] = {
>
Cristian Morales Vega April 11, 2016, 8:06 a.m. UTC | #2
Sorry, for some reason I didn't receive your reply (but patchwork told
me about it), so I am replying here.

Maybe it's something that should be done with ethtool, but I had no
idea those phys were exposed through anything other than swconfig.
What would be the "DEVNAME" in "ethtool -a DEVNAME" if I want to, for
example, check the settings of the switch port #3?


On 5 April 2016 at 15:22, Cristian Morales Vega <cristian@samknows.com> wrote:
> Signed-off-by: Cristian Morales Vega <cristian@samknows.com>
> ---
>  ...diatek-add-swconfig-driver-for-gsw_mt762x.patch | 54 +++++++++++++++++++++-
>  1 file changed, 53 insertions(+), 1 deletion(-)
>
> diff --git a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
> index bbad8cc..d056551 100644
> --- a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
> +++ b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
> @@ -28,7 +28,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
>   obj-$(CONFIG_NET_MEDIATEK_SOC)                        += mtk-eth-soc.o
>  --- /dev/null
>  +++ b/drivers/net/ethernet/mediatek/mt7530.c
> -@@ -0,0 +1,804 @@
> +@@ -0,0 +1,856 @@
>  +/*
>  + * This program is free software; you can redistribute it and/or
>  + * modify it under the terms of the GNU General Public License
> @@ -709,6 +709,50 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
>  +      return 0;
>  +}
>  +
> ++static int mt7621_sw_get_port_fc(struct switch_dev *dev,
> ++                               const struct switch_attr *attr,
> ++                               struct switch_val *val)
> ++{
> ++      u32 reg;
> ++      struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
> ++
> ++      if (val->port_vlan >= MT7530_NUM_PORTS)
> ++              return -EINVAL;
> ++
> ++      reg = mdiobus_read(priv->bus, val->port_vlan, 4);
> ++      reg &= BIT(10);
> ++
> ++      val->value.i = reg ? 1 : 0;
> ++
> ++      return 0;
> ++}
> ++
> ++static int mt7621_sw_set_port_fc(struct switch_dev *dev,
> ++                               const struct switch_attr *attr,
> ++                               struct switch_val *val)
> ++{
> ++      u32 reg;
> ++      struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
> ++
> ++      if (val->port_vlan >= MT7530_NUM_PORTS)
> ++              return -EINVAL;
> ++
> ++      reg = mdiobus_read(priv->bus, val->port_vlan, 4);
> ++      if(val->value.i) {
> ++              reg |= BIT(10);
> ++      } else {
> ++              reg &= ~BIT(10);
> ++      }
> ++      mdiobus_write(priv->bus, val->port_vlan, 4, reg);
> ++
> ++      /* Restart auto-negotiation */
> ++      reg = mdiobus_read(priv->bus, val->port_vlan, 0);
> ++      reg |= BIT(9);
> ++      mdiobus_write(priv->bus, val->port_vlan, 0, reg);
> ++
> ++      return 0;
> ++}
> ++
>  +static const struct switch_attr mt7621_port[] = {
>  +      {
>  +              .type = SWITCH_TYPE_STRING,
> @@ -717,6 +761,14 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
>  +              .get = mt7621_sw_get_port_mib,
>  +              .set = NULL,
>  +      },
> ++      {
> ++              .type = SWITCH_TYPE_INT,
> ++              .name = "flow_ctl",
> ++              .description = "Flow Control",
> ++              .get = mt7621_sw_get_port_fc,
> ++              .set = mt7621_sw_set_port_fc,
> ++              .max = 1,
> ++      },
>  +};
>  +
>  +static const struct switch_attr mt7530_port[] = {
> --
> 2.6.3
>
diff mbox

Patch

diff --git a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
index bbad8cc..d056551 100644
--- a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
+++ b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
@@ -28,7 +28,7 @@  Signed-off-by: John Crispin <blogic@openwrt.org>
  obj-$(CONFIG_NET_MEDIATEK_SOC)			+= mtk-eth-soc.o
 --- /dev/null
 +++ b/drivers/net/ethernet/mediatek/mt7530.c
-@@ -0,0 +1,804 @@
+@@ -0,0 +1,856 @@
 +/*
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
@@ -709,6 +709,50 @@  Signed-off-by: John Crispin <blogic@openwrt.org>
 +	return 0;
 +}
 +
++static int mt7621_sw_get_port_fc(struct switch_dev *dev,
++				 const struct switch_attr *attr,
++				 struct switch_val *val)
++{
++	u32 reg;
++	struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
++
++	if (val->port_vlan >= MT7530_NUM_PORTS)
++		return -EINVAL;
++
++	reg = mdiobus_read(priv->bus, val->port_vlan, 4);
++	reg &= BIT(10);
++
++	val->value.i = reg ? 1 : 0;
++
++	return 0;
++}
++
++static int mt7621_sw_set_port_fc(struct switch_dev *dev,
++				 const struct switch_attr *attr,
++				 struct switch_val *val)
++{
++	u32 reg;
++	struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
++
++	if (val->port_vlan >= MT7530_NUM_PORTS)
++		return -EINVAL;
++
++	reg = mdiobus_read(priv->bus, val->port_vlan, 4);
++	if(val->value.i) {
++		reg |= BIT(10);
++	} else {
++		reg &= ~BIT(10);
++	}
++	mdiobus_write(priv->bus, val->port_vlan, 4, reg);
++
++	/* Restart auto-negotiation */
++	reg = mdiobus_read(priv->bus, val->port_vlan, 0);
++	reg |= BIT(9);
++	mdiobus_write(priv->bus, val->port_vlan, 0, reg);
++
++	return 0;
++}
++
 +static const struct switch_attr mt7621_port[] = {
 +	{
 +		.type = SWITCH_TYPE_STRING,
@@ -717,6 +761,14 @@  Signed-off-by: John Crispin <blogic@openwrt.org>
 +		.get = mt7621_sw_get_port_mib,
 +		.set = NULL,
 +	},
++	{
++		.type = SWITCH_TYPE_INT,
++		.name = "flow_ctl",
++		.description = "Flow Control",
++		.get = mt7621_sw_get_port_fc,
++		.set = mt7621_sw_set_port_fc,
++		.max = 1,
++	},
 +};
 +
 +static const struct switch_attr mt7530_port[] = {