diff mbox series

[net-next,v3,5/5] net: dsa: microchip: apply KSZ87xx family fixes wrt datasheet

Message ID 20240806132606.1438953-6-vtpieter@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: microchip: ksz8795: add Wake on LAN support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 29 this patch: 29
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 83 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-06--15-00 (tests: 707)

Commit Message

Pieter Aug. 6, 2024, 1:25 p.m. UTC
From: Pieter Van Trappen <pieter.van.trappen@cern.ch>

The KSZ87xx switches have 32 entries and not 8. This fixes -ENOSPC
errors from ksz8_add_sta_mac when configured as a bridge.

Add a new ksz87xx_dev_ops structure to be able to use the
ksz_r_mib_stat64 pointer for this family; this corrects a wrong
mib->counters cast to ksz88xx_stats_raw. This fixes iproute2
statistics.

Signed-off-by: Pieter Van Trappen <pieter.van.trappen@cern.ch>
---
 drivers/net/dsa/microchip/ksz_common.c | 47 ++++++++++++++++++++++----
 1 file changed, 41 insertions(+), 6 deletions(-)

Comments

Arun Ramadoss Aug. 7, 2024, 3:41 a.m. UTC | #1
Hi Pieter,

On Tue, 2024-08-06 at 15:25 +0200, vtpieter@gmail.com wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> From: Pieter Van Trappen <pieter.van.trappen@cern.ch>
> 
> The KSZ87xx switches have 32 entries and not 8. This fixes -ENOSPC
> errors from ksz8_add_sta_mac when configured as a bridge.
> 
> Add a new ksz87xx_dev_ops structure to be able to use the
> ksz_r_mib_stat64 pointer for this family; this corrects a wrong
> mib->counters cast to ksz88xx_stats_raw. This fixes iproute2
> statistics.
> 
> Signed-off-by: Pieter Van Trappen <pieter.van.trappen@cern.ch>
> ---
>  
>  static void ksz9477_phylink_mac_link_up(struct phylink_config
> *config,
>                                         struct phy_device *phydev,
>                                         unsigned int mode,
> @@ -1262,12 +1297,12 @@ const struct ksz_chip_data ksz_switch_chips[]
> = {
>                 .dev_name = "KSZ8795",
>                 .num_vlans = 4096,
>                 .num_alus = 0,
> -               .num_statics = 8,
> +               .num_statics = 32,
>                 .cpu_ports = 0x10,      /* can be configured as cpu
> port */
>                 .port_cnt = 5,          /* total cpu and user ports
> */
>                 .num_tx_queues = 4,
>                 .num_ipms = 4,
> -               .ops = &ksz8_dev_ops,

Why don't we rename ksz8_dev_ops also like KSZ88x3_dev_ops or
KSZ88xx_dev_ops, since it is now used only by KSZ8863 and KSZ8873
switches.
Pieter Aug. 8, 2024, 9:28 a.m. UTC | #2
On Wed 7 Aug 2024 at 05:41, <Arun.Ramadoss@microchip.com> wrote:
>
> Hi Pieter,
>
> On Tue, 2024-08-06 at 15:25 +0200, vtpieter@gmail.com wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > know the content is safe
> >
> > From: Pieter Van Trappen <pieter.van.trappen@cern.ch>
> >
> > The KSZ87xx switches have 32 entries and not 8. This fixes -ENOSPC
> > errors from ksz8_add_sta_mac when configured as a bridge.
> >
> > Add a new ksz87xx_dev_ops structure to be able to use the
> > ksz_r_mib_stat64 pointer for this family; this corrects a wrong
> > mib->counters cast to ksz88xx_stats_raw. This fixes iproute2
> > statistics.
> >
> > Signed-off-by: Pieter Van Trappen <pieter.van.trappen@cern.ch>
> > ---
> >
> >  static void ksz9477_phylink_mac_link_up(struct phylink_config
> > *config,
> >                                         struct phy_device *phydev,
> >                                         unsigned int mode,
> > @@ -1262,12 +1297,12 @@ const struct ksz_chip_data ksz_switch_chips[]
> > = {
> >                 .dev_name = "KSZ8795",
> >                 .num_vlans = 4096,
> >                 .num_alus = 0,
> > -               .num_statics = 8,
> > +               .num_statics = 32,
> >                 .cpu_ports = 0x10,      /* can be configured as cpu
> > port */
> >                 .port_cnt = 5,          /* total cpu and user ports
> > */
> >                 .num_tx_queues = 4,
> >                 .num_ipms = 4,
> > -               .ops = &ksz8_dev_ops,
>
> Why don't we rename ksz8_dev_ops also like KSZ88x3_dev_ops or
> KSZ88xx_dev_ops, since it is now used only by KSZ8863 and KSZ8873
> switches.

Hi Arun, indeed that would make more sense. Will rename to
ksz88x3_dev_ops, consistent with the ksz_is_* function names
in ksz_common.h.

Thanks, Pieter
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index c2079e39fbd5..dd141a31b26d 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -312,6 +312,41 @@  static const struct ksz_dev_ops ksz8_dev_ops = {
 	.pme_pwrite8 = ksz8_pme_pwrite8,
 };
 
+static const struct ksz_dev_ops ksz87xx_dev_ops = {
+	.setup = ksz8_setup,
+	.get_port_addr = ksz8_get_port_addr,
+	.cfg_port_member = ksz8_cfg_port_member,
+	.flush_dyn_mac_table = ksz8_flush_dyn_mac_table,
+	.port_setup = ksz8_port_setup,
+	.r_phy = ksz8_r_phy,
+	.w_phy = ksz8_w_phy,
+	.r_mib_cnt = ksz8_r_mib_cnt,
+	.r_mib_pkt = ksz8_r_mib_pkt,
+	.r_mib_stat64 = ksz_r_mib_stats64,
+	.freeze_mib = ksz8_freeze_mib,
+	.port_init_cnt = ksz8_port_init_cnt,
+	.fdb_dump = ksz8_fdb_dump,
+	.fdb_add = ksz8_fdb_add,
+	.fdb_del = ksz8_fdb_del,
+	.mdb_add = ksz8_mdb_add,
+	.mdb_del = ksz8_mdb_del,
+	.vlan_filtering = ksz8_port_vlan_filtering,
+	.vlan_add = ksz8_port_vlan_add,
+	.vlan_del = ksz8_port_vlan_del,
+	.mirror_add = ksz8_port_mirror_add,
+	.mirror_del = ksz8_port_mirror_del,
+	.get_caps = ksz8_get_caps,
+	.config_cpu_port = ksz8_config_cpu_port,
+	.enable_stp_addr = ksz8_enable_stp_addr,
+	.reset = ksz8_reset_switch,
+	.init = ksz8_switch_init,
+	.exit = ksz8_switch_exit,
+	.change_mtu = ksz8_change_mtu,
+	.pme_write8 = ksz8_pme_write8,
+	.pme_pread8 = ksz8_pme_pread8,
+	.pme_pwrite8 = ksz8_pme_pwrite8,
+};
+
 static void ksz9477_phylink_mac_link_up(struct phylink_config *config,
 					struct phy_device *phydev,
 					unsigned int mode,
@@ -1262,12 +1297,12 @@  const struct ksz_chip_data ksz_switch_chips[] = {
 		.dev_name = "KSZ8795",
 		.num_vlans = 4096,
 		.num_alus = 0,
-		.num_statics = 8,
+		.num_statics = 32,
 		.cpu_ports = 0x10,	/* can be configured as cpu port */
 		.port_cnt = 5,		/* total cpu and user ports */
 		.num_tx_queues = 4,
 		.num_ipms = 4,
-		.ops = &ksz8_dev_ops,
+		.ops = &ksz87xx_dev_ops,
 		.phylink_mac_ops = &ksz8_phylink_mac_ops,
 		.ksz87xx_eee_link_erratum = true,
 		.mib_names = ksz9477_mib_names,
@@ -1303,12 +1338,12 @@  const struct ksz_chip_data ksz_switch_chips[] = {
 		.dev_name = "KSZ8794",
 		.num_vlans = 4096,
 		.num_alus = 0,
-		.num_statics = 8,
+		.num_statics = 32,
 		.cpu_ports = 0x10,	/* can be configured as cpu port */
 		.port_cnt = 5,		/* total cpu and user ports */
 		.num_tx_queues = 4,
 		.num_ipms = 4,
-		.ops = &ksz8_dev_ops,
+		.ops = &ksz87xx_dev_ops,
 		.phylink_mac_ops = &ksz8_phylink_mac_ops,
 		.ksz87xx_eee_link_erratum = true,
 		.mib_names = ksz9477_mib_names,
@@ -1330,12 +1365,12 @@  const struct ksz_chip_data ksz_switch_chips[] = {
 		.dev_name = "KSZ8765",
 		.num_vlans = 4096,
 		.num_alus = 0,
-		.num_statics = 8,
+		.num_statics = 32,
 		.cpu_ports = 0x10,	/* can be configured as cpu port */
 		.port_cnt = 5,		/* total cpu and user ports */
 		.num_tx_queues = 4,
 		.num_ipms = 4,
-		.ops = &ksz8_dev_ops,
+		.ops = &ksz87xx_dev_ops,
 		.phylink_mac_ops = &ksz8_phylink_mac_ops,
 		.ksz87xx_eee_link_erratum = true,
 		.mib_names = ksz9477_mib_names,