From patchwork Fri Jan 13 08:14: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: 43063 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp148001wrt; Fri, 13 Jan 2023 00:17:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXszmVob4BxkCwWk+7K+PSzaIpMvGcw5iDBd4eIgE2BJGUO+/sEjEe+q0kvlfgXkQHhx4sjc X-Received: by 2002:a05:6a20:d68f:b0:af:b909:2b34 with SMTP id it15-20020a056a20d68f00b000afb9092b34mr99282344pzb.41.1673597830372; Fri, 13 Jan 2023 00:17:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673597830; cv=none; d=google.com; s=arc-20160816; b=Y0B6vmzfJRCTiogjzcTp7sI7u46w3zSHzEUH6bDHVsEPE7kPIz1qua5U3jrkcDQcBd oBAN5KOz8Rz8no7h6V8vOXxfxu11pBXbq9Jck5ZpGEXBh1HzVPnrjws+LcnkSOqXETyd uV/d1HneI45YClsMQqrs10qqihhLiyqifl3zoMNOTG0+LGdmbsYa88z9AbViir9W94QJ ktF60Ef+eayiIOUvMtBETj2bO4YbYtueHdhAqglS3LD3MP/9RDD3Zr2JU2PuuKUwEl/F Lf6QR4qhkQYB0xeLlszrxh9bzR3cKDyOYVxQD2oA8dBKbMjJ8nhMfVDYDQSyl9s8kOun 1bIQ== 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=kgSaQqXfdgfI8NcVOvewiTZWM9oIMRgDnISHu0f64kk=; b=cxv/uh2xE1/245vxhfD8sw4RA1K3q76u/bUFYdsPOf2OZ5R+8k1ExnSKNaKLe3Go5d KCQKgDgDph0xzureh5IHDFt15IE4M7hfFPwWTkRdEugdtLtL0XWlz6AX9Ircvc89W/zg fmz3GmU80ep/eDZb/vsSqBvsFXWumGZw+M+xF7Cq1aONs88z3Txrw2yECU7XCk1Np+mA bOr05pbyU51D55pPpc0dUEbzNRFj6QOEhe5Ftj1cmGiy4pF29g5dwCE7WI1dq3YGKRjj epFBRQtNtulHTLiDBGTqnrlJtt91SCi5rBP9+TaCv/7L6Qgwvtfue2fDndhKHEQY7R/T AQEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="hY/a23M5"; 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 h23-20020a63e157000000b00470096ba718si20581214pgk.200.2023.01.13.00.16.57; Fri, 13 Jan 2023 00:17:10 -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="hY/a23M5"; 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 S239759AbjAMIQ3 (ORCPT + 99 others); Fri, 13 Jan 2023 03:16:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234855AbjAMIPs (ORCPT ); Fri, 13 Jan 2023 03:15:48 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A57D4166D; Fri, 13 Jan 2023 00:14:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673597687; x=1705133687; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TlE8JkFNzlYrrSINYDLNdYw3yFo8m325dlUNlSj6BFw=; b=hY/a23M56pruZB7eBW73ccpafgN6H+647KxxoeKjdicPUc9ImvwZtfb3 YjhIfj3B77/Cx+N6iB2cJ4LheLxhqziaJKDDjvzhQKQVNVOpZ4//7Ymau 5LtuJzOBnyywwJ+as2zwRwSYejDMUR9W10Xa/P0ZdWNXqM+x5pkCAt1Av pvkyZx/ZKGnQacse6Fwd48FdtRrzZ1pYUs5DMGLB5sJe718WVhUGMLmMC W0F3CwLoPBDz04pFzEJ199LIUvkmUmDz2dipg60+75OUSb/WMWUNssSfF HfdqQnYrE+VU0xwhLsO5vl1ycK43NXIB95AcjMINM81Usbd0ClCtVDaMR Q==; X-IronPort-AV: E=Sophos;i="5.97,213,1669100400"; d="scan'208";a="192080742" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 13 Jan 2023 01:14:46 -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; Fri, 13 Jan 2023 01:14:41 -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; Fri, 13 Jan 2023 01:14:37 -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 v3 2/8] net: microchip: sparx5: Reset VCAP counter for new rules Date: Fri, 13 Jan 2023 09:14:18 +0100 Message-ID: <20230113081424.3505035-3-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113081424.3505035-1-steen.hegelund@microchip.com> References: <20230113081424.3505035-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?1754894518396312750?= X-GMAIL-MSGID: =?utf-8?q?1754894518396312750?= When a rule counter is external to the VCAP such as the Sparx5 IS2 counters are, then this counter must be reset when a new rule is created. 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, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c index b9b6432f4094..8bbbd1b0b552 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c @@ -1808,6 +1808,7 @@ int vcap_add_rule(struct vcap_rule *rule) { struct vcap_rule_internal *ri = to_intrule(rule); struct vcap_rule_move move = {0}; + struct vcap_counter ctr = {0}; int ret; ret = vcap_api_check(ri->vctrl); @@ -1831,8 +1832,12 @@ int vcap_add_rule(struct vcap_rule *rule) } ret = vcap_write_rule(ri); - if (ret) + if (ret) { 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 76a31215ebfb..944de5cb9114 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c @@ -1343,8 +1343,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 not written yet, so it is not in expwriteaddr */ - u32 expwriteaddr[] = {792, 793, 794, 795, 796, 797, 0}; + /* counter is written as the last operation */ + u32 expwriteaddr[] = {792, 793, 794, 795, 796, 797, 792}; int idx; vcap_test_api_init(&is2_admin);