From patchwork Mon Feb 13 09:24:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 56111 Return-Path: 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 + 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 ); 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 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 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 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: 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?= The rule counter must be cleared when creating a new rule, even if the VCAP lookup is currently disabled. Signed-off-by: Steen Hegelund --- 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}; int idx; vcap_test_api_init(&is2_admin);