From nobody Sun Sep 14 03:53:21 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FD51C54EAA for ; Fri, 27 Jan 2023 13:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233454AbjA0NLI (ORCPT ); Fri, 27 Jan 2023 08:11:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234650AbjA0NKs (ORCPT ); Fri, 27 Jan 2023 08:10:48 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1314C80FAC; Fri, 27 Jan 2023 05:09:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674824992; x=1706360992; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rdMyTPDncd3MNKOu21c8aMfAJ7isk97ZKoRLQsOkhN0=; b=hsIigfLkq0hlClRdc/LzLvp45WmuTObc0favZteqwTgUohp2LJmA6FEV oW3j6ITgtliS7HLTBcx4tLWykzcBxM8pRQTBlfCOFZd7UhMpjIByaLTXe muUNUsTb3y6QId7ygEkGZfW8dToXemu9zcf5qxqUoIUmCsE9Ttzf8Jdnr UuuQXHdsb5inWiFwpwmhXx5vIPrx3es6LVlW0FFWbrRgyY1y5L9ToEl8g Ka1rA0X+E7z/jzOvjs2hJa6FsumtKa89oBo6ZwiGJwo/I330IKd4G4/AX Khg+cg7Q3xKFKy2mIKqBjx3v2quJxUTYtHrm29ZSna4UthaVRq0dW7qx6 w==; X-IronPort-AV: E=Sophos;i="5.97,251,1669100400"; d="scan'208";a="134303314" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 27 Jan 2023 06:09:27 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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; Fri, 27 Jan 2023 06:09:27 -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, 27 Jan 2023 06:09:22 -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 8/8] net: microchip: sparx5: Add KUNIT tests for enabling/disabling chains Date: Fri, 27 Jan 2023 14:08:30 +0100 Message-ID: <20230127130830.1481526-9-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230127130830.1481526-1-steen.hegelund@microchip.com> References: <20230127130830.1481526-1-steen.hegelund@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This enhances the KUNIT test of the VCAP API with tests of the chaining functionality. Signed-off-by: Steen Hegelund --- .../ethernet/microchip/vcap/vcap_api_kunit.c | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c b/drivers= /net/ethernet/microchip/vcap/vcap_api_kunit.c index a31cd08e3752..b2753aac8ad2 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c @@ -2145,6 +2145,71 @@ static void vcap_api_filter_keylist_test(struct kuni= t *test) KUNIT_EXPECT_EQ(test, 26, idx); } =20 +static void vcap_api_rule_chain_path_test(struct kunit *test) +{ + struct vcap_admin admin1 =3D { + .vtype =3D VCAP_TYPE_IS0, + .vinst =3D 0, + .first_cid =3D 1000000, + .last_cid =3D 1199999, + .lookups =3D 6, + .lookups_per_instance =3D 2, + }; + struct vcap_enabled_port eport3 =3D { + .ndev =3D &test_netdev, + .cookie =3D 0x100, + .src_cid =3D 0, + .dst_cid =3D 1000000, + }; + struct vcap_enabled_port eport2 =3D { + .ndev =3D &test_netdev, + .cookie =3D 0x200, + .src_cid =3D 1000000, + .dst_cid =3D 1100000, + }; + struct vcap_enabled_port eport1 =3D { + .ndev =3D &test_netdev, + .cookie =3D 0x300, + .src_cid =3D 1100000, + .dst_cid =3D 8000000, + }; + bool ret; + int chain; + + vcap_test_api_init(&admin1); + list_add_tail(&eport1.list, &admin1.enabled); + list_add_tail(&eport2.list, &admin1.enabled); + list_add_tail(&eport3.list, &admin1.enabled); + + ret =3D vcap_path_exist(&test_vctrl, &test_netdev, 1000000); + KUNIT_EXPECT_EQ(test, true, ret); + + ret =3D vcap_path_exist(&test_vctrl, &test_netdev, 1100000); + KUNIT_EXPECT_EQ(test, true, ret); + + ret =3D vcap_path_exist(&test_vctrl, &test_netdev, 1200000); + KUNIT_EXPECT_EQ(test, false, ret); + + chain =3D vcap_get_next_chain(&test_vctrl, &test_netdev, 0); + KUNIT_EXPECT_EQ(test, 1000000, chain); + + chain =3D vcap_get_next_chain(&test_vctrl, &test_netdev, 1000000); + KUNIT_EXPECT_EQ(test, 1100000, chain); + + chain =3D vcap_get_next_chain(&test_vctrl, &test_netdev, 1100000); + KUNIT_EXPECT_EQ(test, 8000000, chain); +} + +static struct kunit_case vcap_api_rule_enable_test_cases[] =3D { + KUNIT_CASE(vcap_api_rule_chain_path_test), + {} +}; + +static struct kunit_suite vcap_api_rule_enable_test_suite =3D { + .name =3D "VCAP_API_Rule_Enable_Testsuite", + .test_cases =3D vcap_api_rule_enable_test_cases, +}; + static struct kunit_suite vcap_api_rule_remove_test_suite =3D { .name =3D "VCAP_API_Rule_Remove_Testsuite", .test_cases =3D vcap_api_rule_remove_test_cases, @@ -2235,6 +2300,7 @@ static struct kunit_suite vcap_api_encoding_test_suit= e =3D { .test_cases =3D vcap_api_encoding_test_cases, }; =20 +kunit_test_suite(vcap_api_rule_enable_test_suite); kunit_test_suite(vcap_api_rule_remove_test_suite); kunit_test_suite(vcap_api_rule_insert_test_suite); kunit_test_suite(vcap_api_rule_counter_test_suite); --=20 2.39.1