From patchwork Sat Jan 14 13:42:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 43762 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp289038wrn; Sat, 14 Jan 2023 05:45:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXt+Disv91dJQx6mrRgMO4Mpe7k1KXaSDIwQ4BOO0bfM39zMsOJfNngnM4s15U8urjsp/65Z X-Received: by 2002:a17:906:9c8b:b0:84d:ed5:a406 with SMTP id fj11-20020a1709069c8b00b0084d0ed5a406mr6594482ejc.14.1673703907867; Sat, 14 Jan 2023 05:45:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673703907; cv=none; d=google.com; s=arc-20160816; b=O2212SqOMFe/Me2Fsgc4ZlopSQr0PetHYmc75zRlMMPRy0p39+vlXuo52u5Ubj0Mbj qaQrKYMZ2NtOcy6ym6xxfI/ehnK+ZZHEiV9hndPpLO6rd3P3dg808+oeWnP/FaNkZ5Vf eTJeh9Vulza0axrM7oDiYBHsdkELuO+jtCYfeoAQXS/880dD5c7z0zBGsm3PM88621a/ e6ij4fPW8R6BOIqne2imbuKmfzZ0ZGiQDaSZdACd/W4Gd9MHwMiuh7QZiPK5xgL0nj7M ltg/F3uSYD89S9ao0b99BrvWZf1fRfEgGrhNa67ucvXySJcN1lEqYDkoY0MmLTKFqMxc iOAA== 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=Xl0AjuQYrgk+2li6IeckEZ9on9Rcpy9lymklhcSlKLxaqwbi4Sng3qJsoQD/OQ0H6P e6F5hzrfQ2e36Ipx9HUunQGI4OjLXQThQTpxV9QMk9DU4SSJsnkn7O+DIAxfPK15/del ZyMCmCbfKyhgvUPYEhC+He8jbeoGff/Aymbbqne7+0Krn3wPja32RZn7iffhc5iALc8P XkLiXCexGMH+Lmy0aX8qYRB0e4GhIFh6xMFS7K3/8aXHzFWcyjFo06UAEAYxRz9md66J ALB+yupbP8aXZ29iqNmya0wLqn4Yi8ZfoaOU9B3VPVH0Id1IydL0q0LDFz6qp4KLiuoq TniQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=Ub7qeUor; 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 xe6-20020a170907318600b0084cbde35b2fsi25296384ejb.465.2023.01.14.05.44.44; Sat, 14 Jan 2023 05:45:07 -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=Ub7qeUor; 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 S230094AbjANNnK (ORCPT + 99 others); Sat, 14 Jan 2023 08:43:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbjANNm7 (ORCPT ); Sat, 14 Jan 2023 08:42:59 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D458A6EAF; Sat, 14 Jan 2023 05:42:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673703779; x=1705239779; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TlE8JkFNzlYrrSINYDLNdYw3yFo8m325dlUNlSj6BFw=; b=Ub7qeUor1aULy1jv1Ivp7xivly/WcjRa2GCGfkcfc/CNktBq6EonrbgV PN+Tm2PIGxgGTcV8L17k1fFO7SJMyFkFm4wJS8P1UWL99iObuz6oZrp57 lg9df1cuGNNnStwawQypBc1yyStYjmBmKfEQCNv1jVyeEf/Vlxu5x3QYN 2osWcJ4SdIVZFOAU1WkphvoFKV2UzyMxJS55CgcdgE7vpVxsOI/IYp7VP teXw4QMfoZK+i9YOljPhvJDIXUTKJXYvzCegNNLnUH8VFnLxgcbdmC0Um 6a4g2SFWojdyy7vbCPOxeHSYEsqlitDfKii89EwVkO//cWjIl3nO2i5C/ Q==; X-IronPort-AV: E=Sophos;i="5.97,216,1669100400"; d="scan'208";a="192264073" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Jan 2023 06:42:59 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Sat, 14 Jan 2023 06:42:57 -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; Sat, 14 Jan 2023 06:42:54 -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 v4 2/8] net: microchip: sparx5: Reset VCAP counter for new rules Date: Sat, 14 Jan 2023 14:42:36 +0100 Message-ID: <20230114134242.3737446-3-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230114134242.3737446-1-steen.hegelund@microchip.com> References: <20230114134242.3737446-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?1755005748884962030?= X-GMAIL-MSGID: =?utf-8?q?1755005748884962030?= 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);