From patchwork Mon Nov 28 14:29:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 13057582 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 39984C43217 for ; Mon, 28 Nov 2022 14:27:00 +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: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:In-Reply-To:References: List-Owner; bh=CmBrM2Kbs+WO7zfkMlIMm9ZsbCU4sy9kzfeyUoTz7Vs=; b=YoXQ4xl/g5rXE7 6MeDnNmTSwtRCEcw7RqGVsgU3LodxQLErHRDK1CAseXEgLGN4xr22bqKTFzVJd++Wve6PKhVreYBJ nffXk0URx4QQ3KGn4PiNdiYL8VSIM0HEKdMHPiMYjfhJ0fsp/1bLCqx0ByuCYMgT/mm96ONqLV/1T umtFbeKezXoUdlMucBDE9TVP+VBg0R/bAk097g9dT1ENU8ZSEusXtxtyzeEcitzE/QJTfYH8SWI0T nRU67AKYmiYyXD/uXEiMXsU0Ofw/OrNyzXOB1tSdIolsgYGLd4Q+lRYVE+P5OMIGdjrsjHRZYDg7Z Wt6SUbslq0lqQ9rf0Ruw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ozf51-002BLR-FQ; Mon, 28 Nov 2022 14:25:55 +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 1ozf4x-002BJk-PL for linux-arm-kernel@lists.infradead.org; Mon, 28 Nov 2022 14:25:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669645551; x=1701181551; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=xfwC3aiQPGwe4e2msPr9Ryy3fEIzoLV82RQR4LmlxKU=; b=aoURymuk4swzLzDjJ8z8diKcyXKSLbXpeMfDP8WA1q6Le+x2w0DvejCd 2iKGZ+MbT1+NOcuWha/QnTX71Vskwzf2aBpi4i/rybskPN8BlyFkxHBmV tdYy/GGvtoqdj6MizvppsUXNkUI4Hip0ExReWuNK91LlQQB9Xe2AK0El8 GIQpJOBJlVMWJ2jN2LtMpp3G0oAKVLAI1a7IoUyFOhBq4gTygYVpwBmRk iXRgh+BX+/q0GKLLUAidorA4X0P7dqiWF/gakLefVf2/J/rLnb2YkTKW8 Xjc/XiwVjgi2nWjQRYSpTDk7Vni1FGFgWsOSNi1Rjz77lgtxmLp/OFwxT A==; X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="188964067" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Nov 2022 07:25:44 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Mon, 28 Nov 2022 07:25:39 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Mon, 28 Nov 2022 07:25:37 -0700 From: Horatiu Vultur To: , , CC: , , , , , , , , , Horatiu Vultur Subject: [PATCH net-next] net: microchip: vcap: Change how the rule id is generated Date: Mon, 28 Nov 2022 15:29:59 +0100 Message-ID: <20221128142959.8325-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221128_062551_921162_43C0019A X-CRM114-Status: GOOD ( 14.01 ) 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 Currently whenever a new rule id is generated, it picks up the next number bigger than previous id. So it would always be 1, 2, 3, etc. When the rule with id 1 will be deleted and a new rule will be added, it will have the id 4 and not id 1. In theory this can be a problem if at some point a rule will be added and removed ~0 times. Then no more rules can be added because there are no more ids. Change this such that when a new rule is added, search for an empty rule id starting with value of 1 as value 0 is reserved. Fixes: c9da1ac1c212 ("net: microchip: sparx5: Adding initial tc flower support for VCAP API") Signed-off-by: Horatiu Vultur --- drivers/net/ethernet/microchip/vcap/vcap_api.c | 7 +------ drivers/net/ethernet/microchip/vcap/vcap_api.h | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c index b50d002b646dc..b65819f3a927f 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c @@ -974,17 +974,12 @@ static u32 vcap_next_rule_addr(u32 addr, struct vcap_rule_internal *ri) /* Assign a unique rule id and autogenerate one if id == 0 */ static u32 vcap_set_rule_id(struct vcap_rule_internal *ri) { - u32 next_id; - if (ri->data.id != 0) return ri->data.id; - next_id = ri->vctrl->rule_id + 1; - - for (next_id = ri->vctrl->rule_id + 1; next_id < ~0; ++next_id) { + for (u32 next_id = 1; next_id < ~0; ++next_id) { if (!vcap_lookup_rule(ri->vctrl, next_id)) { ri->data.id = next_id; - ri->vctrl->rule_id = next_id; break; } } diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.h b/drivers/net/ethernet/microchip/vcap/vcap_api.h index ca4499838306f..689c7270f2a89 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api.h +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.h @@ -268,7 +268,6 @@ struct vcap_operations { /* VCAP API Client control interface */ struct vcap_control { - u32 rule_id; /* last used rule id (unique across VCAP instances) */ struct vcap_operations *ops; /* client supplied operations */ const struct vcap_info *vcaps; /* client supplied vcap models */ const struct vcap_statistics *stats; /* client supplied vcap stats */