From patchwork Thu Oct 28 11:06:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12589841 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C90AC433EF for ; Thu, 28 Oct 2021 11:07:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DBCC60551 for ; Thu, 28 Oct 2021 11:07:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230162AbhJ1LJg (ORCPT ); Thu, 28 Oct 2021 07:09:36 -0400 Received: from mail-dm6nam10on2099.outbound.protection.outlook.com ([40.107.93.99]:59585 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230195AbhJ1LJe (ORCPT ); Thu, 28 Oct 2021 07:09:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UCamKz/6lVvrAG7D+RC0od3sk2D8X41jk/bNErLNyRb7SZ24QAlzEZGO0y8oSHlpuGLUDZNaiCt1YmcFiswapQlgOV2FcRKCGTc9f083qeAceeovckHmB54oyNXhD0dY+zajM/ESbuehWWfm7LI860aWH84MmB5CIY978FX2QJHfCD57O9GRcc/SZfOgDIUBR+CiijJiiv+MzW27zKjdKk/pGkbxN6li1fCPtliy+hkAbhD1JTYUG29SD1t9L2u5169dtrJgcWFjHm2wyZyC+3uQb4P/CfpxCjnZa8ILG7+prhobGYxvfixo8/VihMysYHT8l/7lOG+4x20El+siUg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sRp1HCPVPqPJU3OHFquMchwhifHi9LhY7LZW7gk03f4=; b=C8wGqFlqRemVCTaTjpLqI14x3glfmP77tegE9mJfk1WLKl/k1VQs68+4kmLbAz2mirA1EO5d/ZZGKT1rIqrS8KeoYQhXBlyBrsZinz5JQ3r5DAKtn/gZ8P4h+4Qe54ATE1L/OcYmiRYRRvX2rG6H8zZa+cPDJ6vIJmdUhNddbLjMrAzi/KaJSP+56euhl8qcHtlLvmoV8yFU18MgJbQsToS/ZM8LdGGRpa2g3hQ/RA0kV5vqogYHlYsqvdf0yFtQp+hqeMwfhdpx/y1oahWpR8/NWpivWRmOs7KQ1RdJ9wMWFTjeR7Pv71ii9B00fHHJdOYp/e1GWsvYd+PkHb3+Mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sRp1HCPVPqPJU3OHFquMchwhifHi9LhY7LZW7gk03f4=; b=gKsJRhbKEDyP52/JCK6eqQpVRr+EFXcAWIz2Zb5WAH03iKx6RnRq7vWTajfGlaVAqdWWhXh8u2W0HGgBT3yJS7VZJTeto1G2bG++qnlyM0UxmXSoPCUJrT1S1PY4S6yEP8zbkEHZ/mL04Iubu6DkAzgkLvm2YL+cNJxJtRJZaog= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB5764.namprd13.prod.outlook.com (2603:10b6:510:11b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13; Thu, 28 Oct 2021 11:07:06 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90%9]) with mapi id 15.20.4669.005; Thu, 28 Oct 2021 11:07:06 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Vlad Buslov , Jamal Hadi Salim , Roi Dayan , Ido Schimmel , Cong Wang , Jiri Pirko , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Baowen Zheng , Simon Horman Subject: [RFC/PATCH net-next v3 1/8] flow_offload: fill flags to action structure Date: Thu, 28 Oct 2021 13:06:39 +0200 Message-Id: <20211028110646.13791-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211028110646.13791-1-simon.horman@corigine.com> References: <20211028110646.13791-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:07:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 19086274-032d-400f-d406-08d99a031424 X-MS-TrafficTypeDiagnostic: PH0PR13MB5764: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:179; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J8f+mhLLJ0Ib2AJy7iTlM2BrVJuFdtJ+A95AA2ztisXdS2xpCYzS9b9JPwgRWyyJCLe/xrzjThbBpjRncNaKkvbSbcj8K2edoSsBroqB2WSknOmjpTSW7GzLjk1OQVmuH4CnmPn4cHCnC2cfYuN3Gbw6ZmB6QPaz17bDUqN/TrVy8fQwu8imYcjiPrdb/RHnqUBDd8nVHVO2VdpBW809BkHiAdSOQi3QudW+LnctUem90JMLi/fXUookQp08NW/c9BWddnwsYpU+LgFlL+GQua7g7mGSHVmiIESlSD0fGiNkyM6bdn7ae2Z+xTCL2u5O/Uc0h4QxpTH/MZsntq8H5Z0Isq9aPdtnrNqsMxHYeTbkfGyOr+a9eMU8HsDzNKfIyqPLVhpyyNfQq1MQ878N5vHvYg/+OCumzaXEHofRpWDtBP8fopnWaojKxSAoonCN0xU1VnzUoOxeldQiDyRCcpjkBTpJ8WUGtDhSa6gua5FkaHM7c0yShnL7YLT7/eYpe3YFbyw1vqxwgw/ovLwGXzuXeWM7o3U1L4TyM+6LBhQWD/7+NIBzyv80WiaYmDcs7NkZym+yKu5HBvuxU44XxNur+wLZIkWC0ZcZXT/b6B1buUmTQQr202jjAmaWbGxXK5YBr1xhlAKp7x5BypDNcw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(136003)(366004)(376002)(346002)(39840400004)(6916009)(6486002)(83380400001)(6506007)(4326008)(5660300002)(1076003)(6666004)(86362001)(52116002)(44832011)(186003)(36756003)(8676002)(508600001)(38100700002)(107886003)(316002)(66556008)(66946007)(54906003)(6512007)(66476007)(2906002)(8936002)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Q9S3LFNX1WfIxbcsDX8ZdA6JBUiwLoVA7KgW9Rb05JI48vBEQUeslqEfiaiT9B13cpd5jbZDAIp8piQrSxJevueA+SELEBXVghp6hVeBowy93tNcHbWNUnkRMAC1PFSr0OizU3LJkOGo/pJCdORGkt/vSzqj46ybzPHTWXt9ikDQwtu1SnXE5g2d5Xuvi9AgQt4dAcmBzZ87UIKLYHZni7FKb1hZa7n4hNsgxaHz/bL7MRmriL3YwilIxpklRvXCfcSaqLyqy3SIMC5yvqbjZWJmsuh4HfC8gG9fDyHgeYTRUPA3fdGERbEvwix/ikhj+RkawJx3C0xQqaj4egEcCweelJannHhBXaLakQdyUw/68bUWOCd5/fH89h6p+nAMRxyZkMs7x19waJiNo0NSNO9yLxWszIGMk3PfzQoKilACfKlNooucq9XOdUiTLB2hKOd6jBJaM2Ly9SUJ7juFBo5+CU6uIvIMsov6uh1MosMXl9ChhTvdKSNzvWYgbJ7uvbKRQHIa1PRe6Bet9OmUn8QeXA4X7Ysj5eaCqONZSihtChlPnWTrwM5eivc8N9tU8Blfb5/Vq7IeCu8De/0U3C6C4m/Cwt6P6+xmVrVDApUC8uQp5LKdu0yZw8hIhboT+OOFz/ueyh2sF2F2dHrHpL0pLEW06Mj5vdwgVExSznW/8OVQHbNo+s5HEzFVH8856n/6LqVIxFBAPlGRLydoUEfBd0Dx697xaZuP+IT9Mt6R8sL1ah9VJI+UXbHqEhOyGUID5t2lrqDpYTEillM4IRC/01h0LN0nGyQ+Ov8AloOL3XbUQ0wMDFa0yQrRCy9U9Hio+kAPz9N+ovKgDoqbt33WziylvpZyQj5M0xPXrP9UQ8Qcybf5gy9IRbv4KWNp0JcVb9MOfY4oqQuagsNh4uWROMa3vX6rMI82YB0FrWYW8750BGU9qIzRHDckJGdUJ4ZDJYsX83rOQn3NeYvZv6R9KEDktMB7aVr5wtIG1uuUZNUD4WguxnTXIProIsDlJ3F3Eth+G0dXwb+Q4QmgQ1GttOjEpY73Inushuq5V7ke9s+cUlWak1mXZpVsRpooSq4qp/ttE9BokmqlYtkEMaNBi5iqR0jCvwZKFNWvnSS8kW0qGe6L4wqCGp8nOS4KRDVKprxEjs7RiMYpIwDYXdy1aOjYglhgTT3pJFA5ESC0a13kRgNUkK9EUu1aOSC2pX5BfLCOE+rQfLY24nc9Jk8tXT3KoDtzL4NmqXk8mFsot8hEcElMXqRFbH1BXj12JGQN94JiWBCw6wNPOAC650eOCw/B/B17HR+J5S5ewsm0QVLGYne067Lzx3qYZTssseNJr/7Qi2MrkVfxn92VFvezdGOU8P8CNrdvv07bd0nQQ3SprTYe7TXgtqkDstHo9yV3JJzT85W21CVd+ecUAQjOj2sibHqt7RRIUI9NGhnoAXdvOOUjhdBns3LiIoW4Hy00Of5B7Wqk+yhH2OgtM1gWP+RjRa2x3C/hTAfwxNDr2Q7i1rh8CZvvrDwi0vwb0NPT4alK4lCJXv9FB9G/EpPMFWRx+WDpIT9IBy7M1J7D0ey+vvKo7zJ2m3g0gnRkHd3fDFLAhiJEZGU3toBkYAdutiabJIs2MA3tP0F90ZRYKGTmgFtwnBjfp3yytPz1j3aeB2l2pcw9GR98C/uM49tI9Q7eBlQFv/gnR2iVbkP66R4kV0O5HcBh9XwTGYpC5p0UWKT6haYkj2gricSdeYK7qwSYP2qtOZ9PNVzM4hs= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19086274-032d-400f-d406-08d99a031424 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:07:06.5303 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yVgm5zLrrVjThyqAQmE2Nv1U6GdC9DSp3FEe23dO5e1FLrgUDWuOJaPik5k8X0WfvyhHsJXsLirmy1pKX5ExUA9UMjoFQ7mGoB1uVFOMlgY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5764 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Baowen Zheng Fill flags to action structure to allow user control if the action should be offloaded to hardware or not. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- net/sched/act_bpf.c | 2 +- net/sched/act_connmark.c | 2 +- net/sched/act_ctinfo.c | 2 +- net/sched/act_gate.c | 2 +- net/sched/act_ife.c | 2 +- net/sched/act_ipt.c | 2 +- net/sched/act_mpls.c | 2 +- net/sched/act_nat.c | 2 +- net/sched/act_pedit.c | 2 +- net/sched/act_police.c | 2 +- net/sched/act_sample.c | 2 +- net/sched/act_simple.c | 2 +- net/sched/act_skbedit.c | 2 +- net/sched/act_skbmod.c | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index f2bf896331a5..a77d8908e737 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c @@ -305,7 +305,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, ret = tcf_idr_check_alloc(tn, &index, act, bind); if (!ret) { ret = tcf_idr_create(tn, index, est, act, - &act_bpf_ops, bind, true, 0); + &act_bpf_ops, bind, true, flags); if (ret < 0) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_connmark.c b/net/sched/act_connmark.c index 94e78ac7a748..09e2aafc8943 100644 --- a/net/sched/act_connmark.c +++ b/net/sched/act_connmark.c @@ -124,7 +124,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, ret = tcf_idr_check_alloc(tn, &index, a, bind); if (!ret) { ret = tcf_idr_create(tn, index, est, a, - &act_connmark_ops, bind, false, 0); + &act_connmark_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c index 549374a2d008..0281e45987a4 100644 --- a/net/sched/act_ctinfo.c +++ b/net/sched/act_ctinfo.c @@ -212,7 +212,7 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_ctinfo_ops, bind, false, 0); + &act_ctinfo_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c index 7df72a4197a3..ac985c53ebaf 100644 --- a/net/sched/act_gate.c +++ b/net/sched/act_gate.c @@ -357,7 +357,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla, if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_gate_ops, bind, false, 0); + &act_gate_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index b757f90a2d58..41ba55e60b1b 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c @@ -553,7 +553,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, &act_ife_ops, - bind, true, 0); + bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); kfree(p); diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 265b1443e252..2f3d507c24a1 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c @@ -145,7 +145,7 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, ops, bind, - false, 0); + false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index 8faa4c58305e..2b30dc562743 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -248,7 +248,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_mpls_ops, bind, true, 0); + &act_mpls_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c index 7dd6b586ba7f..2a39b3729e84 100644 --- a/net/sched/act_nat.c +++ b/net/sched/act_nat.c @@ -61,7 +61,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_nat_ops, bind, false, 0); + &act_nat_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index c6c862c459cc..cd3b8aad3192 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -189,7 +189,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_pedit_ops, bind, false, 0); + &act_pedit_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); goto out_free; diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 9e77ba8401e5..c13a6245dfba 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -90,7 +90,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, NULL, a, - &act_police_ops, bind, true, 0); + &act_police_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index ce859b0e0deb..91a7a93d5f6a 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -70,7 +70,7 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_sample_ops, bind, true, 0); + &act_sample_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index e617ab4505ca..8c1d60bde93e 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c @@ -129,7 +129,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_simp_ops, bind, false, 0); + &act_simp_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index d30ecbfc8f84..cb2d10d3dcc0 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -176,7 +176,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_skbedit_ops, bind, true, 0); + &act_skbedit_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c index 9b6b52c5e24e..2083612d8780 100644 --- a/net/sched/act_skbmod.c +++ b/net/sched/act_skbmod.c @@ -168,7 +168,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_skbmod_ops, bind, true, 0); + &act_skbmod_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; From patchwork Thu Oct 28 11:06:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12589843 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6358C433F5 for ; Thu, 28 Oct 2021 11:07:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F44060F9C for ; Thu, 28 Oct 2021 11:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230210AbhJ1LJg (ORCPT ); Thu, 28 Oct 2021 07:09:36 -0400 Received: from mail-dm6nam10on2099.outbound.protection.outlook.com ([40.107.93.99]:59585 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230122AbhJ1LJg (ORCPT ); Thu, 28 Oct 2021 07:09:36 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PUE00h7lIlZzjxLl7qLYJjetYYwfs1rL7tdBoSCfUS7sTdpdrdyNJXEOFRDH3qkWvxdBnfuKok462tQoWeiLNHSJ3lDsDoOz8lvneI5U+2Lb9XLG2sXkqWGnHtJJ5GtLeRpSKMMMmkLZmgbFiDQ0LL7A5+/jeNbv6zwH4an9kEdqJy/oUKljJo4ABAwnrA0iOG5ltGJ5diyG40c3ez6mQ8/zvmiFM1ZhhUq3hIPlq8zbln69LjmPXtDrC9qAgqbOlX0Dji9l4bX4KK3FUa4au3BRijqE3CD85yu4BQqwIsyh/RCUKILtCTiGp4MYSKA+4nzy/ky8bpHggyPVdnY+2Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RL3jsd86yh7cTszKZmgqOIgBeWvug0WTIIC967M9t+U=; b=RGpwK9UkoF8W2ZLSN3o0iYPF5sBZWNAgL2LXSzS+6cKG0/BDlb2d4FXJ1Xt3OcJoPcORFrCx7bCtFCwybDn7NzdH5Yz0dBahymFLQUXsk9Y7XjIDq4kL56XKmkY1LFR0xuAtOFieFb7N8GXUfkK+uH3S7d+J1YrePsTVFaPuEnEXiI675cb6lmM9av3tMoh0RxB9e6Gc0bM3J4OOcDtwXL4PmE1JqEUWcV2KOR3etM/tGykOzV4F5CgK7mV5MXsHEMEhRiK+ErOXTPw62VhYlIVz8bLjxnm+KXm+4Uiza/T7OdEi2LIrG5ZMaR5E1c0TjEA1jyiA/AJu7W+Ibnq5/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RL3jsd86yh7cTszKZmgqOIgBeWvug0WTIIC967M9t+U=; b=Qr4AS+iDdQcQdEBnUExdcfDmasgY4aaQhpU5clkHbWjbTRGUK+42wrQQ/xxtBAkMrlvs4/VBoBWTb1NcV+zm7BwVJBqx/NwFpntbopXjOyVO1eY2tWow3fGEoRlzD7TTMKzVI7TKPAcfV7WGLbPyTQdq1I7MD2fYuN2AwCgyo+g= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB5764.namprd13.prod.outlook.com (2603:10b6:510:11b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13; Thu, 28 Oct 2021 11:07:08 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90%9]) with mapi id 15.20.4669.005; Thu, 28 Oct 2021 11:07:08 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Vlad Buslov , Jamal Hadi Salim , Roi Dayan , Ido Schimmel , Cong Wang , Jiri Pirko , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Baowen Zheng , Simon Horman Subject: [RFC/PATCH net-next v3 2/8] flow_offload: reject to offload tc actions in offload drivers Date: Thu, 28 Oct 2021 13:06:40 +0200 Message-Id: <20211028110646.13791-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211028110646.13791-1-simon.horman@corigine.com> References: <20211028110646.13791-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:07:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d85c85fd-c6ac-4f08-3d2a-08d99a031589 X-MS-TrafficTypeDiagnostic: PH0PR13MB5764: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dzf7Xut4kRM5mUnYVhQHo2L7T3+rgsdlffZcRr1dnw2nVJ61L7fdy2wyhg0U6PUYJMHEWaihRi3Ffq35ip4EuDqTZvYf3EQdqJN+9BlziGzisoU6s4RwXWh5TE21vAsu82V0r3Y77mla1UaPEtD2EWtCWAvaCxWGATogWkW3pkPKhalKZJtcVcAQQ9ghiANMJohJwW6+VbIqtIUyOgxJY8kv6n92oL2lZ1nbexQlP2TiTLk+zEZmLrdy0q1Hnw9pZu0Sw853HlwVbYBGwELAByKZ3ZvzN1fUP7JZ4UYLpj4pv9TjVCAZbilFwk52hCSwx7+iapNKWQk6h22jPLjaafg6eEI6UjlM3xz7iB0FXorH+Xg3CTg+7RNAUltJC0QFCMvwhiFZWmi9flc4XQ7fNKyd3R3KhxkbKJrRksk9L+fnOC4elW6vwbcxAF+xnAu8l/HPUtqZp3ThpfxWjIGbiqlZ/2HUKopojDfEVlUOfkIUVJBJ3qNY6cNib4sU3rbBPvhmxwdy/rah+lK/EA08fZLmfAEjLBS/e1yUxOreQAYiAfiqLwoe73UF8AirYjhFoOFx45yWe2utdXQNNUSkdrPeAr3hXD/4WghsCg74uQ2Xv9L/IQrJdVfBpD56wjSKNHwX0To4xZGYryCbeerujA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(39830400003)(136003)(366004)(376002)(346002)(6916009)(6486002)(83380400001)(6506007)(4326008)(5660300002)(1076003)(6666004)(86362001)(52116002)(44832011)(186003)(36756003)(8676002)(508600001)(38100700002)(107886003)(316002)(66556008)(66946007)(54906003)(6512007)(66476007)(2906002)(8936002)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uqTxCfnYD4mZiI6IOonTR3eQR9e1/Mu0zf6VdgaNtsX8SGE3apIIaxHOO8Hz1PluRww2JGWPj6x4tAAE23bEpOuL+ImMTsa9FXfPRZbN8PD4neX2BcsiE4Bua4+guXlZZ00W4+vL2TgPKRqhQuBuldC545SaYZjxzKnqFSTz8OgaxgERbux0ecccYR0dCunobBX6r+PsR1YNmijF5aAiXR5uYjdVNBKks2qoLW42Nw/Xe9gAOF6x8BrFWmbTARJzJbzQ1bJE1fZ04syzleSHltZxDtWFaI79NXvGLzSqfJX3zKo7iulnpqcHMB0J/Q57B4krFrBin4hdQQt08FXW+5crTGwVy9SlNLGzXGyuPBXIJoO0hoBgYuXpubOZLBfO2mWmCMqvyQClnxQ+dxDX7mFhFdexx8qWCJKOGssg0xNcM5sF8oWzr1pncrGg3leX6bKTM4VSVM4s2g3T44OQDgtwi4AtEkemxRiED8IufkqzInVm7rGQ29yxrMxUYEn999vy6A8sBjUqnzfiFQLieGKmHY9fwA4XHwDqlzaURDAWdYGjZewmlmnkOatM/IxjKgGKY9HzyCuBYGlGXHpZC1EjgUmOTMYU8XTEOGQr+I5uLq6X/fiHBE//VyD6YoPBWOBrm86X2mr6Gyd8dKfhqXv7ZQY2xIQ5Ekt61PqXFuGOcHuYecq47uEyacweFMRHs/10NrUhAlD8InwNvrZ1deTZxNp05Y2UtHCrQcakj7Er5kYALjjfPl4y1fj759PrgPjfUkxLJIyjFMZ+T91Pf8Ffo3VAxtTNaCHtNatXQIRa4B9C1ZDnp0GhQnfIxRcyM8qpyUaTyX8DmItlrErSU8dMhEhunDwkghHHhJ+R4Cus7NN/iIxleTcY6/y7MMGNUyjySXanUO22h7vB7bXODhMsFLXQnFYb462hj6v47o/QPnJi4if2euR8PuSsePe96Xx9XdgegF4BByA87SQJH73bzL/yDmPJ0BzPCF9lm6KYSaf9DZPCqNJyd2+wMzHbEgXCKEgYMdFeaW5PILAIF0i4bpIWoNLKSKAFxejUbv8p5rR4GNRR7e/MQxiq4ISk99kDiQkH3w1/l5AYQTXj7I1wsJYmAevvTQQloMQmSyL+nKvgQWdKOVvkOrNyx1EBwtQdFciK3WycNTEBDVMdwtXiePPLmgMTC75a1nwKMdZWHR3CkrR+hSk4iC+77Za8EoXq/p4+1WuqbqUi09a0gscKGspKLwa8Wv7THYEgec86TzdMoJdi2G0n0nVTbcPrtT56gGZFrlXHLZNf3XASOhPdas1rAQVzrbsoL9hcz4uGG3CXD5qjAF5wxR8SzYBbooQKbL0dGrsGrdtMPZojpwZrCo7yTbXQNiEnYkWWwySQZMxt4dZxQuFymIu5Fx6S2l0/ZjeSukXaF9dtb2/18Hcsh7VGr4TE1kTUWh8jMGxIeUk5v0tg0OCCYvE8tJKvdupMj1xbV1i4ZtJOzZx96V1uMysCx9E8nix6Q3aVDI/y4Qh5UGt4qnvkin6k6JX4IQQOuRFv04gH4ZegVK1haKG6SNAQfYNRwtpzuuYIwehFrMcqPs35AaoyaNKIsnkROCCwia45/Tly/42JE6fIhIc4Y+Uo1dvTY0j8CtLFfUEdefO2zCJ6+mrMd3uvlCMAh1UVScK6bbgs5vPAnBpfsA5xvI3MzWeUiTpGXD/DGy0woP0+LftYcZDBunX2fdZn4RmavNAFVRzvXoQ+wLx/ZG8zyRqkTxmUfeiB7cb1Kac= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: d85c85fd-c6ac-4f08-3d2a-08d99a031589 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:07:08.7407 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mELIMWbqhfZj5sw2jQmb+Escturp1JWYzLBobdODipG7Na2OQy1qwBVP8eKFeTuNzc+DC/YFATj9fvPG5PrMowZduPhzBlU58bLpXS2K8lE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5764 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Baowen Zheng A follow-up patch will allow users to offload tc actions independent of classifier in the software datapath. In preparation for this, teach all drivers that support offload of the flow tables to reject such configuration as currently none of them support it. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 3 +++ drivers/net/ethernet/netronome/nfp/flower/offload.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c index e6a4a768b10b..8c9bab932478 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c @@ -1962,7 +1962,7 @@ static int bnxt_tc_setup_indr_cb(struct net_device *netdev, struct Qdisc *sch, v void *data, void (*cleanup)(struct flow_block_cb *block_cb)) { - if (!bnxt_is_netdev_indr_offload(netdev)) + if (!netdev || !bnxt_is_netdev_indr_offload(netdev)) return -EOPNOTSUPP; switch (type) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c index 398c6761eeb3..5e69357df295 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c @@ -497,6 +497,9 @@ int mlx5e_rep_indr_setup_cb(struct net_device *netdev, struct Qdisc *sch, void * void *data, void (*cleanup)(struct flow_block_cb *block_cb)) { + if (!netdev) + return -EOPNOTSUPP; + switch (type) { case TC_SETUP_BLOCK: return mlx5e_rep_indr_setup_block(netdev, sch, cb_priv, type_data, diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 64c0ef57ad42..17190fe17a82 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -1867,6 +1867,9 @@ nfp_flower_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch, void * void *data, void (*cleanup)(struct flow_block_cb *block_cb)) { + if (!netdev) + return -EOPNOTSUPP; + if (!nfp_fl_is_netdev_to_offload(netdev)) return -EOPNOTSUPP; From patchwork Thu Oct 28 11:06:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12589845 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D043C433F5 for ; Thu, 28 Oct 2021 11:07:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EEA060E8B for ; Thu, 28 Oct 2021 11:07:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230215AbhJ1LJl (ORCPT ); Thu, 28 Oct 2021 07:09:41 -0400 Received: from mail-bn8nam11on2096.outbound.protection.outlook.com ([40.107.236.96]:56801 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230122AbhJ1LJk (ORCPT ); Thu, 28 Oct 2021 07:09:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SIUj2YHSXnz93vAfjGPqBo3752PqZEMRPKeQ9lFuDqzFDc1mZqzAbr2d9nYrX8DDqbE3jC9HiQRBWHxx7/Oo9kpMWgHQC/RPgmsIM1w4SUPnZB4kXH4/MKEmG2n+7mVfX6lXEW9zzy2cbp/OBKZqv5S66QnxHH9cmf8xGC2s2eu8O3MIVuyvADAe3cwGhdozKSWJUZSrGLHVNp0OvkMGCj/8zQUvak+b069EUgrNWmMwu7dOJTgQe74jPkY+fRWaNUD3QjvRl6a9M83Ha8yALFYfB3tfcNOpSWuaOv2yzAj0RhsXbm336Ko+yzor4X/Xb8V6RSLbblNSZ4uZ8sq/qg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b/4HxzwRVriw1LmBVCsT+NzQaHyqFiwP6yC3Vje4ia8=; b=hP04tIlpOxJYkr4RQ1RBEHlHRt2oKrqMRD/v4jQj9x7Rea4fM3p4QhqlLbBfC340LZGO9Sat4vzOWX0g5XVnZae/99OrKSNdZGjm8BU5rcW09obp8AqcnIh6LNnePX/Kj0mXqIZsIRTMnpBUeinB7ZPlZKsu7eic+ODyIIfv2IhtP4vMX/yeDw83MIxz2qbA9sb5rmSkcgRa2Xw6p9HUC4NTBx0sXleqWdClJkhs7Y6xEQAt1Vx1N9AZvjw5K2hmliRtHFHJv18tV4orRgpOM6Jns1gsWjXp1RPm6uY1qhNPB34D9k68zFSf5+ZHx1A0/lDdhA/ZG9DQeD4TU6T7DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b/4HxzwRVriw1LmBVCsT+NzQaHyqFiwP6yC3Vje4ia8=; b=tJe2YpCd+vq9siKe5BMvQqNqiRumg/VAo+CyibaDtJ2QS1MqalKHbpU0sPSNbmftCLHJm54eEIcxwpcucMQ5CEkkRyOkuit4dAMW4T/JMMjK2aSBzaeH9Qkdb3Vmivx76XrQ2/1bUIwu7beeW/XPVnjJwdhN9yo2IDteuVZdnVw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4956.namprd13.prod.outlook.com (2603:10b6:510:98::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.11; Thu, 28 Oct 2021 11:07:11 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90%9]) with mapi id 15.20.4669.005; Thu, 28 Oct 2021 11:07:11 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Vlad Buslov , Jamal Hadi Salim , Roi Dayan , Ido Schimmel , Cong Wang , Jiri Pirko , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Baowen Zheng , Simon Horman Subject: [RFC/PATCH net-next v3 3/8] flow_offload: allow user to offload tc action to net device Date: Thu, 28 Oct 2021 13:06:41 +0200 Message-Id: <20211028110646.13791-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211028110646.13791-1-simon.horman@corigine.com> References: <20211028110646.13791-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:07:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 760a5e69-6197-44b2-f016-08d99a0316dc X-MS-TrafficTypeDiagnostic: PH0PR13MB4956: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:565; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rmHY4syD3H2+8UduqGBuJc+A/dpsN/1azJ6nhaLPllvj8DrOWFB/OIE6YSrOXkfJzYaocd7CB6I3OnlHDZVSbEvWSNpTtZ3Oy/I7PXeZiX1gl85C50Vh3/sq3RF7ErsFC/i2aYEsiNcZGvaSn4UgaEZf2Mb5we1BlSp8jYwX10HFFgi1fQziYG5IgU6otz1u3o/JBFwwseT2RVsD1hP5Sn5Ap6YGoh1gb8akW+WRJbUut2m8goFk5DJH17xHBVSTlOsf5oBxGqs0fK8LZzQxHejqIqquffRPBVr/VwN+hFpuhfhiWMXu3oZoA0GRp0EDLvHfimEvWUym1afonM53pl0LFZZL89QpVJhrnGH1LcaPoHyeIjNfUYrJX6MhYTr9/f1tw1Fpg/kvv04A+93w9PtjsYgDqwgp9SHUydhmLnX4gprFcJ+Zxa4N5ji6cXfw2VPd95I3q6Z/Qn+Q3nG1/+hCRJp+daIJ4dA4eBTnzVLNWPTGqxDh5RCqihFUFDMQ2SAbTJhiX30P8BMCghT6jc5uMewxdoUGyLKO8ZaSXCMyWJ8PqeFLHDFLL32dC35X9sW427FMy69safmfRUvX3XscWl8tS4u/4cBAZYh/ZKdRPbZRGoXYA2Ou4gQ5A7gIzeZn3KLmqeam0gcSMNJoyA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39840400004)(396003)(4326008)(83380400001)(316002)(36756003)(54906003)(44832011)(6512007)(8676002)(2616005)(2906002)(5660300002)(8936002)(6666004)(52116002)(186003)(66476007)(107886003)(66556008)(6916009)(508600001)(6486002)(1076003)(66946007)(6506007)(86362001)(38100700002)(30864003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FQK6vsfSqWqDEWeHTgXKwC1u7JQ+vC41Sla8vSr12MBb+h3TaMiXod1U+rUPXRrhgakbcvwdWLl6jkDRPBy6YtPUm1vKAcM4se/mK6TJbfYACdcaCl7yqMRfi79TiroGk9d1N2UD8JtO1tjWhuOd20WvgS3Rcs08K0RU0qiCkbfCfONx8onQg6OK9rzoEeK7JmsQX5icNVDTAKXzMrSqcm3kkBlg2wm/zl9PFWSu8rMwds4Uobxdt5QQB+b+PfsYrBVks+AcWeGwfd/iNz0JB3wk3M9UeTkN/ec21bv7nmX618jIzbiN0rGIybgSiuE+1E5zTpaEw9lGc6B+1gUaqSgCwqZyUSHqWGDWNUh+mzyzqCw0ldhktFmiUOZT5kPxRWr1SaRPrSa4VKXbI9nCDdBKVNhCGBIH5Exf+XjC7Cl4iKvuHjIb9n3JX90C2dCfC0MRUhwLNz/RrDEzL8lZ+GZuxtOrHZ1CBQVQiuIUzdwnueYkcNMP7sDWkZVqVpge25xkomy5V6nBizFWbSNBRapIiEJlQ5gCnidA9VxTp9NJKZZBawTKmcZNzqOn+7igcYGOgkg7B6UoBfEM0InUfX4q7qrsNU91Rx8FfOR3nHtzsCeXHZPocfCmM7K/MMbGaewbKjSOXKf+XJJyzWVEV+becFig2+gEIJzhry+DkMKGhu5UiC//kXILWzbGSZZcKdJQ5CDTCKKTDlqxEdpy/BaGKuHkhP8wmNZjoiI8HvahzpzwiOz/JCa4tAJ0Rtesw2oqrHykdKY1KQL7IrBW/Tol9aVZiuPBYMTrPgNf2NAH4Qdri9mlZDZiuXRwuW+uFuNDcEY+37v2d7I4ABLra44xZWRZHkPvISB9dVTjLXT74VD11gAhQWYRHzccyOUB0+5O5mTg6BeN3lkD5tovEOofLkXNNhUW3SKCmjkLSPd7cN4f22ei/mlvCOOzpR0wjsArGT+C9y462KAIVQCxJxpXE/7hSKEqTzsBDO4qL43Wdv7CsirrrhJqyeynaM/4144lSp/NwgnGsjj+wRbZf8wM65FIpcigClsEPSl/7bHIAHP8Dl0vXkBEKQQmzEcyDL5UpgxN/NvfCdyFeW2F8zq8fjWYg7Sv087POeFUu2PyHKHuWLjZjl3FjpRJ9Us9Hj5zxoBJuta6qAyy8y7TA6PCodC570EVyJHIUPtHcuAu53g/hC47YNvfNnaK3f557hxbKo232gWxlxLVqLNtsNLzu75hc+0pIsLqROPzFLgtfpRU4P5yaelAlNuzbBODLuXKnckdQHKwld+c24mCErJocM1G0qF8Kf7oabgIwZ3B2bEqEuryAHCBmWbjG0tlbgt6sawyZZA4aEKJ0UgaS03kN6hlkduWMLrQvF53NhzDcZRohMYPQhTORMwrU1KcskaXJgRzZ8PkhfeGxtCb5UVzGbuOXz98MnDMOQwDCquDR7qznAXdAlRynFt0yS46PnGRF1QBuBgSrlv2BgA+H0x8dqxJ8lJhcwICsDerM85tr4/irOpKzTnYBCauUnJOpVZa0maAVxxYVOwT7RTYdsTYc+lntSfcR4zXw+MERhmvlCyb3zXx0ROvl/h7EG7xjS+HzyhUnrRz0JuPmXLcI+nbX4FmPMuJFwH4m4okCAa3E8WmwKxrpbjwgxrPQ65NlOGkNEn59fyw6jb94CRcFIy9qSCKOlakSpWOYD9nQg9mCtJsWmWcW/kAu7WQbxs8PApkESQyRebZ7btQ5m3Zfj3qkRH04oH0MzvnuQcE0SQ= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 760a5e69-6197-44b2-f016-08d99a0316dc X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:07:11.0037 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EiAU/83ffxQ9kP0W13tG1xX64OvXej7oEkCXMAws4tJdfyxc2lWbayTlbzvLGsW25vOwrdxqr2DIcfJEe8J0kkuOPNLR5NWeM28cvyMT7Z8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4956 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Baowen Zheng Use flow_indr_dev_register/flow_indr_dev_setup_offload to offload tc action. We need to call tc_cleanup_flow_action to clean up tc action entry since in tc_setup_action, some actions may hold dev refcnt, especially the mirror action. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- include/linux/netdevice.h | 1 + include/net/act_api.h | 2 +- include/net/flow_offload.h | 17 ++++ include/net/pkt_cls.h | 15 ++++ net/core/flow_offload.c | 43 ++++++++-- net/sched/act_api.c | 166 +++++++++++++++++++++++++++++++++++++ net/sched/cls_api.c | 29 ++++++- 7 files changed, 260 insertions(+), 13 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3ec42495a43a..9815c3a058e9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -916,6 +916,7 @@ enum tc_setup_type { TC_SETUP_QDISC_TBF, TC_SETUP_QDISC_FIFO, TC_SETUP_QDISC_HTB, + TC_SETUP_ACT, }; /* These structures hold the attributes of bpf state that are being passed diff --git a/include/net/act_api.h b/include/net/act_api.h index b5b624c7e488..9eb19188603c 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -239,7 +239,7 @@ static inline void tcf_action_inc_overlimit_qstats(struct tc_action *a) void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, u64 drops, bool hw); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); - +int tcf_action_offload_del(struct tc_action *action); int tcf_action_check_ctrlact(int action, struct tcf_proto *tp, struct tcf_chain **handle, struct netlink_ext_ack *newchain); diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 3961461d9c8b..aa28592fccc0 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -552,6 +552,23 @@ struct flow_cls_offload { u32 classid; }; +enum flow_act_command { + FLOW_ACT_REPLACE, + FLOW_ACT_DESTROY, + FLOW_ACT_STATS, +}; + +struct flow_offload_action { + struct netlink_ext_ack *extack; /* NULL in FLOW_ACT_STATS process*/ + enum flow_act_command command; + enum flow_action_id id; + u32 index; + struct flow_stats stats; + struct flow_action action; +}; + +struct flow_offload_action *flow_action_alloc(unsigned int num_actions); + static inline struct flow_rule * flow_cls_offload_flow_rule(struct flow_cls_offload *flow_cmd) { diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 193f88ebf629..922775407257 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -258,6 +258,9 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) for (; 0; (void)(i), (void)(a), (void)(exts)) #endif +#define tcf_act_for_each_action(i, a, actions) \ + for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = actions[i]); i++) + static inline void tcf_exts_stats_update(const struct tcf_exts *exts, u64 bytes, u64 packets, u64 drops, u64 lastuse, @@ -532,8 +535,19 @@ tcf_match_indev(struct sk_buff *skb, int ifindex) return ifindex == skb->skb_iif; } +#ifdef CONFIG_NET_CLS_ACT int tc_setup_flow_action(struct flow_action *flow_action, const struct tcf_exts *exts); +#else +static inline int tc_setup_flow_action(struct flow_action *flow_action, + const struct tcf_exts *exts) +{ + return 0; +} +#endif + +int tc_setup_action(struct flow_action *flow_action, + struct tc_action *actions[]); void tc_cleanup_flow_action(struct flow_action *flow_action); int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, @@ -554,6 +568,7 @@ int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp, enum tc_setup_type type, void *type_data, void *cb_priv, u32 *flags, unsigned int *in_hw_count); unsigned int tcf_exts_num_actions(struct tcf_exts *exts); +unsigned int tcf_act_num_actions_single(struct tc_action *act); #ifdef CONFIG_NET_CLS_ACT int tcf_qevent_init(struct tcf_qevent *qe, struct Qdisc *sch, diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c index 6beaea13564a..6676431733ef 100644 --- a/net/core/flow_offload.c +++ b/net/core/flow_offload.c @@ -27,6 +27,27 @@ struct flow_rule *flow_rule_alloc(unsigned int num_actions) } EXPORT_SYMBOL(flow_rule_alloc); +struct flow_offload_action *flow_action_alloc(unsigned int num_actions) +{ + struct flow_offload_action *fl_action; + int i; + + fl_action = kzalloc(struct_size(fl_action, action.entries, num_actions), + GFP_KERNEL); + if (!fl_action) + return NULL; + + fl_action->action.num_entries = num_actions; + /* Pre-fill each action hw_stats with DONT_CARE. + * Caller can override this if it wants stats for a given action. + */ + for (i = 0; i < num_actions; i++) + fl_action->action.entries[i].hw_stats = FLOW_ACTION_HW_STATS_DONT_CARE; + + return fl_action; +} +EXPORT_SYMBOL(flow_action_alloc); + #define FLOW_DISSECTOR_MATCH(__rule, __type, __out) \ const struct flow_match *__m = &(__rule)->match; \ struct flow_dissector *__d = (__m)->dissector; \ @@ -549,19 +570,25 @@ int flow_indr_dev_setup_offload(struct net_device *dev, struct Qdisc *sch, void (*cleanup)(struct flow_block_cb *block_cb)) { struct flow_indr_dev *this; + u32 count = 0; + int err; mutex_lock(&flow_indr_block_lock); + if (bo) { + if (bo->command == FLOW_BLOCK_BIND) + indir_dev_add(data, dev, sch, type, cleanup, bo); + else if (bo->command == FLOW_BLOCK_UNBIND) + indir_dev_remove(data); + } - if (bo->command == FLOW_BLOCK_BIND) - indir_dev_add(data, dev, sch, type, cleanup, bo); - else if (bo->command == FLOW_BLOCK_UNBIND) - indir_dev_remove(data); - - list_for_each_entry(this, &flow_block_indr_dev_list, list) - this->cb(dev, sch, this->cb_priv, type, bo, data, cleanup); + list_for_each_entry(this, &flow_block_indr_dev_list, list) { + err = this->cb(dev, sch, this->cb_priv, type, bo, data, cleanup); + if (!err) + count++; + } mutex_unlock(&flow_indr_block_lock); - return list_empty(&bo->cb_list) ? -EOPNOTSUPP : 0; + return (bo && list_empty(&bo->cb_list)) ? -EOPNOTSUPP : count; } EXPORT_SYMBOL(flow_indr_dev_setup_offload); diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 3258da3d5bed..33f2ff885b4b 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -21,6 +21,19 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef CONFIG_INET DEFINE_STATIC_KEY_FALSE(tcf_frag_xmit_count); @@ -148,6 +161,7 @@ static int __tcf_action_put(struct tc_action *p, bool bind) idr_remove(&idrinfo->action_idr, p->tcfa_index); mutex_unlock(&idrinfo->lock); + tcf_action_offload_del(p); tcf_action_cleanup(p); return 1; } @@ -341,6 +355,7 @@ static int tcf_idr_release_unsafe(struct tc_action *p) return -EPERM; if (refcount_dec_and_test(&p->tcfa_refcnt)) { + tcf_action_offload_del(p); idr_remove(&p->idrinfo->action_idr, p->tcfa_index); tcf_action_cleanup(p); return ACT_P_DELETED; @@ -452,6 +467,7 @@ static int tcf_idr_delete_index(struct tcf_idrinfo *idrinfo, u32 index) p->tcfa_index)); mutex_unlock(&idrinfo->lock); + tcf_action_offload_del(p); tcf_action_cleanup(p); module_put(owner); return 0; @@ -1061,6 +1077,154 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, return ERR_PTR(err); } +static int flow_action_init(struct flow_offload_action *fl_action, + struct tc_action *act, + enum flow_act_command cmd, + struct netlink_ext_ack *extack) +{ + if (!fl_action) + return -EINVAL; + + fl_action->extack = extack; + fl_action->command = cmd; + fl_action->index = act->tcfa_index; + + if (is_tcf_gact_ok(act)) { + fl_action->id = FLOW_ACTION_ACCEPT; + } else if (is_tcf_gact_shot(act)) { + fl_action->id = FLOW_ACTION_DROP; + } else if (is_tcf_gact_trap(act)) { + fl_action->id = FLOW_ACTION_TRAP; + } else if (is_tcf_gact_goto_chain(act)) { + fl_action->id = FLOW_ACTION_GOTO; + } else if (is_tcf_mirred_egress_redirect(act)) { + fl_action->id = FLOW_ACTION_REDIRECT; + } else if (is_tcf_mirred_egress_mirror(act)) { + fl_action->id = FLOW_ACTION_MIRRED; + } else if (is_tcf_mirred_ingress_redirect(act)) { + fl_action->id = FLOW_ACTION_REDIRECT_INGRESS; + } else if (is_tcf_mirred_ingress_mirror(act)) { + fl_action->id = FLOW_ACTION_MIRRED_INGRESS; + } else if (is_tcf_vlan(act)) { + switch (tcf_vlan_action(act)) { + case TCA_VLAN_ACT_PUSH: + fl_action->id = FLOW_ACTION_VLAN_PUSH; + break; + case TCA_VLAN_ACT_POP: + fl_action->id = FLOW_ACTION_VLAN_POP; + break; + case TCA_VLAN_ACT_MODIFY: + fl_action->id = FLOW_ACTION_VLAN_MANGLE; + break; + default: + return -EOPNOTSUPP; + } + } else if (is_tcf_tunnel_set(act)) { + fl_action->id = FLOW_ACTION_TUNNEL_ENCAP; + } else if (is_tcf_tunnel_release(act)) { + fl_action->id = FLOW_ACTION_TUNNEL_DECAP; + } else if (is_tcf_csum(act)) { + fl_action->id = FLOW_ACTION_CSUM; + } else if (is_tcf_skbedit_mark(act)) { + fl_action->id = FLOW_ACTION_MARK; + } else if (is_tcf_sample(act)) { + fl_action->id = FLOW_ACTION_SAMPLE; + } else if (is_tcf_police(act)) { + fl_action->id = FLOW_ACTION_POLICE; + } else if (is_tcf_ct(act)) { + fl_action->id = FLOW_ACTION_CT; + } else if (is_tcf_mpls(act)) { + switch (tcf_mpls_action(act)) { + case TCA_MPLS_ACT_PUSH: + fl_action->id = FLOW_ACTION_MPLS_PUSH; + break; + case TCA_MPLS_ACT_POP: + fl_action->id = FLOW_ACTION_MPLS_POP; + break; + case TCA_MPLS_ACT_MODIFY: + fl_action->id = FLOW_ACTION_MPLS_MANGLE; + break; + default: + return -EOPNOTSUPP; + } + } else if (is_tcf_skbedit_ptype(act)) { + fl_action->id = FLOW_ACTION_PTYPE; + } else if (is_tcf_skbedit_priority(act)) { + fl_action->id = FLOW_ACTION_PRIORITY; + } else if (is_tcf_gate(act)) { + fl_action->id = FLOW_ACTION_GATE; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + +static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + struct netlink_ext_ack *extack) +{ + int err; + + if (IS_ERR(fl_act)) + return PTR_ERR(fl_act); + + err = flow_indr_dev_setup_offload(NULL, NULL, TC_SETUP_ACT, + fl_act, NULL, NULL); + if (err < 0) + return err; + + return 0; +} + +/* offload the tc command after inserted */ +static int tcf_action_offload_add(struct tc_action *action, + struct netlink_ext_ack *extack) +{ + struct tc_action *actions[TCA_ACT_MAX_PRIO] = { + [0] = action, + }; + struct flow_offload_action *fl_action; + int err = 0; + + fl_action = flow_action_alloc(tcf_act_num_actions_single(action)); + if (!fl_action) + return -EINVAL; + + err = flow_action_init(fl_action, action, FLOW_ACT_REPLACE, extack); + if (err) + goto fl_err; + + err = tc_setup_action(&fl_action->action, actions); + if (err) { + NL_SET_ERR_MSG_MOD(extack, + "Failed to setup tc actions for offload\n"); + goto fl_err; + } + + err = tcf_action_offload_cmd(fl_action, extack); + tc_cleanup_flow_action(&fl_action->action); + +fl_err: + kfree(fl_action); + + return err; +} + +int tcf_action_offload_del(struct tc_action *action) +{ + struct flow_offload_action fl_act; + int err = 0; + + if (!action) + return -EINVAL; + + err = flow_action_init(&fl_act, action, FLOW_ACT_DESTROY, NULL); + if (err) + return err; + + return tcf_action_offload_cmd(&fl_act, NULL); +} + /* Returns numbers of initialized actions or negative error. */ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, @@ -1103,6 +1267,8 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, sz += tcf_action_fill_size(act); /* Start from index 0 */ actions[i - 1] = act; + if (!(flags & TCA_ACT_FLAGS_BIND)) + tcf_action_offload_add(act, extack); } /* We have to commit them all together, because if any error happened in diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 2ef8f5a6205a..351d93988b8b 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3544,8 +3544,8 @@ static enum flow_action_hw_stats tc_act_hw_stats(u8 hw_stats) return hw_stats; } -int tc_setup_flow_action(struct flow_action *flow_action, - const struct tcf_exts *exts) +int tc_setup_action(struct flow_action *flow_action, + struct tc_action *actions[]) { struct tc_action *act; int i, j, k, err = 0; @@ -3554,11 +3554,11 @@ int tc_setup_flow_action(struct flow_action *flow_action, BUILD_BUG_ON(TCA_ACT_HW_STATS_IMMEDIATE != FLOW_ACTION_HW_STATS_IMMEDIATE); BUILD_BUG_ON(TCA_ACT_HW_STATS_DELAYED != FLOW_ACTION_HW_STATS_DELAYED); - if (!exts) + if (!actions) return 0; j = 0; - tcf_exts_for_each_action(i, act, exts) { + tcf_act_for_each_action(i, act, actions) { struct flow_action_entry *entry; entry = &flow_action->entries[j]; @@ -3725,7 +3725,19 @@ int tc_setup_flow_action(struct flow_action *flow_action, spin_unlock_bh(&act->tcfa_lock); goto err_out; } +EXPORT_SYMBOL(tc_setup_action); + +#ifdef CONFIG_NET_CLS_ACT +int tc_setup_flow_action(struct flow_action *flow_action, + const struct tcf_exts *exts) +{ + if (!exts) + return 0; + + return tc_setup_action(flow_action, exts->actions); +} EXPORT_SYMBOL(tc_setup_flow_action); +#endif unsigned int tcf_exts_num_actions(struct tcf_exts *exts) { @@ -3743,6 +3755,15 @@ unsigned int tcf_exts_num_actions(struct tcf_exts *exts) } EXPORT_SYMBOL(tcf_exts_num_actions); +unsigned int tcf_act_num_actions_single(struct tc_action *act) +{ + if (is_tcf_pedit(act)) + return tcf_pedit_nkeys(act); + else + return 1; +} +EXPORT_SYMBOL(tcf_act_num_actions_single); + #ifdef CONFIG_NET_CLS_ACT static int tcf_qevent_parse_block_index(struct nlattr *block_index_attr, u32 *p_block_index, From patchwork Thu Oct 28 11:06:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12589847 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B59D3C433EF for ; Thu, 28 Oct 2021 11:07:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9984560E8B for ; Thu, 28 Oct 2021 11:07:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230157AbhJ1LJl (ORCPT ); Thu, 28 Oct 2021 07:09:41 -0400 Received: from mail-bn8nam11on2096.outbound.protection.outlook.com ([40.107.236.96]:56801 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230213AbhJ1LJk (ORCPT ); Thu, 28 Oct 2021 07:09:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZhCDU0FQLroQS0VPfcTmDt+ato78iu/fnYWbtpzwt2RnbCqYBYJ1GDgwKSeh8XJz0OCZ5cqRkYGaJHS/hh6FTNad1p3KbXyP4W0phUdCv65s4cnHeLrlkU8/1uylIMXT/5Z0ECngP9rh6KVOr+lb84xmtNOJUfUx4bbgMWaoktfrNBEfZjTq+cmdIyroIP43Cy9aEuRCNzzW8k8xTChgXOAcjgRmRDMwGkjYW7vmtolyadNPl4n6P/eSagibsZL3aFLXupxhngg/lhFaaYvqOYuTJX/UsfhRDcfcTrwsCrwi2oOiXtk+/zp1e0ACrWThPRmoB5FHPO38JMAiRG5V7w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IAmGYRk+bQ1u7Cy7fkTkxpxX5HUn47plXJDBHKw78rc=; b=kjA6huA8SrpJUr4SJ3lCrF5EyQMI3fbDfzyecxm/+ahauw6DiQF2uLaFpPb2nZdJUj5mFoLQ3DIdFdq2+F2f/FgpCQBaOFp78aWJJXGnjO5lXf+c2xVcH9U2tAQprn/2uoh8pymHrmWc5cND3PN1KlUd6JRAQCBRqLPdsDa2ZZmj39c/8inzN6GE3APjYf9/iP4V01mjSrhIzgkFR70PT6kJRX8x1zx1H92bPLBxvIRxuRYtorH5HZCp09zzfZmSrV8YvofZVzca/lbGEiDlPBUQt2oJk9oSwYb73HcMvv+mPnON5GneWqeau/SdZMZutr/uzVKC8ya7UJopkkJyAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IAmGYRk+bQ1u7Cy7fkTkxpxX5HUn47plXJDBHKw78rc=; b=KfwVl8+CCmrVSGLDIkgJ1HxfR/FGjgkerA+sVBmH8mqWwoOGiC3m6wadzsiK7vhZpRliJQQo13kw4Npb2Nf5Aen5gm8JdKT/mn5niuUOSBLDfM6SbfD9qjylVku1RRpGLi0a07+Ve8Kprc5mdM1C5vTNk5AcejGHSaVag+ntDxM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4956.namprd13.prod.outlook.com (2603:10b6:510:98::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.11; Thu, 28 Oct 2021 11:07:13 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90%9]) with mapi id 15.20.4669.005; Thu, 28 Oct 2021 11:07:13 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Vlad Buslov , Jamal Hadi Salim , Roi Dayan , Ido Schimmel , Cong Wang , Jiri Pirko , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Baowen Zheng , Simon Horman Subject: [RFC/PATCH net-next v3 4/8] flow_offload: add skip_hw and skip_sw to control if offload the action Date: Thu, 28 Oct 2021 13:06:42 +0200 Message-Id: <20211028110646.13791-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211028110646.13791-1-simon.horman@corigine.com> References: <20211028110646.13791-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:07:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d075dca-c695-45ef-b33c-08d99a031831 X-MS-TrafficTypeDiagnostic: PH0PR13MB4956: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:619; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D8ldJ94QcowWhjJ3u4uppjININOitKihaAK/HNQ1IAhRytM9oamS7cz7PGckZE5uG+2UAUEcEJ19yicXiBBoV0r6Q1dSQZx5sorRVSGGHIdOVE9+HTcKywJmuA0Lx+efhsQrOkfjYh/I0gbhX+81B2FZOMBPAkA3ayIY2WJQlB0j5Zw5Je/0vsu+/AHv0KRiNkTAabXGK2w/R88o5EZanf1elWczZnFJxY3H0phlqXBN+bA9atfGseGWyQKPfvg8d8rCmqo/T/5AUuNgvbAnw+sJW48jtm2WWA8ctmDRXFTQk81Dl0so6pxZ/0vbgELq9NPIAOZ6h1h2ff9H9NoI8G6Lv0TXVVr6+sCJSLXMimTNKHOf1j2pMJxspDMdZqABnHQP+pVUAidpDPvw/ZRkWERYzEXH/L9k6EHdprfvPEmE8avU1TVBNBU9NmL095l+N0pPnc5UCwNhk7kcKSl+ilfCxbQCepUfnSzWaIyju4NL8nUCaggHpZrhHIfIagMS5JTBTWGp5AftefLBxO8bCtdSQiuyHJfqpHbWb03tDOSuO52xEp7gCRZSghSL0FyuTRQVcEL4o08V+uX0FA+ZEgvkma8ayn04ez1rmrmeGmRAJAUnh1ZVvZhZcOzRt7Tmg/N58k72EqflNk0N3QurhlmOrPBF9dr+oAcYrD68yuX3/+L9qMoZhIH+F9uf+A9n18hMDoEqwDYVGmTBYAO4ig== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39840400004)(396003)(4326008)(83380400001)(316002)(36756003)(54906003)(44832011)(6512007)(8676002)(2616005)(2906002)(5660300002)(8936002)(6666004)(52116002)(186003)(66476007)(107886003)(66556008)(6916009)(508600001)(6486002)(1076003)(66946007)(6506007)(86362001)(38100700002)(309714004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Up/57fWrQRbVyTtPeMw2GIjdMppRUhIEIjz3/5aRU3DAKfb/o6sVKZyHUJjzWFnFAdyiHvrJIzRiOLPos6ypytk2IS1Kn6pQC2ZWBmmJF01oe/cF9isgadoVSS8crcMjIZ4Qy78PWcAhS6g3wk/6ohTM0qpIpYSDwMoAE4JLIIUBnsW/DpqY+3qQB9rEZ/i9sTvZXJ29zwvRjwuDfnyE5yUfBmKW49NeLh2zunCHbGGdvvMITjts7zTg16899wuOSwlr8GmJXoQKXGFbHmhqLyV752HQe8RmLQtnljT8Q5eGMkNCcDxBgBZCgJOqzE42UrRIwD3tVGjzRJNCO3zAKQ/AJXF3RtMDYAUvjLVn4NJZDGpxxWtuWfmDsua9sD0exV6O5PbxJvHACNFABSxLSjG6XrBBodqW6TGGNqZGzgtrRyKfZlXr5dA7d3z3LzW90bJ7Qudh99FbytsYoJkvizMR/bPH03aMP1cRa9DVj+tSn4vdT3r4KAjd7dWG3F/24mP1X0Fqu5KDFmxfytmg81m9dILzdEydbhXbI6CotOTc9w+KHFnO6AgKBexyhgnZ2VIrr82lh0Rarqw7aIRMVBve+9kJo0COGPVfMyppXaXTHhB1Ug3kWVf8gux2zKpiAinScIHOmYPtTeV0lgQe3D5dQ2m+H4XKzm3/RsXhSnIND3r+jhdsiAdQ0cVNVRu7nri+YDAk2TcgRL6VAixKvrKJDJS10ahZrBP3R/JGypG9/H34xuonjeH75ySbQh0IpziOtP5QZCyKO8R10QtcYtf5ay2zR02gZjFAcQs1MDPXeq78wM6583wg0sdrcGhLyUpHF8mOrPtNirqaCEarwHKdQL1RBfFSejEoHnKgCRv+MV0rPUSVUwRBi4rRWMU7XZTXhsb8EgANdIk9e3gB/9SwJKkLHA6x5tJv2ibWW6TRWw1WXw/ctEF5Gie62bXWX6Y31EVKwhOHMTlDCobDJl4XuGP0SyhKj9Q7qoI4xWbN276S7/5Z+9KlyhoGKHuTjNz2CEZWrwVAye5SaQis41+Id8R37InG2blfrqiMc9oicTrwCEHMP/qd2DpC+fOCBnu03ovVWCVLPOgATxLNF8yneFV6nLmDweiYxo7WZkzCXKpYL5acsvDPRyudMO85AiFmW/WiYJm/4UwhCfuhZuYD+c+DcjDBamLOVPOyfGGMIFmacqRQ0YpPDbhWWHZQY3IgI9HL+ThKjkZZbAyblHuUOOYDZ4xuaEufGvSK1PRWNpFj5BqgR7QWys0yw48Gc7XLgkumo19j6MYpr3AyQhkEpSJf8N7b9oLlD2dRQLfzOewX0VxjU2N9beEimjwsPlMtgq7rGLeguiw1Fe2kquuW7WnibWGVVLSHfWoIjcXihgOyrUR9wvJbB3S8z6qOd83jj0dv8daHhzRn+sR1OI8egkW+FInx6KIwPuCx2uH7ou5/MLyy3QHr0ps8tl1FSy7HyPdtj3Q3SOSbhcHzFUfFVEMwYwpbVszSdW1Py54vPOrrG2wkndxR9NmN9dycJGtJnnQx9P1PGNGPqOY8PB4HWHDGJ4QXFkBJHwXv23z3zwqOcPPhw5NrdANi2X5aENiRENA0sNLTFV7DASmPpwm7ceEVLDoW7C1k6SH3+GIJS9TqrOgNUAoFW+gMDpVw/EemKDltFrOsoWPOnF5x6pnVVTiyiSbDu4eQvRbnlzrNJJRB3pFPNLPZMtYlEhQeKd6fCWwjHJnFLupVL8BOvKInEY9N4Fmfnl34EI7QXaU= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d075dca-c695-45ef-b33c-08d99a031831 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:07:13.2300 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7mPtgb1+3/tqGU2ETukneyFOuCMWJg3ial9CeXbxMOhTF7ErOgBM3fUt1udWkKa9JBkAxC2oLzLA6VT9eb2AN4qM3fz4qKrxdGyws7xFG50= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4956 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Baowen Zheng We add skip_hw and skip_sw for user to control if offload the action to hardware. We also add in_hw_count for user to indicate if the action is offloaded to any hardware. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- include/net/act_api.h | 7 +++++ include/net/pkt_cls.h | 23 +++++++++++++++ include/uapi/linux/pkt_cls.h | 9 ++++-- net/sched/act_api.c | 54 ++++++++++++++++++++++++++++++++---- 4 files changed, 84 insertions(+), 9 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 9eb19188603c..671208bd27ef 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -44,6 +44,7 @@ struct tc_action { u8 hw_stats; u8 used_hw_stats; bool used_hw_stats_valid; + u32 in_hw_count; }; #define tcf_index common.tcfa_index #define tcf_refcnt common.tcfa_refcnt @@ -236,6 +237,12 @@ static inline void tcf_action_inc_overlimit_qstats(struct tc_action *a) spin_unlock(&a->tcfa_lock); } +static inline void flow_action_hw_count_set(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count = hw_count; +} + void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, u64 drops, bool hw); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 922775407257..44ae5182a965 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -261,6 +261,29 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) #define tcf_act_for_each_action(i, a, actions) \ for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = actions[i]); i++) +static inline bool tc_act_skip_hw(u32 flags) +{ + return (flags & TCA_ACT_FLAGS_SKIP_HW) ? true : false; +} + +static inline bool tc_act_skip_sw(u32 flags) +{ + return (flags & TCA_ACT_FLAGS_SKIP_SW) ? true : false; +} + +static inline bool tc_act_in_hw(struct tc_action *act) +{ + return !!act->in_hw_count; +} + +/* SKIP_HW and SKIP_SW are mutually exclusive flags. */ +static inline bool tc_act_flags_valid(u32 flags) +{ + flags &= TCA_ACT_FLAGS_SKIP_HW | TCA_ACT_FLAGS_SKIP_SW; + + return flags ^ (TCA_ACT_FLAGS_SKIP_HW | TCA_ACT_FLAGS_SKIP_SW); +} + static inline void tcf_exts_stats_update(const struct tcf_exts *exts, u64 bytes, u64 packets, u64 drops, u64 lastuse, diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index 6836ccb9c45d..ee38b35c3f57 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -19,13 +19,16 @@ enum { TCA_ACT_FLAGS, TCA_ACT_HW_STATS, TCA_ACT_USED_HW_STATS, + TCA_ACT_IN_HW_COUNT, __TCA_ACT_MAX }; /* See other TCA_ACT_FLAGS_ * flags in include/net/act_api.h. */ -#define TCA_ACT_FLAGS_NO_PERCPU_STATS 1 /* Don't use percpu allocator for - * actions stats. - */ +#define TCA_ACT_FLAGS_NO_PERCPU_STATS (1 << 0) /* Don't use percpu allocator for + * actions stats. + */ +#define TCA_ACT_FLAGS_SKIP_HW (1 << 1) /* don't offload action to HW */ +#define TCA_ACT_FLAGS_SKIP_SW (1 << 2) /* don't use action in SW */ /* tca HW stats type * When user does not pass the attribute, he does not care. diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 33f2ff885b4b..604bf1923bcc 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -751,6 +751,9 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, jmp_prgcnt -= 1; continue; } + + if (tc_act_skip_sw(a->tcfa_flags)) + continue; repeat: ret = a->ops->act(skb, a, res); if (ret == TC_ACT_REPEAT) @@ -856,6 +859,9 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) a->tcfa_flags, a->tcfa_flags)) goto nla_put_failure; + if (nla_put_u32(skb, TCA_ACT_IN_HW_COUNT, a->in_hw_count)) + goto nla_put_failure; + nest = nla_nest_start_noflag(skb, TCA_OPTIONS); if (nest == NULL) goto nla_put_failure; @@ -935,7 +941,9 @@ static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { [TCA_ACT_COOKIE] = { .type = NLA_BINARY, .len = TC_COOKIE_MAX_SIZE }, [TCA_ACT_OPTIONS] = { .type = NLA_NESTED }, - [TCA_ACT_FLAGS] = NLA_POLICY_BITFIELD32(TCA_ACT_FLAGS_NO_PERCPU_STATS), + [TCA_ACT_FLAGS] = NLA_POLICY_BITFIELD32(TCA_ACT_FLAGS_NO_PERCPU_STATS | + TCA_ACT_FLAGS_SKIP_HW | + TCA_ACT_FLAGS_SKIP_SW), [TCA_ACT_HW_STATS] = NLA_POLICY_BITFIELD32(TCA_ACT_HW_STATS_ANY), }; @@ -1048,8 +1056,13 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, } } hw_stats = tcf_action_hw_stats_get(tb[TCA_ACT_HW_STATS]); - if (tb[TCA_ACT_FLAGS]) + if (tb[TCA_ACT_FLAGS]) { userflags = nla_get_bitfield32(tb[TCA_ACT_FLAGS]); + if (!tc_act_flags_valid(userflags.value)) { + err = -EINVAL; + goto err_out; + } + } err = a_o->init(net, tb[TCA_ACT_OPTIONS], est, &a, tp, userflags.value | flags, extack); @@ -1161,6 +1174,7 @@ static int flow_action_init(struct flow_offload_action *fl_action, } static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + u32 *hw_count, struct netlink_ext_ack *extack) { int err; @@ -1173,6 +1187,9 @@ static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, if (err < 0) return err; + if (hw_count) + *hw_count = err; + return 0; } @@ -1180,12 +1197,17 @@ static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, static int tcf_action_offload_add(struct tc_action *action, struct netlink_ext_ack *extack) { + bool skip_sw = tc_act_skip_sw(action->tcfa_flags); struct tc_action *actions[TCA_ACT_MAX_PRIO] = { [0] = action, }; struct flow_offload_action *fl_action; + u32 in_hw_count = 0; int err = 0; + if (tc_act_skip_hw(action->tcfa_flags)) + return 0; + fl_action = flow_action_alloc(tcf_act_num_actions_single(action)); if (!fl_action) return -EINVAL; @@ -1201,7 +1223,13 @@ static int tcf_action_offload_add(struct tc_action *action, goto fl_err; } - err = tcf_action_offload_cmd(fl_action, extack); + err = tcf_action_offload_cmd(fl_action, &in_hw_count, extack); + if (!err) + flow_action_hw_count_set(action, in_hw_count); + + if (skip_sw && !tc_act_in_hw(action)) + err = -EINVAL; + tc_cleanup_flow_action(&fl_action->action); fl_err: @@ -1213,16 +1241,27 @@ static int tcf_action_offload_add(struct tc_action *action, int tcf_action_offload_del(struct tc_action *action) { struct flow_offload_action fl_act; + u32 in_hw_count = 0; int err = 0; if (!action) return -EINVAL; + if (!tc_act_in_hw(action)) + return 0; + err = flow_action_init(&fl_act, action, FLOW_ACT_DESTROY, NULL); if (err) return err; - return tcf_action_offload_cmd(&fl_act, NULL); + err = tcf_action_offload_cmd(&fl_act, &in_hw_count, NULL); + if (err) + return err; + + if (action->in_hw_count != in_hw_count) + return -EINVAL; + + return 0; } /* Returns numbers of initialized actions or negative error. */ @@ -1267,8 +1306,11 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, sz += tcf_action_fill_size(act); /* Start from index 0 */ actions[i - 1] = act; - if (!(flags & TCA_ACT_FLAGS_BIND)) - tcf_action_offload_add(act, extack); + if (!(flags & TCA_ACT_FLAGS_BIND)) { + err = tcf_action_offload_add(act, extack); + if (tc_act_skip_sw(act->tcfa_flags) && err) + goto err; + } } /* We have to commit them all together, because if any error happened in From patchwork Thu Oct 28 11:06:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12589849 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10199C433F5 for ; Thu, 28 Oct 2021 11:07:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECAC5604AC for ; Thu, 28 Oct 2021 11:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230166AbhJ1LJs (ORCPT ); Thu, 28 Oct 2021 07:09:48 -0400 Received: from mail-bn8nam11on2113.outbound.protection.outlook.com ([40.107.236.113]:43800 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230225AbhJ1LJo (ORCPT ); Thu, 28 Oct 2021 07:09:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UQWtRViCWaYRncWQj488+5vnRu849kUnKkqAAVMeKSYYXjXKxaBEiLdhC0PvVfKtrBo2z3rx117MPWAUs0G4ujwjM/zhGguEjV9D/948blOGfeCo6zdm6RpGEFmzkhPbIJ9ltyQyIkjOxh2rjwb/95HunVzjcNA5vggMSO/Fra0x5R3I4JIR17/NqGnc1AfJ7lEEzEMFvUHPoO3oAXjH0Aarx6+ygM7551DdbEtle/wmQpA/mV7JTj6e4xblBxaheEImqs2o1EqMhJ7urJuGdtrVZ9TQYIgHMCrG7Ifk1EiWo2NhrlsvrhEML264RfNTkDg6d2xLcxW0/kY85V/Mwg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BD4o+W79tZvEn30aZKKdm3MFBJ/CGhMx+A/vrHGWkrc=; b=exE5q0P2364i7hph4A0+s5bggCnjLGysp1JPUOffQu0L7dDM95pry35I5ywF2jd4Smg31COzZwMXpePvxqAbQ52YW8iU7lMZ33bdiIKGOf40sGa082xI1zwOglD+rRLEobyGA70R8EpxY9fkHVYbDP+3etUxQaL7Xazl06DIZCYPC/g+kdYlTUuOeUmt7DYNFY7f39xwZnbOxUUUDG5h3/7WANLBCGE+Aek2fgWovclHCb5BGky0dnuCh5hgI3Y8Uc8CGpfROA3M4y7PDjXhW0AIfiyOQBmo9Oo5viGdQiSwr01BYS6h4wrRqGUlhHvynlxtMWIWVZEEJGZ6IY7oWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BD4o+W79tZvEn30aZKKdm3MFBJ/CGhMx+A/vrHGWkrc=; b=NLd3bei/uD/pw7WuX+K4K9hneNnAAdz7pRWITNniLIqcCxNx5u+wxS3fwfmv9U0EZLSRrS4Fk4UA6MBhPl7SLX0ejW8d7ZqzPJQzYtaLmgoSBAsnapkk01DshItNurWbRqdOvqVu7p5GwLI9dp2WR3U/D25osjJOnNVbxSFX1eM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4956.namprd13.prod.outlook.com (2603:10b6:510:98::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.11; Thu, 28 Oct 2021 11:07:15 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90%9]) with mapi id 15.20.4669.005; Thu, 28 Oct 2021 11:07:15 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Vlad Buslov , Jamal Hadi Salim , Roi Dayan , Ido Schimmel , Cong Wang , Jiri Pirko , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Baowen Zheng , Simon Horman Subject: [RFC/PATCH net-next v3 5/8] flow_offload: add process to update action stats from hardware Date: Thu, 28 Oct 2021 13:06:43 +0200 Message-Id: <20211028110646.13791-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211028110646.13791-1-simon.horman@corigine.com> References: <20211028110646.13791-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:07:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a611a3b7-2338-4959-1bd0-08d99a03198a X-MS-TrafficTypeDiagnostic: PH0PR13MB4956: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:363; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WZB+kw5xF6+8OyW6BOAy25Z5kkg3AZkG3pfoc3T+wqF5R8WBzDCloIrqq2bqdpqVkiVuRtI7u7ilK2h2aTA999Qlbb3JpHa76bWcxdndBEjDK6OFdZ9Jz0nFrlIYLLLLw+vWRAJORR70lzK1p0Jgs28oSL4ILnuu/gUpJhskFltkTB7MG8ZnhPlRH0fvY9QP/pw47Zlr9PlKiMMvujCEkoar32gqywceDyoVs1X4DeQVa9eYL4urWgaB6Qo4q9lgBpZvL97jVrNB21sY1BlSrCmx9o5gpxGP3d5QnoWKkbzIUbjWGsCNMjuimTG30AAbrPUs/gNbqsb4MhljGa3ixXYuYYE7p4rYWkI0xWAbNqQOREVg/pamLmchDQ7LJljHeiSi1dthRMPAtWlU6uGhcgjWX0DSOnNGrBa3ukE6MsM5PHRdhx38SmiQyImb1Mt4VMA70EjGNIvrBPE8+9WcNlqVZgHWNp/KEcrnE0GWUKOluvpd0uYBgOC6F19XpEtfwzfKBJNWqh8QW43/VT/iMtxxxtxFBk5wbXbnzlCbUhfi+Wmb5ZJmO/e1M04YBhuPYjK8rfPkAyFVHBPnBbg2Bx8A8fZEO4MYKZ2yz5byUY1NrHlZ/MyGUOh2Qq70deAiTMGdJmVy32kw1I6M5kOWyA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39840400004)(396003)(4326008)(83380400001)(316002)(36756003)(54906003)(44832011)(6512007)(8676002)(2616005)(2906002)(5660300002)(8936002)(6666004)(52116002)(186003)(66476007)(107886003)(66556008)(15650500001)(6916009)(508600001)(6486002)(1076003)(66946007)(6506007)(86362001)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 85Pt9C49P4d7z00g1yxb/Zhpar59wzAvhhLziqaekRdfzYVFTqw4sT7RUHopnefhw8B4ucnMgGyTB5zFS0tWKItwqraCmFdMFIncYsaq+TahNXGUiitBXTsYLEbv0Kthn8KLqQ1rpBA2LXmBM5DNBfCPqap8YBEJpw7211hFV0zpNMJjA8tcO9dccPrL3k1RFugSeH6Eop+4EZqfd/euRGx4iasXZJ3M4TQpuZRNIbNy8tHH17c/2sCO57jATXE0RS2wL36A8H6wlDbWyhi0u3psU7IW6D0CE3kP5622q9I1VuVJr3RzKnw1MoQoMLQ/5Aeb0O2bR97p/4rtVmMUJ+enirWXXmI9s5J/CXv2bWQ6AHtESfz2v4RU8Rn5Z1Oi/7CwXwdPWaJDj8Hbx4rUX68BupUumF5AiAeBBbF1sTW5T9Vzzvf/WvpExqKaJ4//ID818/Xao7sjItdif1hMtWBlLTwWxp/9yk/tGG3dhGIhL0ZmmvrY61AjbwegFuh++uuWcTspyArdIi9pBmz3txR9ERlhfuRzAXhPkulxbPwMLbGIFowCT80T31K2M9oyJ9wBh/h1mB/y/BUFRvajcXqobvbaE+zCG0XeXd3smqHNaSG4IF7OQEKxcVa7gNN3XBvGAtW4GPr0FHyEZHzKAijwEk+CD1oC9mdW4xV0LNRl4bRMqdxsHAgVatiL+ypTF5i80au5lQTdk7L+8mpfWEZKsk1z/uwgt4q6JrFwXptA14pkLXqiAFgS1NMfDxCL24irViXdZQ+S94554F8TBylgcDY+AM8kLLXuDw0FVPVOB42cM7wb/hKRbaBPlg3M7Vh73DkmxR4dt7Kdh1gwrtH2AkpLmyFMy3SqhJ2yzjvyJ0XQJgYO7+/nvT8hYD9Unpzn9btJBNa35bF7xdpyMJGKB6xqBKUJcFrPwwE4AsQONIJdBrnLQwUy03J5a2UU+9NFG8DF9QPbdRRm9HCV+kY7ShLOauTuDgs8iRyy2Maw2F75+HQkXDVhwIYy6rGE3y6N9M3D/Xt4hl5xYyBICEV2P8IVt3YC3vI3C+IiHGeLhvHi4FE+37Hj+/IgXQadIpPsc860YSt8+/buiDLu56Qwo5G+UJ6zz6MqSxl/d1UFIEwY4Mt4hYrIw/cfhXTNP2yqC4dYcIEvy4MpB0Yf7VD0aBzheavUVlfN3MvyaCb2icEHBVQKOVnm2r1sNDmyczPI5QGer1ge8LUCqLexRCg6nDQKhG/mqQzlBCxNnWVlLeotQnoWUU0HAYM6rURU4qz26Efi6M/DiXw85FBt4PlXx7bc9T9OVL0W36WEJ1IU76G+PqfSiu3fKtm9C3VSY3LGWpxfPJajcNUJroWVqUqpclr9TCiDt5UpfHPKUEeHLNBgHGM8agQW3Eltv4hEc5Whsk3yhX/xXEDX8C8jM3hxiN05pB2NWERmSmeMEW7CqSIhyKACDPTCWzsJmcYc3lVK2Bf4oUMti6BiC4zKffrXYC8aApY78AXpl+rNH3AnFh4d1VNIT+G3RmRFpzKbyYjsxzU44ODHa84QIuMW9cBLiywhyLrZFXm2TGvapQd6FuoEbisCeWxu00VpBuRUSaJSCBL2QiaeTUYys14dBLZQcOH/tPEt2DRrP1Ex4RoN16VgFLJ7DEkXn/N4fHVWI4EsnhfNtp9Wowz5FQGEnaAO2NCflJoiUn9U0cS+J74xJlByC2tQXMZGrmD5CvoHPq0GLZNixq0SFHf+hS2623cZLtqD8pZIVKMf6oYD6gs= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a611a3b7-2338-4959-1bd0-08d99a03198a X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:07:15.4552 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vq93Gpns5p7dLrLKurhCzUFvtEesp5wFKFJhzsd1wCpBuBEg9cP0t4/lP035LBzwnIyFaTcDd8zPrIy6GEU0sWjbFZT2SCqMzVJwjAfGv+0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4956 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Baowen Zheng When collecting stats for actions update them using both both hardware and software counters. Stats update process should not in context of preempt_disable. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- include/net/act_api.h | 1 + include/net/pkt_cls.h | 18 ++++++++++-------- net/sched/act_api.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 671208bd27ef..80a9d1e7d805 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -247,6 +247,7 @@ void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, u64 drops, bool hw); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); int tcf_action_offload_del(struct tc_action *action); +int tcf_action_update_hw_stats(struct tc_action *action); int tcf_action_check_ctrlact(int action, struct tcf_proto *tp, struct tcf_chain **handle, struct netlink_ext_ack *newchain); diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 44ae5182a965..88788b821f76 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -292,18 +292,20 @@ tcf_exts_stats_update(const struct tcf_exts *exts, #ifdef CONFIG_NET_CLS_ACT int i; - preempt_disable(); - for (i = 0; i < exts->nr_actions; i++) { struct tc_action *a = exts->actions[i]; - tcf_action_stats_update(a, bytes, packets, drops, - lastuse, true); - a->used_hw_stats = used_hw_stats; - a->used_hw_stats_valid = used_hw_stats_valid; - } + /* if stats from hw, just skip */ + if (tcf_action_update_hw_stats(a)) { + preempt_disable(); + tcf_action_stats_update(a, bytes, packets, drops, + lastuse, true); + preempt_enable(); - preempt_enable(); + a->used_hw_stats = used_hw_stats; + a->used_hw_stats_valid = used_hw_stats_valid; + } + } #endif } diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 604bf1923bcc..881c7ba4d180 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1238,6 +1238,40 @@ static int tcf_action_offload_add(struct tc_action *action, return err; } +int tcf_action_update_hw_stats(struct tc_action *action) +{ + struct flow_offload_action fl_act = {}; + int err = 0; + + if (!tc_act_in_hw(action)) + return -EOPNOTSUPP; + + err = flow_action_init(&fl_act, action, FLOW_ACT_STATS, NULL); + if (err) + goto err_out; + + err = tcf_action_offload_cmd(&fl_act, NULL, NULL); + + if (!err && fl_act.stats.lastused) { + preempt_disable(); + tcf_action_stats_update(action, fl_act.stats.bytes, + fl_act.stats.pkts, + fl_act.stats.drops, + fl_act.stats.lastused, + true); + preempt_enable(); + action->used_hw_stats = fl_act.stats.used_hw_stats; + action->used_hw_stats_valid = true; + err = 0; + } else { + err = -EOPNOTSUPP; + } + +err_out: + return err; +} +EXPORT_SYMBOL(tcf_action_update_hw_stats); + int tcf_action_offload_del(struct tc_action *action) { struct flow_offload_action fl_act; @@ -1362,6 +1396,9 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *p, if (p == NULL) goto errout; + /* update hw stats for this action */ + tcf_action_update_hw_stats(p); + /* compat_mode being true specifies a call that is supposed * to add additional backward compatibility statistic TLVs. */ From patchwork Thu Oct 28 11:06:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12589853 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC79EC433FE for ; Thu, 28 Oct 2021 11:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D22A760E8B for ; Thu, 28 Oct 2021 11:07:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbhJ1LJu (ORCPT ); Thu, 28 Oct 2021 07:09:50 -0400 Received: from mail-bn8nam11on2113.outbound.protection.outlook.com ([40.107.236.113]:43800 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230216AbhJ1LJu (ORCPT ); Thu, 28 Oct 2021 07:09:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hehkYJMzWHK+T98CjZV7DXqmhsbr/0MVZanGnAys0CvJIHGnEUI/7PBZlDrDkHkHwnbThWYQlXOQ7QfuQNrUiCVDNq2wh8sIstlN9rQxUHm5/gavcfPRxwta6PbPCP4rX+cNfyH0Nt8SsMDxiOGeNX+G2jcngCsGfXP4oE+AiGXEvlkIboCJvjrfNM4oUxXYDcLlv+f338hnO/zl99tIorPbEVE5no0v7hasJKoWcEM1f0zB/ZX+5BhBuJtR6WyRNJ7Fn4zu4EmyacUR0TyVMMGNfc0XtNw0ovyeCqJGBi3fz8a+RK4PRUc7RG3mQKoPea1upSxX+o8ICUVaR2v9Aw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZgmXNN/J8Y5zBrMApUOnW6EM0EVb5xkPdro/B9YtWXc=; b=k9lXMev3/rF6Iaw+MzO3etd98jXCv93xsrf6HybSuiJDalh2b55dytSJ5nwnf2wBUuCnrIfB6F096zZ3ectw2Dt+u8uvDqDm41vEPpNiSSDw1HkOXbKtTcN4keaIBbTHoVIK7x1aHLu3tVPMGBnFpki4+Snzztp+WSPw0pX3agGO1UBv2FegcBGiPDwyoY+67ZdIPho2Q7ph6xmDO7rkrGEJRedCDNNb70BkYdX7otH3Fj1tJ0UHl2naycVjxkDr9kwdtnDCv3F6Ttcmdmp23kdFte+uO3jMY4xdaEfjiircTrjyB8PaHSBD9kolKrAl+Y2BB6wyYBw0LnTXtEa28g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZgmXNN/J8Y5zBrMApUOnW6EM0EVb5xkPdro/B9YtWXc=; b=XYA1naCSZrheO35kVDNvOyfiSa0Oj/zCFeX4Q0VTAUzsTe24uwBccD0Cdbds4yO+QzJdviBnGU90Ial2ivvVDx4d/cgeMkQIX/BHwWhmgPKqUxwfo+EuqlNY4Ipqqmp46fBDWh99sc6FgPncAVc4Rlafyso3YtN36Bm7WEOq04E= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4956.namprd13.prod.outlook.com (2603:10b6:510:98::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.11; Thu, 28 Oct 2021 11:07:18 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90%9]) with mapi id 15.20.4669.005; Thu, 28 Oct 2021 11:07:18 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Vlad Buslov , Jamal Hadi Salim , Roi Dayan , Ido Schimmel , Cong Wang , Jiri Pirko , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Baowen Zheng , Simon Horman Subject: [RFC/PATCH net-next v3 6/8] net: sched: save full flags for tc action Date: Thu, 28 Oct 2021 13:06:44 +0200 Message-Id: <20211028110646.13791-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211028110646.13791-1-simon.horman@corigine.com> References: <20211028110646.13791-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:07:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0eaa22a-83d7-4e2c-ab4c-08d99a031ae2 X-MS-TrafficTypeDiagnostic: PH0PR13MB4956: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n37ts0mE2e94Q1L4FgKEq6EDt9TTHZgKc6kbwgkAIKz5V8FaSIyAbKLfnbFSLsc2H8xqGv6wzOpS15yNonbdCCl+Hw/jOQD9P7OpINBj8CEuKkgB7noSb8F6y8oh+ZIGJGimwvANepqc9H1AzWygCXpzTtcMxlZy1Ky1qI5mM5U14xVF2rnDeR6W2J8Kpzg617dwuIhFV7VPu3jNQvkkf2B0W0bn+ebPeC6VWNUcmX+EXWkxLaNqWAdMxqvnCAW8VuaJAGtRh5p8oF7lrtNwB3avyuN/QgF2TMLujKO4CbsQE68aA13hpEeffxQTjTk45MxNRKNbTfaEHd73IeFDOZtuFeyEQS4kkfVfg7cn3NCeMmzT2Nf8iaOFUVydur+PtHdErlUI4f3lPn4Pp4E+GSo/1x0BV100rpwENgS/dSoFhkMZ76uGOY8VM5eN3RelgbMxQwAEPpYFyr16wV8Mma5kQLE7HBS1gahDzPKo3nujaHY5AokB0/oxjAgtOnhZyuA2wimKkkRnofC/k5is0CoWwBJZrvSTfnsiyFJlk3cI7o5Y6mM8meNa9o67mi6e9UE7MxjlkEEajdD4Y6pX7BKwX5umFKhqp9oQFMeIUcjTjumzTyb+wo9wRdf+72CLHVbxSd+uE5rjUYA1yBpY2A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39840400004)(396003)(4326008)(83380400001)(316002)(36756003)(54906003)(44832011)(6512007)(8676002)(2616005)(2906002)(5660300002)(8936002)(6666004)(52116002)(186003)(66476007)(107886003)(66556008)(6916009)(508600001)(6486002)(1076003)(66946007)(6506007)(86362001)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DZqO/GMBB9MqWXNX+I5PZCz7GpNK2MsSwxk7+iKoAqBxgG423ARH0GxnLKMtcboqQo2pwTcJojRrX5uZjIxIgg7QYPZPLXs9y1wHZe7WVZKzCXmXworiVGQnTFVJtf4VXXGru0hy1cwE2utD2HnqT5z9rNqrftlbRagpokmnhHlKd53QLE20qc7U6txTJMliXQsqO41qWhJidkBKUOl6eb7i5yPjaW/iFPErTGHDgNSdXVPFoQR5SykPJnXvfrF5c0WRX0VSeSHFkuyuLHzwk9qhG5pxPHs6BKC1HyGbpUnxLjz8M1iGu3CHAQpIZCpKuKS1ayYpXp5q+W2/Biv12kC25XMnWkCK47WsQmDThlvbhi2FhqFYp/IFgmrX/dzmTmDdnkkFRzkWuy3ELR8HqNqG4PJaZ0hjVj3f/nPKAWATpVmzITMLqnufV62tyHKSJMEpXLxxRx9FKXa9ZB7dhsAvMoXE2WFwOHP/hMOasIUurCyWpPaa+7yLRE1f1NotUdIX1//2wPqJsTo+U5b1FlaCFmGz+jaIKzAIRobTu+EriIKfATAv83SSiBOV1ApPR5Yd3o7jGr/+LfzZMNbd8KCtBV3+4PwdgM9ZNmfWwWJ6p5cKMZ3PiE6Ec0gJWyapEFxAmp00TOqVfprjE4OpITCngoxKB6DAJCepVQejEvrxBEdbZqIxKS/l4guSfPRq0h/PDWhkdd5ZLf0mOF/T4CA81CANnXgKwrXoNgdpfF9h2VBkTZjYkqCuFWOXyKhRgKmuvIP9yK7sJLhM4rru4qfK9UZR3fLeWQNMDVhg929xHc4nSXFdDoAM50WQiqNfpkVRknE/peB887lWWZD6JVLhwyyYzaAOKJZJds4A3AghrKbISMNLa92+DuXC1HmvOkRQkflk7TNAYysX17VOTFwTyATNRvlV+GOdk7A6cr3Cb9t0/uD/gooa4EtsbyFCofZlh48RvlrUUtK3AdF0coizlNdUn6aQWvqx5la3znAYN3ncGW6CR2NSKaPzcx2LdHPLZKNJzXQiSS2yJjMDxXjti9a8EzHibA5hOOZnDNOJhDiIOmn8/r6lZmBJREv4+mGOZ9O2OD9+qGRoSnM2oMRSu5hPedtD1Na2kf1s8FYQImPEWGFU2Os3pVk/0I6BPlO5TIDGSDYvRMucwF1PAyHXAyJPiIZflpsF24z6rCbuJCSTaOZ8vPFRp5DEznhWCxYMfZiGaV/O0gtlIOlaTe8I8U8yxW7Nj751SSuy51GhwlrjKCT1NpDfPgRsDjE1Qwnay5fezqkF36VkCYonBfaSKc6YTVx4y6LG2R4rNT7x8vpz+Ayotx2xKQ3h83tIzD9lys4fPQTb1v6UI0pOTM0OAxR9KLR0n/taRYGrHNoL5RRtdkc0ii0Zr6qohTsJP0HXB/byWqdAsybP68B22hWGCq8ZpxUEBFjnZ/Mhn0H8jVSduvmesMDtyFpDPvo5IomDS3DLwkJI2ZzXthXVYfk8XMOeShjU2KekjPQ0+ZfvtF+GYmCpSe+giltEDtNOd7CZ2v2rHe+nvXglPNFIVx2I2nMnWW4x0XmXXbPOocXomDt1lqmxnZd+6uHseo0Z6b9MwpYfjhAvukwbDOQ0h8NPbjoqYhf5XxrlwfPOzKUowkh6nMXWRxozwuI9lrfu3+8rFl5smX5zROuAouLmdeBr++382RmMdZUf4f5RZCPVDl208wFD6yvvfJVS4MdAD/gxtuB87Fr6fK62HlRZwCByjCVOaBm+nyAZ9fg+gpA= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0eaa22a-83d7-4e2c-ab4c-08d99a031ae2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:07:17.9374 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: P8F6l0dP6UUe8lAo9tsidkfd9ts8qyrL/j2ECas6WLX1ORxXNQYw4xXaLZwcHMPB8Y91CVeuRnGF72NN8E6hLL1w+WXF1pT9SnImlTFK2BY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4956 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Baowen Zheng Save full action flags and return user flags when return flags to user space. Save full action flags to distinguish if the action is created independent from classifier. We made this change mainly for further patch to reoffload tc actions. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- net/sched/act_api.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 881c7ba4d180..3893ffd91192 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -513,7 +513,7 @@ int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est, p->tcfa_tm.install = jiffies; p->tcfa_tm.lastuse = jiffies; p->tcfa_tm.firstuse = 0; - p->tcfa_flags = flags & TCA_ACT_FLAGS_USER_MASK; + p->tcfa_flags = flags; if (est) { err = gen_new_estimator(&p->tcfa_bstats, p->cpu_bstats, &p->tcfa_rate_est, @@ -840,6 +840,7 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) int err = -EINVAL; unsigned char *b = skb_tail_pointer(skb); struct nlattr *nest; + u32 flags; if (tcf_action_dump_terse(skb, a, false)) goto nla_put_failure; @@ -854,9 +855,10 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) a->used_hw_stats, TCA_ACT_HW_STATS_ANY)) goto nla_put_failure; - if (a->tcfa_flags && + flags = a->tcfa_flags & TCA_ACT_FLAGS_USER_MASK; + if (flags && nla_put_bitfield32(skb, TCA_ACT_FLAGS, - a->tcfa_flags, a->tcfa_flags)) + flags, flags)) goto nla_put_failure; if (nla_put_u32(skb, TCA_ACT_IN_HW_COUNT, a->in_hw_count)) From patchwork Thu Oct 28 11:06:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12589851 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21D64C433EF for ; Thu, 28 Oct 2021 11:07:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 055E5604AC for ; Thu, 28 Oct 2021 11:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230217AbhJ1LJt (ORCPT ); Thu, 28 Oct 2021 07:09:49 -0400 Received: from mail-bn8nam11on2113.outbound.protection.outlook.com ([40.107.236.113]:43800 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230170AbhJ1LJs (ORCPT ); Thu, 28 Oct 2021 07:09:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cS1GnAHVaFnyYGBHTRVzxr+4S4WlVv/5WZAv6WsWyIBZpRDcAHUR5vfw0NelToscKZj75ypMWet3Ad4kX9H7mSjNRXUQwoq9TT0+xBtZ2FM458PZIFZd0XH3CXiKcKgowjUqW1MOgyJ7cmlqLj8xt/SrhPJ1QjgajxJaCVZSzpNpRkAJCPnnII8XxfZFQXTx3herIda6Yv0vx7TdJMSX6kAe3IquVjYc1ZnyZo7uoiOCywKJXAtyofwnr8T88SXLe+hrMfD5rQOjcodBY2VhCUpWNWOPnCxd/fF5WV9TlfYie+PFeSLe1nCfX/DEBq+2QKoC7eE+K/Pkv/VkbSNalg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I0Wegr03kFezN66/FhJQz+sJWo3B8gRcHvYDGPJ0Ji8=; b=fac1HMLUj3CSVK3OMgXc4OGdZPcmFP/+ZbJ0It5S/NU/NVTdH8O4LkXfnsYWt/fYcBM4eSxPrTxUj9+2Nco//QTqoxWMliMNdg2uTMfUEc/YXxVf+l/v1ZDm7ACo45hny0BIiyLpUVDDGGXqYDFTgNYJI9gH+WcnbYtBWoix8cmqtZsSU8oMKZQMFACS9kXE0N39ANzs1AT1qkHHMyNXmsKswjtACC9ENe4GrB7GItOtuCRk0W58OZWFlzMQrHNZGJcuzSIcCvbJZYS75etFL6czpHTUzpJRFyzr10OMvDGWoMqYlhBJa6wJ+oRz9CiO87tLVUK0XBXTFvgTQcYsLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I0Wegr03kFezN66/FhJQz+sJWo3B8gRcHvYDGPJ0Ji8=; b=jy3UGgvC9ES4yfji0ukCy6unxQtMYg1B0ZbN7M87C8qyHy+a1RTPb9GzeddvQXwWB9UybaUbzuMvrnA9saH3rcjl/Jv1dgk22EOXnU6VskNuC5b4flueiV93Hike0Ds6uySFfbLlIncHlY25tFuiKfKXI0RScBGCHQjgRb4Wgsk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4956.namprd13.prod.outlook.com (2603:10b6:510:98::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.11; Thu, 28 Oct 2021 11:07:20 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90%9]) with mapi id 15.20.4669.005; Thu, 28 Oct 2021 11:07:20 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Vlad Buslov , Jamal Hadi Salim , Roi Dayan , Ido Schimmel , Cong Wang , Jiri Pirko , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Baowen Zheng , Simon Horman Subject: [RFC/PATCH net-next v3 7/8] flow_offload: add reoffload process to update hw_count Date: Thu, 28 Oct 2021 13:06:45 +0200 Message-Id: <20211028110646.13791-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211028110646.13791-1-simon.horman@corigine.com> References: <20211028110646.13791-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:07:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 140d454a-1ead-4b39-ca6a-08d99a031c57 X-MS-TrafficTypeDiagnostic: PH0PR13MB4956: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y0QLkUS05UxJlD8Aixdu9cDPuDxLSA5F0klY0/64JfIO/da/ru9kmQ7yV0FsvjMCJQoa/DG2RZugVc9CglySZapJXPdwkkUaXa/poJQrwJzJB+5wfjfE/6MZE7Zvrk3k0YRbTOgk/TExtYWGg2k8Ffr0RsTXjSjHB3F+qFe/x1tR6Kg8ZLi3/n2FGFNCRyYlk+Hkn2909W65dJX8clyUexJNQC9omvfqq67Qc6CbnUtSZl1QQm/paScvpFEYwotFrT+V/5ZhSLVSlIzEcoVC5z57phuuA8QoxMsKXc93WFcNnFttCkcmiyqZfn747xJy1qFxydD08nQRRRRtXrCL2EwUNcB/IV1gZ4kfZuSe8+rKj3pji1fB/ke3WtyfBTKgJMao7PxZYx1ZUdUDe/WtEC5YsSCwDxdYuZqpFGdI+c0i8sjZ09D7rkhakaNtQkppLiZRc6x2fsQiAPPRhve5YeKMRJ6qgMWnknHqDkKHQQJ82pFnW48LP0m5NVtO4Tc/wFFHdHIwa3VoeVHIqLmgg5FXKC919K/gHh5+Woo/a2HZ+W3h7/ZsVrp+HLwQcO1wJLOWmlwM5xOnYuEgt44HGVW2G1iYdmnZE+yoIRTiqLhi3DYTvBT0NY/Is+Sv0+n3k0PCBqgtfoIAXoaFzjjcOg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39840400004)(396003)(4326008)(83380400001)(316002)(36756003)(54906003)(44832011)(6512007)(8676002)(2616005)(2906002)(5660300002)(8936002)(6666004)(52116002)(186003)(66476007)(107886003)(66556008)(15650500001)(6916009)(508600001)(6486002)(1076003)(66946007)(6506007)(86362001)(38100700002)(30864003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WWZbDKPCdfzAoh2lLkUAqpvVQ0omlYbEyoBSp9OSzUo645cHP/A/F1QTKqkuo2dW/rwKS3QzaRe1TxiEcKLB3LDUl6xBYx7tmlWnEMvAllw19FqcckTA6iKj0NpChm3c1G2ODpOMO7n5LDeSUWKu39AgFJHozjamTMGY9Q6jkNlRYCtNpcaJmO6zh4sZwpG/4+lLiKPWtZKR9dFKrOGAvxwcFCWtdZgI+TNfsxEq4T+DnG+F8X5mGzw5PLl8FjYkG7yHDi3eX/Y5e0E+pfeKLsQOVLJjcuwQoxv5ndnzCbY+REDTerslSWqrZKTGmYYxYvhm1doyhwg3FZfl6MveIFUU4cPJq3pHz0mvCr64nE7Ojkzq7HkIGrM7crBmetpTdk+f34lMkH33KLuZTn12SI2zE7XG5jtbxjtcOce3+CRWIHVwWrWoVsjDSPxguT13EmVHNsimURywtpps3wmR+q+SXJlzew1822ZLHmuNX6ANBMnf8pPYEIt5hPGwVFXb2iMKUP8Zrmkm3aoEzIuuvoeNYy//rufpQF5cDJJCUWsdpc5WikVbzn2q5Mxctgx5MexmdF4j6NY3MzXvFw+KiYL+ltbp6MBxJPCfJAZmGwBl6JxhKVSmLqd0JOndWbs+n2cZU2neZP7RzJ46/MLiIp9L/C30FALJyzBYEaXHPeE61jEdbbRErCu+Wi6DyxbkApNl7WYM+sfdX4un5Po+u+efGNcSWKZ7WHM9MAbYlNXfjMv4qB9gzZqTlbaNz6ulkB3wcytM5NLWCZ5VPQLQnTfJL4bVRTDeanT8b3/XN11IP739Hq5/CldzBqJjDxcyP6MrjxdKZNlwqvtmkVLiX0vxfw0l2WV92NxrLl/1FCuBysiAgRyH/Tq6k87lhz79Ls4nm2VuXli3giIkw3FY5fvujWMdYWShfLcGmf06S07JEApQUQ31GArJoFMf57mB4pgmsnCWRYH85DUaTg9Ti/CWh5uGoXZ18TKwSjvKT2la3P0s4o6lyNPgdzPhNqItun5rLU09fjpPK676jOTfefutu8Kox9gx2p2TtFjRH+pgjTa8AsAEpoE+S+5TKN2cTQKoa7VVTKHXZ2eVJ9ZRbfgn4pyVzad/9dHEeIX55O29+GB9FXtCs3pJ8h9lI340TeExTtMIZqK2rO3tfDWUOCvY7psLE9fVh7Xk1j5ll58jGD97pq9uW0hVAFWlF1cqhuAxd133G8ow6SZxIDoYA/iWGM3wlRcc+oq239hUN1ozPcSB/IcCSSZjGoggrG+fu8/Uc8emMm9ySx0bR6q30SyMgc3rzmGSyo0vyH49wV/G59d1RujWouvxVeHeX1qxDchZin7yaibeecyX8mo9lIW3Ox4rnjWQEx+0wQu8meohPVcM0uZHfR8qfxHzFq4fJlkfiMB2jsiDY4yEb448ZlGnS6qGtXGhLFaFdS7HwwJiWhOw5gCPLvlQS0WtPyvkNpkkNhwDEg6/ugY9u0VhgOjpS6S53M5yMMkU8kNgQq36CrBCnCoUO3j81ccopGNjSY1qIQPu8RZbtH/K3gSSsMd4n9PehvVn+se5i9doOsLINs932ZPbglEQaO8DSeZgMRxVFAH0RKhkQBidCbgcY8mHSjgKpTuS9bapIrvGfiUttF+RPIX9maxhlCMR0xO9uTsFoDH903Utx2Eui0kF8ex3ETWSksGWv+hCkNZqC8MdvsXOn9yyibWjPQ5jt3gZcR5yhqywYkI+Vpn/cUSnFC2ds8K+cTBGuhti4n/ajF0= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 140d454a-1ead-4b39-ca6a-08d99a031c57 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:07:20.1835 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YwrIk0+HvvxSlBWf7IpFJeseYrIdTmaEPr0Bnr9lKjbfBZXMpCr7fJ70E30ysKIwylqUTTLMPv3+AeOomNOirS5VIuvLC6x8Vf2Bcl6NO1Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4956 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Baowen Zheng Add reoffload process to update hw_count when driver is inserted or removed. When reoffloading actions, we still offload the actions that are added independent of filters. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- include/net/act_api.h | 24 +++++ include/net/pkt_cls.h | 5 + net/core/flow_offload.c | 5 + net/sched/act_api.c | 213 ++++++++++++++++++++++++++++++++++++---- 4 files changed, 228 insertions(+), 19 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 80a9d1e7d805..03ff39e347c3 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -243,11 +244,26 @@ static inline void flow_action_hw_count_set(struct tc_action *act, act->in_hw_count = hw_count; } +static inline void flow_action_hw_count_inc(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count += hw_count; +} + +static inline void flow_action_hw_count_dec(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count = act->in_hw_count > hw_count ? + act->in_hw_count - hw_count : 0; +} + void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, u64 drops, bool hw); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); int tcf_action_offload_del(struct tc_action *action); int tcf_action_update_hw_stats(struct tc_action *action); +int tcf_action_reoffload_cb(flow_indr_block_bind_cb_t *cb, + void *cb_priv, bool add); int tcf_action_check_ctrlact(int action, struct tcf_proto *tp, struct tcf_chain **handle, struct netlink_ext_ack *newchain); @@ -259,6 +275,14 @@ DECLARE_STATIC_KEY_FALSE(tcf_frag_xmit_count); #endif int tcf_dev_queue_xmit(struct sk_buff *skb, int (*xmit)(struct sk_buff *skb)); + +#else /* !CONFIG_NET_CLS_ACT */ + +static inline int tcf_action_reoffload_cb(flow_indr_block_bind_cb_t *cb, + void *cb_priv, bool add) { + return 0; +} + #endif /* CONFIG_NET_CLS_ACT */ static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes, diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 88788b821f76..82ac631c50bc 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -284,6 +284,11 @@ static inline bool tc_act_flags_valid(u32 flags) return flags ^ (TCA_ACT_FLAGS_SKIP_HW | TCA_ACT_FLAGS_SKIP_SW); } +static inline bool tc_act_bind(u32 flags) +{ + return !!(flags & TCA_ACT_FLAGS_BIND); +} + static inline void tcf_exts_stats_update(const struct tcf_exts *exts, u64 bytes, u64 packets, u64 drops, u64 lastuse, diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c index 6676431733ef..d591204af6e0 100644 --- a/net/core/flow_offload.c +++ b/net/core/flow_offload.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include #include +#include #include #include #include @@ -418,6 +419,8 @@ int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, void *cb_priv) existing_qdiscs_register(cb, cb_priv); mutex_unlock(&flow_indr_block_lock); + tcf_action_reoffload_cb(cb, cb_priv, true); + return 0; } EXPORT_SYMBOL(flow_indr_dev_register); @@ -472,6 +475,8 @@ void flow_indr_dev_unregister(flow_indr_block_bind_cb_t *cb, void *cb_priv, flow_block_indr_notify(&cleanup_list); kfree(indr_dev); + + tcf_action_reoffload_cb(cb, cb_priv, false); } EXPORT_SYMBOL(flow_indr_dev_unregister); diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 3893ffd91192..dce25d8f147b 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -638,6 +638,59 @@ EXPORT_SYMBOL(tcf_idrinfo_destroy); static LIST_HEAD(act_base); static DEFINE_RWLOCK(act_mod_lock); +/* since act ops id is stored in pernet subsystem list, + * then there is no way to walk through only all the action + * subsystem, so we keep tc action pernet ops id for + * reoffload to walk through. + */ +static LIST_HEAD(act_pernet_id_list); +static DEFINE_MUTEX(act_id_mutex); +struct tc_act_pernet_id { + struct list_head list; + unsigned int id; +}; + +static int tcf_pernet_add_id_list(unsigned int id) +{ + struct tc_act_pernet_id *id_ptr; + int ret = 0; + + mutex_lock(&act_id_mutex); + list_for_each_entry(id_ptr, &act_pernet_id_list, list) { + if (id_ptr->id == id) { + ret = -EEXIST; + goto err_out; + } + } + + id_ptr = kzalloc(sizeof(*id_ptr), GFP_KERNEL); + if (!id_ptr) { + ret = -ENOMEM; + goto err_out; + } + id_ptr->id = id; + + list_add_tail(&id_ptr->list, &act_pernet_id_list); + +err_out: + mutex_unlock(&act_id_mutex); + return ret; +} + +static void tcf_pernet_del_id_list(unsigned int id) +{ + struct tc_act_pernet_id *id_ptr; + + mutex_lock(&act_id_mutex); + list_for_each_entry(id_ptr, &act_pernet_id_list, list) { + if (id_ptr->id == id) { + list_del(&id_ptr->list); + kfree(id_ptr); + break; + } + } + mutex_unlock(&act_id_mutex); +} int tcf_register_action(struct tc_action_ops *act, struct pernet_operations *ops) @@ -656,18 +709,30 @@ int tcf_register_action(struct tc_action_ops *act, if (ret) return ret; + if (ops->id) { + ret = tcf_pernet_add_id_list(*ops->id); + if (ret) + goto id_err; + } + write_lock(&act_mod_lock); list_for_each_entry(a, &act_base, head) { if (act->id == a->id || (strcmp(act->kind, a->kind) == 0)) { - write_unlock(&act_mod_lock); - unregister_pernet_subsys(ops); - return -EEXIST; + ret = -EEXIST; + goto err_out; } } list_add_tail(&act->head, &act_base); write_unlock(&act_mod_lock); return 0; + +err_out: + write_unlock(&act_mod_lock); + tcf_pernet_del_id_list(*ops->id); +id_err: + unregister_pernet_subsys(ops); + return ret; } EXPORT_SYMBOL(tcf_register_action); @@ -686,8 +751,11 @@ int tcf_unregister_action(struct tc_action_ops *act, } } write_unlock(&act_mod_lock); - if (!err) + if (!err) { unregister_pernet_subsys(ops); + if (ops->id) + tcf_pernet_del_id_list(*ops->id); + } return err; } EXPORT_SYMBOL(tcf_unregister_action); @@ -1175,15 +1243,11 @@ static int flow_action_init(struct flow_offload_action *fl_action, return 0; } -static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, - u32 *hw_count, - struct netlink_ext_ack *extack) +static int tcf_action_offload_cmd_ex(struct flow_offload_action *fl_act, + u32 *hw_count) { int err; - if (IS_ERR(fl_act)) - return PTR_ERR(fl_act); - err = flow_indr_dev_setup_offload(NULL, NULL, TC_SETUP_ACT, fl_act, NULL, NULL); if (err < 0) @@ -1195,9 +1259,41 @@ static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, return 0; } +static int tcf_action_offload_cmd_cb_ex(struct flow_offload_action *fl_act, + u32 *hw_count, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) +{ + int err; + + err = cb(NULL, NULL, cb_priv, TC_SETUP_ACT, NULL, fl_act, NULL); + if (err < 0) + return err; + + if (hw_count) + *hw_count = 1; + + return 0; +} + +static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + u32 *hw_count, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) +{ + if (IS_ERR(fl_act)) + return PTR_ERR(fl_act); + + return cb ? tcf_action_offload_cmd_cb_ex(fl_act, hw_count, + cb, cb_priv) : + tcf_action_offload_cmd_ex(fl_act, hw_count); +} + /* offload the tc command after inserted */ -static int tcf_action_offload_add(struct tc_action *action, - struct netlink_ext_ack *extack) +static int tcf_action_offload_add_ex(struct tc_action *action, + struct netlink_ext_ack *extack, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) { bool skip_sw = tc_act_skip_sw(action->tcfa_flags); struct tc_action *actions[TCA_ACT_MAX_PRIO] = { @@ -1225,9 +1321,10 @@ static int tcf_action_offload_add(struct tc_action *action, goto fl_err; } - err = tcf_action_offload_cmd(fl_action, &in_hw_count, extack); + err = tcf_action_offload_cmd(fl_action, &in_hw_count, cb, cb_priv); if (!err) - flow_action_hw_count_set(action, in_hw_count); + cb ? flow_action_hw_count_inc(action, in_hw_count) : + flow_action_hw_count_set(action, in_hw_count); if (skip_sw && !tc_act_in_hw(action)) err = -EINVAL; @@ -1240,6 +1337,12 @@ static int tcf_action_offload_add(struct tc_action *action, return err; } +static int tcf_action_offload_add(struct tc_action *action, + struct netlink_ext_ack *extack) +{ + return tcf_action_offload_add_ex(action, extack, NULL, NULL); +} + int tcf_action_update_hw_stats(struct tc_action *action) { struct flow_offload_action fl_act = {}; @@ -1252,7 +1355,7 @@ int tcf_action_update_hw_stats(struct tc_action *action) if (err) goto err_out; - err = tcf_action_offload_cmd(&fl_act, NULL, NULL); + err = tcf_action_offload_cmd(&fl_act, NULL, NULL, NULL); if (!err && fl_act.stats.lastused) { preempt_disable(); @@ -1274,7 +1377,9 @@ int tcf_action_update_hw_stats(struct tc_action *action) } EXPORT_SYMBOL(tcf_action_update_hw_stats); -int tcf_action_offload_del(struct tc_action *action) +static int tcf_action_offload_del_ex(struct tc_action *action, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) { struct flow_offload_action fl_act; u32 in_hw_count = 0; @@ -1290,13 +1395,83 @@ int tcf_action_offload_del(struct tc_action *action) if (err) return err; - err = tcf_action_offload_cmd(&fl_act, &in_hw_count, NULL); - if (err) + err = tcf_action_offload_cmd(&fl_act, &in_hw_count, cb, cb_priv); + if (err < 0) return err; - if (action->in_hw_count != in_hw_count) + if (!cb && action->in_hw_count != in_hw_count) return -EINVAL; + /* do not need to update hw state when deleting action */ + if (cb && in_hw_count) + flow_action_hw_count_dec(action, in_hw_count); + + return 0; +} + +int tcf_action_offload_del(struct tc_action *action) +{ + return tcf_action_offload_del_ex(action, NULL, NULL); +} + +int tcf_action_reoffload_cb(flow_indr_block_bind_cb_t *cb, + void *cb_priv, bool add) +{ + struct tc_act_pernet_id *id_ptr; + struct tcf_idrinfo *idrinfo; + struct tc_action_net *tn; + struct tc_action *p; + unsigned int act_id; + unsigned long tmp; + unsigned long id; + struct idr *idr; + struct net *net; + int ret; + + if (!cb) + return -EINVAL; + + down_read(&net_rwsem); + mutex_lock(&act_id_mutex); + + for_each_net(net) { + list_for_each_entry(id_ptr, &act_pernet_id_list, list) { + act_id = id_ptr->id; + tn = net_generic(net, act_id); + if (!tn) + continue; + idrinfo = tn->idrinfo; + if (!idrinfo) + continue; + + mutex_lock(&idrinfo->lock); + idr = &idrinfo->action_idr; + idr_for_each_entry_ul(idr, p, tmp, id) { + if (IS_ERR(p) || tc_act_bind(p->tcfa_flags)) + continue; + if (add) { + tcf_action_offload_add_ex(p, NULL, cb, + cb_priv); + continue; + } + + /* cb unregister to update hw count */ + ret = tcf_action_offload_del_ex(p, cb, cb_priv); + if (ret < 0) + continue; + if (tc_act_skip_sw(p->tcfa_flags) && + !tc_act_in_hw(p)) { + ret = tcf_idr_release_unsafe(p); + if (ret == ACT_P_DELETED) + module_put(p->ops->owner); + } + } + mutex_unlock(&idrinfo->lock); + } + } + mutex_unlock(&act_id_mutex); + up_read(&net_rwsem); + return 0; } From patchwork Thu Oct 28 11:06:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12589855 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20C50C433EF for ; Thu, 28 Oct 2021 11:07:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0955060E8B for ; Thu, 28 Oct 2021 11:07:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbhJ1LJ6 (ORCPT ); Thu, 28 Oct 2021 07:09:58 -0400 Received: from mail-bn8nam11on2113.outbound.protection.outlook.com ([40.107.236.113]:43800 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230170AbhJ1LJv (ORCPT ); Thu, 28 Oct 2021 07:09:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m+gOV1l3mcsuRFKzr+I9ohkeMTunVa8t5sZf2h93tjh3TNZ4IOMd/ukjPTV9tdK0Fa0ikqcBrFUyV7Sajy8FcTavLtI7DifQShO0ETy6dC75gVaOaGXtflCRazTroecGkev0a28o9E9e+Iu2AxxqsLOn+ve/7ZmGWo0BEKrGNHNl4O/aqpsQiKOC2Art/KztfT52Hl3volMtwR0f8u56EWdlRtwVTWIeZnIQthhu1waBoMNr6Imd+wEoaVmPAH+6RW5KQEohL0V/PQruS9r6FKA+fHQBbV1HJvuwUX0Tue/BTYOfgnFd7JCX3U+4W2qzcuNtOfrAlWjg3eYq3pcDMQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=28R8aZtPnnaNPJMk9V88HMkRGRJERf5FVr2s03fIvCs=; b=VbZ66/dhL34Vvyt65nHhRdRvNDuDwGc4eTvQ18NoZiPCcPXsgyJZ+PV1KF3wCY8imrJE7BJ+PwQ5VN0vv+fvo8Ycjc4nf/caHRT9FJZM3uSKfOZtRM+i/jDaFPywvTelUixRGcEmm2I21Bck/MVKROwcwqrYdV7UBA8YElLpk2k5WNOJXfEGcayz2qQ3TyeJw+8dQ9SuMqB8wmA4loYDmKKXf2Lvf2LuhUAeiPiupLW8N6c30TGXc3mkSchwAM9cN5s06bYZBD296lY4C6u2gY02EXY7ZcghfkA+SVCFvaWjiQed4HnxAHpp5WxCnSNoKdACs7ElVKz7gT7DIjf4zA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=28R8aZtPnnaNPJMk9V88HMkRGRJERf5FVr2s03fIvCs=; b=IdOUEU+4DoBkdTJkL9fPN4/vizXRIHPB7DEDs/UwralLH//QnA3B0EoYrg+xahhP0YMdMTrX2M9vfHmfFgdWctgfgJuGMLoAJYVx/JTQrYp+3v5PBDGJlkuCc/H2vL1tQfYiwck/WIioAWwe2NibRWs7ClbY/EygmoMkgXMZ4jo= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4956.namprd13.prod.outlook.com (2603:10b6:510:98::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.11; Thu, 28 Oct 2021 11:07:22 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::e1d9:64d0:cb4f:3e90%9]) with mapi id 15.20.4669.005; Thu, 28 Oct 2021 11:07:22 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Vlad Buslov , Jamal Hadi Salim , Roi Dayan , Ido Schimmel , Cong Wang , Jiri Pirko , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Baowen Zheng , Simon Horman Subject: [RFC/PATCH net-next v3 8/8] flow_offload: validate flags of filter and actions Date: Thu, 28 Oct 2021 13:06:46 +0200 Message-Id: <20211028110646.13791-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211028110646.13791-1-simon.horman@corigine.com> References: <20211028110646.13791-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR03CA0040.eurprd03.prod.outlook.com (2603:10a6:208::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:07:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2bbab98d-b4d8-43a9-b7e4-08d99a031db1 X-MS-TrafficTypeDiagnostic: PH0PR13MB4956: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:24; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wTfOjfIREAnxAo4Eiy1dOc1wu0z9mBjbclGC1CYATPeFbGgOODabfPRTtI82sF/pYCK9cuqaYVAkOdk6bQfAcvWKOGmoI+u5fOZ31X+C+9pLPyUBjcNRi3K5zo/KQBvg7KP61qtSmBruHzive9vXA6XT0xl6BwRgYqGEUFza03hTjUia4dBGj0ZCRhVj4Ls4LzZ0OzAjJN2+Kl0WbBoWaxGn1EsqLtS5Nw2hHbwrlVkVIROzdTudjjDZRBGQ35oRo7q17qnMnMOPrmF1ifQp4bSXiaurMXka2ugl4FV8Xbstjw+KLmKgUSaD07XvRkYj7m1SktK/Iw7nlJHQirFd3U0uv0ahiTUsK52vcTR9sbdd/S2JElmqDyIPnH3vi+qIT/rU99E8V++M8YK/oKYOL8RgjoSpNEUo5Q6cSBaOX4pXFlgpb4FzINWYapKosH5BkufisOOP72xmpv31qXk9er/+za+61Y8uNoau4ZDwAwDdFuMHsKBia/sqrxkn5j2G3ppVvUZp8XakSosQg1XuWKbzuygYqpsTTmcBmwnyVpoV/Byohkcas4L8sS3fd97yjxSGRO2I8PHa5+L6ineLn5kAsV3HDEvl6PQ9C27dzVcwhTCakneI8XLXGai2SgOKJmRsVLw6PJU6ywE+zqPocA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39840400004)(396003)(4326008)(83380400001)(316002)(36756003)(54906003)(44832011)(6512007)(8676002)(2616005)(2906002)(5660300002)(8936002)(6666004)(52116002)(186003)(66476007)(107886003)(66556008)(15650500001)(6916009)(508600001)(6486002)(1076003)(66946007)(6506007)(86362001)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gZSACZto41R6Rp2PqnqI7G8h/HEbvh6vR6Nlbc9N2Wfah8z3O+TrlES/ec4FuRFNbWChBw0RHSv92FCgvzl2RX9oFD4+iMbKJaf4WZkYbnE4V62UjW8qkQYUKM27rJWGU5hUrm3/ef2pF0toVcM1L+xuWYn9H3SunHYXNMzBHKZ7aBU2mgjzqTV1TKlssWiEWwcU/I6GhQDR7hpJ7y1zAYqs83Zmh7wdoTzamezyUeLsUzyMyKLHLhcf1mO1J+5TcAeoAUYOmZ2hVWONTfHU2TpCvEnlvqzvFsi87O7V6SjK0gaTOIhYMQakE6CK6snvnDd/uQHH+42GQ/ihh5HNoVJlvahrs3nJlq3TnH21hasiypssY1015XRo1ug+KXaQkkyaif3WUp8VmL9GrbSseMaOZOexlVL+4QYO7fTq5YR4pnFQPys2hChgBDQx06JkdFO8mF6huZquh/zJkO7ANhWdciY2emJXQgyT+opkfqXBAH745crz1jbK2xhJ7CT7iEOlNiW95JSI7dpAUDGSjHDQnArjligiPjrxXAqbj7oM8gDFY2IZlDuiTjixZFEaayVFVzbb+qCBmaz68HbDueRsfAPWDESCSS3vzhgZYhN/zRFjy5/u0ceCBHlgG1CNSsJ7eXvUBrpJ+uXJiNs0Ovgatwp2TDal+ynIv2je4B9H8w4vTpw1MrZ8SHbkIrBTpjYQYBWaLzMOxMpKR3sCUonseekEwpIiri/kFwBvTpuQjOWhyBeENkmhQFki4ygmwEkMvy6C6Wu6tmXL+k20qOxGgPJbt1NthBnH11OT4Ia9jTzmUF/lfAMNLbaf/jubELaKYjEnneIaL2FjjSeHxzx2NxMLCg77PcooI3CmzMeCwvfXou3qw8+6Z3peVJ/ysD5UYRdodpH41b9FLSWJT41H6S12Z6DjVti7zEqqnJ2Exx1Onpot6RXcNBV6v7wZKqkTuJEkQD6SHvL+L9BI9mHwZnlfZpr3LPtgD02A/1GXIyXqrHKJGu91RbazbLCqCsBowsBgSymBLt1T0XQ2X47xvRd099cyQqglte20hefxZWoHOE7dC1QDuR/eXy399nFcJ3iHLKLVWEpKZuriUUKejZnXQ64W3V0Au3stTIXYwabcRYcYGooj2Kf8pTR7NoyK/ynEq1wvMJUPQoN/5Wh7BrDz/JBVbl1rGUJ/Cy3HGayZX7L2dSP4i7MnuglfBsqAnlcojhvXBObXDQ1PRJe3sLvVBwMY52ZciyszQls0uydncnl1P9c91f41Z9SfG1X6RsmZGxXoR8EGyEjQJOkf4yTi7lL2ONvFn2tlC9EReL+ZonPD1xFDyUqR5kmi9v8E7TIb+rX3fnAWxRBwH1KODFq1QYDsU44Rre0nmJ4Y5aW1IfJaL4PwbtiJnI+j5IBiW51Ed7stH8Db983UGhVVhcChb1bkwkq5uoMdkeTbSfkxTVPmQ7U4lHFssX4OHHtQRjjsSIQO3TmDwvdv7YxosxYRm8faA8sLLxtgV3daYWlQTvbwfwRurthyjZduOFwsDhonKOCOOJzXYYeJI/vK86HLTRYLlclioUbsgm7X06RQ6hbdabEkQpASliNdYJz6JnTvIaZ2QaMpcpp0VpxaTNKsDsI5TpGPY4h1o6T2St1UReZxrhkHPg1VlqbY/0fugktlzsVdSzJ2wse9/vY+HCrnPJZMyjYKPMF2NAK/hme/tG8fg4Oa+A4TSAGzc/s95I0+sZwTtc+EPBlrbN2PO5xneQu3jUKBfFHgUg4= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2bbab98d-b4d8-43a9-b7e4-08d99a031db1 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:07:22.4237 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0hXjpXbqmXccEZ05veij50HRi2OsNPEBH4Q2m7lzWhJ4omi2gl/T4yVWnucMM05B0Ic6V1WMYE34Pu0P8wwoM2YJk02kOLzhCyReWHYxENo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4956 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Baowen Zheng Add process to validate flags of filter and actions when adding a tc filter. We need to prevent adding filter with flags conflicts with its actions. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- net/sched/cls_api.c | 26 ++++++++++++++++++++++++++ net/sched/cls_flower.c | 3 ++- net/sched/cls_matchall.c | 4 ++-- net/sched/cls_u32.c | 7 ++++--- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 351d93988b8b..80647da9713a 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3025,6 +3025,29 @@ void tcf_exts_destroy(struct tcf_exts *exts) } EXPORT_SYMBOL(tcf_exts_destroy); +static bool tcf_exts_validate_actions(const struct tcf_exts *exts, u32 flags) +{ +#ifdef CONFIG_NET_CLS_ACT + bool skip_sw = tc_skip_sw(flags); + bool skip_hw = tc_skip_hw(flags); + int i; + + if (!(skip_sw | skip_hw)) + return true; + + for (i = 0; i < exts->nr_actions; i++) { + struct tc_action *a = exts->actions[i]; + + if ((skip_sw && tc_act_skip_hw(a->tcfa_flags)) || + (skip_hw && tc_act_skip_sw(a->tcfa_flags))) + return false; + } + return true; +#else + return true; +#endif +} + int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, struct nlattr *rate_tlv, struct tcf_exts *exts, u32 flags, struct netlink_ext_ack *extack) @@ -3066,6 +3089,9 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, return err; exts->nr_actions = err; } + + if (!tcf_exts_validate_actions(exts, flags)) + return -EINVAL; } #else if ((exts->action && tb[exts->action]) || diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index eb6345a027e1..55f89f0e393e 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -2035,7 +2035,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, } err = fl_set_parms(net, tp, fnew, mask, base, tb, tca[TCA_RATE], - tp->chain->tmplt_priv, flags, extack); + tp->chain->tmplt_priv, flags | fnew->flags, + extack); if (err) goto errout; diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 24f0046ce0b3..00b76fbc1dce 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -226,8 +226,8 @@ static int mall_change(struct net *net, struct sk_buff *in_skb, goto err_alloc_percpu; } - err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], flags, - extack); + err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], + flags | new->flags, extack); if (err) goto err_set_parms; diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 4272814487f0..fc670cc45122 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -895,7 +895,8 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, return -ENOMEM; err = u32_set_parms(net, tp, base, new, tb, - tca[TCA_RATE], flags, extack); + tca[TCA_RATE], flags | new->flags, + extack); if (err) { u32_destroy_key(new, false); @@ -1060,8 +1061,8 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, } #endif - err = u32_set_parms(net, tp, base, n, tb, tca[TCA_RATE], flags, - extack); + err = u32_set_parms(net, tp, base, n, tb, tca[TCA_RATE], + flags | n->flags, extack); if (err == 0) { struct tc_u_knode __rcu **ins; struct tc_u_knode *pins;