From patchwork Tue Feb 14 10:40:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 56846 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2893093wrn; Tue, 14 Feb 2023 02:44:54 -0800 (PST) X-Google-Smtp-Source: AK7set+eTPWWJuifKGkKgeehjwn4Qs9zbIs5whu4SutJF9CGtwSDy1xhgwHVokg8qt+pJjdXkqJD X-Received: by 2002:a17:902:d04b:b0:19a:a8c5:2493 with SMTP id l11-20020a170902d04b00b0019aa8c52493mr1598104pll.67.1676371493711; Tue, 14 Feb 2023 02:44:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676371493; cv=none; d=google.com; s=arc-20160816; b=AjTsKTRr3jjwCnO5ckeOEQDMowUhWvYvI5knrxEc7QNoRHgy2Ed4bwAloWZ+w8z8tH X+E3Ocp1ZYPDg0pszL7hBVPUa0vM7KBOowjgL4+3hINX5RPgAMD2BbP8FUyw60rsyB+L Svr157je5FWDN9lOQMNtHY5NiYc1Cm68aYuZPx4c1NjgP2q0Ig0vAagEu3bVMCDKE4IA 8K3BEXyeZ7VDiawnVWq/gWB90TKDVdIZiy5zBsE1JNgYezBImNkNqGo1VOsZQlRU6aqW hIflRv6gkaEMzc9xYDej0RXz+WKZMYiowZNnrCavWwvXY7oSUy/URjkw0XATWLYv5Y/m mZRQ== 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=b161hb6RzCbRXS04TkzvNVTNUogQ09mU5pa9iTok1Lc=; b=uJ6/CGzKf/LSqv4FvFkbxn5f+q6E7IboIQxEjw+X9hc1O9k0+9vY5O6w5OiBONa3SE 8Ag4w136JQUzTlXO/KHq/holaHz80smmQ88T5KJvnzcCh24k8ZU0Oac72ciR9gdMo1el so04zl7ZWYjF7cgfyoSrNEDLL3F/mJqrq7lRJ5duS3BgvHtMR7WRLrqoh54e2+a+IZX5 EpNa0GViWexpUNk5riCpuIjdlApYcLN5uqJLtjW6fyvUgrx/yi4WwHN0erzEaYaOG32b fuMULz2kwINNgsLjFT7LYFgVSTYRfAHtu58SI/1DcfYs0bmJXuhClMIJQTn2uUMQ5RJc oRoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=nT3oj+LN; 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 jn14-20020a170903050e00b0016efde92292si13264960plb.255.2023.02.14.02.44.41; Tue, 14 Feb 2023 02:44:53 -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=nT3oj+LN; 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 S232124AbjBNKmC (ORCPT + 99 others); Tue, 14 Feb 2023 05:42:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231710AbjBNKlc (ORCPT ); Tue, 14 Feb 2023 05:41:32 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DE3D25E35; Tue, 14 Feb 2023 02:41:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676371268; x=1707907268; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3fgN4RfdGtLWUA4LDkD/x8yRlw2s9yAn3AcVZjEKbZQ=; b=nT3oj+LND5MIgcC9q+RnE2s15We+lI+3KM7fLZi5PgdDGc9gl+0E3WKL xQ7h7sV2NI7b333j8NQWUQ+ppqynupI8dZcepwkNMcBJc9hnuVxYbzzel cdDcsZ4nYtzDXvJE8zssufADxxXcsAbrvu7qRDWuH8mv5aMiQShvSZbov 7suJkCKVjHF1IWYjJEdiEW/nNc5XbzO/226PtQ9oG9pzbazPinbWVlmuz 6RaCIFKMKRoKwRhnGhMZxgfSLmDDzNRacrtB60HufuMR/GdlZhD38oKV3 lnqdmC8LvwndExC99/sn2MaOCmUSMPASAH7DHeY+3HVi81cWFD0RS9Zqb A==; X-IronPort-AV: E=Sophos;i="5.97,296,1669100400"; d="scan'208";a="200856767" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2023 03:41:04 -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; Tue, 14 Feb 2023 03:41:03 -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:40:59 -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 02/10] net: microchip: sparx5: Clear rule counter even if lookup is disabled Date: Tue, 14 Feb 2023 11:40:41 +0100 Message-ID: <20230214104049.1553059-3-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-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?1757802915409774699?= X-GMAIL-MSGID: =?utf-8?q?1757802915409774699?= The rule counter must be cleared when creating a new rule, even if the VCAP lookup is currently disabled. This ensures that rules located in VCAPs that use external counters (such as Sparx5 IS2 and ES0) will have their counter reset even if the VCAP lookup is not enabled at the moment. Signed-off-by: Steen Hegelund Fixes: 95fa74148daa ("net: microchip: sparx5: Reset VCAP counter for new rules") --- 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);