Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp187143lqp; Tue, 11 Jun 2024 00:58:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURyHYcQu80Xjl4sWoOC/bN+eikTlvJwjxnQZQkYzva97ppSr0AJ0HRvm/y9A6ThBJMuIRTNVnIoLqXe0IFEmBBIuqEdlZRhqIR0tAM0Q== X-Google-Smtp-Source: AGHT+IE9mfeGp6U9uEkw+YfbsrW1bL5wOx85vJOydPqehQQ+G02k8frz7oRwpucsgkYWx86w3e4+ X-Received: by 2002:a17:906:eb12:b0:a6f:2130:34c2 with SMTP id a640c23a62f3a-a6f213f79c9mr241630366b.18.1718092692113; Tue, 11 Jun 2024 00:58:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718092692; cv=pass; d=google.com; s=arc-20160816; b=inRxconKSuY3v8xIsG25oVaIGOBWqkNTzHE3uhqu8ek1rXZ9ZfboTT4ZdOJFL8x1A6 qEomfabQ8+ieywxBZDa3uuuxXSscTLZDBmkcjp+0PQTeI9ERa+bZPgL+J7GBd0du3k/q I1BHOYjTiLKqo02t5weCJu8uJAPQ1q4ErxgdwpbFQOvaXhBpNew9s37+MFE7vMdmMT4Q et4SRypYUvDxhI4u77TtoTCb9gsccXs/9d6EDzMW/nQlWWWNeAKtYr4Y643s99f5Hqzk XuIMjkrcelnRDgitBkVpT1zaLuhYbqwqkxSlSpaXu9OlLKfFWrjoYZX/+5fyZ1R3GaZs C/zg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=30zqSUWjkfAM9mdnIDNSFOIrbz6pswK1l56WwXCpHD0=; fh=LnsBCEVOLpS7/f0PJ3xBDX4CxSIHPT55R01VrXdGGLw=; b=ZW2MiUNp6TXwscfb/Y6W+NSTUPI4Ki704auuwPRSEvetNd1GzbMBtc45HWJ+m7qEwU XOh5ieQufcasAT15zIbd+iPh51Ot4UodaeOOJ6Z27Y5qjM2GOvtcHXCJjbrYvQMqioco dqdctcK5IueMOYVbCI3WTwE4vlNuOaOxKsbS2WFQWG57OTOwMcsilWVaQHjC6wczJft8 uiY4905+tFuClBfS9nkMTzhUH2U+o03vTePzjW1cvTWcX7jup8uXRqUIegBsFV6G70Bu WDsmcH6VMpIxg1ooWdIuLofCcH076WdcX1lxcqUKTe62vEVBgxKM3aQ1bvc1b/ens72O 80rA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SUeCMwrv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-209416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f1a1ad4ffsi220031166b.613.2024.06.11.00.58.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 00:58:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SUeCMwrv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-209416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8A1DA1F29C75 for ; Tue, 11 Jun 2024 07:50:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8209172BCE; Tue, 11 Jun 2024 07:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SUeCMwrv" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3132172798; Tue, 11 Jun 2024 07:50:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718092223; cv=none; b=Hx8UIO4V/c74qQZe6OCSWZkLh6TOIcDWcTqkhVjFGjni4GQHQxxhDSMpNhpMLq0/N5U/ZmQc0MDbmgDvG85k2V7AhvoOXwbHW4F+ecWStbdMSLILcKQ9x5RBC0weLHImBcEVcRcqA4JbVEzqgxRJ6CKGgrQRbnFt9NZfPfNvkKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718092223; c=relaxed/simple; bh=/tWfB59NEBN9boSZX0IDoiDx1xvzNUOL2J/WjwuRFWw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XKqkAnnQIlV/IuMzcO464pgeFWTelL7R2KH+HiHwe/nuKhcSW6lxoXRiA5aejOj3tqCE6cmBq5iJiDK0++kT3j5IUT0080m+/VQJArf/yNX0aKmrPJkpdbc2buyrpkxq3QKvuiOOpQjGYt0ibVyv5DTtz8p0cXLXtMj4CvUp29c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SUeCMwrv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B9EEC2BD10; Tue, 11 Jun 2024 07:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718092222; bh=/tWfB59NEBN9boSZX0IDoiDx1xvzNUOL2J/WjwuRFWw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SUeCMwrvxhqLlr0zpe5+fL9/zDEf8PGGNw7RCcB9OJoYjzN5vPWFyRda0mxoRNL29 F4zzdGCfeUkfbC5hrqArj1FZjH6sIVWG5mzBSiopy99vzybrrz5nOx7TS7CZC6gFtt IlVPh4zTopZrqTkE06ntXQRp4V1Docol8KJjXPqj7j0YvAxeG2TnrhuDiUDcc14Yk4 gEZDCexr94ccaj1vjBcqwDoc4OVzguuV2bwby0QFQVKTVcdwUCJRTZpLXZlvnB3bLZ J+Jx2EjSqDBSKWtcI/cBa0wDMGi8ZOTyz17UdwZBMiPB0dRbvxCzXCxD7h6KyVHBj7 /bUS4bUEUPUQg== Date: Tue, 11 Jun 2024 09:50:16 +0200 From: Marek =?UTF-8?B?QmVow7pu?= To: Aryan Srivastava Cc: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v0] net: dsa: mv88e6xxx: Add FID map cache Message-ID: <20240611095016.7804b091@dellmb> In-Reply-To: <20240610050724.2439780-1-aryan.srivastava@alliedtelesis.co.nz> References: <20240610050724.2439780-1-aryan.srivastava@alliedtelesis.co.nz> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 10 Jun 2024 17:07:23 +1200 Aryan Srivastava wrote: > 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 > --- > drivers/net/dsa/mv88e6xxx/chip.c | 25 +++++++++++++++++++------ > drivers/net/dsa/mv88e6xxx/chip.h | 4 ++++ > 2 files changed, 23 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c > index e5bac87941f6..91816e3e35ed 100644 > --- a/drivers/net/dsa/mv88e6xxx/chip.c > +++ b/drivers/net/dsa/mv88e6xxx/chip.c > @@ -1815,14 +1815,17 @@ int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap) > > static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) > { > - DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); > int err; > > - err = mv88e6xxx_fid_map(chip, fid_bitmap); > - if (err) > - return err; > + if (!chip->fid_populated) { > + err = mv88e6xxx_fid_map(chip, chip->fid_bitmap); > + if (err) > + return err; > > - *fid = find_first_zero_bit(fid_bitmap, MV88E6XXX_N_FID); > + chip->fid_populated = true; > + } > + > + *fid = find_first_zero_bit(chip->fid_bitmap, MV88E6XXX_N_FID); > if (unlikely(*fid >= mv88e6xxx_num_databases(chip))) > return -ENOSPC; > > @@ -2529,6 +2532,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); > + wouldn't it make more sense to do this bit setting in mv88e6xxx_atu_new() and clearingin a new function mv88e6xxx_atu_delete/drop() ?