From: Arun Ramadoss <arun.ramadoss@microchip.com>
To: <netdev@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <bpf@vger.kernel.org>
Cc: Woojung Huh <woojung.huh@microchip.com>,
<UNGLinuxDriver@microchip.com>, Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Rob Herring" <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Russell King <linux@armlinux.org.uk>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <kafai@fb.com>,
"Song Liu" <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>
Subject: [Patch net-next v15 09/13] net: dsa: microchip: lan937x: add MTU and fast_age support
Date: Fri, 1 Jul 2022 20:39:54 +0530 [thread overview]
Message-ID: <20220701150954.29200-1-arun.ramadoss@microchip.com> (raw)
In-Reply-To: <20220701144652.10526-1-arun.ramadoss@microchip.com>
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>
---
drivers/net/dsa/microchip/ksz_common.c | 2 ++
drivers/net/dsa/microchip/lan937x.h | 1 +
drivers/net/dsa/microchip/lan937x_main.c | 28 ++++++++++++++++++++++++
drivers/net/dsa/microchip/lan937x_reg.h | 5 +++++
4 files changed, 36 insertions(+)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 67bb4bff4d9b..fb0de48a3f5e 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -206,6 +206,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = {
.setup = lan937x_setup,
.get_port_addr = ksz9477_get_port_addr,
.cfg_port_member = ksz9477_cfg_port_member,
+ .flush_dyn_mac_table = ksz9477_flush_dyn_mac_table,
.port_setup = lan937x_port_setup,
.r_phy = lan937x_r_phy,
.w_phy = lan937x_w_phy,
@@ -224,6 +225,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = {
.fdb_del = ksz9477_fdb_del,
.mdb_add = ksz9477_mdb_add,
.mdb_del = ksz9477_mdb_del,
+ .change_mtu = lan937x_change_mtu,
.max_mtu = ksz9477_max_mtu,
.config_cpu_port = lan937x_config_cpu_port,
.enable_stp_addr = ksz9477_enable_stp_addr,
diff --git a/drivers/net/dsa/microchip/lan937x.h b/drivers/net/dsa/microchip/lan937x.h
index 370203406a05..50563874600d 100644
--- a/drivers/net/dsa/microchip/lan937x.h
+++ b/drivers/net/dsa/microchip/lan937x.h
@@ -14,4 +14,5 @@ int lan937x_switch_init(struct ksz_device *dev);
void lan937x_switch_exit(struct ksz_device *dev);
void lan937x_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data);
void lan937x_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);
+int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu);
#endif
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;
diff --git a/drivers/net/dsa/microchip/lan937x_reg.h b/drivers/net/dsa/microchip/lan937x_reg.h
index 7a0fa2595950..19f3aa344228 100644
--- a/drivers/net/dsa/microchip/lan937x_reg.h
+++ b/drivers/net/dsa/microchip/lan937x_reg.h
@@ -149,6 +149,9 @@
#define PORT_BACK_PRESSURE BIT(3)
#define PORT_PASS_ALL BIT(0)
+#define PORT_MAX_FR_SIZE 0x404
+#define FR_MIN_SIZE 1522
+
/* 8 - Classification and Policing */
#define REG_PORT_MRI_PRIO_CTRL 0x0801
#define PORT_HIGHEST_PRIO BIT(7)
@@ -161,4 +164,6 @@
#define P_PRIO_CTRL REG_PORT_MRI_PRIO_CTRL
+#define LAN937X_TAG_LEN 2
+
#endif
--
2.36.1
next prev parent reply other threads:[~2022-07-01 15:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 14:46 [Patch net-next v15 00/13] net: dsa: microchip: DSA Driver support for LAN937x Arun Ramadoss
2022-07-01 14:46 ` [Patch net-next v15 01/13] dt-bindings: net: make internal-delay-ps based on phy-mode Arun Ramadoss
2022-07-01 14:57 ` [Patch net-next v15 02/13] dt-bindings: net: dsa: dt bindings for microchip lan937x Arun Ramadoss
2022-07-01 15:00 ` [Patch net-next v15 03/13] net: dsa: tag_ksz: add tag handling for Microchip LAN937x Arun Ramadoss
2022-07-01 15:01 ` [Patch net-next v15 04/13] net: dsa: microchip: generic access to ksz9477 static and reserved table Arun Ramadoss
2022-07-01 15:01 ` [Patch net-next v15 05/13] net: dsa: microchip: add DSA support for microchip LAN937x Arun Ramadoss
2022-07-01 15:02 ` [Patch net-next v15 06/13] net: dsa: microchip: lan937x: add dsa_tag_protocol Arun Ramadoss
2022-07-01 15:06 ` [Patch net-next v15 07/13] net: dsa: microchip: lan937x: add phy read and write support Arun Ramadoss
2022-07-01 15:07 ` [Patch net-next v15 08/13] net: dsa: microchip: lan937x: register mdio-bus Arun Ramadoss
2022-07-01 15:09 ` Arun Ramadoss [this message]
2022-07-01 15:10 ` [Patch net-next v15 10/13] net: dsa: microchip: lan937x: add phylink_get_caps support Arun Ramadoss
2022-07-01 15:11 ` [Patch net-next v15 11/13] net: dsa: microchip: lan937x: add phylink_mac_link_up support Arun Ramadoss
2022-07-01 15:12 ` [Patch net-next v15 12/13] net: dsa: microchip: lan937x: add phylink_mac_config support Arun Ramadoss
2022-07-01 15:16 ` [Patch net-next v15 13/13] net: dsa: microchip: add LAN937x in the ksz spi probe Arun Ramadoss
2022-07-02 15:40 ` [Patch net-next v15 00/13] net: dsa: microchip: DSA Driver support for LAN937x patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220701150954.29200-1-arun.ramadoss@microchip.com \
--to=arun.ramadoss@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=robh+dt@kernel.org \
--cc=songliubraving@fb.com \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).