From patchwork Mon Jun 10 05:07:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aryan Srivastava X-Patchwork-Id: 13691486 X-Patchwork-Delegate: kuba@kernel.org Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [202.36.163.20]) (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 69B5AB645 for ; Mon, 10 Jun 2024 05:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.36.163.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717996070; cv=none; b=d9R3+T9bTYe4ErYHhyW3mafUXuTu4Aj/F06HIuRWh9mvuOHl/isOf3+6gZxT3pDfdGSoi0jXH7NV9s99DanELvFlFCv05trpzPrNrvtodDStDq73LtmbcwJlH1yRwr5Ci5nCLDTJpWCkuTwzQZLl8n7DEUZ3eJIQedqyQQifkWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717996070; c=relaxed/simple; bh=+lCXsNSPdHORdkSn7RwEEwtPCP8V/j8aKbfQGRFmWQU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=piyXxEokgiiiLtlxATCB5pTUR7UHCdsQBeftonuNT2a8CSN8Ogb1lNyy7O8pW+KXNtW9zLJgoPSSH1AF9qABCOiHoNPQAVn8EEqQewSoSv5+hNhAuLdGQplnjn3//9ZU5TQqw9brW9zNM0+0PhO13YdPRoygi7+gZpyn/O0CO+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz; spf=pass smtp.mailfrom=alliedtelesis.co.nz; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b=oLIeIxCB; arc=none smtp.client-ip=202.36.163.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alliedtelesis.co.nz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="oLIeIxCB" Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id C54442C04C9; Mon, 10 Jun 2024 17:07:44 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1717996064; bh=GCjCcG0qd1PndBkV0c2OpqdW3auENo4im4S6llh54d8=; h=From:To:Cc:Subject:Date:From; b=oLIeIxCBbpoXawfZcUvMy1mQnA74uGu0o7uB0mBPw0cWfjIfWqYXdphuxSJzYwcEG SFs5pwVoM/qOQ4+SYbWD0xaVU4gE8e/g0+rp4kb2sZKdnctshDobnqyudAyTQCJ6QP MNDpUkIqF/hnbbPjZk9YSWi4rZ60ZapVoDrCiUBg/gEHjwgVGkGlBkHu/GRbLw2SA0 fMeYLawaaxBUsO0u85yZvr98PCaI41L438PZE30bEIdJ5z0ZSZdQq0TTuoGsgmdViY p62wqKIxNMzKwwfM//6e9mYxRRpivfB5vEmIlsTUSoyGNxbRLlyKuxYyHMIx/6DHVF Wy9z7VktPFyRg== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Mon, 10 Jun 2024 17:07:44 +1200 Received: from aryans-dl.ws.atlnz.lc (aryans-dl.ws.atlnz.lc [10.33.22.38]) by pat.atlnz.lc (Postfix) with ESMTP id 8E7BF13EE2B; Mon, 10 Jun 2024 17:07:44 +1200 (NZST) Received: by aryans-dl.ws.atlnz.lc (Postfix, from userid 1844) id 87BF22A2270; Mon, 10 Jun 2024 17:07:44 +1200 (NZST) From: Aryan Srivastava To: Andrew Lunn Cc: Aryan Srivastava , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v0] net: dsa: mv88e6xxx: Add FID map cache Date: Mon, 10 Jun 2024 17:07:23 +1200 Message-ID: <20240610050724.2439780-1-aryan.srivastava@alliedtelesis.co.nz> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.4 cv=F9L0dbhN c=1 sm=1 tr=0 ts=66668a20 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=T1WGqf2p2xoA:10 a=vjRDvl-ZFQDR-u-TRfYA:9 a=3ZKOabzyN94A:10 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat X-Patchwork-Delegate: kuba@kernel.org 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); + return 0; } @@ -2636,7 +2642,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..2abe6f09c8df 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -421,6 +421,10 @@ struct mv88e6xxx_chip { /* Bridge MST to SID mappings */ struct list_head msts; + + /* FID map */ + DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); + bool fid_populated; }; struct mv88e6xxx_bus_ops {