kernel: backport b53/bcm_sf2 changes from v5.8
authorRafał Miłecki <rafal@milecki.pl>
Wed, 7 Dec 2022 08:57:47 +0000 (09:57 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Wed, 7 Dec 2022 09:30:14 +0000 (10:30 +0100)
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
target/linux/bcm4908/patches-5.4/070-v5.10-0001-net-dsa-b53-Use-dev_-err-info-instead-of-pr_.patch
target/linux/bcm4908/patches-5.4/071-v5.12-0001-net-dsa-bcm_sf2-support-BCM4908-s-integrated-switch.patch
target/linux/generic/backport-5.4/709-v5.8-0001-net-dsa-b53-per-port-interrupts-are-optional.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/709-v5.8-0002-net-dsa-b53-Rename-num_arl_entries-to-num_arl_bins.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/709-v5.8-0003-net-dsa-b53-Provide-number-of-ARL-buckets.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/709-v5.8-0004-net-dsa-b53-Bound-check-ARL-searches.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/709-v5.8-0005-net-dsa-b53-Remove-is_static-argument-to-b53_read_op.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/709-v5.8-0006-net-dsa-b53-remove-redundant-premature-assignment-to.patch [new file with mode: 0644]
target/linux/mediatek/patches-5.4/0601-net-dsa-propagate-resolved-link-config-via-mac_link_.patch

index 776cf4a1f2ee2b48992e69f8be082c9aae4bf4f2..83a9b9345f9050d8d61e0b20653b645ad7a30b21 100644 (file)
@@ -26,7 +26,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
  #include <linux/delay.h>
  #include <linux/export.h>
  #include <linux/gpio.h>
-@@ -2596,8 +2594,9 @@ int b53_switch_detect(struct b53_device
+@@ -2616,8 +2614,9 @@ int b53_switch_detect(struct b53_device
                        dev->chip_id = id32;
                        break;
                default:
@@ -38,7 +38,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
                        return -ENODEV;
                }
        }
-@@ -2627,7 +2626,8 @@ int b53_switch_register(struct b53_devic
+@@ -2647,7 +2646,8 @@ int b53_switch_register(struct b53_devic
        if (ret)
                return ret;
  
index 531388da7039b1ae1cf5233ebbd58e79dc5b0664..5c698a342fae79136c95fe27aa0a3999e1a3a537 100644 (file)
@@ -23,7 +23,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
 
 --- a/drivers/net/dsa/b53/b53_common.c
 +++ b/drivers/net/dsa/b53/b53_common.c
-@@ -2392,6 +2392,22 @@ static const struct b53_chip_data b53_sw
+@@ -2409,6 +2409,22 @@ static const struct b53_chip_data b53_sw
                .jumbo_pm_reg = B53_JUMBO_PORT_MASK,
                .jumbo_size_reg = B53_JUMBO_MAX_SIZE,
        },
diff --git a/target/linux/generic/backport-5.4/709-v5.8-0001-net-dsa-b53-per-port-interrupts-are-optional.patch b/target/linux/generic/backport-5.4/709-v5.8-0001-net-dsa-b53-per-port-interrupts-are-optional.patch
new file mode 100644 (file)
index 0000000..ee1c883
--- /dev/null
@@ -0,0 +1,25 @@
+From 007fc3c0ca478f3a8ad687cf9ecbe672d3a64700 Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 17 Apr 2020 11:33:41 -0700
+Subject: [PATCH] net: dsa: b53: per-port interrupts are optional
+
+Make use of platform_get_irq_byname_optional() to avoid printing
+messages on the kernel console that interrupts cannot be found.
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/dsa/b53/b53_srab.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/dsa/b53/b53_srab.c
++++ b/drivers/net/dsa/b53/b53_srab.c
+@@ -524,7 +524,7 @@ static void b53_srab_prepare_irq(struct
+               port->num = i;
+               port->dev = dev;
+-              port->irq = platform_get_irq_byname(pdev, name);
++              port->irq = platform_get_irq_byname_optional(pdev, name);
+               kfree(name);
+       }
diff --git a/target/linux/generic/backport-5.4/709-v5.8-0002-net-dsa-b53-Rename-num_arl_entries-to-num_arl_bins.patch b/target/linux/generic/backport-5.4/709-v5.8-0002-net-dsa-b53-Rename-num_arl_entries-to-num_arl_bins.patch
new file mode 100644 (file)
index 0000000..7b566dd
--- /dev/null
@@ -0,0 +1,255 @@
+From 673e69a67dd63fc3b40f109d1677a5dc72185fbb Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Thu, 30 Apr 2020 11:49:08 -0700
+Subject: [PATCH] net: dsa: b53: Rename num_arl_entries to num_arl_bins
+
+The variable currently holds the number of ARL bins per ARL buckets,
+which is different from the number of ARL entries which would be bins
+times buckets. We will be adding a num_arl_buckets in a subsequent patch
+so get variables straight now.
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/dsa/b53/b53_common.c | 52 ++++++++++++++++----------------
+ drivers/net/dsa/b53/b53_priv.h   |  2 +-
+ 2 files changed, 27 insertions(+), 27 deletions(-)
+
+--- a/drivers/net/dsa/b53/b53_common.c
++++ b/drivers/net/dsa/b53/b53_common.c
+@@ -1506,10 +1506,10 @@ static int b53_arl_read(struct b53_devic
+       if (ret)
+               return ret;
+-      bitmap_zero(free_bins, dev->num_arl_entries);
++      bitmap_zero(free_bins, dev->num_arl_bins);
+       /* Read the bins */
+-      for (i = 0; i < dev->num_arl_entries; i++) {
++      for (i = 0; i < dev->num_arl_bins; i++) {
+               u64 mac_vid;
+               u32 fwd_entry;
+@@ -1532,10 +1532,10 @@ static int b53_arl_read(struct b53_devic
+               return 0;
+       }
+-      if (bitmap_weight(free_bins, dev->num_arl_entries) == 0)
++      if (bitmap_weight(free_bins, dev->num_arl_bins) == 0)
+               return -ENOSPC;
+-      *idx = find_first_bit(free_bins, dev->num_arl_entries);
++      *idx = find_first_bit(free_bins, dev->num_arl_bins);
+       return -ENOENT;
+ }
+@@ -1705,7 +1705,7 @@ int b53_fdb_dump(struct dsa_switch *ds,
+               if (ret)
+                       return ret;
+-              if (priv->num_arl_entries > 2) {
++              if (priv->num_arl_bins > 2) {
+                       b53_arl_search_rd(priv, 1, &results[1]);
+                       ret = b53_fdb_copy(port, &results[1], cb, data);
+                       if (ret)
+@@ -2179,7 +2179,7 @@ struct b53_chip_data {
+       u16 enabled_ports;
+       u8 cpu_port;
+       u8 vta_regs[3];
+-      u8 arl_entries;
++      u8 arl_bins;
+       u8 duplex_reg;
+       u8 jumbo_pm_reg;
+       u8 jumbo_size_reg;
+@@ -2198,7 +2198,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM5325",
+               .vlans = 16,
+               .enabled_ports = 0x1f,
+-              .arl_entries = 2,
++              .arl_bins = 2,
+               .cpu_port = B53_CPU_PORT_25,
+               .duplex_reg = B53_DUPLEX_STAT_FE,
+       },
+@@ -2207,7 +2207,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM5365",
+               .vlans = 256,
+               .enabled_ports = 0x1f,
+-              .arl_entries = 2,
++              .arl_bins = 2,
+               .cpu_port = B53_CPU_PORT_25,
+               .duplex_reg = B53_DUPLEX_STAT_FE,
+       },
+@@ -2216,7 +2216,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM5389",
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2228,7 +2228,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM5395",
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2240,7 +2240,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM5397",
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS_9798,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2252,7 +2252,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM5398",
+               .vlans = 4096,
+               .enabled_ports = 0x7f,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS_9798,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2264,7 +2264,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM53115",
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .vta_regs = B53_VTA_REGS,
+               .cpu_port = B53_CPU_PORT,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2276,7 +2276,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM53125",
+               .vlans = 4096,
+               .enabled_ports = 0xff,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2288,7 +2288,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM53128",
+               .vlans = 4096,
+               .enabled_ports = 0x1ff,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2300,7 +2300,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM63xx",
+               .vlans = 4096,
+               .enabled_ports = 0, /* pdata must provide them */
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS_63XX,
+               .duplex_reg = B53_DUPLEX_STAT_63XX,
+@@ -2312,7 +2312,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM53010",
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2324,7 +2324,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM53011",
+               .vlans = 4096,
+               .enabled_ports = 0x1bf,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2336,7 +2336,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM53012",
+               .vlans = 4096,
+               .enabled_ports = 0x1bf,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2348,7 +2348,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM53018",
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2360,7 +2360,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM53019",
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2372,7 +2372,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM585xx/586xx/88312",
+               .vlans  = 4096,
+               .enabled_ports = 0x1ff,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2384,7 +2384,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM583xx/11360",
+               .vlans = 4096,
+               .enabled_ports = 0x103,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2396,7 +2396,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM7445",
+               .vlans  = 4096,
+               .enabled_ports = 0x1ff,
+-              .arl_entries = 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2408,7 +2408,7 @@ static const struct b53_chip_data b53_sw
+               .dev_name = "BCM7278",
+               .vlans = 4096,
+               .enabled_ports = 0x1ff,
+-              .arl_entries= 4,
++              .arl_bins = 4,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2436,7 +2436,7 @@ static int b53_switch_init(struct b53_de
+                       dev->jumbo_pm_reg = chip->jumbo_pm_reg;
+                       dev->cpu_port = chip->cpu_port;
+                       dev->num_vlans = chip->vlans;
+-                      dev->num_arl_entries = chip->arl_entries;
++                      dev->num_arl_bins = chip->arl_bins;
+                       break;
+               }
+       }
+--- a/drivers/net/dsa/b53/b53_priv.h
++++ b/drivers/net/dsa/b53/b53_priv.h
+@@ -117,7 +117,7 @@ struct b53_device {
+       u8 jumbo_pm_reg;
+       u8 jumbo_size_reg;
+       int reset_gpio;
+-      u8 num_arl_entries;
++      u8 num_arl_bins;
+       enum dsa_tag_protocol tag_protocol;
+       /* used ports mask */
diff --git a/target/linux/generic/backport-5.4/709-v5.8-0003-net-dsa-b53-Provide-number-of-ARL-buckets.patch b/target/linux/generic/backport-5.4/709-v5.8-0003-net-dsa-b53-Provide-number-of-ARL-buckets.patch
new file mode 100644 (file)
index 0000000..3c278d4
--- /dev/null
@@ -0,0 +1,198 @@
+From e3da4038f4ca1094596a7604c6edac4a6a4f6ee9 Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Thu, 30 Apr 2020 11:49:09 -0700
+Subject: [PATCH] net: dsa: b53: Provide number of ARL buckets
+
+In preparation for doing proper upper bound checking of FDB/MDB entries
+being added to the ARL, provide the number of ARL buckets for each
+switch chip we support. All chips have 1024 buckets, except 7278 which
+has only 256.
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/dsa/b53/b53_common.c | 21 +++++++++++++++++++++
+ drivers/net/dsa/b53/b53_priv.h   |  1 +
+ 2 files changed, 22 insertions(+)
+
+--- a/drivers/net/dsa/b53/b53_common.c
++++ b/drivers/net/dsa/b53/b53_common.c
+@@ -2180,6 +2180,7 @@ struct b53_chip_data {
+       u8 cpu_port;
+       u8 vta_regs[3];
+       u8 arl_bins;
++      u16 arl_buckets;
+       u8 duplex_reg;
+       u8 jumbo_pm_reg;
+       u8 jumbo_size_reg;
+@@ -2199,6 +2200,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 16,
+               .enabled_ports = 0x1f,
+               .arl_bins = 2,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT_25,
+               .duplex_reg = B53_DUPLEX_STAT_FE,
+       },
+@@ -2208,6 +2210,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 256,
+               .enabled_ports = 0x1f,
+               .arl_bins = 2,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT_25,
+               .duplex_reg = B53_DUPLEX_STAT_FE,
+       },
+@@ -2217,6 +2220,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2229,6 +2233,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2241,6 +2246,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS_9798,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2253,6 +2259,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x7f,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS_9798,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2265,6 +2272,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .vta_regs = B53_VTA_REGS,
+               .cpu_port = B53_CPU_PORT,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2277,6 +2285,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0xff,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2289,6 +2298,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1ff,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2301,6 +2311,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0, /* pdata must provide them */
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS_63XX,
+               .duplex_reg = B53_DUPLEX_STAT_63XX,
+@@ -2313,6 +2324,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2325,6 +2337,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1bf,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2337,6 +2350,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1bf,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2349,6 +2363,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2361,6 +2376,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1f,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2373,6 +2389,7 @@ static const struct b53_chip_data b53_sw
+               .vlans  = 4096,
+               .enabled_ports = 0x1ff,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2385,6 +2402,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x103,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2397,6 +2415,7 @@ static const struct b53_chip_data b53_sw
+               .vlans  = 4096,
+               .enabled_ports = 0x1ff,
+               .arl_bins = 4,
++              .arl_buckets = 1024,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2409,6 +2428,7 @@ static const struct b53_chip_data b53_sw
+               .vlans = 4096,
+               .enabled_ports = 0x1ff,
+               .arl_bins = 4,
++              .arl_buckets = 256,
+               .cpu_port = B53_CPU_PORT,
+               .vta_regs = B53_VTA_REGS,
+               .duplex_reg = B53_DUPLEX_STAT_GE,
+@@ -2437,6 +2457,7 @@ static int b53_switch_init(struct b53_de
+                       dev->cpu_port = chip->cpu_port;
+                       dev->num_vlans = chip->vlans;
+                       dev->num_arl_bins = chip->arl_bins;
++                      dev->num_arl_buckets = chip->arl_buckets;
+                       break;
+               }
+       }
+--- a/drivers/net/dsa/b53/b53_priv.h
++++ b/drivers/net/dsa/b53/b53_priv.h
+@@ -118,6 +118,7 @@ struct b53_device {
+       u8 jumbo_size_reg;
+       int reset_gpio;
+       u8 num_arl_bins;
++      u16 num_arl_buckets;
+       enum dsa_tag_protocol tag_protocol;
+       /* used ports mask */
diff --git a/target/linux/generic/backport-5.4/709-v5.8-0004-net-dsa-b53-Bound-check-ARL-searches.patch b/target/linux/generic/backport-5.4/709-v5.8-0004-net-dsa-b53-Bound-check-ARL-searches.patch
new file mode 100644 (file)
index 0000000..8faf2ac
--- /dev/null
@@ -0,0 +1,43 @@
+From cd169d799beeb738fa2d3e891960924cdcaf8414 Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Thu, 30 Apr 2020 11:49:10 -0700
+Subject: [PATCH] net: dsa: b53: Bound check ARL searches
+
+ARL searches are done by reading two ARL entries at a time, do not cap
+the search at 1024 which would only limit us to half of the possible ARL
+capacity, but use b53_max_arl_entries() instead which does the right
+multiplication between bins and indexes.
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/dsa/b53/b53_common.c | 2 +-
+ drivers/net/dsa/b53/b53_priv.h   | 5 +++++
+ 2 files changed, 6 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/dsa/b53/b53_common.c
++++ b/drivers/net/dsa/b53/b53_common.c
+@@ -1715,7 +1715,7 @@ int b53_fdb_dump(struct dsa_switch *ds,
+                               break;
+               }
+-      } while (count++ < 1024);
++      } while (count++ < b53_max_arl_entries(priv) / 2);
+       return 0;
+ }
+--- a/drivers/net/dsa/b53/b53_priv.h
++++ b/drivers/net/dsa/b53/b53_priv.h
+@@ -213,6 +213,11 @@ static inline int is58xx(struct b53_devi
+ #define B53_CPU_PORT_25       5
+ #define B53_CPU_PORT  8
++static inline unsigned int b53_max_arl_entries(struct b53_device *dev)
++{
++      return dev->num_arl_buckets * dev->num_arl_bins;
++}
++
+ struct b53_device *b53_switch_alloc(struct device *base,
+                                   const struct b53_io_ops *ops,
+                                   void *priv);
diff --git a/target/linux/generic/backport-5.4/709-v5.8-0005-net-dsa-b53-Remove-is_static-argument-to-b53_read_op.patch b/target/linux/generic/backport-5.4/709-v5.8-0005-net-dsa-b53-Remove-is_static-argument-to-b53_read_op.patch
new file mode 100644 (file)
index 0000000..e4dad7d
--- /dev/null
@@ -0,0 +1,36 @@
+From ef2a0bd99b1549a3a4253355be247d5dff25d720 Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Thu, 30 Apr 2020 11:49:11 -0700
+Subject: [PATCH] net: dsa: b53: Remove is_static argument to b53_read_op()
+
+This argument is not used.
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/dsa/b53/b53_common.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/drivers/net/dsa/b53/b53_common.c
++++ b/drivers/net/dsa/b53/b53_common.c
+@@ -1495,8 +1495,7 @@ static int b53_arl_rw_op(struct b53_devi
+ }
+ static int b53_arl_read(struct b53_device *dev, u64 mac,
+-                      u16 vid, struct b53_arl_entry *ent, u8 *idx,
+-                      bool is_valid)
++                      u16 vid, struct b53_arl_entry *ent, u8 *idx)
+ {
+       DECLARE_BITMAP(free_bins, B53_ARLTBL_MAX_BIN_ENTRIES);
+       unsigned int i;
+@@ -1561,7 +1560,8 @@ static int b53_arl_op(struct b53_device
+       if (ret)
+               return ret;
+-      ret = b53_arl_read(dev, mac, vid, &ent, &idx, is_valid);
++      ret = b53_arl_read(dev, mac, vid, &ent, &idx);
++
+       /* If this is a read, just finish now */
+       if (op)
+               return ret;
diff --git a/target/linux/generic/backport-5.4/709-v5.8-0006-net-dsa-b53-remove-redundant-premature-assignment-to.patch b/target/linux/generic/backport-5.4/709-v5.8-0006-net-dsa-b53-remove-redundant-premature-assignment-to.patch
new file mode 100644 (file)
index 0000000..1360aa4
--- /dev/null
@@ -0,0 +1,28 @@
+From 9f01a71c5cbec10b851588457089d17c20dc5a40 Mon Sep 17 00:00:00 2001
+From: Colin Ian King <colin.king@canonical.com>
+Date: Wed, 27 May 2020 13:01:29 +0100
+Subject: [PATCH] net: dsa: b53: remove redundant premature assignment to
+ new_pvid
+
+Variable new_pvid is being assigned with a value that is never read,
+the following if statement updates new_pvid with a new value in both
+of the if paths. The assignment is redundant and can be removed.
+
+Addresses-Coverity: ("Unused value")
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Acked-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/dsa/b53/b53_common.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+--- a/drivers/net/dsa/b53/b53_common.c
++++ b/drivers/net/dsa/b53/b53_common.c
+@@ -1336,7 +1336,6 @@ int b53_vlan_filtering(struct dsa_switch
+       u16 pvid, new_pvid;
+       b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &pvid);
+-      new_pvid = pvid;
+       if (!vlan_filtering) {
+               /* Filtering is currently enabled, use the default PVID since
+                * the bridge does not expect tagging anymore
index b25f3c0d116888b629ca945c6da0e91656a7e594..dbba2f65a250b162ac9f7aedd5b76296763b83a4 100644 (file)
@@ -25,7 +25,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
  
 --- a/drivers/net/dsa/b53/b53_priv.h
 +++ b/drivers/net/dsa/b53/b53_priv.h
-@@ -338,7 +338,9 @@ void b53_phylink_mac_link_down(struct ds
+@@ -344,7 +344,9 @@ void b53_phylink_mac_link_down(struct ds
  void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
                             unsigned int mode,
                             phy_interface_t interface,