From patchwork Fri Dec 17 18:16:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685411 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 F15EDC433FE for ; Fri, 17 Dec 2021 18:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240175AbhLQSRO (ORCPT ); Fri, 17 Dec 2021 13:17:14 -0500 Received: from mail-bn8nam12lp2176.outbound.protection.outlook.com ([104.47.55.176]:6605 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229502AbhLQSRN (ORCPT ); Fri, 17 Dec 2021 13:17:13 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OfO7dwCcB9xkUhH4EGA44I9YpXV0ruptOfFoo2A+oFfcwArLqdppc7spb643nDiYzie1ZvDZYTkScLJ1v/roPwX6TQ2yL4fEkBEQA4iys/aNDrOTdpt4hALhnflgTNUFQy1nhyoaBIXYoJgx+OzyAonDk+6L6APg3S3C/7QsUvN3IlbyTm8mCxIUVK+RSRh61dIFuNDN6BPLrWJqAlnqnUpSx4DUzC13C7v38AQ2u5HOlFcwEi3mxacYawreeVM9/kWgO3ydHQdDUu+oTqulHO03HaRb86X5e8eC6ruhlhZjbuYzAplSCbEtnPgcPnqKbVhVYI/aa2XLIS27lTkvcQ== 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=rn5O01i419HJh9Y89KjhphnbQg7uoh4w1glS4FjXJrs=; b=A8PJKups1EZumKyOZzT31H16lsZiVuLsxkJ2gYsUPY+yJBvG/Ls7+aWLws8gQeM7T8/njAos5WmHkuuXXX8qsf76SEL/2JKG9gSG/NToX8zpyDmYIlJT0EwaY9UFTYVbegQstj0WRQGlKFOwOiWP+qUFz2gh5bEXn7sW1sPBkIsv/mxuAVAeXjiOaef8pW2GpqkFqU40JjG8xKJM9GVt1DIrvBlIb+yDAhfInu77wcALKp3QH/0I9dHUZFNkSQHdTtm4rFASgGN4EjJH3bifPBs9iufgnQBpHsJ2sqxtGtwrd+xpG92JM9kiZlfkkH7+43NrSAbtn8aFvaX+v1zHAA== 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=rn5O01i419HJh9Y89KjhphnbQg7uoh4w1glS4FjXJrs=; b=bZiaNbSD3SxGdoBDBQj6unVtsnPQAvsczt47noyJ4pzSkkTOWMpRz3wM2XX4WiHCrexxx008cDfLE4POWLXMYLANBosijtoGRw6hHiUxyUJ5KwWVo/XRCeHJNxxRc72zAbbf1Mqp8xmD9dThUfcB0OgsJBEukgd6+83LSg2UyCU= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.12; Fri, 17 Dec 2021 18:17:11 +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 18:17:11 +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 v8 net-next 01/13] flow_offload: fill flags to action structure Date: Fri, 17 Dec 2021 19:16:17 +0100 Message-Id: <20211217181629.28081-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 4db9bb3b-19be-456f-5c15-08d9c18971d1 X-MS-TrafficTypeDiagnostic: PH0PR13MB5004: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: 34KUeSZ9GVa/VPMyg44bihwHp2zNRq5AmxGDRMNO87Q1+y3n+uCgK1sIOEKPL8YyDjdLUIJQMKJYnuX1RlydXjuujzKN1FzcS8WVRVS2qBkzB9rSTy6lx399f4M5I4u/npvN3THeXwhbchgeyZ6nq24p2+7J0jVhzvo4SA8pX100od2ZxsdkLjJdRJqhAj53r38YpoeRxVhoQe0AvQWrijCUykPiRStjLYtIqEpfDKoftoJronIR2uUmfSnT6DIkmLEI3gbKwZBRV6JYhMBOeeKaiHS5oLfeKnifjOHwIyMb2pFpaDKh5pzuEWqm+a7xaQ2P/aviPi1ERfNPU5VfmvvXyEEUn67px//aksyFFeVwMBFvvklbH8X4qSO4ArvWBkziVOrWBLh/WkbqPImXtrFSId8Tr0biG7frYUja6qWOw3YBP5R6Ccku3Ma+ERmOUcx6f5aRJ9H7cvmIE+Ll1t2y/+ZiwU7eKOrJgbhRTNozqvLYwDnbblg7jRTCSgzi9Xki465b5fDZvcUUK0de0aFCOu2HfFGrYtQzfvT4IiUjavFDWgYmMIEsVh7uMAKHcVCq0IxR4aixF216fN75gEJCAyQLud69QqsNmFqVKMff7UpQKbvR4R98Z7qBN+noyE2OHLF6ctSj9nsPvV8v8aqb4OL5xOBfhjbDfISlkvHHFATGo4O+WRwWnrp8tuTp 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)(136003)(396003)(346002)(39830400003)(376002)(366004)(508600001)(36756003)(6486002)(7416002)(5660300002)(186003)(6506007)(38100700002)(2906002)(44832011)(52116002)(6512007)(66476007)(83380400001)(8676002)(54906003)(110136005)(86362001)(107886003)(66556008)(1076003)(2616005)(4326008)(316002)(66946007)(8936002)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WLsNm6jpoE47K0Xe/POCQqQbKTS/Ohx2BzNxpqYu9mNyH2x2ALNd4ZHI5NEohCG9I59w40c5YIiVRlbXKkEdko6Cd/SeXKfspQu0H8moIDJAHMBGP34YtsmfuNIE7uMXvzsb2JXRhVQiXtW7vfGbW+BTK/kr3jz262x1GHApWNLfJrSSk8wAMSlfrOhF2CQHd2/Ne2zyn6fAEUSYK60d24ATSglycD6/bY+f6tHGWgYqKtwxy1FtN1Xc6sXyNsDLbSgUpfjO5Ol1kFgJ55GR410VSFXm+b1RaE4w5EnbX0Q4ZwK1P/R8y8mKQvLuI7ijB4C5T4c5KW/t0Jb53PwGi5bBU7DbJ7CorOac7wML7kAZXODSh6g4w2SWG7bT2jVOzalEgKiJIsjOUF87zJ5noGHuzglsD3m813RNaR4pLBgrMYGX7YcttvEkfatKCOlzSQ9cW7d+rtAOrKmRe0/oIzmYIp6HcW4jrUG/vPCRoYsPUcfRnR2cUN3gvwUG2Fby9UIaLTT7ylXlg0eMKjBB6bEWweZ2SPr/Ol68nWyIIXt6iBhnafUjSC+69f18HN+lOscG958VrcWTlWFIZSzdrmkvO8OmD7gDyL3ujhgYJvnJrfMeOAz8gMDjHb7aGUG+ERrxSERtQ0NYbmPyQ/xQDnIjV1usb3yye+uUeSEORCqgMULB9L7RGMHLvc6TWXQmjU6Rkv47tg4qs96LDCbNKkcIAmFrmUSvD+afJrN7zDIcqT33a3RiqecHL2VDN3LIH8LAnV0wY6d+ZC5A7HgYQrTjeYRvHGt6A4hbS5pmmKCx5w/ESTPyZsueq2pTptHYxCoJlSLUrmD/IaWb66xEY6qq9mAKQsDu1mJFUFZOW51eLul5yfVF9PlpVmV2TOxsPGBK1oXQLdz0Ek3NOdBGtu3nV8eMyQRWdDNx/Svp9vyaXyXfvxbvt5iaw+IaIEVBJkl9cbSEYAhWp67llNyO0GRnlQ/g4BoxKR33hBNSPv9Khbiii/lBONHKF6nxau0ySumRklPgnejQ/eWvJ9m0jcEp6L5FTqqa1VDtX57xNr0le5MC0iPkcDWSeKSKIu5+Q1dvnciiHMi2m7leq3+LxffGbxesmHZj35POKSuv6bnD7aMjv4u0McUvAp7itjugW4ljR7dsh8JLgT9Hd0gc+Qj1ugwI+iaF9iyc+4dNhOTO38JjEw3vinsNJudTeHSONGQfIv13dFjZX/DndO++IEKd8M8U5K99OnGYz7crzuFD4ZWRjS6PWs1DPaIOncEzRt2pZ3vysfc5n30mh+2PDZ8XNAeTOm+0dT0k8uApVD+mUTk3xVYmbW72Qf5KEdILbkGegKuMTHBUuzZUOE2fnTT5+p/nz0mMwMckeoct1WXthwxjEvE3Hlgk3Yt/mrM9eWJQZ1KM9x9z9eX5GGZHmwFKYaRRnKFdPWWcg9qtYkD2Ta6S7AT1ILz0vRjBEmtd5h/2nhxSrI0JDdx4i+RFvWmRwzazGVI1ohlUZJLPS4mxwhn7C0RT1cR03VNd2H0p33ZvZTHYHa1NqZUaa6Z8ixSbPkOAqfGGLgeU5ZYcw/arK0VPFSwwW+83TB+/0AzG6kzHepLeSuxOP+BgPXzpGsqm59/cDRgcO00no++SxF0R9L2ildxM9TKtpySTNnnmptgqNvKYab68cKnypLUPSYFaVTZKQMsuBZGzwQGZojUHy/hSbBUKv3bXmsAtlMeg6RaJiIWmNTehgcGcpXqbObPiNK+OfG6vE8hPvvpTmFo= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4db9bb3b-19be-456f-5c15-08d9c18971d1 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:11.5594 (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: Q1TKGA1+N6/dMnLXhtXTSzNcTblP0O/Q3AB3stR/+OklQX7onOJD8hgRFylFei06Oe8RWsU4Ta/pZUGwa+9ztId80Ryt1WG7ddO8wBwuevk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 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..f6df717b9f17 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, act_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 18:16:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685413 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 46136C433F5 for ; Fri, 17 Dec 2021 18:17:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240184AbhLQSRV (ORCPT ); Fri, 17 Dec 2021 13:17:21 -0500 Received: from mail-mw2nam10lp2109.outbound.protection.outlook.com ([104.47.55.109]:6446 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229502AbhLQSRT (ORCPT ); Fri, 17 Dec 2021 13:17:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G4h8yAaJfDBYhJ/WsPE3UoWpSY9ALeG0+r1GSF0K1r13gomq4vUkrAwLtIHh7fr5BRu2eZPMCFppWszv4V9nIQfEbsz751qQK+1rbGSujj3NjPXVC6yc2HM1Mpg0f3vvT7z/pyhWH77ofdjKLjnSPhw0GSKiHx7JtOF+V4j24PWbzuk5mJZB//BMs6nhKAmzJivgXsbHYWaDJ2R4q3wW8gayElDvujLICJVqWEXW3oT55pxrxBs25kIQ2uiUAZmAJCmLIMmLOLXKWEvHWZjrZ8pQ8gZFmHGW2r+VxKCB/F/61yAF7M8VtAc3qBD/UXss7a3Qggt6RFoLrAGvwN59OA== 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=W7qwANJ1FYLZZ0h/39bUsemjHkBmg0KyF88IisGdlK+sXsCtqPPM88RfDhlhJ72cmVpDBUEoiVTE1Sl0zXS1+AutC1RH0K4qqp8/o1P+9tz0g4gyqvjPkECkWCtmti8lD0Hce6Au4oWFzvJMds9udkgqOmoH7+KGt4uhd1vaTeczIfoKzs06VnQzc8nZX3LRMNNXgTf3cgkXo4zhDdhkhmOuIlJxvNcCI8JEpCb7gkJb0D81MUtVkAj8/rRRFpxaPTWQ1sHxfDLzaAMLc62QBFkX7gYy5M4NJq1RSIW4Vag3iPJvKpixhkN6K4hF+QJywce/DNV+0m704b5K8ylJyw== 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=k/i0GanZEZ5HEEPV0fjJ/MkK0cVCnxpb38fKoftWuAwAnNDDGIJvdtdESbWLZGq7Q6dFLaeP9FRCxceSv743Wt85C/cP/ERznMq7DdWeEbPE55YbZw75yf/ta7fvPG3HoI/n+JnFvhZP1WeNTaaD9RvBiN1XmF+vnDl0uAtQkY8= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.12; Fri, 17 Dec 2021 18:17: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 18:17: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 v8 net-next 02/13] flow_offload: reject to offload tc actions in offload drivers Date: Fri, 17 Dec 2021 19:16:18 +0100 Message-Id: <20211217181629.28081-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 35b7d463-b0fe-4282-6f7f-08d9c189748b X-MS-TrafficTypeDiagnostic: PH0PR13MB5004: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: R706omUMCWnkWpOkZd9EljwXwbN1enVc1AP9wkVojKLS4XXtey5rcCyVkPSy0cV4c1wIMByyPlMigA8T5qNT8p/MBOadAajmSq6v4ZzwSBgoNsvyhmME3pB3sDvwhzn6jVrrgczQp+//UsBRuwVRIk3sp/JW6ca5f93o3eKcrdAdRrsiUcyAXyochmdoKoR5w0Ja/gPKsci8AAzu2arPZ85uea6OySUntrfdiPh39p7VsJgNmeShmjOrhOugPrSFFlNevR9hRic/YQMbj0Y+Cak/t59TZWyuBIT+12+Jzk+u1CxP1AU/A2T/m56SbT1giHRx+XBy3EN85WtCIQNCajksZT6sEH54TNGxP0/YtMcsi9/1GH6HLty4ysmTRVU46yXTYJyIwXOUhYT0L41wOmXbBQ/T/dvjSodhVShdrF9ysgodVtZwsboz8mUmqKnOFRAKNleIg6Y0gcJvtURWDpfkogWjwLSF4NDCW/WHVrHSzYoalsqxKyWOQmbP146bRvD0PgNO0/KUdQWMWTTiO8SZonoBXFFCKHYE1TrxEkBHccSxooBlfZ/dC7PH8CGv6QulyGDcIkHGXBmGjGJTUu697ctXJV/pAqHYTqZOd+aaQfL1uBv7vYpmvShp2khdAyTXdz8GVhakzM/Bk1XIcVI8E/pgDvwBBzHAlQW5J4aAtwfYpTihpvuqCUbtCWTdmfI/qgdj+cdkNTZyv80L2Q== 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)(136003)(396003)(346002)(39830400003)(376002)(366004)(508600001)(36756003)(6486002)(7416002)(5660300002)(186003)(6506007)(38100700002)(2906002)(44832011)(52116002)(6512007)(66476007)(83380400001)(8676002)(54906003)(110136005)(86362001)(107886003)(66556008)(1076003)(2616005)(4326008)(316002)(66946007)(8936002)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QHvc1v8WU43aVf5i3Vh2erUS2RjYwTjM1mXh5aJDfLaplRmGVgoeZALvc0nvdkM3xsbufszxWwUlmOpV4jcNECtEBl4XhhnRdYh83YYi6bGflb/pEftPuadbgFpS9tP3PlyGY6WQDLyYlNzFfAkY3M5Bj4OZ1rwF/Uv+4knaDe1qtW3UbFY9zW7trLe/x9Nm3z2C3Cbsk487aiNsBupUkkm9yzFECztKrJWpwG4fagcHM+8AVn24qvTkgFuapZVBQfROq/2KIOmWdfhajHzv3jHLqLUsVuNmVdbJji2V7C5SW6+Hf463X4rJFJ9Lz6A/Fdqn/kpaKVJdZEo3bAVY3SzVHHbecVrqe/OgB7hyHduXKdjt9CKJt1P0Dr6YuldURIlh+3uP2/Arbxh8YSd5t0efc7Hp6huPqKhFxSXJKABGeAPVLXEV7vXhvwcAEr4RcF5PNk4pa1YX5DZZ3aT/G5NG0fNe6l32eiRNbTktqqr49s2rx2YZqHofIPnI+IWjGEdbWaGpj1i+ZI5Gd1NiF6RDFES+RvPWYqBq1sC5ilqus8a9NQtFB4PIQ5UsW35KMunIr4X9RUFOkdEbzy9u/bGbUFDmFJUOIWafN2wYkyl/HJQ1eIjqrHbBCbHIZr49FG7bp4E50Ih8D3Il6Bwoxwh5zILPNXC1unpzFpt5MhKdMTL0erPg0BAYaiQakz2CQyExs1fKXhL+qYEbJzT/1A4XFwpcOS3/0fY4Kqs5r2UmnOAUl3kplXaTHpB36+mux+jlKT6Yn2gYkG5fdKU7M62jNpwkgzg5/gGvFii2qwlzMw3PchMgSRXCB1xBcEfo4RIwW+v0TQxUuZAg/cecrnERNHcPIWoWg+VW20O5NT2WeSnbMGbO6xK6bmchWto9xCaQ77dgLiniWgJc9is5Cx23msdT6FJVZXzUYE/Kq1MmyC8yF/xm4+wAPXibt7QlJKX97XqLdRfDq0MmqQJRKj+VffBkbYiJO8aNZbPmghvezmoYTAr3bYciP3p8Zs+XxpzcFgB4SycnZICbfnPPMYZv3vO4umWfpOYqgsYDD6rLqBQBN9cXVGKQwheI926F+sfwP2Q1IxR+p3bh9iUQ97zarsXH6Fc6FAPPvHMrVBspCLM0bwI/H7qv20EWorhsdfMMjmLmTQcUVu/FY/bauyA9zLr4ktvFER8QBqigHQDg6dQpWeIQiXUaTpuOdjNKGA36C+1GbnXDvhUefpae/x5ZnpLL2DMNHRoxRCxcEpGthooo1BVnUPM9Hr6QsZJCYNSd4cmP0BoZjF5CVQMfqwM1Lip5uIXU2MISsxjBfMMzcQMh1RU+Ehy5zKE59PeFSM7RlwOYL/YGBuBO+XvZJTSnbmB6mS49rtEXesyNk/OnnOykziJlcoW8v2UwSY6RlAtmOkCDyw+5vuLwy8W4wTiiuVMqHmFIZwgtuUkAGqivjeMC87bJSKHptHW3NsYj5eMy3ZYR4A9tKVAqLx7QP6NEzHts8QMJI9dNsi70U27H7Gq70O2cKOyikV5n6o2IEvYPmECWzRBnH96A9c1Hban3r723E49R3PoyM+PGCXxWTIk0qNE8RdGm5+25S/qOuHIUF7yga+TCAMcT1Au+EyeXvSnefN8XFkh1E0c94/CZnfi6z63p/mVaiR5Pu4mhVIBphdEJ6RVBF92ZEh9tQqwEDBXpn5QH0Fulp47Hrsh6E4vOmdD2m1k/0S8nk9FcsTG6cWgKA0ONVVAxK5Oly6MmyUolxdaPOnKyYVyUoQE= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35b7d463-b0fe-4282-6f7f-08d9c189748b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:16.1652 (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: HATiuVADgdf+dXfo+Wdiaai53GFG64VHeGBKT1JA4pXZ5xvAuDydmYt4p9DPnI92Sh8VZyJgb7kqT56HMI0sLB8/obKXDtxan3pdWYEsHXw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 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 18:16:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685415 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 C050AC433F5 for ; Fri, 17 Dec 2021 18:17:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240233AbhLQSRZ (ORCPT ); Fri, 17 Dec 2021 13:17:25 -0500 Received: from mail-mw2nam10lp2103.outbound.protection.outlook.com ([104.47.55.103]:7308 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240199AbhLQSRW (ORCPT ); Fri, 17 Dec 2021 13:17:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eOmLnGXv52QsDzMxvLBq+Vz+f+mQKX5Y/YUkyz/yMNt0WOnPkhUMG6QJSQF4O17hOetvsKn/PUCcXXr0iUoPK7Jhr5yZoNXo7UXjOjI6N2bapyuh69oOMtrTCAkF0e1tFVtvqrJjGHXjuBkypaR7ByzhkbnKsAJX0fwi4YRlzo7+OAGmnXYPbM8ewl5mR7WykDhc90AAa2ln5lc22iYDB2RtmmE8ghQSF0sHxly+4rPg7nXEtioWa0uDEELzRHPtiSaMc/MtPVblRr+NSopLAYhj9q5HKTcvIF8AfERdTHe1ZU2tYkD6wDn8XXI85v/qNYai/vPkp58ESAWuXPUYpQ== 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=hcv7jAmJ6flbAX8EY7k5RRQQRm2VwE8h8OsBEWCrKF83y8ZuTJD0qUw9cOS4r9n5blQgsYq0tib7oX/okk+D/k6OTgm7vIN/oS3sAg/Yj63wlVwP+0dzde6eNWRyCCD7wYAhrd6wuG/62SZ0w6WtVSbwLdWcsu66pIzbz007IKmc5HfjbiNgk/icP+j8ykc/KEPvh2AdwvHThpHfv1cPjmZbsbKSz1EILj71YZD3b9EzJByhgo2B7RNTlQD1saRO0FcRYZPKPX5EVe1QL39Lx6/GM9srxR/wRNusdgFJPGQsJbd4QHjmpqWvyzSx+7SqgGoN0qFXYwsHcxwZnvIFEA== 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=dlUJ7OICMWTEQj/BbVwB0aDZQesRcsAY6Ibav9I5DvUNoy11mXFUHPxHX1+VIqoiO921fgw1ELtGuM/qEvIpHYRgpO0AzoOT+skeojdX74NRxj64WBfMislUjkrcBoXUEyN+g7ISVgdBvT/Ku87Vrb3bhewIjG6Oi6eDzugQhdU= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.12; Fri, 17 Dec 2021 18:17: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 18:17: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 v8 net-next 03/13] flow_offload: add index to flow_action_entry structure Date: Fri, 17 Dec 2021 19:16:19 +0100 Message-Id: <20211217181629.28081-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 3e19d4ea-ce07-4321-01e8-08d9c1897755 X-MS-TrafficTypeDiagnostic: PH0PR13MB5004: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: VnzwXAu6R58pPMYWw7eVK/3L1D/GEbpUTWOXX4Lt2yB2tSUOGkoWH92qeqIIZz2Vv+ERXuDJ4nnYV8FC5LP52DCyOabYFP6Co2brmvJA0FVzZ7NC1lXS+n4hULZDmAbKbHuK7ld/ECCzjsJ69BJBNcwQ5700Rp4nIHXGKZZq4lL+Ee4+ibdRbcoD/NVfGRF/V/1qKLd2xftFvOiKRitGGXAgtnbsSJJSd9Z7AQa84kOmXKO4GT1TdimmQpFK8dNzrKjeDaQqikfTa325eP5Lu6QQ+u4kfSI+POnHotauVIXDKwxls5I1QH4lZz0RKVONiYEHd1vWIa12Gp9WB179tQ8Iy2d9c/2sxk6f+Rq9TmgD9EDsMVb013rpDD4jbjIFuDXFsxvUenzmhybNREJ8A7P9poFPpiJ4jaI8+1w5kMar2HG7t88ipu2vAijyv4RH6MX75+tKyuTML/kkBF7PgpfpC3yOMLICJKVev1X3B3kcAcq0iouLx/e5JfKDMgsPACF7Daf3k7TDrDnBrkVxkHnAgPqHh4V8GyaOzaNklfJ0LPjJtlD2T21WCV4GXqvbYsG9+kdHctQBGvKZLaY7RNK4NI/B3QIprl2iwZGGYe1vbNdqVNjBqyaRLrbR5RxcxghPz8KArZ6pxr8FRW8e2J5G7GuhrAHqdn99MVRvhXs5A4pOq58HxdNy885POVFof3qrUROK9vc609Hun8JdQQ== 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)(136003)(396003)(346002)(39830400003)(376002)(366004)(508600001)(36756003)(6486002)(7416002)(5660300002)(186003)(6506007)(38100700002)(2906002)(44832011)(52116002)(6512007)(66476007)(83380400001)(8676002)(54906003)(110136005)(86362001)(107886003)(66556008)(1076003)(2616005)(4326008)(316002)(66946007)(8936002)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3+MoIfFeA40huXpq9SRteIr1b/yJ3ezrAwzQCm/KFvsexUZcl7XloStw8Hixm6RDEbbqpp7abB7Prsq/anzfawjXRaKUGKgO0AUiQpDuJiE605KeftVAC3N7U/SVOXgmHxp0eRFinoAMpdr0BAhFwpLLVZeOp8eMhCNrrMHSZSjCmmCvsJs4m/KeDuhruvDQkvo1ZH0HEcKgpasBrNu/saMoAHZHqkubCdBPd+iE2uMVNozjbk3FyWCpf6v4RmjxhaThKwNDLZFeqq1lwJiUgthwjHAU4GkrWyTkzGLMGevzdN77GeymDRhZ0yUUS1Fe4cpziN3qC2gyrYm2xEzoTx1vSdkKPvBxBYia8um67SZG9FryxWrc5qWeNP19If04oqwo66nrWYvbGruo8zLMJbufF+sipPvNuIrM3spRVb1FvUDBK1TQI/d9qecdQU7LINL+a+O98VpQzLSy7+FAuEscFGypKiJ4g351XSPVWfOwBhp1zB2GBDuckGbl8ysrAWUo64uiEXzxN0dvlItcP+OdwNWrxAvXzRxrnSfzuD1e+ZrRJK8sLbh36Py1GTJu/eoXVnFwSrN2O/biMRhy1hRFNWgpI9Ff8KXQ4J14L7bFGfhrHBy/Npq5gx5i522a/9F3EXhV9kxM6VU8xMhesyFA7zP1W07fQ2CnFhj2gFBGAlmfkfZF5xRukYFy+vIKUaU70by9QQncbXEsz3Y4xqViEgtOoORk+m9kJ1HRHIx8etC22cSLcvuoVJ4FpOpVy6HpZpTqyfdk6stoSMVHqxugSF0xqU1sRwBfFaCapfXthy/U2pN54IcXVgN+BFv+eNjDkuKVhxu5AaI3RB8G+tMXV6DIn8ITfBrx4wPsfY32U1S94dW+5c76XN3kNk9K4T7ilJ9gTIo3Ue6fxwNAzcUPaUovYBHHUPjg2F19xCl24WijJ5SJo3TSQjW18kmVnOfsiIiIXbp3fwPeSJHb6z1ZpO4BVecy+r5EUzFm2LwdXay6IZKKkVcyPaaGTHcqPwmsSeyJkjxBPfyN8MuBH1ES5Ajl5DrjyuCYCyRluEGlDVsJXUqoAo+xMT3cD580kC+HsJN+mDuX3n6gCSV+2gJPSJjElLGvgAYFVv4vggFZNKSnH7GM1kiB/88EP1boOsFeMYskhLn6Xrw3YzISCZDx+ePHYt/0abkoPVMl0BEowYyiNu/w9ULrIaz9MMZPaJLv/GbguU59+QIBawffUEm3zwoqqcmX9LBPbGA7FrjkQtIepXytuMgnoOTn7W0o5ZZ2uI5el4LYAbKPMdRBhtk9PpKVV8C29RmoSZivtVnWoz+uoAqIiDwRAOukN/S/hDK/rLFQWNfFM+2uy9TBCw0qd8iQ/UY4X4sjZefjWlmemK4NbDV992fneYz/5Nhrw4/TZQ2xV2y9yUbmOXmvW255nBnEWADSB8e0CW8sV/5InCCzLsbM0asKw70Ll72wgmzkME3fb+18rWNRUUxwKYpT/u8jXdVDLNoNvkwEXM7kN+P8us3no5riEbOqeL3QnfvkykhxlG+/pDWQ8jHK9fUe5kTTbGyYblkNJyq0jnW5QuK6W6ZYoVWZ+SXwE5+ioLwpIhQu7ebeNUolAcJisOgyGpQCWC299Kt0e66l+WPQiUMaqbOrfjcjyYIcDdKQDXHpaGmT7OS4aUSePW/NL44FSneuK/G6nlU/hH3ZOyPcFZkHjoYHEjzYTcEbr5cDYMsYaoCh5INbfzcer7O4LosOySHfzB4g1lOeQAiSP5A= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e19d4ea-ce07-4321-01e8-08d9c1897755 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:20.9691 (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: ELgh1b65rOlZ+hts/8b3LafDlyaWlkei0b5NipLlvzwETCqUB8H2JVTtodmm6JZkW5jlQPem+ERiQ7lt9bp5FIcjBXkBu7m7ACG7JMSKIzY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 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 18:16:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685417 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 8B26EC433EF for ; Fri, 17 Dec 2021 18:17:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240224AbhLQSRa (ORCPT ); Fri, 17 Dec 2021 13:17:30 -0500 Received: from mail-mw2nam10lp2102.outbound.protection.outlook.com ([104.47.55.102]:6598 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240214AbhLQSR3 (ORCPT ); Fri, 17 Dec 2021 13:17:29 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bAigDkcgBiRY/CK6JNFa3QBppkYSG7i2jbeeiRKaENNhra29/VlYLoW42+pDCwR/A5RW5hYiWxdulUaN5P3KgeRuKyMz1k03t92GkHe3Hi2J3wjn4QMZrc8TYLcFZzlyWOS4r4MjwbNPFLMakIcULW7xB72asBVUbkpqtjzckrzPx8efKPn7u2kSdlaLA2/vw3A2HmvlXx78NnOm3XZvAQU//hCNW+Gs/I1g5JHyYo59Gip3yhYxp9OhuVKvi/Mt02PxBZCjGL14fQDMomKIAp46gbP9Wm5Zr2CCBaylmoyxUNe9cAojtN1H+KpE7RscDVFOSk547LABCyQrgmLjDw== 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=UUzsfNtzHlfoZPe/mpMg3n43kCGq1FlTjmJb7/mg1mBUstKRcC5rxcVswMHidLlqQmnCLGu6AW7MPHJvNN76OVJx26y7Me2bDhL0e0NBE7EvJ8Nq+HIylGBU45COEnQh13sZetcs97agOdyk9k39fXIwleYJH0J5xsNKD8n2Na0STooTdadYvMBkYhyCX5MedbB8fzoHRTM1PCgOKPVBfahJ64gk9dZMNl6TQeFEfFZoh/P8MrtilrLNBCOsgCwPyGupOK1Z5gRe70qRkcNM5L2PBawyXNj6OefTDXHtyH5VQyQOIilM580GtQAqnm/FFQEWpmqrm0VKaoLKc7O64A== 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=W0e9hL5bYnoVVYJCMNA9NGauVglDTH/Bo4oFaxtT5Mix77rnLA+KOLzc12FO+N8bMBJk/vMUTq0HN3Pj2y7QKNoAEwuUMJv57PwztwjwzA+SWTEk2ntBZXx08oY7EyeqX2USeKPxQtmVCp0Rk8W2vj3HtDZmsQ7c5fOMBihn8TM= 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 PH0PR13MB5589.namprd13.prod.outlook.com (2603:10b6:510:142::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.9; Fri, 17 Dec 2021 18:17: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 18:17: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 v8 net-next 04/13] flow_offload: rename offload functions with offload instead of flow Date: Fri, 17 Dec 2021 19:16:20 +0100 Message-Id: <20211217181629.28081-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 47af73db-31c9-45cf-0cc8-08d9c1897a30 X-MS-TrafficTypeDiagnostic: PH0PR13MB5589: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: +hOSClMVoZ8kyM71+GU48tgVKAARgrpIsK5wkW5tsqAPtqmiIoGUm4Ktmq5vlHjMfV8DhxDHGTt+I1veHq9ixsFh21JZXp37FV/aDf0RD4aLM2IMXM5/dFt1lNohSlAaqBPbhbTyVkd5ORwK9u5Xrluo2smpV8BokO96om02lEB13Jk4hK0aX03owyWviuzZ9G3aRcIEq32of20r4EcHXQk2yq/abdUk5c6680mVJBFU4NrHBPMFHMxFbGZlPHpm3LzJjqJyVu1+Su+wiaYARCoFPn56aVCmWIcMMO2ym77G+eqinMO2GvLFBCa/zvhhUVb6SsZV+0PEY3H2r+CXFHCT++QMdMo+XVQWy92D74WrZmH2MW/nXXpcqtz7udogYhB2N+pdI1gSdVQV4rE5gnVZ+YpbkGDKrtGdH6Vs24CVaJ703nb7KZXsxeGmJnFVZQexl8MIwQR1XxTLAQx0i2RLV8+Eopoe4aFth8FU/UkjVzJumC7u7QJoCvSc5LKmwmus2O7OdRDMY0jJC4MstUz3kkyMAeSVb1wsrpqoegg20SQAM1BYICV7Zp2vqzcy1DPYTM7p4bx2S71dK+9btJP+YQ3WUG5YOG2LyF0vp3FANliRJwzLpdTBrjUc7PD28t2P5s5g6NfZH75vchif5w== 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)(376002)(346002)(366004)(39840400004)(396003)(136003)(508600001)(107886003)(52116002)(6666004)(6512007)(86362001)(2616005)(6486002)(186003)(83380400001)(1076003)(8676002)(316002)(6506007)(2906002)(54906003)(66946007)(44832011)(110136005)(7416002)(4326008)(8936002)(66476007)(66556008)(5660300002)(36756003)(38100700002)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eM3cBmTuRfLy5tmh3koByvG1JLtz/G56RRYevZnuHDnySEqe/VqzqmQ/Z8nY6l+WwKGKJduyYJvOIx+1NHAf6VKzOnjZBlpXF3a1/6FdeXq8Bleh80wjdM2LsHGXKgjuHgldWjpn+/pw7m4XlkMslziOTL5RRAauRXIzHU4w363hYt8sxnn8ELqz1ppoPkYM32KVUUv7Q//xvyrKfL974lQ0+0bMnYCGt0VA1bRzLI9H8S8O8YT6QEUl2B3Z/ZuzuZ5oRP6yBU4CPrLZD1NwJsrD/pXsI9PZavixpuZ4AZOTYAfQowUA+8gG2L4030NkH7zk4RDEpN4NsmJVS25hiXkB0ysOijrAFv+wRukh0wo3bWU2Rx0VMhEcp2Ox9gJ0r+33uTIjJSJ9LGYaA8im19f2f7OtefLonEOZhrPugjBchdSkAjvJ+uUE+nTWf5I/SMDI+8QCk4m6D8u0Vhntb3iHkci4xdmsuE3pDJdTWwUpCRnNswSyFyGX2yGdtru+xeNho/u6/fgRimQkbeyOIpXYDkzBEdBEiguKvHhd6RyHPlbC7zcJb3h20UWUJLCuNfiBP8NbpotCya8qS09WumgQxBCTJvzC1LqUjLu+Kl1psiAB+/q8zAcU1kKFDADyB+nvQ4a9RiuJSQbLWLN+y4kKMgS2k1MSxq+CR+pRO0ixxRwl1bEzMgiX+P4pZDof4wC0PIIL1I1EgttWDSeC5lHmjCuNAYDdCyw6T3Ax3csmSUzZYJQYfwu03LxasPbx/mQOIiONASzqyUDVmAYXuVDzD6yEbUSt8vr2ZYlDeNZXIQ/qQ4iIM2tYEk/dIO5OGXeoEtWQ2N+e92ZwoJ4n2sKgvUCbA6rKiZqwsmhQzqV6TpmVjCKjnR+EVCtIKrBjSUwc+9ZxW2JYs9uPoi8Bc/MW023IuNIn2w1kRlh6HJ3R64fye4Q8SbCoEyU/OfbJJ14H/X2toFXLSvcvY9ulZsIaZOoWzIiLwGx1mmr1zXHBoGE4v2gpdk+ICBUNiWgVxbJ7lH28uSjVMkALntlvqJyrIcxU8b1fhlPmS4iIQCKyilTbcYWqf7zVEIPB/Aa3yuapNk5ZlNnBGvW+cx0OlVKDMzoGuKVU8WPBYjVFNH1cx49LyWaKkEgpPDEiN+SkHcgVF8nuHmr+PyFqwEhmRqdoV4stXFLGAyRowCKThD4Jrbhvg5h/rGlnClubE+D8L/wO2NjALbwTX1VxKWOqLSlCFxeWs8ro8Qh48rfbbub44NjChx6iOpl4I5yZeqyDrdto2H88oMBRgiz2Xenc9bZ5KCP09SZgj9WMjp+/b7q1rqsgdDcqA/63ApGks5F9s4qkQOZEFsL2yZzODVqcJbwZGpSsOf+MnPW/mqmnzJ7ar4IVTWu3VVrBZ28q7v4BrgpPkm1Ljkm+Bu8QBWlXO2BkxrVpoRdmjVjetiPn6QpaIIjx5H0uMi/iqQ4NP7rMp318OXjT6RtCQcya2Rg4UsWHK3lRLAUTvubX99RRZxVUPozB++dg2kHYIGTOGCYvoD6dGPOMWOM4E6rhE5LcjPqcfFc7LB9dkM/vIwYVaGZPxpfbuQfj6fGQBR72rhrXnfyND63u9aNd7qol7JhIezg5iaQDHVMMGPmvFjLFhBvr7Ma/RP+Qor/gTc1p9d89CywOO1P0+U1azThw2D36UylPnhN11+q33+bHxX6dU18uGDqDD+JFk5s6U4USeRbxc5h5rn7tc6FxpBYstDAdjA== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47af73db-31c9-45cf-0cc8-08d9c1897a30 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:25.7411 (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: nto/sEsGTXrAqgErNf/PfrpxiFZjYOwIzNt0Q7cTEw5qkd72v6piMnlffPvl4S92bLQ94bKD+WhvWZzjf/fyPet+T0leCFD9Jcsh6EipjuI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5589 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 18:16:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685419 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 7E446C433FE for ; Fri, 17 Dec 2021 18:17:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240244AbhLQSRd (ORCPT ); Fri, 17 Dec 2021 13:17:33 -0500 Received: from mail-dm6nam10lp2104.outbound.protection.outlook.com ([104.47.58.104]:6099 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240237AbhLQSRc (ORCPT ); Fri, 17 Dec 2021 13:17:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HL+y4OATlWjZWYdayFLxWAxP8vYnTkW813SZrk/TroVvoBqAqASJvvH9sXWodsNply385Ut8xOgXemYXxzJweET/GFC+OQEbmwfuTNt7rhUzg+kTb3R/hoqJV02bTgKP/qOG+F6oIikIdJukku4/I8NiRDTKxrSiOVYkxo1C4A1UL+5Gr3oCQeU4h5LWWNjj7x3LcipBxD2tRGuuLDBtBSOZUCLiMQQupjgDQBimPPnMiYlYWtXIJ9J2AXZrUmfb970z+SnV8EtI85iy4a+4ttgSSNKGQmZcn0ccH4vDKcYtoGYYuVUT61IYZu+EkiRlzZ3mMJ85b8QiUhEDqq7O+g== 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=2MZZiclSoRMq7iLCn8kRfs/GVfnwOPivvtL5sJ/LC6Q=; b=Syn0S2Y7oOiUt5WUYFSfqZNxouG81P5DRduv5zg0XHb7jOk8Rao/Z3xLDFmtLzh8tzopHB5qHgN5M1EjNff4J7mOL0bp5OIvNlh2rsLwdGv1VN4JReqA58wsVWTl6KR4+Ft+rw6fOkUVEPOoM6+VLgWLkO/UeXFeafAY4cZaADb2YP7kRzFGn/kLpsjNIicQ8KAvRfLAh4KYs9kevm7j4jpBu7iAFnod87jF/G77FTwXnCt7oJw7KxFfIpuDhmJAS53m3D2MxvUrZBZKoOneydOh4CYc0kxKwvHxNyLINANebYHcmyp6RuLFPXC2Ks2vdlotrkRBlzzDnS0FowrcSA== 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=2MZZiclSoRMq7iLCn8kRfs/GVfnwOPivvtL5sJ/LC6Q=; b=sg8IZzNnjmTWwwrsmmDVm3/vfi1zTXliPU2OqsZ724KBng3Uc+nadgmkJJISy18LlysvyIeNrHgrgjmJAbgHW4q/fnf/I4lxn5S0AH9kH+Ft1iLMnvTe/517CNJpbvABAe19/0Y9B6yVoM42bVAjysTi6+uOYM/w7XFnAaz0zjs= 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 PH0PR13MB5589.namprd13.prod.outlook.com (2603:10b6:510:142::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.9; Fri, 17 Dec 2021 18:17: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 18:17: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 v8 net-next 05/13] flow_offload: add ops to tc_action_ops for flow action setup Date: Fri, 17 Dec 2021 19:16:21 +0100 Message-Id: <20211217181629.28081-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 570955c0-b3ff-413b-3dfb-08d9c1897cff X-MS-TrafficTypeDiagnostic: PH0PR13MB5589: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: c5ABALPbLwxoZL+4YQe1jfqe6d/Wa0tuazZEJsD709tUxjkXccBiVo9f/F6EBY5cE2DgOurJOCB7uKRJ9N8vyCcNei5rVIz8XSmefCqV6Je7t0GzSawLsE5onZVcVEAwMvNc9TT+YSFSLIqMsDe/r5GQNY3kFqWx7cge+OO1mbpqBQGQZgRnqGW7yDmeqg2sanRvXlgfgij/ZynfawLPnsUkjb+PpOv6LRUBIQb+pq9BqR6P8DdqThY+RpF4CBipQt6Zu7KUDS2wjNWl12QBB6qUQpvzXFYGk1Z/f/CZ5phVxUYjWw+MPypG4RjVTHVMG7ZBHxx8KnDz8hNE+NFTwoLtEQ7C2fq3luSmgqgu4YbfrdpT7prmqDnJ3j9z/a0qhVkMevCsvA0iDowDinYpfcKs/Ss3T0aA1SxQUeoiE2a4mAAV+OeVh2aPtDeO2YN/B3TFE0bT4C9LdYYXZs6UnpSyFbzEswDN1iiE6la1y9uRz5zESmNXbWjmxtrVc0XQN/OnPt/C4oOGsZ2ImITxny9I/I7LMf+jMfkjDNUL4tNb76lnoYP0RIt2Fv+1kpO3qpcKUrwFsxzh57qMe6cxNL7HNkaroVAxeFY3t5BLe+kSB8CT+dE1n9iZnCwXE80O5Cq2khKykauTrdVx2OwEmg== 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)(376002)(346002)(366004)(39840400004)(396003)(136003)(508600001)(107886003)(52116002)(6666004)(6512007)(86362001)(2616005)(6486002)(186003)(83380400001)(1076003)(8676002)(316002)(6506007)(2906002)(54906003)(66946007)(44832011)(110136005)(30864003)(7416002)(4326008)(8936002)(66476007)(66556008)(5660300002)(36756003)(38100700002)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3XieyUWRG1AJq8eaYxdtOtLqSJGOTkB8/tuoL34MjBDTI6jdnONOX7/dLzxuvio4M/Glw4KEY8NV3gWbt0OjvwO4j0rIcvOPZC0hKI+ECnvPq50l2lG2TTwUYmaDdw2pzVcjLUiQ6EB1h7u1N8bGdOdsJDI942vWk4Vfc4psPZwx5OV/Y5HfmwgXj3wUpaX2580yF/2Q09vkzTK8TPLYxNetkgxhQdANR0fso8dXOCgyq/S0lXcYOBLcJCQ8u752kLU+Wjv+YO/IELsNFJtTJEIdGvAJ3F00bAGro6oHaZT1aPy/bplLfDzVnEJvtaumiqFsmqBRS43wrm0KyQwz5gswcUYhjC+xP75gnhycTHWDda9naqcMj/UrBtawBTbV14tr8BNCf39NUOGx8nNBElSurx3xh/+wWEOA6D+6T1yA7cARK1+fJhvlz2WGVqD97uJGlZypyR77LG8DiI3gl+b/Pb+tCQ7dOdFh7tyL8xrEjOVMsq1DVrfPViqGIyQLiQrHPdCJJiXlGTiXND+IQgb8lneX7A0b52bsNURUWFWWc9fZeiRwtCKbXuvAxdCrstvxsZoKrn0E37zk9qT0z7Ogrqy26MO0XYD8wCB0Q2zvyKJLbmlrt/NXp4bkbZdumSgktSO3Mp8kvwRmANZ8Gbd49hUc95ndglXM4LfHgRxQacKdfrX84g2eUM/jT7MGptXyUNg5jSkbL+tnio7gXqRKyUDDUX3X8BIYiPHwTDdJWZ5ulWxZJoZAXfdYF/MH4hB26sJioOHLW+bgaR5U88Ynd0Aes5USPW3ohU4y34ftBEfvjHj8YlTgwmqZSXzrJNNA0Sm/k+Ta4jYikElqvQCsIXpglEY4Oh190mFOvP71CTuXwf+rKoA1yaSr6Mp25RWHplc/qqXCOuQMMFq+SuQ7uunRs+Ncq+EhULtRyxor5BAgS50P9bTDfftxD3GFSxvHFKrPk38N0HpWjaXS5BOwkrldsmN4qyYsh3+IqCas6Nl4EYJVSXF3zNyMdGQbMQf5M+jjZDQIxQbLxMDHo/WbJty9DC/O400StgtUmoZnW/oeLvfFbsGL7snukKSFZH1y5wZdj2offJKi/0FMs2ADnJW6WvFf2vrULbO4lud7mQL02jAchrA0bGuaYjeuAwd+ZD4uVIkw1FnGzUlaPZI25l4glheZFCBL6nfVrRNAE8siPPMJCdtD7hb97YwbThtv+rRcmX2xw9YYyDN8l1/obAm+M2WPwMwoYXntUUbVHX8xrqJNW4EePYtqDmuyYV0audVETQRhJm7RK3hO2tdKGAnt1EPkp/U72JNz/4UsvnNTC6h9Baax/uIw7o3RlJC9q+IBZU4z/MxSARM7EG5sHLP08GQns2HeivNgrx1NP+duLGNz9xlJ5+RZC4Q69KG2LyeSj53H5tELaQ0x17iTV67azSJxvuYyRCRUGcjQGYB0CQ+3IH2+Q/UB3hpuN3BraS/SvrBi8TxZhuMI3D1Qw/9bMf7wg0JS69vt311oPTcrrnY8801/paz9zXo2GOBw+LncbFhKHy2IuJw8cPamTZvRuQn8uvA2J5YC3fWpfEx8LY8udEl9zsqlIzFkSMiFQJQmlUIctnB+8rcclKVpJGYYjborKzv1aaoWVz4OiPGMeTw4MjOdhWwQMLkBR+xItGhmIPE+wNT4h09aoRky+q3nKBXmJZTMHDHuzd5LLIXzVFNCkzWETtXt7wLIpWPy3cNANY3fkLxGNmIWKw== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 570955c0-b3ff-413b-3dfb-08d9c1897cff X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:30.3758 (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: fmWCOyMO+S39i1BFjy0Xh68nhe+4AJIjOBVoTpmgLXnuQsGCBodd64CdX4EPvvbisQqdViqSulcN92DLvJA9ANHVLIQKxuCmbRRwfdtte4s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5589 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 f6df717b9f17..c380f9e6cc95 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 18:16:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685421 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 22E38C433EF for ; Fri, 17 Dec 2021 18:17:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240255AbhLQSRl (ORCPT ); Fri, 17 Dec 2021 13:17:41 -0500 Received: from mail-dm6nam10lp2107.outbound.protection.outlook.com ([104.47.58.107]:31253 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240217AbhLQSRj (ORCPT ); Fri, 17 Dec 2021 13:17:39 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IZdE9Q3KLoN0mk4dp+DePSRSVerBxu6wr4xgU6R+1lRQ66oSdMwEQNEMaEt3IyMg3C130X9eS8H9vNysusePitR+q7lAX8F2+plbcEVK4FpqRgLbDqGNXb9MVeIz+tkqp3/q2h1r2LKS/PEpJN0hBGF4eQuPTMzo2NM+8xYYEhTfljk5z3Pn/EsUO0I/VSShBaQm1l/ZfPTH2qPPFTEFKyrrIQnJBAcQ60OjqCsZ3FL0y8Z94MXhpWPuMjrGkfyBynX4KrVErewvJ/y638RK3yWwv/b/Tk/SiDWuj4sh1W/q2vXdVPiRDN5j4p2kOiV8jEdz4IsPU4LMYpnrwvA+7g== 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=lZzKAzNCYUKQI8Flr4CbURWRJSIB/K3RaHeUH39cEC0=; b=AcD42agj4tgMOp+BOl0HWnBdDLW/HvLcmXjHQUrmFi6/+YXVeX6VF64f76acFzCnO0PThSXUROgCEgn8KiyfoQXnpDldlShbEcrfteeZ8TqDW+ryjAbWC2yB1WzNHzC0uN3uepQBeyBP6hIO2AxAGcy0VQ0FNjVEpVOSqrTAfhoGdu2UTWXTau2q7TRQBnUwQeZ3OasFTjGDuPwXcuE05FZBsONDeNkuFtcc7pjXyvTtaQTgUAoZatxbjDsfdyFDvTLXIeYQuRdz9Z5IeRYF7FF5Pe3ByL+7zuazs6Fq+JRdzUo9B4JirCEy66/XpP/9u5xvRgrtxkcE5a8oUqUlvw== 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=lZzKAzNCYUKQI8Flr4CbURWRJSIB/K3RaHeUH39cEC0=; b=CMx0ywiAzntAoojtqzPkDJXuok4uaxrnspE+1g8TsmehB6nCBIPu8nblgcSLJLSgBTl9mkM6PxoMH6Zs3Hv7VdJqybTXSqfVWFXN+vv3aiThZeDaIAx4LLr9BX9Gq6IsndaQIiQ8FcWecey2dKwlUdtmGTmuVzlDpvt+kN9OsPE= 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 PH0PR13MB5589.namprd13.prod.outlook.com (2603:10b6:510:142::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.9; Fri, 17 Dec 2021 18:17:35 +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 18:17:35 +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 v8 net-next 06/13] flow_offload: allow user to offload tc action to net device Date: Fri, 17 Dec 2021 19:16:22 +0100 Message-Id: <20211217181629.28081-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 2478454d-7f36-4009-b623-08d9c1897fc4 X-MS-TrafficTypeDiagnostic: PH0PR13MB5589: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: quGH8PFVCqv1ROwMxoOrIxS2QbooIWDq+QR+kwT3vz7XHwz+2r6pP3Sxqbt4xpAhQ059JnHadAnJZMNaR5g3MrUlOOEon5J4Q/9aKQf1f9hwxUyYnX6Ht6NhtW2EXAd3FS/Umtodn1ia+bHILKp5SOFwk0BVbQQF1Tz3nO4OqLZHaXTMI0YrwhBklka8QkmjV+cWAxc1shqVG/56oJp04OWWRzxfhXQeyGJvQxm2Gt4OW9tPE0oXnfnRFoobPY0/GLFoPsj6ZF76RfiWbcBNCN9WvtOlDhvoEOBUXnYqp7CmM91oJdLqbXL6zDhn70J1/l9DNM8eZNEnE82enFhoJJ9vHFNvrTBtg0mvGS5eRs5JkaZ8ZF3XdfWDBzTlyHhcScnfd9r3v4V22j7vgKPufGDO3esHiVbIy4QLRxwRdsQsH8IfqDv4VzpwUfs7gOa+HElJvV9fmZw3UNkELQGXiHWH83Su6oeTaIymWiwp0z0/JLIax3h6NJm+Xk3MKhrHPY+cV0BZ9fL9Rd4Z3hliDyKBb4e+qaNImapegtZ15eFxtDiDdXnek+QoF0tOx2s6MxCTdjis8DMK6jalgl/yiv7iq3FQpwxplJqlU+h4C12UL+hIN1PLhTdjYiIMJgCKmQIpbNqdT8x2idfegzdJEg== 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)(376002)(346002)(366004)(39840400004)(396003)(136003)(508600001)(107886003)(52116002)(6666004)(6512007)(86362001)(2616005)(6486002)(186003)(83380400001)(1076003)(8676002)(316002)(6506007)(2906002)(54906003)(66946007)(44832011)(110136005)(30864003)(7416002)(4326008)(8936002)(66476007)(66556008)(5660300002)(36756003)(38100700002)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7Fw/aDGP1hhRyFQsMnJEwbY9sosb7Cj8mEQ/QfliPLkwjYE3wxtygi/zJK8/cdeQEE65yn7XHNkRZKWE0CBZR28IeoveOTrq7g78QMx6d3GIvTRFjDvWVlADsoIJWLHZv6fT89iOno69q6PTroNeepnSIwRgCjwxR9x1n97hgoSYV3WLzD+eDsEw826CcrlPJwX8IL54KaQQ+t33J/qqw6MDDXbzYfPaHk+eq6BLfMFrEelz9ulfZS/1dh7UjjyZCSzSAXwBFsNGuONDmNWcVlL2H9VcqQ+PSQ6SoTWvm+y2yU3xuMXWS8okNHOnIU7ZuWV+EvUvm4DXdMO05rRZ9BXaXJxeCaLgOirOY9CNpxGjZDIGKAt0CVfXQHh0K/hOVF7ORDMKWlEo9jhna3iXXRpMTgHNgrfHxWW2d44flNAnNVo4JtKeUSRoH0OwHfiddETkOibW2NbB2qtaQ2xV33KNCe05zJlYhUrz5XMt0MgWsVCNJAQlmSklvIoABPtl5W8bEcPrGS0GbcITF+f6S/rsEjbqoylcakooJa1bcBf6cct1dTZlDDRNl3Wdiqwmbvuvw91FEouBjffxfnPOGSyKPI2Cb9b+2GCqGlKoa6N+BbVnxGqMjauju5wGIXl3p+f9hCEAGh2W6QPpYuCPisDEf3PgTENW38vxBWzot1UeldO+FcGAZvVYP2L6YsH2/H5lFAm9t6lW55b0FuHXoP3MwCeBBj8hJaA+P7f0OkJE7SSRDeryU46WeFKiF4qwpmp2sNYDaxtlgy812tYMyu1f+ynHhQ+H37wocL665IZXFKnFGpIJxV47Ubm6+PPMwqjqlKE0Wqf/tsqCqQsUfqKL8Ljp5pLSxCKkSlffkTH1v5gzonakE7Gmq+vrFSok1P4CLJWBv9yT4urv354cDeEEj4OP+SL7bHy5rVrcAGMeGY+a6A3xW9WGNfN1eZpQV5rY4Oak1yIgWlkFkiZ6vV6JzkCe5Dqcy/yBsXnz2zdlsur7slqyp0IeesNsjmC4YsBzvGaBDbntfsKTXPVPEK/Q1DqC4VpJ6Z5aBWuoAO7iJ/r0qnJgza8or2gDKwRJIkW4LJldt7WeJQrJHb8aFOifSCMsPnYltVStTmDHAwugpVXQHRpcVKI8qGLW7NQSNYag73M/9AdpWgUQhCAw1IU3INib2u6pbYqy+4QOvpvrfMR5Cy4zmUs0svq0A/XmERR/tXO3I8JLk8SMPkfuBaLmC7EhtbyWv7+JXcZwVFvOE8Ynwh3PyO21GJQvQyfr+Znpjr/txkhhAwFm2f5MCopgicxWMZZuUdjMIpiWjK7bmWXQoV33tbPA7Ui30kWsf/ZZ+eB+DIT7gqHRTsBf+7l26m37Um0adNVWdb6IAdvforNkqYhRx40JnWdt3n1YB62jJ3JfLTrEppKqL3hdkvbhNQ66Er2qv525drIiPw6vBlTzTsTyETkZOMOCUGFOD32cpjMpiX4A29XoDd/8360KahMa+AJY1MpJevTucFcRHQbX/rnnF0rEYwE6JQj4AJWEx0Cs3+EmQKlHA7BS4oUsrZcZqIFvnut4kUT1g3+Jw/Hm1ijMwm1Zy8ZLK7HeOwyVDFqIQySQ+JZJdyyj6Di/jsus0rkzfPDmEXXCFpIaGEgDAag8tIT1Bdz61Gbkv0VY+v2VBxY+6cvrzG/E4hrvWR2YEMfm8QjFWDeC84LM1Vx8UVq4ddc3X1XTCSFYse//9b6y6qlkdpRioBTP/w== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2478454d-7f36-4009-b623-08d9c1897fc4 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:35.1010 (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: 3BsjFXbAcOmF2K3i/56Gn+Y7HoQbd5ziV5Shv3eM/IOoH0T7Qnzo+2APDyc9QGNih4B8V3YcRywm8VufoIKF3GzgBJCbohhwNUZc+27te7A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5589 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 Reported-by: kernel test robot --- 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..5b8c54eb7a6b 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -551,6 +551,23 @@ struct flow_cls_offload { u32 classid; }; +enum 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 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..5c21401b0555 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 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 c380f9e6cc95..ceba11b198bb 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 18:16:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685423 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 2D665C43219 for ; Fri, 17 Dec 2021 18:17:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240217AbhLQSRn (ORCPT ); Fri, 17 Dec 2021 13:17:43 -0500 Received: from mail-dm6nam10lp2107.outbound.protection.outlook.com ([104.47.58.107]:31253 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240246AbhLQSRl (ORCPT ); Fri, 17 Dec 2021 13:17:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m0yyidn3PtFLp/WG+hd/ngqqqzNo/EhdK+GDF+xuQh7ytExy5h6KMN2VIQGNGTMnYB+eQth1zQzDYXctx92HCvdEUMOg3h+4ozY5xMvFe4XbK8h0OvPn+2D1xV/DVBEPrIi6PWmtslnNSb5MsgCrBfOl/Q/W4Sx0ZP7UzgMDYyY35qwFI47kqIr0cMeJw/sbK7qHS+M4WWwf6IEEpJGvWFO5ciFZ9xYnkKcf1kXvqYyu/7zLF2i5CajNvy9Crml+ZrIJ8OAvrQbYjZg+WbNZKVLy39fQjuavMz9PcgHSJlimeR4bXctMS4ju/+0vXt6Rj7fr57OSQLNItLyGMV2fYg== 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=zRaCzaabMo/a5mPyDgj5aEQmu+wrJeuPsXUpb3w+tKc=; b=dbf59SPAZfSGlSsZaEmJxDLQay8oYrVcDyQNHJX91C3k+gjFa9MRx8jaKntCAG5Fc6CUJKUKS1ukFHqCe5EZWy/VjJbqh7q2vfb6AEU33eDT9/HKcW0AaqkBopzgVTMpUXfA76NzksAnpcPJw1aP/IlNc9jF2SIj7ufElxdjRIbQ0+Wq/rsWc6SnsE1z6QfJ34nt35P0oM4WjfUsjzCmy3CeuylPZ5V0T8o4BahbMlHWcbtoX37yrXJ1LuwA0LHcmI+VbyWKaTTMwn+gQbGNuIl7KHCHCS3lTfQyO9SV+scnEnO6DPCPkRkzZeEd4zKFD8OnT8wdSxeHVbYR44b8Eg== 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=zRaCzaabMo/a5mPyDgj5aEQmu+wrJeuPsXUpb3w+tKc=; b=U5Nvlb7F6XH44ItrhZwRIWNUCUwMU4DSDqs8mDuNZ09RJbKB+OHZ2KrhAoh/XExqfIioc6WDGOOFnAYhTSs1ZtgEnYqFZQ1ebNTWwxMn1jvF7qM8ag9e2+zrf5dXCiO2qkJ+/ms64fdbmARSpNWONdYQaQVhYpxjzLWdAsupp8Y= 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 PH0PR13MB5589.namprd13.prod.outlook.com (2603:10b6:510:142::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.9; Fri, 17 Dec 2021 18:17: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 18:17: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 v8 net-next 07/13] flow_offload: add skip_hw and skip_sw to control if offload the action Date: Fri, 17 Dec 2021 19:16:23 +0100 Message-Id: <20211217181629.28081-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: edda1ee0-6d01-48fc-3f0a-08d9c1898297 X-MS-TrafficTypeDiagnostic: PH0PR13MB5589: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: onvGRJGuXi4QTIpWIuHDTZMsE/9B6IrscKbw/EY+bUElpu1plMcRikhZTqwzGFkdA9CuKnEje/+jKp5fwNEGTA+taec0SLiIouLea+W5gXTsYgY1fucQ9GMWXyaLcrhx9MuKJ+4u74ULluzNFHOit34qhzaSimIsLwnhoyE2tdHnQ6+mfG95khkoflHcEe7sgqgO2bf7+U2eOp2dzba2/dHCIZK3p9sdjEMeyTn4BUep+LrQA4VXB2gGGeYx8b+guAlChn4Z82K7+/xqb1inLnh7KlvNeY1tflKWB9uD4Mvby++2PXMUmNLm+omphjRPEQY1/PPAfCu3qu+LCViEa4BX4rno/2KEzy7UXKRSOpdaJwROwghGszujKWx47qKhw6AQ+uy7Tx/zZMk6Q38OokG9iPs9BUtnzGN2W3lLUxmUSbwuVS8dtY/6l2ldqa3CmIo8dlsm1SkG4xtB5MTqmT7en/qQzo9738u/EPObNJ8xFjYHthJY5nei/muzcNWHHFFPp2+9ukpVFJXQtf0r+52v22QgENaXJsCAjmJC/4dy/nScY2cUeyv3IYDBa7EkAZ4ZxClb9ml5QvsBAylr/QJkiuYuxGSPsR+neOb6Z5ZZ1n/xIfgJ8J26DOW6jRROolPdmGHpVqTdkIj+ZKmGUAdcduMRTsuFDRh2qMpIzghHvk9dcjsw9JKrTngZ95MR 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)(376002)(346002)(366004)(39840400004)(396003)(136003)(508600001)(107886003)(52116002)(6666004)(6512007)(86362001)(2616005)(6486002)(186003)(83380400001)(1076003)(8676002)(316002)(6506007)(2906002)(54906003)(66946007)(44832011)(110136005)(7416002)(4326008)(8936002)(66476007)(66556008)(5660300002)(36756003)(38100700002)(309714004)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AZS3/h35IlvLKK5HYqGC6ZStkzIPVrSqlWeaTbcvp21GDsdhDA2eYV0hsJy3i9vZErDUcuw/Hqrpx0zDA7duE8vGVdmI4ePAdJs2Uw2HnxtaHVPweVhVW9Et9rrx9+WyvpxyZVTRwBoxgSXG5qCGA4LoHwzsa8VqmAgvdgWkr7Jr0fbn/QhkOdfNMHPNGgo57krKWDXKuDdmwgq2szn9Em9+e0RV3yKHlpmTJVy0zFVWfB26GqBDg25conZAB4q9CrDyfbb6asZkhoL0j5s+nmRMrNDRqJyhnbKNE7VWvd4hV0iRGmc2LKGmN0f3J1wBdpge17p4A21AGXDmzKlR8S58ide3T9Zte9QD1alq+/8iFoXGY46H/HKNa+/J+OnN55vO4xu4AMtduZOznPw4505ZwIl9TH9VnvDV6qYV2xzwD9lSF4Lt9OcefiE3U207AkJ7I9W82xVXcynm1VFBIuxnRToHDGTNHtL+qY5DHkc9lwbOx1xO+Np01EVmonuoC/BDPnHgSwjJ6vgyxc3J6WwqCqW2MpvemhZg7n5K+M5bmG0gQqeT8AqM7k2AsJqzw95mjYAcCkdFNzxtqxAA5WIw0Jj66Oo4g+PtNdff6E9j1/1tCfkT+mdj0Qzj3lEuoTwEL8BxEg61nypS5MB0UaZUOkJ71QL0B3eE//P6f9+Q1R+Pa+MgqzYVktbzS4ONkRVcZNgbZE0g9FlCUu8BcHbHoUrK59bsZcY0VrBCjfiUegmV87ha35gO5mYYUrfc5qQQqjHXCglsxduA8L/gY1nJohSLXhMS27OmrawRpUSSkdlBioM4887tKzmfawRANATHZ9CYsGEaRiEhNtkdH7ETetEATkhphdype6MzABnHqWS5mb2I3kMVa8+z0jk300a+cYJNkTCznsogSTTBna03wcLD9tuxIrSTbLthyVUlT5MLd8BGpH0cyZ6c6dMmxCx/EyA/U2cXnlzqNadO3cyojAD22h3ogRJKh9nQgtskHWZ3jg/FBqVgslU2MKG57oHmQyQI21CIF39wE1p0txOG7AWZWz0Vn5YjCRyfwgcwqSi0aW57cuFoxzQPAZ9nLGxD+ekzeHmPHYHJzk+O+yhMRhmz6A36q69OfpLDH9e2F3688CwHlkdqNOkzdqYBON5VfYvINpCjZz8kJkJzJsSwd/JhQGZoojPjyXe2f+wN6b54w5u2wjajr3kzmHp/ygsjVO6JRL7CnCin46SQBjqoIpdKkHy4BNfRtmfCRyYu6ltYUxB49xLYo/gc63Tp6PkpcFZO+UOrT3+0TuhQIPcdeTGBoWbITASc+gukB995EEwewP3WdLAJWrPVCmswDoJPbooIr6yiyZhnwVV4X9I6PItXJ/bOV3X1Mtd/2EddLEcwR3mEE/BkvnUg9yYGKzg/vibiqMbTjqGh8yyKdt9jSJhSMtXr8xXsnpmpDlDSaNFJ/HVK+Tr1D5eKtSTekdL+OwaT26iVaftzx8V/p1XX4MXvBMqv8P+Dz5qTcMv83uhPydvtbtPgh6NRz5ronHfXtN42QHArMlKfnOUcQf6PChDn9ZLHo0PvtjMImPhATFkNXzVlOL86MBTNtUZRA32b4DNpyCps0B5StcqbCUvFyBvKy6qGzVQtflKqnQkRNYkhBVIIL2mjYndj93BvPl4UaFHApQKmGpF9Uo1qaVY5oLCbPfYplNGalvzaFL/aDmmlGKqDL8O6SIsRt9fNJTicBf2fuhWV2acsA7LClg== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: edda1ee0-6d01-48fc-3f0a-08d9c1898297 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:39.7148 (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: f07HfJABJNE6T63MJ7BXU2dwzo+l7OXNvChXWYL379FiHtVgisBw+wRzZsauKRGeyfiZJq0HbKs39uD2Ln42Mq43XoINbPSh/nJhQ3gSQY8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5589 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 5c21401b0555..d446e89ececc 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 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 18:16:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685425 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 74258C433FE for ; Fri, 17 Dec 2021 18:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240315AbhLQSRu (ORCPT ); Fri, 17 Dec 2021 13:17:50 -0500 Received: from mail-dm6nam10lp2107.outbound.protection.outlook.com ([104.47.58.107]:36846 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240279AbhLQSRq (ORCPT ); Fri, 17 Dec 2021 13:17:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ivdLH5cMi53K9yhNCjGHtkfBcxBQMx9mLkkt+h7Swv7ojWJp6GYzl6Dh4OG4HreJQ8k7fLdPem5v1nFnZ8gkBVo9Udhi19PXwH5HgAICL129Yj5Gxx3unDe+FFveatu0ub0XPD6zQHSOvsLNwr5reZhxyswRZL7EIoXz2LodgzjYrw3LYrzG3b6c4ES4wzX142PaK2g307AjVwbjg4tBnTp5Ksf44rScHp3D4x80ynb/dzVP5WQG8qDX0J6+paNiPAfnpMuozkMYK/prCx9V5vS3rf09FWa5K3/EmHHFe+m/I2EjLLbClSBODMQvfSAy56QWIcZYrLd5uKLiXVnjFg== 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=6but3WQbAbaDUq49Xg+Hl2ofSBrTrp1BQNNd3rahVWI=; b=fd3ovZO+VjHy68v+pCK4HZWKu8C7SGYyESsMroWzJfDZQLZAs1d/QQ5OfifGj75gUg6KKblkNFld4kfodCzjgYyCjNwZw/FToKRnLEstbsCSqIMgoH0tp/m7cw/MOAe3Yb69f5mkvhPw9kuT+0dwunNsVdhaoPlGeX6T8KRMnE0nQNbbZu/usu2/8Azo5h+Fl/lKX58s0z5AS4STa2GN0tRgiInnQzJin0JGhK4+ViTbYY555XPU+SuBPYrRCYKlvuV58dYrFN07RzAVpwmRvBU2k+183/hyhf3wmRUyz6Cm0r+GJ+F/MwiZtygNaG0JEmzTxEDDFwGS4tA9yVW52w== 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=6but3WQbAbaDUq49Xg+Hl2ofSBrTrp1BQNNd3rahVWI=; b=ZAKBeYosfWmND6VCNqardWWG80Y/zuSFEqj7akMuMfweuHjhKC1jwqrnHD9AbupEOA1h+eweuKyZPvEudSn8EpmtSmPgyQv/pZHi8ypFAYr+7F7HD+DMqMZBM3zRw6GEajQKSLB+RPgq0A5oAPSMr+5MBSX9+rpS2/XSVDyBa9I= 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 PH0PR13MB5589.namprd13.prod.outlook.com (2603:10b6:510:142::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.9; Fri, 17 Dec 2021 18:17:44 +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 18:17:44 +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 v8 net-next 08/13] flow_offload: rename exts stats update functions with hw Date: Fri, 17 Dec 2021 19:16:24 +0100 Message-Id: <20211217181629.28081-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 560778a8-24d2-4f9f-43d4-08d9c1898580 X-MS-TrafficTypeDiagnostic: PH0PR13MB5589:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:619; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pVUjMxnHtASkTJDpi4l9x2PIGhJiBQDOp2w6XhKWyVysd0Gzo7QAYJPfco4NlUYHy4ggoc1D7glia89RBAl6N+jbyitELzrwkP8NxPRNCBau/vjw/hUGYKjTep7wjJBL6QCmxz1vDUexj/suSc/xTIdUngcbwhKAoxWgn4knrgGP0/GY8hBkSpPKH+JkSZmspb7qk1zsTLV+ipcWEUs44PuDUrG7v0Btc90e7StTJJZjkV4fQOfLOElf2BSaTm1BHKA5hkp7vD1Wjwmbcr9SS+5y52Aa/EJsfPAp0qtWYG0V5wA4EAAqxomQfvneDz+Usv2IlpEzDXxFukiB6w1Odd6FfLNwJqtE9/1v2OHWR0xdKVOgEzZbFLSD0P5erkYeVOtKMSIWahKLO7gz8j8Nnspbe5RJzP37M6FJf/kHjvS8igxtHvz186qdT6+QQFlNsdLw4ur1tdS186pcZXDd7PeYvw262fvkxwk+On5wWclfP3OJaZtLkLEVIVvfqvoy6RUWzl4iiNtPNVNDo1N8Iret2pd/ncnI1diuPDQNerm44fIY5m2uu/2FPS6RTdY8DunEruMxHYO2zI1pp1JvEn5QWcek/VCxd9SzjE2OsREGGxIwoMKHgurAwdtK2TVjKnCWol4TPnu/K6CGeDsw6w== 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)(376002)(346002)(366004)(39840400004)(396003)(136003)(508600001)(107886003)(52116002)(6666004)(6512007)(86362001)(2616005)(6486002)(186003)(83380400001)(1076003)(8676002)(316002)(6506007)(2906002)(54906003)(66946007)(15650500001)(44832011)(110136005)(7416002)(4326008)(8936002)(66476007)(66556008)(5660300002)(36756003)(38100700002)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 01G+kvJKhdebo7LStpyI0R0HTGyEI08xTQ1ilQ6mL1/qQBEWFGSSrwYBC5k6ueoeyaWy+7abyJKJ62FAjDRrUEZ7u9YQAUgcSaJCI8WOv/gesJE31tfgyqzJ0vlpFXBh5kuwEeVcloxXm9fpM8uwJMiPYP0gJlNFXFpBPaxpwczzs3qln0C3HCCeDNZ+VG9GyboHlFc9YlasRunNIoO0/c+KTYRCj2B8ElcFAmjAa4PxzFcuwXoMRYPZoMYhqEn5fZRGx7SfdK6qv8HdWgFu1a6G04aoEIf7PP5T9lXwHbulwDxzV2xH2z54q6iv1KDoBYOVbdMK7GLoWKnuEe6rmFj2jqVVI1GzpaRkZa5humFILDNt2MPQ0H3KWNoMnmzJ50nLVosUS2LXtl+eae79GR1KgT8M2YlAbT2q5gYrGbb+kpojT0dFn6uWCZcQexF/XX+FbHv1SIyXVMl8H8Qd/O0GaFUlo/Zm3AXezRfn/ay09ejt2F+NW7O7rLTR0u4gtuunZmoP1IrYMLY0crStEDvMMuM5wzArStC5Ri9LlA/QZ2u3/LuzM6c9/5mrc54UsD5myprjgzHRplTTt7HbBOiWfze6+XkjuF9uFgWPYq4LjRMWjGXEa9soiNEB+24/sgkt/P7SB8Yfz2hUCDH+WZhxyhT6HtF5xAofJhep6Xz5orsEBDzgh12kEs5QnFP1BiCBsrZKMVjN6PtNJF5jpdT+bBaU6+or/zZJNm8MY16U1RFYS0bgxeGcjeHDhyvsbh0pmCUWdJun2RPJixBMphXqqggiyXJiFbQasH4PPeWH12q5XupkAJWHVFnc2IYLs/L56HD2PfzKtAYEnXbaR+QSI+54XcSLwR3Q6Iz/HJxDetrJxCgic0FeVbXxMc2rYqWMFwWFuktXdAWeZejK7dd86ji+/u/xJixjlC0cGIY+x2hPe9bdTS/rXvs7dtiMkloOUQwl/LKHCpQBDK6rIReTZ129MPa/CN9J+Q5swzqDeTvGcFjhun+MwuOfvxYxoB4+QoO3Ev0XZ6hPfn9nufKwn3j8Mi+llYHFxu7HkDBUVfh0o3y9qP/s/JBtxEM3hH0EtGvaNFL5mftRxJzqsIK/7cSTsps8589I35/mHvAwlqv4nAkp4PHXFHMU3oVQgl4IxWE7/1VrpkwB3mIReJrLl/3zeCVkYC9tNBL4w1d6NELtbQg/oL1QbUb/N0FWP8fuxFggeuG3yNR9nCtCiPnvwggJp10FZP78Z/A3Rt8U2ZjIvznSmLEQJENQE0hsyZYQrpz17OOj3jSvxe7IhtwsfBA7xraBmzH+yv6yLvvetLGTpCmqZ0NLyKFQLMwiTYFJ0bi/3LtU7aD2uwNneVZa32mOKClLbn03Df7CIYw5HaTIRyJyi9lwJn087d4jS7SDgJtIrPO5lOaT89pJyRncxecR+xz1h+Gk3QF1RQti7H70S3Fq7lE5Oo/qz8J4tI/2BMTnrt9gqcQG9QLR9VxYqw9elfJ3wL2wgWW9yMDUNSZ6BMDHvhqaRvIC/4C+ViE/CEFnMxYOe1SmjvLj0+xUb9IToemczzVSPZh469FFZv8dcH6mqDDU8SAPJozF49DPrRtoW7NdukjsO5YFWrjI8/EMzJmCAWigAaztAaSmGiZ1UVnMsPf3oADHtSdaNGB5I3cR7zAK4qiZJN14izi5qNxtrluU/SQBg4nDqACTn/MRn9emxCAPQBawjIVAAO7oulxAR/8/XYegcLIU/g== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 560778a8-24d2-4f9f-43d4-08d9c1898580 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:44.5684 (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: B4tmCL9EtFbRsuunzGfp2tSWPiiXVfzYbM7Ufq/dtORx/NFEWmG/V8Ab/yGjetMZZKszocayJq1k/8km7V5V/htJqI66uPM5vtvZ7nbUSe0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5589 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Rename exts stats update functions with hw for readability. We make this change also to update stats from hw for an action when it is offloaded to hw as a single action. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman --- include/net/pkt_cls.h | 6 +++--- net/sched/cls_flower.c | 12 ++++++------ net/sched/cls_matchall.c | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 1bfb616ea759..efdfab8eb00c 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -266,9 +266,9 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) 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, - u8 used_hw_stats, bool used_hw_stats_valid) +tcf_exts_hw_stats_update(const struct tcf_exts *exts, + u64 bytes, u64 packets, u64 drops, u64 lastuse, + u8 used_hw_stats, bool used_hw_stats_valid) { #ifdef CONFIG_NET_CLS_ACT int i; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index f4dad3be31c9..9a63bc49104f 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -501,12 +501,12 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f, tc_setup_cb_call(block, TC_SETUP_CLSFLOWER, &cls_flower, false, rtnl_held); - tcf_exts_stats_update(&f->exts, cls_flower.stats.bytes, - cls_flower.stats.pkts, - cls_flower.stats.drops, - cls_flower.stats.lastused, - cls_flower.stats.used_hw_stats, - cls_flower.stats.used_hw_stats_valid); + tcf_exts_hw_stats_update(&f->exts, cls_flower.stats.bytes, + cls_flower.stats.pkts, + cls_flower.stats.drops, + cls_flower.stats.lastused, + cls_flower.stats.used_hw_stats, + cls_flower.stats.used_hw_stats_valid); } static void __fl_put(struct cls_fl_filter *f) diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 2d2702915cfa..5b9264da46f8 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -336,11 +336,11 @@ static void mall_stats_hw_filter(struct tcf_proto *tp, tc_setup_cb_call(block, TC_SETUP_CLSMATCHALL, &cls_mall, false, true); - tcf_exts_stats_update(&head->exts, cls_mall.stats.bytes, - cls_mall.stats.pkts, cls_mall.stats.drops, - cls_mall.stats.lastused, - cls_mall.stats.used_hw_stats, - cls_mall.stats.used_hw_stats_valid); + tcf_exts_hw_stats_update(&head->exts, cls_mall.stats.bytes, + cls_mall.stats.pkts, cls_mall.stats.drops, + cls_mall.stats.lastused, + cls_mall.stats.used_hw_stats, + cls_mall.stats.used_hw_stats_valid); } static int mall_dump(struct net *net, struct tcf_proto *tp, void *fh, From patchwork Fri Dec 17 18:16:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685427 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 57758C433FE for ; Fri, 17 Dec 2021 18:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240273AbhLQSR6 (ORCPT ); Fri, 17 Dec 2021 13:17:58 -0500 Received: from mail-dm6nam10lp2105.outbound.protection.outlook.com ([104.47.58.105]:24917 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240317AbhLQSRu (ORCPT ); Fri, 17 Dec 2021 13:17:50 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PgoPROZMfjoePvbTya16OVF60kw7JIaD6dEkd1gjhYPFt/rAi8RskqqYvXFoMGE3iMWFBrRnXLUeUjORFr5uiRNpYfbcoI0CmKnMt0hN6UjcVB5bihFZVIz5tWqGBp62hAsuAj1ZnqtPIluC5iSEa9u42LX2ycxXI9uaM7aAx6nD5q/GxO8Z+xa6yXsm8dVjG0G1lHAmKl/U4bt/fSQnZ/9Zbg6Nu8sDWq/u2W2MGK2w4LbMnG7W2mPqi4TI0XxbYJXNbIARkAWjEa8OK0DNayGcCy0M9/4y40bYzeQDeZ6X0PVcpFlE8U9ZxtZNZfyHE9P/ym/ZLdJRtKkyYoabpw== 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=h1i3cRCzaG6Z03nWMWmH6BmfZEsBQGcxj9lHRADtJ10=; b=KLhm5wGmi6WCYe+lr0ymvJL7eMnCCSMkzoW0PtjsgK4NbIlYd/MSRpM5pSjOGG42hmBlACH1u1xPD9yBhf7MJFkBb8KcijIsyapSfXYQkZXtttMG78is0lFYxL69N0CN0D9ryoKoqVfIuqGW2Vms8Yr7Xu31lKIYv7yoCt57Z4HxGScfWoD49kEq9VBJH1p4CQzH79FwxE3rbvK3w+uv4A06KuIBfSrJKsbNbq1efCJMGNbpZhmmNNlX0NpZPfOfBZOS1HuybLirBtph4k709ub13fcVsEdFxQSI2zTfFbY6HXmUU7ijCcmXhbjV9FWDaoSz3Az9OpKz5aq/wfYZWQ== 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=h1i3cRCzaG6Z03nWMWmH6BmfZEsBQGcxj9lHRADtJ10=; b=q/RWuzfY0ACrZ0ApMJF88NIJ/FdquEN4zcO3C/7JtJqa0lp3HqJyfyot4BxoEY4u3TN91kUA/Ove1SKTUyLY2x5rvY+tgukNUnCyV6T81hVjK8rD4cgTgbwxSd9B0hitYXoxHMZCaKnPKB4ISR8/4LZFO/xznoASDixYlWn/PaQ= 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 PH0PR13MB5589.namprd13.prod.outlook.com (2603:10b6:510:142::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.9; Fri, 17 Dec 2021 18:17:49 +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 18:17:49 +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 v8 net-next 09/13] flow_offload: add process to update action stats from hardware Date: Fri, 17 Dec 2021 19:16:25 +0100 Message-Id: <20211217181629.28081-10-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 2327938e-88af-4a66-7a8e-08d9c1898835 X-MS-TrafficTypeDiagnostic: PH0PR13MB5589: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: 9oxojN0VN1wb2Jds7kLhtQG+TFSopzFGz0u2Q7Dc2j8vT91cXEZRYPbcP8r0R8xzVs/Yf70oL6bTlM9vY+sFvCJ6JHqTt3Yc5g8qPXUPMbrvo9BfNTaz85FO+oaVMHYUsWvhGdnpdDaPLaJhhW321DKlGxu+VT7PPg+54nnJSPDr3+uDmXhMbp5RRca1uGTqA2AyWmSFTJbYBV0t/QpMbMwOEO0XqG9mToIzl8o6JA7P2w43staL1P0R3tv7fk0VZhfszSXeyrq/kGb9XwxQcuFcfehk1AE2kTvt7kP1xO8PQZbn/vEiLOuFgGqGUp65TkHjWnm8JZ/uYa1VNnkMQDV5Z+bHcX5WVLVD9ECVF5Ptqbfq/g2HKypQBb5Rs/4JG58gNpvH7YItt/1xQdPvdI3reK3Y6a3dY38gjuaSkkwqj/EYyXma/oBaDIZziwF7P0x1AHSD7DCl5Gs7SpN9ckwdRLiww1RU34OZzRyhW7eKV1HEDrzVOUW/6jwTEitwMHkzixsp/lM+9SYvj3ecZx4RpNWdeI3q0a42OprH0UpJie7ViLxXrOyPvAnvS3g0sFEkpS2vtSDwlB/otQeHcumbPKF7f15FLsVql4Y92rvk+1UePTkXfesoiZhLhNUySYRRQ3miVOy1Lp1fX0O3JQ== 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)(376002)(346002)(366004)(39840400004)(396003)(136003)(508600001)(107886003)(52116002)(6666004)(6512007)(86362001)(2616005)(6486002)(186003)(83380400001)(1076003)(8676002)(316002)(6506007)(2906002)(54906003)(66946007)(15650500001)(44832011)(110136005)(7416002)(4326008)(8936002)(66476007)(66556008)(5660300002)(36756003)(38100700002)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PiZJZ3c2/CUGZExFEBEK5NLCEth6xdRARRMxbmzZzO+4ZohekQFF7C8xgeT13Y0CtlyidZR23yYIe2XxdOeEiImh30RItn08jL4oCz1Who7fMiSSeSf95dXAjfPwGNxW7ysNi8FcOYM6XMFo5fRXgRsipKtnx5EydJuAaexenQLExBwBdBQhu529lU4y71PRTzXo9auKgqPCJGwm1TvGbKk0O4/OBMpu5ortKK1JKFK7Crvx/dTwhEm/1ZySTAgcRqk3Vy1Kr0neG9GtpABAMt2FeDkv8GkSJ3phHoT0uqLePRtYkDvNd7FRjFvKCh1YZUkzEdcNB4qS0QFukO+oGDop/YuIFs/3ERwEe+IIVIawjOpNoor6yabGGD7UKRFGqgNS373UgVpyC7wTUTJflGV8ORuGDPiTDKp3/Cr8zTp/J8fScS7NKnQebOsN14Oy5x/ROWUfN2RVH+6Nb4RpVaWYEhfDGT1dDle8cQwfGdo9C4cqI21zgbWIVd+DICOwvoyBlc1viWqe+z/JuP0i7KyrjY8kT1cjHQ3CLUoEq9bmjKKFQS4rBe/bCo/ytJALT5+3a7sHCkAexXeAomigim5uNx2Gj/pI4Ivi9spOaL7V84zlvkLidSxE6mV8R5qGYnCCIGSaXbn0MRqGR2jhFcJnC4S1cmv7MFPLn3l4oetXdNhpsjQMzYQlxTHEwvadLOeg2QsyCXAvprI471UJtDRsUTd62yFXbQzFIE/Vw9PpIYwoi3EWUH/cJ/rJ1FoCxdSwxLgbR6RLnwgfAmm5jJHss7EQYucbf6+Xizh9TsNkytfaAVY4Tk2gkQmHMSWH7dirMkucUCtvwblRu1Vc3Hq4vvZai5hOtPObuCbUU9Y0MmVQYR5I2P1wxcFU4lJHNUMttQb6jRY47dcKYXRLHmSEVGnQNHYC56kiU0dCGTsejdk3+j1Ch6jyhLxmxmKVInkOAv2hQw8kYLM+DXheeGrBD6zL2P4HTmtymexWyrcwuN50IX4RvcmokrmqxAx+q+FVwPb5zXiCLzkVSVZF0Z55Sk9w6MRl4HCHCsx8o3rR7K0lqKnYehWnRxjbduudeucjOTMlQfKX+Yev7Scis6GiUHwRB4RtueZ+olWIywPkxPhGBpdzKZS36cG7k/41rGgxQN6JMoVLYuMoOebyOFlRt79VYGWhp8FDPc4r0mghIzgfPqQIIVvklrOlhOiiE99KAKBNJ7bYYsZDRcISV7OGB30rDl3PsKvxLGCxWUuQCFGZXOYJ4cxJBm3CFnLOt/gQU+zhZRDJEIQfLYvr4oymKV6fnLOrOxCqap+XYfKnzWkVFAcyHyi2TtstPJtyZaXTy5DhYXX0pOesXO0xp3SEE8jtXMZ19OTxOYdkEP4hv/mxePMHcPfZI6lgA8aqp9VsjKbU+mAVpi0TjmrMwqPf0GdSJDDvmqbXXrZEl+a4/7KHPXi3+NzNvqlJQVNLdLKlu2SJQoZIovZ2hq6S+hXI79N58Y5p37ewMZceBLGUvMQCEnOlhgFEAHaijuU9XOQo7xCpExIQkGJjqdOXFvUFmK1VzPwfhQccHLs8tl3d5BWTgSu6LgcpYuTZuo8BJrM9pp4cwDdud3Y+S4WesFzy0HOO3WC41yWESgZFCqcGUnMA5qdHR4speCVewI57gfFlPp/CtqBSUy5tFKSQ+OqXjOOxifyxZ2bOMXfNV6gwe9xLwL0Ot2xseYqJ0tIOlLE/3ynovLnp6KU9ZHniEA== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2327938e-88af-4a66-7a8e-08d9c1898835 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:49.2409 (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: kJIyznq0OCqtTGFemff7by17DKGIZbs6l5bLERB/k7m2ZwoO/SHvbEpX5Cfd9L6tO6881pVUoEQOPJvRaV1p/rVY2p1z0Fpyu9gJQLgvKHw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5589 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 efdfab8eb00c..337a3ebb4666 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -273,18 +273,20 @@ tcf_exts_hw_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 d446e89ececc..f9186f283488 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 18:16:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685429 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 E17B1C433F5 for ; Fri, 17 Dec 2021 18:18:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240397AbhLQSSI (ORCPT ); Fri, 17 Dec 2021 13:18:08 -0500 Received: from mail-dm6nam10lp2105.outbound.protection.outlook.com ([104.47.58.105]:24917 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240403AbhLQSR6 (ORCPT ); Fri, 17 Dec 2021 13:17:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LV0/Jji18fFfodRPH29JueQJPtg8FX3vshvc6aqa1EoqMiDhDkYmlrcjiyul7WXYu+mn2DFwvHUIAud4S1mombHZWd/wmYt0lRph/K//umk/XuyVF8JWLGPtx1TUSms1SjqLoXYCDxHjJk17dV1ogsGhLNzktmW7WZyP69rkGAf29Q3gcRy4Z0SiHJuFtee456HOOqcpYCGb7eB7PqtOa8Lub06jZN00Ad0tJ7tSpeKsmezGkPXfszybFoy9lvSomYon69MVGw6GOmObU8D9qqUYUUhpH+RbhzXDq+qap7a5v3pWYKvFlg089ZC3PpXFBOsyp7T8ZdqzVK9VsKaZfQ== 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=BTA7FwwNKF/Y/7KDPQXYZQSBTdlW7E97VIIBj8WcX3A=; b=VkvO0S/cR3JstGPI7/hqKsTQS9Z0sv6Fk010OnPxMSdSamXA0PTdaz7VPtVqH8mLD2Qj1sHA5FMQYhv5I1z5Q1ac8uYGQBcmr9XFOpm2KjoJXlMgn6210DoPjwftnrvx5fHSQj9ZMfvc+M5mPuk6MmEKsgwKm6fWF/wK0c/KkATBJryX4YHkzVh+YD6w6mDinoV5n3sTcfNhiXXiu9g84itrP2jysEMU977ROjCJ2uHfBDj++NbxDIYIOL3D2Ht3HkRGwuq6T4d2MPNqMoBljMqsoBt7R75bS59bwbN6AF4uXKrlYBrZAmIB2tM68498Kpzd5xwB842FeQGuVzQTJQ== 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=BTA7FwwNKF/Y/7KDPQXYZQSBTdlW7E97VIIBj8WcX3A=; b=rLbYfMS0CtFpXl3kmK+dUidgBx9f9F21be1plMF66Yx4GXU3L2JSxC6v+QnOgr5MNTwOMma7UOZaWPw1TDin3bfF9EoDy0iFEfr3oCFU3n6gEACDP8bCOry/T/kuZ15zXYRt3Tm+eIfUPAo0IUQzxpuDZY3YKNMG97Ser0g310A= 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 PH0PR13MB5589.namprd13.prod.outlook.com (2603:10b6:510:142::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.9; Fri, 17 Dec 2021 18:17:53 +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 18:17:53 +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 v8 net-next 10/13] net: sched: save full flags for tc action Date: Fri, 17 Dec 2021 19:16:26 +0100 Message-Id: <20211217181629.28081-11-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 2b629554-dd8e-4b48-ec56-08d9c1898afc X-MS-TrafficTypeDiagnostic: PH0PR13MB5589: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: AfORnDuOuhop/SmnQcK5YBtahv35d4Nopm8atCB8i129QyJM0/qeKEntH8QV4O03o40Hswlp54nPW9vmAMVDOHerMEKhUfhT6O080b5ZtPuP1e3tegz5P1eacja3FfzxIbZwT4HJVQRPtKT7rbBOdAdRq7iQQq1Q4YrYhd0cGUXL1HS1lU1D/pOiVxF8ZlSk4b/Ib4X9dw8AZVJahJwNAXZjToHGN9yVxUBvV/LymZzNaTpbCSfzyyRsXVanaffD0ztQqu8mqQZ4zy8b4nq7SlQ0hZQ5873azN2TBpkZ4eTDPCowk8PbG5wM7SNybE+P67frGDobuB755goHwyjcpw8p56A57LdX59WlqE2sIOR5MLAbYy4YwVBOpf1LAipqs8yBmUWy0BXILXbgUG5hGrlP3r4qK94mke75DoZlFgVFuKXYpo6HnqLRfQzAUr4gtQ5yzNCPiQaTwoeov0o9i+GQZ7zOfrqgO4WS7Cwn4TVcKamjGFZ3lrtA7S7HHW4I/+N0ZKb9SWSTxzF9pBdokA2PoOfTQdVDWnWEVGmFi9GiAV0g/adH+hxsE87O/95Z1RtkObbbNwlucU7ekz1kOJaULsG//cdtGoyvCQT0qEgSC8v5bw9lMhUWwXDbuJVyqfzloVpNn2eBkoZ8rMKZ7g== 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)(376002)(346002)(366004)(39840400004)(396003)(136003)(508600001)(107886003)(52116002)(6666004)(6512007)(86362001)(2616005)(6486002)(186003)(83380400001)(1076003)(8676002)(316002)(6506007)(2906002)(54906003)(66946007)(44832011)(110136005)(7416002)(4326008)(8936002)(66476007)(66556008)(5660300002)(36756003)(38100700002)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SDSbRJpO1QYDaoOzV1D7Umqg9Pahf1oBQwn71V2CKQdBM79u3hmCESqUdRjbzh2c0QqXS81OmFbZDlSs+b1TCFKyAjeohYZxgeSp39neDBq/C3z7AiQn9/wB5IhkfQuEEhWP9PqrqVmOWY+6iRoHHjTUuEnRtwW36z1TWx4AK4llT4Nc8/11EjARTIRBj6JTYfLYotBklauhv8qwIC+NyjDCVR0hh9uuMj+h2vCMYPygDGAlKmk3W+QqvFdz7vJnsIvlyJhp0yfy9plxUBuKeDUeu5hoG4peZFBZG7wOA/hEymeL+ZNSOsoerikf50cpqpAIQysVciBuAObKvbqbFqtkarIDnndUtooZ93tAvGUZFmwjJXw9dhuEzxrlZNe6xD4C0mIB1gmHdMo4YuhaKj8JMCEC7kyzvLfcGBKqqXIjmotrZHa/zqUm4RWa/Grk4xo1G6rXmJYNnWhxMFDV3Y5qg5kotTYoApvUX7AZUHTgn4xKEHE1N3EiMG/i4fqLjvD+SkKkH9mP4qhQiGSoO9ihuAEqTMce3ZGHQgQIYIpfJ7H6S2esI5w4wG4jtEVU3Izc6+Tu4wRElJ5GsY/uVY7XIzki6C/5N5uDHpZZG6dZWqBU/jXcu0lNZwSFDk4xryE8lz1rxJzcISLivKGNX6MCVKvu+qxK5BpduZ8Tk3ptoINylgLlJvjAJRheuf7XoPl9Jpf2HDH33VEXxVIr0Q0wL0888jZMTjyEvOdjhYTphoLEKUPemOdCH4IShGNHD+LPJZFrM9dkanjdCI/hU4sBkgmysOffRMFaKGJyyxl4zbaCHr4gqEQXLyT49DoG8cAeKCpRsgpV4ycSKjnWmGCGNdGGlqBsQ0fGivf5NWvL78gmgRxJhgpS66Yd4rqo/fleDFnsEExhHz8WknkEg+gjFSjPLTfQmVLzMbG8zr9SizCxajfy/KBJ7m5WvbO9Ut958A7OOBUa9YPcHIyPE8SsyCmDGUDb8ykHhZ+oL0x0O7mFLFse7JQ2XpRN/mdgPSwm3KTuZpT903aRo6y1LtH+3hEOa3krTC4JkIks1WzJFsz/9OO4afNu4sMYbvIgbZP+funaWV6CqRjlbYvNrbN0PmIAbFT5r09jZzZx3Ji0X6Hy6Ee1kyFBTPrrYM9LQU9eRV3i/Tkhkql1nxM7i4AtO3lzGTHF84/OnlqJZkLs63BKR/W4CLyYaQjaIxM5UbpOAgplbcMuk+zfAOoBZM6Z6ztNnbEn0EpegiHJUSdw7B4qU+aYP5exlD5epZ+urhaIx0bVizU2i7F9RRwflcLHG3MdBIwW2V7PaUImUy6POKajY4VFD1RM6CuW64phfOCecFa9/W2uYH/MPrSwwRrgRYGFYp/BTKpYGXntAiAbgFXUkZIdHBqvlje7WCLC6qoZcYucBVnDikm7T5bXp5oIpQZTmLTMdfLTzVaAs0UU4umXaAEvrrHeOXZkz855nWql1fgIILSGByHbQlr7bYgZfQNKjVYqWlOsqjsHJ5PjkoBmhAZtKNaSGGxNYAuzLL4ndljvU4oGuSOgUy2y9FY1N9tODqnXeW7QuuJR76zbEQtuzQyVHGGk+jmydnavbz/3iK7St8VYV5e/1aTUCPOFo31dDCjcjs3Q60+0SRoYhWBmOxm21Ifxp61p74jSfkqjR8Tg5a04RM81vWSTqOgtccZ6xeLLlVAAmKpiC3ahachK8frt4nFLAaKoiYIRNDKLDzyJlhrNNfrHfNlnJg== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b629554-dd8e-4b48-ec56-08d9c1898afc X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:53.7790 (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: MBfedWsZ/FxfN9nQaVUxZTnelhV+fuk8GjI6gUcRon+N9QQY7kw6WFfXWkcXTCQ2CnaYKzItrD84apY4ZCGhbqLuuju9bBeB5RBw9o/tgjc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5589 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 f9186f283488..b32680ad75d3 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 18:16:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685431 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 63B41C4332F for ; Fri, 17 Dec 2021 18:18:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240331AbhLQSSL (ORCPT ); Fri, 17 Dec 2021 13:18:11 -0500 Received: from mail-mw2nam10lp2106.outbound.protection.outlook.com ([104.47.55.106]:30377 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240271AbhLQSR7 (ORCPT ); Fri, 17 Dec 2021 13:17:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HNN/DdXwEV9cD6RJEw2/CvskyAskUmaVGfybE9c0Fg2E34kB3v11ZlCFsMZ8Phh/883kCOvSv10DJ5SYZK3i/csnXpI5+ToMqdUT0Nk9A9UI3rfIyseoVrj0Gv048uLmxI9rxup60i5txkJyVHIXgqGVrUjd74WgHHdaKgrcbfCgBCYfeCUa5qjmfILHg4R6BSYxSGiq37Aqe1Vts4Ud8yh3/SUGCi/Na+8Ogh4RA5QAnfajsBjx2Lfe5K94M3OVKRN0hh15MgbYD01ccs2HQ+QTWSWlZduS/UH4vCOhiwfoEdL5DGB3LxYQ3FwO1vh7X6YE6rEjQ8F/jWJ7d7qr4g== 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=mlHJG9PTyxekjfMaYmGsORCLGiNZbLZ5jccegE0GeLI=; b=muRcifua53n5ISfphpzUbqmpWNUauUODeMz0ZCraWOw8No3YChxIN3CnFc0XdzyBUaISpIwb2IgXmgbcjTw9oJKEpyUG4E0yXs7/ZaHBn0QTGiLJeIJlSTWq4SOZfQ6MVtAjY9LDEZM3Qe7bQL5w8lTo9nl7JRpt0KRGx6JOMD6g32Fu0LRV5CmWdQeMvcoSwdh8AyNWh8VxJTn7cGMq4ZHj7hvwT5ol4Fe7fj8EBbuDOPnfQvlU7lZ4MgeHj3e4x3VLVG3fwFrIiatNjQVvnII6mjIfZK/UrsQpM+o8/GJy1vIHQnJ5/zp0oVgCjd7CLFIPJux31gOXXafNErDF9w== 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=mlHJG9PTyxekjfMaYmGsORCLGiNZbLZ5jccegE0GeLI=; b=XJXT2AnndnUerIs3SORh7U7YRQkWGIMYVV/OI4IDCEgi/up6LgxX5+sWI5j4TNT+F7e9hVA7CZv3Ypn+cECPxg78+8bdWRSHiaEn4J47T0tBvQw6IWOrz4phknTuK2WCpWmhKijpuqrYioSbTVYacmZryCqbkJMrIWecZ0NRS5I= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.12; Fri, 17 Dec 2021 18:17:58 +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 18:17:58 +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 v8 net-next 11/13] flow_offload: add reoffload process to update hw_count Date: Fri, 17 Dec 2021 19:16:27 +0100 Message-Id: <20211217181629.28081-12-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 86769d6f-9b32-4c46-774e-08d9c1898db0 X-MS-TrafficTypeDiagnostic: PH0PR13MB5004: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: +yu8UaIo79Y2gCiKacQJQAszDa1mTgoI9SV2soMRlOTH+uydJLCghMJ9mNToBwmJUxA3OAPU1SL6MPe1fNBFI8G0l09NibwbcEylxpMJliK4FlNuCXzLJ5N0/iB9Hs3t+mmlgSXnQejorCZwspuneNR9znus4HY7Cel241Olu84vtfqG4KPvfEeZLfcClJs92+vwTpzQ+BHjaTyiljO/Z4ueiqczbsajcmWfRgV102WohHE1HzQUWl5grcuy6BAWb3YG/5w4TMFEKTejvbhMKs5BwZpNHk6WmYj4zdARiBVLm8bmJa8zH127Je4sQpHWwcAq6OtOd0YW+zmnx1AC5W3IOO9hEsV9lOWVIzO3PQ5KqE7ITi4EgKMw3s4yvG69CDRqNW6xwZJMjb6edXaVplghXeX6rkA6Tq52QSz//LWCqnRXwagHGaSyrfODeXZmaO6J171HrvoJE8PEz6Fqu6QnyqTkqhrrfvbjGs2c7ViMn64Tz6uPoXYv5W+fVXNFBL26li2Bq+G+bhThLcW1P30YHKySg2PzBxnYgeqmeAZaBW/X6hV7dssgaLyCNS6so++MpScvQjAZQ5fTcYwCZVrO9untCc9rxykACkd0KvabetdmDJIJEF4/8lCdGBs36jj41D2P2YoWnG9SoDCmR5468ufNzBGYrXPH6BUZnU2laXtSnbg8oUElQ+Pyy/56 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)(136003)(396003)(346002)(376002)(39840400004)(366004)(508600001)(36756003)(6486002)(7416002)(5660300002)(186003)(6506007)(38100700002)(2906002)(44832011)(52116002)(6512007)(66476007)(83380400001)(8676002)(54906003)(110136005)(86362001)(107886003)(66556008)(1076003)(2616005)(4326008)(316002)(66946007)(8936002)(6666004)(15650500001)(30864003)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kifq9prUbw17oOXjSbLqzHdQ88FRDGJVywqjBqOxSq/wkNaG6S5V7rS5k0Zdid7bwbsXnlklBjg6eOoAhqEc0KaBrY79qA+d54emdCcZ1X9CmnDEHZY2jDe3PBP7bgOsvmE9fLkgEneeXGIa//CuPsmKcvgQIvPOpYsWt0QLy7DNqpIh9xDKXZzHartNB/VlquPawfMRXCS1OnP9rQ3E8f1AVUdTmMQsOCnaey0lO6Ef2JGq5fUKiS0MJZ7+Ld4w9Ek6IWc+udI5xP6OwQYu9wxSRx5Hm8rN9fIA04yhUKI6f/tVdCB2aiy4FRpo3phpDfiFKD76BaPP82QCespA3ekPRFGlkTacv9WHk8b6pho0DxadEbwTiRylpo/GRzw9x+fRd3J5cbV9Hn8QPQyWQjN5c0u3jCLW0G70M3V+AzLvGub77DDhXI+B2DKO6HLSixdzSfMuR19KPRU1wEtHqGFsV1e6gp0tOd/ZnfavIt941dnnnhoaBIaOceOjxQHFv/bNwJpp2n8RjezS+1faQv60nY5L5IOX+lFfaPJh9BEwcTZOyujPnSc6KjFzAo4ES5UZhxqxSxPoMz7JE/+dp/ej8WtGoXKkHLrnN6Bz0RzTXmVslJMhl+/mdj0aUiKcQeOz2jEZqi7S/BbeTYSVhxm4592wQOEIExpZFMTLcPe2odKThZfsFWJW538LUisABjpbMxX1F7AZ4CKJ8jNZILn8tbvyg1ci4V6bfVnddzScDR4vuE8RIn5qBZPZBrgdBONf4cOPaN+JF49gR0EH7U23RqoMVumokT3poO8RISSejP16Kn3RcYlakD8znyRxzrOEVs6iYj4uicWYrPIonzpPjp3tHQcXx/GRqt8nvqM1J/414AV1uzUjEyW6lwRhsrtq8/UE1AIjOZ5Xr4PNOR42FM50X72Y1mJeCfAK6Erkt7btAztPSYlQ73ajc/ohqLJspGwDckg4ByCzY8do8jaYk8zqrGdIY5LZ82daNUbP0lJjhYM6Wn0ns6cvlkm7JIawCu5KVBKzlmQw8/hwHg5wyR99sKp6WQhh+XgqRMR7FNg7dMwIWMOxbUEKglO49w5VKu0wuoQZSzrFxfQTVMcEIV1sF25ARkAuDR9sHtitRe5nlEqkS7Vt14xwpjpPvzJ0EdXzY8TPN+kcvs8GdsfvH8sIhdehhvsyMtu09ftf8VauCGT/4hjvBqhbPkaW+12fk1DNw/fi8gxijPlfs8741K9NSjaF1CXoL+wfHY0HbCqfH8Mzh3XUqna6XJ65SnZubcwhAiqpYfazwgxzDR8Ci77Y0MOCSDxv3x6moUKo7WkGNn9iz/GRjKuLUrOkmfl1sLTSAylebuVF8ECwVVDJHMVT5PattHsHT5EOeTxf+SMxZqN1MCVbWSr97wMhATZ/lmUhQN5wpEEE8JdaS6HBb5PAChZHsV0Ks7awHNhU6bH6KwczBXJHqNPzz1dT68KE9l4wMZwloZjkHTf813E/cQKlVpC9naeevXQhJx51N9pb3gnn9zt3FQr5rV1IWjV3I35ChKdgleWn/10NoM7VxbI6sGJAXt9WbDmMeeWT5xlOtaeVz5KjuhGx815e7JKxk4fVgcog6PzrJyDguB5RB8M0lamtD6K1a2uaOM69qOy4fIdZSxIrA2e0sk7k5K85JtlKwnH/g3d2lDtc6Jf0dLUnv+kygnHGNo08MO4EKubxMW2pfgGrwd6A3PNPwecGAWHswieKTIV7w3gHqQ== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86769d6f-9b32-4c46-774e-08d9c1898db0 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:17:58.3270 (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: NSSf8vHg96SEg3iGBn6k6eP7X956cK5qjvFw3+ShT8bhVvpmuqBuhj5J+P3hW6JfigqkSj8921ebmTiwIR0zw3WD0IN5ju07yg3UqPLNr1g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 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 b32680ad75d3..99f998be2040 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 18:16:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685433 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 A8F44C433FE for ; Fri, 17 Dec 2021 18:18:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240358AbhLQSSW (ORCPT ); Fri, 17 Dec 2021 13:18:22 -0500 Received: from mail-bn8nam12lp2174.outbound.protection.outlook.com ([104.47.55.174]:6485 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240298AbhLQSSF (ORCPT ); Fri, 17 Dec 2021 13:18:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CyU3E+IwA1B8VkDALyZJEAQ2mIh29Z6vf4Cr1vKi15yVfgY0UJhnpYSHJDdvfr8qhzXVNmoVlJ5duNhyP1oLGD0ZRzUABaC/5Azn6mtdCZjUEFO8NlwTMAkXVNL0hrjQycR0wRQJbgR1hb1aUZbyBZpq5u7FI2KcjhiTkgy4kbFQ+SYQC+EzvoUOWOtNdVugNBejDG2U9uR1qFhs6MhnsH3oP9q2yNGorfdOSE74Lw3yMK/SyibefNuLM91vk2yS8z8zWUJO69HTkCQ2svrUWM2WzHeQ1FkRwLKcoThPBCtygG8uR6yb88g9J39LY3GHTADk37QjWRuXwdCJnWRxVw== 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=NPHztvF8ZgPBGoag2dwgHY1YHAh4emhDGws5pBrGAI8=; b=blacVd2h0+yRWG0GjFjYNY5zRnk9Xzvy8A/TohK6A1ichdYtjrmgaaeVE67AI3c5HakBb9qRMvdDyz5qbOJOiIDOjU5cMEoiNGcoU20Vk/n53g6wzSdBf8xVAJNr3cDSvPo1llkSJrG0XFCIPa6OMMCkXtDLJyQFPsZet5d3j9MttEenMhby9BAKtbqv+iS61uz8wxJF0xXJRfCCKAooMXycsfBTP/n/jm0cnZaCEJK2IU45fcAYQGEnxmaYPipWe6jfWPwx0a4hAon/GuuRXUgI58teVk+KG0NIT916wNlSzeHMwJ0d4pPdaMpHYsIqx/s+z8+Jqv1ke+Z4TWZKnQ== 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=NPHztvF8ZgPBGoag2dwgHY1YHAh4emhDGws5pBrGAI8=; b=L6DB5YWhZ9Jp9iVF9QseiR2b68Ry2wvrIgC7bNxE6rjkHS4dpGr5fxbOm21qAdoVV183RJlOv7XCyb5IFoSMjUbQBag48ds8siW5HxhVR2rHaR7FHpsZQAyrIiLDDXsonoUGCjYSRw+ppiMOLUhX7B/7sSqdrjsPa9Bd2cDFy9o= 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 PH7PR13MB5502.namprd13.prod.outlook.com (2603:10b6:510:130::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.7; Fri, 17 Dec 2021 18:18:03 +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 18:18:02 +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 v8 net-next 12/13] flow_offload: validate flags of filter and actions Date: Fri, 17 Dec 2021 19:16:28 +0100 Message-Id: <20211217181629.28081-13-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: ebfcce2e-5289-4093-15e4-08d9c189906a X-MS-TrafficTypeDiagnostic: PH7PR13MB5502: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: RNY8xYVqN8SzCruKB8RuXUdde0eMubl6fARBzjN/WP/Y2sQv61gELF4zAAjsXf3vGuQwnR1LuwuB2kQY7O31Gh75yqYGniKa8NyZqP5j5eHHRmCJW36o2mwHVc3dXA7teE+mjffpdQQj+uS4nO1kL+TdltJieK+uXWqoRb7Ltu4dDTJcuskbSP48BeZcuQ9ZUc9me0LVLjc0g3UN77iQV8un3a5GxZuNLmsWHdEPUF7FCWET1hZVYFpHXxPBCmmyeiybut2HhY3603a9dFgDvAloq32N1X9akom3rpBWk6TazPDBnjx6yqeNfKxLQXeogwMME+olMDc9GyiawGGcD94qJSt7lS1ngTiF02GEdbJuggLux1SSpbzXwzFkhlfxIauXFsCuxNJkdzwzN4zd+TX49B+qWFuEwS/1eH+zBjMSCXDGTw0ltyMwMQO/JZUlTlxZThIvX5sD4sG7XTzTQStUZmJID+CtKdVcbcWamSVdNVYWXSIpvtSU/qCmTUwVm752VZ0xTbMS35okWRNkoL/9d+fDMPzkkvxbOHe/D/DsQQppeIwd5TWoeaVhFdfPBSIatlZqzE3Shgxf3uux7sq7VE9tAxP1RruKa2H/knndH0k15z6mYb/Zr/3XgusflFqLTQiaOTy+BOQElxtjYg== 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)(136003)(396003)(39840400004)(366004)(376002)(346002)(44832011)(54906003)(15650500001)(66946007)(316002)(110136005)(6506007)(2906002)(36756003)(38100700002)(7416002)(4326008)(8936002)(5660300002)(66476007)(8676002)(66556008)(86362001)(107886003)(52116002)(6666004)(508600001)(2616005)(6486002)(6512007)(83380400001)(186003)(1076003)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: q5zn5G1vtc8h2AZwcbswSrxYbIEojRJ/bVORBiIgF0d9cXCyEClJ7adJSyLNb5vGFwQj/av8qik/TynKFkHrKrJgcc1Mo0e/sD+ey2Akvb8nxinMMQ1T+BzHoxFVK6geXH825i/xu3P6Gf1ggcvlQlpQrSHLrFfKfHoPBlW0Si3knqli0Dr56+FtGj53NeKCZuHzZhvdly1A7revEsTDNCJDBy6zwg38/f/2sPRM2Z9ogmNt1bO6zOqzE7YqyObZLZCcOxrGbnVQSHq5D6nJIPshEuCv7fZJKTQvrbWIt5XZysoJ92R4v0Z+IULLw3f5qEPCAng+JFhzR1eKtj1njzxpiiduwjuTsWkiXdmMrgqg/jMj9111ouIWJ1AWpVll7On9McIjlvADZASFKHgfVb/Fl0s4FDinn2/n+fGccwMws9y4PuPdocn3/NZGXWP5/cGhBfUXsdB495+1NME6pMLDu90+GlI9bfa2f+yJ1UE/G70lsHg3V22x1TqzqmGAAIIquHQ3KIFKwz+/C+tKPdVnr9kb4hoqfMZPs1pOKc4H8YD1sVIdk6yVpksWH9fFiAfdR7pr0PYv6c0284O6uVURUZJeEYwrwGrkCgXrUtozc6bLV7kKI6LctqTULTRyIVSCN11WdNzAxiBUUB+52OUY/1Gmz/KE9U8PqyvazYigXWc3jaNMT/SAghVqGt3Ey/z32yfqzyg+JMAnRQdxiSr0wrgBROFyt0ZjX9yNpaLJRqq1TfPHSlDu9SARj8VNBlwp8u3/T8vc1Rj4iiAXEEROWPhBqL8VvDKrRzfuPLD5x7MXMv8a28M7AzYH+dPuvhIjlnZqyqaCbRjs2fCuNuRN137xkNYnbbU+cGY+Q6IUsv+FKKqBFiNuwmJNY6yndTJrnC0y+PIeEUmu43VCugKCwNQEn9W7tBl+COOpdi0IkIQ8mOzMo29CApKPhJJCQYBxDDpbY9/9jWx4zjdasmhhgyBbPlJzC6FCu4o6JJTj5FfBSs7nCVVN1+NPCkE9St+m8i1hns4B6q4YNEwlDqV/0t4g0tmOuPHAbzEJ92I8DIAVzvNZq5Rd66lNKu0TsUHSlQbVKsxaOJSJcSJjkvXAJvzRzq0EzV/1ruHaklDuGqS1wFFu1n+L4HOV4KzBxN2aRS0rEPUi6h8GTPlcrMr/VuGeEiMcbs7WxMEXHX9hg2WK7JvzpwtDFIukyOTTZRriWojcz/ffRFSs8grWQPxqYlGq4xkzctOZn0qsEoW7FfBStvLRSCiab9AwHQUkSgCUXaVTSAcTyZ2rHz7LxL28wsQVVcFnkZHlRyWL7EIR5OCzHPW7KN/nKdiPIeNJvOwrxVqLc1XgcSMKwClMbIiHtcmTl6OpLgsox2Can0S8M0wrJ2/CgU0eEjGd0dbc5Uncnk3FXHRHHhoUadtZ+pipjWZOQr39hYhmsIbkrhlO5fa5twsVeVv4pAqHbdLd4H76bmT/Qg95XiJGIDk1jijSYtJXmeagH0TiiqF6jHfNZke8RlQYZIKrlEDRuwKSdGMMGCcenQ18XnZgLp4BV+2fzGzh/f2/v1TcRt/nItRtmh4UwIWx/xLQDNjQB137o1HTsgIRM+ES6wLt+x2kFQsAAMX7rRgfX+Js8KFdcEk0rtbiwLU5xQTN3jWQzKt2iQ6a5TUgLUvzk+jxMk0F50G+Xre4egGN36M1K+ZcpLB8Py8lu3vVVh3nPycadWczL823xSWxQnEIKFuotUB0Ng== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebfcce2e-5289-4093-15e4-08d9c189906a X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:18:02.8890 (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: ub05D29dmwVTBeiT0ckisKW7ApW++WsqecCYUKksBFz/rR+cfeXW7+wVznHHQ6fWWmpC5u2gpnFyIAyFh8tyQ09sOcBFOzpZzmohmSBqSAk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5502 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 337a3ebb4666..ebef45e821af 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 99f998be2040..b2f8a393d3c5 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 9a63bc49104f..c73f65738ef7 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 5b9264da46f8..ca5670fd5228 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 18:16:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12685435 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 1EB53C433EF for ; Fri, 17 Dec 2021 18:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240362AbhLQSSo (ORCPT ); Fri, 17 Dec 2021 13:18:44 -0500 Received: from mail-bn8nam12lp2174.outbound.protection.outlook.com ([104.47.55.174]:6485 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240302AbhLQSSW (ORCPT ); Fri, 17 Dec 2021 13:18:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PojvSjO7noz5ytLnJ0ZRPeWrZYo5JTwf5qX1DEW2R0kbu1xPdpUkcnZbOA25soBbtmTrrvVx6CEYR1Gqjyu1+FUzglOW0xIDviOkTa4xMFJ+B9Ybr/gDU7t2o5eb6wbpYT5sL77Vv5Gw6RD1MA7o/LlUA9/NPL4XY600VXpkcqSepiWtVXlEioiIKr+dLigEMFwjI6xNhMziLV+WGQEZShmGdmDY6JeB1chE3wnUg0sqcLUbE2erQAf6WDPlt5s11PnAcb6/wZpMFb+kxJj6xbRYJWGvdfkqsnEV+qh/0chRNLaC3Gclmp5EmmEj31kg8uiuzOoIEur4XK3a52Slnw== 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=oVWkFgG/FkMeYMYbSQUwunxMFy/J+mtlqBccoXQtvOh82zNcfW4fGgXpK+7gYqE3AS5vM1d7WqQFUd83ih2UJkyGZF8PwcLtBafoKXtYyjUvpAjtLU3oAy+JcIuJA/RtSSB+Dqfh6CXpER0gFyGW0tXQjG3USQ8w6z16sUgxwogqfnZ590oE4qAPzaJpkNhOOJD9qEmV7P2cI/qjZhh8LObS9+9cCYS3WmxVLj4MBwMOQql2kzC4wPT/4dKXv0HQXJ3Xdj0a6LOn8dW+OZlilrSE0uz1C9jBGQOchRSEkuv/+mat0YURQLJGmgFwMCXGlW1OItlgzj/Gphzd94rOuA== 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=DA/FxhIwYfs8nJjveIcAwDx8JX0QfTjzrwMnHDLVZNXDU5niBy20EfpIvPb1GY+qvnyMPUG57h9CZjc0vWvKnB2siIgWWVGcAWt2ewozt+mECckRr731ntjyKEBRevSAifuJ3Fk2XmRxb7z/90hA911ASv8MrmKyN0FJdWWZuac= 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 PH7PR13MB5502.namprd13.prod.outlook.com (2603:10b6:510:130::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.7; Fri, 17 Dec 2021 18:18:07 +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 18:18:07 +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 v8 net-next 13/13] selftests: tc-testing: add action offload selftest for action and filter Date: Fri, 17 Dec 2021 19:16:29 +0100 Message-Id: <20211217181629.28081-14-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211217181629.28081-1-simon.horman@corigine.com> References: <20211217181629.28081-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0097.eurprd06.prod.outlook.com (2603:10a6:208:fa::38) 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: 91df205b-7957-4c89-4428-08d9c1899340 X-MS-TrafficTypeDiagnostic: PH7PR13MB5502: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: xqxGgkzqs/UobMYCakOPiGGTETkRtxA1hpEZsOGJk3gV/jUXHB5UKnGDedwt3G6F8c2GUp0pEao1VVw64I4hCnl/pCC8846oM9CXfkraPK+y3Irh099KOTOHv9uVcb+FVzYcSc8YBz8UMYgOPF3XMqQ70qQT75c/nlT28eTTb4CHpJDPvV1vptBj5NF0ZGKttFfipN0SBSzhGmXknlerFm/NnnaybANo49E44oVB0vmxePGTx9Wxd58gAMppCwhcBLIEQ27WFzaupVATh7QgUWUlFv615u09VFGpe7E5ujNpdctPr94SJ2a+yazUQ5tFplLRumUCvh3YkVMeV6d1yl+pnqPUB/mucDgRKXTb1/8TjAVwR91V6IKlMOy/c90UYsthwo+9UTYFU5NHH9ysDCuh8p9TW7kFxmp09i20Eawc2K7ipVwQ3jwTIEjPCmZYcJQhIEynPayQzDrsPTEvPCyQxSkWSYnnXWBoF4Ry2LHNUb6RnWWbABvp6z5bvXxm9d83DFUeWEdiOSgCwwub2R0YrHidjMIxg6aF58dI6vUmeC2TO1JjVmvIMDd9a5hIu21I/4i7f3M+kBfSAcxEz+96Hz20C/PWkEJ5kc6rqvmwMPQcZ3C0WkpHvsSn/l7FZm3lT9Crox06qfLdKOOd/Q== 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)(136003)(396003)(39840400004)(366004)(376002)(346002)(44832011)(54906003)(66946007)(316002)(110136005)(6506007)(2906002)(36756003)(38100700002)(7416002)(4326008)(8936002)(5660300002)(66476007)(8676002)(66556008)(86362001)(107886003)(52116002)(6666004)(508600001)(2616005)(6486002)(6512007)(83380400001)(186003)(1076003)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y3+TNviyoo3rt3poJU+qk69J0q7m33tRGxtncMwfyjSVAXqPxyVszMG63xbNfMo9yvXXQdaKsKzBAGgQdyL3YoTLYLaOMVs7lD25btikNTJdBLCGl45FGzNiiDvgZsQRGg/0rDErzHlWsM22sM5L1ediZbKdJuGlcq0ElxpJ4Yk3Ho3A6mU3RHXQcGFzmdDGBo0Vl1me9KBSy/lBqsrIqYxGG+17Ijt1EwCwJ6/YmV0C+t9D8wBVh+JUHLjKftBnYyuiLBUEiJuKQ1u226kcuDTPhA4Z4Z+FMwruXfXJO8OugRpaPJyYNcg0/cHxQL+/wBHFVL3qEUG7PThP+iA9+B23OFpPzqkzj5gHtdP+kH6Xyzv158IseyFPc1/flWE+IIGl/2WGrC4oAyUlGjjDLLpqnYWJRfo9JFHkQqQM92zk2yBYcnJmAOTNg1dY7wVA3grXSLF5wIqVADdaFLVk/ZOt+reVTawC6LYWc+7dZk6agpMFzjygl7QTT2llkK3LWLgKWF6sjTc/UOmninweDzGC7CEcNZpAvUc1aGpSzcfSREanxpuD2okFp7sIDR1/TmpDinoHZoaegX9PeWqLnKFMgSjfT+o/AzyqSl+eBb6L3V1ZBwMStYdQMRvDZFKJ1wAz8szy4F3l7WqP/NU9u0DxjY0VG6naarbqF+LyBylS2ZJU0kE2lvSx6sFmfTE263kZHn7oe8UqKUvQ8yHrrgHFULyEEra95MZU1gUbsPEykaoeaw6gpPRgCpYhPwltUxcCSh5JBkECeuPtW7jlvAL1E2SFmz6z4VUmuMajEN8+iqlL8bdTTQlKWloeABQsvAQ9EzSKg5Hf50p/se7OdBZp3kY68rajHqII9vSlAra0Xre6OO7zMjHFbwQhX/yKVrzobeOy/XftPTbDjuvQ6KkBs8PuZJRwEV4mJuKG2tVyczz58nZDtmXZFwfA4RJ+2qMbg3q+2iwPX2d0AE0qhKHp8e3oDDHVkIYRooNB0dENywk+WNPlP4tzU+3g+z7+CMBLfTtF01quGR4fnAEBhYJAhAKsu5ZrQ+Hi3Tc0X7F5NwK+cGD+5j1L6lmYKIsx0peXRb+jHHCk48PcWs7lg1nsKsphSjAK+QsKbcUCRnLShlbb+EXXUWdBkeXiOQTuyrmi/whUR2GPkeXzJ9K5h0PjqYdFr7b7FGobOOEW/2hhbrXzBzXltkIUQrCtoFFp57O1U+b9/IlLbrQziuA/FDq9eWBQ2HiElV/Lfuo6CHh1yDAalN3YLcYiwIE90u2KxagEpDAcKsCzUX8PyEW5jNQ0Dn3wqwJR3fBWvfMgsYW3Ziyy8rgost0AYGhwKx3Bvjon79alWJhyC9IdxjHynsAANlLMfh7Pw0zqOq9IqHl8E31dNx3Me1SMbc0RWEZCtIJf3ry6AqvUkra/19U+AZ05BjW8u9vS53Q9fowR/BT147kyUDNH6VVkGog+6tJL4LtCJWDixN7yyh0wHv6rypcttMjP8ixCl7mjkizhWgblVkdRgHRqIiKpH3bJYmzzERd9xOsH0dvx4aJAEXIAUM6mh7xBbGDpNPWgVqEhgZ0Uqootwff3m5vSbtXWmVV/SmgKKP2bKzxqsqoDAg1BYL4iJ+Fe1KaD6a4actp1TvSok+ua9F44BhlfEJvK0v9u2bWg1NC0J/SnZsuDYNxvOx2zYmWeqiGBW54I2RmoDrFbzC4vUmhCW6DUDghRrmaHnkHrZAtbNola8245Jjq9Jg== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91df205b-7957-4c89-4428-08d9c1899340 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2021 18:18:07.6511 (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: /nD9ZIKRGTuuD0panOvMYNBeLIJpsyXQK6Z4e8FcfDZ/wI/tFYz3dsZFgN7pR/thak9qRoT9lBqBsiaJPY1uXZ1cgBTjJ1M+M0BO1Ykp3bI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5502 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" + ] } ]