Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp150171lqp; Sun, 9 Jun 2024 22:08:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWMTfWcEkSaojDsuQmhqp8+m0gPrZACIjy1WYzeCnPpytUMkv01dV1D4t2fkVuPy9guzfmCF3Vh6hCwhQsQEgVK1rzgVd+mbcITbloRJA== X-Google-Smtp-Source: AGHT+IG9vMErhbX6YMBFY5gSipYzOioahvfBqXMWMDBmXZ1nuv8WhQaBmIyOozK8oJCN/PUa3gt+ X-Received: by 2002:a17:902:f650:b0:1f6:8314:50f4 with SMTP id d9443c01a7336-1f6d0388c60mr94021625ad.47.1717996085603; Sun, 09 Jun 2024 22:08:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717996085; cv=pass; d=google.com; s=arc-20160816; b=z3h3vQbtCsEuXSxlp5qkeZyo3wrUU5tZGf4jMpxh1i/vlx0xCAkhlWpGVLzkslmMEa Q5uUUcWheJU/B/Iq/y0FLLcIEF/0wYD2yZPhRMDGTyhgVRY98fR9NbOMGH97FhiixrXK p2eVP3UCIIxZ5BLLIgSgJKFg9mQKrbBqch92Ig6KiB9oF6sWuR3EU9mlR09httZA9A6v QpkvIfa6iCQBd4DUhUvvjwP+5w1GB5WbC2QrTMY7VCERmj5wTD2Tdx7sIn9Iy9cJTEqS pFciICQncEjOjr+xxcmi4kluTqs9X6z4HU1XOedLgw6Pm5KmTiLCET/Gih7eXtcdFru3 C/CQ== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=GCjCcG0qd1PndBkV0c2OpqdW3auENo4im4S6llh54d8=; fh=kplA5BiYT7Iz7rlfi4V0qHhQKpCIdnipQlvnKatkPjc=; b=EdYFR3AM+H8V7aYoB1MoclIQZXlsZ1lC6ReGPboM/L4zTOgMOlrz9gaQTpbzVEiJ6a +IajKKCb44iwjVYWQ4r+GpN/u5ZPTz1s6nbmsgDs7WUf0az0dRogltF2IT+UA1gLtlUE lCFgN9eBAR1L6IIIcUXtZDd/oaVnyYtt6ohBVYdLr59H0pMPonyOgSHtx5KuuUnsOmgf h2wqmFjtzh5vFTjrrEajef008XaueWS8T6SMK/soyjuCsNN3gYltXjKO3hdIC+sXoiBn MshGr1fs/ZTwvgz1DeMbF0+Fr62Adzr1OGXJXVOo38qDhzDUW6cPN8cUf68zyTcLoFJq YMgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=oLIeIxCB; arc=pass (i=1 spf=pass spfdomain=alliedtelesis.co.nz dkim=pass dkdomain=alliedtelesis.co.nz dmarc=pass fromdomain=alliedtelesis.co.nz); spf=pass (google.com: domain of linux-kernel+bounces-207644-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207644-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f71aff6c30si4668885ad.9.2024.06.09.22.08.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 22:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207644-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=oLIeIxCB; arc=pass (i=1 spf=pass spfdomain=alliedtelesis.co.nz dkim=pass dkdomain=alliedtelesis.co.nz dmarc=pass fromdomain=alliedtelesis.co.nz); spf=pass (google.com: domain of linux-kernel+bounces-207644-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207644-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B4773B20DDD for ; Mon, 10 Jun 2024 05:08:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02C23101CA; Mon, 10 Jun 2024 05:07:52 +0000 (UTC) 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 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 69B20A935 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=1717996071; cv=none; b=baMgtGDTsPOsTHt9UQGoOU1bVfmH+8oWzM544O9SXPEbpdBJ9jvEydl7Ds9zbNEky5Dh/iya94hK92Dta8zzvEKBE9XpWBHW/TezUXaJypeooIBIuyij3dqT/iDXpOQbA6tCBrqQoZBxyMSWjW27JOJ8HcFh3+xgeuiR+m3I8lw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717996071; c=relaxed/simple; bh=+lCXsNSPdHORdkSn7RwEEwtPCP8V/j8aKbfQGRFmWQU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=XsPPk9dGEjinAON2IW2GxdKxUv1ISrwVEL6kyZMNmDrRqoCxCtZ8Y99cvijpu+DN/rNRPFGVcevO0lf3WeK71beAJkFsYm9FLD/ibJizjyS8OeX2yV2DpUafpnT/kh8gIvKUycz3ZHFP86J8XSzywi64qOtYifg1H/dRROstal8= 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 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 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) =20 static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) { - DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); int err; =20 - err =3D mv88e6xxx_fid_map(chip, fid_bitmap); - if (err) - return err; + if (!chip->fid_populated) { + err =3D mv88e6xxx_fid_map(chip, chip->fid_bitmap); + if (err) + return err; =20 - *fid =3D find_first_zero_bit(fid_bitmap, MV88E6XXX_N_FID); + chip->fid_populated =3D true; + } + + *fid =3D find_first_zero_bit(chip->fid_bitmap, MV88E6XXX_N_FID); if (unlikely(*fid >=3D mv88e6xxx_num_databases(chip))) return -ENOSPC; =20 @@ -2529,6 +2532,9 @@ static int mv88e6xxx_port_vlan_join(struct mv88e6xx= x_chip *chip, int port, port, vid); } =20 + /* Record FID used in SW FID map */ + bitmap_set(chip->fid_bitmap, vlan.fid, 1); + return 0; } =20 @@ -2636,7 +2642,14 @@ static int mv88e6xxx_port_vlan_leave(struct mv88e6= xxx_chip *chip, return err; } =20 - return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false); + err =3D 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; } =20 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 { =20 /* Bridge MST to SID mappings */ struct list_head msts; + + /* FID map */ + DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); + bool fid_populated; }; =20 struct mv88e6xxx_bus_ops { --=20 2.43.2