From patchwork Tue Feb 14 10:40:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 13139852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8689DC61DA4 for ; Tue, 14 Feb 2023 10:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mEZw6UXzYZuxsbCJMzGz+XmztdYHlnBZrDHaCuM/flQ=; b=O/W8nSBnIhw8SR I42GYoLRD9V5G2IHroA1Hb52ge73L8aLuTPS2Aek0m+DDSmposNN4o7Bb3XEeiIxG8/DfqrkGIRl1 ieZnH1l3p5nmJxmCtYSlCIc6YQOZMUjz1+KWdSMLPcGjDBQoUq2vjgxXo/XuGWoGRgEsC50GgkSQJ yseDVgee5kNsC0yf+ARc2enIJNptBvSDdahizLLm7/vGXbCmMEf1BTR3GXWXM/SdFHW/5jcdWlXQO RQXjX/m7GowHwBY0h/e52NmM4thSeyY9V4uuUyuphSgQItuQVB83TBXb/bNiaJl1F4NYvjojD0mJi BOpzJSz/8Jf8t3Gdyc4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRsl9-0014WM-5F; Tue, 14 Feb 2023 10:42:03 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRskM-00149t-7v for linux-arm-kernel@lists.infradead.org; Tue, 14 Feb 2023 10:41:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676371274; x=1707907274; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QTCEvWMBpzgY5YyohEVC7852Z+3PzYdmpKIe3hK+24o=; b=VwBtyq/AMM8Qg1VK6unM1mIgONJptshzbW7/C2wVPhQ4yYP9wYFxLGt1 eX6Du/jr9D/9uYNtrinVZYboqpFZa5R9u7g7gzZeOWFHKUDw1RxcuSuNY wBSGCZNjSG3dwDeTQPRvYXgcyLViWEwSi67rXFsdf4oWTw7nCjw76yJnQ OrHVAlsY2S5f9nlfZbjxEv+S8+y+xwcrWZNzFu7ASrCTvEaQFBtvv91M7 IK19jhMNNC97OCZKXpHjX8wv72U/vFnyJiVhIdIXUD3BU2kF0Kd66dsXp 4y2xBcYY9b5CjK6tf251MNjfTu+N+E8z/5d/0z9hFMOudMhX9L9uZnQQY A==; X-IronPort-AV: E=Sophos;i="5.97,296,1669100400"; d="scan'208";a="200417835" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2023 03:41:13 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 14 Feb 2023 03:41:10 -0700 Received: from den-dk-m31857.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 14 Feb 2023 03:41:07 -0700 From: Steen Hegelund To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni CC: Steen Hegelund , , Randy Dunlap , "Casper Andersson" , Russell King , Wan Jiabing , "Nathan Huckleberry" , , , , "Steen Hegelund" , Daniel Machon , Horatiu Vultur , Lars Povlsen , Dan Carpenter , Michael Walle Subject: [PATCH net-next v2 04/10] net: microchip: sparx5: Use chain ids without offsets when enabling rules Date: Tue, 14 Feb 2023 11:40:43 +0100 Message-ID: <20230214104049.1553059-5-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214104049.1553059-1-steen.hegelund@microchip.com> References: <20230214104049.1553059-1-steen.hegelund@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230214_024114_672751_D1AD6FB6 X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This improves the check performed on linked rules when enabling or disabling them. The chain id used must be the chain id without the offset used for linking the rules. Signed-off-by: Steen Hegelund --- drivers/net/ethernet/microchip/vcap/vcap_api.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c index 68e04d47f6fd..4847d0d99ec9 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c @@ -1649,10 +1649,8 @@ bool vcap_is_next_lookup(struct vcap_control *vctrl, int src_cid, int dst_cid) if (vcap_api_check(vctrl)) return false; - /* The offset must be at least one lookup, round up */ - next_cid = src_cid + VCAP_CID_LOOKUP_SIZE; - next_cid /= VCAP_CID_LOOKUP_SIZE; - next_cid *= VCAP_CID_LOOKUP_SIZE; + /* The offset must be at least one lookup so round up one chain */ + next_cid = roundup(src_cid + 1, VCAP_CID_LOOKUP_SIZE); if (dst_cid < next_cid) return false; @@ -2177,12 +2175,13 @@ static int vcap_get_next_chain(struct vcap_control *vctrl, static bool vcap_path_exist(struct vcap_control *vctrl, struct net_device *ndev, int dst_cid) { + int cid = rounddown(dst_cid, VCAP_CID_LOOKUP_SIZE); struct vcap_enabled_port *eport = NULL; struct vcap_enabled_port *elem; struct vcap_admin *admin; int tmp; - if (dst_cid == 0) /* Chain zero is always available */ + if (cid == 0) /* Chain zero is always available */ return true; /* Find first entry that starts from chain 0*/ @@ -2201,7 +2200,7 @@ static bool vcap_path_exist(struct vcap_control *vctrl, struct net_device *ndev, return false; tmp = eport->dst_cid; - while (tmp != dst_cid && tmp != 0) + while (tmp != cid && tmp != 0) tmp = vcap_get_next_chain(vctrl, ndev, tmp); return !!tmp;