From patchwork Thu Apr 8 13:38:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 12191123 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89FD2C433B4 for ; Thu, 8 Apr 2021 13:40:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CD2361153 for ; Thu, 8 Apr 2021 13:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231773AbhDHNkN (ORCPT ); Thu, 8 Apr 2021 09:40:13 -0400 Received: from mail-mw2nam10on2066.outbound.protection.outlook.com ([40.107.94.66]:21857 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231724AbhDHNkL (ORCPT ); Thu, 8 Apr 2021 09:40:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fHQIQOlEV2d7KqeVs4tZzHmBn4fwB7Pxa//M24AVTKy00Nqs894suPZVZ0BHH/A1D3h7gnFSkgU0JMAzJldv9cZndf3unKxH0wCBXyGLQpk5NTyxqsu9Pjh7ZmnDwjcNjWPjPluJKVHhSU+m3k8jrsO9uKKLPKnk4ueFnXEnzlth12Yd9zzRJiojVi8zft0DC8iLJQos+VzNS/rOQromwi6xUTcSk7QoAHEwO36FXLb4aZ1Du8A9B+Jf1BXKLsI901I4C1O8oddGmUaPGV7op1870WJaehVFRZ74qmpV9rVvQNrq9mPcNctGsMTmT3m88cc9nK4ZYZr5VOjbQy/edw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=la2R0eoUoRXLwKeFSIx6tOfIZefdkQrcWANFgkxO3J8=; b=PsPKcFHmWKptZ/TYUOgLdjMQQApg6JKKPy3s9FAb9mXY1YWS7499yjN7rjpJKk+ZG34Ov/eXWNZXmQK67eQCpTrDX9I1Iq4BKexvDNty8wqZ1pTRnetC9LtVKy6Ox1YCBjMpo0M98x/q1Yk50OCXdCydgLU5tpCI5Lz2+zQL4DMAQhp7/S8ikUYCCuPf2vSmNtebJV3A+y1ldj5IBW0jQN7isxCR4qrO1CmLYfIIY5P9vHVXBXu5anIZ6AxDn3bYgECT/ZwGENcwvPHrOjdhcRYyle6xakrhvmE3BqyJrEjm5mOr1chP/tADeDl+DmLde7XsUP7dG3NKegOyCVFzyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=la2R0eoUoRXLwKeFSIx6tOfIZefdkQrcWANFgkxO3J8=; b=ZyTcZt4CPEBb5ns7PH75lUOm57Yss0NFqGnqTX84a1A1Ps9p9aZs+iBkPxvdksh9lI7DQY9yQ0dIWFzYVca+uByIAwHLQ10hDUDkVDi/VLXzyB7nt5F/9qjs+GawXIEAvfd73jLSf+RsPGGgcEAJEWswx2o6jgpg5lPP9ApxILnpIsBXF1Xk+fdJlE76aexiGeucf7cDjaDIHK+TTX3SJscFtodeAHiJppPw5AxuuOo1OVHAH79wXh0p/7KKv6pe2Dx8P8AXrb9S9m1t7PhpQyEkbZkDaq4QlO/BRx65NNiNCaWH4Qrr2sPyB44nft2DapMRZBzoH91aNh72AMjsLQ== Received: from BN9PR03CA0472.namprd03.prod.outlook.com (2603:10b6:408:139::27) by BN8PR12MB3426.namprd12.prod.outlook.com (2603:10b6:408:4a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.32; Thu, 8 Apr 2021 13:39:56 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:408:139:cafe::33) by BN9PR03CA0472.outlook.office365.com (2603:10b6:408:139::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 13:39:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 13:39:56 +0000 Received: from localhost.localdomain (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 8 Apr 2021 13:39:53 +0000 From: Petr Machata To: CC: Petr Machata , Jiri Pirko , "David S. Miller" , Jakub Kicinski , Ido Schimmel , Cong Wang , Jamal Hadi Salim Subject: [PATCH net-next 1/7] net: sched: Add a trap-and-forward action Date: Thu, 8 Apr 2021 15:38:23 +0200 Message-ID: <20210408133829.2135103-2-petrm@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210408133829.2135103-1-petrm@nvidia.com> References: <20210408133829.2135103-1-petrm@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c6ec263-6845-4bab-2b92-08d8fa93cc54 X-MS-TrafficTypeDiagnostic: BN8PR12MB3426: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bUmv0ilR2QoxytMwjejxzl5WVgWIh2aFyV24R/kGtBBbWulF2qHlWsBDE3HZvDQ5ypMT1kW4Gk4UdR214WhDFAjMo9s1VJwBsw9eQq+z7pJk6i2ykRIIUGcnHJNBtgypj1YXiOmDz2Q56eW+Xc/6e5xKQ3b7xwVuxvf5VyC7hhw5c4h7HNnW4O8CT+liZ0GuY8bGr3DbDsCoRJNb+tYg7PlnutiGPGHZKx5WE92AFVHjDynzMpK+wZNu2GTZT1t3JGR29WN/G0ESTejEn+jEKw0D9qFmELW+sSGK4LzwOFUXH/8I3ChXJJ90QehPopsi2klXW5t19IQMR53CRrrUxA35qac5cvykM9QQv5Aj4OWxKWAxitUESF+VLkePcSmQHHqevEGXKqySeYJjgissQPgkP5vrHdq+Uflwmd9Z0HN2hXcOtRtycSNlQ08Mwxwa4yYJSDRaFX03zzeEl3mSIfMxej3Wi6DgZfT2aEsGUc9jDgkypyN0leR7P7wV9RJ0illxixfPDYeMm1unBhE4HOc2TbvVn1XNQRSnxkcRaPlSmuXpiv/pWgjn+v3gsf8Wh2V1SkF6SkSFij7u0RnberUZOLnvUZXQF2w7aojcCqKTnhVvPgfk2v+wtGq9T6VsugTnj4hDF8neymr1yYjqycdRzWgawMYRiqx+HxX9UiU= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(346002)(376002)(39860400002)(396003)(136003)(36840700001)(46966006)(2616005)(6916009)(4326008)(478600001)(36860700001)(16526019)(2906002)(186003)(26005)(8936002)(8676002)(336012)(426003)(5660300002)(82740400003)(86362001)(70206006)(1076003)(70586007)(83380400001)(356005)(36756003)(7636003)(82310400003)(6666004)(47076005)(36906005)(54906003)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 13:39:56.6380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c6ec263-6845-4bab-2b92-08d8fa93cc54 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3426 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The TC action "trap" is used to instruct the HW datapath to drop the matched packet and transfer it for processing in the SW pipeline. If instead it is desirable to forward the packet and transferring a _copy_ to the SW pipeline, there is no practical way to achieve that. To that end add a new generic action, trap_fwd. In the software pipeline, it is equivalent to an OK. When offloading, it should forward the packet to the host, but unlike trap it should not drop the packet. Signed-off-by: Petr Machata Reviewed-by: Jiri Pirko Reviewed-by: Ido Schimmel --- include/uapi/linux/pkt_cls.h | 6 +++++- net/core/dev.c | 2 ++ net/sched/act_bpf.c | 13 +++++++++++-- net/sched/cls_bpf.c | 1 + net/sched/sch_dsmark.c | 1 + tools/include/uapi/linux/pkt_cls.h | 6 +++++- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index 025c40fef93d..a1bbccb88e67 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -72,7 +72,11 @@ enum { * the skb and act like everything * is alright. */ -#define TC_ACT_VALUE_MAX TC_ACT_TRAP +#define TC_ACT_TRAP_FWD 9 /* For hw path, this means "send a copy + * of the packet to the cpu". For sw + * datapath, this is like TC_ACT_OK. + */ +#define TC_ACT_VALUE_MAX TC_ACT_TRAP_FWD /* There is a special kind of actions called "extended actions", * which need a value parameter. These have a local opcode located in diff --git a/net/core/dev.c b/net/core/dev.c index 9d1a8fac793f..f0b8c16dbf12 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3975,6 +3975,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev) switch (tcf_classify(skb, miniq->filter_list, &cl_res, false)) { case TC_ACT_OK: case TC_ACT_RECLASSIFY: + case TC_ACT_TRAP_FWD: skb->tc_index = TC_H_MIN(cl_res.classid); break; case TC_ACT_SHOT: @@ -5083,6 +5084,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret, &cl_res, false)) { case TC_ACT_OK: case TC_ACT_RECLASSIFY: + case TC_ACT_TRAP_FWD: skb->tc_index = TC_H_MIN(cl_res.classid); break; case TC_ACT_SHOT: diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index e48e980c3b93..be2a51c6f84e 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c @@ -54,8 +54,16 @@ static int tcf_bpf_act(struct sk_buff *skb, const struct tc_action *act, bpf_compute_data_pointers(skb); filter_res = BPF_PROG_RUN(filter, skb); } - if (skb_sk_is_prefetched(skb) && filter_res != TC_ACT_OK) - skb_orphan(skb); + if (skb_sk_is_prefetched(skb)) { + switch (filter_res) { + case TC_ACT_OK: + case TC_ACT_TRAP_FWD: + break; + default: + skb_orphan(skb); + break; + } + } rcu_read_unlock(); /* A BPF program may overwrite the default action opcode. @@ -72,6 +80,7 @@ static int tcf_bpf_act(struct sk_buff *skb, const struct tc_action *act, case TC_ACT_PIPE: case TC_ACT_RECLASSIFY: case TC_ACT_OK: + case TC_ACT_TRAP_FWD: case TC_ACT_REDIRECT: action = filter_res; break; diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index 6e3e63db0e01..5fd96cf2dca7 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c @@ -69,6 +69,7 @@ static int cls_bpf_exec_opcode(int code) case TC_ACT_SHOT: case TC_ACT_STOLEN: case TC_ACT_TRAP: + case TC_ACT_TRAP_FWD: case TC_ACT_REDIRECT: case TC_ACT_UNSPEC: return code; diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index cd2748e2d4a2..054a06bd9dc8 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c @@ -258,6 +258,7 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch, goto drop; #endif case TC_ACT_OK: + case TC_ACT_TRAP_FWD: skb->tc_index = TC_H_MIN(res.classid); break; diff --git a/tools/include/uapi/linux/pkt_cls.h b/tools/include/uapi/linux/pkt_cls.h index 12153771396a..ccfa424dfeaf 100644 --- a/tools/include/uapi/linux/pkt_cls.h +++ b/tools/include/uapi/linux/pkt_cls.h @@ -45,7 +45,11 @@ enum { * the skb and act like everything * is alright. */ -#define TC_ACT_VALUE_MAX TC_ACT_TRAP +#define TC_ACT_TRAP_FWD 9 /* For hw path, this means "send a copy + * of the packet to the cpu". For sw + * datapath, this is like TC_ACT_OK. + */ +#define TC_ACT_VALUE_MAX TC_ACT_TRAP_FWD /* There is a special kind of actions called "extended actions", * which need a value parameter. These have a local opcode located in From patchwork Thu Apr 8 13:38:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 12191125 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 641A1C43460 for ; Thu, 8 Apr 2021 13:40:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2558561155 for ; Thu, 8 Apr 2021 13:40:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231768AbhDHNkO (ORCPT ); Thu, 8 Apr 2021 09:40:14 -0400 Received: from mail-mw2nam12on2085.outbound.protection.outlook.com ([40.107.244.85]:26816 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231765AbhDHNkM (ORCPT ); Thu, 8 Apr 2021 09:40:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wq+2qBH9Kj1ev6Awf+/O4AWIn7YLiy8Zpi1Xt9GxWkOHuc5V95BrXB1s3qmSHtUKL8k+lIaBxVkIk6caa3fK3KNYlRRdjbxe+PxMnaIt+Dle3ej5GqRNnAMwrZJJrRBUTSxtwo0y5xx4MB2Bkw9glOb/rpPvFJPN8gnyWpAzuAbISEgF/VL5yLP7LVzl9pTpgFuUcXXPoD9ERsNDi2NAXwgJXsbrbg6AVzzu+e/iM/aewzCdllhDhELAnxcCNWY3lopGe2KM+Fvpsp1Oip9Sq6qj2r1fa2tNdAVimGV2ldVQ8QzwKl1XJfrGEj3VBBsWdbTp3dDS/g+61hRcp/D4MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n44fdZ1pttfQWhuy4c3KI2VhfuQZkvMOeKftof3cSfg=; b=A3Q6qK7+iEVhDPpZS0kUbyzidWHZoO1By4LDHEiK9d23SlDUmnvs3qW0UW/vcFTa3RpC/G48wgnmhmnPD36JyiUoCibNmIvx4qlQ09GAWKCRxinOIMODHpM5HhuqBdiYs1RBoTSdgJjZAIMJLnAFo4YoiiFul7QdGFtnfM8wBW8zYTd7YMHPVOvxvo6TaMmTki9PiTknTjgVaA2tLTSAcVY0WuTZw29C7yg6IarKw/g96fMz6J9aBPJ/ho+uxVguGvm9Osw9L3g6b/Dwcf4Lj8BrV2JrPc1qdde4cRNCip4kFIU05Koza0sf9m2eEzOg6YsD09t1qfw/04kzCij6kA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n44fdZ1pttfQWhuy4c3KI2VhfuQZkvMOeKftof3cSfg=; b=XmgaP7Trozqmoic31VWU9G5lAg7VNm5C9tm2fnOf3OO81yugnTsLT7RxwsAai0t9rzU7NR2/IQef94Ctuj2u5AqLl4u52RfbVAaNbCurdQs+iLaKHSR15YqBVatvhRpGhMOYOucH5CkP9RRFqqHfMyprPh8PR1IPYJF87rZmgDWqMHQlTSxhJVZ0iDZuQqAmSGAFfK+5X/8QZpit3moYLjlQWOlPPgIzswNhVey2kQ9jqGIRWzEt5V+bGgoLT+cqfv/71N8m2AGEjRX/OcGQ6rcK+c0zAzrL6sxja+0dE5M3SeM/7ZPIeF2Rous7659YB6LBk6DwzS4et4ELbKxWBQ== Received: from BN6PR11CA0002.namprd11.prod.outlook.com (2603:10b6:405:2::12) by DM6PR12MB3580.namprd12.prod.outlook.com (2603:10b6:5:11e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.32; Thu, 8 Apr 2021 13:40:00 +0000 Received: from BN8NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:405:2:cafe::fb) by BN6PR11CA0002.outlook.office365.com (2603:10b6:405:2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Thu, 8 Apr 2021 13:40:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT011.mail.protection.outlook.com (10.13.176.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 13:39:59 +0000 Received: from localhost.localdomain (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 8 Apr 2021 13:39:56 +0000 From: Petr Machata To: CC: Petr Machata , Jiri Pirko , "David S. Miller" , Jakub Kicinski , Ido Schimmel , Cong Wang , Jamal Hadi Salim Subject: [PATCH net-next 2/7] net: sched: Make the action trap_fwd offloadable Date: Thu, 8 Apr 2021 15:38:24 +0200 Message-ID: <20210408133829.2135103-3-petrm@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210408133829.2135103-1-petrm@nvidia.com> References: <20210408133829.2135103-1-petrm@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 572ba4ea-c8ee-4c94-357e-08d8fa93ce4b X-MS-TrafficTypeDiagnostic: DM6PR12MB3580: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QB0Ik3mFvuWbd3o5fRiG4zL3kiIYEQy0+42hE4alKt8Y5GOfhOzZH27shsjweoQlYacD/yrLQBHzg9F1om/+gIpF+JQxUi+SndpRxquqozCXR8a5qQ1mozS837Dh7U9tU07Tc7GfiEDdqPBhLksjCUxNhEoe5aIHS/tXB/GwClqVQjuDGpV/xkakIF/JfgAk2HhJLKeCONcg5lAk/mvIPzB0wsyhK2+n2xwI8q4Ssw4q5DdpNSU/FAnQIBtmoBk9n/Xywr4Z8eGQYYbIMe9cSRnTQPZZFScUtugNuDd4v1G56rJABhNoctvtWfaPwnnXtOa3dSocpT3LqbnmZiDjGJD6Cy8LB+IXAWiEZdhsH5oI+6ve867hqTdE7PVyEDYgWr85GexH+Akmf9wtNXJRFI5VzEYdfSN3XJ75VmfmOXHpmWmDUJvO1z/9JiXVmb+CI46qTGzYr+Aiznabx3UH/VWjGBzZPHL4y7Vi28X4eZx/AimzBbcjBi6cEmEeCpn8rZXQNaaIeIlsjPWnb0JjaSubzcLi3AKncleFwS1tQGX1i9SKzv7eXjHyieA8UT2kPfu4AKyLva7bBVn1/dCbAoeFBfw3Slrs/YxMPqSQShFGRti89/cUFhiS9eaCExFRcyNp6nKLcNG0u6ESMF8Ubg== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(39860400002)(346002)(376002)(396003)(136003)(36840700001)(46966006)(26005)(16526019)(336012)(54906003)(36756003)(70206006)(70586007)(186003)(2906002)(36860700001)(316002)(4326008)(5660300002)(47076005)(36906005)(356005)(478600001)(8676002)(86362001)(2616005)(82310400003)(7636003)(8936002)(1076003)(6666004)(82740400003)(6916009)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 13:39:59.9308 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 572ba4ea-c8ee-4c94-357e-08d8fa93ce4b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3580 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add the new flow action and related support so that drivers can offload the trap_fwd action. Signed-off-by: Petr Machata Reviewed-by: Jiri Pirko Reviewed-by: Ido Schimmel --- include/net/flow_offload.h | 1 + include/net/tc_act/tc_gact.h | 5 +++++ net/sched/cls_api.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index dc5c1e69cd9f..5f35523f12b5 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -121,6 +121,7 @@ enum flow_action_id { FLOW_ACTION_ACCEPT = 0, FLOW_ACTION_DROP, FLOW_ACTION_TRAP, + FLOW_ACTION_TRAP_FWD, FLOW_ACTION_GOTO, FLOW_ACTION_REDIRECT, FLOW_ACTION_MIRRED, diff --git a/include/net/tc_act/tc_gact.h b/include/net/tc_act/tc_gact.h index eb8f01c819e6..df9e0a19c826 100644 --- a/include/net/tc_act/tc_gact.h +++ b/include/net/tc_act/tc_gact.h @@ -49,6 +49,11 @@ static inline bool is_tcf_gact_trap(const struct tc_action *a) return __is_tcf_gact_act(a, TC_ACT_TRAP, false); } +static inline bool is_tcf_gact_trap_fwd(const struct tc_action *a) +{ + return __is_tcf_gact_act(a, TC_ACT_TRAP_FWD, false); +} + static inline bool is_tcf_gact_goto_chain(const struct tc_action *a) { return __is_tcf_gact_act(a, TC_ACT_GOTO_CHAIN, true); diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index d3db70865d66..95e37eb50173 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3582,6 +3582,8 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->id = FLOW_ACTION_DROP; } else if (is_tcf_gact_trap(act)) { entry->id = FLOW_ACTION_TRAP; + } else if (is_tcf_gact_trap_fwd(act)) { + entry->id = FLOW_ACTION_TRAP_FWD; } else if (is_tcf_gact_goto_chain(act)) { entry->id = FLOW_ACTION_GOTO; entry->chain_index = tcf_gact_goto_chain_index(act); From patchwork Thu Apr 8 13:38:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 12191127 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC714C433B4 for ; Thu, 8 Apr 2021 13:40:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D1A861153 for ; Thu, 8 Apr 2021 13:40:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231772AbhDHNkT (ORCPT ); Thu, 8 Apr 2021 09:40:19 -0400 Received: from mail-mw2nam12on2060.outbound.protection.outlook.com ([40.107.244.60]:43552 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231795AbhDHNkQ (ORCPT ); Thu, 8 Apr 2021 09:40:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jF8TZfv5dGzOpa5bHhgqHX8wap17ydUntflLc8J+wI6O9o7UNl+EmzWVvBIfNGIR9rImLC6Appv4oY6LznY7Gv2G/OxsejE0PuNyMX0uZfdZOGqBx5lFn+Mehf2GhHKBxs0RZs1SC7vD0y9E1Jh0uzpYt7C972c0d4Ssor15GUl9Ne0oQP5ANBwh20XXz4HgxOo4QrE9JNskiT3hBY7WRf83mQaAQ6UM4HsolrQ6G5Ya//NfUrbo18mV2WHgN9NACFuF+YfKlWncXycA2JBA7h2kCbybNd8kf9lu5bIPH3i5WCOLImj8QQjujq2UmuchzoI/1pD8yNzGE8TYnsi1uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XI/7TKI9bjXtRgi+mfq/fGYau9oENFEOuMwetmyb9Tk=; b=flsaet4Pk+KK1PHhO4Nnmut+yhrEIxRjZzkqWnn7p8zaD5dqdNL8AIAX46YfWf5d8N9aKbyZTrQLl3V3AsoOZdEnJVg5t0Jx3hA1jKbHYgtdELr/RtLAOxePrpVjKRBaIN/OkYfTixij+AAG4FwEADN0ZYBkv8ZpEF2w6y4BSPbJUekJvHXGEcrJ8yF5g9FM/IFQpCZSb4A42epoF3KNZ49WwraIcdyI7QmB+V9Ez8o9YVrZnJlH3ZwiKRU2EBE6l6t18oSMnG1ritqV+NjHZaXabXIRRr+/SllUrb/jy/JnKvBRwlnpIrO1vxlJzMr3LYagRbNyLh7Xu/U9V8qWJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XI/7TKI9bjXtRgi+mfq/fGYau9oENFEOuMwetmyb9Tk=; b=O3DYbNeiVBsbgLtMbZ/OgioarVOeAZr6mW6kH3RFWGd50xJXdb0XWgSAVRSKhMHR6RSH12zcrQP1720M7TyuUNQ7Q/nLMk9FEpLkLoR1batvBebEHScq28+2lgxEwK3K1I5mHuZF+hUbjxMhYNL1cKZhj1yETnAnUlUvMtbpHTSgfEDkwUFhEpY+uCgP0gGAplDMZeikbLBEt+Z7Pa28pqG8gXB73njOiuCyqdZWcM7cbNXB2e3GF4GVqFhram5o6RusCWk9tY/uzI1fVIienkJb0yKAX5zJv2K9TmrCzPxjzISSofhU1nhWT6+kZ3nRkWZodn9tqsC8mSbJTngz7w== Received: from BN6PR22CA0047.namprd22.prod.outlook.com (2603:10b6:404:37::33) by BN6PR12MB1331.namprd12.prod.outlook.com (2603:10b6:404:17::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.32; Thu, 8 Apr 2021 13:40:03 +0000 Received: from BN8NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:404:37:cafe::8b) by BN6PR22CA0047.outlook.office365.com (2603:10b6:404:37::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Thu, 8 Apr 2021 13:40:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT021.mail.protection.outlook.com (10.13.177.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 13:40:03 +0000 Received: from localhost.localdomain (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 8 Apr 2021 13:39:59 +0000 From: Petr Machata To: CC: Petr Machata , Jiri Pirko , "David S. Miller" , Jakub Kicinski , Ido Schimmel , Cong Wang , Jamal Hadi Salim Subject: [PATCH net-next 3/7] devlink: Add a new trap for the trap_fwd action Date: Thu, 8 Apr 2021 15:38:25 +0200 Message-ID: <20210408133829.2135103-4-petrm@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210408133829.2135103-1-petrm@nvidia.com> References: <20210408133829.2135103-1-petrm@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1330876f-bf18-42bc-1b8d-08d8fa93d052 X-MS-TrafficTypeDiagnostic: BN6PR12MB1331: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +epNI/iiojebvAJgQRxn1rTorZ4jjWIiWWRobXGkGAVKNONNGjOs6J1MTiBkib3iTMbLZOC4kRQJNHz7GfBh293v+2rdezbJO0sJ9wjeoMQUPcYhyJtMSoQimWlbvDcKZsqsTP77hA+CC7i7z0DQc3eodWE2dtsZgJex3zZEcHXWtl6apftVf3hFsrkqFHVmsVO3An/wTKBcgiropqOv3Es3v2kmgqHsUmlz+WqkYHz7QcsDjeKEphwFZuTSptGo+zXijSmFxskIP5ub1LoCK+7kAr8xg6yQUZksmfI+uA+xbQAx9dD8ItsXPNo/iiaLZSQkARcApYo1cVb7qE6Vbpap1JlLeX73W72UDvsH9uKsXHBDAPB2yHkp+czMG68liGnV16j8eON0tnwFtxbCVGL7df9a2otgKodsumk+xBqBKpMAj5uUnD2cv05y/hH3KZAwESBQMKsj8eQQnwrpLT7VAZWumTLb+0R4BWVQq5MMnSLwxl/Os1WS2PTkWt/JI9LhiUHdBT/YAea2n+iK12mJlxE0qwj+brArRMOC4P8J+ZOvZK63U0EgFwYETur3VnetK9XhqmFG79YtAfh7fE0d7JxiftH+7+3vIyWiTh2nELplzh7yGdlTkUiCVQTwa12VHlBQ06UMM59BhJIs8g== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(39860400002)(346002)(46966006)(36840700001)(7636003)(8676002)(16526019)(82740400003)(54906003)(2906002)(6666004)(6916009)(4326008)(8936002)(316002)(36906005)(478600001)(1076003)(2616005)(336012)(70206006)(36860700001)(70586007)(83380400001)(26005)(86362001)(47076005)(356005)(5660300002)(36756003)(426003)(186003)(82310400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 13:40:03.3364 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1330876f-bf18-42bc-1b8d-08d8fa93d052 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1331 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add a new trap so that drivers can report packets forwarded due to the trap_fwd action correctly. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Documentation/networking/devlink/devlink-trap.rst | 4 ++++ include/net/devlink.h | 3 +++ net/core/devlink.c | 1 + 3 files changed, 8 insertions(+) diff --git a/Documentation/networking/devlink/devlink-trap.rst b/Documentation/networking/devlink/devlink-trap.rst index 935b6397e8cf..3f1c0f89d284 100644 --- a/Documentation/networking/devlink/devlink-trap.rst +++ b/Documentation/networking/devlink/devlink-trap.rst @@ -405,6 +405,10 @@ be added to the following table: - ``control`` - Traps packets logged during processing of flow action trap (e.g., via tc's trap action) + * - ``flow_action_trap_fwd`` + - ``control`` + - Traps packets logged during processing of flow action trap_fwd (e.g., via + tc's trap_fwd action) * - ``early_drop`` - ``drop`` - Traps packets dropped due to the RED (Random Early Detection) algorithm diff --git a/include/net/devlink.h b/include/net/devlink.h index 853420db5d32..967e70363ba9 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -845,6 +845,7 @@ enum devlink_trap_generic_id { DEVLINK_TRAP_GENERIC_ID_PTP_GENERAL, DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_SAMPLE, DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_TRAP, + DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_TRAP_FWD, DEVLINK_TRAP_GENERIC_ID_EARLY_DROP, DEVLINK_TRAP_GENERIC_ID_VXLAN_PARSING, DEVLINK_TRAP_GENERIC_ID_LLC_SNAP_PARSING, @@ -1053,6 +1054,8 @@ enum devlink_trap_group_generic_id { "flow_action_sample" #define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_TRAP \ "flow_action_trap" +#define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_TRAP_FWD \ + "flow_action_trap_fwd" #define DEVLINK_TRAP_GENERIC_NAME_EARLY_DROP \ "early_drop" #define DEVLINK_TRAP_GENERIC_NAME_VXLAN_PARSING \ diff --git a/net/core/devlink.c b/net/core/devlink.c index 737b61c2976e..478d4bc01a39 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -9744,6 +9744,7 @@ static const struct devlink_trap devlink_trap_generic[] = { DEVLINK_TRAP(PTP_GENERAL, CONTROL), DEVLINK_TRAP(FLOW_ACTION_SAMPLE, CONTROL), DEVLINK_TRAP(FLOW_ACTION_TRAP, CONTROL), + DEVLINK_TRAP(FLOW_ACTION_TRAP_FWD, CONTROL), DEVLINK_TRAP(EARLY_DROP, DROP), DEVLINK_TRAP(VXLAN_PARSING, DROP), DEVLINK_TRAP(LLC_SNAP_PARSING, DROP), From patchwork Thu Apr 8 13:38:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 12191129 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0CBCC433ED for ; Thu, 8 Apr 2021 13:40:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBC9561107 for ; Thu, 8 Apr 2021 13:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231771AbhDHNk0 (ORCPT ); Thu, 8 Apr 2021 09:40:26 -0400 Received: from mail-dm6nam11on2057.outbound.protection.outlook.com ([40.107.223.57]:10976 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231722AbhDHNkT (ORCPT ); Thu, 8 Apr 2021 09:40:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RCedl1+DGLm77Yn2HounT966vW6I1JnlPk8W/jRHLe4zrL8ca+5uPOUh4HX5Qy7Hw9j26qPx8nk16CWL97ST47PX5pL1sfs833gi2SY8InDeJ1tkauLfQCxFei071bJq5uwk8vts2h/SzSpOo+yoMzT7qCWxGYqxkTAU/NOnDYz7PH8K6h0b4RIZ6fP2CRjIQ+U6tokkPjXP3oNLaG+6u7A0jmxbQs5d8IILYvryEP54ms7c73QeJiIv7uN4D1VYhNWgytRDUb8d8K7bZL0NxX2/n6ka5pgEJEwild6APEXFoQZarG60N54N/OfSndfAEOGTDp5QKFPMqQUzvSGKUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J/q5XYYrG4nRl3Biq6XUQoR0svlOdf7wRrnfFd80t0c=; b=bVSlF5H0dXEZyXdmi4JIRalqmaAnUTW9FSTL7yt6B5RlZ144zFXSMUFAyL5jbvKpOcTuDokUONgChzVsBKxHXvzBjZ9VoksRJQFmGbCwVMTuWiCAOza8z9AwK/pTdfqYfWM8dovz4NYXXdEgzZd0BiOZBiXwUdNSF+lPaBZSG1V1oTDNtYNDF9cCiksIWjn8si0si/uEEAWbVrxacFti968p87oaUEKE2A2vtad2l6W1cffaQXbnGRWwthQjSSckUjpdxWc9owaJDmi7O5ju2JvJrl1PUEeVDgbjWRc/TvF7jgRwqVOBc4bnd4nQFUtEUMU5DWVN5A2M6ZshevipMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J/q5XYYrG4nRl3Biq6XUQoR0svlOdf7wRrnfFd80t0c=; b=i1jtWoHNgZImZLs8v3GdD5GvHuoSBo06DBFJJXZFIvY/UsIm0oeWhHGyg1TaeHHDjPO16o3tloAjlvxW8FfLk8qErIlxv9u7Uz2jCXauAJg+jlIpvY4RoAMggzYXusJFXMoE3dmEBUp+8UFgEGxBNbEgE6YyjBiy56HrCZBfZHxQ8qnf1DgRDLo3T7AjIoRfEAKLKTt2kgIeY1i5QJ2I99hnJbcLFiJxZu+sBvkcQHBxNmpa4BKFD1z8+4a9sA1eiEUGVjHMdXQhvWxAWfn1SA4w8iZPye6p++5tinH4xKmlFh9wOwv1Xm4YNIfy81xgTidC/aq5woFYUUGXJdtCIg== Received: from BN0PR04CA0044.namprd04.prod.outlook.com (2603:10b6:408:e8::19) by BYAPR12MB4727.namprd12.prod.outlook.com (2603:10b6:a03:99::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26; Thu, 8 Apr 2021 13:40:07 +0000 Received: from BN8NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e8:cafe::f) by BN0PR04CA0044.outlook.office365.com (2603:10b6:408:e8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 13:40:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT044.mail.protection.outlook.com (10.13.177.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 13:40:06 +0000 Received: from localhost.localdomain (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 8 Apr 2021 13:40:03 +0000 From: Petr Machata To: CC: Petr Machata , Jiri Pirko , "David S. Miller" , Jakub Kicinski , Ido Schimmel , Cong Wang , Jamal Hadi Salim Subject: [PATCH net-next 4/7] mlxsw: Propagate extack to mlxsw_afa_block_commit() Date: Thu, 8 Apr 2021 15:38:26 +0200 Message-ID: <20210408133829.2135103-5-petrm@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210408133829.2135103-1-petrm@nvidia.com> References: <20210408133829.2135103-1-petrm@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8609ba12-8a93-4141-9dd4-08d8fa93d253 X-MS-TrafficTypeDiagnostic: BYAPR12MB4727: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:569; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sm1PlADQalwOAdcEUUkXSYK6OQyDD3CEf2kpDr6UsoahEJRRCUbBtFmaYZ5JxSjurmlr/iXypvZrMacgSW9RKMy7cy5McJnlCGR4wSXWz0h9D3xXckGGdLfHjoAXXz+Y8sZTpkXNmxE3JMN2TV6pk8FzuXLF8cXWOZAN0WCMIk4lbOTRLMwI+5AIlJkys5JAie/k7OQI0fB4PxWAD8XJN03W+ZjwiRkl9lc066WmyrtKDCdP2TUXl6GaF7dBd83WV5RBPkWHrkv6ikd1y35hr4Ss6d4/kGFlgfhWcgPWy5JlKbntFak0gJLbpcBfJn2zHpBxKi38u4are6rw+yoUj6ryCx+tE8ACjPiwA84L7C3GOvicELMLPfU1K0VW2iavq0Vs9fNBrLvhQ2pwWqj2upbKdG1hhPY4LyVp1cc661R5/PogBQZhdBzBOQ7xNrvsrEjWWRdbXK0E6GIymQgHJ9Rqr9COLGMRvlwncgkyvL/rcLxmtuSl8hr0RMgzhQliX2TdabGQ3+W8XIjqrbw9JxTpXP4082zw86EcEJBzYQYF3o1xbtPNq+mvEQU3on0XRDFHAj1/HfOhPid5xP1m6IcnYsQRMVDvk+sG7DxQCZs+qqXr/+Du2xrnkJ7DzyIxQmX80oM/GYNpYVw9JLvL8HHRHuoitOI+40+O3wUw7l8= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(376002)(346002)(136003)(39860400002)(396003)(46966006)(36840700001)(2616005)(1076003)(426003)(6666004)(7636003)(82740400003)(8936002)(47076005)(83380400001)(36860700001)(336012)(4326008)(316002)(5660300002)(26005)(82310400003)(2906002)(16526019)(54906003)(36756003)(186003)(86362001)(6916009)(478600001)(8676002)(70586007)(36906005)(70206006)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 13:40:06.6508 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8609ba12-8a93-4141-9dd4-08d8fa93d253 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB4727 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In the following patch, attempts to change the next/goto of a flexible action set from goto to next will be rejected for action sets that contain a trap_fwd action. Propagate extack to make it possible to communicate the issue to the user. Signed-off-by: Petr Machata Reviewed-by: Jiri Pirko Reviewed-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c | 9 ++++++--- .../net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h | 3 ++- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 3 ++- drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c | 5 +++-- drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c | 2 +- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c index 78d9c0196f2b..faa90cc31376 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c @@ -264,7 +264,8 @@ static void mlxsw_afa_set_goto_set(struct mlxsw_afa_set *set, } static void mlxsw_afa_set_next_set(struct mlxsw_afa_set *set, - u32 next_set_kvdl_index) + u32 next_set_kvdl_index, + struct netlink_ext_ack *extack) { char *actions = set->ht_key.enc_actions; @@ -455,7 +456,8 @@ void mlxsw_afa_block_destroy(struct mlxsw_afa_block *block) } EXPORT_SYMBOL(mlxsw_afa_block_destroy); -int mlxsw_afa_block_commit(struct mlxsw_afa_block *block) +int mlxsw_afa_block_commit(struct mlxsw_afa_block *block, + struct netlink_ext_ack *extack) { struct mlxsw_afa_set *set = block->cur_set; struct mlxsw_afa_set *prev_set; @@ -479,7 +481,8 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block) return PTR_ERR(set); if (prev_set) { prev_set->next = set; - mlxsw_afa_set_next_set(prev_set, set->kvdl_index); + mlxsw_afa_set_next_set(prev_set, set->kvdl_index, + extack); set = prev_set; } } while (prev_set); diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h index b65bf98eb5ab..24350f9470f8 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h @@ -45,7 +45,8 @@ struct mlxsw_afa *mlxsw_afa_create(unsigned int max_acts_per_set, void mlxsw_afa_destroy(struct mlxsw_afa *mlxsw_afa); struct mlxsw_afa_block *mlxsw_afa_block_create(struct mlxsw_afa *mlxsw_afa); void mlxsw_afa_block_destroy(struct mlxsw_afa_block *block); -int mlxsw_afa_block_commit(struct mlxsw_afa_block *block); +int mlxsw_afa_block_commit(struct mlxsw_afa_block *block, + struct netlink_ext_ack *extack); char *mlxsw_afa_block_first_set(struct mlxsw_afa_block *block); char *mlxsw_afa_block_cur_set(struct mlxsw_afa_block *block); u32 mlxsw_afa_block_first_kvdl_index(struct mlxsw_afa_block *block); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index f99db88ee884..d74fc7ff8083 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -920,7 +920,8 @@ struct mlxsw_sp_acl_rule_info * mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl, struct mlxsw_afa_block *afa_block); void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei); -int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); +int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei, + struct netlink_ext_ack *extack); void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei, unsigned int priority); void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c index 3a636f753607..cda04bc4453f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c @@ -75,7 +75,7 @@ mlxsw_sp1_acl_ctcam_region_catchall_add(struct mlxsw_sp *mlxsw_sp, err = mlxsw_sp_acl_rulei_act_continue(rulei); if (WARN_ON(err)) goto err_rulei_act_continue; - err = mlxsw_sp_acl_rulei_commit(rulei); + err = mlxsw_sp_acl_rulei_commit(rulei, NULL); if (err) goto err_rulei_commit; err = mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->cregion, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c index 67cedfa76f78..b9c4c1feba6d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c @@ -341,9 +341,10 @@ void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei) kfree(rulei); } -int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei) +int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei, + struct netlink_ext_ack *extack) { - return mlxsw_afa_block_commit(rulei->act_block); + return mlxsw_afa_block_commit(rulei->act_block, extack); } void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c index be3791ca6069..936788f741dd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c @@ -611,7 +611,7 @@ int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp, if (err) goto err_flower_parse; - err = mlxsw_sp_acl_rulei_commit(rulei); + err = mlxsw_sp_acl_rulei_commit(rulei, f->common.extack); if (err) goto err_rulei_commit; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c index 221aa6a474eb..f81e8d25987b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c @@ -241,7 +241,7 @@ mlxsw_sp_mr_tcam_afa_block_create(struct mlxsw_sp *mlxsw_sp, goto err; } - err = mlxsw_afa_block_commit(afa_block); + err = mlxsw_afa_block_commit(afa_block, NULL); if (err) goto err; return afa_block; From patchwork Thu Apr 8 13:38:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 12191131 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB95AC433ED for ; Thu, 8 Apr 2021 13:40:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 694C261153 for ; Thu, 8 Apr 2021 13:40:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231730AbhDHNk3 (ORCPT ); Thu, 8 Apr 2021 09:40:29 -0400 Received: from mail-mw2nam10on2055.outbound.protection.outlook.com ([40.107.94.55]:53088 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231777AbhDHNkX (ORCPT ); Thu, 8 Apr 2021 09:40:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZZ2L9EwvxwLCSNWSYg1EuMhr0zXImqgca1D9xlapTY2yHx91eEMn7OfmlrRMP4nxXX5q8WXMp6evUHgD48hCuV+oiZBM0PDDMaWTpe0molztXTFOfzdxDpPs10VmXu/jhkVhPM0d5wUuoyDezbczjsXNoIVyF1bLWRwN3kTA37OR+qFSwXkNZTdeiDTBl7GxMBAXhhUblqFnGovzF09LKRCg4FDLJ/ZfQkauPkcUBT/CicJjVEsKnhzFR7iSvtRkesfJZdUFnG4CMny2WWOy0/HDR9HIRtIg7yBKVOYnGUUnavM6wtnKdiPAipnDTYhyVlfqaU8UodS+CEofSakxPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XJzRTCnK2XO6I6rO2bfGCuK7ecwpCL7fmVVPDBY2aKc=; b=f4H6taHqDth/all2twyK6bW+7ZDlYBxf8rb71MKr1Y0mSo38H2Sa6QmHtvvMJ4IsqQGmkWZmcmIExaxVD+U7qJs82MX9rj+BqqRIkQEGQAS4nBc/4f6DNyzNMI2DKxED49Ay1yswstrQxVLgbmK9yHD9QoZ5MTrPyqf7lkdCabMppKEwRTet8Pxitj57zNmV5+LfK0e+vHtCidL1SQ4V4ETGtU2BabSAAk3HTqq5jTJZup8KgH48aXygXM41cen1FmiFn9yw7TtL7vZl3Ea39XVs4Lg5j8QYmIDbFMZNRqrjpBAQgEsf9OukyePsfqq9SuOwtj0oynH2PYHJiZJNAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XJzRTCnK2XO6I6rO2bfGCuK7ecwpCL7fmVVPDBY2aKc=; b=H3Pwu2CJn2iBRnv5mC660CPb1gYv5N2f8xFsHNxONsbFtQ/Jp7mXk3zyMdnTNtOWJWAt0+VPRPLe5Ca8eDo0ZJovXRITczbbJxAWENvVgOYZ/6Ynl/22UpSwnw185l2SXRa/bpdnEZ2fQn5XvmRacSUUItO3kbK6UPwzBUAUFA0C2OGehr8IIBgln+wpuuFeJZ42/U6dF4FoWTbIFBuAvcUlzBWZ0hy4QGiWbp8ifAjgvWczKPURqQYoJlZnosOzBqcglwhuedyq6ZYYgQr661h23ZexTwFuIpiNzFfLPFdMKYKpQRREufz1lTpBgS9ZTIwuHUl/7jbqXAqA4Zx1fw== Received: from BN6PR19CA0073.namprd19.prod.outlook.com (2603:10b6:404:133::11) by CH2PR12MB4022.namprd12.prod.outlook.com (2603:10b6:610:22::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.32; Thu, 8 Apr 2021 13:40:09 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:404:133:cafe::f0) by BN6PR19CA0073.outlook.office365.com (2603:10b6:404:133::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Thu, 8 Apr 2021 13:40:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 13:40:09 +0000 Received: from localhost.localdomain (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 8 Apr 2021 13:40:06 +0000 From: Petr Machata To: CC: Petr Machata , Jiri Pirko , "David S. Miller" , Jakub Kicinski , Ido Schimmel , Cong Wang , Jamal Hadi Salim Subject: [PATCH net-next 5/7] mlxsw: Offload trap_fwd Date: Thu, 8 Apr 2021 15:38:27 +0200 Message-ID: <20210408133829.2135103-6-petrm@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210408133829.2135103-1-petrm@nvidia.com> References: <20210408133829.2135103-1-petrm@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5dd9da5-d849-43e8-d898-08d8fa93d405 X-MS-TrafficTypeDiagnostic: CH2PR12MB4022: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:628; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZG0oZ/5NgC0+Zp9Va4PzZ3l9q8PvC31T+vWMs34tPn2rh2hliHrQif0qFfi1T2uftv/CagWkyVY9V6Zgmmn8Xnv0ItjqzVmHmUNkl/I6YrJcnFD4T3j4tTUci4eUEUVJMHKXLjI7ek8g+8cacVTZqvVmMqr/I2iBaCV3w6KpJ6KQA0zy81SJ4G+B427VB5LXMeXfcHagvkKct+1yPFRuVs168Fx3UJEy7mSGEa6T+FeTKxkgwSl5H44/ivOByTAoOcKmqhSZwvb9OVesbY7CnPyLUphY0IBoXDQD0Kq05wROEsBWQSt48RVMHcqt5y4kfZ6Mz+/ZBuzioKfyE+rQeVhHfUP08PVIL6lfKF9Ejv5s4z2ozoqZ4TBFEpVthW2PJKc2CY6GEHEudLBhz8WLyD7IB9MI4gV88eM9uAd2z87+COYclmNe5mRbbs3DLtg6nKBqNvIzluh5BPPolFEyrwSu8/+c+2udj0eY76DiryJd+Gb3slpcMlrWlIH8cNyegQXboFGpxbuRMgXtel72qO9iA5aK84Zv/HIH0UgWkbexdmPCB7cti1+Kd0PxOs6CsOpeDu4XbYGMEQ6+PSuAmGhWv0QQP3JmMfu8TQOqz4lB8cnotXwqBdInRWFxL07rFHLXMRDpdHKxKc+n21SzSA== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(346002)(396003)(39860400002)(376002)(136003)(46966006)(36840700001)(5660300002)(7636003)(356005)(426003)(2616005)(36756003)(6916009)(82740400003)(83380400001)(16526019)(4326008)(70586007)(36906005)(316002)(6666004)(336012)(2906002)(1076003)(47076005)(36860700001)(26005)(82310400003)(86362001)(70206006)(8676002)(54906003)(8936002)(186003)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 13:40:09.5215 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5dd9da5-d849-43e8-d898-08d8fa93d405 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4022 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Offload the TC action trap_fwd. This is offloaded as a TRAP_ACTION with forward_action of FORWARD (as opposed to NOP for the trap action). Unlike trap, trap_fwd needs to be in an "goto"-typed action set, not "next"-typed one. Trap_fwd'd traffic is marked with offload_fwd_mark and offload_l3_fwd_mark to prevent second forwarding in the SW datapath. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../mellanox/mlxsw/core_acl_flex_actions.c | 23 +++++++++++++++---- .../net/ethernet/mellanox/mlxsw/spectrum.h | 1 + .../ethernet/mellanox/mlxsw/spectrum_acl.c | 6 +++++ .../ethernet/mellanox/mlxsw/spectrum_flower.c | 7 ++++++ .../ethernet/mellanox/mlxsw/spectrum_trap.c | 8 +++++++ drivers/net/ethernet/mellanox/mlxsw/trap.h | 2 ++ 6 files changed, 43 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c index faa90cc31376..d7d7e688139f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c @@ -94,7 +94,8 @@ struct mlxsw_afa_set { * kvdl_index is valid). */ has_trap:1, - has_police:1; + has_police:1, + has_trap_fwd:1; unsigned int ref_count; struct mlxsw_afa_set *next; /* Pointer to the next set. */ struct mlxsw_afa_set *prev; /* Pointer to the previous set, @@ -263,14 +264,23 @@ static void mlxsw_afa_set_goto_set(struct mlxsw_afa_set *set, mlxsw_afa_set_goto_next_binding_set(actions, group_id); } -static void mlxsw_afa_set_next_set(struct mlxsw_afa_set *set, +static int mlxsw_afa_set_next_set(struct mlxsw_afa_set *set, u32 next_set_kvdl_index, struct netlink_ext_ack *extack) { char *actions = set->ht_key.enc_actions; + /* If the forwarding action is not drop, the next/goto record must not + * be a next, it must be a goto. + */ + if (set->has_trap_fwd) { + NL_SET_ERR_MSG_MOD(extack, "Only goto permissible after a trap_fwd action"); + return -EINVAL; + } + mlxsw_afa_set_type_set(actions, MLXSW_AFA_SET_TYPE_NEXT); mlxsw_afa_set_next_action_set_ptr_set(actions, next_set_kvdl_index); + return 0; } static struct mlxsw_afa_set *mlxsw_afa_set_create(bool is_first) @@ -461,6 +471,7 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block, { struct mlxsw_afa_set *set = block->cur_set; struct mlxsw_afa_set *prev_set; + int err; block->cur_set = NULL; block->finished = true; @@ -481,8 +492,10 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block, return PTR_ERR(set); if (prev_set) { prev_set->next = set; - mlxsw_afa_set_next_set(prev_set, set->kvdl_index, - extack); + err = mlxsw_afa_set_next_set(prev_set, set->kvdl_index, + extack); + if (err) + return err; set = prev_set; } } while (prev_set); @@ -1346,6 +1359,8 @@ int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block, if (IS_ERR(act)) return PTR_ERR(act); + + block->cur_set->has_trap_fwd = true; mlxsw_afa_trap_pack(act, MLXSW_AFA_TRAP_TRAP_ACTION_TRAP, MLXSW_AFA_TRAP_FORWARD_ACTION_FORWARD, trap_id); return 0; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index d74fc7ff8083..6067a049dcf2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -940,6 +940,7 @@ int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei, const struct flow_action_cookie *fa_cookie, struct netlink_ext_ack *extack); int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei); +int mlxsw_sp_acl_rulei_act_trap_fwd(struct mlxsw_sp_acl_rule_info *rulei); int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_rule_info *rulei, struct mlxsw_sp_flow_block *block, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c index b9c4c1feba6d..6f7913424bd9 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c @@ -401,6 +401,12 @@ int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei) MLXSW_TRAP_ID_ACL0); } +int mlxsw_sp_acl_rulei_act_trap_fwd(struct mlxsw_sp_acl_rule_info *rulei) +{ + return mlxsw_afa_block_append_trap_and_forward(rulei->act_block, + MLXSW_TRAP_ID_ACL3); +} + int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_rule_info *rulei, struct net_device *out_dev, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c index 936788f741dd..1f52ea7ba202 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c @@ -86,6 +86,13 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, return err; } break; + case FLOW_ACTION_TRAP_FWD: + err = mlxsw_sp_acl_rulei_act_trap_fwd(rulei); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Cannot append trap_fwd action"); + return err; + } + break; case FLOW_ACTION_GOTO: { u32 chain_index = act->chain_index; struct mlxsw_sp_acl_ruleset *ruleset; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c index 26d01adbedad..504fb7440a1f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c @@ -1154,6 +1154,14 @@ static const struct mlxsw_sp_trap_item mlxsw_sp_trap_items_arr[] = { false), }, }, + { + .trap = MLXSW_SP_TRAP_CONTROL(FLOW_ACTION_TRAP_FWD, + ACL_TRAP, MIRROR), + .listeners_arr = { + MLXSW_SP_RXL_L3_MARK(ACL3, FLOW_LOGGING, MIRROR_TO_CPU, + false), + }, + }, { .trap = MLXSW_SP_TRAP_DROP(BLACKHOLE_NEXTHOP, L3_DROPS), .listeners_arr = { diff --git a/drivers/net/ethernet/mellanox/mlxsw/trap.h b/drivers/net/ethernet/mellanox/mlxsw/trap.h index 9e070ab3ed76..5271d7ad092a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/trap.h +++ b/drivers/net/ethernet/mellanox/mlxsw/trap.h @@ -108,6 +108,8 @@ enum { MLXSW_TRAP_ID_ACL2 = 0x1C2, MLXSW_TRAP_ID_DISCARD_INGRESS_ACL = 0x1C3, MLXSW_TRAP_ID_DISCARD_EGRESS_ACL = 0x1C4, + /* Packets trapped due to FLOW_ACTION_TRAP_FWD. */ + MLXSW_TRAP_ID_ACL3 = 0x1C5, MLXSW_TRAP_ID_MIRROR_SESSION0 = 0x220, MLXSW_TRAP_ID_MIRROR_SESSION1 = 0x221, MLXSW_TRAP_ID_MIRROR_SESSION2 = 0x222, From patchwork Thu Apr 8 13:38:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 12191133 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4CFFC433ED for ; Thu, 8 Apr 2021 13:40:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F270610FA for ; Thu, 8 Apr 2021 13:40:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231804AbhDHNkc (ORCPT ); Thu, 8 Apr 2021 09:40:32 -0400 Received: from mail-dm6nam12on2054.outbound.protection.outlook.com ([40.107.243.54]:5014 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231767AbhDHNk0 (ORCPT ); Thu, 8 Apr 2021 09:40:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VNHNz2m8OT3svbiJlmR2mhsVypLqNQca9awGcgYjqeONDL9I3BOYDSCt0oUaXZSTVi3LwBXGcNUNV5aRVsezjDc9LJnOyBmKnOTCL/0to70vZf8oRtExDRjdfRsWsfiCAXmL+ZDly0REGb1cdDyzDWZHnXF2cGBRQaDLx+V67nH//2ss32NjUnGrKYV2N1OxXiK/1NCVAmBsVLRJA/ElPG0nlBx1jhbxG2d1nuBdEUdQmHjNJDwz+9XEGN/Q9kmNqbIlcUGJF8cTjLeLHvVyBylG60pFLmcgMn640YuCcFY1mjt6Ar9s+PQoWjmMkxbf9QEpc5yMrtza/xaDBock4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I+QU0NrVZaIIzHWl/S46NG+dZyFfqLtgB+gKxaidfuM=; b=PBu5f/dPOJDLYXHWKC5lSurJCPWk171PzUIwWti/qZk6w0V7XBWspxa9vzB2wQSFc15WT5lEIwMP4exvOEF5qqsjdjCzjyc7JEz0kWnCU1/0f7hnPMMnShz8NM+V8v/rB0slHTDgv8Y2Y9c+9KvL85J4KXc2yMOcC2RKXjWIjIMXCyBUZpOfRavK3tkax+kHjFOyvYxd/pAIc++jDLYjfYe3IDs27TcJOVI3/WisrW4rFLPFlrbEvZgsGEsurRp/5P5EDS4eIMVqvJWa8IgyysQKwAWSx56bwYB2wOJYWP01xw+Cx5Qd0iMcyBPEYGnSfymUeRy4CGI3ntyj2/3cHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I+QU0NrVZaIIzHWl/S46NG+dZyFfqLtgB+gKxaidfuM=; b=WtHMpDWkcp5uVQ4Js083wKgK7/kjFVZNfKGme96GQvS4t8mwdUPoTXvP5qyhMAKwEXrkaYMeYk8Y6SZma6xd1B5ZVMigSraukaGZJIW8HdlPur8Dmz749jvGy8RpL/q7YqZ5gPjqZCoqA0HiKkMDRzJ7vc4emzJ9XPUNyt6xM1d5oADr3CVqAlpyTjf5HOBQb5l4Gznodgw7AGOfDazcvIgSsie30sJP4/VhMVrYRhhyGJIKRXzhe6cTS9q9vHodk0o1XkKnwFnS1SZg0FaeC8l47wTh4kOosdEAqDeZhmgcUOzuuAPm1oSOrWMb4uZVEJIydbMsjLuXmH9Aabm9dw== Received: from BN6PR19CA0051.namprd19.prod.outlook.com (2603:10b6:404:e3::13) by BL0PR12MB2403.namprd12.prod.outlook.com (2603:10b6:207:40::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.32; Thu, 8 Apr 2021 13:40:13 +0000 Received: from BN8NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:404:e3:cafe::b2) by BN6PR19CA0051.outlook.office365.com (2603:10b6:404:e3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21 via Frontend Transport; Thu, 8 Apr 2021 13:40:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT006.mail.protection.outlook.com (10.13.177.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 13:40:13 +0000 Received: from localhost.localdomain (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 8 Apr 2021 13:40:09 +0000 From: Petr Machata To: CC: Petr Machata , Jiri Pirko , "David S. Miller" , Jakub Kicinski , Ido Schimmel , Cong Wang , Jamal Hadi Salim Subject: [PATCH net-next 6/7] selftests: forwarding: Add a test for TC trapping behavior Date: Thu, 8 Apr 2021 15:38:28 +0200 Message-ID: <20210408133829.2135103-7-petrm@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210408133829.2135103-1-petrm@nvidia.com> References: <20210408133829.2135103-1-petrm@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a244aca8-4419-477f-dbf8-08d8fa93d637 X-MS-TrafficTypeDiagnostic: BL0PR12MB2403: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WYppZ1lUPss7hhbws4vKptoPHBEglDKY/b1sKH+TImYV7aUdFvHMDqN7SIkxk/gJgyzhJHMG9nXZN/xRRBJ5EyT4QxXkleZefjrkc4MVOakzQp4I6toU6w74RXbeU3I70s13xKt77r+CkNyDAjIWjWOlIR2iWWN1G+XAZbaUN4vj0WZimHZYctlz3d+sAMoOIBRTvresZTyZdii9CiNVGR3azRPY52Vg7jk7hV9BDfGDuEd5yiPSfyd7AWnOibnfdor9hD0Y4j6JozqjKXRUbinWWaGKhTDUdAp3Q3lBpK5vBMObG3FRWjgK9Jn2NssdLKDqRv7Xek8UvdIk0IaxYiwGhW0DlwQbWE23Zyibn8y6liP7BrghqdLS/l2UMXt1kQ2W88NUYqLotI2Q6oCpqqZSuIl5B8RrUCaLZCY/si8bq79aTQmojjsgZ4dvmuRD7u/36AXHVfiOPocoI00wNqSgoaSVDv1V8HciCM4bHm4V8yqtmGKYQTZc3RmWP56s0H5qmAldsjYqJfw1ThDUJaHIa1fpbTE1VeZiTUxQe87pQ2b632o8C7AOSgQww/1xiAeFZCM9CuphHZkq4nNWAZtkoe3ELepSkq6lNNG2+q+k7SUmWgzsph3ZUOAMysPD/7UhoxiiUZUCfgLlZaZeLQ== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(346002)(376002)(39860400002)(136003)(396003)(46966006)(36840700001)(316002)(2906002)(47076005)(36906005)(36756003)(36860700001)(186003)(4326008)(6666004)(1076003)(8676002)(82310400003)(8936002)(16526019)(54906003)(70206006)(83380400001)(70586007)(336012)(2616005)(6916009)(7636003)(356005)(26005)(86362001)(5660300002)(478600001)(82740400003)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 13:40:13.2207 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a244aca8-4419-477f-dbf8-08d8fa93d637 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2403 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Test that trapped packets are forwarded through the SW datapath, whereas trap_fwd'd ones are not (but are forwarded through HW datapath). For completeness' sake, also test that "pass" (i.e. lack of trapping) simply forwards the packets in the HW datapath. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../selftests/net/forwarding/tc_trap.sh | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/tc_trap.sh diff --git a/tools/testing/selftests/net/forwarding/tc_trap.sh b/tools/testing/selftests/net/forwarding/tc_trap.sh new file mode 100755 index 000000000000..56336cea45a2 --- /dev/null +++ b/tools/testing/selftests/net/forwarding/tc_trap.sh @@ -0,0 +1,170 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# In the following simple routing scenario, put SW datapath packet probes on +# $swp1, $swp2 and $h2. Always expect packets to arrive at $h2. Depending on +# whether, in the HW datapath, $swp1 lets packets pass, traps them, or +# traps_forwards them, $swp1 and $swp2 probes are expected to give different +# results. +# +# +----------------------+ +----------------------+ +# | H1 | | H2 | +# | + $h1 | | $h2 + | +# | | 192.0.2.1/28 | | 192.0.2.18/28 | | +# +----|-----------------+ +----------------|-----+ +# | | +# +----|----------------------------------------------------------------|-----+ +# | SW | | | +# | + $swp1 $swp2 + | +# | 192.0.2.2/28 192.0.2.17/28 | +# +---------------------------------------------------------------------------+ + + +ALL_TESTS=" + no_trap_test + trap_fwd_test + trap_test +" + +NUM_NETIFS=4 +source lib.sh +source tc_common.sh + +h1_create() +{ + simple_if_init $h1 192.0.2.1/28 + ip route add vrf v$h1 192.0.2.16/28 via 192.0.2.2 +} + +h1_destroy() +{ + ip route del vrf v$h1 192.0.2.16/28 via 192.0.2.2 + simple_if_fini $h1 192.0.2.1/28 +} + +h2_create() +{ + simple_if_init $h2 192.0.2.18/28 + ip route add vrf v$h2 192.0.2.0/28 via 192.0.2.17 + tc qdisc add dev $h2 clsact +} + +h2_destroy() +{ + tc qdisc del dev $h2 clsact + ip route del vrf v$h2 192.0.2.0/28 via 192.0.2.17 + simple_if_fini $h2 192.0.2.18/28 +} + +switch_create() +{ + simple_if_init $swp1 192.0.2.2/28 + __simple_if_init $swp2 v$swp1 192.0.2.17/28 + + tc qdisc add dev $swp1 clsact + tc qdisc add dev $swp2 clsact +} + +switch_destroy() +{ + tc qdisc del dev $swp2 clsact + tc qdisc del dev $swp1 clsact + + __simple_if_fini $swp2 192.0.2.17/28 + simple_if_fini $swp1 192.0.2.2/28 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + swp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + vrf_prepare + forwarding_enable + + h1_create + h2_create + switch_create +} + +cleanup() +{ + pre_cleanup + + switch_destroy + h2_destroy + h1_destroy + + forwarding_restore + vrf_cleanup +} + +__test() +{ + local action=$1; shift + local ingress_should_fail=$1; shift + local egress_should_fail=$1; shift + + tc filter add dev $swp1 ingress protocol ip pref 2 handle 101 \ + flower skip_sw dst_ip 192.0.2.18 action $action + tc filter add dev $swp1 ingress protocol ip pref 1 handle 102 \ + flower skip_hw dst_ip 192.0.2.18 action pass + tc filter add dev $swp2 egress protocol ip pref 1 handle 103 \ + flower skip_hw dst_ip 192.0.2.18 action pass + tc filter add dev $h2 ingress protocol ip pref 1 handle 104 \ + flower dst_ip 192.0.2.18 action drop + + RET=0 + + $MZ $h1 -c 1 -p 64 -a $(mac_get $h1) -b $(mac_get $swp1) \ + -A 192.0.2.1 -B 192.0.2.18 -q -t ip + + tc_check_packets "dev $swp1 ingress" 102 1 + check_err_fail $ingress_should_fail $? "ingress should_fail $ingress_should_fail" + + tc_check_packets "dev $swp2 egress" 103 1 + check_err_fail $egress_should_fail $? "egress should_fail $egress_should_fail" + + tc_check_packets "dev $h2 ingress" 104 1 + check_err $? "Did not see the packet on host" + + log_test "$action test" + + tc filter del dev $h2 ingress protocol ip pref 1 handle 104 flower + tc filter del dev $swp2 egress protocol ip pref 1 handle 103 flower + tc filter del dev $swp1 ingress protocol ip pref 1 handle 102 flower + tc filter del dev $swp1 ingress protocol ip pref 2 handle 101 flower +} + +no_trap_test() +{ + __test pass 1 1 +} + +trap_fwd_test() +{ + __test trap_fwd 0 1 +} + +trap_test() +{ + __test trap 0 0 +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +if ! tc_offload_check; then + check_err 1 "Could not test offloaded functionality" + log_test "offloaded tc_trap test" + exit +fi + +tests_run + +exit $EXIT_STATUS From patchwork Thu Apr 8 13:38:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 12191135 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 169E8C433B4 for ; Thu, 8 Apr 2021 13:40:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C37D561130 for ; Thu, 8 Apr 2021 13:40:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231802AbhDHNkj (ORCPT ); Thu, 8 Apr 2021 09:40:39 -0400 Received: from mail-bn8nam12on2081.outbound.protection.outlook.com ([40.107.237.81]:65025 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231801AbhDHNka (ORCPT ); Thu, 8 Apr 2021 09:40:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aUjdxAx7yfg+8PSRd7HgmSFN0IlcL6QR1FCx9w3PsDGamDodaRuycSOP4cdo9cNyuIYZVbXas/iHHffPhpw5xK5FwWzSgjQeNsd+iRNEDLpt1MuzB6XQixypS6Gb8RWF/MeIcNyXv6Vl7V7cGyzUfU+8qS8zrlp74IAxD1NV0tj9JWkdUbfFL0O6JAAjHZmU8k3lTEgP96gCKN0IV4vSIhBiEgufjnOJOM6WoEr1Ohhd2YNkTDYBOZMpWdoR8AodoKZ7jRk/HYWFkqJYbMbH2+xQAZMBzzGNRDqbDLq1PpS8wrzb1s7J+cGygOCqVY6qf03swyXdbLKu3BtLsKBfvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yWa2gCulQOfxI5FLqJx9L7x42e7BhwVM22eMRXQOZwA=; b=JKd/oB2hAG4koIjhKB7PJyHHDbrP8VF5YSbtadED2lFavuluis4kUYN1fC1kG8LU4ZEmkBjj1HV/TpwxcYS7H8W2W8fdEwbmygc9bZJloba4q+uj2OUFnYyUMG2LHGRHl8UyS0fWFS8etqDRZWd4bDwPq/DY1SmNW8SqBwQtcg+ocUlKrhOFhruAPJopuW+CsZqebJomSXVF+HoHaiVnQPORS/tZFc/wllGAF33G/C4VPK790b+2+7ZNgYOv/gAcat/a9hvef4Ln8V2DBjYopac7XESYUbLmerVKRwuqW/7bV2JVHAiCUpNisWo+FCsFABkAhpVATEnKsFNLnqDvlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yWa2gCulQOfxI5FLqJx9L7x42e7BhwVM22eMRXQOZwA=; b=cQhtN6vPfzh61w9rX8dfzVUnrdjpBtepoduaPxPz05KaZDBfNePx1Ve68MrmioAZ4hNiWKEFZ1287XzFiB1iL71CBy/W8QyjcruNmk08mUzeUR0FFvOCl4lr7/BlteSGWKlvxNaK51vK1AS40dV9b+FZwxCyDBMOd7D7LIBAd14jzxm/DSUCtBuaw4OrCmuzVIy4NkkgChmd640/FD2YjSs/fx0skgLaDN5+D0NM3v+meG8UCs+SS7eRG7rWqfpKjgfjFPqOxfjhJybcWMQg9VaQKJLLT3SdNBNRtABLlJLufVmWB4hS9/sD3QfO0OEJ1Lc7C20AR0fc6ISixsdBFw== Received: from BN0PR03CA0029.namprd03.prod.outlook.com (2603:10b6:408:e6::34) by MWHPR12MB1773.namprd12.prod.outlook.com (2603:10b6:300:10d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17; Thu, 8 Apr 2021 13:40:17 +0000 Received: from BN8NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e6:cafe::c8) by BN0PR03CA0029.outlook.office365.com (2603:10b6:408:e6::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Thu, 8 Apr 2021 13:40:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT054.mail.protection.outlook.com (10.13.177.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 13:40:17 +0000 Received: from localhost.localdomain (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 8 Apr 2021 13:40:13 +0000 From: Petr Machata To: CC: Petr Machata , Jiri Pirko , "David S. Miller" , Jakub Kicinski , Ido Schimmel , Cong Wang , Jamal Hadi Salim Subject: [PATCH net-next 7/7] selftests: mlxsw: Add a trap_fwd test to devlink_trap_control Date: Thu, 8 Apr 2021 15:38:29 +0200 Message-ID: <20210408133829.2135103-8-petrm@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210408133829.2135103-1-petrm@nvidia.com> References: <20210408133829.2135103-1-petrm@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e610f09-aef9-41b2-643a-08d8fa93d8b1 X-MS-TrafficTypeDiagnostic: MWHPR12MB1773: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:741; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mWqakO4vwfOsX73dHwyH/gScqjK5JVGidXtBmqbQGxrPsHMJEF1C+WHpAad2qjmWrCHxC9n8tSLtkqoXzg9sFf70j/Yp8mkK+iIIOy3ZE4GMP3GgozIcux1mHLdTtJ3FaL6NxKDXXkp6PTwOVjSeRm07pO/Vjoq3CqSRy/JxuVsa5JV9x3YjWMWu9S7rdO7R6r3lc2CcYqfnms08vCCge4q2yD717z7lrhv/iLxyVUqaFSLs0bW7SuXNTdwz5Kw3Cl2HdfGtH4L1mpvf4+T/1XHhVYXo1ArwA0FaNZnNCvvoSp01px3Xb+Bm7UVAfLuKxEu8Zts/HQoh3PTPFcnU6p38YtEEL8hZ7gWWnfs35Gbfoumxj9sV5InxKao2xQSvD6rvxri8+lKM/wIEbp9fT902jM11nEQXQRWRqJodfKqpecgy6dLimbnoD2jzfG2dcKA2i2E0dW/fwZ2EZzWqsY3BfUaRo6hyczVt70uuSC3YY1XAqI8WHJkPfY9QTQO6hRm8Q0pkE6AOUHcpbe4BzVjTDQoo+eT1Yn4ffecmS4F54WUOileIxXtcgLkz/B/bcfhdCEXXtEzj7wQAM2iLk7dKy50ics9NgFF/SXsbam2Du4jORbkNosHcGVhyizahhi9ynfo2zyNrhlGk2sP1hg== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(39860400002)(136003)(376002)(346002)(36840700001)(46966006)(70206006)(186003)(7636003)(5660300002)(26005)(6666004)(356005)(70586007)(16526019)(82740400003)(36756003)(1076003)(36860700001)(316002)(54906003)(6916009)(36906005)(47076005)(426003)(4326008)(8676002)(83380400001)(478600001)(8936002)(2906002)(336012)(86362001)(82310400003)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 13:40:17.3816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e610f09-aef9-41b2-643a-08d8fa93d8b1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1773 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Test that trap_fwd'd packets show up under the correct trap. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../drivers/net/mlxsw/devlink_trap_control.sh | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_control.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_control.sh index a37273473c1b..8bca4c58819b 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_control.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_control.sh @@ -83,6 +83,7 @@ ALL_TESTS=" ptp_general_test flow_action_sample_test flow_action_trap_test + flow_action_trap_fwd_test " NUM_NETIFS=4 source $lib_dir/lib.sh @@ -663,14 +664,18 @@ flow_action_sample_test() tc qdisc del dev $rp1 clsact } -flow_action_trap_test() +__flow_action_trap_test() { + local action=$1; shift + local trap=$1; shift + local description=$1; shift + # Install a filter that traps a specific flow. tc qdisc add dev $rp1 clsact tc filter add dev $rp1 ingress proto ip pref 1 handle 101 flower \ - skip_sw ip_proto udp src_port 12345 dst_port 54321 action trap + skip_sw ip_proto udp src_port 12345 dst_port 54321 action $action - devlink_trap_stats_test "Flow Trapping (Logging)" "flow_action_trap" \ + devlink_trap_stats_test "$description" $trap \ $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \ -A 192.0.2.1 -B 198.51.100.1 -t udp sp=12345,dp=54321 -p 100 -q @@ -678,6 +683,18 @@ flow_action_trap_test() tc qdisc del dev $rp1 clsact } +flow_action_trap_test() +{ + __flow_action_trap_test trap flow_action_trap \ + "Flow Trapping (Logging)" +} + +flow_action_trap_fwd_test() +{ + __flow_action_trap_test trap_fwd flow_action_trap_fwd \ + "Flow Trap-and-forwarding (Logging)" +} + trap cleanup EXIT setup_prepare