diff mbox series

[v1] net: dsa: mv88e6xxx: Add FID map cache

Message ID 20240620002826.213013-1-aryan.srivastava@alliedtelesis.co.nz (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v1] net: dsa: mv88e6xxx: Add FID map cache | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be 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 fail Errors and warnings before: 842 this patch: 843
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang fail Errors and warnings before: 849 this patch: 851
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 fail Errors and warnings before: 849 this patch: 850
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 98 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

Commit Message

Aryan Srivastava June 20, 2024, 12:28 a.m. UTC
Add a cached FID bitmap. This mitigates the need to walk all VTU entries
to find the next free FID.

Walk VTU once, then store read FID map into bitmap. Use and manipulate
this bitmap from now on, instead of re-reading HW for the FID map.

The repeatedly VTU walks are costly can result in taking ~40 mins if
~4000 vlans are added. Caching the FID map reduces this time to <2
mins.

Signed-off-by: Aryan Srivastava <aryan.srivastava@alliedtelesis.co.nz>
---
 drivers/net/dsa/mv88e6xxx/chip.c    | 37 +++++++++++++++++++----------
 drivers/net/dsa/mv88e6xxx/chip.h    |  3 +++
 drivers/net/dsa/mv88e6xxx/devlink.c |  9 +------
 3 files changed, 28 insertions(+), 21 deletions(-)

Comments

Jakub Kicinski June 20, 2024, 1:41 a.m. UTC | #1
On Thu, 20 Jun 2024 12:28:26 +1200 Aryan Srivastava wrote:
> +static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
> +{
> +	int err;

err is unused in this function. Please make sure you look at:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html
before reposting
Aryan Srivastava June 20, 2024, 4:57 a.m. UTC | #2
On Wed, 2024-06-19 at 18:41 -0700, Jakub Kicinski wrote:
> On Thu, 20 Jun 2024 12:28:26 +1200 Aryan Srivastava wrote:
> > +static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16
> > *fid)
> > +{
> > +       int err;
> 
> err is unused in this function. Please make sure you look at:
> https://scanmail.trustwave.com/?c=20988&d=tojz5oNpkLwspUVw7ijVLRxq6kprXqr5mqSHszr-YQ&u=https%3a%2f%2fwww%2ekernel%2eorg%2fdoc%2fhtml%2fnext%2fprocess%2fmaintainer-netdev%2ehtml
> before reposting
Apologies, missed this during my compile. Will re-upload with fix in
next series.

Thanks,
Aryan
kernel test robot June 20, 2024, 2:40 p.m. UTC | #3
Hi Aryan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]
[also build test WARNING on net/main linus/master v6.10-rc4 next-20240619]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Aryan-Srivastava/net-dsa-mv88e6xxx-Add-FID-map-cache/20240620-083100
base:   net-next/main
patch link:    https://lore.kernel.org/r/20240620002826.213013-1-aryan.srivastava%40alliedtelesis.co.nz
patch subject: [PATCH v1] net: dsa: mv88e6xxx: Add FID map cache
config: arm-randconfig-003-20240620 (https://download.01.org/0day-ci/archive/20240620/202406202033.cdjd66Gh-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240620/202406202033.cdjd66Gh-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406202033.cdjd66Gh-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/net/dsa/mv88e6xxx/chip.c: In function 'mv88e6xxx_atu_new':
>> drivers/net/dsa/mv88e6xxx/chip.c:1960:13: warning: unused variable 'err' [-Wunused-variable]
    1960 |         int err;
         |             ^~~


vim +/err +1960 drivers/net/dsa/mv88e6xxx/chip.c

  1957	
  1958	static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
  1959	{
> 1960		int err;
  1961	
  1962		*fid = find_first_zero_bit(chip->fid_bitmap, MV88E6XXX_N_FID);
  1963		if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
  1964			return -ENOSPC;
  1965	
  1966		/* Clear the database */
  1967		return mv88e6xxx_g1_atu_flush(chip, *fid, true);
  1968	}
  1969
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index e5bac87941f6..38426434707c 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1726,14 +1726,6 @@  static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
 			port, err);
 }
 
-static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
-{
-	if (!mv88e6xxx_max_vid(chip))
-		return 0;
-
-	return mv88e6xxx_g1_vtu_flush(chip);
-}
-
 static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
 			     struct mv88e6xxx_vtu_entry *entry)
 {
@@ -1813,16 +1805,25 @@  int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap)
 	return mv88e6xxx_vtu_walk(chip, mv88e6xxx_fid_map_vlan, fid_bitmap);
 }
 
-static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
+static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
 {
-	DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
 	int err;
 
-	err = mv88e6xxx_fid_map(chip, fid_bitmap);
+	if (!mv88e6xxx_max_vid(chip))
+		return 0;
+
+	err = mv88e6xxx_g1_vtu_flush(chip);
 	if (err)
 		return err;
 
-	*fid = find_first_zero_bit(fid_bitmap, MV88E6XXX_N_FID);
+	return mv88e6xxx_fid_map(chip, chip->fid_bitmap);
+}
+
+static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
+{
+	int err;
+
+	*fid = find_first_zero_bit(chip->fid_bitmap, MV88E6XXX_N_FID);
 	if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
 		return -ENOSPC;
 
@@ -2529,6 +2530,9 @@  static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
 			 port, vid);
 	}
 
+	/* Record FID used in SW FID map */
+	bitmap_set(chip->fid_bitmap, vlan.fid, 1);
+
 	return 0;
 }
 
@@ -2636,7 +2640,14 @@  static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
 			return err;
 	}
 
-	return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
+	err = mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
+	if (err)
+		return err;
+
+	/* Record FID freed in SW FID map */
+	bitmap_clear(chip->fid_bitmap, vlan.fid, 1);
+
+	return err;
 }
 
 static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
index c54d305a1d83..37958a016a3f 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -421,6 +421,9 @@  struct mv88e6xxx_chip {
 
 	/* Bridge MST to SID mappings */
 	struct list_head msts;
+
+	/* FID map */
+	DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
 };
 
 struct mv88e6xxx_bus_ops {
diff --git a/drivers/net/dsa/mv88e6xxx/devlink.c b/drivers/net/dsa/mv88e6xxx/devlink.c
index a08dab75e0c0..ef3643bc43db 100644
--- a/drivers/net/dsa/mv88e6xxx/devlink.c
+++ b/drivers/net/dsa/mv88e6xxx/devlink.c
@@ -374,7 +374,6 @@  static int mv88e6xxx_region_atu_snapshot(struct devlink *dl,
 					 u8 **data)
 {
 	struct dsa_switch *ds = dsa_devlink_to_ds(dl);
-	DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
 	struct mv88e6xxx_devlink_atu_entry *table;
 	struct mv88e6xxx_chip *chip = ds->priv;
 	int fid = -1, count, err;
@@ -392,14 +391,8 @@  static int mv88e6xxx_region_atu_snapshot(struct devlink *dl,
 
 	mv88e6xxx_reg_lock(chip);
 
-	err = mv88e6xxx_fid_map(chip, fid_bitmap);
-	if (err) {
-		kfree(table);
-		goto out;
-	}
-
 	while (1) {
-		fid = find_next_bit(fid_bitmap, MV88E6XXX_N_FID, fid + 1);
+		fid = find_next_bit(chip->fid_bitmap, MV88E6XXX_N_FID, fid + 1);
 		if (fid == MV88E6XXX_N_FID)
 			break;