diff options
author | Arun Ramadoss <arun.ramadoss@microchip.com> | 2022-07-01 20:39:54 +0530 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-07-02 16:34:05 +0100 |
commit | ab8823688f9e4adb0d423d5659df619806c8d15c (patch) | |
tree | 5cfee6bb13e7eb41473cb2f8f226cb1e20b6fc54 /drivers/net/dsa/microchip/lan937x_main.c | |
parent | a50b35366c646ed6735d996480f57d8d16e707ff (diff) |
net: dsa: microchip: lan937x: add MTU and fast_age support
This patch add the support for port_max_mtu, port_change_mtu and
port_fast_age dsa functionality.
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa/microchip/lan937x_main.c')
-rw-r--r-- | drivers/net/dsa/microchip/lan937x_main.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c index 7090947cf52c..5917cc11ba59 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -9,6 +9,7 @@ #include <linux/of_net.h> #include <linux/of_mdio.h> #include <linux/if_bridge.h> +#include <linux/if_vlan.h> #include <linux/math.h> #include <net/dsa.h> #include <net/switchdev.h> @@ -284,6 +285,33 @@ void lan937x_config_cpu_port(struct dsa_switch *ds) } } +int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu) +{ + struct dsa_switch *ds = dev->ds; + int ret; + + new_mtu += VLAN_ETH_HLEN + ETH_FCS_LEN; + + if (dsa_is_cpu_port(ds, port)) + new_mtu += LAN937X_TAG_LEN; + + if (new_mtu >= FR_MIN_SIZE) + ret = lan937x_port_cfg(dev, port, REG_PORT_MAC_CTRL_0, + PORT_JUMBO_PACKET, true); + else + ret = lan937x_port_cfg(dev, port, REG_PORT_MAC_CTRL_0, + PORT_JUMBO_PACKET, false); + if (ret < 0) { + dev_err(ds->dev, "failed to enable jumbo\n"); + return ret; + } + + /* Write the frame size in PORT_MAX_FR_SIZE register */ + ksz_pwrite16(dev, port, PORT_MAX_FR_SIZE, new_mtu); + + return 0; +} + int lan937x_setup(struct dsa_switch *ds) { struct ksz_device *dev = ds->priv; |