diff mbox series

[net-next] net: dsa: mt7530: enable jumbo frame

Message ID 20200409155409.12043-1-dqfext@gmail.com
State New
Headers show
Series [net-next] net: dsa: mt7530: enable jumbo frame | expand

Commit Message

Qingfang Deng April 9, 2020, 3:54 p.m. UTC
Enable jumbo frame for MT7530
It allows frames up to 15 KB (including FCS)

Signed-off-by: DENG Qingfang <dqfext@gmail.com>
---
 drivers/net/dsa/mt7530.c | 16 ++++++++++++++++
 drivers/net/dsa/mt7530.h |  7 +++++++
 2 files changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 2d0d91db0ddb..ed080ded34a7 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -1284,6 +1284,19 @@  mtk_get_tag_protocol(struct dsa_switch *ds, int port,
 	}
 }
 
+static void
+mt7530_set_jumbo(struct mt7530_priv *priv, u8 kilobytes)
+{
+	if (kilobytes > 15)
+		kilobytes = 15;
+
+	if (kilobytes > 1)
+		mt7530_rmw(priv, MT7530_GMACCR, MAX_RX_JUMBO_MASK | MAX_RX_PKT_LEN_MASK,
+			   MAX_RX_JUMBO_KB(kilobytes) | MAX_RX_PKT_LEN_JMB);
+	else
+		mt7530_rmw(priv, MT7530_GMACCR, MAX_RX_PKT_LEN_MASK, MAX_RX_PKT_LEN_1536);
+}
+
 static int
 mt7530_setup(struct dsa_switch *ds)
 {
@@ -1428,6 +1441,9 @@  mt7530_setup(struct dsa_switch *ds)
 	if (ret < 0)
 		return ret;
 
+	/* Enable jumbo frame up to 15 KB */
+	mt7530_set_jumbo(priv, 15);
+
 	return 0;
 }
 
diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h
index ef9b52f3152b..62f5ea64670d 100644
--- a/drivers/net/dsa/mt7530.h
+++ b/drivers/net/dsa/mt7530.h
@@ -223,6 +223,13 @@  enum mt7530_vlan_port_attr {
 #define  PMSR_DPX			BIT(1)
 #define  PMSR_LINK			BIT(0)
 
+#define MT7530_GMACCR			0x30e0
+#define  MAX_RX_JUMBO_KB(x)		((x) << 2)
+#define  MAX_RX_JUMBO_MASK		MAX_RX_JUMBO_KB(0xf)
+#define  MAX_RX_PKT_LEN_MASK		0x3
+#define  MAX_RX_PKT_LEN_1536		0x1
+#define  MAX_RX_PKT_LEN_JMB		MAX_RX_PKT_LEN_MASK
+
 /* Register for MIB */
 #define MT7530_PORT_MIB_COUNTER(x)	(0x4000 + (x) * 0x100)
 #define MT7530_MIB_CCR			0x4fe0