From patchwork Fri Dec 17 14:21: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: 12684747 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EC69C433EF for ; Fri, 17 Dec 2021 14:22:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237266AbhLQOWT (ORCPT ); Fri, 17 Dec 2021 09:22:19 -0500 Received: from mail-bn7nam10lp2105.outbound.protection.outlook.com ([104.47.70.105]:16746 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229587AbhLQOWO (ORCPT ); Fri, 17 Dec 2021 09:22:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D2XZmmdHu1QdP8/ExVRsOok04SfaQ+g3m3ojCIO3hEqiyoqoCNVS2eS9VbBokuPF7P50NdfvpBIozNERfO7fmIyvtFpWeix/oGaZ4UiFPu5asvbT2b3Sw9j+K9lc4g1170Uy4vaPmfjgYctRm0S2iZs7YVqJy6xi6XZJLpWsuRxQtKO83/V02Un5Qr/3y/+EpBGBqKScKRisOcmSLI0LvXaF9JVJq1H6PzCCIe7NpDRqLYjXNktQX/g4aRFhtsOyVFqGJIfAdSCTuH83U9S6V8cFRIVCq9q1+PNO0CmqZC5m8z6s9VMs92oQcUj6xx3iyARCUBW5iuDcS+FW++T0VA== 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=IGwWhdokVA7Y7a6J70GoTbMdojF6CQOJO78VX+r3lfs=; b=nhjuQDEQ76Ev1+0pcUW0N8TzmqMeTdfZnNaM5Srq4R7DjNEI3iFbJP58SGPSPiNiAlylNaIHgAC5WdLgbc6bbXPOpMIImmwj62cja1JB0fEWko08nagAphYBLvuDV8Fdf2nf6aFuDt1U2xc/V79g25V2Yxe/uLlcVEB8Xc1d2CqtySrJehz6CYl/6lwyrKApw2vGMIxgOeRjMd9DeiQ0rtkuzL7p/vPJmTrBQ6HhIQ68bjThzqx6QD0jSL0Z6paTt/HWgkBvf2rUDJXrFC2mD/imujOy91zEDbimWXro0rWt/37xJiRrcQLu0xfTuTiHpJOvmplNUXWibf+MCI/0JA== 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=IGwWhdokVA7Y7a6J70GoTbMdojF6CQOJO78VX+r3lfs=; b=TfNq0kgoL0kFUhicI3aLnew8Voa4hQd3CDl+na0DplC7ixjIuBKkXSKuXl+p2tRiaKceAWH30lBKps7H5BZHbCd7T3MRTT+S0VrOPsusN96v8OriXkhRA4tQYF5TrpS1Tv9OhjIJ1YONzZqL3gbNyrvlDGWHuGtvP5YKZ4bftmE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB5469.namprd13.prod.outlook.com (2603:10b6:510:142::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:12 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:12 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 01/12] flow_offload: fill flags to action structure Date: Fri, 17 Dec 2021 15:21:39 +0100 Message-Id: <20211217142150.17838-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dacc0896-0b32-47f9-6738-08d9c1689de7 X-MS-TrafficTypeDiagnostic: PH0PR13MB5469:EE_ 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: gbX3t7eyRDxft390y7W9o8k7CfDUK3d9Lah20K6M3oWI4lN6L/rKJLGcK4R/wBsEiHBk36tCA5CtzhUBnlRg6pv5FwtRop69K7i0VxtmHUMU7+J7QQIlImuZIWas20YIrYm78gz5SFRZ+xZkxau08rdbB+LTW9N0UzsuohBB1tXVN7YkQJVh/wtB4PYtcmug7Pbn1eFiwRK7n8laIkiOfi63C/HVNWBG0x2Qbb7/9ZkLOt+MeL62xoSydUyokowEnBfoFr2SadOCHahqZYIaW4NNvP02xK0ITKRuw6jH4HWH+9pxtvvTTOPQ9KSCn8aEhVquCKIE5pQCppTyDi0zMiTfUSVEEWnNY5ZRBjm8fgtcanF82Mymgg+mTLTHt3w7s8gVCM+4YN5+Nf4TQIObVodR74zCteY68+K6rcpa+tWkjP2ib8yl7d3N3idZJNdWPKkjJd2cyVqb/5OoKQL0XFEFc+Rqg4vf/HivZoGqxHOlj0KYgkacAfeqZQlB+PAzUITJOZK2RTkU12UhlW9EVKPibW1Fdr19lpAz3tm9o4zhWpH/UsgLB/3+e48wG65V0rXM+UNJN5sUAnZ3ouR3DOPttym/kCaoCOfDMOW2EDmyBmmjTNW3BCCInaKAIlX7exojQ80UIH2daPj2Wz/ZjLPYhrk/NC+RaLd1DJlT2eHmgdcghI8es1bVaFFbG8K9 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:(13230001)(366004)(39840400004)(376002)(136003)(346002)(396003)(7416002)(5660300002)(83380400001)(36756003)(6666004)(186003)(44832011)(1076003)(107886003)(6506007)(2906002)(6512007)(6486002)(52116002)(66476007)(66556008)(4326008)(38100700002)(66946007)(54906003)(110136005)(508600001)(8936002)(86362001)(316002)(8676002)(2616005)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4QjFJlVIqc/5f1yVu299YV5PurMifxRjYtWKvA3x9A9Ub94hzp0oDJ9tXUu1nQhoT5W2aa758ZgY5pDejeaIQ9KKgLImRtYwqIj6YdpFalLo7wzBW5LCPyH3jiVmLDnu2zl2DqRIgtHbEwDGV0gnLDgJVy4Y6Y2iAKiFvCMCvmxBhz93a6Xv/xInZw0tGLZSVQ23kVKZMNowP/j/VaJMD25jPkdxB9ZhC5HZTKiSOMSzHKBOif43fQQlUMcvRU3pMjuHJ27w5POL/1DblQf/7bGrdwcT+FX9rH8KAtd1IIuYULgngIHfeyc5BwOv5f5dIG9pOFWQrIsLnGUDUlb/I4SOpgWxdxM+39hXwjYx3HKiKQjtOemJmQZ9IGNEmu0hApM58ny+vgylCuL3FbaVX3sxbqVUFuokQ3lUIOO4nQi5gU9uNQxzscRb1U0f/AU5KyuxB8bDVRp4FPJQTRGaq7k9OahUDrOtWFJxMdZGc/bLGgmqmECFdlIC95qwPYxjDblXt3M1kA2/4dJXU5mk233+al63xLvHaj08COdaVQSI9I1HD36NixtsFyGd1YdVVVG866AmxVcm762K+6iP6fgWLg4+mdev6R93qQ981G9JEon1DWnP1si9fX11HsBELZU8ScR6ybOsXU6a32ZYDIMat8Cvyzf+74rLTjuSFOC7qLPoh70IAAnigzI6Zmmu5FrBbST847Qc19KRQd1WkKwzxrmzDwXltX6fqnhT4SWIjeKnI7NUAiEWs2wMXSgLK45LWFTDR2frj/ekLzRh7pKxHBlz1zGcTTWSK4q/xNhzqNsmyImqY2W0Ft9a/o1hhNJcOAzc+gxgXZwwc/lVlJQ/DJXH52LGHGQbEUgSb1jr3/apDt3ybg96lpjk72KmACOtigu65XmIgWuMJJD/fpi772ICYnS8k4wPrwdic1R5wK5C8NhJL7r0djyjvGNwqJRPsGeSSwTLEShRftiRelvOHssCLaPE7rh9bM6IDeIf/E7tgPQPofB990Kq3eZZqavII6PucqnrpmZyWnehORRONRHJwYQ+PStQV8A28+p4HbSDIGSjaxCpSmMN8CLkSaFmsQIc1rrYmYve8Ki67fk/933jT+2qVtY/93nPW1GcCWk0q5feyzR9c4DGZNh5/4+2Kj3rGckDrWeTye7IRERoQBw+mrLRwAPliSny0qDKLB9xDM9TMAXYMrIac1yBjSd29g+Cl+n/Eyt0omoK31Ja/Yxe6feQBpxagcLcZc8jKzZlSL4ua4rwQAFLHcAwGPY6bKJgeRjCkgL+PTehQglM+UBpo8oXFUpiKKlHGgm9zwdqyDS7ivv+2h2Kx35wLRHKQZarNcfYyFT4nm78jN9tlnB0H5VFsSDnuNuGXqJKeRP986HMUmsnpXNIInE/nWSHWGATj32mtMQoDwHcWbkDCSofBgbccgEA3lfMoQ5rN2Mh110mp6PyYRLCzm9+kZh+CyRgYdHxLql49IpGv1/2/bCFPazdCIrnHLV/pvODPHynn8im73C93a0GCJZQ2SQEVsrIywaTB1nhhy/Gh5WWlFbZ40n9Eo5siei3CwP4Xpaz82YwdyYJztizvaQYyT1n1mMoWKaTxQREGoFvrnNQlC1Ef3OjfCwYa/SpDT28NRlwUGD2i//FnGeHL2gnGcAxM1wbtKbXaTDTyKEzmb4HaIBQYH5GzS5KBOR9WdSdVRIKjOx1a3LTggk3p8tyTeoPo1s5CDMmC+0UThju1Q== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: dacc0896-0b32-47f9-6738-08d9c1689de7 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:12.1594 (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: lSkEufQAU3HzyDVtL+oGlKD/N3j8CSflo3TYst5ML1tqGT9LG15ekVqP7VribfidUGndd8ymnvSAohGa5FFV2m7M9ee5dbf/pqTNSNcs0YE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5469 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Acked-by: Jamal Hadi Salim --- 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 Fri Dec 17 14:21: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: 12684749 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75E6DC433EF for ; Fri, 17 Dec 2021 14:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237220AbhLQOWW (ORCPT ); Fri, 17 Dec 2021 09:22:22 -0500 Received: from mail-bn7nam10lp2105.outbound.protection.outlook.com ([104.47.70.105]:16746 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237125AbhLQOWT (ORCPT ); Fri, 17 Dec 2021 09:22:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kO9tWuQGstERlS5MnhIc16rp6dvSfujaUuuDPlxcKu7pfeAZSicSTcXPBUW1WuAp2H3FSiFELX7R9AfcqeFLclKWwlcLhCp4rr+yCb4CyJ7+1018iOCOEeoy5H+ZiftCDBaeI76TbyF25oyi8Gnjnio8D81B/gJqeSdMDmhrb4YjqsQm/K5RHoPXw4VuetbPNf8GXcAK78f8eHQQLbFP1SblGXvYBTK35IjKJRffcw1Lc46UeMIVxMyjB3XsLlKgYtJQNbC7gIYlDYwYVvpqIt57Jyao2L4FTc6ZkbVXb6DSyONs9W/RPRW5+zeklbOJrsahNcPc7hzxdG96IqILiA== 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=Hs+dKXZZSvKbfLQWptjH8Rwe19bdXbG1jYOuLoqdAlU=; b=UekPM0jjh+S5Ap3pY0WazDaCK2u9yVble6r3T+8At3Rhb63mS5ugMckHZ39TlY9h8r3bobIY32H1r6WHFCenDjNE61CkXL440uJw5/C2ig7A0MLadFM/gRC2h7H1So42+v8gOtjKKDWaboB3qlP0PmPl2bsNj9KNtd4WEMHtTh+cmf40fwzD83pNamOFwIVBggQve5R9bINQtGroDxT337MND5S17pJxITO1gufgqAE/Gtdqaz8dkKzFL2gYz9VDvYjxvbLdZQda/hcYRZYTb+P6W6CTnX7C/AR82PlTNgzfUbX4avB/0cUc7OjNE2QA+g0dqCgeRWT6lgXq+LnElg== 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=Hs+dKXZZSvKbfLQWptjH8Rwe19bdXbG1jYOuLoqdAlU=; b=qFKxl9s/eKMrMWTxmMCrtTFr7qHGddfKM96KR13D7kpftgJ5bPNMOovyhWouUGY2thFGZlH6ttlABx7TibZB341zEoAFBYpNSMbugC3NnesNFNarEYQoGQS8ievn9ElqOlkvpbxCzuTk7l3enBEOJvXc+7FKL264aTDkmBKua2w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB5469.namprd13.prod.outlook.com (2603:10b6:510:142::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:16 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:16 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 02/12] flow_offload: reject to offload tc actions in offload drivers Date: Fri, 17 Dec 2021 15:21:40 +0100 Message-Id: <20211217142150.17838-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a189f3f4-9de9-4e70-051c-08d9c168a089 X-MS-TrafficTypeDiagnostic: PH0PR13MB5469:EE_ 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: NNJnrvcSL0FB4Foe5XdKEK+IFQyIq3Mm8xKI0y6Nse+2QL1ObVERIuXU7eUbyHxJby6/NUbPEXiBV7EC1H6BEJm9L+8yS6yL5WiaeG4vWC2uv4rteoircZkS2ZLwckon4v6gy5tCevf48ABNsdGJwwBepO07Dk68cPKEvRnl6XifA3xPmXCTCifcSieU+EUt6c4N1N7lK/mMTLuevKIS1cRGN3f4O764k/9qnUSD+o+c5HMwPpV8N0PbIJDF/iikNxfVOagu8MCJE+SrGcyJgRQOzpgTba+KvSxCwAepX7bp0mdq0A96wkJfNHGpFg0DDTKDraSu4b+IRsaO9IZoxOviCuuf3zwA+rONd7ylvTskYK0XL1Z/q9c8tskixXuXlenS6K/lfTtVpS3A1rTVtbT2sJmAMZ+k4c0UwsvfEYOjqF61gjUa6e1hfBUPW+EhOE74Spvyqva4v/dG7zYTxLfahEHjzfALnZZVdAbyideRthgkw3iKQwDRQeXcbNjAadqEX+ph2GRPxYmc5g0BJIjpHqO4Nkc2+3pdAE0tFQ449PEMYyWDEM8ycffzY3itcbHxEHgPSL0ZQRQbDJrj4YA3ZtY1DIysHDDRsn6pUGGSh5Ci85LdnXI4Vy2A3nBs772brn7Mdn6bXIYUXhV11mBq/y2elFNo8MfL6FfUEmkZ8nAVNfTuJITGpTV+gkjIvOg8tsVzlMIGXrJfJFPPLA== 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:(13230001)(366004)(39840400004)(376002)(136003)(346002)(396003)(7416002)(5660300002)(83380400001)(36756003)(6666004)(186003)(44832011)(1076003)(107886003)(6506007)(2906002)(6512007)(6486002)(52116002)(66476007)(66556008)(4326008)(38100700002)(66946007)(54906003)(110136005)(508600001)(8936002)(86362001)(316002)(8676002)(2616005)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9Jg6vAwX7MDhfymcbMB7P+nftmoVvmfHdbnYeeOtSyxA65ez6iIHXrpr6eSSUwnNawu5SwUkPtJwEK9EZgzp7dI41WGbizCscC6ITxroTCopIXWb58EmuLmDLJpRQwMSmsWppWeoO35fqCGiFhrlX+5nAC0ry2OzDMumQUjuukEct3nePHWHbw3pELHmfCuT/n8JXplQzkeUeEtfl6lTQhI9b25A4HaYo/qmLSPkgyU/cBTEFEYK3tTvyRUJLm9F+Y+7P0qGRWWUh3n2kVEBBEqAh6u9O/AUq8RScG2jDXJYMtRRwBVSej2eSQOL7X65JAfqV3oYp0/EP4UWn7ZPB1L/J4XzXeDueMmdu+renKELfKvJvloMXcPtwIhgsbIC00W041DDeAeoe2HVBo2+sWURAyM59YP4RY/umIwzndoYOrLyHDm7uNLm2DhhQbkJTHJQ0rSk48fZYH2KapMjSVQgK6gIfkhZemdQ7zE1wDsevIHAGdPS6zkA5jnnwDAjX7jPTdasG7vL8/xMDofkRyZNMloj4Fb2VrRaLa+vXhCdKtgNn9UJXiRufc+rJSYnUsNmb5YZycNrw7UxmD/I9985Cbz5lCIUyFM5RXga6NxyNGCOn0a87piRXJaDLfO2l2UXcJFfSx1r8scWmgi/gSZMQjSLkPCxCSkeIrFYuqAD7Y0otZ08GGsgecg/11A8ljCyqQgYuqBb792V+7K2M6mkNFzlHqvez94LgYLafg36AoD19DIyKjWST/u2+5sXQ9ySGo9wPJ+qQuIzC1Fbs3m0f5jOFFq5WShdROLB1elwRfub9oYdXwX6gtZgHQ69EO4Lip80FshnThMJEI1NS+MQHgy24RLdi1MLq49MEW6w/P51xXW/AnP0x6bFu71Z7yQwJdgP/jV9VCKFpaYWTWlC+bGDu0WSUbnfi3kHbRbPPjZUarNHPCFxPbxunavvjTZzAYFZJxacTQSzhTQc6jfC1JutEdRTSm+TebsdpWL0RN7je7s63hv576rmCCdy8gO0Jb5UBqayNHMgDUiXHYyuK2WmJ7b21tAnG5fVMQ0xBE41FRgN2QtFuhtyVC1DSa9KDz5nRIzp+HAKXWBoQwU+l64sND7WUm/Y5ZY19bARsCf0+3elMJgs7LPHTUpR/xQjWukmr07u6X9LHL6s9+oquaYmZ+M1yH14iVbGO4rKoMMoonnM4WtjeopBh+HOnF+G93U09jkntnJnJIN3Qg8xQ1buytpR1///YwigyuGcVOP5G9bNKJ0M0t8+8voM6ryWMyFH4gfJ7RkFAABI2+ouKp4wM52CHDMrXt/JD5+zmMK6ZRmmhVhQSKo61iMc7/3ZkNAWyYFtdCCaEfBucyEK1pEqo7hiQl7EatVOcBwgaIGq1HhMknODEcAqIgLVezg66l+GX6NqnaJtpEdj9XO0b1mZktmayFg+akPpC6ZfCWlXfQjpgHoc5ZVAaxbMOoFDopD7Xd7dnsehTRJheNk1+Htu4tbiiyT35rNXzE1+p5CYE11Dv05rCPkyRMKsIhR7clQ71W4GC/X86rlcbzZr9VKUAABSMMCK7xNNS9YTwk3UbCA9T53dhhf44DD4AoMw/No4fr09WlGX0CYIudU+jlCtCw9MQdNV/TYyEJ8MLg43brVIEJL75HmUsERshZJbuteflBP4P722nUm7r2BzsDy/KmrJTiVttnk5y2CApSc+Vt9TllI5Q2UNCvowiCgRU76tnuWETjr1JMFrDQ== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a189f3f4-9de9-4e70-051c-08d9c168a089 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:16.5561 (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: xvcYVobSWhxdq1aAo1pBT0o6MEt3oJiAwEFBDb326Lnt2pGcigIPPomaNG3s+xwMNjrrRhYdJ8VUfTRPADf15LAYYGkm8S6p6ocbAB3w8fg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5469 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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: Simon Horman Acked-by: Jamal Hadi Salim --- 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 1471b6130a2b..d8afcf8d6b30 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 fcb0892c08a9..0991345c4ae5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c @@ -517,6 +517,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 224089d04d98..f97eff5afd12 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 Fri Dec 17 14:21: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: 12684751 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13509C433FE for ; Fri, 17 Dec 2021 14:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234693AbhLQOWb (ORCPT ); Fri, 17 Dec 2021 09:22:31 -0500 Received: from mail-bn7nam10lp2104.outbound.protection.outlook.com ([104.47.70.104]:6434 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237252AbhLQOWX (ORCPT ); Fri, 17 Dec 2021 09:22:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q61CgfRcoWqSyzxsi9UzWEZRzWpoHmJ7yGLn3JonMsLWwabwOkmfuuoEKYe1HeWdskrNNvnkwgDeuAso3oRZm1KQ86U1wxp40YlnB5HAKe3LhGgXgFZ7CLqeCaVFU5I3V/rpl1tzUmSoOUburlHToof3jAgZasKvpeGua7aTPzl/FK8jTr23AmFWvU9akkd+NxSLbM6r/syWPrZ+ZB5ZxAsUTr3hRWYgNBGM+fMc6AfSuBFj2nfJFcTGOJw9QeN/sEJnvMNXpKvFx+kluOykNdT+EeWeO2w/u5kwx73MzQ+3VJUl8KuaLBxbPxOPBYdwzfrlL9E+78nxQ96KCDK2mQ== 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=rDxbz0agi6tuKvuxZkL+ESnpnv5yDWQ2KIvtKcBMQm8=; b=mfVLEGKcACAdigfjQZAcwxwMzyo2NRVoTLPezrOeknuQYBPooBsJtobTc/xHjZboT5DCNXx0PqeP4dJ6yGmeAPwVvwzKpBzITsYFu0ZdxvqtLoo/qxHjgad4nAPlN07xtoK4OzGAniqL3rDzPjRAQZvExJPq8Zv7gsM01LBz8omfn74zk6LmzA6SUU5aMniNi8RCn2aC5LfryAi3cuuTJ9NglkB7rEQet6U57eN/9CLrey3o0Ap9fz9eWCPd8aSiORJ9M0J2AZPoYfHkr4Ot2G0IOwVn9H1moBfZ4yGrxRTLHszbx+WN3/UbgmcB5oMQB7K6yMUxCaK06IwJ1czJGA== 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=rDxbz0agi6tuKvuxZkL+ESnpnv5yDWQ2KIvtKcBMQm8=; b=Ug7+6ryRJMVw1gyF8mOhJFUUECmuZPvNDZLGStTKpqRof/DHGVXfzv87YYlGGeeR1b8BAIymEB42ozmCblSGCuWjdpwrNh+HA110VnwUl1lVrLZqojUq7uzg8gSzzseYmLTEKEufOryRQfi/A0p0EGozZxGC2Bk4o0Uwxi7bsMw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB5469.namprd13.prod.outlook.com (2603:10b6:510:142::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:21 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:21 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 03/12] flow_offload: add index to flow_action_entry structure Date: Fri, 17 Dec 2021 15:21:41 +0100 Message-Id: <20211217142150.17838-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78c11960-e167-41d1-8f55-08d9c168a324 X-MS-TrafficTypeDiagnostic: PH0PR13MB5469:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:64; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eYo/6FtkOWNlPL7xci7D9brz1NHPysMfwKDN1Qi91as4P/RF2RYEkXbBUTX4zU6meWGZqba3nSodjX6+0JE0Yn4DhH2hiFOs+La5+F4n0HmSmbB6OJh2tfsP6RWDi1CPXKR+EvMw7MTFLyC38Usln/oiLGk5byzPMsIBno6NAHkn1CgsulUAtRF6yaq/22mdKSvqnwh/q16kARLIttdZ4QyIhZLAaXmwinAO74fqWd53iLaLzJ0EOj85rkCF6f5fRGK9T9bPcp7037TqDOfH2HLo2D5IzIs/zQ6rOj+cDqROQT4LkqjY7+gH0o9X4vwakNQODbpno0yw5WUBjcpISzeLvi//VD5Ml55XbEJrwV1B4x2Ym1xUhxzy496hdKwXZg3IzQghvn9Zn2jU9gYeoCaosuM9dgqxyJRut+mx58l378goaMO1zRQvsGI7OtiMPKZIVUP1NCMVkNQ/t9Bfa0b/yZn3TXDKYOVJ61ZIxvdta1N3uvRgpD1/vzqpQPNkeLCWIyZl4QiYmOYENQnSg3btoivy/9gLEL2IiaIIlGumj8Aicf5I/SToJEhbvAUxq9LG4glNu6R1qDJknnNAw8XlV+J669KNep3tD6jdB4ys2DQ5kA5XKkGobgvpWzoJrKRIYqQQzyf+z4YIGJEHsS0f5BjhxSvv/mPhzbZMKqIQbnyk8/3RfQvYbunfKhERbFYq7GoRbc3PrPFafW+Sng== 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:(13230001)(366004)(39840400004)(376002)(136003)(346002)(396003)(7416002)(5660300002)(83380400001)(36756003)(6666004)(186003)(44832011)(1076003)(107886003)(6506007)(2906002)(6512007)(6486002)(52116002)(66476007)(66556008)(4326008)(38100700002)(66946007)(54906003)(110136005)(508600001)(8936002)(86362001)(316002)(8676002)(2616005)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qwvRHSsNXdgdQCDZfZXacTAkFmItaZOZspR4yXloGIOc2Ma2YjXIm8UOCEXWiZPGTUpPUHaxFv2Y4ocMzu2fe0NcxBcJmwE0ZNdJcG4sgffDd5RheDOFHWnwsCfzjaU3aKH26Emwbvv/eXzOZEFXI7HHINHebnnt4JhmxWhGYvSnmqdyn6zZadKnv5q6fT+8Rvg2XbcJuNvByKfkvsNheuqgFzWJRrcxJ41h4P4FVCHsnKTzaInO1vkL9V8UkZz2fLbzdRUh+AqZ2fnCc3jJtP+7Sc7zuIS0zW1H0/HFazqf1CgGxJLQPandmxtQKAC4QOLgT3sIlSaOaFiQBLNr7HggJZhDhL5jQxhOxLee9xaFbOyz/HDCIVoXJNVu11NdfPmnuED8geVxF4PHCOUHQ2DCedIYePshZWdb2YDqzYQy4qSz75EqfUyUi4lNZ66OTk3zxDM9Gc+pxgPMikgWuxoynVJFtiMWMk2RokNylpO3cwC23CJk+1MXOyU3Ofh5dcrI1CNYPqGrEUVTDsFesIBJ6YwifU3ltdLczGlJ1EJHjQ3U8Qw/BIlvTfDF3ljoNWZT/6Ggzf3sRNNhT5eItS6PCJjc2a2D6ele0ahLllV/2cfQnTYbbWQdZFwFrwfGUEws+o0mvPXm0jTbmEw0G+A1FX0IoytXXnO7UejiS8KiKIbnyeZC2vIw5s9VTDQdVQHXK/b+QWzrkbAoAO4BCKBk3GjBI3E9jQQHwt///QtOj88zdrRTeINespIoWlcR/X1IhedOxhZ7Q+GkULSO3e6bAfudQTAz1ZDgR3hhGNhpHx2KL1tw7iKkrucPUOa90YVqNKM+XTLLdGjwwXXgeTj5EuBwHHQEmsaRWTRArex++1PLXx6vyOYa0l1YwmteiI9UKfil3cE1Pqjh0u6mFuCx6avA3cuob9sLDnoiTTHCG23U7tDZkXCS4706HbubAdysxn9dqYA/KA/AD1UZ/BxZORW1W31fJCj4Xdjx+LcIczA8I2NNwlqysGHHmW3/CG83N5qLAS05vwPGBElsZrT+vdenq59lXNConCJ3Cjh96kfuqcaOSxbQE3j39hZ1iHUkXsy6kHEAckaTnL5gyijpUrH4NTK0GQ3A9IPEgLenXXNcXGqD3wbw8myBqNk90tsfO5GpgqF0/npML+WhKfJW/VG9OKMJOe8ZuT1B6yQw3b6Sz8CQ9Th76Z3s3OFZKiRg929WWsuj79frkB0HmVgNds6fT0EBjBPfBjGeHGuqdiMo+X99i1X0fW6PjP2ZYokt1tbu25fQgBboFkKOW88OP7yw9R9mp7nxugsD43A83VoauY7AHnxB4hidcgUp/UDN4+YCP/XBNm/v3uxJ9NnEP1YNjfgXdsf+T+2zf60kDWgGP1B7I8woUPCZZo2UqD15yLtzA348qbsnGLe+9CthoRkKci012gzl0z2rVn8KabVFPamhE2EQ9qteYCzMPR5DU1ZoqaDPxHzJH09QcLFmMpXRiK5fU4/E6RkBItOOwD61yJ/BmzG87WUPc+3vCAEG5ualNOEcviaVsDnwoZUt1Ws6pu3hRGz29my+DBfZSalDzqG/LYWFuedqW3bfAaGk7W9piqdBf7h7YvDgVYW9UsyCUlnMgEp8An/kKWUh/9OovhW/D000XHrxWk6mnqtGK6IeYDOGLi+Ctx6EWEw3F+uhfUxuvzXh4rVRH4Gx1TyD8B2kFj+szA0zFuCijEv9+Zl2aePvs7S/y7cdMQ== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78c11960-e167-41d1-8f55-08d9c168a324 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:21.0514 (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: 1OSRpHoD6XxzhMwHiSwp7bQ9CSYTYvebx2XMLD18rYTlTIlRl1RCSmMZTvW6IF1JPfEe30fOwGW9XyUAcNNqRElgr/G3+2/bbH+LS6fuUX4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5469 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add index to flow_action_entry structure and delete index from police and gate child structure. We make this change to offload tc action for driver to identify a tc action. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman --- drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++-- drivers/net/dsa/sja1105/sja1105_flower.c | 2 +- drivers/net/ethernet/freescale/enetc/enetc_qos.c | 6 +++--- drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 2 +- drivers/net/ethernet/mscc/ocelot_flower.c | 2 +- include/net/flow_offload.h | 3 +-- include/net/tc_act/tc_gate.h | 5 ----- net/sched/cls_api.c | 3 +-- 8 files changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 110d6c403bdd..4ffd303c64ea 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1745,7 +1745,7 @@ static void vsc9959_psfp_sfi_table_del(struct ocelot *ocelot, u32 index) static void vsc9959_psfp_parse_gate(const struct flow_action_entry *entry, struct felix_stream_gate *sgi) { - sgi->index = entry->gate.index; + sgi->index = entry->hw_index; sgi->ipv_valid = (entry->gate.prio < 0) ? 0 : 1; sgi->init_ipv = (sgi->ipv_valid) ? entry->gate.prio : 0; sgi->basetime = entry->gate.basetime; @@ -1947,7 +1947,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port, kfree(sgi); break; case FLOW_ACTION_POLICE: - index = a->police.index + VSC9959_PSFP_POLICER_BASE; + index = a->hw_index + VSC9959_PSFP_POLICER_BASE; if (index > VSC9959_PSFP_POLICER_MAX) { ret = -EINVAL; goto err; diff --git a/drivers/net/dsa/sja1105/sja1105_flower.c b/drivers/net/dsa/sja1105/sja1105_flower.c index 72b9b39b0989..7dcdd784aea4 100644 --- a/drivers/net/dsa/sja1105/sja1105_flower.c +++ b/drivers/net/dsa/sja1105/sja1105_flower.c @@ -379,7 +379,7 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port, vl_rule = true; rc = sja1105_vl_gate(priv, port, extack, cookie, - &key, act->gate.index, + &key, act->hw_index, act->gate.prio, act->gate.basetime, act->gate.cycletime, diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index 0536d2c76fbc..3555c12edb45 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -1182,7 +1182,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, } /* parsing gate action */ - if (entryg->gate.index >= priv->psfp_cap.max_psfp_gate) { + if (entryg->hw_index >= priv->psfp_cap.max_psfp_gate) { NL_SET_ERR_MSG_MOD(extack, "No Stream Gate resource!"); err = -ENOSPC; goto free_filter; @@ -1202,7 +1202,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, } refcount_set(&sgi->refcount, 1); - sgi->index = entryg->gate.index; + sgi->index = entryg->hw_index; sgi->init_ipv = entryg->gate.prio; sgi->basetime = entryg->gate.basetime; sgi->cycletime = entryg->gate.cycletime; @@ -1244,7 +1244,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, refcount_set(&fmi->refcount, 1); fmi->cir = entryp->police.rate_bytes_ps; fmi->cbs = entryp->police.burst; - fmi->index = entryp->police.index; + fmi->index = entryp->hw_index; filter->flags |= ENETC_PSFP_FLAGS_FMI; filter->fmi_index = fmi->index; sfi->meter_id = fmi->index; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c index be3791ca6069..186c556f0de1 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c @@ -203,7 +203,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, */ burst = roundup_pow_of_two(act->police.burst); err = mlxsw_sp_acl_rulei_act_police(mlxsw_sp, rulei, - act->police.index, + act->hw_index, act->police.rate_bytes_ps, burst, extack); if (err) diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c index 58fce173f95b..beb9379424c0 100644 --- a/drivers/net/ethernet/mscc/ocelot_flower.c +++ b/drivers/net/ethernet/mscc/ocelot_flower.c @@ -303,7 +303,7 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port, } filter->action.police_ena = true; - pol_ix = a->police.index + ocelot->vcap_pol.base; + pol_ix = a->hw_index + ocelot->vcap_pol.base; pol_max = ocelot->vcap_pol.max; if (ocelot->vcap_pol.max2 && pol_ix > pol_max) { diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 3961461d9c8b..2271da5aa8ee 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -197,6 +197,7 @@ void flow_action_cookie_destroy(struct flow_action_cookie *cookie); struct flow_action_entry { enum flow_action_id id; + u32 hw_index; enum flow_action_hw_stats hw_stats; action_destr destructor; void *destructor_priv; @@ -232,7 +233,6 @@ struct flow_action_entry { bool truncate; } sample; struct { /* FLOW_ACTION_POLICE */ - u32 index; u32 burst; u64 rate_bytes_ps; u64 burst_pkt; @@ -267,7 +267,6 @@ struct flow_action_entry { u8 ttl; } mpls_mangle; struct { - u32 index; s32 prio; u64 basetime; u64 cycletime; diff --git a/include/net/tc_act/tc_gate.h b/include/net/tc_act/tc_gate.h index 8bc6be81a7ad..c8fa11ebb397 100644 --- a/include/net/tc_act/tc_gate.h +++ b/include/net/tc_act/tc_gate.h @@ -60,11 +60,6 @@ static inline bool is_tcf_gate(const struct tc_action *a) return false; } -static inline u32 tcf_gate_index(const struct tc_action *a) -{ - return a->tcfa_index; -} - static inline s32 tcf_gate_prio(const struct tc_action *a) { s32 tcfg_prio; diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index e54f0a42270c..dea1dca6a0fd 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3568,6 +3568,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, goto err_out_locked; entry->hw_stats = tc_act_hw_stats(act->hw_stats); + entry->hw_index = act->tcfa_index; if (is_tcf_gact_ok(act)) { entry->id = FLOW_ACTION_ACCEPT; @@ -3659,7 +3660,6 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->police.rate_pkt_ps = tcf_police_rate_pkt_ps(act); entry->police.mtu = tcf_police_tcfp_mtu(act); - entry->police.index = act->tcfa_index; } else if (is_tcf_ct(act)) { entry->id = FLOW_ACTION_CT; entry->ct.action = tcf_ct_action(act); @@ -3698,7 +3698,6 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->priority = tcf_skbedit_priority(act); } else if (is_tcf_gate(act)) { entry->id = FLOW_ACTION_GATE; - entry->gate.index = tcf_gate_index(act); entry->gate.prio = tcf_gate_prio(act); entry->gate.basetime = tcf_gate_basetime(act); entry->gate.cycletime = tcf_gate_cycletime(act); From patchwork Fri Dec 17 14:21: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: 12684753 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAB0FC433F5 for ; Fri, 17 Dec 2021 14:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237198AbhLQOWe (ORCPT ); Fri, 17 Dec 2021 09:22:34 -0500 Received: from mail-bn7nam10lp2104.outbound.protection.outlook.com ([104.47.70.104]:6434 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234633AbhLQOWa (ORCPT ); Fri, 17 Dec 2021 09:22:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RkxdktAbUBBLslK/2hKhs9OyAeKtWOrveWpn/OZOyXWj0g8BpCAX19ThUZW+XoiPYTdtgHW325A9UnLiTcr8T3gS9E8O5sgV24OzAWrnzJUBLrBe29moQ+YoqDHHuKmRzrUtrgrvIDWnN8cNePjV4VLgrnx/+hYgp1RoorQKZ2jkL5TXbxizWP/VZpgaxxnm4+Q0hjGKPZHydQryZqqrm0ORs1iyBSSsyAYQ5vKrVgs2vw/XlOqV6dq5O3IybvTzZ8m+ZwRn/HLbi32N2P7kASCnfc/YAVAPtj8YcYQbuciPYIMLBtM2gqEtwIHvOsHMUfYQov3pHIunt3vI/ZEVTg== 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=Y1G4tyxFc3zVOAmfbFEQn58jDSjQMx8ROLT5iAs0ugw=; b=baLyFy6Y7d/mTV5VLKLqQI0ZvmmI7a8viQXiOrKlnNIUgNwxvdkOGi+b73RegDssmDWVkS+mGgx2c7q7tt2TXRXj1OMGMGhP+yEfqVyG2GOb+TJQmMEDayfY3M7ghs0a4vYxU065qSCaShUN6vFD+PDLDefmUnC25pzONZTX3Qa4iYvSNhgxhKGY0G1RAFUID1zxgpaHjNCSLJht3Fw4c4tc5KKPmMlva3X6w0ekiApImhcdWXX5F88lITiAFwDrSFpkR2RH5zLi5641yqRKG0YGalgekdi5kMBgqOD3j2N4+B7elpHsIQPjIz/LHfgVnRkJRdI8w/0vGAZdY16khg== 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=Y1G4tyxFc3zVOAmfbFEQn58jDSjQMx8ROLT5iAs0ugw=; b=JD2I5QF+1Tqz3GmjQ8cGossqsZL2AOpDRIfJaOUQ+nlXK9GEgy0IbY3Q8b6YtSHFTZswUsB44oF7KUhVz7+CMv22fEdKbmiJpw3iLZ1m7Fmjc57GCgCfBbKwp0vL1UBtZHUzQ3J2tisicJ/phQcumd6U/RGdzdMXzw3dfkvFLTQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB5469.namprd13.prod.outlook.com (2603:10b6:510:142::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:25 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:25 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 04/12] flow_offload: rename offload functions with offload instead of flow Date: Fri, 17 Dec 2021 15:21:42 +0100 Message-Id: <20211217142150.17838-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0e76ff1-2085-43f9-ed95-08d9c168a5e5 X-MS-TrafficTypeDiagnostic: PH0PR13MB5469:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:612; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jQ3BNxxjfOHmVPlwNTsAP9vDYF5rVUaEUJdAVJ8kT5hkG+OoXC937HQH2QTMhe1n4Sn8j/3EZ0WZiOkgwXrTnZrHUiykoyqHhyriOg7FVgL+Zn5A4JdgFFa9iuAApAQD/VmHRibek2Dh20Dd5BGfy6e1mJ7qkltUT/Xbiu80pzyH8nv+Ll9ySuHQkOYtsBGuWzHlc7/lnWfjhyKSC0L4YvVqBPI2/d8yilLo9PaymsLKLGrTXSzd21PRyCIEx5Ql6/DQJ4gjhM6TOyQcuw+kZjrIxrPrZMViLIWJW2YEktyB34PUY9pX9J24OQIYaFKtYMnTwUsdMKM0FinJiinuh/5qRis2jPcDIcgn3P/hLyJRdkPZd7KPtlsFue8fme1OcEqk0F4wZXx87aH6vo4l6hZYtC3E+g0QijBJBWcD9U+4Qdndh3TquI8CIDOURbMZRDjP8m+vKp/R8gsQJnAbNQkcv7snciFM8lcacbetKMfN8RoWvQ+yIoHPPEFTS88gE1RefhvfyDTALA0SQGBNGZuSDLMjJPcKNMI/IbZK5nPoUmP02TXX3Vf9ZXn5w2M1jmQ+lKTffCEKmpelOFRpkyxMFFKBWsAE5EMaeA99rrkjjQJtRy7Z9Pc9WuxZfvVzFh0yUlXoFV+aOxiHM0x17/UD35+6Cb25TPap3O+PCHIcWjH9JN0tSn00+pl8bn2a 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:(13230001)(366004)(39840400004)(376002)(136003)(346002)(396003)(7416002)(5660300002)(83380400001)(36756003)(6666004)(186003)(44832011)(1076003)(107886003)(6506007)(2906002)(6512007)(6486002)(52116002)(66476007)(66556008)(4326008)(38100700002)(66946007)(54906003)(110136005)(508600001)(8936002)(86362001)(316002)(8676002)(2616005)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LTtC866LgxUjnHfGI6PmWPbroHkEqoZvb5//WcpjWTn6SrZ/z1DLzzMEcoG3vsVTDn/81DJIxtwrrapmOl8yrI26ojkgJH0YTBmV71BoLVbM9YVnYeJPrKvLAySpLyg3XtEFUM11dFpof/ewhGbWKeNHNYk5G2Px2FOLRLAKhUqwDvTBrsrZc/rbIVjRnX9Rwaieeo1M/aCjBYaq02fb3kL/0acD1FbnXz1+a/JWMYr22EJSyOmww4hvui0k3YY1Lf+Tp3KZavgIRZzfKFhIUpkSq1/+5IV+JOf0ENzUC5zaAeWbfNLLQSHiC3qVGje1K5oRwjqFcwaMlsxdf5Br4akCvk+b33NXqj0EKmzm16UymD6aETMUyKIHNZT8Ny7H6/dGmWRhsUtPzXTICtoxL0O8f4dPBhwK2F1/ZbN0wwjnZ8ervPj1iHyqCdXtL1dQk1C755Q5xoUzsFOQZyD2TrkGW4AuZbx7QUghkP35yw4N/0YQLcewr8rbjpQ/hybTNuPPZXXubuBh8zVqtPr+CT535nT1sboObZtDUw1ZXyXk6pAsVZcWReL1zvORpjgeqCnzZhx49D8fsmSUvXiw31ERPozk5ShgYPFxNvXCUNHrt5x+fc1ubVSwNdppT/mrB0P6QMeQYIzBgEapv/BIgpcTsm73vmUhwpVLrarNofQYm6i+lJyZiNd93SBqrF151TvX2hWejNZXyZQJT2ofRm5VeuzkPU1D9KmByeTYQbHkVhQ0U3F3Z263PN8lUbj9gltKHpyHFdE0ErzI55rFQg8ZJtjzicWhTgb2sqm3Fq7kuKT7qt/VLkPvHGVGcWVZ3u5VIOQT0z0ip75ZxNMpsjKXa6iv1kk3J4IxFlrqx8/ELNVOn/sd+D6eJPtfWt7mrNlqOoOrNOXXHnOpcFINQdA/yVlTsGGkNPOAZQkgQXi9pzDrAUnWsfyZtB3SsQWD8p78yQZp0pwdUIYqmg7eYW8VQDkV7uusbCJtYoQlQd6qzaSLismZ78c1PooyZdRJYaML9A++mdh6BBCUWF7fiatxznXJn/iDZKpy3h6x7DspiURBUYZ88YOKQRTLaXG06VmyHQ1ADW2T7zFOXX65cA3h/MMEqWvoysvg8n0aq+Jl3uxq3K+IdHyWjPE/ou7RaVbIeyQHWClWFYT9Z0O8p7JMYNP5Dzrios9BHDgg/VX1z1FjqC1pDXfhE8Xlskghn1NJ+iSXXQJwReTvefGoX8+oVF9b0zqC+OKePHom7fW+5rAZdQOxqrYviGcip0HEqQmgueB4Q0FXSrTK5N5UalHhY0akRfA78tfNffYkaiSbkJzFvMOE4O3dXRpwZTgqFWrouznuMYytw2kf0BVfVUtGgIOgLCKR4Pw6NYUc5WEMqWSdQnduvawibMbVNPnYJHWhVzNlXQconKbrge+JwIIZZTwjFmG2q85rG6AgV8XRlBcg/8F8uTCtwF9aT17SEgIuKZw8/8u2/yh+Y3z7zv5p2MBPTO5+R4zyMqV7RzJpVGPUGz0DiovNyHoAOWuNM1KpI2SMufQpQMtg+P3yd6qY67Nldy/vBgTOm9qBMgPSJRLbVIa0y9u7/Eh1WuVSVcUz8iO07DUe0leboZDPq/MLJ3/EH88fCcK84MGweRNeyPsnPLV9JcFswJQgUCQdHtwlhDrTHaASJddIxVR6e3tI4OopRfDc4To0oebbDwqsi37rExXFb9dkXr1thibrA4HJV60xbPGI3FXqFfv4Ng== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0e76ff1-2085-43f9-ed95-08d9c168a5e5 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:25.5705 (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: /DvrScNJXPWgJG4IqP4cT0/Zw/cNfWdytM7+q2zyhfR+cqzoHcneGNpUSQVGaeHAVK0uxiL5mEe8HlkupPp/WMNmpquOaDFkej3av7uFVjU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5469 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng To improves readability, we rename offload functions with offload instead of flow. The term flow is related to exact matches, so we rename these functions with offload. We make this change to facilitate single action offload functions naming. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman --- include/net/pkt_cls.h | 6 +++--- net/sched/cls_api.c | 12 ++++++------ net/sched/cls_flower.c | 8 ++++---- net/sched/cls_matchall.c | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index cebc1bd713b6..5d4ff76d37e2 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -536,9 +536,9 @@ tcf_match_indev(struct sk_buff *skb, int ifindex) return ifindex == skb->skb_iif; } -int tc_setup_flow_action(struct flow_action *flow_action, - const struct tcf_exts *exts); -void tc_cleanup_flow_action(struct flow_action *flow_action); +int tc_setup_offload_action(struct flow_action *flow_action, + const struct tcf_exts *exts); +void tc_cleanup_offload_action(struct flow_action *flow_action); int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, void *type_data, bool err_stop, bool rtnl_held); diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index dea1dca6a0fd..61b5012c65dc 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3461,7 +3461,7 @@ static void tcf_act_put_cookie(struct flow_action_entry *entry) flow_action_cookie_destroy(entry->cookie); } -void tc_cleanup_flow_action(struct flow_action *flow_action) +void tc_cleanup_offload_action(struct flow_action *flow_action) { struct flow_action_entry *entry; int i; @@ -3472,7 +3472,7 @@ void tc_cleanup_flow_action(struct flow_action *flow_action) entry->destructor(entry->destructor_priv); } } -EXPORT_SYMBOL(tc_cleanup_flow_action); +EXPORT_SYMBOL(tc_cleanup_offload_action); static void tcf_mirred_get_dev(struct flow_action_entry *entry, const struct tc_action *act) @@ -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_offload_action(struct flow_action *flow_action, + const struct tcf_exts *exts) { struct tc_action *act; int i, j, k, err = 0; @@ -3718,14 +3718,14 @@ int tc_setup_flow_action(struct flow_action *flow_action, err_out: if (err) - tc_cleanup_flow_action(flow_action); + tc_cleanup_offload_action(flow_action); return err; err_out_locked: spin_unlock_bh(&act->tcfa_lock); goto err_out; } -EXPORT_SYMBOL(tc_setup_flow_action); +EXPORT_SYMBOL(tc_setup_offload_action); unsigned int tcf_exts_num_actions(struct tcf_exts *exts) { diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index aab13ba11767..f4dad3be31c9 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -461,7 +461,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, cls_flower.rule->match.key = &f->mkey; cls_flower.classid = f->res.classid; - err = tc_setup_flow_action(&cls_flower.rule->action, &f->exts); + err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts); if (err) { kfree(cls_flower.rule); if (skip_sw) { @@ -473,7 +473,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, err = tc_setup_cb_add(block, tp, TC_SETUP_CLSFLOWER, &cls_flower, skip_sw, &f->flags, &f->in_hw_count, rtnl_held); - tc_cleanup_flow_action(&cls_flower.rule->action); + tc_cleanup_offload_action(&cls_flower.rule->action); kfree(cls_flower.rule); if (err) { @@ -2266,7 +2266,7 @@ static int fl_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb, cls_flower.rule->match.mask = &f->mask->key; cls_flower.rule->match.key = &f->mkey; - err = tc_setup_flow_action(&cls_flower.rule->action, &f->exts); + err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts); if (err) { kfree(cls_flower.rule); if (tc_skip_sw(f->flags)) { @@ -2283,7 +2283,7 @@ static int fl_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb, TC_SETUP_CLSFLOWER, &cls_flower, cb_priv, &f->flags, &f->in_hw_count); - tc_cleanup_flow_action(&cls_flower.rule->action); + tc_cleanup_offload_action(&cls_flower.rule->action); kfree(cls_flower.rule); if (err) { diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 24f0046ce0b3..2d2702915cfa 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -97,7 +97,7 @@ static int mall_replace_hw_filter(struct tcf_proto *tp, cls_mall.command = TC_CLSMATCHALL_REPLACE; cls_mall.cookie = cookie; - err = tc_setup_flow_action(&cls_mall.rule->action, &head->exts); + err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts); if (err) { kfree(cls_mall.rule); mall_destroy_hw_filter(tp, head, cookie, NULL); @@ -111,7 +111,7 @@ static int mall_replace_hw_filter(struct tcf_proto *tp, err = tc_setup_cb_add(block, tp, TC_SETUP_CLSMATCHALL, &cls_mall, skip_sw, &head->flags, &head->in_hw_count, true); - tc_cleanup_flow_action(&cls_mall.rule->action); + tc_cleanup_offload_action(&cls_mall.rule->action); kfree(cls_mall.rule); if (err) { @@ -301,7 +301,7 @@ static int mall_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb, TC_CLSMATCHALL_REPLACE : TC_CLSMATCHALL_DESTROY; cls_mall.cookie = (unsigned long)head; - err = tc_setup_flow_action(&cls_mall.rule->action, &head->exts); + err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts); if (err) { kfree(cls_mall.rule); if (add && tc_skip_sw(head->flags)) { @@ -314,7 +314,7 @@ static int mall_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb, err = tc_setup_cb_reoffload(block, tp, add, cb, TC_SETUP_CLSMATCHALL, &cls_mall, cb_priv, &head->flags, &head->in_hw_count); - tc_cleanup_flow_action(&cls_mall.rule->action); + tc_cleanup_offload_action(&cls_mall.rule->action); kfree(cls_mall.rule); if (err) From patchwork Fri Dec 17 14:21: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: 12684755 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACB02C4332F for ; Fri, 17 Dec 2021 14:22:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237306AbhLQOWf (ORCPT ); Fri, 17 Dec 2021 09:22:35 -0500 Received: from mail-dm6nam11lp2173.outbound.protection.outlook.com ([104.47.57.173]:6423 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237263AbhLQOWc (ORCPT ); Fri, 17 Dec 2021 09:22:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V9sXazfXrIe9KkuSMisPKkJK99Pq9ydYKSr5dX0wNTVUFixtIq4mPFeF0TaBLd6Ip/sPNC3oJNz3in1V550yiSrUw7gJrHYOsbaQQAL8NsJvqdm8HjDfv5d8p2Kg+Z7TvIMvZk0JbWJst9wPBSFHRFM63A8I+sZ+qvedy9Vl7nXFHQ+UKnG56k+3jcWCv3qyUBtO+t/6vEkQpZ9ruyXW0p1PWFWDn42WODEGqphs3M9AL/o6G8NSx9g9qPJR/nOHZN4KUIG7zU1wZWmZVgyfemHZZNlVWpUiemMNHuI63yn1rV5+26rIuoGYW9gh027gSb/Q5qG76EwFQk2FGgNBIQ== 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=YVuBaZNncgpHU7GbMkmErVsvE+v8DDso+eiqreHriv8=; b=egiusSfkN+fREyVd52XycPk1f/mar6Z+vuJAhJnpqLoP5DsAmuetHOQ45uWzFagzTdr6Jdou8C1fp/m3gYYLi3HV88Tdu7sUz8fZoIuTNVGYm4R2K3qLn6NFPRsrAskZRITmwazVaq49QX9+oMGF+bK1O1iDnRVHX1O0m7Nxx4gh2M2TxvTiZMHC1u2mrlhJH6DunSUODKRGbL/C/o22w1XkefUuJaXWJxJ3u1pk+c9ryUcUPk+OWWvgXb0G8Lr6FcmMNbvCs8H2tVzuXg+J7KK8fUOAgLsAoIg9RDlHpwFa3U5DafRCrjzqBh0ZJ5j/ODfwLytEccWe2sZToTlOtQ== 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=YVuBaZNncgpHU7GbMkmErVsvE+v8DDso+eiqreHriv8=; b=VaIMDxloL2Mco5V1VVciJWfX/qPHJPCJU/uR6cC7K0iuSlScQMGWxtj7ofopE8R9KH5ugKudq6JpVodnYOpDy8lPTQO/VFWy8cvP3Glj1o/GR0+M8IuJ1ZpGqynMulfl+feXVaIqlwlYimvfVAUzH3jL7Vgoq1deOZ1doUSFr3c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH7PR13MB5595.namprd13.prod.outlook.com (2603:10b6:510:139::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:30 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:30 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 05/12] flow_offload: add ops to tc_action_ops for flow action setup Date: Fri, 17 Dec 2021 15:21:43 +0100 Message-Id: <20211217142150.17838-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05e5d9e4-4740-403f-91f2-08d9c168a885 X-MS-TrafficTypeDiagnostic: PH7PR13MB5595:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:586; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /EHgu7ryFP2tRbdsataUClv8etgQkNu0pZVOBJ8hVWorl3czmo5fV/5tCPf/ANgQ5LP6744pdGugdZ8wRR/aVBJGwiMp+w4oh/Y60AxD3r0KC5l/pc2N6caKp5hhKQryxdDDZy0EQTKp+1/S6TICfQDyAq3ZCezQEHb9Zy+wcsYBJ82+Mgc9I8h3T4G10dPdWiAYtj+z1yP53BuGz0iJ74YhQqISHKa3sgz3n4xVHciwt4gQZKc3SKCWeCCHkdu8a4kibkE2DQTLLcog0tQQQJEFCVutPadSz10vU9bi/pF1O+b1+SGAFvJZ8JHsKKl9NMyR6cSGPWkyJULGgdsF5HT2s4mEpJuCJm7GdrB/fzHlkz4i4WLUBaY+YOoYOZ1b+FnuZBNEDfhskQXzgkAjkBMLcLb07/g6ZKjtNy3uzIpbik4wJakq+IIG+KoNk5YeaP249qlgOKrNVd7svqPf2q7dG8frzDPrc0Z70UQ6MZBu1e3hzUfqxPEGJzf0q12YlJ4bNndjfeAiu78H5+FzpJE2xnMScKSP6QIVbmYrr/tKgw5JNoKqjq33b5iKs8En6QpXZzewirmpAOhSOT2WxiHZAElepuIpnLAzV5qfnwl/gYSXKIODRkJkPoSGeilFr/dAITaPl3yU0NPudqLH4D7MYQ8sqGNdpJawV1RQYzO+UqTYzekI+Y9KiRxE+Fez 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:(13230001)(396003)(366004)(39840400004)(346002)(376002)(136003)(110136005)(8936002)(54906003)(8676002)(316002)(66946007)(66476007)(7416002)(2906002)(66556008)(4326008)(30864003)(86362001)(38100700002)(107886003)(83380400001)(508600001)(1076003)(6486002)(36756003)(6506007)(2616005)(6666004)(52116002)(5660300002)(44832011)(186003)(6512007)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: abfyqrWL0lAOE1oXAZTue9OMyS8OXeqgoWV+5rSEgj0WU9eFQpAP50cRJtmAlRsGKA5nEhXo2+q/37iUsaMYfHyDKBIn8IaoDSAbsdq6OlBP/cXU1K2+nJRRiXTPQ+htVNcwsPj69RwB2Q6kRRbJFs75+Y2KekhfESggVRHmf5O1wClg0ZssTEmiNHQfKs0QTywPIQ2JE/17KE61ii0X/++31R3T50v/ad7CYETq8RzS2cj6wJMx/deTSApF1y6/IUgXyxWn77NVe5Kqtyzn7O7al7LMf3DjK4mMkwenA1fw6yRMrewYtPtmRtJ+X75vxua55DDWolgM56cVQgt9XVRhlmi6Kd0ap7vVwHeSlZONlTFY3ezvr7oJRe8yJjz6D1htcqOp2ef0SH49XCOyEJkC/bJRtLyX8UFt4Vni4kjshptgIZoCUAe/uzWwLXXPV1qRMrN0DgWxyA9zZlx61zy5j7n8h8KIaLGmWaXK5m0j0BbD9bm2U0dSBoQOY8IAd6JW+aYhuMftdIqqW5KytvPDwkmBsfaWrRbT3nHZxId/g0I+1Fw5KPrvnbEWHyCQdUUUuIgyGVexbJqeCSX0SNGTDIWJx/2FOko6R3TcfEys1mtcdnZh/u34Z/zaNkTtBLkw37/Ntivw66do8qhKjb1GZjHTt+vd5tFHD82ALdH4jVvM4oPr3yZ4FdLzwCzE7Fsusc8J6/XsqHSeFhakfXlxtOqtx6INpLX7aPZtjA4ihUUWSz5OiRu28uhPjaOpiSVi6rEGImR4/DVHBNgKdqj7zBbpXitjgurGyQk5u6GW65fAzZ7B1xgpGlo7lr3flSE/p4q8JB7t+Q0qM6X7mH3LVRhi/RYbIJi/1zcAD5FJ9O0w92BpEqJZuTTCgNRi/2htd/2LQk86Xxrp3lImEtY5/dIvPmEXkdkV87t+xOzwfFzFxsSiZ9uOsDJUAcDv8Rr9ubi2kIkFyXotdH2FShrcUMxC2IsOQPBzSOCEOu7whh0Ao/YaDQnKm6bxiSlVCNrYdPUlPJ3uaCWxrFHvm1akSvi5H3sBHtwbg3S4eqUvCm3dOYQ7hx3bYHSOVEAR1yCt4cAEn1mjmPS7J9Njw8xhiPKCS4AqUrgR4FRhyJdnOzK4NCnhXIEDofOoWpD6nxcl5MRzF5L3FfaWT8VMK8Sjgk6GcOJ5oAbrLmquujxY4GOScnIiEiAIDYDSNbx5ij8n6R5DELbgKath+EtVlKyLfE44ie/do6KN+YEQbxx9PxL2kODyDWBcexqLd7H9DSNSxaWHN890rAANxQInBsoWtJj4WfyUvkQEt8yi/9NRwNdDmeplJ8zdy0R/8DfagISrdAF8Wz+/NIIsJxTVMRattips1GUhfEDBRulgIpvv4sDmScmjBE01tT0JULbIMxi52wIcJJzTCYQqJpIBxSpA42Sxc/bO8eq4/dHNi9BtpJ23lN75+zu1K04bdGwIfO11+CUaFJ7tfpSoeg2wFFLKC/M8sfmrtyJow6RVIIrei7qfOdr/MgSnl52FGLlj6VvVUZ6hHN9xMV6jcZC1WN3t9ETWm2pmRDOlUytZUfXC0TztwyZ1TZuX2GanpMIVr7q1bSHAeOkvREc6IUQAhrrsXJXyUaaUyoVf3XQe/kziJ+l8uecpfk62HznEoJQeleadqyZzhb1+mM5n7KrHKNp0hKsma/5BpQf2dngxEicH0+bSa+3MncHNH+sxWNRExz9qoTLM/HxFD0qCulx6Jw== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05e5d9e4-4740-403f-91f2-08d9c168a885 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:30.0797 (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: W1c4tbbCzJitBb1kwAHbIk+5x4DtpXeA4xPGyjQq5nGwa57+SNDAbQ+5RP+GRHmh3/pPyfO6gYPbuJOIAUAEBQY7Ed1wgOIcL9TaOW0WsLE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5595 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add a new ops to tc_action_ops for flow action setup. Refactor function tc_setup_flow_action to use this new ops. We make this change to facilitate to add standalone action module. We will also use this ops to offload action independent of filter in following patch. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman --- include/net/act_api.h | 12 ++ net/sched/act_csum.c | 17 +++ net/sched/act_ct.c | 19 ++++ net/sched/act_gact.c | 27 +++++ net/sched/act_gate.c | 47 ++++++++ net/sched/act_mirred.c | 39 +++++++ net/sched/act_mpls.c | 38 +++++++ net/sched/act_pedit.c | 34 ++++++ net/sched/act_police.c | 23 ++++ net/sched/act_sample.c | 28 +++++ net/sched/act_skbedit.c | 27 +++++ net/sched/act_tunnel_key.c | 47 ++++++++ net/sched/act_vlan.c | 34 ++++++ net/sched/cls_api.c | 222 +++---------------------------------- 14 files changed, 406 insertions(+), 208 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index b5b624c7e488..b418bb0e44e0 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -88,6 +88,16 @@ static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm) dtm->expires = jiffies_to_clock_t(stm->expires); } +static inline enum flow_action_hw_stats tc_act_hw_stats(u8 hw_stats) +{ + if (WARN_ON_ONCE(hw_stats > TCA_ACT_HW_STATS_ANY)) + return FLOW_ACTION_HW_STATS_DONT_CARE; + else if (!hw_stats) + return FLOW_ACTION_HW_STATS_DISABLED; + + return hw_stats; +} + #ifdef CONFIG_NET_CLS_ACT #define ACT_P_CREATED 1 @@ -121,6 +131,8 @@ struct tc_action_ops { struct psample_group * (*get_psample_group)(const struct tc_action *a, tc_action_priv_destructor *destructor); + int (*offload_act_setup)(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind); }; struct tc_action_net { diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index a15ec95e69c3..4428852a03d7 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c @@ -695,6 +695,22 @@ static size_t tcf_csum_get_fill_size(const struct tc_action *act) return nla_total_size(sizeof(struct tc_csum)); } +static int tcf_csum_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + entry->id = FLOW_ACTION_CSUM; + entry->csum_flags = tcf_csum_update_flags(act); + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_csum_ops = { .kind = "csum", .id = TCA_ID_CSUM, @@ -706,6 +722,7 @@ static struct tc_action_ops act_csum_ops = { .walk = tcf_csum_walker, .lookup = tcf_csum_search, .get_fill_size = tcf_csum_get_fill_size, + .offload_act_setup = tcf_csum_offload_act_setup, .size = sizeof(struct tcf_csum), }; diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index ab1810f2e660..dc64f31e5191 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1493,6 +1493,24 @@ static void tcf_stats_update(struct tc_action *a, u64 bytes, u64 packets, c->tcf_tm.lastuse = max_t(u64, c->tcf_tm.lastuse, lastuse); } +static int tcf_ct_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + entry->id = FLOW_ACTION_CT; + entry->ct.action = tcf_ct_action(act); + entry->ct.zone = tcf_ct_zone(act); + entry->ct.flow_table = tcf_ct_ft(act); + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_ct_ops = { .kind = "ct", .id = TCA_ID_CT, @@ -1504,6 +1522,7 @@ static struct tc_action_ops act_ct_ops = { .walk = tcf_ct_walker, .lookup = tcf_ct_search, .stats_update = tcf_stats_update, + .offload_act_setup = tcf_ct_offload_act_setup, .size = sizeof(struct tcf_ct), }; diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index d8dce173df37..f77be22069f4 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c @@ -252,6 +252,32 @@ static size_t tcf_gact_get_fill_size(const struct tc_action *act) return sz; } +static int tcf_gact_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + if (is_tcf_gact_ok(act)) { + entry->id = FLOW_ACTION_ACCEPT; + } else if (is_tcf_gact_shot(act)) { + entry->id = FLOW_ACTION_DROP; + } else if (is_tcf_gact_trap(act)) { + entry->id = FLOW_ACTION_TRAP; + } else if (is_tcf_gact_goto_chain(act)) { + entry->id = FLOW_ACTION_GOTO; + entry->chain_index = tcf_gact_goto_chain_index(act); + } else { + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_gact_ops = { .kind = "gact", .id = TCA_ID_GACT, @@ -263,6 +289,7 @@ static struct tc_action_ops act_gact_ops = { .walk = tcf_gact_walker, .lookup = tcf_gact_search, .get_fill_size = tcf_gact_get_fill_size, + .offload_act_setup = tcf_gact_offload_act_setup, .size = sizeof(struct tcf_gact), }; diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c index ac985c53ebaf..1d8297497692 100644 --- a/net/sched/act_gate.c +++ b/net/sched/act_gate.c @@ -597,6 +597,52 @@ static size_t tcf_gate_get_fill_size(const struct tc_action *act) return nla_total_size(sizeof(struct tc_gate)); } +static void tcf_gate_entry_destructor(void *priv) +{ + struct action_gate_entry *oe = priv; + + kfree(oe); +} + +static int tcf_gate_get_entries(struct flow_action_entry *entry, + const struct tc_action *act) +{ + entry->gate.entries = tcf_gate_get_list(act); + + if (!entry->gate.entries) + return -EINVAL; + + entry->destructor = tcf_gate_entry_destructor; + entry->destructor_priv = entry->gate.entries; + + return 0; +} + +static int tcf_gate_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + int err; + + if (bind) { + struct flow_action_entry *entry = entry_data; + + entry->id = FLOW_ACTION_GATE; + entry->gate.prio = tcf_gate_prio(act); + entry->gate.basetime = tcf_gate_basetime(act); + entry->gate.cycletime = tcf_gate_cycletime(act); + entry->gate.cycletimeext = tcf_gate_cycletimeext(act); + entry->gate.num_entries = tcf_gate_num_entries(act); + err = tcf_gate_get_entries(entry, act); + if (err) + return err; + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_gate_ops = { .kind = "gate", .id = TCA_ID_GATE, @@ -609,6 +655,7 @@ static struct tc_action_ops act_gate_ops = { .stats_update = tcf_gate_stats_update, .get_fill_size = tcf_gate_get_fill_size, .lookup = tcf_gate_search, + .offload_act_setup = tcf_gate_offload_act_setup, .size = sizeof(struct tcf_gate), }; diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 952416bd65e6..8eecf55be0a2 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -450,6 +450,44 @@ static size_t tcf_mirred_get_fill_size(const struct tc_action *act) return nla_total_size(sizeof(struct tc_mirred)); } +static void tcf_offload_mirred_get_dev(struct flow_action_entry *entry, + const struct tc_action *act) +{ + entry->dev = act->ops->get_dev(act, &entry->destructor); + if (!entry->dev) + return; + entry->destructor_priv = entry->dev; +} + +static int tcf_mirred_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + if (is_tcf_mirred_egress_redirect(act)) { + entry->id = FLOW_ACTION_REDIRECT; + tcf_offload_mirred_get_dev(entry, act); + } else if (is_tcf_mirred_egress_mirror(act)) { + entry->id = FLOW_ACTION_MIRRED; + tcf_offload_mirred_get_dev(entry, act); + } else if (is_tcf_mirred_ingress_redirect(act)) { + entry->id = FLOW_ACTION_REDIRECT_INGRESS; + tcf_offload_mirred_get_dev(entry, act); + } else if (is_tcf_mirred_ingress_mirror(act)) { + entry->id = FLOW_ACTION_MIRRED_INGRESS; + tcf_offload_mirred_get_dev(entry, act); + } else { + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_mirred_ops = { .kind = "mirred", .id = TCA_ID_MIRRED, @@ -462,6 +500,7 @@ static struct tc_action_ops act_mirred_ops = { .walk = tcf_mirred_walker, .lookup = tcf_mirred_search, .get_fill_size = tcf_mirred_get_fill_size, + .offload_act_setup = tcf_mirred_offload_act_setup, .size = sizeof(struct tcf_mirred), .get_dev = tcf_mirred_get_dev, }; diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index 2b30dc562743..a4615e1331e0 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -384,6 +384,43 @@ static int tcf_mpls_search(struct net *net, struct tc_action **a, u32 index) return tcf_idr_search(tn, a, index); } +static int tcf_mpls_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + switch (tcf_mpls_action(act)) { + case TCA_MPLS_ACT_PUSH: + entry->id = FLOW_ACTION_MPLS_PUSH; + entry->mpls_push.proto = tcf_mpls_proto(act); + entry->mpls_push.label = tcf_mpls_label(act); + entry->mpls_push.tc = tcf_mpls_tc(act); + entry->mpls_push.bos = tcf_mpls_bos(act); + entry->mpls_push.ttl = tcf_mpls_ttl(act); + break; + case TCA_MPLS_ACT_POP: + entry->id = FLOW_ACTION_MPLS_POP; + entry->mpls_pop.proto = tcf_mpls_proto(act); + break; + case TCA_MPLS_ACT_MODIFY: + entry->id = FLOW_ACTION_MPLS_MANGLE; + entry->mpls_mangle.label = tcf_mpls_label(act); + entry->mpls_mangle.tc = tcf_mpls_tc(act); + entry->mpls_mangle.bos = tcf_mpls_bos(act); + entry->mpls_mangle.ttl = tcf_mpls_ttl(act); + break; + default: + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_mpls_ops = { .kind = "mpls", .id = TCA_ID_MPLS, @@ -394,6 +431,7 @@ static struct tc_action_ops act_mpls_ops = { .cleanup = tcf_mpls_cleanup, .walk = tcf_mpls_walker, .lookup = tcf_mpls_search, + .offload_act_setup = tcf_mpls_offload_act_setup, .size = sizeof(struct tcf_mpls), }; diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index cd3b8aad3192..31fcd279c177 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -487,6 +487,39 @@ static int tcf_pedit_search(struct net *net, struct tc_action **a, u32 index) return tcf_idr_search(tn, a, index); } +static int tcf_pedit_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + int k; + + for (k = 0; k < tcf_pedit_nkeys(act); k++) { + switch (tcf_pedit_cmd(act, k)) { + case TCA_PEDIT_KEY_EX_CMD_SET: + entry->id = FLOW_ACTION_MANGLE; + break; + case TCA_PEDIT_KEY_EX_CMD_ADD: + entry->id = FLOW_ACTION_ADD; + break; + default: + return -EOPNOTSUPP; + } + entry->mangle.htype = tcf_pedit_htype(act, k); + entry->mangle.mask = tcf_pedit_mask(act, k); + entry->mangle.val = tcf_pedit_val(act, k); + entry->mangle.offset = tcf_pedit_offset(act, k); + entry->hw_stats = tc_act_hw_stats(act->hw_stats); + entry++; + } + *index_inc = k; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_pedit_ops = { .kind = "pedit", .id = TCA_ID_PEDIT, @@ -498,6 +531,7 @@ static struct tc_action_ops act_pedit_ops = { .init = tcf_pedit_init, .walk = tcf_pedit_walker, .lookup = tcf_pedit_search, + .offload_act_setup = tcf_pedit_offload_act_setup, .size = sizeof(struct tcf_pedit), }; diff --git a/net/sched/act_police.c b/net/sched/act_police.c index c13a6245dfba..abb6d16a20b2 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -405,6 +405,28 @@ static int tcf_police_search(struct net *net, struct tc_action **a, u32 index) return tcf_idr_search(tn, a, index); } +static int tcf_police_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + entry->id = FLOW_ACTION_POLICE; + entry->police.burst = tcf_police_burst(act); + entry->police.rate_bytes_ps = + tcf_police_rate_bytes_ps(act); + entry->police.burst_pkt = tcf_police_burst_pkt(act); + entry->police.rate_pkt_ps = + tcf_police_rate_pkt_ps(act); + entry->police.mtu = tcf_police_tcfp_mtu(act); + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + MODULE_AUTHOR("Alexey Kuznetsov"); MODULE_DESCRIPTION("Policing actions"); MODULE_LICENSE("GPL"); @@ -420,6 +442,7 @@ static struct tc_action_ops act_police_ops = { .walk = tcf_police_walker, .lookup = tcf_police_search, .cleanup = tcf_police_cleanup, + .offload_act_setup = tcf_police_offload_act_setup, .size = sizeof(struct tcf_police), }; diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 91a7a93d5f6a..07e56903211e 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -282,6 +282,33 @@ tcf_sample_get_group(const struct tc_action *a, return group; } +static void tcf_offload_sample_get_group(struct flow_action_entry *entry, + const struct tc_action *act) +{ + entry->sample.psample_group = + act->ops->get_psample_group(act, &entry->destructor); + entry->destructor_priv = entry->sample.psample_group; +} + +static int tcf_sample_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + entry->id = FLOW_ACTION_SAMPLE; + entry->sample.trunc_size = tcf_sample_trunc_size(act); + entry->sample.truncate = tcf_sample_truncate(act); + entry->sample.rate = tcf_sample_rate(act); + tcf_offload_sample_get_group(entry, act); + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_sample_ops = { .kind = "sample", .id = TCA_ID_SAMPLE, @@ -294,6 +321,7 @@ static struct tc_action_ops act_sample_ops = { .walk = tcf_sample_walker, .lookup = tcf_sample_search, .get_psample_group = tcf_sample_get_group, + .offload_act_setup = tcf_sample_offload_act_setup, .size = sizeof(struct tcf_sample), }; diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index cb2d10d3dcc0..75c03dde70f8 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -327,6 +327,32 @@ static size_t tcf_skbedit_get_fill_size(const struct tc_action *act) + nla_total_size_64bit(sizeof(u64)); /* TCA_SKBEDIT_FLAGS */ } +static int tcf_skbedit_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + if (is_tcf_skbedit_mark(act)) { + entry->id = FLOW_ACTION_MARK; + entry->mark = tcf_skbedit_mark(act); + } else if (is_tcf_skbedit_ptype(act)) { + entry->id = FLOW_ACTION_PTYPE; + entry->ptype = tcf_skbedit_ptype(act); + } else if (is_tcf_skbedit_priority(act)) { + entry->id = FLOW_ACTION_PRIORITY; + entry->priority = tcf_skbedit_priority(act); + } else { + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_skbedit_ops = { .kind = "skbedit", .id = TCA_ID_SKBEDIT, @@ -339,6 +365,7 @@ static struct tc_action_ops act_skbedit_ops = { .walk = tcf_skbedit_walker, .get_fill_size = tcf_skbedit_get_fill_size, .lookup = tcf_skbedit_search, + .offload_act_setup = tcf_skbedit_offload_act_setup, .size = sizeof(struct tcf_skbedit), }; diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index d9cd174eecb7..e96a65a5323e 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -787,6 +787,52 @@ static int tunnel_key_search(struct net *net, struct tc_action **a, u32 index) return tcf_idr_search(tn, a, index); } +static void tcf_tunnel_encap_put_tunnel(void *priv) +{ + struct ip_tunnel_info *tunnel = priv; + + kfree(tunnel); +} + +static int tcf_tunnel_encap_get_tunnel(struct flow_action_entry *entry, + const struct tc_action *act) +{ + entry->tunnel = tcf_tunnel_info_copy(act); + if (!entry->tunnel) + return -ENOMEM; + entry->destructor = tcf_tunnel_encap_put_tunnel; + entry->destructor_priv = entry->tunnel; + return 0; +} + +static int tcf_tunnel_key_offload_act_setup(struct tc_action *act, + void *entry_data, + u32 *index_inc, + bool bind) +{ + int err; + + if (bind) { + struct flow_action_entry *entry = entry_data; + + if (is_tcf_tunnel_set(act)) { + entry->id = FLOW_ACTION_TUNNEL_ENCAP; + err = tcf_tunnel_encap_get_tunnel(entry, act); + if (err) + return err; + } else if (is_tcf_tunnel_release(act)) { + entry->id = FLOW_ACTION_TUNNEL_DECAP; + } else { + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_tunnel_key_ops = { .kind = "tunnel_key", .id = TCA_ID_TUNNEL_KEY, @@ -797,6 +843,7 @@ static struct tc_action_ops act_tunnel_key_ops = { .cleanup = tunnel_key_release, .walk = tunnel_key_walker, .lookup = tunnel_key_search, + .offload_act_setup = tcf_tunnel_key_offload_act_setup, .size = sizeof(struct tcf_tunnel_key), }; diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index e4dc5a555bd8..0300792084f0 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -368,6 +368,39 @@ static size_t tcf_vlan_get_fill_size(const struct tc_action *act) + nla_total_size(sizeof(u8)); /* TCA_VLAN_PUSH_VLAN_PRIORITY */ } +static int tcf_vlan_offload_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + switch (tcf_vlan_action(act)) { + case TCA_VLAN_ACT_PUSH: + entry->id = FLOW_ACTION_VLAN_PUSH; + entry->vlan.vid = tcf_vlan_push_vid(act); + entry->vlan.proto = tcf_vlan_push_proto(act); + entry->vlan.prio = tcf_vlan_push_prio(act); + break; + case TCA_VLAN_ACT_POP: + entry->id = FLOW_ACTION_VLAN_POP; + break; + case TCA_VLAN_ACT_MODIFY: + entry->id = FLOW_ACTION_VLAN_MANGLE; + entry->vlan.vid = tcf_vlan_push_vid(act); + entry->vlan.proto = tcf_vlan_push_proto(act); + entry->vlan.prio = tcf_vlan_push_prio(act); + break; + default: + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_vlan_ops = { .kind = "vlan", .id = TCA_ID_VLAN, @@ -380,6 +413,7 @@ static struct tc_action_ops act_vlan_ops = { .stats_update = tcf_vlan_stats_update, .get_fill_size = tcf_vlan_get_fill_size, .lookup = tcf_vlan_search, + .offload_act_setup = tcf_vlan_offload_act_setup, .size = sizeof(struct tcf_vlan), }; diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 61b5012c65dc..53f263c9a725 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3474,81 +3474,25 @@ void tc_cleanup_offload_action(struct flow_action *flow_action) } EXPORT_SYMBOL(tc_cleanup_offload_action); -static void tcf_mirred_get_dev(struct flow_action_entry *entry, - const struct tc_action *act) +static int tc_setup_offload_act(struct tc_action *act, + struct flow_action_entry *entry, + u32 *index_inc) { #ifdef CONFIG_NET_CLS_ACT - entry->dev = act->ops->get_dev(act, &entry->destructor); - if (!entry->dev) - return; - entry->destructor_priv = entry->dev; -#endif -} - -static void tcf_tunnel_encap_put_tunnel(void *priv) -{ - struct ip_tunnel_info *tunnel = priv; - - kfree(tunnel); -} - -static int tcf_tunnel_encap_get_tunnel(struct flow_action_entry *entry, - const struct tc_action *act) -{ - entry->tunnel = tcf_tunnel_info_copy(act); - if (!entry->tunnel) - return -ENOMEM; - entry->destructor = tcf_tunnel_encap_put_tunnel; - entry->destructor_priv = entry->tunnel; + if (act->ops->offload_act_setup) + return act->ops->offload_act_setup(act, entry, index_inc, true); + else + return -EOPNOTSUPP; +#else return 0; -} - -static void tcf_sample_get_group(struct flow_action_entry *entry, - const struct tc_action *act) -{ -#ifdef CONFIG_NET_CLS_ACT - entry->sample.psample_group = - act->ops->get_psample_group(act, &entry->destructor); - entry->destructor_priv = entry->sample.psample_group; #endif } -static void tcf_gate_entry_destructor(void *priv) -{ - struct action_gate_entry *oe = priv; - - kfree(oe); -} - -static int tcf_gate_get_entries(struct flow_action_entry *entry, - const struct tc_action *act) -{ - entry->gate.entries = tcf_gate_get_list(act); - - if (!entry->gate.entries) - return -EINVAL; - - entry->destructor = tcf_gate_entry_destructor; - entry->destructor_priv = entry->gate.entries; - - return 0; -} - -static enum flow_action_hw_stats tc_act_hw_stats(u8 hw_stats) -{ - if (WARN_ON_ONCE(hw_stats > TCA_ACT_HW_STATS_ANY)) - return FLOW_ACTION_HW_STATS_DONT_CARE; - else if (!hw_stats) - return FLOW_ACTION_HW_STATS_DISABLED; - - return hw_stats; -} - int tc_setup_offload_action(struct flow_action *flow_action, const struct tcf_exts *exts) { + int i, j, index, err = 0; struct tc_action *act; - int i, j, k, err = 0; BUILD_BUG_ON(TCA_ACT_HW_STATS_ANY != FLOW_ACTION_HW_STATS_ANY); BUILD_BUG_ON(TCA_ACT_HW_STATS_IMMEDIATE != FLOW_ACTION_HW_STATS_IMMEDIATE); @@ -3569,151 +3513,13 @@ int tc_setup_offload_action(struct flow_action *flow_action, entry->hw_stats = tc_act_hw_stats(act->hw_stats); entry->hw_index = act->tcfa_index; - - if (is_tcf_gact_ok(act)) { - entry->id = FLOW_ACTION_ACCEPT; - } else if (is_tcf_gact_shot(act)) { - entry->id = FLOW_ACTION_DROP; - } else if (is_tcf_gact_trap(act)) { - entry->id = FLOW_ACTION_TRAP; - } else if (is_tcf_gact_goto_chain(act)) { - entry->id = FLOW_ACTION_GOTO; - entry->chain_index = tcf_gact_goto_chain_index(act); - } else if (is_tcf_mirred_egress_redirect(act)) { - entry->id = FLOW_ACTION_REDIRECT; - tcf_mirred_get_dev(entry, act); - } else if (is_tcf_mirred_egress_mirror(act)) { - entry->id = FLOW_ACTION_MIRRED; - tcf_mirred_get_dev(entry, act); - } else if (is_tcf_mirred_ingress_redirect(act)) { - entry->id = FLOW_ACTION_REDIRECT_INGRESS; - tcf_mirred_get_dev(entry, act); - } else if (is_tcf_mirred_ingress_mirror(act)) { - entry->id = FLOW_ACTION_MIRRED_INGRESS; - tcf_mirred_get_dev(entry, act); - } else if (is_tcf_vlan(act)) { - switch (tcf_vlan_action(act)) { - case TCA_VLAN_ACT_PUSH: - entry->id = FLOW_ACTION_VLAN_PUSH; - entry->vlan.vid = tcf_vlan_push_vid(act); - entry->vlan.proto = tcf_vlan_push_proto(act); - entry->vlan.prio = tcf_vlan_push_prio(act); - break; - case TCA_VLAN_ACT_POP: - entry->id = FLOW_ACTION_VLAN_POP; - break; - case TCA_VLAN_ACT_MODIFY: - entry->id = FLOW_ACTION_VLAN_MANGLE; - entry->vlan.vid = tcf_vlan_push_vid(act); - entry->vlan.proto = tcf_vlan_push_proto(act); - entry->vlan.prio = tcf_vlan_push_prio(act); - break; - default: - err = -EOPNOTSUPP; - goto err_out_locked; - } - } else if (is_tcf_tunnel_set(act)) { - entry->id = FLOW_ACTION_TUNNEL_ENCAP; - err = tcf_tunnel_encap_get_tunnel(entry, act); - if (err) - goto err_out_locked; - } else if (is_tcf_tunnel_release(act)) { - entry->id = FLOW_ACTION_TUNNEL_DECAP; - } else if (is_tcf_pedit(act)) { - for (k = 0; k < tcf_pedit_nkeys(act); k++) { - switch (tcf_pedit_cmd(act, k)) { - case TCA_PEDIT_KEY_EX_CMD_SET: - entry->id = FLOW_ACTION_MANGLE; - break; - case TCA_PEDIT_KEY_EX_CMD_ADD: - entry->id = FLOW_ACTION_ADD; - break; - default: - err = -EOPNOTSUPP; - goto err_out_locked; - } - entry->mangle.htype = tcf_pedit_htype(act, k); - entry->mangle.mask = tcf_pedit_mask(act, k); - entry->mangle.val = tcf_pedit_val(act, k); - entry->mangle.offset = tcf_pedit_offset(act, k); - entry->hw_stats = tc_act_hw_stats(act->hw_stats); - entry = &flow_action->entries[++j]; - } - } else if (is_tcf_csum(act)) { - entry->id = FLOW_ACTION_CSUM; - entry->csum_flags = tcf_csum_update_flags(act); - } else if (is_tcf_skbedit_mark(act)) { - entry->id = FLOW_ACTION_MARK; - entry->mark = tcf_skbedit_mark(act); - } else if (is_tcf_sample(act)) { - entry->id = FLOW_ACTION_SAMPLE; - entry->sample.trunc_size = tcf_sample_trunc_size(act); - entry->sample.truncate = tcf_sample_truncate(act); - entry->sample.rate = tcf_sample_rate(act); - tcf_sample_get_group(entry, act); - } else if (is_tcf_police(act)) { - entry->id = FLOW_ACTION_POLICE; - entry->police.burst = tcf_police_burst(act); - entry->police.rate_bytes_ps = - tcf_police_rate_bytes_ps(act); - entry->police.burst_pkt = tcf_police_burst_pkt(act); - entry->police.rate_pkt_ps = - tcf_police_rate_pkt_ps(act); - entry->police.mtu = tcf_police_tcfp_mtu(act); - } else if (is_tcf_ct(act)) { - entry->id = FLOW_ACTION_CT; - entry->ct.action = tcf_ct_action(act); - entry->ct.zone = tcf_ct_zone(act); - entry->ct.flow_table = tcf_ct_ft(act); - } else if (is_tcf_mpls(act)) { - switch (tcf_mpls_action(act)) { - case TCA_MPLS_ACT_PUSH: - entry->id = FLOW_ACTION_MPLS_PUSH; - entry->mpls_push.proto = tcf_mpls_proto(act); - entry->mpls_push.label = tcf_mpls_label(act); - entry->mpls_push.tc = tcf_mpls_tc(act); - entry->mpls_push.bos = tcf_mpls_bos(act); - entry->mpls_push.ttl = tcf_mpls_ttl(act); - break; - case TCA_MPLS_ACT_POP: - entry->id = FLOW_ACTION_MPLS_POP; - entry->mpls_pop.proto = tcf_mpls_proto(act); - break; - case TCA_MPLS_ACT_MODIFY: - entry->id = FLOW_ACTION_MPLS_MANGLE; - entry->mpls_mangle.label = tcf_mpls_label(act); - entry->mpls_mangle.tc = tcf_mpls_tc(act); - entry->mpls_mangle.bos = tcf_mpls_bos(act); - entry->mpls_mangle.ttl = tcf_mpls_ttl(act); - break; - default: - err = -EOPNOTSUPP; - goto err_out_locked; - } - } else if (is_tcf_skbedit_ptype(act)) { - entry->id = FLOW_ACTION_PTYPE; - entry->ptype = tcf_skbedit_ptype(act); - } else if (is_tcf_skbedit_priority(act)) { - entry->id = FLOW_ACTION_PRIORITY; - entry->priority = tcf_skbedit_priority(act); - } else if (is_tcf_gate(act)) { - entry->id = FLOW_ACTION_GATE; - entry->gate.prio = tcf_gate_prio(act); - entry->gate.basetime = tcf_gate_basetime(act); - entry->gate.cycletime = tcf_gate_cycletime(act); - entry->gate.cycletimeext = tcf_gate_cycletimeext(act); - entry->gate.num_entries = tcf_gate_num_entries(act); - err = tcf_gate_get_entries(entry, act); - if (err) - goto err_out_locked; - } else { - err = -EOPNOTSUPP; + index = 0; + err = tc_setup_offload_act(act, entry, &index); + if (!err) + j += index; + else goto err_out_locked; - } spin_unlock_bh(&act->tcfa_lock); - - if (!is_tcf_pedit(act)) - j++; } err_out: From patchwork Fri Dec 17 14:21: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: 12684757 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1A0EC433F5 for ; Fri, 17 Dec 2021 14:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237334AbhLQOWi (ORCPT ); Fri, 17 Dec 2021 09:22:38 -0500 Received: from mail-dm6nam12lp2176.outbound.protection.outlook.com ([104.47.59.176]:25502 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237331AbhLQOWg (ORCPT ); Fri, 17 Dec 2021 09:22:36 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kw4Y1DPl/R5Yz59hqXUutmMeTze+tStXoad24zlMsux+oU5Ltlo9PaTJHlGkU+oH/mk/8yWiym9LYodaujExB/+wYZkkduPUCVgKeG3UAvdV+8OlJ7GxWGUpwS1JAKkMnAqwQmP2mC8cYE2ffsHN3vY5q74Zjgc7ITmVTRTMOhrrFcTDE6kzXEiCNVmlaaUShbFnUkYXgY7Ytq8Bkb/t9snpk6B/ZH5WGeaowLKMbuiV5zoNxa/72Di/4yNBM/Cu1h4bNhnRZKTVTOJC0QsgTKqz3d3adbfdIOwLtwfd3XWk5UyIyMck5tsQ4ujo49GE4EtS0GKxftz8vPFKBfabfA== 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=gyPnqcHR0MtJVYMHc7msT7h2nxVOEhhVJc+KPijcS0Q=; b=ZDBMz+z3QjpFtEe/VpUX+oClphaWdw+gzBVyEZIhIr6SFC3LUyx/q1hPaXh07yxVO1Nm3R8/MG2Ap5iiy7I66HrxBt4uMK/hzWXxpw+v2JTLyDHVtZ728T1nxJu7Rhi+qjA8jkFxU1DF2kMTecafjK9keDXyx8KwL5zzXVa7h8dX2qMillEBaNaoShOvleXU+i4vYqH9H9yjhqOBQtXuh/CFLqRTCp0BZuzh8NY39TP0UwDcBXPQjTBEJIVli91U7b4zIly8DVnywFVTe+4wNkJz4pNnM4O2h/7Qt7IcVqM6JSjwxYlf/WUWC2uq/+3mppqYC91a56ADTRsygfOFSQ== 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=gyPnqcHR0MtJVYMHc7msT7h2nxVOEhhVJc+KPijcS0Q=; b=O8Wz6pikL4ARqTHFdBs/GORkEq5P39EEiel3uhbY/sBPLQNzvyBbeclJ0wH1jNAEF9nkXggfM0dL6MD5kAZ4MQx7CAq05D5xN/IJ2BiNR3IRxXCwApyIBxaizZUEIhiQ3HInafBlYtmVONKmJSP4QXZ7CipftXixz45yjhzvPQM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH7PR13MB5595.namprd13.prod.outlook.com (2603:10b6:510:139::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:34 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:34 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 06/12] flow_offload: allow user to offload tc action to net device Date: Fri, 17 Dec 2021 15:21:44 +0100 Message-Id: <20211217142150.17838-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1498e083-af89-4f51-a862-08d9c168ab38 X-MS-TrafficTypeDiagnostic: PH7PR13MB5595:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:669; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1gNmd5w+2X2KyAJ66d4Ej1FxmKbRtcmCpgYxhfnx5GRDKOvncC4WuBXkz1wAhkOahDmM6In5zMpdEBHLYCOeYsFtq5YPorPvqASLVwn91QpuWSGCz2qMD0JLlkpq+pXpta0B6w9GkzTTJ6LYTG6lXyGfj7gdN9XDz3XQoK1DtF91sZo5YUB3UmITw6YmZdYOZY3kBNDmW2JfGVOVG/DvAmhB8LR4O2I/MM3cvZ2QIvrUw+FZJWqGsIwWSxVIS9GzPDNfkuUay5hUHqNUNWFSpdk9TJEdthj5UoIX316CPc2t6M/Gc96p2s5G1e32bykQetn/Tium88WYxmOcAUMVBxKOTeYG5DCVLlCdvQtg6y6W7VYJu1wU2wef0Qc7KkOwKF9cyZQsNf+Y4ZJC56gvV7cxlfgIHdbZ0/QEFwi/cbisn+9/GPlCmgR65QnxTwiz+jVjtkvC5/lSfrxj8W3Yc8uOCdrjIzri/6/lTXsuZvkD0ikbyc575kZs339/26Gy48zrovB+9Ck7EJqzCWsBL6/MRVYCcSpG2V9qk399l9+vvCwjVNMNbh8ngJxftW0Qikr24BZP5b4wTmmGX+s70urFpukRHx8H4ahK0Ikl4+8QDv80tvmKOUxw4BxLbYljkHznHo9zFGhExm6aqH2A72UV7OksqYgCDoMo3UedVPhUw07FLl9/vSlQE8/60hSF 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:(13230001)(396003)(366004)(39840400004)(346002)(376002)(136003)(110136005)(8936002)(54906003)(8676002)(316002)(66946007)(66476007)(7416002)(2906002)(66556008)(4326008)(30864003)(86362001)(38100700002)(107886003)(83380400001)(508600001)(1076003)(6486002)(36756003)(6506007)(2616005)(6666004)(52116002)(5660300002)(44832011)(186003)(6512007)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9N4iDPnL4mKgUO9IR8fAr1L9QcgFWLuQYLFP2QrY6CN2/30TULLB6JvxSCigPL4lyrhUYzAQ0In1KVc4tYPeZhFDVLTRiIOW7OzWNPSNVS6hLIv+sDldtzocpi0fsTsjnW8j7Y6OYyR6ttYBy0tkEQINX9QokTIlXhUMZNtLXG1MP3f88hOITB4CsaPh2uU2JWyBFdxqPBi//i/3URG5HhMIApSqf8c743hfoRDM3ODlPIBNu06Sa06DL8Lthq9UxZ8sSUgzpwQOHIHqSs4ON0McbCdaf/H4UZp4ABOwbZTPnpVQvc3or0UicIopW+H/DJM3MEKl3kERoUNCTLvvI2mTj0m/1Ugteid2/Ry41LicicGJAUAm7HVYG9eg2giFAUvfWk3ZuAGUWyz4gvnhr7CYTJuoyFRc2TKMK9cu+GKjzbChz9SZ+jq2ZGyDQUCFiQiW88+jXVeZ6i8uyZGJ6dGHdMrMaxZagchXad28hjddSvxOoBQznckbkA1JoNXjC8i2I4L/2sxJa2a3w6yIc40Nfs9MLIfl8utzGBvv6Osv26LcjbScMoyaB/MXoQL9XOHhLEWVPdWEXFbIOJ1JKWs8WlgLaZzyc11+RrSqYFyTPHRBOgxfNd4I35PZlur5A5NAqMpq/NURMf6ByNo8rRS9zjpUDoLy70vn2x+FG4NIlh6K+heiC37pVJiwzGslCsXMrELEwKsPrDATkx0YPxrrkHWn9sMuHOcqTHqk5NtRQ49M0mB58SD0WhIoCrJ/TXBRJKb5KlmoF107Itpb1aFRL2krH/ZGZrNaf28eq9UBVmnKNFS+h4fDEJwMH2Pg62K6dziahUNaGAqPze38WL+G8Lo/AgyKi0rDZ3BGxUmN8VQZntvPXuP25rjpDhJjB7qik56jw05NqM/6OB4i+TEVacm0E+vj5fvwYk/m4jzzbT+rk+boGRDG0pAHRWTyrpucb390Q39FnMMhSFFqKlX2ySNRjxc1evs5K0xxRJh0ab+Qj77C8MJz/ro5qIpDivkAOFK3HPpl++b3bQLirug1FoyknfI++c68ALlEERy2ZjbCwsiUXg8QoIveVxdEIAHsfQQBk8j9PSyqr0dy8qihvKIeGQTO6OPZetx3yFllomY5UYtwXruN/w+oYYKAbDKf0DtT+NkjbV2Oq+3FkS7g2OwTrkzRQQLBmOkxM0XBPsH92PIpAJFJZ6Ubu8K/kv1Rc/+2mEegvAcBnTayLnRrZr1Zbb9L/NSsKBUQ8orunB0du1aVuXL9oT/4ru0N2ZhwWm4qq3wgo2uj5xCeovmR2aFUQHeWIzXUON8GbiqQKPPf20P8vK0FHorWNfGJc45I9DdBhxK6QGI0g3NH26tAxi1EDTAYkJMBSL4Y5y90851926yyyLg9hsTh5TlvoRYehBmm1LvWcSpnDh77P04vB5hEFxJRc9kv6Bb+RqO6dqjbGS5efTK1tucJrwx3yWjzh5kHn3pCWiem1ikYTpNWZVDHa9ffSLgZbWPyDjdNzoJHH0tp0fF93KbsjK2ItSM6WsPRcK9RvIDsqLM1/pIGM+i4AQhcxXZG2H2EzTV/QgEGXA0T4KMJNMkbwwJEN6kEdv5d+oJ+836Em7K+wsDw3TOpb8crR5ybb9zvuDgS0+IhcfRXCwcz+vutqS4NFXCR8jLwbl4VD+4c9PONFX0TKAxRzJSfjKCGWiZqhT9g5zRG+WIOQiPFLd+O+dp+SC9akiv79LOhB/clX7MnWw== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1498e083-af89-4f51-a862-08d9c168ab38 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:34.5153 (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: MQHNeo+Lxm9ntK67m0if4dWWDDZN6gDBgUjkjfGo/Jt8vL7cNJIUe5csUMDVxsOyzhlf2ZHFqHTZBdySnsrHc2Kv6kZvwTmnvxgm95womo4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5595 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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/flow_offload.h | 17 +++++++ include/net/pkt_cls.h | 5 ++ net/core/flow_offload.c | 42 +++++++++++++---- net/sched/act_api.c | 93 ++++++++++++++++++++++++++++++++++++++ net/sched/act_csum.c | 4 +- net/sched/act_ct.c | 4 +- net/sched/act_gact.c | 13 +++++- net/sched/act_gate.c | 4 +- net/sched/act_mirred.c | 13 +++++- net/sched/act_mpls.c | 16 ++++++- net/sched/act_police.c | 4 +- net/sched/act_sample.c | 4 +- net/sched/act_skbedit.c | 11 ++++- net/sched/act_tunnel_key.c | 9 +++- net/sched/act_vlan.c | 16 ++++++- net/sched/cls_api.c | 21 +++++++-- 17 files changed, 254 insertions(+), 23 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a419718612c6..8b0bdeb4734e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -920,6 +920,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/flow_offload.h b/include/net/flow_offload.h index 2271da5aa8ee..71f91eb2d3e6 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -551,6 +551,23 @@ struct flow_cls_offload { u32 classid; }; +enum flow_offload_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_offload_act_command command; + enum flow_action_id id; + u32 index; + struct flow_stats stats; + struct flow_action action; +}; + +struct flow_offload_action *offload_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 5d4ff76d37e2..1bfb616ea759 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -262,6 +262,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, @@ -539,6 +542,8 @@ tcf_match_indev(struct sk_buff *skb, int ifindex) int tc_setup_offload_action(struct flow_action *flow_action, const struct tcf_exts *exts); void tc_cleanup_offload_action(struct flow_action *flow_action); +int tc_setup_action(struct flow_action *flow_action, + struct tc_action *actions[]); int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, void *type_data, bool err_stop, bool rtnl_held); diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c index 6beaea13564a..022c945817fa 100644 --- a/net/core/flow_offload.c +++ b/net/core/flow_offload.c @@ -27,6 +27,26 @@ struct flow_rule *flow_rule_alloc(unsigned int num_actions) } EXPORT_SYMBOL(flow_rule_alloc); +struct flow_offload_action *offload_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; +} + #define FLOW_DISSECTOR_MATCH(__rule, __type, __out) \ const struct flow_match *__m = &(__rule)->match; \ struct flow_dissector *__d = (__m)->dissector; \ @@ -549,19 +569,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..207905df2b9c 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -19,8 +19,10 @@ #include #include #include +#include #include #include +#include #ifdef CONFIG_INET DEFINE_STATIC_KEY_FALSE(tcf_frag_xmit_count); @@ -129,8 +131,92 @@ static void free_tcf(struct tc_action *p) kfree(p); } +static unsigned int tcf_offload_act_num_actions_single(struct tc_action *act) +{ + if (is_tcf_pedit(act)) + return tcf_pedit_nkeys(act); + else + return 1; +} + +static int offload_action_init(struct flow_offload_action *fl_action, + struct tc_action *act, + enum flow_offload_act_command cmd, + struct netlink_ext_ack *extack) +{ + fl_action->extack = extack; + fl_action->command = cmd; + fl_action->index = act->tcfa_index; + + if (act->ops->offload_act_setup) + return act->ops->offload_act_setup(act, fl_action, NULL, false); + + return -EOPNOTSUPP; +} + +static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + struct netlink_ext_ack *extack) +{ + int err; + + 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 action after it is 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 num, err = 0; + + num = tcf_offload_act_num_actions_single(action); + fl_action = offload_action_alloc(num); + if (!fl_action) + return -ENOMEM; + + err = offload_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_offload_action(&fl_action->action); + +fl_err: + kfree(fl_action); + + return err; +} + +static int tcf_action_offload_del(struct tc_action *action) +{ + struct flow_offload_action fl_act = {}; + int err = 0; + + err = offload_action_init(&fl_act, action, FLOW_ACT_DESTROY, NULL); + if (err) + return err; + + return tcf_action_offload_cmd(&fl_act, NULL); +} + static void tcf_action_cleanup(struct tc_action *p) { + tcf_action_offload_del(p); if (p->ops->cleanup) p->ops->cleanup(p); @@ -1061,6 +1147,11 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, return ERR_PTR(err); } +static bool tc_act_bind(u32 flags) +{ + return !!(flags & TCA_ACT_FLAGS_BIND); +} + /* Returns numbers of initialized actions or negative error. */ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, @@ -1103,6 +1194,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 (!tc_act_bind(flags)) + tcf_action_offload_add(act, extack); } /* We have to commit them all together, because if any error happened in diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index 4428852a03d7..e0f515b774ca 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c @@ -705,7 +705,9 @@ static int tcf_csum_offload_act_setup(struct tc_action *act, void *entry_data, entry->csum_flags = tcf_csum_update_flags(act); *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + fl_action->id = FLOW_ACTION_CSUM; } return 0; diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index dc64f31e5191..1c537913a189 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1505,7 +1505,9 @@ static int tcf_ct_offload_act_setup(struct tc_action *act, void *entry_data, entry->ct.flow_table = tcf_ct_ft(act); *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + fl_action->id = FLOW_ACTION_CT; } return 0; diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index f77be22069f4..bde6a6c01e64 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c @@ -272,7 +272,18 @@ static int tcf_gact_offload_act_setup(struct tc_action *act, void *entry_data, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + 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 + return -EOPNOTSUPP; } return 0; diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c index 1d8297497692..d56e73843a4b 100644 --- a/net/sched/act_gate.c +++ b/net/sched/act_gate.c @@ -637,7 +637,9 @@ static int tcf_gate_offload_act_setup(struct tc_action *act, void *entry_data, return err; *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + fl_action->id = FLOW_ACTION_GATE; } return 0; diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 8eecf55be0a2..39acd1d18609 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -482,7 +482,18 @@ static int tcf_mirred_offload_act_setup(struct tc_action *act, void *entry_data, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + 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 + return -EOPNOTSUPP; } return 0; diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index a4615e1331e0..b9ff3459fdab 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -415,7 +415,21 @@ static int tcf_mpls_offload_act_setup(struct tc_action *act, void *entry_data, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + 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; + } } return 0; diff --git a/net/sched/act_police.c b/net/sched/act_police.c index abb6d16a20b2..0923aa2b8f8a 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -421,7 +421,9 @@ static int tcf_police_offload_act_setup(struct tc_action *act, void *entry_data, entry->police.mtu = tcf_police_tcfp_mtu(act); *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + fl_action->id = FLOW_ACTION_POLICE; } return 0; diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 07e56903211e..9a22cdda6bbd 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -303,7 +303,9 @@ static int tcf_sample_offload_act_setup(struct tc_action *act, void *entry_data, tcf_offload_sample_get_group(entry, act); *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + fl_action->id = FLOW_ACTION_SAMPLE; } return 0; diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index 75c03dde70f8..72bf49e3ca07 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -347,7 +347,16 @@ static int tcf_skbedit_offload_act_setup(struct tc_action *act, void *entry_data } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + if (is_tcf_skbedit_mark(act)) + fl_action->id = FLOW_ACTION_MARK; + 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 + return -EOPNOTSUPP; } return 0; diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index e96a65a5323e..23aba03d26a8 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -827,7 +827,14 @@ static int tcf_tunnel_key_offload_act_setup(struct tc_action *act, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + 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 + return -EOPNOTSUPP; } return 0; diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index 0300792084f0..756e2dcde1cd 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -395,7 +395,21 @@ static int tcf_vlan_offload_act_setup(struct tc_action *act, void *entry_data, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + 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; + } } return 0; diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 53f263c9a725..353e1eed48be 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3488,8 +3488,8 @@ static int tc_setup_offload_act(struct tc_action *act, #endif } -int tc_setup_offload_action(struct flow_action *flow_action, - const struct tcf_exts *exts) +int tc_setup_action(struct flow_action *flow_action, + struct tc_action *actions[]) { int i, j, index, err = 0; struct tc_action *act; @@ -3498,11 +3498,11 @@ int tc_setup_offload_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]; @@ -3531,6 +3531,19 @@ int tc_setup_offload_action(struct flow_action *flow_action, spin_unlock_bh(&act->tcfa_lock); goto err_out; } + +int tc_setup_offload_action(struct flow_action *flow_action, + const struct tcf_exts *exts) +{ +#ifdef CONFIG_NET_CLS_ACT + if (!exts) + return 0; + + return tc_setup_action(flow_action, exts->actions); +#else + return 0; +#endif +} EXPORT_SYMBOL(tc_setup_offload_action); unsigned int tcf_exts_num_actions(struct tcf_exts *exts) From patchwork Fri Dec 17 14:21: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: 12684759 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80551C433F5 for ; Fri, 17 Dec 2021 14:22:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237380AbhLQOWq (ORCPT ); Fri, 17 Dec 2021 09:22:46 -0500 Received: from mail-dm6nam11lp2175.outbound.protection.outlook.com ([104.47.57.175]:23036 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237331AbhLQOWk (ORCPT ); Fri, 17 Dec 2021 09:22:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BnkYUvm/MFKRBxHsKWxnq7762inc3rYatEXNwVFqViqGlfClmEkV5PVNyNAIHiMJk5C/LbtW8GUwYScLYpVzVYqU3//kw2qyiQIltLVOJ852mK8SnZReCEiRCM7c6pPgyqw1w8sU2DZYFx6bGGyobP8O3EzDsgubb9uxRf/K1dbB+ongiY4MZJuhLy4Ze6nfhBDVEholtPuGK4akYx6h7cBHph1w9O/2Uwn35v71qQGIYou3mcBsthxV4wsKcgK6U/4gfaHl5TaCPYUJr2zMkYdf4ZGJrZcNSzTk5Z4U7cTyeqQCWEfC1VkaiCiVakVbOoSQLYbsJr1pWZPOb+GHsg== 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=/hOUt66RXSz1uzkp3TRVkfAKL4KcUGHfDhag6bT9EoA=; b=kWv56kHYIlm6rXu3n3O3G2oWR4SnaZNnwIDRKg9esmbc3SAdUFfQ/Hnyz4WWpNlQ55ikP41jvSCzoPuerNGzup9jZrWDt8v8qVMLIiSsKriWhPn9T7U5qHEH4YRiORY8g9XgErL8XNg4hWa3ThmZICA45Jm/XCaYrm2joDJQWutAeVD774L97HKFR+mV6GlOKV1w5uqQDVY+4TKtcJuLdQn+yUMCufrnYABuCc30TBE+HyhlsGScGgAFaTGd1il7P4FSSSN9ydCCcoXJ1NU+rpCep9YZ6wwDlB0nfWWlQ5M+74SVODu/iWALWBItf0mXQNgs+/3lhuxgWW9vkVkZSg== 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=/hOUt66RXSz1uzkp3TRVkfAKL4KcUGHfDhag6bT9EoA=; b=pd0YG9y4oKj+olrflPFSg6LkC2amaT5QImi8SQO9wGIF8/z8CKsad5M7QyMk5bQS++bBN0Y/dNjh9yt4m6vSYoLhrMG0utuNBpj8J5my0TS/xgDS5BRvUjRfgOWUhnF59N9XHeeXSr9hSLYFMnTiPNDcQmfYsQzVVeYmyBWNOnc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH7PR13MB5595.namprd13.prod.outlook.com (2603:10b6:510:139::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:39 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:39 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 07/12] flow_offload: add skip_hw and skip_sw to control if offload the action Date: Fri, 17 Dec 2021 15:21:45 +0100 Message-Id: <20211217142150.17838-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01eb6ca2-241f-41f5-e69d-08d9c168ae03 X-MS-TrafficTypeDiagnostic: PH7PR13MB5595:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:568; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aBLBNtuYAcPq+JTRKKnJKHLzdpJq/bwKZGBdP+beP+TS4idAJucI6WAi03IM6cjryOr0+wp5AXf5iohSdEPmepl5joB5G5hnEGazY9mdmIoiKl6KLBeXjGd8rVyObIEq2mTYQQXpltiQK0OWKhLCB+K0sWYbmXpjf6wrYUeW3tErMttQUmC3zqUJGa7x0SShEfIIaboqowpfg0KOkLF2t8f0p0kyiMeMq+FOhbwH7HO11dQXEpg/8KN/CeGC3zR21FNt5Cz9k6JbQbGy4t/MiHH5a++T7WcWmuJ0EwZ0ku6ipfrJgyeDq4pIg0Rj8cyrWu7CBB610Kl9jn2NSey4uAhTMJuF2D6MViKGRPufGpefyF6eNKlZTYlSvnTZ5WD/3sXxabzpkITsyqtEFGP2dP2dsHsono1VStdzPowEc7WumoPq1l3jOsY818cKzUaCbfmogLI7W/5GkpAyfODupVr4p+zt59msIHmjDeDpxUnIy3JwRIY42KY3IiuRrYDSeX6Bal/3fhPAu8uD4MlxFqLSuhHeufZXKAANuAGjKmnJs30CJgiBE3WVNLzqQvxaJKrJ5vWL1YdRqRwW3D59sNlH7NyUmHL/Do9Peg2e9dMKL6gvzVpZdZQD+jy5CFNcZV2hPebLAAJtoqhX0ktlflSenw1rXdF5J51PQPoexukhoeczRpaAa4RqRajf0I0kSTC3m9CqgU33n933OV5PCQ86SbXVvyrnpzbLGuMmgm8= 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:(13230001)(396003)(366004)(39840400004)(346002)(376002)(136003)(110136005)(8936002)(54906003)(8676002)(316002)(66946007)(66476007)(7416002)(2906002)(66556008)(4326008)(86362001)(38100700002)(107886003)(83380400001)(508600001)(1076003)(6486002)(36756003)(6506007)(2616005)(6666004)(52116002)(5660300002)(44832011)(186003)(6512007)(309714004)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WJLyUgVO0HIbR6qssyWsHSi9V+l5pdFj1t1uRgSv1yxITw8zinFmAGU/9LhLMsr02RZfvu52M7Og62S9FMnL6CrxT+cGj8y8zMZgtDjqazCa3ZCj4XMv8oSikQC+k7GP7KsembEJ8RDS5ykQVB1a70+KfhIyX3/maHOdS9bE+wvnYicFRy2KtXyBEQmrkWf94aetA2TFG0ipW9qBuUWxE+tlWIb1TI8kQ/hLXMFK2qOv5MsRWYW29vfGUleEyMQNm8Spk1+0sZT5F9Sfu6323vWAdejFPLFX9uP92T/9X51K2wD7wn6h1PLUN5WrTZhfbgcayJbUZ2UnM+SUIWZOKzqIcRFaoaUqufp9cub2qAn50bP/Zdb6JaLlwCHk/OAot8T87iEFduR5qX4I5ijk7TembkDbVIlnD8BlwAhE/TZy2T3BgsGVHeCcJDofDwj2CTo3TGyHhQfWMoyewyCbJupMva9UhE7ai4u0oBmMur198dZwZ66T8i/rGh6zXIhQkz7xUr2UpK6YBRsBPIYM8ZCMOtS/QvEex9cfvKmZzesP4QOi7uRmyNCdHY5K/ufklYeZiTaL/8zQt5CTyodBetheR7Kd6F7GumjWMX9jPMdW2a3fqeURMjH7GGUaSJc4eZMPSV34MZbvdN+NMOuzMJw0cY24fLpMboLm3XH18/0WZ2EpjiBjNV/i8PHa8gbWFDL0ea4ZOK7sPTqb317UMC4SSXaMb5vSJhJ7+uLT5UVl7O1+/mezRUqlCivMTZ8nJbc1B51InaewKZIAedy9ykfKfDtbxQPoIeZL7PxLUNE+f0t/P4KTZNMu9ruqyHT2rFaAjzZvMRb/bMS8SL88GMr+Q0sHWdFiTQKPkinpq9GnJUzU54bZGwwMKDY6TJ2YMeEoyClmpqL5fns0vberhY8oyBSo8Mr5NNzUYoHUEPLw60iWbeosPFqwFRqGd+Pafu+FcC2YnNWuGZn1xwbX6CdAH+c/NSJrua3VcgyZm+lkr9DsxmRpUUuzRlvDrwppvKOsvYoPQzyIM7wfX+cRwFEz0oFhu0v7NwncDOoD+9EOYvtvJatNrTn1MhtL3hDmXzT7QWjEjxSoIILfEPOGWbCtlXko+DDD462d5WZaV7SgVm9KvTs5UPku2xxi8z4UNn+jj0LSxpXNJcgFkg3OYRikyxucc5S/XYYWBypkpeLznPVoh4RcV+zUgt7HJU4Hus5sBOhWzFYDS695iqpzpSRhxJHJmbwg2BcBKuJpRgz+RLLihMfPUtsxJcr/m3V3Q6c1dNiNokEI8Y/O+Mg5CqG4e67izH+hG1BiYiXncyibSPfTgBHNzdquP0N3q9Payxlk5bq5JWQJhgr6mxKXHOGt7Eh+Km0u+5otgFVw4yi+JkLfhUB83QOVukDPEiyZXjd5atEPkxRBZ+pwzx+3PMESmOtKeYrhviYgQ/t9N25tATgnnplFsgRLpaTuDGNF2132wFjRFivs/FkmRPk/nfzuCNZxARNOq3ktShRVNMrXl+uYli6LGdN63IWvp/076SZKWZWDdCec2Im2M1PBpbFCqzhDCjXEHMB3G0H9BlkS68wQ+3T/0D4hkqgrO1uoPOdQhvvw80LSo/Og58yIgrwh9rwDbs5L9L13bPaYxlLfwbyrHIINPJPj1/2193ifP7B+zQtV7AeXXChLwFOMInGXFOwzLahCN8/Ed/ee9qExNaKfRrk4T1IrNcvQ+vYLqlN2VfOXO1tlznjBFJnu/g== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01eb6ca2-241f-41f5-e69d-08d9c168ae03 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:39.1848 (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: nfPFKuF420FgghWHlCyVilAPT2stoWTQFm762G/CMRx1ETRjkLmqkbR0qgwMN01IdttcmKklrIcey/tKvJjTmklUB11PFwF8Mtt+Gj7jFOg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5595 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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: Simon Horman Acked-by: Jamal Hadi Salim --- include/net/act_api.h | 1 + include/uapi/linux/pkt_cls.h | 9 ++-- net/sched/act_api.c | 83 +++++++++++++++++++++++++++++++++--- 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index b418bb0e44e0..15c6a881817d 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 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 207905df2b9c..073461d9eacf 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -131,6 +131,12 @@ static void free_tcf(struct tc_action *p) kfree(p); } +static void offload_action_hw_count_set(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count = hw_count; +} + static unsigned int tcf_offload_act_num_actions_single(struct tc_action *act) { if (is_tcf_pedit(act)) @@ -139,6 +145,29 @@ static unsigned int tcf_offload_act_num_actions_single(struct tc_action *act) return 1; } +static bool tc_act_skip_hw(u32 flags) +{ + return (flags & TCA_ACT_FLAGS_SKIP_HW) ? true : false; +} + +static bool tc_act_skip_sw(u32 flags) +{ + return (flags & TCA_ACT_FLAGS_SKIP_SW) ? true : false; +} + +static bool tc_act_in_hw(struct tc_action *act) +{ + return !!act->in_hw_count; +} + +/* SKIP_HW and SKIP_SW are mutually exclusive flags. */ +static 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 int offload_action_init(struct flow_offload_action *fl_action, struct tc_action *act, enum flow_offload_act_command cmd, @@ -155,6 +184,7 @@ static int offload_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; @@ -164,6 +194,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; } @@ -171,12 +204,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 num, err = 0; + if (tc_act_skip_hw(action->tcfa_flags)) + return 0; + num = tcf_offload_act_num_actions_single(action); fl_action = offload_action_alloc(num); if (!fl_action) @@ -193,7 +231,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) + offload_action_hw_count_set(action, in_hw_count); + + if (skip_sw && !tc_act_in_hw(action)) + err = -EINVAL; + tc_cleanup_offload_action(&fl_action->action); fl_err: @@ -205,13 +249,24 @@ static int tcf_action_offload_add(struct tc_action *action, static int tcf_action_offload_del(struct tc_action *action) { struct flow_offload_action fl_act = {}; + u32 in_hw_count = 0; int err = 0; + if (!tc_act_in_hw(action)) + return 0; + err = offload_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; } static void tcf_action_cleanup(struct tc_action *p) @@ -821,6 +876,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) @@ -926,6 +984,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; @@ -1005,7 +1066,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), }; @@ -1118,8 +1181,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); @@ -1194,8 +1262,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 (!tc_act_bind(flags)) - tcf_action_offload_add(act, extack); + if (!tc_act_bind(flags)) { + 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 Fri Dec 17 14:21: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: 12684761 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C4B0C4332F for ; Fri, 17 Dec 2021 14:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237388AbhLQOWs (ORCPT ); Fri, 17 Dec 2021 09:22:48 -0500 Received: from mail-dm6nam11lp2175.outbound.protection.outlook.com ([104.47.57.175]:23036 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237289AbhLQOWp (ORCPT ); Fri, 17 Dec 2021 09:22:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZCYdNwSuCazZgUBiOTh6QTwHbMx4chNr96IdBkLe04RQPZJzD/X5Whvq0Sx9MuEEDQyCGbm54uUr88fpcJAl4mPYTs7k6dOmw9N6sC5Lmiq1Vb0MppTiHiVP67UBYq7WcTfzELHErzswMmzS9+2dL1gX9uz8TOrP/cvJpVPXGQ+grVD6F80dHwh1/M8dGE1cjJfFYPiVGRBisztsMSby1GZRF4Rv/eOwNK3Vnv+7jMEtV0Hu4Ay0YcP3PAwZX0Ft76BATVILJ6PAnYRQCZHv8PAtg0xgN5ZnfH6DK4H4EoG6Orl8b0SqGYR9G+PlZSCU6nL7F9hav/ARM8rpUomIJA== 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=4QfSgnjsykgOtzdPL0C1gZtrHXn5Lvx8cmTtdYaeBzA=; b=I+uSUU2A11HNUgZxttPF6e2lW9pfu/nVwVWVnLIO3RnI7HbqbaKteR5ZquDMvDzfglZhL+/0J4E5sj2EKrBCEmRWQ5ERV/A7SKFAFtqrV6or0p+EBal8S8N6eZV7k+wW4IZwfokggacA98enPU+InN+F2yhEp64aWkzuedvMX4WZFyXnGIFYzhQWqEVm2SEGgCNb4Ev0JQ0/DuWfecwoM4ba6ZfP5df5zApidKdv/JXfZlIEPLQBrlIZ2OPuFzcGi0cILFhC+ZOqrX9yPrAm3A/Ks3umK5JhvnJs0N6uMDpachhckS1AkarrA2expXqOX6HXmt36VTAKx7fJrK/7pQ== 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=4QfSgnjsykgOtzdPL0C1gZtrHXn5Lvx8cmTtdYaeBzA=; b=bD8dbCA+6SiyZKJdzPsM9aN+7BH5KcyE45QKgBlRLi/22pHeMio3TMXpUTWstsJEkse3ZXv0suc0k6aq81VJxhIzpFTlMj8VpCreXDiKQQ/1rJwDAf5Gdl397cUcnBLwcD9MaYQE86z0jJpQrxfpAHKbG/hvI1aH2AU+E/mq/OE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH7PR13MB5595.namprd13.prod.outlook.com (2603:10b6:510:139::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:43 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:43 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 08/12] flow_offload: add process to update action stats from hardware Date: Fri, 17 Dec 2021 15:21:46 +0100 Message-Id: <20211217142150.17838-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 287b2464-5f2f-4cfe-438f-08d9c168b0a1 X-MS-TrafficTypeDiagnostic: PH7PR13MB5595:EE_ 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: 6HEhGSDXiPyB0goD5Xo3mep0N9cS2zYFl/wapPYa5gOKg0RrGPvvf5+OvJmIP+3Czfn9xnnr0VjsF3g6eYCy7DfX61tNrTLEYVKUDPlagAJHU6aellIiNhPyAQ9Nz3pR3mSRqF4e/FDo0Q9RJHa+Prs1hdQPfbddUObSMs9eUmxaxIO46Zj1goStpnbfio00XATfMoktiV3yYEKbNwk4r0o4ZOfO7GTCm6Rs+leNpcHpJ5g/GGbKTueWJz1JH4IakOE6QgJreN1Yhb2MG3CorEhRpcv8qvtRrFEoJHdeoilbXScKxeOTzDqibpPBbRG5BV1DplpfUYoIGRBzJbeMz44fa5z5ohipKO3nZ3hpuKt+wLqmxGf/2I7+I56S7OzppttnupkyNXhxEE4dZ/kn0o4HNjRUzkpqUQGdwMcnqdV/XSW9XAJIQm5GgKwYTvMmdhemRfKdIYl5+Qbys+UyIrzquKl9e42hp/n4YREJYcHy1yBGcVvyuPqc2t/4SgyAnHMkUMCxxfcN8B213wwtAsLjN/HX4mXcTn6uiIdIpYr6JiowxiI1tQ066WFQoKJnqjRyTrLI6FCj3VZOFDAwdYl6YDebecjomX0tpkPG67yQ/wWDTUwGodBELgqHbjYhxnTvyW8f5rYpInR3nV7QI9uFQOIjLsTdt5s0oELKaiPEOjSTnxs9DOaQqVW9Fu85 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:(13230001)(396003)(366004)(39840400004)(346002)(376002)(136003)(110136005)(8936002)(54906003)(8676002)(316002)(66946007)(66476007)(7416002)(2906002)(66556008)(4326008)(86362001)(38100700002)(107886003)(83380400001)(508600001)(1076003)(6486002)(36756003)(6506007)(2616005)(52116002)(5660300002)(15650500001)(44832011)(186003)(6512007)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: el1CtNWb95smwGVuNQpq4xtk3nvjrrk7pxl2EXu6v/xiIbaxg0ZNHm1hFyQhL3nwYgn5gXdbzctSP3KO7m3WoBsK+tEeqFqEUNAufmC6mDX12y2FTqvzstgEev9qEt90DWRHvkVI4OLUJalBYi9mWtsKr0whKLpkIlf7GzVIRku2kza5+QTn+A8IDtcD43MXXfMLIPvQW3IORKeZJN+u3ha6KdNpb5QidFLgUOmO28+YM3iVI+RJxXtRzcuesqMj9+4WtQfkfLCLj+/C4ETp4njGxkIqZhnFXJ9rLgmBVlU0sUlTaMfgQiNz8k02rHT9DAC8ucyHDuA0qpq46TM5FMn02vxUgE5ZmDtXn9oQagAmIZb8exsYIN6QfSDPVGg8TE82PRbAni2r4lyglfIgM2MQpPqzh8PmCzd7m4KaFEda5WpPGLCN9ilENDXm/Jzgdl9otSO6zpsA61OxB1OG+vSZJMxYfQsEzsge/DD/XK9noZFZSebtBMAVRHxJeZw3Ow2y32v7O1YYpeZTIksgWMdn1w7MEbKxkpWUpl4zNQM5UGpB+Ln45LG6LV04DDHEu9psQz9pj0lfbf7LjtZgPogmWzljdHF7CKmdtob3p+nlgBTPiR5yZafIRoD2NWv9M2lZ1Dyj8Z9OkeW4SZXU1M6UwT/yxQr5Ueid2dqPOccnToO9/96Or2mbR7SOPGe3oVGqAZnIcQpfK03Dllmq2tCyOpfJctlXJ0JFpTgTEZm1Rw0DvSIn3LnrO/NrmBti+IspBk8ZpfPUlehyDxWqPDuS32JJj/QjOgdpleFjBntkUP2Lp9sFNlbDf4hxHCuvZnewzk2a399MF6LPb8CYmukdcL9zyK8pH2zuLOeHd6/AM3HLYFZRa7qL5Ylu+HobmJesjvk10ygAsL23LIuQkItNRNbAnJ4qGAhnK2W4K/j7OhYZ4MfBmdB9phNhDK/2Ne95hP63UiC1l8XmCcAteRZfahGy0c4I3XnTsQ7Oiu+CKh6Hpd3/27eDyDq90b0xKjy0cHS6JoErpTPV/35rTfEXkjx6cv1Fu3O7LOKbFXGqjcAT8zY7ZRz0VaKBxGSHs7C8uh7Eg0i6UZh3PF29YE0qAM2l72ddTkyiFQRtwVNiQuBGUKoI7L3VrAR3YDBcuHV/OeotapSJqSRxBE4m5q5JVxoZlbNXjO27hARgbi9GjTmphymFptzcWwrhXIPjurkW3pAsO/tOzlweNU7EdnnNjKyzY/D9yUxTeakQ0quwE6z44LvUM2njYQO6+QKJZCaexGIvQ+qm6k323yKLD3tg0RVQN+pJ6hAycMwSBbBagYMfqSGU4rGtnTpSCBm0oYuq8+piCjqdDNkx3tIfqD8b2I7N4AAH29NE66SMSWeD0Xa26c3ytAtieKu3FqcfbYHcKDYfWo1tc8OjRokBj8Qq0VDQW04Wdjt/g3rXdAzU3GamCrI/ftLGoiKrp9uStCZHPIVl8D0+AoP20XXETM/iE/IQ2EAYK1eCZxCUjiVGBYbtGejlafQf4JBRTbRUN1GCEFhbmY74qJD/pX3MoqGSYRuJMjMNJnhdidF0v3/2VQZoiNnQfNUmN/xLcp93yp7d4Y3f4JLRZLZ3NMQg2232f1uHpX1/M+DishlOITn/8/xRkWB23HTumcqBgsfwKGW8IVsIpi00I5qM4sDDrYof9kFy+PoR2AccE3UiiCQuXEo4EqNpnrXrQz8bUpMToX6eRcYtKWyu5hMQ+jsI4Q== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 287b2464-5f2f-4cfe-438f-08d9c168b0a1 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:43.6701 (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: ktaG/Oti7tpJfXj8XF3gjC1MQ9b49xlv81MLEg+I1URSq0ozHZ0xoJH4r3NoY9PR91S/p2Brw6QcVsrPTzoEiZ5ECF5afusSO7xtzGMHxnY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5595 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng When collecting stats for actions update them using both hardware and software counters. Stats update process should not run 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 | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 15c6a881817d..20104dfdd57c 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -253,6 +253,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_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 1bfb616ea759..9021e29694c9 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -273,18 +273,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 073461d9eacf..ac6c2c396d4f 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -246,6 +246,37 @@ 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; + + if (!tc_act_in_hw(action)) + return -EOPNOTSUPP; + + err = offload_action_init(&fl_act, action, FLOW_ACT_STATS, NULL); + if (err) + return err; + + err = tcf_action_offload_cmd(&fl_act, NULL, NULL); + if (!err) { + 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; + } else { + return -EOPNOTSUPP; + } + + return 0; +} +EXPORT_SYMBOL(tcf_action_update_hw_stats); + static int tcf_action_offload_del(struct tc_action *action) { struct flow_offload_action fl_act = {}; @@ -1318,6 +1349,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 Fri Dec 17 14:21:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12684763 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8153C433F5 for ; Fri, 17 Dec 2021 14:22:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237166AbhLQOWw (ORCPT ); Fri, 17 Dec 2021 09:22:52 -0500 Received: from mail-dm6nam12lp2172.outbound.protection.outlook.com ([104.47.59.172]:37698 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237375AbhLQOWt (ORCPT ); Fri, 17 Dec 2021 09:22:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FRGVF3HAxMM5Y5gLjFZRqO6IPfZ82zImKfuLSiLQuzJ/yTZ4AO2FSSxK8486bOVecaLSJK4EFMX0K+bIdf5epz42tt4IVAklmtl3KXGU7HVi1YcEG00AaVMWoZyfcLmu0WoonLZhkfpI5J5bA1LRIDWmNnId3mjbmN4BBkrWAMiBcrmPZx2FkjxtH6o6uuivKA8WCspqEkVaekF3GebS+1FXl75dupGY3RQgn+7+lg3VnzEri/NqeBy7rFIuTKoln0INiPgQsobsYI2b103yQhhPcRxNAOHrJ00Exzv+Vpzi5MBgcPFOkQl36HaSINXAsQXdfXz164hqwmBZx8Novg== 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=uwnbpnGQsujWzVpx0G3VIKNtNa/iDjgKdHVE5iByKUg=; b=F/vmF3ciSSdz/RTPKGw+mA7+9cBLy8h9XMhJfh3a/KKPOWnQ8+aq3tZ+1YgMhdyZY/WZkIn/piUv6TwIp3ZtSMOelmV6AnKfbCEBsLAXpocNeJwkln7lTNRVK4nIv1sKuq5aFIXi6P0nLCHFidgSKOODeVVOxktg8ajgMqla3CMXCB0fjRM7v16iPuh9VYld6fIbBfFbVl3F7HT5sVpOMp0phe2CT0Ol0MjaqIn0uD8qRqlAvpwaiamYTmmF76SEDb6mVhgGzrYOWG98uvtczQwiQq2slMm/6dapzcmG12hqYR/yiWTBHqmt6P6y94nYOv1Hs5qsZq3QEgdl5bRZWw== 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=uwnbpnGQsujWzVpx0G3VIKNtNa/iDjgKdHVE5iByKUg=; b=Ca7RExL0cTWwnqEr4WJ5UtBblPdO95Di5OaDnuuJFlEhmllGLJ8p+klhkY3UxjCcG7jfqxHDdf0Oq/+73cT398CroahJXM5rvwOotOepsTWu+cotX0bVLA/2pPiLx9B1wHdc0yblDE6L3fRq3nk0aPHncHFhA6fVToSp/xSYHU8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH7PR13MB5595.namprd13.prod.outlook.com (2603:10b6:510:139::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:48 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:48 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 09/12] net: sched: save full flags for tc action Date: Fri, 17 Dec 2021 15:21:47 +0100 Message-Id: <20211217142150.17838-10-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2f5c639e-914d-4f00-22f1-08d9c168b353 X-MS-TrafficTypeDiagnostic: PH7PR13MB5595:EE_ 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: wKBYgCc0yBuYVu9hqJjd1IpwOs0t0eG5sAQd5FaNtIM2MZshqnSTGvD9sIABegoa60lxec4ncj/wdYi7GGUzPXqYciTr7/eDerj34YkIEcT0v95OaNogrWOS3bins7n/h7dfoHdlseXaRkwSskROVKM1n1b+Jnnue6hdRe1xQNXVwDwYKcbBFGMGFHY5TLZroFiDCVd0SYS9m5l7kFifI7bxuVyizO6HaXQowOdvEg1zjgZnl64e35nCGsroXP2EukO+ao/PF4wXf/zU2TKmrz1Thrmau/xZ+GnsM/8intE8EHpPGfXy3P8m+Mz3aFgkexD1pxy7eaBHEGC+sBYZEGV3+DYcvdl+5oeIx6qjeS4JzUzKjVbc6pPbFj32/T3F9Ck23eAAxBLBxKVw1eo5nHa81IrybA4losylxKX5X2p7ek/RUpQ2MM/WQUYT1IwyrGK23wZsrRwcwiXTOcu3qhXHWqJWS/OD4FLQRA+QAOHKcj/6kfUhMqpyr67dpnEPvKW6MxGTU7OcyPvN6EsqIA9XMcPxxH5Jl7cfiVJYZhcDB6ad6wA6JX7OQCf7F1omevHn7CRvtmuno9oBX3nqp5+R77BjpHGKqUjNX44LoajbthUdt7lTR2oaX+KYF0p0xpCY49NFTiFH1ZCpkkOHme7n4ekmeHPMN6BfvxyQsl9ybFcd0p7ZxLbXrN1rUNFy 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:(13230001)(396003)(366004)(39840400004)(346002)(376002)(136003)(110136005)(8936002)(54906003)(8676002)(316002)(66946007)(66476007)(7416002)(2906002)(66556008)(4326008)(86362001)(38100700002)(107886003)(83380400001)(508600001)(1076003)(6486002)(36756003)(6506007)(2616005)(52116002)(5660300002)(44832011)(186003)(6512007)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pFI6HdNln5kvgkB75CEEAWhvWUiePZRJNLF9+TNr4+NNWEr0sfvjCOc0SgwGA19/xlIWPkB/1H9BziAFrmbsDlNWDPZ2JVtuLFNOXXxeixvng1cvgh4g/Pj60bsyj7zZ5bvpi/PPX85ybeWgGBxJb0RTJ30Is7n5C30KnNYVzfoJrSMSGXfqobPR02KWZW04cccw+bG2GgY4Tp10X8/ErjCQhDs8rq4KsJeSfs0FTG2nshTqXyNWb4DEU3M/FTo+komPfEf7i4TKRio2ojEdqDLg7MTzsKAtANYOX/qYwvJm/J1LJk29sW5PtSiP9Caos+6EHDu0jLmC+nmVsQoM8NjkdjIZHnrcuRZi30R1tpH51wd+JJP/rB71prjSRBqh4bujC1BTxwEpMB/RaG83zvAx7QI+b8O7NhypqIbxswRs//WnavdynTXC3qGTw1sRoJP3XGLfWKuxbAfrAKsUwmUzzvNBJ1pg9Kx1xhWSJgepzroKDaYbVdk7/Tn/y3IKeesEOXb/KLmdJQTBtdzbhPE63MIDFP2EnScEp2ulADtx7g/G9TGlqzrOD2e6wEqeSLU0q2+JXcuYZtMQZWLFWvUdIUnDnwYvvuaX8sDQkOaEN6W0u3Dv+9yvno6y2+TQO6Sp4AltHPu4ebltXQ7LjIX5qW61yM7h5Gl0KCgl2RkK451+/dDavKGjxw2q4WeQdi5L1/aw7KTZU5pkr11+LrIQjWQW6qNq8xZ8dm+bSk5lZ6hh5u3S1giWYIo5ukWkXBUJS/ECMXwf9LyiCSe/YCO5DFKq8Ia671mbtS0C+beOphsC/xoJa9pVC/yh3n5SxXPYlR9t2QVRoizopePdN2pWuvgybuvvevCVL0WGsf2hx/fpRZIlaK1/NfsfW1xQJz8ZCvYBMixa7DweeWF+uKJBvZ98/kt9q2AM9giTeYheLSuraGg4O5/iMvRlDv1YLVqlhd1Eoahd+0MISsEl8IPQyv0qmdecLKVbY+ENhE2tm3u+UP4dexFwOZGgTAQ6b2IId+7aQYTZF48SOBBVLxtppDD/mDR8dhuT7wODpt+I6DTDauTndiHTVWzw+YkUdNlESotKG/t1pkBEvyGRC4xRf7huLXIKqW8oiFC1C2OfMafyl4/NJQbuoY6EYWlVAoTVYcFx/YyCstXPNn03xXWzRz4Yx0KxErgt1OjJe+IhL/QzOIqqq3nDQjQtw3obSVtsdo9aDp6I9HO07rkrBu8HdAJXrk+UWxQ7ZO7yyivK07Dvrj8jfslgXneLSQUMvjeLzqzFmJNd09Mp96obmtw/qJKtjHDSiSIxjzT6PyJNBesNDaJZ2cU6Vq4fI77ekeek+i3CApucQARd006LGLOzZBs+7TogbI6m3tvMfk+31OVjrqFf0RAuR04Pf/iHuhX6K4aue9CRMd69bgFBZsELIa9i3a4utAJBTa/QaRz8Bf7lKBcmzuB5ufPoban7wgeIa79ihFSkVWJHsRwteJRyuQBVyqmgvkkI3r2SLdml6REIryR/eyp54Ll2ShHV+s8AIr9wpNODKvwaztfh4rve5JvaqCjnExH+M3wg+oQJ9FJzTKOGZ+0YyQ0bmrsfoa9Xy/EOqjRu0CGpEOhFvATvHsmu/xRqFKslU+T/OQ0pphCfoNv/PtcrPGcPLzuXThz6VF+BuilfayxaGk1VBNRrd6weho8hS19UpgTX9oTQnxLrdTSCJXHu6s4yfO/0HB+dr98HvioSRUmlIvr0Ug== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f5c639e-914d-4f00-22f1-08d9c168b353 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:48.0757 (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: dj8+Tzw8q7BduE4iXxtducAvSw/irg4WiIhKPq/34ONP6ANGjMdqCE9HUTep0bPTz4oMXGssveux88yzgBr0RDQgXKPj5q84EwKzjradWAo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5595 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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: Simon Horman Acked-by: Jamal Hadi Salim --- 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 ac6c2c396d4f..75f34e6fdea0 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -669,7 +669,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, @@ -996,6 +996,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; @@ -1010,9 +1011,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 Fri Dec 17 14:21:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12684765 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5434C433FE for ; Fri, 17 Dec 2021 14:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237289AbhLQOXC (ORCPT ); Fri, 17 Dec 2021 09:23:02 -0500 Received: from mail-dm6nam12lp2171.outbound.protection.outlook.com ([104.47.59.171]:28401 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234648AbhLQOWy (ORCPT ); Fri, 17 Dec 2021 09:22:54 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jXn2ZLZ9iIn684MDVJrXhKm7NgyA0tdBqcCOaORgF8ja/+9KJgziFqrUXuVLBIuQbPIs1J4hVOfWL2F2yG0Pi5jjKr6uk1keTlz6pk6OdUeS5ffIG4VaqR/qXrSqdOpN5vjp7qju9yuFs2wdmRbKiiX3pX3a5Mu78AC6BUOfPHtk25VNxIlAx6r32qYhyjILJCPxhL15weBWytQ2TtAaV4nxzUFZRbyLJgJKqmMWyrFcV9BLY0HkjIJ9yRG+s3v1i6UwuiwXo5vqfT8W79Ufjey8OfXS4mzO52X3j+k0///oOrP1P88Km37armZngeJauVpZqDbKr1J8sVMAL0rHBw== 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=RPfU+Rnat6W5QW/UhiKUvJVvi9dDW8DWhD1LTx7oijg=; b=eiRMjEJFfQhGKSa/wd8R/uNtYksE5odcdteA7MCVl3NW5ydPFJ+WYp48Jmf9EChxQReMg9hpHI8kobiKpGEMRPGOLXVCo+KmAXimR+gga/dZ4bDt8WrJ4FbartkADRdVBXMo2L6bPvycYX5spS3cqfdXaGM/7DV6yLxeR20QhhjnomDP07a8h0A8X2sTvR5d7A/sH2jp0xdEHDpYpjQ/5N7JtaQvYnhxMNJR5lY7IjSlll+LmyhLr0nGuhRnTLD+Y4QCh8bU2fVmFq0WOEafASjKP82OzVSpP38o9AsZdenkon0rrCh/1kjPON/AVJ/vT396CfW1JxlCv2bFamy34Q== 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=RPfU+Rnat6W5QW/UhiKUvJVvi9dDW8DWhD1LTx7oijg=; b=lsM5Q+mYAYcDrbXQNceRiCCZUU9+CbjCB+FhabFDLChOtO6eXa3faSYNWSO/mkWcAh/oqy1YvF1Xwy++pGxk8CB5z9ebtoDnfF7XyGvzkgw8GAPUafL/wPLNoJfQ393YZmTvuBFDwTxKjezT+vadjr6wesxJL/Bu1XMPQQa1ST4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH7PR13MB5595.namprd13.prod.outlook.com (2603:10b6:510:139::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:52 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:52 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 10/12] flow_offload: add reoffload process to update hw_count Date: Fri, 17 Dec 2021 15:21:48 +0100 Message-Id: <20211217142150.17838-11-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bef68b1d-f2ed-4d23-ce0a-08d9c168b5fc X-MS-TrafficTypeDiagnostic: PH7PR13MB5595:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: udeyNiR2EzbKiQdu3avXLkdXciOKoNH9coWLRnbSOmKn6uhFqp951aCLJQ4Fkn9eplQp2ELJYBBnoJtoUfOGa64L2WKy++pwP9y9D9ciG+GQl8FvOnI+XzCrcMejSYcx3JS9UpBXD3rUfdtzx1cZH2iD758EmZocMTgJHtMKzhKUlBi+yJriKVZOiaogqVzQ6XQQszW17gm7MkwBlExSxhJXrQwbemszmNeWdlcf/1wQ0SV1nwZvMwbzhboAOnf6eGIVzku23uBUgg75XUYTMJhWudUL9DzKtI7CQ2sxktO1RAPQ+9UeWjLm95msszKGBegerlLvUdMHgq2RXWs1By+CpTeKf3CWNeRrHsEDR8RI7yGlP7KmL6Np1lMtpoeJ6UyeA0g9r+kJNU4NStUXoUfOI2YAf4AY0BFd9npNIRRIngu3J8Xbqqc8a6IH10zqj/XV6BxcDYCu5OkT/spPN3dH9bwJXVjTFqaJ5OsWYcM0YgCnaP8OvSnA8zNuOVxAiadlPENODRDp82Trm8dGh0grpIPxuN8334dUMlMx8+4QtX3GcRJBrsSlPsvBOdiOIjRhtwvzBwOJBb0WaybXm+gTdtetOJTGlN8iGJqH3WLIQlRWoPft6Pn4KZVRKevQTsKAxhYvERWj+0SkzLLEOd6qtBgA8qvYfWgRyNfO94mGf9Pr5PG/1IV7sJODwYLs 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:(13230001)(396003)(366004)(39840400004)(346002)(376002)(136003)(110136005)(8936002)(54906003)(8676002)(316002)(66946007)(66476007)(7416002)(2906002)(66556008)(4326008)(30864003)(86362001)(38100700002)(107886003)(83380400001)(508600001)(1076003)(6486002)(36756003)(6506007)(2616005)(6666004)(52116002)(5660300002)(15650500001)(44832011)(186003)(6512007)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hBQwU6zrIpYyUvRPPo5A8xrz5ae0toJA2DecYIBdoYhUjcIzLzw13XEAcQMoVGonaI4aVItket4mQ8CVuMyTa8SD+vsCGUbJhbb3EuWEv2ntdsoEs7OS1jKgszyaVORrZRb90QVEUCQ10mJ6rMM9TomSIpup2GMnWWGALTLCKWuXK+OYTu/psS5WZuX0DPKz3Jok3Q9XBSO1Fz5WODAL9LN6fPJQmIiGd1FTebfSHY4CJYM+q74cheTGpsu/fA1O+gJl5t+bQ/5N+mtRnc6CZIdiwyuFKCgJ7jgjd/NQawtbUuH5oYEr0m6/TYRe+MluFqXOuUbPS8YGb77J7hp/krCQhHAZHa35SLoxb7fUlu6djIlxTHx3X0tPYjYxn3M3oQJWYFZ95ZeD9dr9cWrCeJ9ElYzV60O5YndfLk8048Q2m7cSkz4ASxlE58v/viNFyn+5FK9uGT/MNZXssJfQoWqqwzSuy74WCZ7ZyEt1PsfuprkauIxsBF1K61ZrPfl20xsK07iQkj/er8B43beqk8Tkgb5f41d+pVKtunU9/72GFkz0qrNTRI/WCRvGkaBImL5GmP5MkQYX/vnDu55EbKXKiHgqZLxiG81/0H6y5gGzRhW8j7qcjgkd0Pmz/CAw9fFshb4ua8nQEfmF+Ndhi75eZjO4NApMApE/d34ftyU+DE9pFaoch+k/9LK+R8QWh+yK+FbfWPgLKHo8/6uNSAY8ozsDeE5wlYIcXounwOPrlMVR4lxzURLOMR4GthdqQKGBV2/cOhv40Q0R7tCHsg+ZazoT87DAOk6E2GBcjk5xPRlXjWgcDG/QzHI0QZnm4mbQI748VPTC5lNf4Ju3ZIQVdrKNxcQboLQGAAIUlQ6vfHxuVcRlYa4l2QIKhby2OBC1TRnvk/nO8ayej2ITQxVSmA+AptV8/VBF+96/3dV28GbVOiGjbbLk3deZUQLiRKBTPvJ/ewXdvt2pyqk9iDiEZLJ5sGRNZgyjJTjUbDe+EfvGgKtI187tS45FXdvVBtYZAqX4ZUxnZgYeksCJyikX8XtQsW/pomAS7hxGXsX8ReU6cQgjvrFw8cAEwW5u/FWEmkgfpx1tBlfQLNpU5S+BexqlhGQcJ8wksIlFhwJCony1pfx1OrfhphitIOtkqw0QJm430qD4FIXHiOH4YAhsKLgin+s+EkvDsSVlFRHpw3tOh5oraMV+pohln1MCA8u+GMB/VNxNDg/4PzA3svfmwUeGWxfOYWkF0nMztY8hvO5923RlG/KdviVUe7Eu+mHQx2psky8CEeZ4r8V2CLBnLziNzfVzYK7gTtEgWMPQ2a6YhOMo6XNG/ogXBfAtT9RTEjSuV93hXLqAQP4MgnxITE8/LF6Ipu2CqGKAqrtqkLgmuCGCEghk70uPr2j9lNKIkuZ8EjN30KRgTBwJ/UdC9gS5Q7dfnD2DGo51cFfCoqRKidFBOVbmoZ0qrgqRIqjqDo2pcf/56F9P5VyjUli6ok0DWeCdgyP7xqZ3Vxxfo9IPG3Rcl13tJ9HeqoAgdnBf/nBNJCM4hTrcJ53BC605+P7B/8Ac7dJTZ5fYz6Je67vxKPSXz6vA/zf/oE326j4S1vsSlFoBFEOPQychPWhmCy01RfRBRWNv/gltcZEy7VLgDVNnf6jXEuLgZe9/41q/pXLQeUiw7onozPc7goSWcu3pjJBj7zjb0qGDOaqW3r6lwvJpSzYllNBU6Uif4EewuDWI/APIfUL9eR020A== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: bef68b1d-f2ed-4d23-ce0a-08d9c168b5fc X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:52.5889 (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: Ri6sYQTDMbVtNAdv0vvzJ5ki/MImdnKT1qeUHNRmBHTsW6SdqKJBaiqhGUBUkR71ZlEOBBCm2i6H+tt4yAqW28vX5/UIwoiyjYp8qe+3dE8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5595 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add reoffload process to update hw_count when driver is inserted or removed. We will delete the action if it is with skip_sw flag and not offloaded to any hardware in reoffload process. 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 | 11 ++ net/core/flow_offload.c | 4 + net/sched/act_api.c | 252 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 250 insertions(+), 17 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 20104dfdd57c..0f5f69deb3ce 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -254,6 +255,8 @@ void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); 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); @@ -265,6 +268,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/net/core/flow_offload.c b/net/core/flow_offload.c index 022c945817fa..73f68d4625f3 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 @@ -417,6 +418,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); @@ -469,6 +472,7 @@ void flow_indr_dev_unregister(flow_indr_block_bind_cb_t *cb, void *cb_priv, __flow_block_indr_cleanup(release, cb_priv, &cleanup_list); mutex_unlock(&flow_indr_block_lock); + tcf_action_reoffload_cb(cb, cb_priv, false); flow_block_indr_notify(&cleanup_list); kfree(indr_dev); } diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 75f34e6fdea0..0103e44e241f 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -137,6 +137,19 @@ static void offload_action_hw_count_set(struct tc_action *act, act->in_hw_count = hw_count; } +static void offload_action_hw_count_inc(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count += hw_count; +} + +static void offload_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; +} + static unsigned int tcf_offload_act_num_actions_single(struct tc_action *act) { if (is_tcf_pedit(act)) @@ -183,9 +196,8 @@ static int offload_action_init(struct flow_offload_action *fl_action, return -EOPNOTSUPP; } -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; @@ -200,9 +212,37 @@ static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, return 0; } -/* offload the tc action after it is inserted */ -static int tcf_action_offload_add(struct tc_action *action, - struct netlink_ext_ack *extack) +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) +{ + return cb ? tcf_action_offload_cmd_cb_ex(fl_act, hw_count, + cb, cb_priv) : + tcf_action_offload_cmd_ex(fl_act, hw_count); +} + +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] = { @@ -231,9 +271,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) - offload_action_hw_count_set(action, in_hw_count); + cb ? offload_action_hw_count_inc(action, in_hw_count) : + offload_action_hw_count_set(action, in_hw_count); if (skip_sw && !tc_act_in_hw(action)) err = -EINVAL; @@ -246,6 +287,13 @@ static int tcf_action_offload_add(struct tc_action *action, return err; } +/* offload the tc action after it is inserted */ +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 = {}; @@ -258,7 +306,7 @@ int tcf_action_update_hw_stats(struct tc_action *action) if (err) return err; - err = tcf_action_offload_cmd(&fl_act, NULL, NULL); + err = tcf_action_offload_cmd(&fl_act, NULL, NULL, NULL); if (!err) { preempt_disable(); tcf_action_stats_update(action, fl_act.stats.bytes, @@ -277,7 +325,9 @@ int tcf_action_update_hw_stats(struct tc_action *action) } EXPORT_SYMBOL(tcf_action_update_hw_stats); -static 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; @@ -290,16 +340,25 @@ static 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) + offload_action_hw_count_dec(action, in_hw_count); + return 0; } +static int tcf_action_offload_del(struct tc_action *action) +{ + return tcf_action_offload_del_ex(action, NULL, NULL); +} + static void tcf_action_cleanup(struct tc_action *p) { tcf_action_offload_del(p); @@ -794,6 +853,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) @@ -812,18 +924,31 @@ 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 err_id; + } + 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); + if (ops->id) + tcf_pernet_del_id_list(*ops->id); +err_id: + unregister_pernet_subsys(ops); + return ret; } EXPORT_SYMBOL(tcf_register_action); @@ -842,8 +967,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); @@ -1595,6 +1723,96 @@ static int tcf_action_delete(struct net *net, struct tc_action *actions[]) return 0; } +static int +tcf_reoffload_del_notify(struct net *net, struct tc_action *action) +{ + size_t attr_size = tcf_action_fill_size(action); + struct tc_action *actions[TCA_ACT_MAX_PRIO] = { + [0] = action, + }; + const struct tc_action_ops *ops = action->ops; + struct sk_buff *skb; + int ret; + + skb = alloc_skb(attr_size <= NLMSG_GOODSIZE ? NLMSG_GOODSIZE : attr_size, + GFP_KERNEL); + if (!skb) + return -ENOBUFS; + + if (tca_get_fill(skb, actions, 0, 0, 0, RTM_DELACTION, 0, 1) <= 0) { + kfree_skb(skb); + return -EINVAL; + } + + ret = tcf_idr_release_unsafe(action); + if (ret == ACT_P_DELETED) { + module_put(ops->owner); + ret = rtnetlink_send(skb, net, 0, RTNLGRP_TC, 0); + } else { + kfree_skb(skb); + } + + return ret; +} + +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)) + tcf_reoffload_del_notify(net, p); + } + mutex_unlock(&idrinfo->lock); + } + } + mutex_unlock(&act_id_mutex); + up_read(&net_rwsem); + + return 0; +} + static int tcf_del_notify(struct net *net, struct nlmsghdr *n, struct tc_action *actions[], u32 portid, size_t attr_size, struct netlink_ext_ack *extack) From patchwork Fri Dec 17 14:21:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12684767 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51485C4332F for ; Fri, 17 Dec 2021 14:23:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237280AbhLQOXI (ORCPT ); Fri, 17 Dec 2021 09:23:08 -0500 Received: from mail-dm6nam12lp2171.outbound.protection.outlook.com ([104.47.59.171]:28401 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234597AbhLQOXC (ORCPT ); Fri, 17 Dec 2021 09:23:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fvmQCT1wOULeD3w4mTnPvrD978W92VPqHZe9Chkkfczo9te8fMpe631/Aa2K0NYsc2UHjlIUv6AU0xHWj7WdUdHB9PNxSlGQI4mY+WP/ixW9/XIPugUcsWI0thdTmaKz7xn34E+pN9cti5jhFsbEfNo8/yPP/8YLgd9XBAu94JPIEYNuQSxBa6MH75rSetBOJyh80OgAwHE+cTwlUOreR/2r86IbklLRsgbI4BgqvcfEW8h4XukzlRyq8qma1nrIfpKgD2QHNl6J3jx+5bwYDznSEtYQ8u2ZqT+75hQn7V6IVuPJxTeRiDUYvJDg9XJEK9c9YeG8CqENyW2AjCmT1g== 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=NsZmCq/HKqyStIIUm6M+BPEeFAHsIGK1ekUALHueZOU=; b=NAK+XZc1wHqMfcHJi72Il+1NOuen0Hob1vJXPaCQq63EECnnjZzBKnmtww1/IOlDe+Plm7M8ECzoMqpircidOow1VV2lhodCj32J/jSi64a0ZDUIabRdIRutd8mHXS20Hyz/w/lL3cHwAKrS7FUuGBg6raovdqhNCSXXM7goMzKXErU31U+T8uLuE/6WmAsl7E9oZXiSLC7oW+nWKmL/k+jR7ZqgG+Eh5SVfcPxEYpdpcVl35CVyKbJri0M/Jejw5iXL/mC7ECzdOw2s/i8jq90K9beNd+JmqYhHJEn+oCcp5SxLcRPjS6twRuL1Xx//1PCo0bO00wUWNprl/yZ/kg== 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=NsZmCq/HKqyStIIUm6M+BPEeFAHsIGK1ekUALHueZOU=; b=fSSyzfkEf9gXKu/zWtxS0iNM5Sp/LbbzCV+3Hy9yT8wnx79ue6i1cpFGJWwUVJ1n6P68tm4Lk4jua+LXUZtnHcT5uSut3rIOEnFJa4J8wuXWotKqOdPd6JswChcxzTZPUfEXPkSbxMK+yk8e6daochqU5uewPVVFUqRusgKRNck= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH7PR13MB5595.namprd13.prod.outlook.com (2603:10b6:510:139::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:22:57 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:22:57 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 11/12] flow_offload: validate flags of filter and actions Date: Fri, 17 Dec 2021 15:21:49 +0100 Message-Id: <20211217142150.17838-12-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 398672ad-d237-4caa-8600-08d9c168b8a2 X-MS-TrafficTypeDiagnostic: PH7PR13MB5595:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:16; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BQbtGZJ5IH3/+BteaVYvPwyWMGOPf7W+OhHOgup148A5UfGvP8E+bapJPaI8dyR/XCh060T8vmuGBWJq0wJyW+Vp0yURoiQVre1Rag1vi09e0beg+3yX/fyPHj9BKkoVeaXmWGA4Dx5L/5FFefjJALVA1IqZKDir4SYczxQrtEgmksWfhi8oftllXtc4sQTY5ZKyEXumsAcA+d6JsAsL0j3iKTET5Gm1Iwx+O5swpgHHfq8pHDKr+040gUU6t9/OXjz56l39jPMSrTqehLhOVoYb/umaaY9A8RIAU9Pw9tqfQLrcJjra7UAhXXrW91z5gYlVreTlgwz0oDYQ2e7OYi2r6nN1NlH6pBZwjyJqfShnV6aBV2hZaBiwac78bBcOBSD+Xx9PorbUSnZGuSNgC68KPhJfDIFEBFDwrRrJzBP2NrmewQvrMqyH6x8YCkGzYtGGilFBgJdZYKORQ19th7a68hxZWqooWENhYMioWHTKWnZIwrhndEC7mN4pIISMAOdrOClbGvI7eqtCY/VOJdjA2y8lgo/lknmsunt3AmUlkZJkv5/9YMCz1Dh9qXZm8T+GACekkiwwyzV4oRh2MHNn7wtoExcZOUiiqMb8fWvhcWOrmBgx45F+TV8cHthBBLZZKcJrli3W/sKe85TJLLWAGZxSzbK7v3R3k1JVjRzD2L+r9iEOIx9s3TABrktE 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:(13230001)(396003)(366004)(39840400004)(346002)(376002)(136003)(110136005)(8936002)(54906003)(8676002)(316002)(66946007)(66476007)(7416002)(2906002)(66556008)(4326008)(86362001)(38100700002)(107886003)(83380400001)(508600001)(1076003)(6486002)(36756003)(6506007)(2616005)(6666004)(52116002)(5660300002)(15650500001)(44832011)(186003)(6512007)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DIamQdy1K4ozw1g25MU61URD9hu5PqIexYkdq/IayzNpFaIlnpHXA5qQ3r2dlXcrvq86gZ8DdztlzwAe5e9XdCZSWVoHgLRSlL3j3X0fXJphFNTu1kaX5+AYEl0D0Ee5BNHt4NTII7P+6w8oRWJljH0Uhs581F1JajzvGceTgKQmVzlGF6B5x/DGLmq0RZXp2ZWg5A5LqNTH07E95fQHnz5lyV8WRlaJ2HHiWV1pSIJe1XBtWDZ5znOXul9KrZhT+w7i/wWMjBHjbb9iCduoj6xE6ziRqWHlaQ/VIsGK3TpUbbXFzmpREWTGUSDkU95PfzvFVOwWlc019wlXX3boRCjMaA460JMPQ/yyOm7+T96NMugpxKgVnq5cVb2g9gX6rcndmeYRI9mK7KO3zUFt9SgKDbX3EWzgccRnMDe8CIcgF7IfpK3t/4CgQBFtq5dBv000LNhBNDspItGr+2aoUlOlrQQxI9MYWI1ndUMAcYSPuq6T9SW6bBdKMPJLN6lkH2uVjf7zEs7qAPQbCq+9tEFUw6hCt6BnZX3Hl/aEYrsnAP8x6PZq6AhVuwGLc4575i8VHtk/3UuOPRpqVzoz71+kadgcFJn5FHCN6Gk2/c0u4GNDO3LsNrveZkGvp6qElIfelrwmSNqCtW8R+1VPRYuvKgXFqPgp2lMT2NBscn4+DDJbBlQrI80qXOd5FM5kKATSUneVn2xGbB9NbQWG1AQ3DZivW84nHiqjwKY9VD678uKd1RrSKJc2lIzGcXvQ2t1v015AedMpjfNNA0hcQtHDdmlfa5xxGHzXpTCDY/dtgCpAy0n0g2TtqJvRwJEs5gy6UFj4D7MKHUwhF8j5Fq45QonQJnLSKQee9SqVO3pJ+VpwA5IrqcNvPgGTDO98yJz2l5nUlMXQvGe2PE0tT0zLKhemaIS9KRAztubCPhqheXg6kGuevJJXD89ztVkjA18NxDLsLpAnCzqKdbL058JWilvm0Mg3oLhr5qvnHwtMj9mDkZk+L1Sqc/75CaP5/gNbSIdHBWs/vQCCa5FzpdCsjKNEWUJp12VppMFFYDJNBiVnRQ10ovjW71QEbW4++LplgLuWpzMFuKp5o0svpZl4y/TkZgIsOxgsN9nzKtnpzGy3UX5mQ2ojKsUsZgoY8EzGuB2zOU34kbsXy/MqaZWpv1V+ihCQ+C6S8TUgXq944LNcqKQfQ1mPZOBYhe/3vr2Cfqxl2412oWQYGcbvkZLy45oA9kJYoPU2dGYfmZ6lNo8qLwkhZ5O/7h22Wy2NLLmGAaHm0UnV2AuWve+1IFlin4ZZgrUD+15WbJ4Txi9evMPBb+zQdW/WIecVvnDJ0F9RRlbxsvg0VuYhIVRnoFFRzvbLrTIII02JMyImk99tEN1yYMB5+2IDek3qSXWCQyZwySbSDIRzMe5qhkp/pTGBBfupUKSsxqGG22tcjBZ40jmvSMUxYMq2U1m3FcvtlJBgzcz6NV7NuiANQxe8zWgCRFMHakqicO7R3X/ocyF2L/1TpyPTIxY7JdDqtQ+NX50/lhPHNGEm/2zbja1RRqgXZdWnuY+z8hEtdbCVzh966h1V04EsUKb89QnTb4KapSq6WwkcL233UnK0J1QYVrG+C2SudNCTRGKqFREGPcAJJG8vuBo/piNMh7e7aJSWqGgmxIDuOemK1GpiqpAGkQia8iOq633IKqlJF9YQjyFiZUkT1CHEDUuiq3VNrXdWAJgTs1YdibFvhB5n/dRtrg== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 398672ad-d237-4caa-8600-08d9c168b8a2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:22:57.0155 (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: GMVe+Z7Csx91nAWwjPwy1uNPidV9lS9bRvVapPTTXmqYiMkC3wnSM6djtb/+ZwQxidlvGx08+eQoTPQv0gEQcVwTe8rRnNuNbu5FAfZwNo4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5595 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Acked-by: Jamal Hadi Salim --- include/net/act_api.h | 2 +- include/net/pkt_cls.h | 3 +++ net/sched/act_api.c | 18 +++++++++++++++--- net/sched/cls_api.c | 18 ++++++++++++++---- net/sched/cls_flower.c | 9 ++++++--- net/sched/cls_matchall.c | 9 +++++---- net/sched/cls_u32.c | 12 +++++++----- 7 files changed, 51 insertions(+), 20 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 0f5f69deb3ce..3049cb69c025 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -203,7 +203,7 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, struct nlattr *est, struct tc_action *actions[], int init_res[], size_t *attr_size, - u32 flags, struct netlink_ext_ack *extack); + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack); struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police, bool rtnl_held, struct netlink_ext_ack *extack); diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 9021e29694c9..8a2f4579081c 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -330,6 +330,9 @@ 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); +int tcf_exts_validate_ex(struct net *net, struct tcf_proto *tp, struct nlattr **tb, + struct nlattr *rate_tlv, struct tcf_exts *exts, + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack); void tcf_exts_destroy(struct tcf_exts *exts); void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src); int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts); diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 0103e44e241f..91967f6a6c03 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1385,7 +1385,8 @@ static bool tc_act_bind(u32 flags) int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, struct nlattr *est, struct tc_action *actions[], - int init_res[], size_t *attr_size, u32 flags, + int init_res[], size_t *attr_size, + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { struct tc_action_ops *ops[TCA_ACT_MAX_PRIO] = {}; @@ -1423,7 +1424,18 @@ 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 (!tc_act_bind(flags)) { + if (tc_act_bind(flags)) { + bool skip_sw = tc_skip_sw(fl_flags); + bool skip_hw = tc_skip_hw(fl_flags); + + if (tc_act_bind(act->tcfa_flags)) + continue; + if (skip_sw != tc_act_skip_sw(act->tcfa_flags) || + skip_hw != tc_act_skip_hw(act->tcfa_flags)) { + err = -EINVAL; + goto err; + } + } else { err = tcf_action_offload_add(act, extack); if (tc_act_skip_sw(act->tcfa_flags) && err) goto err; @@ -1926,7 +1938,7 @@ static int tcf_action_add(struct net *net, struct nlattr *nla, for (loop = 0; loop < 10; loop++) { ret = tcf_action_init(net, NULL, nla, NULL, actions, init_res, - &attr_size, flags, extack); + &attr_size, flags, 0, extack); if (ret != -EAGAIN) break; } diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 353e1eed48be..e3e26d358c7f 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3025,9 +3025,9 @@ void tcf_exts_destroy(struct tcf_exts *exts) } EXPORT_SYMBOL(tcf_exts_destroy); -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) +int tcf_exts_validate_ex(struct net *net, struct tcf_proto *tp, struct nlattr **tb, + struct nlattr *rate_tlv, struct tcf_exts *exts, + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { #ifdef CONFIG_NET_CLS_ACT { @@ -3061,7 +3061,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, flags |= TCA_ACT_FLAGS_BIND; err = tcf_action_init(net, tp, tb[exts->action], rate_tlv, exts->actions, init_res, - &attr_size, flags, extack); + &attr_size, flags, fl_flags, + extack); if (err < 0) return err; exts->nr_actions = err; @@ -3077,6 +3078,15 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, return 0; } +EXPORT_SYMBOL(tcf_exts_validate_ex); + +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) +{ + return tcf_exts_validate_ex(net, tp, tb, rate_tlv, exts, + flags, 0, extack); +} EXPORT_SYMBOL(tcf_exts_validate); void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index f4dad3be31c9..1e5caad4f7c8 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -1917,12 +1917,14 @@ static int fl_set_parms(struct net *net, struct tcf_proto *tp, struct cls_fl_filter *f, struct fl_flow_mask *mask, unsigned long base, struct nlattr **tb, struct nlattr *est, - struct fl_flow_tmplt *tmplt, u32 flags, + struct fl_flow_tmplt *tmplt, + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { int err; - err = tcf_exts_validate(net, tp, tb, est, &f->exts, flags, extack); + err = tcf_exts_validate_ex(net, tp, tb, est, &f->exts, flags, + fl_flags, extack); if (err < 0) return err; @@ -2036,7 +2038,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 2d2702915cfa..13f7a9ecd89a 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -163,12 +163,13 @@ static const struct nla_policy mall_policy[TCA_MATCHALL_MAX + 1] = { static int mall_set_parms(struct net *net, struct tcf_proto *tp, struct cls_mall_head *head, unsigned long base, struct nlattr **tb, - struct nlattr *est, u32 flags, + struct nlattr *est, u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { int err; - err = tcf_exts_validate(net, tp, tb, est, &head->exts, flags, extack); + err = tcf_exts_validate_ex(net, tp, tb, est, &head->exts, flags, + fl_flags, extack); if (err < 0) return err; @@ -226,8 +227,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..cf5649292ee0 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -709,12 +709,13 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { static int u32_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, struct tc_u_knode *n, struct nlattr **tb, - struct nlattr *est, u32 flags, + struct nlattr *est, u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { int err; - err = tcf_exts_validate(net, tp, tb, est, &n->exts, flags, extack); + err = tcf_exts_validate_ex(net, tp, tb, est, &n->exts, flags, + fl_flags, extack); if (err < 0) return err; @@ -895,7 +896,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 +1062,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; From patchwork Fri Dec 17 14:21:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12684769 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C152FC4321E for ; Fri, 17 Dec 2021 14:23:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237272AbhLQOXK (ORCPT ); Fri, 17 Dec 2021 09:23:10 -0500 Received: from mail-dm6nam12lp2171.outbound.protection.outlook.com ([104.47.59.171]:28401 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237287AbhLQOXI (ORCPT ); Fri, 17 Dec 2021 09:23:08 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z1md+j17gF5T8z5liSM76BxQ66aZ386HhX5qYFlShu9WVc4XcUnrz6pq2sDHSje+aK7AOUD3u2aTlaW+qR9ekCdRpjXR44xniwcJW/COQcQHaL5DQ5FCcWtpFKOTZmIGZVrAje4WdazCmm3FRFTnMKJRyHJwWQEhN9lJw2kuc/SjrEiQNgW1+Pp5X5JpPalf9RSi35Pkj0Py9caxMt9exnzrn4DlHYEMEvGhY8yDdZUKytfzPbiHCkqjsjq0KECp1VJSNYyg8RUgC1eK7mc1i0MmIQGpc94k1+Tpd6v1cCbS06LwSue3zB7Xsmb2CHoHump3wxz9yzbxeCvJe30kLg== 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=oKllfkqrbcJlJzWlMdm1iJKX8DOQSDXWjvJzsShFQ3c=; b=cSIkko14Smln46vKw8ffl0K7yyAfTenvoCmnFtuZPqAxa2buUACwhxrplSDy/SOfbLfa0fgNUKEGiR8Y2JimxgUFGp1vuYDxx6z2YDffK3iahY/E0uCjd9sbFsAFfuYGnMwrqTbaGAH/zRbE638bNAU0JlckfQhW7AfAhZ3B4IY4s1Zk5BPSVFob5EoTVbz+q9EgRFLeWQ4ixM2FhxDYvMnKuvkb5kYuZnNluGzalI1fGEOLepbWPwgBPfpOl3rMvYCOYc+qz/EIuOCCyucmvxqkieZ57R68mYxTrVZyBtSIBJlss2zNFwujg0inUEZEWWwhjUaslOWW58j4LiBmjw== 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=oKllfkqrbcJlJzWlMdm1iJKX8DOQSDXWjvJzsShFQ3c=; b=vsZqEJoYnnadRZpKo87S5gWTbwmot/m6J+GNYYswrILRxFIRuHOgoxsnNeqAU0IUkQmREw31vFGvpMD8b/JZctV4VDptG+2/OOnq5FSG5UZjfhTMMmIf1WBbgafQ5kTu8zIy5kFCdKwYz629dORL0qIVO71HZV+0UR/DVUGMUFo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH7PR13MB5595.namprd13.prod.outlook.com (2603:10b6:510:139::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.8; Fri, 17 Dec 2021 14:23:01 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4801.014; Fri, 17 Dec 2021 14:23:01 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Alexandre Belloni , Andrew Lunn , Claudiu Manoil , Cong Wang , Florian Fainelli , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Leon Romanovsky , Michael Chan , Oz Shlomo , Petr Machata , Roi Dayan , Saeed Mahameed , Vivien Didelot , Vlad Buslov , Vladimir Oltean , Baowen Zheng , Louis Peens , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH v7 net-next 12/12] selftests: tc-testing: add action offload selftest for action and filter Date: Fri, 17 Dec 2021 15:21:50 +0100 Message-Id: <20211217142150.17838-13-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217142150.17838-1-simon.horman@corigine.com> References: <20211217142150.17838-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR07CA0079.eurprd07.prod.outlook.com (2603:10a6:207:6::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d9b6137a-0850-4241-e65a-08d9c168bb44 X-MS-TrafficTypeDiagnostic: PH7PR13MB5595:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H+jBzW4j6IQj+LXP2JhdlEuXvZ9f3dQ3JclKOW2+xsgRLI4pOcEG+4Z0maM4NPyVq5LQ/dzjlZEItitgv5LGPGPSwqAHxdOecAYdcTpAZPw7eJMCSyUdUVKchJ1A3ftQDaRQXBU4OZL+nihO02XlpYrVT7+F5OHzFIu8ruhbUYsziXfdLras2eBv3azz5EM162RcUtuPbZmCyGWWjTJRPKHMp3OrAiLiDlgdDFoOxI2iZB+Sj6vxnkJQxjClPgRoQyCdD0x+2eFx3baE1Ang2oKmhlLfUDIOIth9zt9+jwkszOX49aufYF+/sV+OSljXvrC78M94kNoUEPJauukje3ASOa3NYEneNTMkkYKp71oE2eBtxYMCR+4pUTJCwqmll/9ZTDdOwjkf7EewIfdx8+SlHwaEIVwIl4/oMPe+9H7aew+U0mDE+P4lu8vaa8nGfjGvDaSF5YsSw8LWgbAe9osXh2xv492ela9uRj88JFjHGB2M2oaVPv/JGolS+OeZ7V+kxbRFUPVjK9tknS3E56+mtpJKzv5WlLnqP8rrxnbxvh15B8tmAQvhXfMlzKTzuGR7sv9+/KhukjgjxOCe01dNzIVniIY08YS4NIo4r0LLXxtunnM/oG+8M4V1iukLL7gBY9d9UgAt+Ut9pGpiBgcf6rOTn4YJutNhvdyzzgbBJcsQ38SkexjdGzh6JPap 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:(13230001)(396003)(366004)(39840400004)(346002)(376002)(136003)(110136005)(8936002)(54906003)(8676002)(316002)(66946007)(66476007)(7416002)(2906002)(66556008)(4326008)(86362001)(38100700002)(107886003)(83380400001)(508600001)(1076003)(6486002)(36756003)(6506007)(2616005)(6666004)(52116002)(5660300002)(44832011)(186003)(6512007)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KBF10lni7pnu9U/u8bfv7XJ4BnP5YOeeU1Qy79F42h3HM/FVT3zS7ikFp2N7I5gHFf3Z/lrZ8mC3agF6hPLm9US8q7ZbSNSjD2KGaLS/sp06qZiTlYKLel/lFc3eWOWcEWOXwCj/R2YEJy99nCnzhHuXZ38nhtJ6Zv/NeGCBNe5AJELke+Cfq+kxCY4OTk1d9r/oLSj+Qy3umnbpVfv9EgF4+2UMXFqeCK2nwONFEGfwRTsJQ4GggbxA1GgSqFsp+7paqVHQ59gMDIE2+kDp0rs4wdCyjC4QoXuUrfnMPexlfZzrwc2NBWww6kt4Y6IqVaqAu4eNLI1tg9K1ygSLpoD6vL+Vl3XEmCcEnDfkofMHQ6zauqPNmpx/xgz1dsPtfiT83zbOzA1Ev69tzG0trc0X6LHIvNWyr6A8cpmtjqlqun9EuniXr2z9p1hBuo8wh8fBA1weGCMzlas0noG3LENyrzd68DCG4XecMeijEEmwwhwykodlrSqhKR+R21eoyaQHgV4Cw4J4gknCmsOPf5WvPVC3VpEyCiFmBOt/s0/SWu8yrhkN0chI7HGbeC47I2BY1qg+n+ecZlDPE/TGsYC1qA/hED6qzeO2qyocQFEA4iyW30AjZtlR7yTXctS+h2/wvNkrnu8qFm9nAAWRbFZGru4KZajVb2Qsfk3DZek6D8tSIACc3Hn8LyhEL52cXVS6xCK56rteokmJcmLDCJOP9v9OyuLdll2+SFVufCn2D6BzP8QP12W4QZuOiwUDelS+fyrLZMoE0PqElttljF/l5VJW3zB7O4EroFAlv+8f+vnjxEBa7gYPEhZjgrIix/Nq+KuIwMJ4iWLbC9l+s7G0kSO7YD+Fm5k/Wng4BaTgV7X8QaNZNkHDq5XOdbtPSpoo7im6BtqjhAhAp6Zrji6v91o/vtFQu+WwQwOkNa6zUlaXnGPUCZ7t7fS6YxoTmlayNluDCqyO6tELMPcxEBQY5crL2RcNNwQUHunMQFIogdFf9gq2W5cUWK+gzNZLQJKmlWs8HAETgCXnWXPZkxj5opFbnCcKxHuHOWPIexD9vT0R4uQRyNJZXNAMPI1CAzH664SoBiw+ny5HUoh3wyja8ZQfSClaT2fgDLJXKZ8NECzZQgDKzST/UZ9WUhOkfYWqIMaJoDMbhQEiymZKQ9OvSX3alvT2g9BJq1OHOcrERXfE4BXnAeL0unAU2NK6ge6ZqGW4yZZ0OwocR3IxE9t2VxDaGilqeOT4YjQ0ti9zXJn0SGPwW2DATk5/vKxm4ItLL96lqJ2Flg67/i+aBPmS3HXfy94SIy59L0gDGmvvZaqrnBXEN/weJBSOrDKDFlKDoMpHocUSNPD3H4bFon+wqdyJyDZV9Vbm40FyWNDjK7yZlkTp6k8Pvw1zGdtYwIJs3P62HYT8a+PoB41wDjytokMd+W8qgROgILDzVe8D/KJokqwPcZY3uL5b8AmNitGabze4KLO/Od7Jf1qO5AAVXhFttwlnjf6M6oFfK3/ZdTWO9tzddPwuVDvDBqXcmR6VYeMw4ctcr1pcN1x8RtpdzMawdk2bd+I/urS9pBG2RiXznnru7DhfFCFZLQokvEdYRM6ov6O2Tzr9pntfGeQC6eu/mSD8MVd2rbBP5ZZ8NhA+mTp2wDvxdrNtLS0atd7fwOJZ+l48n6VPczuummQtQxTG4vsBpglgQW5YOlY5RyTDpTmjgz4mgh3IklKOIclnjbkT/50qmuPgpUtebA== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9b6137a-0850-4241-e65a-08d9c168bb44 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 14:23:01.4042 (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: 8OnXHmY8sEsiUAa4mpNmPTnpMPWoTXSMqPqKMjP43sILwejQcsAbBD+/jSimNUWJ2ZsVnvkaUYiqvWAPJISKI4tNJrqBxUENi5vy1hRFEpE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5595 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add selftest cases in action police with skip_hw. Add selftest case to validate flags of filter and action. These tests depend on corresponding iproute2 command support. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman --- .../tc-testing/tc-tests/actions/police.json | 24 +++++++ .../tc-testing/tc-tests/filters/matchall.json | 72 +++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json index 8e45792703ed..b7205a069534 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json @@ -812,5 +812,29 @@ "teardown": [ "$TC actions flush action police" ] + }, + { + "id": "7d64", + "name": "Add police action with skip_hw option", + "category": [ + "actions", + "police" + ], + "setup": [ + [ + "$TC actions flush action police", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC actions add action police rate 1kbit burst 10k index 100 skip_hw", + "expExitCode": "0", + "verifyCmd": "$TC actions ls action police | grep skip_hw", + "matchPattern": "skip_hw", + "matchCount": "1", + "teardown": [ + "$TC actions flush action police" + ] } ] diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json b/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json index 51799874a972..2df68017dfb8 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json +++ b/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json @@ -387,5 +387,77 @@ "$TC qdisc del dev $DUMMY ingress", "$IP link del dev $DUMMY type dummy" ] + }, + { + "id": "3329", + "name": "Validate flags of the matchall filter with skip_sw and police action with skip_hw", + "category": [ + "filter", + "matchall" + ], + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true", + "$TC qdisc add dev $DUMMY ingress", + "$TC actions flush action police", + "$TC actions add action police rate 1mbit burst 100k index 199 skip_hw" + ], + "cmdUnderTest": "$TC filter add dev $DUMMY parent ffff: handle 0x1 prio 1 protocol ipv4 matchall skip_sw action police index 199", + "expExitCode": "2", + "verifyCmd": "$TC filter get dev $DUMMY parent ffff: handle 1 prio 1 protocol ipv4 matchall", + "matchPattern": "^filter parent ffff: protocol ip pref 1 matchall.*handle 0x1.*", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY ingress", + "$IP link del dev $DUMMY type dummy", + "$TC actions del action police index 199" + ] + }, + { + "id": "0eeb", + "name": "Validate flags of the matchall filter with skip_hw and police action", + "category": [ + "filter", + "matchall" + ], + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true", + "$TC qdisc add dev $DUMMY ingress", + "$TC actions flush action police", + "$TC actions add action police rate 1mbit burst 100k index 199" + ], + "cmdUnderTest": "$TC filter add dev $DUMMY parent ffff: handle 0x1 prio 1 protocol ipv4 matchall skip_hw action police index 199", + "expExitCode": "2", + "verifyCmd": "$TC filter get dev $DUMMY parent ffff: handle 1 prio 1 protocol ipv4 matchall", + "matchPattern": "^filter parent ffff: protocol ip pref 1 matchall.*handle 0x1.*", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY ingress", + "$IP link del dev $DUMMY type dummy", + "$TC actions del action police index 199" + ] + }, + { + "id": "eee4", + "name": "Validate flags of the matchall filter with skip_sw and police action", + "category": [ + "filter", + "matchall" + ], + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true", + "$TC qdisc add dev $DUMMY ingress", + "$TC actions flush action police", + "$TC actions add action police rate 1mbit burst 100k index 199" + ], + "cmdUnderTest": "$TC filter add dev $DUMMY parent ffff: handle 0x1 prio 1 protocol ipv4 matchall skip_sw action police index 199", + "expExitCode": "2", + "verifyCmd": "$TC filter get dev $DUMMY parent ffff: handle 1 prio 1 protocol ipv4 matchall", + "matchPattern": "^filter parent ffff: protocol ip pref 1 matchall.*handle 0x1.*", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY ingress", + "$IP link del dev $DUMMY type dummy", + "$TC actions del action police index 199" + ] } ]