netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] net: dsa: mv88e6xxx: remove some 6250-specific methods
@ 2021-01-25 15:04 Rasmus Villemoes
  2021-01-25 15:04 ` [PATCH net-next v2 1/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_getnext() for the 6250 Rasmus Villemoes
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Rasmus Villemoes @ 2021-01-25 15:04 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, Vladimir Oltean, Tobias Waldekranz,
	Jakub Kicinski, David S . Miller, Vivien Didelot,
	Rasmus Villemoes

v2:

- resend now that the bug-fix patch (87fe04367d84, "net: dsa:
  mv88e6xxx: also read STU state in mv88e6250_g1_vtu_getnext") is in
  net and also merged to net-next.

- include various tags in patch 1.

- add second similar patch for loadpurge.

Rasmus Villemoes (2):
  net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_getnext() for the 6250
  net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_loadpurge() for the 6250

 drivers/net/dsa/mv88e6xxx/chip.c        |  4 +-
 drivers/net/dsa/mv88e6xxx/global1.h     |  4 --
 drivers/net/dsa/mv88e6xxx/global1_vtu.c | 69 +++----------------------
 3 files changed, 8 insertions(+), 69 deletions(-)

-- 
2.23.0


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

* [PATCH net-next v2 1/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_getnext() for the 6250
  2021-01-25 15:04 [PATCH net-next v2 0/2] net: dsa: mv88e6xxx: remove some 6250-specific methods Rasmus Villemoes
@ 2021-01-25 15:04 ` Rasmus Villemoes
  2021-01-26 21:53   ` Vladimir Oltean
  2021-01-25 15:04 ` [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_loadpurge() " Rasmus Villemoes
  2021-01-27  2:10 ` [PATCH net-next v2 0/2] net: dsa: mv88e6xxx: remove some 6250-specific methods patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Rasmus Villemoes @ 2021-01-25 15:04 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, Vladimir Oltean, Tobias Waldekranz,
	Jakub Kicinski, David S . Miller, Vivien Didelot,
	Rasmus Villemoes

mv88e6250_g1_vtu_getnext is almost identical to
mv88e6185_g1_vtu_getnext, except for the 6250 only having 64 databases
instead of 256. We can reduce code duplication by simply masking off
the extra two garbage bits when assembling the fid from VTU op [3:0]
and [11:8].

Reviewed-by: Tobias Waldekranz <tobias@waldekranz.com>
Tested-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/net/dsa/mv88e6xxx/chip.c        |  2 +-
 drivers/net/dsa/mv88e6xxx/global1.h     |  2 --
 drivers/net/dsa/mv88e6xxx/global1_vtu.c | 36 ++-----------------------
 3 files changed, 3 insertions(+), 37 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 5cc1465fd635..8a0df1e903bf 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -4023,7 +4023,7 @@ static const struct mv88e6xxx_ops mv88e6250_ops = {
 	.mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
 	.pot_clear = mv88e6xxx_g2_pot_clear,
 	.reset = mv88e6250_g1_reset,
-	.vtu_getnext = mv88e6250_g1_vtu_getnext,
+	.vtu_getnext = mv88e6185_g1_vtu_getnext,
 	.vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
 	.avb_ops = &mv88e6352_avb_ops,
 	.ptp_ops = &mv88e6250_ptp_ops,
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
index 80a182c5b98a..d2dd2f4e4730 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -336,8 +336,6 @@ int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 			     struct mv88e6xxx_vtu_entry *entry);
 int mv88e6185_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip,
 			       struct mv88e6xxx_vtu_entry *entry);
-int mv88e6250_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
-			     struct mv88e6xxx_vtu_entry *entry);
 int mv88e6250_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip,
 			       struct mv88e6xxx_vtu_entry *entry);
 int mv88e6352_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
index 7b96396be609..519ae48ba96e 100644
--- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c
+++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
@@ -336,39 +336,6 @@ int mv88e6xxx_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 	return mv88e6xxx_g1_vtu_vid_read(chip, entry);
 }
 
-int mv88e6250_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
-			     struct mv88e6xxx_vtu_entry *entry)
-{
-	u16 val;
-	int err;
-
-	err = mv88e6xxx_g1_vtu_getnext(chip, entry);
-	if (err)
-		return err;
-
-	if (entry->valid) {
-		err = mv88e6185_g1_vtu_data_read(chip, entry);
-		if (err)
-			return err;
-
-		err = mv88e6185_g1_stu_data_read(chip, entry);
-		if (err)
-			return err;
-
-		/* VTU DBNum[3:0] are located in VTU Operation 3:0
-		 * VTU DBNum[5:4] are located in VTU Operation 9:8
-		 */
-		err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_VTU_OP, &val);
-		if (err)
-			return err;
-
-		entry->fid = val & 0x000f;
-		entry->fid |= (val & 0x0300) >> 4;
-	}
-
-	return 0;
-}
-
 int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 			     struct mv88e6xxx_vtu_entry *entry)
 {
@@ -389,7 +356,7 @@ int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 			return err;
 
 		/* VTU DBNum[3:0] are located in VTU Operation 3:0
-		 * VTU DBNum[7:4] are located in VTU Operation 11:8
+		 * VTU DBNum[7:4] ([5:4] for 6250) are located in VTU Operation 11:8 (9:8)
 		 */
 		err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_VTU_OP, &val);
 		if (err)
@@ -397,6 +364,7 @@ int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 
 		entry->fid = val & 0x000f;
 		entry->fid |= (val & 0x0f00) >> 4;
+		entry->fid &= mv88e6xxx_num_databases(chip) - 1;
 	}
 
 	return 0;
-- 
2.23.0


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

* [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_loadpurge() for the 6250
  2021-01-25 15:04 [PATCH net-next v2 0/2] net: dsa: mv88e6xxx: remove some 6250-specific methods Rasmus Villemoes
  2021-01-25 15:04 ` [PATCH net-next v2 1/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_getnext() for the 6250 Rasmus Villemoes
@ 2021-01-25 15:04 ` Rasmus Villemoes
  2021-01-26 21:55   ` Vladimir Oltean
  2021-01-27  2:10 ` [PATCH net-next v2 0/2] net: dsa: mv88e6xxx: remove some 6250-specific methods patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Rasmus Villemoes @ 2021-01-25 15:04 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, Vladimir Oltean, Tobias Waldekranz,
	Jakub Kicinski, David S . Miller, Vivien Didelot,
	Rasmus Villemoes

Apart from the mask used to get the high bits of the fid,
mv88e6185_g1_vtu_loadpurge() and mv88e6250_g1_vtu_loadpurge() are
identical. Since the entry->fid passed in should never exceed the
number of databases, we can simply use the former as-is as replacement
for the latter.

Suggested-by: Tobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/net/dsa/mv88e6xxx/chip.c        |  2 +-
 drivers/net/dsa/mv88e6xxx/global1.h     |  2 --
 drivers/net/dsa/mv88e6xxx/global1_vtu.c | 33 +++----------------------
 3 files changed, 5 insertions(+), 32 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 8a0df1e903bf..7e1bbb400e8a 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -4024,7 +4024,7 @@ static const struct mv88e6xxx_ops mv88e6250_ops = {
 	.pot_clear = mv88e6xxx_g2_pot_clear,
 	.reset = mv88e6250_g1_reset,
 	.vtu_getnext = mv88e6185_g1_vtu_getnext,
-	.vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
+	.vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
 	.avb_ops = &mv88e6352_avb_ops,
 	.ptp_ops = &mv88e6250_ptp_ops,
 	.phylink_validate = mv88e6065_phylink_validate,
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
index d2dd2f4e4730..7c396964d0b2 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -336,8 +336,6 @@ int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 			     struct mv88e6xxx_vtu_entry *entry);
 int mv88e6185_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip,
 			       struct mv88e6xxx_vtu_entry *entry);
-int mv88e6250_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip,
-			       struct mv88e6xxx_vtu_entry *entry);
 int mv88e6352_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 			     struct mv88e6xxx_vtu_entry *entry);
 int mv88e6352_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip,
diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
index 519ae48ba96e..ae12c981923e 100644
--- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c
+++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
@@ -434,35 +434,6 @@ int mv88e6390_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 	return 0;
 }
 
-int mv88e6250_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip,
-			       struct mv88e6xxx_vtu_entry *entry)
-{
-	u16 op = MV88E6XXX_G1_VTU_OP_VTU_LOAD_PURGE;
-	int err;
-
-	err = mv88e6xxx_g1_vtu_op_wait(chip);
-	if (err)
-		return err;
-
-	err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
-	if (err)
-		return err;
-
-	if (entry->valid) {
-		err = mv88e6185_g1_vtu_data_write(chip, entry);
-		if (err)
-			return err;
-
-		/* VTU DBNum[3:0] are located in VTU Operation 3:0
-		 * VTU DBNum[5:4] are located in VTU Operation 9:8
-		 */
-		op |= entry->fid & 0x000f;
-		op |= (entry->fid & 0x0030) << 4;
-	}
-
-	return mv88e6xxx_g1_vtu_op(chip, op);
-}
-
 int mv88e6185_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip,
 			       struct mv88e6xxx_vtu_entry *entry)
 {
@@ -484,6 +455,10 @@ int mv88e6185_g1_vtu_loadpurge(struct mv88e6xxx_chip *chip,
 
 		/* VTU DBNum[3:0] are located in VTU Operation 3:0
 		 * VTU DBNum[7:4] are located in VTU Operation 11:8
+		 *
+		 * For the 6250/6220, the latter are really [5:4] and
+		 * 9:8, but in those cases bits 7:6 of entry->fid are
+		 * 0 since they have num_databases = 64.
 		 */
 		op |= entry->fid & 0x000f;
 		op |= (entry->fid & 0x00f0) << 4;
-- 
2.23.0


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

* Re: [PATCH net-next v2 1/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_getnext() for the 6250
  2021-01-25 15:04 ` [PATCH net-next v2 1/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_getnext() for the 6250 Rasmus Villemoes
@ 2021-01-26 21:53   ` Vladimir Oltean
  0 siblings, 0 replies; 6+ messages in thread
From: Vladimir Oltean @ 2021-01-26 21:53 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: netdev, Florian Fainelli, Tobias Waldekranz, Jakub Kicinski,
	David S . Miller, Vivien Didelot

On Mon, Jan 25, 2021 at 04:04:48PM +0100, Rasmus Villemoes wrote:
> mv88e6250_g1_vtu_getnext is almost identical to
> mv88e6185_g1_vtu_getnext, except for the 6250 only having 64 databases
> instead of 256. We can reduce code duplication by simply masking off
> the extra two garbage bits when assembling the fid from VTU op [3:0]
> and [11:8].
> 
> Reviewed-by: Tobias Waldekranz <tobias@waldekranz.com>
> Tested-by: Tobias Waldekranz <tobias@waldekranz.com>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---

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

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

* Re: [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_loadpurge() for the 6250
  2021-01-25 15:04 ` [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_loadpurge() " Rasmus Villemoes
@ 2021-01-26 21:55   ` Vladimir Oltean
  0 siblings, 0 replies; 6+ messages in thread
From: Vladimir Oltean @ 2021-01-26 21:55 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: netdev, Florian Fainelli, Tobias Waldekranz, Jakub Kicinski,
	David S . Miller, Vivien Didelot

On Mon, Jan 25, 2021 at 04:04:49PM +0100, Rasmus Villemoes wrote:
> Apart from the mask used to get the high bits of the fid,
> mv88e6185_g1_vtu_loadpurge() and mv88e6250_g1_vtu_loadpurge() are
> identical. Since the entry->fid passed in should never exceed the
> number of databases, we can simply use the former as-is as replacement
> for the latter.
> 
> Suggested-by: Tobias Waldekranz <tobias@waldekranz.com>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---

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

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

* Re: [PATCH net-next v2 0/2] net: dsa: mv88e6xxx: remove some 6250-specific methods
  2021-01-25 15:04 [PATCH net-next v2 0/2] net: dsa: mv88e6xxx: remove some 6250-specific methods Rasmus Villemoes
  2021-01-25 15:04 ` [PATCH net-next v2 1/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_getnext() for the 6250 Rasmus Villemoes
  2021-01-25 15:04 ` [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_loadpurge() " Rasmus Villemoes
@ 2021-01-27  2:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-01-27  2:10 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: netdev, f.fainelli, olteanv, tobias, kuba, davem, vivien.didelot

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Mon, 25 Jan 2021 16:04:47 +0100 you wrote:
> v2:
> 
> - resend now that the bug-fix patch (87fe04367d84, "net: dsa:
>   mv88e6xxx: also read STU state in mv88e6250_g1_vtu_getnext") is in
>   net and also merged to net-next.
> 
> - include various tags in patch 1.
> 
> [...]

Here is the summary with links:
  - [net-next,v2,1/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_getnext() for the 6250
    https://git.kernel.org/netdev/net-next/c/67c9ed1c8809
  - [net-next,v2,2/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_loadpurge() for the 6250
    https://git.kernel.org/netdev/net-next/c/b28f3f3c3f30

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-01-27  6:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 15:04 [PATCH net-next v2 0/2] net: dsa: mv88e6xxx: remove some 6250-specific methods Rasmus Villemoes
2021-01-25 15:04 ` [PATCH net-next v2 1/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_getnext() for the 6250 Rasmus Villemoes
2021-01-26 21:53   ` Vladimir Oltean
2021-01-25 15:04 ` [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: use mv88e6185_g1_vtu_loadpurge() " Rasmus Villemoes
2021-01-26 21:55   ` Vladimir Oltean
2021-01-27  2:10 ` [PATCH net-next v2 0/2] net: dsa: mv88e6xxx: remove some 6250-specific methods patchwork-bot+netdevbpf

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).