From patchwork Thu Jan 5 08:13:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 39363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp185029wrt; Thu, 5 Jan 2023 00:15:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXt5cXXTwTYXHBveLyVbm7I3FbLPFHtMdFuuBzu5mL72dy8aj6EDLeTjtjG06f9o/ENF1HyM X-Received: by 2002:a05:6402:380d:b0:47e:eaae:9a5b with SMTP id es13-20020a056402380d00b0047eeaae9a5bmr42199099edb.42.1672906546651; Thu, 05 Jan 2023 00:15:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672906546; cv=none; d=google.com; s=arc-20160816; b=VNs5hN077RAwrwUPOmjIV6RgMsPbu7hPd1o9SDBjOiJrcsxyAecOFTbKJfnSBPlBJi 1aplR4YrfYerKplHi+ZruwbPoOjbygDf+QqbRp9ej1EA9r6Aw0m03ScGZdgGz+gB4mkl rnbv+UoeJT10I+5kpbqcqTIHcUcc6jzXiB95W1VMZi0hq/X/4L6pdY7Y43uSneqhWueR ZesUzxM/x/sQO1ZFtI5I6h3JV6Ix1xWqyEEY8nMC+bmlFVlxaS1bcOqobjC+b1tmF85G gL/NFbvX08eMeNBLCUVKI/r5DNAkqeNiiyP2OOncOAmc5NfI6czsxYovbXU8Ycv7Ooin 5gYA== 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=wshlybZg+KwwjijoGfYln5ePAi2eRn5oC9A/0lQ7MgB/FLOleXEF3PfZ6Z1OfA5lXm eygDHngvFxZ7i4mpwtVaJb/WbequRc0RCEdZj6zSuT1edYT2k7C/UXxKhNVSots6zTh9 77FtSDOWItxs9875DxHDUvmmvuL4Eqr/AbVCDkAiHDitdLv/x+ostlvo+f7Cntszge4w IkcBG8wUaqorHo2A2YIc2b16g3ibUS3EmLbpNjAGZYnokgl/zOyB4ZiYCh41GlEm3v6N FVG2xE2tQNGgFuFFVqPU91km8YwGYotbNgs9EbTPPor+1bNnVy0MtSeswYIlRBD14bhM 4ZkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=fHQtNJN+; 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 b15-20020a056402350f00b0046af9fdf3f5si35021361edd.282.2023.01.05.00.15.23; Thu, 05 Jan 2023 00:15:46 -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=fHQtNJN+; 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 S231560AbjAEIN5 (ORCPT + 99 others); Thu, 5 Jan 2023 03:13:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231532AbjAEINy (ORCPT ); Thu, 5 Jan 2023 03:13:54 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A72385830B; Thu, 5 Jan 2023 00:13:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1672906433; x=1704442433; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jn6Qh4EKzF9+AlWQ2VgROJSkdvNeDO0+z00VKMoS2gg=; b=fHQtNJN+Yae5vXnU+22lV6NcjVPAR5cvnfe1QYm7c5KDg1WB0xlhnf9x 0TIwpqYbPiIICVx/u7A6gjytlYF84XjroBBQrtkcRWf6p2mYd2yVjcfH/ 8A+1J2rXp4g1R7+10nhoZKJCdjGNS2UMfi9P95LUBoocjCjn5dnMnzDSg 0zCLEyH7SeADRbv8W4A6nxi3RDHmdkIZkgJaC/nVI4h9H0PjLqHOeUK+/ v0/+1P64fArv0qzTHjTC/a6aek+M9j3Wh672PxvVJfr0+2koCXInF6YtJ 2jzvb5rlKgqHW0ifUp2ZRBpUiAZtXKNv1eQmKmtZif5x0CVG+PhBxP0Md w==; X-IronPort-AV: E=Sophos;i="5.96,302,1665471600"; d="scan'208";a="190835952" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 05 Jan 2023 01:13:52 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 5 Jan 2023 01:13:49 -0700 Received: from den-dk-m31857.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 5 Jan 2023 01:13:46 -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-next 2/8] net: microchip: sparx5: Reset VCAP counter for new rules Date: Thu, 5 Jan 2023 09:13:29 +0100 Message-ID: <20230105081335.1261636-3-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105081335.1261636-1-steen.hegelund@microchip.com> References: <20230105081335.1261636-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?1754169654801825871?= X-GMAIL-MSGID: =?utf-8?q?1754169654801825871?= 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);