All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v6 0/6] net: dsa: microchip: add MTU support for KSZ8 series
@ 2022-11-24 10:14 Oleksij Rempel
  2022-11-24 10:14 ` [PATCH net-next v6 1/6] net: dsa: microchip: move max mtu to one location Oleksij Rempel
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Oleksij Rempel @ 2022-11-24 10:14 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Arun.Ramadoss

changes v6:
- move dsa configuration to ksz8_setup 

changes v5:
- add mtu normalization patch

changes v4:
- remove per port max_frame cache
- remove port variable for ksz88* variants
- add KSZ9563_CHIP_ID
- not start a new line with an operator

changes v3:
- rename KSZ8863_LEGAL_PACKET_SIZE -> KSZ8_LEGAL_PACKET_SIZE

changes v2:
- add ksz_rmw8() helper
- merge all max MTUs to one location

Oleksij Rempel (6):
  net: dsa: microchip: move max mtu to one location
  net: dsa: microchip: do not store max MTU for all ports
  net: dsa: microchip: add ksz_rmw8() function
  net: dsa: microchip: ksz8: add MTU configuration support
  net: dsa: microchip: enable MTU normalization for KSZ8795 and KSZ9477
    compatible switches
  net: dsa: microchip: ksz8: move all DSA configurations to one location

 drivers/net/dsa/microchip/ksz8.h        |  1 +
 drivers/net/dsa/microchip/ksz8795.c     | 75 +++++++++++++++++++++----
 drivers/net/dsa/microchip/ksz8795_reg.h |  3 +
 drivers/net/dsa/microchip/ksz9477.c     | 21 +++----
 drivers/net/dsa/microchip/ksz9477.h     |  1 -
 drivers/net/dsa/microchip/ksz9477_reg.h |  2 -
 drivers/net/dsa/microchip/ksz_common.c  | 29 ++++++++--
 drivers/net/dsa/microchip/ksz_common.h  | 13 ++++-
 8 files changed, 109 insertions(+), 36 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH net-next v6 1/6] net: dsa: microchip: move max mtu to one location
  2022-11-24 10:14 [PATCH net-next v6 0/6] net: dsa: microchip: add MTU support for KSZ8 series Oleksij Rempel
@ 2022-11-24 10:14 ` Oleksij Rempel
  2022-11-24 10:14 ` [PATCH net-next v6 2/6] net: dsa: microchip: do not store max MTU for all ports Oleksij Rempel
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2022-11-24 10:14 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Oleksij Rempel, Arun Ramadoss, kernel, linux-kernel, netdev,
	Arun.Ramadoss

There are no HW specific registers, so we can process all of them
in one location.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Tested-by: Arun Ramadoss <arun.ramadoss@microchip.com> (KSZ9893 and LAN937x)
---
 drivers/net/dsa/microchip/ksz9477.c     |  5 -----
 drivers/net/dsa/microchip/ksz9477.h     |  1 -
 drivers/net/dsa/microchip/ksz9477_reg.h |  2 --
 drivers/net/dsa/microchip/ksz_common.c  | 22 +++++++++++++++++-----
 drivers/net/dsa/microchip/ksz_common.h  |  3 ++-
 5 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 0d6b40968657..602d00671bef 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -60,11 +60,6 @@ int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu)
 				  REG_SW_MTU_MASK, max_frame);
 }
 
-int ksz9477_max_mtu(struct ksz_device *dev, int port)
-{
-	return KSZ9477_MAX_FRAME_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN;
-}
-
 static int ksz9477_wait_vlan_ctrl_ready(struct ksz_device *dev)
 {
 	unsigned int val;
diff --git a/drivers/net/dsa/microchip/ksz9477.h b/drivers/net/dsa/microchip/ksz9477.h
index 00862c4cfb7f..7c5bb3032772 100644
--- a/drivers/net/dsa/microchip/ksz9477.h
+++ b/drivers/net/dsa/microchip/ksz9477.h
@@ -50,7 +50,6 @@ int ksz9477_mdb_add(struct ksz_device *dev, int port,
 int ksz9477_mdb_del(struct ksz_device *dev, int port,
 		    const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
 int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu);
-int ksz9477_max_mtu(struct ksz_device *dev, int port);
 void ksz9477_config_cpu_port(struct dsa_switch *ds);
 int ksz9477_enable_stp_addr(struct ksz_device *dev);
 int ksz9477_reset_switch(struct ksz_device *dev);
diff --git a/drivers/net/dsa/microchip/ksz9477_reg.h b/drivers/net/dsa/microchip/ksz9477_reg.h
index 53c68d286dd3..cc457fa64939 100644
--- a/drivers/net/dsa/microchip/ksz9477_reg.h
+++ b/drivers/net/dsa/microchip/ksz9477_reg.h
@@ -1615,6 +1615,4 @@
 #define PTP_TRIG_UNIT_M			(BIT(MAX_TRIG_UNIT) - 1)
 #define PTP_TS_UNIT_M			(BIT(MAX_TIMESTAMP_UNIT) - 1)
 
-#define KSZ9477_MAX_FRAME_SIZE		9000
-
 #endif /* KSZ9477_REGS_H */
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 8c8db315317d..49a5a236d958 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -14,6 +14,7 @@
 #include <linux/phy.h>
 #include <linux/etherdevice.h>
 #include <linux/if_bridge.h>
+#include <linux/if_vlan.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/of_mdio.h>
@@ -206,7 +207,6 @@ static const struct ksz_dev_ops ksz9477_dev_ops = {
 	.mdb_add = ksz9477_mdb_add,
 	.mdb_del = ksz9477_mdb_del,
 	.change_mtu = ksz9477_change_mtu,
-	.max_mtu = ksz9477_max_mtu,
 	.phylink_mac_link_up = ksz9477_phylink_mac_link_up,
 	.config_cpu_port = ksz9477_config_cpu_port,
 	.enable_stp_addr = ksz9477_enable_stp_addr,
@@ -243,7 +243,6 @@ static const struct ksz_dev_ops lan937x_dev_ops = {
 	.mdb_add = ksz9477_mdb_add,
 	.mdb_del = ksz9477_mdb_del,
 	.change_mtu = lan937x_change_mtu,
-	.max_mtu = ksz9477_max_mtu,
 	.phylink_mac_link_up = ksz9477_phylink_mac_link_up,
 	.config_cpu_port = lan937x_config_cpu_port,
 	.enable_stp_addr = ksz9477_enable_stp_addr,
@@ -2500,10 +2499,23 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)
 {
 	struct ksz_device *dev = ds->priv;
 
-	if (!dev->dev_ops->max_mtu)
-		return -EOPNOTSUPP;
+	switch (dev->chip_id) {
+	case KSZ8563_CHIP_ID:
+	case KSZ9477_CHIP_ID:
+	case KSZ9563_CHIP_ID:
+	case KSZ9567_CHIP_ID:
+	case KSZ9893_CHIP_ID:
+	case KSZ9896_CHIP_ID:
+	case KSZ9897_CHIP_ID:
+	case LAN9370_CHIP_ID:
+	case LAN9371_CHIP_ID:
+	case LAN9372_CHIP_ID:
+	case LAN9373_CHIP_ID:
+	case LAN9374_CHIP_ID:
+		return KSZ9477_MAX_FRAME_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN;
+	}
 
-	return dev->dev_ops->max_mtu(dev, port);
+	return -EOPNOTSUPP;
 }
 
 static void ksz_set_xmii(struct ksz_device *dev, int port,
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index c6726cbd5465..27c26ee15af4 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -322,7 +322,6 @@ struct ksz_dev_ops {
 	void (*get_caps)(struct ksz_device *dev, int port,
 			 struct phylink_config *config);
 	int (*change_mtu)(struct ksz_device *dev, int port, int mtu);
-	int (*max_mtu)(struct ksz_device *dev, int port);
 	void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze);
 	void (*port_init_cnt)(struct ksz_device *dev, int port);
 	void (*phylink_mac_config)(struct ksz_device *dev, int port,
@@ -588,6 +587,8 @@ static inline int is_lan937x(struct ksz_device *dev)
 
 #define PORT_SRC_PHY_INT		1
 
+#define KSZ9477_MAX_FRAME_SIZE		9000
+
 /* Regmap tables generation */
 #define KSZ_SPI_OP_RD		3
 #define KSZ_SPI_OP_WR		2
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v6 2/6] net: dsa: microchip: do not store max MTU for all ports
  2022-11-24 10:14 [PATCH net-next v6 0/6] net: dsa: microchip: add MTU support for KSZ8 series Oleksij Rempel
  2022-11-24 10:14 ` [PATCH net-next v6 1/6] net: dsa: microchip: move max mtu to one location Oleksij Rempel
@ 2022-11-24 10:14 ` Oleksij Rempel
  2022-11-24 10:14 ` [PATCH net-next v6 3/6] net: dsa: microchip: add ksz_rmw8() function Oleksij Rempel
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2022-11-24 10:14 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Arun.Ramadoss

If we have global MTU configuration, it is enough to configure it on CPU
port only.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/microchip/ksz9477.c    | 14 +++++---------
 drivers/net/dsa/microchip/ksz_common.h |  1 -
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 602d00671bef..f6e7968ab105 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -45,19 +45,15 @@ static void ksz9477_port_cfg32(struct ksz_device *dev, int port, int offset,
 
 int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu)
 {
-	u16 frame_size, max_frame = 0;
-	int i;
-
-	frame_size = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
+	u16 frame_size;
 
-	/* Cache the per-port MTU setting */
-	dev->ports[port].max_frame = frame_size;
+	if (!dsa_is_cpu_port(dev->ds, port))
+		return 0;
 
-	for (i = 0; i < dev->info->port_cnt; i++)
-		max_frame = max(max_frame, dev->ports[i].max_frame);
+	frame_size = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
 
 	return regmap_update_bits(dev->regmap[1], REG_SW_MTU__2,
-				  REG_SW_MTU_MASK, max_frame);
+				  REG_SW_MTU_MASK, frame_size);
 }
 
 static int ksz9477_wait_vlan_ctrl_ready(struct ksz_device *dev)
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 27c26ee15af4..61228be299f9 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -95,7 +95,6 @@ struct ksz_port {
 
 	struct ksz_port_mib mib;
 	phy_interface_t interface;
-	u16 max_frame;
 	u32 rgmii_tx_val;
 	u32 rgmii_rx_val;
 	struct ksz_device *ksz_dev;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v6 3/6] net: dsa: microchip: add ksz_rmw8() function
  2022-11-24 10:14 [PATCH net-next v6 0/6] net: dsa: microchip: add MTU support for KSZ8 series Oleksij Rempel
  2022-11-24 10:14 ` [PATCH net-next v6 1/6] net: dsa: microchip: move max mtu to one location Oleksij Rempel
  2022-11-24 10:14 ` [PATCH net-next v6 2/6] net: dsa: microchip: do not store max MTU for all ports Oleksij Rempel
@ 2022-11-24 10:14 ` Oleksij Rempel
  2022-11-24 10:14 ` [PATCH net-next v6 4/6] net: dsa: microchip: ksz8: add MTU configuration support Oleksij Rempel
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2022-11-24 10:14 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Oleksij Rempel, Arun Ramadoss, kernel, linux-kernel, netdev,
	Arun.Ramadoss

Add ksz_rmw8(), it will be used in the next patch.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/microchip/ksz_common.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 61228be299f9..5f404a444ce1 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -454,6 +454,11 @@ static inline int ksz_write64(struct ksz_device *dev, u32 reg, u64 value)
 	return regmap_bulk_write(dev->regmap[2], reg, val, 2);
 }
 
+static inline int ksz_rmw8(struct ksz_device *dev, int offset, u8 mask, u8 val)
+{
+	return regmap_update_bits(dev->regmap[0], offset, mask, val);
+}
+
 static inline int ksz_pread8(struct ksz_device *dev, int port, int offset,
 			     u8 *data)
 {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v6 4/6] net: dsa: microchip: ksz8: add MTU configuration support
  2022-11-24 10:14 [PATCH net-next v6 0/6] net: dsa: microchip: add MTU support for KSZ8 series Oleksij Rempel
                   ` (2 preceding siblings ...)
  2022-11-24 10:14 ` [PATCH net-next v6 3/6] net: dsa: microchip: add ksz_rmw8() function Oleksij Rempel
@ 2022-11-24 10:14 ` Oleksij Rempel
  2022-11-24 10:14 ` [PATCH net-next v6 5/6] net: dsa: microchip: enable MTU normalization for KSZ8795 and KSZ9477 compatible switches Oleksij Rempel
  2022-11-24 10:14 ` [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location Oleksij Rempel
  5 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2022-11-24 10:14 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Oleksij Rempel, Arun Ramadoss, kernel, linux-kernel, netdev,
	Arun.Ramadoss

Make MTU configurable on KSZ87xx and KSZ88xx series of switches.

Before this patch, pre-configured behavior was different on different
switch series, due to opposite meaning of the same bit:
- KSZ87xx: Reg 4, Bit 1 - if 1, max frame size is 1532; if 0 - 1514
- KSZ88xx: Reg 4, Bit 1 - if 1, max frame size is 1514; if 0 - 1532

Since the code was telling "... SW_LEGAL_PACKET_DISABLE, true)", I
assume, the idea was to set max frame size to 1532.

With this patch, by setting MTU size 1500, both switch series will be
configured to the 1532 frame limit.

This patch was tested on KSZ8873.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/microchip/ksz8.h        |  1 +
 drivers/net/dsa/microchip/ksz8795.c     | 53 ++++++++++++++++++++++++-
 drivers/net/dsa/microchip/ksz8795_reg.h |  3 ++
 drivers/net/dsa/microchip/ksz_common.c  |  7 ++++
 drivers/net/dsa/microchip/ksz_common.h  |  4 ++
 5 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz8.h b/drivers/net/dsa/microchip/ksz8.h
index 8582b4b67d98..ea05abfbd51d 100644
--- a/drivers/net/dsa/microchip/ksz8.h
+++ b/drivers/net/dsa/microchip/ksz8.h
@@ -57,5 +57,6 @@ int ksz8_reset_switch(struct ksz_device *dev);
 int ksz8_switch_detect(struct ksz_device *dev);
 int ksz8_switch_init(struct ksz_device *dev);
 void ksz8_switch_exit(struct ksz_device *dev);
+int ksz8_change_mtu(struct ksz_device *dev, int port, int mtu);
 
 #endif
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index bd3b133e7085..d01bfd609130 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -76,6 +76,57 @@ int ksz8_reset_switch(struct ksz_device *dev)
 	return 0;
 }
 
+static int ksz8863_change_mtu(struct ksz_device *dev, int frame_size)
+{
+	u8 ctrl2 = 0;
+
+	if (frame_size <= KSZ8_LEGAL_PACKET_SIZE)
+		ctrl2 |= KSZ8863_LEGAL_PACKET_ENABLE;
+	else if (frame_size > KSZ8863_NORMAL_PACKET_SIZE)
+		ctrl2 |= KSZ8863_HUGE_PACKET_ENABLE;
+
+	return ksz_rmw8(dev, REG_SW_CTRL_2, KSZ8863_LEGAL_PACKET_ENABLE |
+			KSZ8863_HUGE_PACKET_ENABLE, ctrl2);
+}
+
+static int ksz8795_change_mtu(struct ksz_device *dev, int frame_size)
+{
+	u8 ctrl1 = 0, ctrl2 = 0;
+	int ret;
+
+	if (frame_size > KSZ8_LEGAL_PACKET_SIZE)
+		ctrl2 |= SW_LEGAL_PACKET_DISABLE;
+	else if (frame_size > KSZ8863_NORMAL_PACKET_SIZE)
+		ctrl1 |= SW_HUGE_PACKET;
+
+	ret = ksz_rmw8(dev, REG_SW_CTRL_1, SW_HUGE_PACKET, ctrl1);
+	if (ret)
+		return ret;
+
+	return ksz_rmw8(dev, REG_SW_CTRL_2, SW_LEGAL_PACKET_DISABLE, ctrl2);
+}
+
+int ksz8_change_mtu(struct ksz_device *dev, int port, int mtu)
+{
+	u16 frame_size;
+
+	if (!dsa_is_cpu_port(dev->ds, port))
+		return 0;
+
+	frame_size = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
+
+	switch (dev->chip_id) {
+	case KSZ8795_CHIP_ID:
+	case KSZ8794_CHIP_ID:
+	case KSZ8765_CHIP_ID:
+		return ksz8795_change_mtu(dev, frame_size);
+	case KSZ8830_CHIP_ID:
+		return ksz8863_change_mtu(dev, frame_size);
+	}
+
+	return -EOPNOTSUPP;
+}
+
 static void ksz8795_set_prio_queue(struct ksz_device *dev, int port, int queue)
 {
 	u8 hi, lo;
@@ -1233,8 +1284,6 @@ void ksz8_config_cpu_port(struct dsa_switch *ds)
 	masks = dev->info->masks;
 	regs = dev->info->regs;
 
-	/* Switch marks the maximum frame with extra byte as oversize. */
-	ksz_cfg(dev, REG_SW_CTRL_2, SW_LEGAL_PACKET_DISABLE, true);
 	ksz_cfg(dev, regs[S_TAIL_TAG_CTRL], masks[SW_TAIL_TAG_ENABLE], true);
 
 	p = &dev->ports[dev->cpu_port];
diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h
index 77487d611824..7a57c6088f80 100644
--- a/drivers/net/dsa/microchip/ksz8795_reg.h
+++ b/drivers/net/dsa/microchip/ksz8795_reg.h
@@ -48,6 +48,9 @@
 #define NO_EXC_COLLISION_DROP		BIT(3)
 #define SW_LEGAL_PACKET_DISABLE		BIT(1)
 
+#define KSZ8863_HUGE_PACKET_ENABLE	BIT(2)
+#define KSZ8863_LEGAL_PACKET_ENABLE	BIT(1)
+
 #define REG_SW_CTRL_3			0x05
  #define WEIGHTED_FAIR_QUEUE_ENABLE	BIT(3)
 
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 49a5a236d958..f39b041765fb 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -172,6 +172,7 @@ static const struct ksz_dev_ops ksz8_dev_ops = {
 	.reset = ksz8_reset_switch,
 	.init = ksz8_switch_init,
 	.exit = ksz8_switch_exit,
+	.change_mtu = ksz8_change_mtu,
 };
 
 static void ksz9477_phylink_mac_link_up(struct ksz_device *dev, int port,
@@ -2500,6 +2501,12 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)
 	struct ksz_device *dev = ds->priv;
 
 	switch (dev->chip_id) {
+	case KSZ8795_CHIP_ID:
+	case KSZ8794_CHIP_ID:
+	case KSZ8765_CHIP_ID:
+		return KSZ8795_HUGE_PACKET_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN;
+	case KSZ8830_CHIP_ID:
+		return KSZ8863_HUGE_PACKET_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN;
 	case KSZ8563_CHIP_ID:
 	case KSZ9477_CHIP_ID:
 	case KSZ9563_CHIP_ID:
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 5f404a444ce1..cb27f5a180c7 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -591,6 +591,10 @@ static inline int is_lan937x(struct ksz_device *dev)
 
 #define PORT_SRC_PHY_INT		1
 
+#define KSZ8795_HUGE_PACKET_SIZE	2000
+#define KSZ8863_HUGE_PACKET_SIZE	1916
+#define KSZ8863_NORMAL_PACKET_SIZE	1536
+#define KSZ8_LEGAL_PACKET_SIZE		1518
 #define KSZ9477_MAX_FRAME_SIZE		9000
 
 /* Regmap tables generation */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v6 5/6] net: dsa: microchip: enable MTU normalization for KSZ8795 and KSZ9477 compatible switches
  2022-11-24 10:14 [PATCH net-next v6 0/6] net: dsa: microchip: add MTU support for KSZ8 series Oleksij Rempel
                   ` (3 preceding siblings ...)
  2022-11-24 10:14 ` [PATCH net-next v6 4/6] net: dsa: microchip: ksz8: add MTU configuration support Oleksij Rempel
@ 2022-11-24 10:14 ` Oleksij Rempel
  2022-11-24 15:08   ` Arun.Ramadoss
  2022-11-25 21:32   ` Vladimir Oltean
  2022-11-24 10:14 ` [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location Oleksij Rempel
  5 siblings, 2 replies; 16+ messages in thread
From: Oleksij Rempel @ 2022-11-24 10:14 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Arun.Ramadoss

KSZ8795 and KSZ9477 compatible series of switches use global max frame
size configuration register. So, enable MTU normalization for this reason.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz8795.c | 2 ++
 drivers/net/dsa/microchip/ksz9477.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index d01bfd609130..060e41b9b6ef 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -1357,6 +1357,8 @@ int ksz8_setup(struct dsa_switch *ds)
 	struct ksz_device *dev = ds->priv;
 	int i;
 
+	ds->mtu_enforcement_ingress = true;
+
 	ksz_cfg(dev, S_REPLACE_VID_CTRL, SW_FLOW_CTRL, true);
 
 	/* Enable automatic fast aging when link changed detected. */
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index f6e7968ab105..47b54ecf2c6f 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1134,6 +1134,8 @@ int ksz9477_setup(struct dsa_switch *ds)
 	struct ksz_device *dev = ds->priv;
 	int ret = 0;
 
+	ds->mtu_enforcement_ingress = true;
+
 	/* Required for port partitioning. */
 	ksz9477_cfg32(dev, REG_SW_QM_CTRL__4, UNICAST_VLAN_BOUNDARY,
 		      true);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location
  2022-11-24 10:14 [PATCH net-next v6 0/6] net: dsa: microchip: add MTU support for KSZ8 series Oleksij Rempel
                   ` (4 preceding siblings ...)
  2022-11-24 10:14 ` [PATCH net-next v6 5/6] net: dsa: microchip: enable MTU normalization for KSZ8795 and KSZ9477 compatible switches Oleksij Rempel
@ 2022-11-24 10:14 ` Oleksij Rempel
  2022-11-24 15:05   ` Arun.Ramadoss
  2022-11-25 21:33   ` Vladimir Oltean
  5 siblings, 2 replies; 16+ messages in thread
From: Oleksij Rempel @ 2022-11-24 10:14 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Arun.Ramadoss

To make the code more comparable to KSZ9477 code, move DSA
configurations to the same location.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz8795.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index 060e41b9b6ef..003b0ac2854c 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -1359,6 +1359,16 @@ int ksz8_setup(struct dsa_switch *ds)
 
 	ds->mtu_enforcement_ingress = true;
 
+	/* We rely on software untagging on the CPU port, so that we
+	 * can support both tagged and untagged VLANs
+	 */
+	ds->untag_bridge_pvid = true;
+
+	/* VLAN filtering is partly controlled by the global VLAN
+	 * Enable flag
+	 */
+	ds->vlan_filtering_is_global = true;
+
 	ksz_cfg(dev, S_REPLACE_VID_CTRL, SW_FLOW_CTRL, true);
 
 	/* Enable automatic fast aging when link changed detected. */
@@ -1418,16 +1428,6 @@ int ksz8_switch_init(struct ksz_device *dev)
 	dev->phy_port_cnt = dev->info->port_cnt - 1;
 	dev->port_mask = (BIT(dev->phy_port_cnt) - 1) | dev->info->cpu_ports;
 
-	/* We rely on software untagging on the CPU port, so that we
-	 * can support both tagged and untagged VLANs
-	 */
-	dev->ds->untag_bridge_pvid = true;
-
-	/* VLAN filtering is partly controlled by the global VLAN
-	 * Enable flag
-	 */
-	dev->ds->vlan_filtering_is_global = true;
-
 	return 0;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location
  2022-11-24 10:14 ` [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location Oleksij Rempel
@ 2022-11-24 15:05   ` Arun.Ramadoss
  2022-11-25  5:52     ` Oleksij Rempel
  2022-11-25 21:33   ` Vladimir Oltean
  1 sibling, 1 reply; 16+ messages in thread
From: Arun.Ramadoss @ 2022-11-24 15:05 UTC (permalink / raw)
  To: olteanv, UNGLinuxDriver, vivien.didelot, andrew, f.fainelli,
	kuba, edumazet, pabeni, o.rempel, Woojung.Huh, davem
  Cc: linux-kernel, netdev, kernel

Hi Oleksij,
On Thu, 2022-11-24 at 11:14 +0100, Oleksij Rempel wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> To make the code more comparable to KSZ9477 code, move DSA
> configurations to the same location.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/dsa/microchip/ksz8795.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/dsa/microchip/ksz8795.c
> b/drivers/net/dsa/microchip/ksz8795.c
> index 060e41b9b6ef..003b0ac2854c 100644
> --- a/drivers/net/dsa/microchip/ksz8795.c
> +++ b/drivers/net/dsa/microchip/ksz8795.c
> @@ -1359,6 +1359,16 @@ int ksz8_setup(struct dsa_switch *ds)
> 
>         ds->mtu_enforcement_ingress = true;
> 
> +       /* We rely on software untagging on the CPU port, so that we
> +        * can support both tagged and untagged VLANs
> +        */
> +       ds->untag_bridge_pvid = true;
> +
> +       /* VLAN filtering is partly controlled by the global VLAN
> +        * Enable flag
> +        */
> +       ds->vlan_filtering_is_global = true;
> +
>         ksz_cfg(dev, S_REPLACE_VID_CTRL, SW_FLOW_CTRL, true);
> 
>         /* Enable automatic fast aging when link changed detected. */
> @@ -1418,16 +1428,6 @@ int ksz8_switch_init(struct ksz_device *dev)
>         dev->phy_port_cnt = dev->info->port_cnt - 1;
>         dev->port_mask = (BIT(dev->phy_port_cnt) - 1) | dev->info-
> >cpu_ports;

Since you moved dsa related items to ksz8_setup, remaining items in
ksz8_switch_init are
- dev->cpu_port - Used in ksz_setup but called after the individual
switch setup function. We can move it ksz8_setup.
- dev->phy_port_cnt - Used in ksz8_vlan_filtering and
ksz8_config_cpuport. We can move.
- dev->port_mask - used in ksz_switch_register. So we cannot move.

To make the ksz8_switch_init and ksz9477_switch_init function similar,
we can move dev->cpu_port and dev->phy_port_cnt from ksz8_switch_init
to ksz8_setup

> 
> -       /* We rely on software untagging on the CPU port, so that we
> -        * can support both tagged and untagged VLANs
> -        */
> -       dev->ds->untag_bridge_pvid = true;
> -
> -       /* VLAN filtering is partly controlled by the global VLAN
> -        * Enable flag
> -        */
> -       dev->ds->vlan_filtering_is_global = true;
> -
>         return 0;
>  }
> 
> --
> 2.30.2
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v6 5/6] net: dsa: microchip: enable MTU normalization for KSZ8795 and KSZ9477 compatible switches
  2022-11-24 10:14 ` [PATCH net-next v6 5/6] net: dsa: microchip: enable MTU normalization for KSZ8795 and KSZ9477 compatible switches Oleksij Rempel
@ 2022-11-24 15:08   ` Arun.Ramadoss
  2022-11-25 21:32   ` Vladimir Oltean
  1 sibling, 0 replies; 16+ messages in thread
From: Arun.Ramadoss @ 2022-11-24 15:08 UTC (permalink / raw)
  To: olteanv, UNGLinuxDriver, vivien.didelot, andrew, f.fainelli,
	kuba, edumazet, pabeni, o.rempel, Woojung.Huh, davem
  Cc: linux-kernel, netdev, kernel

On Thu, 2022-11-24 at 11:14 +0100, Oleksij Rempel wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> KSZ8795 and KSZ9477 compatible series of switches use global max
> frame
> size configuration register. So, enable MTU normalization for this
> reason.

Acked-by: Arun Ramadoss <arun.ramadoss@microchip.com>

> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/dsa/microchip/ksz8795.c | 2 ++
>  drivers/net/dsa/microchip/ksz9477.c | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/net/dsa/microchip/ksz8795.c
> b/drivers/net/dsa/microchip/ksz8795.c
> index d01bfd609130..060e41b9b6ef 100644
> --- a/drivers/net/dsa/microchip/ksz8795.c
> +++ b/drivers/net/dsa/microchip/ksz8795.c
> @@ -1357,6 +1357,8 @@ int ksz8_setup(struct dsa_switch *ds)
>         struct ksz_device *dev = ds->priv;
>         int i;
> 
> +       ds->mtu_enforcement_ingress = true;
> +
>         ksz_cfg(dev, S_REPLACE_VID_CTRL, SW_FLOW_CTRL, true);
> 
>         /* Enable automatic fast aging when link changed detected. */
> diff --git a/drivers/net/dsa/microchip/ksz9477.c
> b/drivers/net/dsa/microchip/ksz9477.c
> index f6e7968ab105..47b54ecf2c6f 100644
> --- a/drivers/net/dsa/microchip/ksz9477.c
> +++ b/drivers/net/dsa/microchip/ksz9477.c
> @@ -1134,6 +1134,8 @@ int ksz9477_setup(struct dsa_switch *ds)
>         struct ksz_device *dev = ds->priv;
>         int ret = 0;
> 
> +       ds->mtu_enforcement_ingress = true;
> +
>         /* Required for port partitioning. */
>         ksz9477_cfg32(dev, REG_SW_QM_CTRL__4, UNICAST_VLAN_BOUNDARY,
>                       true);
> --
> 2.30.2
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location
  2022-11-24 15:05   ` Arun.Ramadoss
@ 2022-11-25  5:52     ` Oleksij Rempel
  2022-11-25  7:14       ` Arun.Ramadoss
  0 siblings, 1 reply; 16+ messages in thread
From: Oleksij Rempel @ 2022-11-25  5:52 UTC (permalink / raw)
  To: Arun.Ramadoss
  Cc: olteanv, UNGLinuxDriver, vivien.didelot, andrew, f.fainelli,
	kuba, edumazet, pabeni, Woojung.Huh, davem, netdev, linux-kernel,
	kernel

Hi Arun,

On Thu, Nov 24, 2022 at 03:05:27PM +0000, Arun.Ramadoss@microchip.com wrote:
> Hi Oleksij,
> On Thu, 2022-11-24 at 11:14 +0100, Oleksij Rempel wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > know the content is safe
> > 
> > To make the code more comparable to KSZ9477 code, move DSA
> > configurations to the same location.
> > 
> > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> > ---
> >  drivers/net/dsa/microchip/ksz8795.c | 20 ++++++++++----------
> >  1 file changed, 10 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/net/dsa/microchip/ksz8795.c
> > b/drivers/net/dsa/microchip/ksz8795.c
> > index 060e41b9b6ef..003b0ac2854c 100644
> > --- a/drivers/net/dsa/microchip/ksz8795.c
> > +++ b/drivers/net/dsa/microchip/ksz8795.c
> > @@ -1359,6 +1359,16 @@ int ksz8_setup(struct dsa_switch *ds)
> > 
> >         ds->mtu_enforcement_ingress = true;
> > 
> > +       /* We rely on software untagging on the CPU port, so that we
> > +        * can support both tagged and untagged VLANs
> > +        */
> > +       ds->untag_bridge_pvid = true;
> > +
> > +       /* VLAN filtering is partly controlled by the global VLAN
> > +        * Enable flag
> > +        */
> > +       ds->vlan_filtering_is_global = true;
> > +
> >         ksz_cfg(dev, S_REPLACE_VID_CTRL, SW_FLOW_CTRL, true);
> > 
> >         /* Enable automatic fast aging when link changed detected. */
> > @@ -1418,16 +1428,6 @@ int ksz8_switch_init(struct ksz_device *dev)
> >         dev->phy_port_cnt = dev->info->port_cnt - 1;
> >         dev->port_mask = (BIT(dev->phy_port_cnt) - 1) | dev->info-
> > >cpu_ports;
> 
> Since you moved dsa related items to ksz8_setup, remaining items in
> ksz8_switch_init are
> - dev->cpu_port - Used in ksz_setup but called after the individual
> switch setup function. We can move it ksz8_setup.
> - dev->phy_port_cnt - Used in ksz8_vlan_filtering and
> ksz8_config_cpuport. We can move.
> - dev->port_mask - used in ksz_switch_register. So we cannot move.
> 
> To make the ksz8_switch_init and ksz9477_switch_init function similar,
> we can move dev->cpu_port and dev->phy_port_cnt from ksz8_switch_init
> to ksz8_setup

It make no sense to move this variables. Every place where they are
used, can be replaced with dsa functions like:
dsa_switch_for_each_user_port() or dsa_cpu_ports()/dsa_is_cpu_port()

Making this changes within this patch set make no sense to.

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location
  2022-11-25  5:52     ` Oleksij Rempel
@ 2022-11-25  7:14       ` Arun.Ramadoss
  2022-11-25  7:49         ` Oleksij Rempel
  2022-11-25 11:54         ` Oleksij Rempel
  0 siblings, 2 replies; 16+ messages in thread
From: Arun.Ramadoss @ 2022-11-25  7:14 UTC (permalink / raw)
  To: o.rempel
  Cc: olteanv, UNGLinuxDriver, linux-kernel, vivien.didelot, andrew,
	f.fainelli, kuba, edumazet, pabeni, netdev, Woojung.Huh, davem,
	kernel

Hi Oleksij,

On Fri, 2022-11-25 at 06:52 +0100, Oleksij Rempel wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> Hi Arun,
> 
> On Thu, Nov 24, 2022 at 03:05:27PM +0000, Arun.Ramadoss@microchip.com
>  wrote:
> > Hi Oleksij,
> > On Thu, 2022-11-24 at 11:14 +0100, Oleksij Rempel wrote:
> > > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > > know the content is safe
> > > 
> > > To make the code more comparable to KSZ9477 code, move DSA
> > > configurations to the same location.
> > > 
> > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> > > ---
> > >  drivers/net/dsa/microchip/ksz8795.c | 20 ++++++++++----------
> > >  1 file changed, 10 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/drivers/net/dsa/microchip/ksz8795.c
> > > b/drivers/net/dsa/microchip/ksz8795.c
> > > index 060e41b9b6ef..003b0ac2854c 100644
> > > --- a/drivers/net/dsa/microchip/ksz8795.c
> > > +++ b/drivers/net/dsa/microchip/ksz8795.c
> > > @@ -1359,6 +1359,16 @@ int ksz8_setup(struct dsa_switch *ds)
> > > 
> > >         ds->mtu_enforcement_ingress = true;
> > > 
> > > +       /* We rely on software untagging on the CPU port, so that
> > > we
> > > +        * can support both tagged and untagged VLANs
> > > +        */
> > > +       ds->untag_bridge_pvid = true;
> > > +
> > > +       /* VLAN filtering is partly controlled by the global VLAN
> > > +        * Enable flag
> > > +        */
> > > +       ds->vlan_filtering_is_global = true;
> > > +
> > >         ksz_cfg(dev, S_REPLACE_VID_CTRL, SW_FLOW_CTRL, true);
> > > 
> > >         /* Enable automatic fast aging when link changed
> > > detected. */
> > > @@ -1418,16 +1428,6 @@ int ksz8_switch_init(struct ksz_device
> > > *dev)
> > >         dev->phy_port_cnt = dev->info->port_cnt - 1;
> > >         dev->port_mask = (BIT(dev->phy_port_cnt) - 1) | dev-
> > > >info-
> > > > cpu_ports;
> > 
> > Since you moved dsa related items to ksz8_setup, remaining items in
> > ksz8_switch_init are
> > - dev->cpu_port - Used in ksz_setup but called after the individual
> > switch setup function. We can move it ksz8_setup.
> > - dev->phy_port_cnt - Used in ksz8_vlan_filtering and
> > ksz8_config_cpuport. We can move.
> > - dev->port_mask - used in ksz_switch_register. So we cannot move.
> > 
> > To make the ksz8_switch_init and ksz9477_switch_init function
> > similar,
> > we can move dev->cpu_port and dev->phy_port_cnt from
> > ksz8_switch_init
> > to ksz8_setup
> 
> It make no sense to move this variables. Every place where they are
> used, can be replaced with dsa functions like:
> dsa_switch_for_each_user_port() or dsa_cpu_ports()/dsa_is_cpu_port()
> Making this changes within this patch set make no sense to.

Agreed. 
I thought of cleaning up
ksz8_switch_init/ksz9477_switch_init/lan937x_switch_init, since these
functions are not performing any useful activity other than
initializing these variables. Similarly all the exit function are
performing same reset function. I thought these init and exit function
in the ksz_dev_ops structure is reduntant.

> 
> Regards,
> Oleksij
> --
> Pengutronix
> e.K.                           |                             |
> Steuerwalder Str. 21                       | 
> http://www.pengutronix.de/e/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-
> 0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-
> 5555 |

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location
  2022-11-25  7:14       ` Arun.Ramadoss
@ 2022-11-25  7:49         ` Oleksij Rempel
  2022-11-25 11:54         ` Oleksij Rempel
  1 sibling, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2022-11-25  7:49 UTC (permalink / raw)
  To: Arun.Ramadoss
  Cc: Woojung.Huh, andrew, f.fainelli, davem, netdev, linux-kernel,
	UNGLinuxDriver, edumazet, pabeni, kernel, kuba, olteanv,
	vivien.didelot

On Fri, Nov 25, 2022 at 07:14:32AM +0000, Arun.Ramadoss@microchip.com wrote:
> Hi Oleksij,
> 
> On Fri, 2022-11-25 at 06:52 +0100, Oleksij Rempel wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > know the content is safe
> > 
> > Hi Arun,
> > 
> > On Thu, Nov 24, 2022 at 03:05:27PM +0000, Arun.Ramadoss@microchip.com
> >  wrote:
> > > Hi Oleksij,
> > > On Thu, 2022-11-24 at 11:14 +0100, Oleksij Rempel wrote:
> > > > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > > > know the content is safe
> > > > 
> > > > To make the code more comparable to KSZ9477 code, move DSA
> > > > configurations to the same location.
> > > > 
> > > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> > > > ---
> > > >  drivers/net/dsa/microchip/ksz8795.c | 20 ++++++++++----------
> > > >  1 file changed, 10 insertions(+), 10 deletions(-)
> > > > 
> > > > diff --git a/drivers/net/dsa/microchip/ksz8795.c
> > > > b/drivers/net/dsa/microchip/ksz8795.c
> > > > index 060e41b9b6ef..003b0ac2854c 100644
> > > > --- a/drivers/net/dsa/microchip/ksz8795.c
> > > > +++ b/drivers/net/dsa/microchip/ksz8795.c
> > > > @@ -1359,6 +1359,16 @@ int ksz8_setup(struct dsa_switch *ds)
> > > > 
> > > >         ds->mtu_enforcement_ingress = true;
> > > > 
> > > > +       /* We rely on software untagging on the CPU port, so that
> > > > we
> > > > +        * can support both tagged and untagged VLANs
> > > > +        */
> > > > +       ds->untag_bridge_pvid = true;
> > > > +
> > > > +       /* VLAN filtering is partly controlled by the global VLAN
> > > > +        * Enable flag
> > > > +        */
> > > > +       ds->vlan_filtering_is_global = true;
> > > > +
> > > >         ksz_cfg(dev, S_REPLACE_VID_CTRL, SW_FLOW_CTRL, true);
> > > > 
> > > >         /* Enable automatic fast aging when link changed
> > > > detected. */
> > > > @@ -1418,16 +1428,6 @@ int ksz8_switch_init(struct ksz_device
> > > > *dev)
> > > >         dev->phy_port_cnt = dev->info->port_cnt - 1;
> > > >         dev->port_mask = (BIT(dev->phy_port_cnt) - 1) | dev-
> > > > >info-
> > > > > cpu_ports;
> > > 
> > > Since you moved dsa related items to ksz8_setup, remaining items in
> > > ksz8_switch_init are
> > > - dev->cpu_port - Used in ksz_setup but called after the individual
> > > switch setup function. We can move it ksz8_setup.
> > > - dev->phy_port_cnt - Used in ksz8_vlan_filtering and
> > > ksz8_config_cpuport. We can move.
> > > - dev->port_mask - used in ksz_switch_register. So we cannot move.
> > > 
> > > To make the ksz8_switch_init and ksz9477_switch_init function
> > > similar,
> > > we can move dev->cpu_port and dev->phy_port_cnt from
> > > ksz8_switch_init
> > > to ksz8_setup
> > 
> > It make no sense to move this variables. Every place where they are
> > used, can be replaced with dsa functions like:
> > dsa_switch_for_each_user_port() or dsa_cpu_ports()/dsa_is_cpu_port()
> > Making this changes within this patch set make no sense to.
> 
> Agreed. 
> I thought of cleaning up
> ksz8_switch_init/ksz9477_switch_init/lan937x_switch_init, since these
> functions are not performing any useful activity other than
> initializing these variables. Similarly all the exit function are
> performing same reset function. I thought these init and exit function
> in the ksz_dev_ops structure is reduntant.

I'll try to add ore cleanups to my currently pending patch set.
Currently I'm working on following ksz8 related tasks:
- add MTU configuration support
- add stats64 support
- fix fdb_dump and add fdb_add/del support
- fix PHY loopback support to make selftest work

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location
  2022-11-25  7:14       ` Arun.Ramadoss
  2022-11-25  7:49         ` Oleksij Rempel
@ 2022-11-25 11:54         ` Oleksij Rempel
  2022-11-25 13:46           ` Arun.Ramadoss
  1 sibling, 1 reply; 16+ messages in thread
From: Oleksij Rempel @ 2022-11-25 11:54 UTC (permalink / raw)
  To: Arun.Ramadoss
  Cc: Woojung.Huh, andrew, f.fainelli, davem, netdev, linux-kernel,
	UNGLinuxDriver, edumazet, pabeni, kernel, kuba, olteanv,
	vivien.didelot

On Fri, Nov 25, 2022 at 07:14:32AM +0000, Arun.Ramadoss@microchip.com wrote:
> Hi Oleksij,
> 
> On Fri, 2022-11-25 at 06:52 +0100, Oleksij Rempel wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > know the content is safe
> > 
> > Hi Arun,
> > 
> > On Thu, Nov 24, 2022 at 03:05:27PM +0000, Arun.Ramadoss@microchip.com
> >  wrote:
> > > Hi Oleksij,
> > > On Thu, 2022-11-24 at 11:14 +0100, Oleksij Rempel wrote:
> > > > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > > > know the content is safe
> > > > 
> > > > To make the code more comparable to KSZ9477 code, move DSA
> > > > configurations to the same location.
> > > > 
> > > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> > > > ---
> > > >  drivers/net/dsa/microchip/ksz8795.c | 20 ++++++++++----------
> > > >  1 file changed, 10 insertions(+), 10 deletions(-)
> > > > 
> > > > diff --git a/drivers/net/dsa/microchip/ksz8795.c
> > > > b/drivers/net/dsa/microchip/ksz8795.c
> > > > index 060e41b9b6ef..003b0ac2854c 100644
> > > > --- a/drivers/net/dsa/microchip/ksz8795.c
> > > > +++ b/drivers/net/dsa/microchip/ksz8795.c
> > > > @@ -1359,6 +1359,16 @@ int ksz8_setup(struct dsa_switch *ds)
> > > > 
> > > >         ds->mtu_enforcement_ingress = true;
> > > > 
> > > > +       /* We rely on software untagging on the CPU port, so that
> > > > we
> > > > +        * can support both tagged and untagged VLANs
> > > > +        */
> > > > +       ds->untag_bridge_pvid = true;
> > > > +
> > > > +       /* VLAN filtering is partly controlled by the global VLAN
> > > > +        * Enable flag
> > > > +        */
> > > > +       ds->vlan_filtering_is_global = true;
> > > > +
> > > >         ksz_cfg(dev, S_REPLACE_VID_CTRL, SW_FLOW_CTRL, true);
> > > > 
> > > >         /* Enable automatic fast aging when link changed
> > > > detected. */
> > > > @@ -1418,16 +1428,6 @@ int ksz8_switch_init(struct ksz_device
> > > > *dev)
> > > >         dev->phy_port_cnt = dev->info->port_cnt - 1;
> > > >         dev->port_mask = (BIT(dev->phy_port_cnt) - 1) | dev-
> > > > >info-
> > > > > cpu_ports;
> > > 
> > > Since you moved dsa related items to ksz8_setup, remaining items in
> > > ksz8_switch_init are
> > > - dev->cpu_port - Used in ksz_setup but called after the individual
> > > switch setup function. We can move it ksz8_setup.
> > > - dev->phy_port_cnt - Used in ksz8_vlan_filtering and
> > > ksz8_config_cpuport. We can move.
> > > - dev->port_mask - used in ksz_switch_register. So we cannot move.
> > > 
> > > To make the ksz8_switch_init and ksz9477_switch_init function
> > > similar,
> > > we can move dev->cpu_port and dev->phy_port_cnt from
> > > ksz8_switch_init
> > > to ksz8_setup
> > 
> > It make no sense to move this variables. Every place where they are
> > used, can be replaced with dsa functions like:
> > dsa_switch_for_each_user_port() or dsa_cpu_ports()/dsa_is_cpu_port()
> > Making this changes within this patch set make no sense to.
> 
> Agreed. 
> I thought of cleaning up
> ksz8_switch_init/ksz9477_switch_init/lan937x_switch_init, since these
> functions are not performing any useful activity other than
> initializing these variables. Similarly all the exit function are
> performing same reset function. I thought these init and exit function
> in the ksz_dev_ops structure is reduntant.

Can you please give your Acked-by? :)

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location
  2022-11-25 11:54         ` Oleksij Rempel
@ 2022-11-25 13:46           ` Arun.Ramadoss
  0 siblings, 0 replies; 16+ messages in thread
From: Arun.Ramadoss @ 2022-11-25 13:46 UTC (permalink / raw)
  To: o.rempel
  Cc: andrew, UNGLinuxDriver, linux-kernel, olteanv, vivien.didelot,
	f.fainelli, kuba, edumazet, pabeni, netdev, Woojung.Huh, davem,
	kernel

On Fri, 2022-11-25 at 12:54 +0100, Oleksij Rempel wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> On Fri, Nov 25, 2022 at 07:14:32AM +0000, Arun.Ramadoss@microchip.com
>  wrote:
> > Hi Oleksij,
> > 
> > On Fri, 2022-11-25 at 06:52 +0100, Oleksij Rempel wrote:
> > > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > > know the content is safe
> > > 
> > > Hi Arun,
> > > 
> > > On Thu, Nov 24, 2022 at 03:05:27PM +0000, 
> > > Arun.Ramadoss@microchip.com
> > >  wrote:
> > > > Hi Oleksij,
> > > > On Thu, 2022-11-24 at 11:14 +0100, Oleksij Rempel wrote:
> > > > > EXTERNAL EMAIL: Do not click links or open attachments unless
> > > > > you
> > > > > know the content is safe
> > > > > 
> > > > > To make the code more comparable to KSZ9477 code, move DSA
> > > > > configurations to the same location.
> > > > > 
> > > > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> > > > > ---
> > > > >  drivers/net/dsa/microchip/ksz8795.c | 20 ++++++++++---------
> > > > > -
> > > > >  1 file changed, 10 insertions(+), 10 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/net/dsa/microchip/ksz8795.c
> > > > > b/drivers/net/dsa/microchip/ksz8795.c
> > > > > index 060e41b9b6ef..003b0ac2854c 100644
> > > > > --- a/drivers/net/dsa/microchip/ksz8795.c
> > > > > +++ b/drivers/net/dsa/microchip/ksz8795.c
> > > > > @@ -1359,6 +1359,16 @@ int ksz8_setup(struct dsa_switch *ds)
> > > > > 
> > > > >         ds->mtu_enforcement_ingress = true;
> > > > > 
> > > > > +       /* We rely on software untagging on the CPU port, so
> > > > > that
> > > > > we
> > > > > +        * can support both tagged and untagged VLANs
> > > > > +        */
> > > > > +       ds->untag_bridge_pvid = true;
> > > > > +
> > > > > +       /* VLAN filtering is partly controlled by the global
> > > > > VLAN
> > > > > +        * Enable flag
> > > > > +        */
> > > > > +       ds->vlan_filtering_is_global = true;
> > > > > +
> > > > >         ksz_cfg(dev, S_REPLACE_VID_CTRL, SW_FLOW_CTRL, true);
> > > > > 
> > > > >         /* Enable automatic fast aging when link changed
> > > > > detected. */
> > > > > @@ -1418,16 +1428,6 @@ int ksz8_switch_init(struct ksz_device
> > > > > *dev)
> > > > >         dev->phy_port_cnt = dev->info->port_cnt - 1;
> > > > >         dev->port_mask = (BIT(dev->phy_port_cnt) - 1) | dev-
> > > > > > info-
> > > > > > cpu_ports;
> > > > 
> > > > Since you moved dsa related items to ksz8_setup, remaining
> > > > items in
> > > > ksz8_switch_init are
> > > > - dev->cpu_port - Used in ksz_setup but called after the
> > > > individual
> > > > switch setup function. We can move it ksz8_setup.
> > > > - dev->phy_port_cnt - Used in ksz8_vlan_filtering and
> > > > ksz8_config_cpuport. We can move.
> > > > - dev->port_mask - used in ksz_switch_register. So we cannot
> > > > move.
> > > > 
> > > > To make the ksz8_switch_init and ksz9477_switch_init function
> > > > similar,
> > > > we can move dev->cpu_port and dev->phy_port_cnt from
> > > > ksz8_switch_init
> > > > to ksz8_setup
> > > 
> > > It make no sense to move this variables. Every place where they
> > > are
> > > used, can be replaced with dsa functions like:
> > > dsa_switch_for_each_user_port() or
> > > dsa_cpu_ports()/dsa_is_cpu_port()
> > > Making this changes within this patch set make no sense to.
> > 
> > Agreed.
> > I thought of cleaning up
> > ksz8_switch_init/ksz9477_switch_init/lan937x_switch_init, since
> > these
> > functions are not performing any useful activity other than
> > initializing these variables. Similarly all the exit function are
> > performing same reset function. I thought these init and exit
> > function
> > in the ksz_dev_ops structure is reduntant.
> 
> Can you please give your Acked-by? :)

Acked-by: Arun Ramadoss <arun.ramadoss@microchip.com>

> 
> --
> Pengutronix
> e.K.                           |                             |
> Steuerwalder Str. 21                       | 
> http://www.pengutronix.de/e/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-
> 0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-
> 5555 |

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v6 5/6] net: dsa: microchip: enable MTU normalization for KSZ8795 and KSZ9477 compatible switches
  2022-11-24 10:14 ` [PATCH net-next v6 5/6] net: dsa: microchip: enable MTU normalization for KSZ8795 and KSZ9477 compatible switches Oleksij Rempel
  2022-11-24 15:08   ` Arun.Ramadoss
@ 2022-11-25 21:32   ` Vladimir Oltean
  1 sibling, 0 replies; 16+ messages in thread
From: Vladimir Oltean @ 2022-11-25 21:32 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, kernel, linux-kernel, netdev, Arun.Ramadoss

On Thu, Nov 24, 2022 at 11:14:57AM +0100, Oleksij Rempel wrote:
> KSZ8795 and KSZ9477 compatible series of switches use global max frame
> size configuration register. So, enable MTU normalization for this reason.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location
  2022-11-24 10:14 ` [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location Oleksij Rempel
  2022-11-24 15:05   ` Arun.Ramadoss
@ 2022-11-25 21:33   ` Vladimir Oltean
  1 sibling, 0 replies; 16+ messages in thread
From: Vladimir Oltean @ 2022-11-25 21:33 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, kernel, linux-kernel, netdev, Arun.Ramadoss

On Thu, Nov 24, 2022 at 11:14:58AM +0100, Oleksij Rempel wrote:
> To make the code more comparable to KSZ9477 code, move DSA
> configurations to the same location.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-11-25 21:33 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-24 10:14 [PATCH net-next v6 0/6] net: dsa: microchip: add MTU support for KSZ8 series Oleksij Rempel
2022-11-24 10:14 ` [PATCH net-next v6 1/6] net: dsa: microchip: move max mtu to one location Oleksij Rempel
2022-11-24 10:14 ` [PATCH net-next v6 2/6] net: dsa: microchip: do not store max MTU for all ports Oleksij Rempel
2022-11-24 10:14 ` [PATCH net-next v6 3/6] net: dsa: microchip: add ksz_rmw8() function Oleksij Rempel
2022-11-24 10:14 ` [PATCH net-next v6 4/6] net: dsa: microchip: ksz8: add MTU configuration support Oleksij Rempel
2022-11-24 10:14 ` [PATCH net-next v6 5/6] net: dsa: microchip: enable MTU normalization for KSZ8795 and KSZ9477 compatible switches Oleksij Rempel
2022-11-24 15:08   ` Arun.Ramadoss
2022-11-25 21:32   ` Vladimir Oltean
2022-11-24 10:14 ` [PATCH net-next v6 6/6] net: dsa: microchip: ksz8: move all DSA configurations to one location Oleksij Rempel
2022-11-24 15:05   ` Arun.Ramadoss
2022-11-25  5:52     ` Oleksij Rempel
2022-11-25  7:14       ` Arun.Ramadoss
2022-11-25  7:49         ` Oleksij Rempel
2022-11-25 11:54         ` Oleksij Rempel
2022-11-25 13:46           ` Arun.Ramadoss
2022-11-25 21:33   ` Vladimir Oltean

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.