[net-next,02/10] net: microchip: sparx5: Clear rule counter even if lookup is disabled
Message ID | 20230213092426.1331379-3-steen.hegelund@microchip.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2250000wrn; Mon, 13 Feb 2023 01:27:50 -0800 (PST) X-Google-Smtp-Source: AK7set+xVob5P9CZHj55foxVm6OWyYYLBQHatP2edN2V0ISzSSiulxrRpLFfdo9o+SMwaaqZ4bq8 X-Received: by 2002:a50:8d1e:0:b0:4ac:c426:6b4a with SMTP id s30-20020a508d1e000000b004acc4266b4amr3787389eds.36.1676280469933; Mon, 13 Feb 2023 01:27:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676280469; cv=none; d=google.com; s=arc-20160816; b=ZzjNAbtl6vgjK8nB7o1GkK0VxquTNnG2iVo5LJtJQh4Bnl67aKqnvnZC6o1+0KGbYY UmEE5yymvTcBXpcq5dFaNJbvLZGUBA2oLEsm/anvPvvcKM58Qm/lGP8tHT4oubGfnGAZ S95JkWPnQ5yRTJWBuxgEpDu1/Df1njuOvxQricNzVWeIora8mxRgcf08X2Ntl5Vb5kqu zVvVt3rCgJjAml+I7acDLAzOXu232ewrECgjnDmG+CrBpzcPBOiKm12AWP7ZV9cL8A6B GcS2mOIsSaDzuyW1qyEZSS367TrNYWM0kmfks0n1Lc0TUIAOdCVe/s566cbpfG2W6+Qn amIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=By3O0cB6Q47DWEDPlQhZioCU6fT3VRRszJPjxtjlNNk=; b=hi2ny7aKkMa6TNYLGwwOK/suoe7+TyHJnHpqejoYD108Jq1spIur3Tp5/YPNe+QcEO 6Z68X5+uTOzOBKr00ufkvooBSrE0+h4CYe6908prZiQDgEyrdvLrZh54Xj6ZVSsoe/LD 1t2zZFnoDVT0K7mEJfYkKSJ6N+6XPUDU7ULHOvnXGBBl7zQT3QTS6Qq7hxWrgxHZJmVM kn5SBDDRXPSXdNBCHUjc4owr4TWZIdwqytpC0qEHK1ndLNr5zc3107JVy2r5T9hYPGvG oLyyRPW0S+9RU7+XSfPc9TFgBitqVXuKTt4kKQlYumHse9pL4KD4IoEqrSIseqENOAwK eFzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=Y4kir+J2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a50fe88000000b004ab250bcee5si10981747edt.647.2023.02.13.01.27.27; Mon, 13 Feb 2023 01:27:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=Y4kir+J2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229981AbjBMJYz (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Mon, 13 Feb 2023 04:24:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbjBMJYr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 13 Feb 2023 04:24:47 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10061BDE6; Mon, 13 Feb 2023 01:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676280285; x=1707816285; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fUqcEr8xiVVv9RpE+ICjO+IU3AQzgM8prfSvJBqKoi8=; b=Y4kir+J2lTpZpcK2gJj3fhJF9994owY3IsKNkTmnn7Jt61KN7KUzkqaP 4CGpmFPEKwsUGiaXm6peYHgwuAUgm0V14Rmdy4Jhc0IgQE+pQm0ZBtTkj 4W8xv4ywbpW2iAzTPHcOsQG2/wTc5qkWKS+yfIIDFZiluvIKidsNJTvwh lNIdmmLy47E541w4gX/ARUv/ghr5Qx5EyExAMSQJZLfitJJZcZPRWLhZm A0TWxLB2pB0bwn42LiXTk+zm9A0Nm96QbOkDoE0rLi5pG0Vb6nDe6jC/w GYhRYfc/FrLt5wEmEAx6rsLzKRYr7ksjqfiKRpJQjMs+4i2pa5sJEaTZu A==; X-IronPort-AV: E=Sophos;i="5.97,293,1669100400"; d="scan'208";a="136853329" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 13 Feb 2023 02:24:45 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 13 Feb 2023 02:24:43 -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; Mon, 13 Feb 2023 02:24:39 -0700 From: Steen Hegelund <steen.hegelund@microchip.com> To: "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> CC: Steen Hegelund <steen.hegelund@microchip.com>, <UNGLinuxDriver@microchip.com>, Randy Dunlap <rdunlap@infradead.org>, "Casper Andersson" <casper.casan@gmail.com>, Russell King <rmk+kernel@armlinux.org.uk>, Wan Jiabing <wanjiabing@vivo.com>, "Nathan Huckleberry" <nhuck@google.com>, <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, "Steen Hegelund" <Steen.Hegelund@microchip.com>, Daniel Machon <daniel.machon@microchip.com>, Horatiu Vultur <horatiu.vultur@microchip.com>, Lars Povlsen <lars.povlsen@microchip.com>, Dan Carpenter <error27@gmail.com>, Michael Walle <michael@walle.cc> Subject: [PATCH net-next 02/10] net: microchip: sparx5: Clear rule counter even if lookup is disabled Date: Mon, 13 Feb 2023 10:24:18 +0100 Message-ID: <20230213092426.1331379-3-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213092426.1331379-1-steen.hegelund@microchip.com> References: <20230213092426.1331379-1-steen.hegelund@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757707469796230902?= X-GMAIL-MSGID: =?utf-8?q?1757707469796230902?= |
Series |
Adding Sparx5 ES0 VCAP support
|
|
Commit Message
Steen Hegelund
Feb. 13, 2023, 9:24 a.m. UTC
The rule counter must be cleared when creating a new rule, even if the VCAP
lookup is currently disabled.
Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
---
drivers/net/ethernet/microchip/vcap/vcap_api.c | 7 +++++--
drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c | 4 ++--
2 files changed, 7 insertions(+), 4 deletions(-)
Comments
On Mon, Feb 13, 2023 at 10:24:18AM +0100, Steen Hegelund wrote: > The rule counter must be cleared when creating a new rule, even if the VCAP > lookup is currently disabled. > > Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com> Is this a bugfix? If so what are the user visible effects of this bug and please add a Fixes tag. If not then could you explain more what this patch is for? > --- > drivers/net/ethernet/microchip/vcap/vcap_api.c | 7 +++++-- > drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c | 4 ++-- > 2 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c > index 6307d59f23da..68e04d47f6fd 100644 > --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c > +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c > @@ -2246,6 +2246,11 @@ int vcap_add_rule(struct vcap_rule *rule) > if (move.count > 0) > vcap_move_rules(ri, &move); > > + /* Set the counter to zero */ > + ret = vcap_write_counter(ri, &ctr); > + if (ret) > + goto out; > + > if (ri->state == VCAP_RS_DISABLED) { > /* Erase the rule area */ > ri->vctrl->ops->init(ri->ndev, ri->admin, ri->addr, ri->size); > @@ -2264,8 +2269,6 @@ int vcap_add_rule(struct vcap_rule *rule) > pr_err("%s:%d: rule write error: %d\n", __func__, __LINE__, ret); > goto out; > } > - /* Set the counter to zero */ > - ret = vcap_write_counter(ri, &ctr); > out: > mutex_unlock(&ri->admin->lock); > return ret; > diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > index b2753aac8ad2..0a1d4d740567 100644 > --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > @@ -1337,8 +1337,8 @@ static void vcap_api_encode_rule_test(struct kunit *test) > u32 port_mask_rng_mask = 0x0f; > u32 igr_port_mask_value = 0xffabcd01; > u32 igr_port_mask_mask = ~0; > - /* counter is written as the last operation */ > - u32 expwriteaddr[] = {792, 793, 794, 795, 796, 797, 792}; > + /* counter is written as the first operation */ > + u32 expwriteaddr[] = {792, 792, 793, 794, 795, 796, 797}; So this moves 792 from the last to the first. I would have expected that that would mean that we had to do something like this as well: diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c index b2753aac8ad2..4d36fad0acab 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c @@ -1400,7 +1400,7 @@ static void vcap_api_encode_rule_test(struct kunit *test) /* Add rule with write callback */ ret = vcap_add_rule(rule); KUNIT_EXPECT_EQ(test, 0, ret); - KUNIT_EXPECT_EQ(test, 792, is2_admin.last_used_addr); + KUNIT_EXPECT_EQ(test, 797, is2_admin.last_used_addr); for (idx = 0; idx < ARRAY_SIZE(expwriteaddr); ++idx) KUNIT_EXPECT_EQ(test, expwriteaddr[idx], test_updateaddr[idx]); But I couldn't really figure out how the .last_used_addr stuff works. And presumably fixing this unit test is the point of the patch... regards, dan carpenter
Hi Dan, On Mon, 2023-02-13 at 14:29 +0300, Dan Carpenter wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you know the > content is safe > > On Mon, Feb 13, 2023 at 10:24:18AM +0100, Steen Hegelund wrote: > > The rule counter must be cleared when creating a new rule, even if the VCAP > > lookup is currently disabled. > > > > Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com> > > Is this a bugfix? If so what are the user visible effects of this bug > and please add a Fixes tag. If not then could you explain more what > this patch is for? Yes this is a bugfix of a side effect introduced by my mid-January series "Add support for two classes of VCAP rules" where this counter change should have been added too. The counter problem is only present on VCAP that has external counters, so it only affects the IS2 and ES0 VCAP on Sparx5 and none of the LAN966x VCAPs. I will add a Fixes tag to the next series. > > > --- > > drivers/net/ethernet/microchip/vcap/vcap_api.c | 7 +++++-- > > drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c | 4 ++-- > > 2 files changed, 7 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c > > b/drivers/net/ethernet/microchip/vcap/vcap_api.c > > index 6307d59f23da..68e04d47f6fd 100644 > > --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c > > +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c > > @@ -2246,6 +2246,11 @@ int vcap_add_rule(struct vcap_rule *rule) > > if (move.count > 0) > > vcap_move_rules(ri, &move); > > > > + /* Set the counter to zero */ > > + ret = vcap_write_counter(ri, &ctr); > > + if (ret) > > + goto out; > > + > > if (ri->state == VCAP_RS_DISABLED) { > > /* Erase the rule area */ > > ri->vctrl->ops->init(ri->ndev, ri->admin, ri->addr, ri->size); > > @@ -2264,8 +2269,6 @@ int vcap_add_rule(struct vcap_rule *rule) > > pr_err("%s:%d: rule write error: %d\n", __func__, __LINE__, > > ret); > > goto out; > > } > > - /* Set the counter to zero */ > > - ret = vcap_write_counter(ri, &ctr); > > out: > > mutex_unlock(&ri->admin->lock); > > return ret; > > diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > index b2753aac8ad2..0a1d4d740567 100644 > > --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > @@ -1337,8 +1337,8 @@ static void vcap_api_encode_rule_test(struct kunit > > *test) > > u32 port_mask_rng_mask = 0x0f; > > u32 igr_port_mask_value = 0xffabcd01; > > u32 igr_port_mask_mask = ~0; > > - /* counter is written as the last operation */ > > - u32 expwriteaddr[] = {792, 793, 794, 795, 796, 797, 792}; > > + /* counter is written as the first operation */ > > + u32 expwriteaddr[] = {792, 792, 793, 794, 795, 796, 797}; > > So this moves 792 from the last to the first. I would have expected > that that would mean that we had to do something like this as well: > > diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > index b2753aac8ad2..4d36fad0acab 100644 > --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > @@ -1400,7 +1400,7 @@ static void vcap_api_encode_rule_test(struct kunit > *test) > /* Add rule with write callback */ > ret = vcap_add_rule(rule); > KUNIT_EXPECT_EQ(test, 0, ret); > - KUNIT_EXPECT_EQ(test, 792, is2_admin.last_used_addr); > + KUNIT_EXPECT_EQ(test, 797, is2_admin.last_used_addr); > for (idx = 0; idx < ARRAY_SIZE(expwriteaddr); ++idx) > KUNIT_EXPECT_EQ(test, expwriteaddr[idx], > test_updateaddr[idx]); > > > But I couldn't really figure out how the .last_used_addr stuff works. > And presumably fixing this unit test is the point of the patch... It is just the array of addresses written to in the order that they are written, so for the visibility I would like to keep it as an array. > > regards, > dan carpenter Thanks for the comments! BR Steen
On Mon, Feb 13, 2023 at 01:44:35PM +0100, Steen Hegelund wrote: > > > diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > index b2753aac8ad2..0a1d4d740567 100644 > > > --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > @@ -1337,8 +1337,8 @@ static void vcap_api_encode_rule_test(struct kunit > > > *test) > > > u32 port_mask_rng_mask = 0x0f; > > > u32 igr_port_mask_value = 0xffabcd01; > > > u32 igr_port_mask_mask = ~0; > > > - /* counter is written as the last operation */ > > > - u32 expwriteaddr[] = {792, 793, 794, 795, 796, 797, 792}; > > > + /* counter is written as the first operation */ > > > + u32 expwriteaddr[] = {792, 792, 793, 794, 795, 796, 797}; > > > > So this moves 792 from the last to the first. I would have expected > > that that would mean that we had to do something like this as well: > > > > diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > index b2753aac8ad2..4d36fad0acab 100644 > > --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > @@ -1400,7 +1400,7 @@ static void vcap_api_encode_rule_test(struct kunit > > *test) > > /* Add rule with write callback */ > > ret = vcap_add_rule(rule); > > KUNIT_EXPECT_EQ(test, 0, ret); > > - KUNIT_EXPECT_EQ(test, 792, is2_admin.last_used_addr); > > + KUNIT_EXPECT_EQ(test, 797, is2_admin.last_used_addr); > > for (idx = 0; idx < ARRAY_SIZE(expwriteaddr); ++idx) > > KUNIT_EXPECT_EQ(test, expwriteaddr[idx], > > test_updateaddr[idx]); > > > > > > But I couldn't really figure out how the .last_used_addr stuff works. > > And presumably fixing this unit test is the point of the patch... > > It is just the array of addresses written to in the order that they are written, > so for the visibility I would like to keep it as an array. > My question was likely noise to begin with, but it's not clear that I phrased it well. I'm asking that since 797 is now the last element in the array, I expected that the KUNIT_EXPECT_EQ() test for last_used_addr would have to be changed to 797 as well. regards, dan carpenter
Hi Dan, On Mon, 2023-02-13 at 18:06 +0300, Dan Carpenter wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you know the > content is safe > > On Mon, Feb 13, 2023 at 01:44:35PM +0100, Steen Hegelund wrote: > > > > diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > > b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > > index b2753aac8ad2..0a1d4d740567 100644 > > > > --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > > +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > > @@ -1337,8 +1337,8 @@ static void vcap_api_encode_rule_test(struct kunit > > > > *test) > > > > u32 port_mask_rng_mask = 0x0f; > > > > u32 igr_port_mask_value = 0xffabcd01; > > > > u32 igr_port_mask_mask = ~0; > > > > - /* counter is written as the last operation */ > > > > - u32 expwriteaddr[] = {792, 793, 794, 795, 796, 797, 792}; > > > > + /* counter is written as the first operation */ > > > > + u32 expwriteaddr[] = {792, 792, 793, 794, 795, 796, 797}; > > > > > > So this moves 792 from the last to the first. I would have expected > > > that that would mean that we had to do something like this as well: > > > > > > diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > index b2753aac8ad2..4d36fad0acab 100644 > > > --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c > > > @@ -1400,7 +1400,7 @@ static void vcap_api_encode_rule_test(struct kunit > > > *test) > > > /* Add rule with write callback */ > > > ret = vcap_add_rule(rule); > > > KUNIT_EXPECT_EQ(test, 0, ret); > > > - KUNIT_EXPECT_EQ(test, 792, is2_admin.last_used_addr); > > > + KUNIT_EXPECT_EQ(test, 797, is2_admin.last_used_addr); > > > for (idx = 0; idx < ARRAY_SIZE(expwriteaddr); ++idx) > > > KUNIT_EXPECT_EQ(test, expwriteaddr[idx], > > > test_updateaddr[idx]); > > > > > > > > > But I couldn't really figure out how the .last_used_addr stuff works. > > > And presumably fixing this unit test is the point of the patch... > > > > It is just the array of addresses written to in the order that they are > > written, > > so for the visibility I would like to keep it as an array. > > > > My question was likely noise to begin with, but it's not clear that I > phrased it well. I'm asking that since 797 is now the last element in > the array, I expected that the KUNIT_EXPECT_EQ() test for last_used_addr > would have to be changed to 797 as well. There are two writes to the 792 address as the counter recides with the start of the rule (the lowest address of the rule). Instead of being written after the rule, it is now being written before the rule, so the test array that records the order of the write operations gets changed. The is2_admin.last_used_addr on the other hand records the "low water mark" of used addresses in the VCAP instance, so it does not change as the rule size is the same. > > regards, > dan carpenter > BR Steen
On Mon, Feb 13, 2023 at 04:32:21PM +0100, Steen Hegelund wrote: > There are two writes to the 792 address as the counter recides with the start of > the rule (the lowest address of the rule). Instead of being written after the > rule, it is now being written before the rule, so the test array that records > the order of the write operations gets changed. > > The is2_admin.last_used_addr on the other hand records the "low water mark" of > used addresses in the VCAP instance, so it does not change as the rule size is > the same. That explains it. Thanks! regards, dan carpenter
diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c index 6307d59f23da..68e04d47f6fd 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c @@ -2246,6 +2246,11 @@ int vcap_add_rule(struct vcap_rule *rule) if (move.count > 0) vcap_move_rules(ri, &move); + /* Set the counter to zero */ + ret = vcap_write_counter(ri, &ctr); + if (ret) + goto out; + if (ri->state == VCAP_RS_DISABLED) { /* Erase the rule area */ ri->vctrl->ops->init(ri->ndev, ri->admin, ri->addr, ri->size); @@ -2264,8 +2269,6 @@ int vcap_add_rule(struct vcap_rule *rule) pr_err("%s:%d: rule write error: %d\n", __func__, __LINE__, ret); goto out; } - /* Set the counter to zero */ - ret = vcap_write_counter(ri, &ctr); out: mutex_unlock(&ri->admin->lock); return ret; diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c index b2753aac8ad2..0a1d4d740567 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c @@ -1337,8 +1337,8 @@ static void vcap_api_encode_rule_test(struct kunit *test) u32 port_mask_rng_mask = 0x0f; u32 igr_port_mask_value = 0xffabcd01; u32 igr_port_mask_mask = ~0; - /* counter is written as the last operation */ - u32 expwriteaddr[] = {792, 793, 794, 795, 796, 797, 792}; + /* counter is written as the first operation */ + u32 expwriteaddr[] = {792, 792, 793, 794, 795, 796, 797}; int idx; vcap_test_api_init(&is2_admin);