diff mbox series

[net,v1,2/2] net: dsa: microchip: improve port count comments

Message ID 20201205152814.7867-2-TheSven73@gmail.com
State Superseded
Headers show
Series [net,v1,1/2] net: dsa: microchip: fix devicetree parsing of cpu node | expand

Commit Message

Sven Van Asbroeck Dec. 5, 2020, 3:28 p.m. UTC
From: Sven Van Asbroeck <thesven73@gmail.com>

Port counts in microchip dsa drivers can be quite confusing:
on the ksz8795, ksz_chip_data->port_cnt excludes the cpu port,
yet on the ksz9477, it includes the cpu port.

Add comments to document this situation explicitly.

Fixes: 912aae27c6af ("net: dsa: microchip: really look for phy-mode in port nodes")
Signed-off-by: Sven Van Asbroeck <thesven73@gmail.com>
---

Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git # 905b2032fa42

To: Woojung Huh <woojung.huh@microchip.com>
To: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>
To: Andrew Lunn <andrew@lunn.ch>
To: Vivien Didelot <vivien.didelot@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>
To: Vladimir Oltean <olteanv@gmail.com>
To: "David S. Miller" <davem@davemloft.net>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Helmut Grohne <helmut.grohne@intenta.de>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

 drivers/net/dsa/microchip/ksz8795.c | 12 +++++++++---
 drivers/net/dsa/microchip/ksz9477.c | 16 ++++++++++++----
 2 files changed, 21 insertions(+), 7 deletions(-)

Comments

Andrew Lunn Dec. 7, 2020, 11:31 p.m. UTC | #1
On Sat, Dec 05, 2020 at 10:28:14AM -0500, Sven Van Asbroeck wrote:
> From: Sven Van Asbroeck <thesven73@gmail.com>
> 
> Port counts in microchip dsa drivers can be quite confusing:
> on the ksz8795, ksz_chip_data->port_cnt excludes the cpu port,
> yet on the ksz9477, it includes the cpu port.
> 
> Add comments to document this situation explicitly.

Rather than document it, we should make it uniform. Unless there is a
valid reason to require them to mean different things.

      Andrew
Jakub Kicinski Dec. 8, 2020, 2:16 a.m. UTC | #2
On Tue, 8 Dec 2020 00:31:16 +0100 Andrew Lunn wrote:
> On Sat, Dec 05, 2020 at 10:28:14AM -0500, Sven Van Asbroeck wrote:
> > From: Sven Van Asbroeck <thesven73@gmail.com>
> > 
> > Port counts in microchip dsa drivers can be quite confusing:
> > on the ksz8795, ksz_chip_data->port_cnt excludes the cpu port,
> > yet on the ksz9477, it includes the cpu port.
> > 
> > Add comments to document this situation explicitly.  
> 
> Rather than document it, we should make it uniform. Unless there is a
> valid reason to require them to mean different things.

Agreed.

I wonder if we should make this effort target net-next.

My concern is that for the 3 port switch the cpu_ports variable is set
to 0x10, the same as for the 4 port one. Which makes me worried that 
if we just allow the "+ 1" - the CPU port will not actually hit the
register offsets its supposed to on 3 port platforms.

Since configuring the CPU port never worked here (AFAICT) we can view
this as a new feature / config option (even tho an important one).

So let's move to net-next, and we can "do this right".

Does that sound sane?
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index f5779e152377..99183347053f 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -1190,7 +1190,9 @@  static const struct ksz_chip_data ksz8795_switch_chips[] = {
 		.num_alus = 0,
 		.num_statics = 8,
 		.cpu_ports = 0x10,	/* can be configured as cpu port */
-		.port_cnt = 4,		/* total physical port count */
+		.port_cnt = 4,		/* total physical port count, excluding
+					 * the cpu port
+					 */
 	},
 	{
 		.chip_id = 0x8794,
@@ -1199,7 +1201,9 @@  static const struct ksz_chip_data ksz8795_switch_chips[] = {
 		.num_alus = 0,
 		.num_statics = 8,
 		.cpu_ports = 0x10,	/* can be configured as cpu port */
-		.port_cnt = 3,		/* total physical port count */
+		.port_cnt = 3,		/* total physical port count, excluding
+					 * the cpu port
+					 */
 	},
 	{
 		.chip_id = 0x8765,
@@ -1208,7 +1212,9 @@  static const struct ksz_chip_data ksz8795_switch_chips[] = {
 		.num_alus = 0,
 		.num_statics = 8,
 		.cpu_ports = 0x10,	/* can be configured as cpu port */
-		.port_cnt = 4,		/* total physical port count */
+		.port_cnt = 4,		/* total physical port count, excluding
+					 * the cpu port
+					 */
 	},
 };
 
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 2f5506ac7d19..e56122ffd495 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1482,7 +1482,9 @@  static const struct ksz_chip_data ksz9477_switch_chips[] = {
 		.num_alus = 4096,
 		.num_statics = 16,
 		.cpu_ports = 0x7F,	/* can be configured as cpu port */
-		.port_cnt = 7,		/* total physical port count */
+		.port_cnt = 7,		/* total physical port count, including
+					 * the cpu port
+					 */
 		.phy_errata_9477 = true,
 	},
 	{
@@ -1492,7 +1494,9 @@  static const struct ksz_chip_data ksz9477_switch_chips[] = {
 		.num_alus = 4096,
 		.num_statics = 16,
 		.cpu_ports = 0x7F,	/* can be configured as cpu port */
-		.port_cnt = 7,		/* total physical port count */
+		.port_cnt = 7,		/* total physical port count, including
+					 * the cpu port
+					 */
 		.phy_errata_9477 = true,
 	},
 	{
@@ -1502,7 +1506,9 @@  static const struct ksz_chip_data ksz9477_switch_chips[] = {
 		.num_alus = 4096,
 		.num_statics = 16,
 		.cpu_ports = 0x07,	/* can be configured as cpu port */
-		.port_cnt = 3,		/* total port count */
+		.port_cnt = 3,		/* total physical port count, including
+					 * the cpu port
+					 */
 	},
 	{
 		.chip_id = 0x00956700,
@@ -1511,7 +1517,9 @@  static const struct ksz_chip_data ksz9477_switch_chips[] = {
 		.num_alus = 4096,
 		.num_statics = 16,
 		.cpu_ports = 0x7F,	/* can be configured as cpu port */
-		.port_cnt = 7,		/* total physical port count */
+		.port_cnt = 7,		/* total physical port count, including
+					 * the cpu port
+					 */
 	},
 };