From patchwork Wed Dec 21 13:25:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 35364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3522799wrn; Wed, 21 Dec 2022 05:30:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXsgDyHwd3uPZ53NDpmD382r29mg3/LGWQIk0O/AhlHnrKUF0Y3fGM5gL/KlJjo2sPr6MxSY X-Received: by 2002:a17:90a:71c2:b0:219:d84:4446 with SMTP id m2-20020a17090a71c200b002190d844446mr2136831pjs.26.1671629416954; Wed, 21 Dec 2022 05:30:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671629416; cv=none; d=google.com; s=arc-20160816; b=geRmkYLHbaZcK4iCCNXyNj8IX5dEvrRu6+ilPM9rPg55VY88uAJeXrBFvy/Ecv9xfl ll4B58U5dyNfO8Wi5S/mYqXh6idrXfqxNseSXfqlWr+PZBr4rdrq1b91BHS4wKxJGXny H4Mzlsu4FuB6wAt7/dMqxvSKloomUT+DKkUQ8ghNl3hcL3N3t+I8WDhvp1YYQpcoH5rE oJ1INowPkJ+nlHJb+M/T6c3ziAS3ogn+eY/t+Lp6SQqnIAqniZXhgm80HCsA2/YinhjR 5w5NpEmyyFKg4cIHD0Wjw7phRUI9phlgE4ZuDcFjBwwm5Pf02KV+xejENaHwLBM/lg8d KBcw== 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=xXyFu34+nWdKqiI+GOMha4BKnM2jSXEvEWZDhivJ1YM=; b=eVGl+/uZfX6nEv655oSqaAhPQTg62LCGJJ6knZicugwkpWDbgPaJRCOIForExLKj0E sbWPttxaH8Xx/Dvzp8+L/vHXmFZ5aDEjFqXmAvncieQF8l9WTZKkqW2P6SkpJHBhJdR/ jib0/YiT8cZajCd2hWppsnATWPR2HFbpcjGmwEZVBl05ORDrCEbk1zZSXDurrCbc7T5O jU8XrLoHr2ejw0yT05IWEB+oN10SciGWwHFi+MNdM48/nE3ZtahLzTEJLqpWt3EF0q1R XxnrhCsuT/U0WPsp9+5fGUbRbseIpFz3Wk4sC4/27lxBL+FpzztTP6HTnLacrpL4hCEq 9BTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=Z4F+XCOg; 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 g14-20020a17090a578e00b002233101b2aesi1641045pji.53.2022.12.21.05.30.04; Wed, 21 Dec 2022 05:30:16 -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=Z4F+XCOg; 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 S234218AbiLUNZp (ORCPT + 99 others); Wed, 21 Dec 2022 08:25:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233998AbiLUNZg (ORCPT ); Wed, 21 Dec 2022 08:25:36 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CFBC220D6; Wed, 21 Dec 2022 05:25:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1671629136; x=1703165136; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jn6Qh4EKzF9+AlWQ2VgROJSkdvNeDO0+z00VKMoS2gg=; b=Z4F+XCOg5/4CNT8ANNQEWq/M50xSt2oE0HokNum4i5APdkCnJzUCbjco 3cu2G8wpmdQ/MvfoYBO1371adDmL6MvWR20Bbs6GWzdacgj/CifEWaAg0 CRRDagzMRQlhR9o5UGMjlno7f2BBzNVrjKlzifL1R6tM6OX8mOrB1/88Y 8Hz2KDdVyMeMoORk/R1s630hDJdguPn55STMd4syqb871j6989KRtiLmJ fnqVGbhOL8TW3lBQPcAllDdVVS8FQl0WCRmjh3DDCyaRRZxsSF0AeC5NM GMJMXKX5TwmIUG7++g6K20wIDCPaPcVnrZvVeCNcgwFHDd3vGFf752/Iv Q==; X-IronPort-AV: E=Sophos;i="5.96,262,1665471600"; d="scan'208";a="193965097" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 21 Dec 2022 06:25:35 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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; Wed, 21 Dec 2022 06:25:34 -0700 Received: from den-dk-m31857.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Wed, 21 Dec 2022 06:25:31 -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 Subject: [PATCH net 2/8] net: microchip: sparx5: Reset VCAP counter for new rules Date: Wed, 21 Dec 2022 14:25:11 +0100 Message-ID: <20221221132517.2699698-3-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221221132517.2699698-1-steen.hegelund@microchip.com> References: <20221221132517.2699698-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?1752830487433408776?= X-GMAIL-MSGID: =?utf-8?q?1752830487433408776?= 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 | 3 +++ drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c index b9b6432f4094..67e0a3d9103a 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); @@ -1833,6 +1834,8 @@ int vcap_add_rule(struct vcap_rule *rule) ret = vcap_write_rule(ri); if (ret) pr_err("%s:%d: rule write error: %d\n", __func__, __LINE__, ret); + /* 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);