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

2016-04-11 Thread Cristian Morales Vega
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  wrote:
> Signed-off-by: Cristian Morales Vega 
> ---
>  ...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 
>   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 
>  +  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 
>  +  .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
>



-- 
Cristian Morales Vega

Email crist...@samknows.com
Office +44 (0) 20 3111 4330
Web:  www.samknows.com


This email is sent for and on behalf of SamKnows Limited.

This email and any attachments are confidential, legally privileged
and protected by copyright. If you are not the intended recipient
dissemination or copying of this email is prohibited. If you have
received this in error, please notify the sender by replying by email
and then delete the email completely from your system.

SamKnows Limited, Registered Number: 06510477, Registered Office: Hill
House, 1 Little New Street, London, EC4A 3TR. Registered in England
and Wales. Trade Mark 2507103
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


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

2016-04-09 Thread John Crispin
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 
> ---
>  ...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 
>   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 
>  +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 
>  +.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[] = {
> 
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel