From patchwork Tue Jan 24 10:45:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 13113782 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C0370C25B4E for ; Tue, 24 Jan 2023 10:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=X20GCRfeQw2aKa3yaB0aHQ0o65KXPU0NnFlwKChqP4Y=; b=MzifkyZd4IfcrH JYpuI8Ow0/uUyjHQb/FdlQFX1WHNe76LeOFxTE8EvX+nIVuh04yIwg1EoLe8F4HfbVQAa3Z010yyX TnRTbK47DHzoqT68HWe/Bq0JHEYbHVJKylBTjtE3aQiyeg5PXcsYgZTEBM5VDm8XRqunHvK157RzU Mrywkxo2SPmhs2qye4ul8FSXwvrnzjtc8MvV9iJiVlcxobVW29/domDoYffWF3b3Jcl+UM1Xn920l 8HA07EgSiaMmPPw5lyn1tQZKxYWqvTIBgpYDJHXPeL77dPpawRXddwoDFkGmtjBiQNvqN1QZMamy0 raxBuI+Xxa3dgd29Tt2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKGoS-003DV3-9u; Tue, 24 Jan 2023 10:46:00 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKGo4-003DGq-4V for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 10:45:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674557137; x=1706093137; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NMT1v23LlceJBcDri8vzubqJYcUPHF9idJ28GFyW5mI=; b=x6Uynjn1pBynBkzGlqanve3hiaW8WGVg3xLOTdmyhTMN6fOT+XG17j4D 5syxx0MV2W8s5BeO16LXjfWKXWUL6YBG2rNzsAv0sNyG3z3EZCeBJYUK7 tY0tv295fBhtwpzLq/hPC9CGtvgYYwf43D3JdGemN4q//9S75pl2l1MSS S/NHgkEmCckQLQC44A1JRFd0VJrdSXctDRFqJ4mmIU2KbGlC7Qt7Qmkjw KCSsna+zq0R31yffX1MfgHRNEbwmN4vGlpI9ARHedyA5qaGnv/UIizCld KFNEw0jBt2UnsqMT/WjemU/cwFGEWP/jzHqKLVW1YUdBNTimYLfkNDRAD w==; X-IronPort-AV: E=Sophos;i="5.97,242,1669100400"; d="scan'208";a="193598311" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Jan 2023 03:45:36 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Tue, 24 Jan 2023 03:45:33 -0700 Received: from den-dk-m31857.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 24 Jan 2023 03:45:29 -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 4/8] net: microchip: sparx5: Add TC support for IS0 VCAP Date: Tue, 24 Jan 2023 11:45:07 +0100 Message-ID: <20230124104511.293938-5-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124104511.293938-1-steen.hegelund@microchip.com> References: <20230124104511.293938-1-steen.hegelund@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_024536_319440_C163A9FA X-CRM114-Status: GOOD ( 19.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This enables the TC command to use the Sparx5 IS0 VCAP Signed-off-by: Steen Hegelund --- .../microchip/sparx5/sparx5_tc_flower.c | 54 +++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c index affaa1656710..72bc2733b662 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c @@ -30,6 +30,7 @@ struct sparx5_tc_flower_parse_usage { struct flow_cls_offload *fco; struct flow_rule *frule; struct vcap_rule *vrule; + struct vcap_admin *admin; u16 l3_proto; u8 l4_proto; unsigned int used_keys; @@ -304,6 +305,13 @@ sparx5_tc_flower_handler_basic_usage(struct sparx5_tc_flower_parse_usage *st) VCAP_BIT_0); if (err) goto out; + if (st->admin->vtype == VCAP_TYPE_IS0) { + err = vcap_rule_add_key_bit(st->vrule, + VCAP_KF_TCP_UDP_IS, + VCAP_BIT_1); + if (err) + goto out; + } } else { err = vcap_rule_add_key_u32(st->vrule, VCAP_KF_L3_IP_PROTO, @@ -542,6 +550,7 @@ static int sparx5_tc_use_dissectors(struct flow_cls_offload *fco, .fco = fco, .vrule = vrule, .l3_proto = ETH_P_ALL, + .admin = admin, }; int idx, err = 0; @@ -623,18 +632,21 @@ static int sparx5_tc_flower_action_check(struct vcap_control *vctrl, return 0; } -/* Add a rule counter action - only IS2 is considered for now */ +/* Add a rule counter action */ static int sparx5_tc_add_rule_counter(struct vcap_admin *admin, struct vcap_rule *vrule) { int err; - err = vcap_rule_mod_action_u32(vrule, VCAP_AF_CNT_ID, vrule->id); - if (err) - return err; + if (admin->vtype == VCAP_TYPE_IS2) { + err = vcap_rule_mod_action_u32(vrule, VCAP_AF_CNT_ID, + vrule->id); + if (err) + return err; + vcap_rule_set_counter_id(vrule, vrule->id); + } - vcap_rule_set_counter_id(vrule, vrule->id); - return err; + return 0; } /* Collect all port keysets and apply the first of them, possibly wildcarded */ @@ -815,6 +827,29 @@ static int sparx5_tc_add_remaining_rules(struct vcap_control *vctrl, return err; } +/* Add the actionset that is the default for the VCAP type */ +static int sparx5_tc_set_actionset(struct vcap_admin *admin, + struct vcap_rule *vrule) +{ + enum vcap_actionfield_set aset; + int err = 0; + + switch (admin->vtype) { + case VCAP_TYPE_IS0: + aset = VCAP_AFS_CLASSIFICATION; + break; + case VCAP_TYPE_IS2: + aset = VCAP_AFS_BASE_TYPE; + break; + default: + return -EINVAL; + } + /* Do not overwrite any current actionset */ + if (vrule->actionset == VCAP_AFS_NO_VALUE) + err = vcap_set_rule_set_actionset(vrule, aset); + return err; +} + static int sparx5_tc_flower_replace(struct net_device *ndev, struct flow_cls_offload *fco, struct vcap_admin *admin) @@ -874,13 +909,14 @@ static int sparx5_tc_flower_replace(struct net_device *ndev, goto out; break; case FLOW_ACTION_ACCEPT: - /* For now the actionset is hardcoded */ - err = vcap_set_rule_set_actionset(vrule, - VCAP_AFS_BASE_TYPE); + err = sparx5_tc_set_actionset(admin, vrule); if (err) goto out; break; case FLOW_ACTION_GOTO: + err = sparx5_tc_set_actionset(admin, vrule); + if (err) + goto out; /* Links between VCAPs will be added later */ break; default: