From patchwork Fri Jan 6 08:53:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 40007 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp718986wrt; Fri, 6 Jan 2023 00:55:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXvvHQhBS36vjma+7PQMFWVXz5JkBT85AlcXgGqvfV94kuqZ67ytk5fk3pvn9N8kc2rzc9/U X-Received: by 2002:a05:6402:916:b0:461:7d2:c9fc with SMTP id g22-20020a056402091600b0046107d2c9fcmr48835153edz.26.1672995333567; Fri, 06 Jan 2023 00:55:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672995333; cv=none; d=google.com; s=arc-20160816; b=NwpyPolEbkV/YYbXEACqXbrPoOCrL4PTeG4nvFu6As388d84efSlb3/RsjI5ZrD/uJ yIePFI4CxCzw5rEqrw2zm5vPm4ElXk+AeW3ViZEJKGZLZeG/Zpce3jkXUT7q38BEahl9 ljmfvnFj6oK5Ar/p2ZY3NUtxXccFxrLfaKjTPkNPEFSTS2ZeTed3xWnvZarvZV/d7aEw +WyhQGFYWo1X+e247I8uxofBNsWV2pzP9y1hmcfQLKrNiCrZgLGexI/HUlYNtE+nrGhF h3tc+YmAIwzIiHb7S8DrEUE8FP1t4YFqNgVJnekVuQgeFrFQ9Wn2WA2RUrjiggthRXBp zE/g== 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=G93tz8MvvC1hGPT80i0EwflNJbYhgYQvTsABjHpxYV0QRCP38yNwZqbB/vy5twTxgl PdloaZiE+jfHL9J+ZqcAwmklzp5q2G6M3N8ZQ01kXTnIFEtfaZsqqvUkS6w5/R+iGsX3 jZLK0QQqGV/1h8gqQucZJIAxGrjoLkc862uOW9JRrQ2wIwgr6VUiZP4QvVWDd8H6AseX w4kgmOEIul/swgJ6JHUxoI9IBZq2Tos4bLViIq8x+yG9dw14yTPM7R6++mQFWvdYWV6N v/a2HyIXay05VZyr1bXBJTXTTIlm1L9FfEVD6+B9/qV889E5H3mpiTMtLQPC+vge9xnN bvmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=CCUkmILe; 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 o15-20020aa7d3cf000000b0048461eff750si817733edr.563.2023.01.06.00.55.09; Fri, 06 Jan 2023 00:55:33 -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=CCUkmILe; 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 S232228AbjAFIxx (ORCPT + 99 others); Fri, 6 Jan 2023 03:53:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231810AbjAFIxj (ORCPT ); Fri, 6 Jan 2023 03:53:39 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9CCA669A5; Fri, 6 Jan 2023 00:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1672995218; x=1704531218; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TlE8JkFNzlYrrSINYDLNdYw3yFo8m325dlUNlSj6BFw=; b=CCUkmILeSLxyywnitSO/BzVQWUVpXMDw2NLqihB0jDlvJnKW+Sp6/OLJ Ev5nj0T3S7krmJRl16ry+NpUfp6XOSeqBaYEurJH2rr6IxtdHIOWKkFga s9n+Z6aiBsELabVOsVR95f94nwZRGKsT+RuFeL3vy7UvusjkCJ1849uXV DPP+XjlIqEGyOV0/YNTaLO6YKTZN7qUU8qQ1Rdx1f28IlY++/zLMR2bZB f/DQJLziNtAip70sy6/cDXCeG0oYJRKuBUdByMRhm+sx9qpuW5TEB/5bN 4ICXlVCKQo+lRJovrP6BIWiPuMpbfBaW+Pu3CzAb4CYX9A8soZize9a4y g==; X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="194562841" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 06 Jan 2023 01:53:38 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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; Fri, 6 Jan 2023 01:53:35 -0700 Received: from den-dk-m31857.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 6 Jan 2023 01:53:32 -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 2/8] net: microchip: sparx5: Reset VCAP counter for new rules Date: Fri, 6 Jan 2023 09:53:11 +0100 Message-ID: <20230106085317.1720282-3-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230106085317.1720282-1-steen.hegelund@microchip.com> References: <20230106085317.1720282-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?1754262754752193793?= X-GMAIL-MSGID: =?utf-8?q?1754262754752193793?= 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);