From mboxrd@z Thu Jan 1 00:00:00 1970 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 88744C43217 for ; Mon, 28 Nov 2022 14:42:37 +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=9lhKsSFSOIzKJjmeBN5HzADwZvAPEw/JituGrvV7tdo=; b=HVV+omnAW1k6Lx 5E6q8wXjEc8W7TTBslFjVCEdoH/72aApOb55rcWNh9Qfp8H0XylPucHzMZMGePmbgIMfG4F7Y9hGr SPVrcSbi/mgYu3UbC+jha3zqZrgBNyPT493CiFLSCZFdH/81aq3cGjRQnu9aVEF/U65ylZj5pCfof SAvimHiRLw5crVjEiKquK9Esv78fQIkBs+5e7b2BB7PjdtWMXxSysyWDHd30uF0zrN63Y8nAbgzlf WXzGz6Atwkm7uLYIepg0ObMfZk3cOwE+Xp4XdfAFnXxHeb5ZKHkHQeSZE8eio8VTTdZqZ5JzeYujP +P9BSeeHj7y0y95PbvOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ozfKD-002HeM-8w; Mon, 28 Nov 2022 14:41:37 +0000 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ozfKA-002Haz-PI for linux-arm-kernel@lists.infradead.org; Mon, 28 Nov 2022 14:41:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669646494; x=1701182494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MSh9uVp2zwjD3iNzMDF4CLgvmRLyaxXitI4MRNVQLcs=; b=QGSSrLylpzLHWUcqqVp9CltEV0cfuud4sabhNnKTtcGhkFNjdsO4kHkX an1GkCqBLMr0KbWyKJVZRuVdA3WAB/JknhWYBSb6YH0NOJlnb3oW1f3gJ iXwgfzwPeK5EcNyw+jmYJsTBcU5TpQzLw0yON9w+wEuyz7gFSmVbkLIEs Gs9yF9O6URF6Ah0DZUlXhulaGpRbw+FIDTfDKllZkGpBS+3g8TeFvRFBc rd21Kh0KzyiTBrtTkMbNHtejbdw57v0wHdjldS/MxDxYPqVn8t7thfz29 ZkO54t/0nwqCwAVNKImZ2r0LLiRv9rpCfpxhNsA4EMJzBlLjgkDc/JS/2 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10545"; a="376988504" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="376988504" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2022 06:41:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10545"; a="749411853" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="749411853" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga002.fm.intel.com with ESMTP; 28 Nov 2022 06:41:26 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 2ASEfPu2018253; Mon, 28 Nov 2022 14:41:25 GMT From: Alexander Lobakin To: Horatiu Vultur Cc: Alexander Lobakin , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, lars.povlsen@microchip.com, Steen.Hegelund@microchip.com, daniel.machon@microchip.com, UNGLinuxDriver@microchip.com, casper.casan@gmail.com Subject: Re: [PATCH net-next] net: microchip: vcap: Change how the rule id is generated Date: Mon, 28 Nov 2022 15:40:42 +0100 Message-Id: <20221128144042.2097491-1-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221128142959.8325-1-horatiu.vultur@microchip.com> References: <20221128142959.8325-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221128_064134_937662_113F5DF9 X-CRM114-Status: GOOD ( 23.18 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Horatiu Vultur Date: Mon, 28 Nov 2022 15:29:59 +0100 > 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)) { Or you can simply use IDA/IDR/XArray which takes care of all this :) > 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 */ > -- > 2.38.0 Thanks, Olek _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel