From patchwork Thu Dec 9 09:27:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666203 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 BFE86C433F5 for ; Thu, 9 Dec 2021 09:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236163AbhLIJcG (ORCPT ); Thu, 9 Dec 2021 04:32:06 -0500 Received: from mail-dm6nam10on2106.outbound.protection.outlook.com ([40.107.93.106]:50465 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236292AbhLIJcC (ORCPT ); Thu, 9 Dec 2021 04:32:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GxkgP5x1gC6FQapnO5t8xG0XEVOZ8oOASS6vv74ydJZ2BjUI24JtWzQqQoQCVlZSICjgqHg4c5zDhL6Eb5wzyD4+L3ouFyvzTpLFjsEFFkBB7L7eUrDkKljYQ0qq2N7jgC22lnJLW013Cbw9JLm0uu0N0dFK7P6VuScjrNtAnC13+c8E7dONxaaD8dFSbUAEZg1s4A9Kuoh6yqru3rCYNzaRtP1DnzzYmI5GDh3s8mt7z7qYl+Ou6PhM5cdIcMpQneMrWEQMaAfqRcop2eyQKRabRbgaUF///ZK9tTo/fACggHY4ZhvIvGqt57+ku9NhJdrhUKfr4hXS+tbEPKPeJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sRp1HCPVPqPJU3OHFquMchwhifHi9LhY7LZW7gk03f4=; b=TaoxnMEKmn5xpdBPLWGb6INb0FgMm0pJOzPVELN2yjT1v81EqRBN7s/QRgJGKLaRSyKwnxLzQRfask5SWAdntOTlR2sA9ZLyFGrZuV+cSRoywxGr0nnmeQ4CfNKQP97Rswh2kOxk0ERK/VoV2qnCgttmUmvOZ636i9lWze/2StkVAsn1L/stIJDFb297vbcrFlmoD95ljwE8Ci9XSaXnQhW/vWUFul/2mRmFLedlesIA2Wrh7WrBbQ6NsN8hjNtBJez6M5bbg4DB9Gq13MRi/DkKquarIQHt9pGmv0w8FGIhuZ93K17Hgkyd19c28hD5ionbGofo+aGzS/UVAgPgvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sRp1HCPVPqPJU3OHFquMchwhifHi9LhY7LZW7gk03f4=; b=tptWxbGx6Ok3CErA8f7qAC+Bjgz8pnDtb2WqMaBZYTnTRzp1QEI7HHGqPYyit2Kn3cgTlfzNIyGs3QDe2wcLDMnZ88zyPSy8vGRlKJ2hMOAGvWM/NmB3BAOj6rloKaO2mIUdzzDzatKiXi7IuYDVVeFKvnevEeZYk7iMHdETdEo= 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 PH0PR13MB4796.namprd13.prod.outlook.com (2603:10b6:510:99::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28:28 +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.4778.012; Thu, 9 Dec 2021 09:28:28 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 01/12] flow_offload: fill flags to action structure Date: Thu, 9 Dec 2021 10:27:55 +0100 Message-Id: <20211209092806.12336-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: 27590a60-0fcb-42e1-e77f-08d9baf641f8 X-MS-TrafficTypeDiagnostic: PH0PR13MB4796: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: cWni6bv/46YZaDqTK+z4FJm4tcGd1EOu4eMVBr+d6oyccdwYs88g1KJmXj0c2uA3caUH5dYOrfZZAYQo1zE/jeCaMp7JyyM5orC+Bkynl2xcXtINgUA49DxVMMw5Xkc2PH0QmxFTCrIEPmjLKOLp2ynt2GAgzRlDYwMxZ3o+UjZgzzPePPL7LDjw443UVSC7s6F66Bqy5xHn3bcrZkXPF5DKL1UWFdu2jDaXkzSey2NTHYafGiuyHvYgu1AJ0il+3z1q/aOa6Ndq+nzHry2/OKm0Wlko9g5ZGByZ9qnDra7DxRqVh00AezVFaNAmloj55N0WGvlbZFMV7cJc+HXZcdcwmlJ8RGMnO4mydyI6anEMsqDVm7bboxQ0LOXvBi1s0ztvKfgq0VNxPOU/adzoPsfooWsEr3tA9YFZO6bqe45k+v6oMTXqC8SSUKZ87DHpQuu+ZNkx/NGPkdxsTnjjbIbpUp5n8Z4wfxZqlyT5HgaCMGWRLjxyCxs3BkBTXrqUnecjx9b4BYQwHgSVvQZhFq4b1MvhGU/StIi3Jw/Uwwg+Imu5xcy/a/NeMUa9yea+lyoEz3Tp1ZFRTubLY0chs8mwjEGVERhAs9myQfYh9JSJh81+CpBWTMNecZz0IIaIDjEphnpmt0E30Y+7aZCi5uFDuGr38LOx6YHftz1ieV2Fv3wNS0H3qOodOIfmQi95 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:(346002)(366004)(376002)(136003)(396003)(39830400003)(83380400001)(52116002)(8676002)(2906002)(316002)(4326008)(86362001)(5660300002)(54906003)(186003)(508600001)(6506007)(8936002)(44832011)(6486002)(2616005)(6512007)(6916009)(66946007)(36756003)(107886003)(66476007)(66556008)(38100700002)(1076003)(6666004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YY7AbYlIMazxtApg0GxzF/TTR+7i/765Cmx7pOOfg+/Pn9I6rC43QocFGBBQDh8wloE42BNmhe5ZjNku//tKjmyZ1BXMRVtmhiyXi+fcmfE4m8NoojOPzBNT30ipZoxpxgQgcGlmN8iBD0eITEzSmXff4XylKLTSj3Z26xenl/+3o/f9slqvaDWvHHwRflDevQMPbdSxzPdcLkgoQmWn8FfJhrQkS34Alu3RCDYK6BySlUdfbDOu6FAKZ2Vmn85hqu+k5vSaRm10439O7dx4drZBdt5XYQe6GLOUrLi7GFkO2DvzVijZreN2NB4xoW/sIwkCr89dgMAGXvL5AB0bmPhlbZr+5bvHBcUuVxJog+orecO8aRFZWbsFShUrNBU9zz/5vzoFc/o80W1Fd3zOGqYYOKFiP594Ij8vAU4y7eJ0H3A1X6VGAUPQT2sN//VKiZZDC/duSU4krVoSMilaE2LP1FqYXz/KR/KEfPK5RrabIOqPdsoyZIGlliR+/0E4p7Ca3qeGUw4/ShPWZTjCFg6l/ozwhfzUeSZpwhh0EwbT/dlXkhG0jAQEPpstAeqcyvAoWPOJD8TE4NsvlQJexuLYTNvsx6yZAcevpdIhaNHC2lTQG2IRm4dAkwv0cImRR32Wy3MKQqfYDg5JbSHGTHfElRrLQfyiG8lY1+GilQv2rENex9LX1kUle8fROkAk/YBmLy1Ul15QtIlkfNfXNdgD9KvQSBlCYCfAlE6u6pa74c+Gjzqv3KyFEAu+NyTzJPdSoCQSQiT4oblAJjluQ9sOLxCuRTlqY8KwDwfTIoxgedaPehCKJd/4+8+yDislMTKFTM6el1mIFMejQoHDitqdg6i0gkgD0OaRIha7oFfDU8JeZ+TW/PUNYc7KFB2qB/hp002ybxCVjU6KAVmcStGEVq2hB9+gMP75Nb7bVRSpqjijQaP8rx0wd90/iUoGwuSYLHPlqgYXFY+JfBLZNSEPjYiwJ5infStVaj/DJAD3wUbkXZzUprH/STDzsltgYjm93HfXTes+Z43Vk8HwxyHWuxqlGMolvWxTyhcMYIbkUpD/qqRMGveM13aOAUL+59xkDaZe2nCnfC9YA/5MEo0J2RlvYTxa96D69+H/cBNmt5ZZNrbEhyr+5VzhF5r231ogSiExmTuY9r0og88YqaKnItEtEF1+atf94/ConHegdBreODsCAr3LKkRMeY9veyzneWTGUyoMiYGJ6nTvzvzk97Vj4ni2QIRLfI/J3ECK+bcxlhWJX8/IGwXZVuftifm0MeFYqGfgIZf4pQ0O6enU/+nvKMcAGRIo4pp4gJL86LXCoP+vVFZlCxpxsy5fQ+g2nZm9ZpvDlSLuvtfVQPb4hKvkSdUpb2YBK9TgSUPURlXqLIEPx6AHo6lh1vKrg/YCUwmwwsE0iake9oKnopPEK7pE/ULheTHkQhdzsu2cRbIeQlo0ysegAO2hxz9UBaLRUKSg2GkXzrMDlI8Q9kH47/kZk0rro5npVLv0UPvtRUDBC1GB0RPeMJmYrI0Ygu7ysQd3mCLzOptdkoEtM92SjRIoFybLbB3pwYTL0Zv7rfeMDBTfX5dOZW2lmxtS88KoYB19JpyJtgJ6AX8aelycJOQTEZGgIKUYoRAgnmoS070z4mRZjFP2VkRievB4pSqKYNlYgrd0szesgDOfrSQwUzg8D574oCk5Y5Rs4Moh4cfoO60BSyFMWFop+bXtGsmE5qdjzsaoHTgpzVPCA4wPYM7wKuDWvrTvpflL4Nc= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27590a60-0fcb-42e1-e77f-08d9baf641f8 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:28.3826 (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: t7uKaLKQXcWe4MfpNkeMgwkI3IDdzDUK7UAKjm+u4hsW5/WeDu1SFjSC3GpAtBMEx6j3fFNxOidyXKSgmAcf+KK2FaYgeZ3t6z9C1rvv0Jo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4796 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Fill flags to action structure to allow user control if the action should be offloaded to hardware or not. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman Acked-by: Jamal Hadi Salim --- net/sched/act_bpf.c | 2 +- net/sched/act_connmark.c | 2 +- net/sched/act_ctinfo.c | 2 +- net/sched/act_gate.c | 2 +- net/sched/act_ife.c | 2 +- net/sched/act_ipt.c | 2 +- net/sched/act_mpls.c | 2 +- net/sched/act_nat.c | 2 +- net/sched/act_pedit.c | 2 +- net/sched/act_police.c | 2 +- net/sched/act_sample.c | 2 +- net/sched/act_simple.c | 2 +- net/sched/act_skbedit.c | 2 +- net/sched/act_skbmod.c | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index f2bf896331a5..a77d8908e737 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c @@ -305,7 +305,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, ret = tcf_idr_check_alloc(tn, &index, act, bind); if (!ret) { ret = tcf_idr_create(tn, index, est, act, - &act_bpf_ops, bind, true, 0); + &act_bpf_ops, bind, true, flags); if (ret < 0) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_connmark.c b/net/sched/act_connmark.c index 94e78ac7a748..09e2aafc8943 100644 --- a/net/sched/act_connmark.c +++ b/net/sched/act_connmark.c @@ -124,7 +124,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, ret = tcf_idr_check_alloc(tn, &index, a, bind); if (!ret) { ret = tcf_idr_create(tn, index, est, a, - &act_connmark_ops, bind, false, 0); + &act_connmark_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c index 549374a2d008..0281e45987a4 100644 --- a/net/sched/act_ctinfo.c +++ b/net/sched/act_ctinfo.c @@ -212,7 +212,7 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_ctinfo_ops, bind, false, 0); + &act_ctinfo_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c index 7df72a4197a3..ac985c53ebaf 100644 --- a/net/sched/act_gate.c +++ b/net/sched/act_gate.c @@ -357,7 +357,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla, if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_gate_ops, bind, false, 0); + &act_gate_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index b757f90a2d58..41ba55e60b1b 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c @@ -553,7 +553,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, &act_ife_ops, - bind, true, 0); + bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); kfree(p); diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 265b1443e252..2f3d507c24a1 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c @@ -145,7 +145,7 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, ops, bind, - false, 0); + false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index 8faa4c58305e..2b30dc562743 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -248,7 +248,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_mpls_ops, bind, true, 0); + &act_mpls_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c index 7dd6b586ba7f..2a39b3729e84 100644 --- a/net/sched/act_nat.c +++ b/net/sched/act_nat.c @@ -61,7 +61,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_nat_ops, bind, false, 0); + &act_nat_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index c6c862c459cc..cd3b8aad3192 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -189,7 +189,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_pedit_ops, bind, false, 0); + &act_pedit_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); goto out_free; diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 9e77ba8401e5..c13a6245dfba 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -90,7 +90,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, NULL, a, - &act_police_ops, bind, true, 0); + &act_police_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index ce859b0e0deb..91a7a93d5f6a 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -70,7 +70,7 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_sample_ops, bind, true, 0); + &act_sample_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index e617ab4505ca..8c1d60bde93e 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c @@ -129,7 +129,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_simp_ops, bind, false, 0); + &act_simp_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index d30ecbfc8f84..cb2d10d3dcc0 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -176,7 +176,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_skbedit_ops, bind, true, 0); + &act_skbedit_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c index 9b6b52c5e24e..2083612d8780 100644 --- a/net/sched/act_skbmod.c +++ b/net/sched/act_skbmod.c @@ -168,7 +168,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_skbmod_ops, bind, true, 0); + &act_skbmod_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; From patchwork Thu Dec 9 09:27:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666205 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 C8B8AC433F5 for ; Thu, 9 Dec 2021 09:28:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236224AbhLIJcM (ORCPT ); Thu, 9 Dec 2021 04:32:12 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236165AbhLIJcL (ORCPT ); Thu, 9 Dec 2021 04:32:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CIMsO0SZ7deBctN/IPPFXVL+gjBPLeHIoakXVmbDqilEP8tEAtDPm2suc7qWUrKhpUsrrXB5Gt4HRP8W1KqiY3PbXIzvvC50BnJR6r5Cp7me/V7cRbFPIBXsgqin0utAUoNdooQjPGYNyqRb5YraFZJaydqoVhgC6DQoXHpoPS/93dkxMD4xcHTrKOn2qj+9P5Hehpiiu7ElYFwqkZ0+rHOoeG1BRUriheiTdKP1Us6pIqklzEN91fMueFfSpyHNLjaZ7eQOB9hewnZyptlhPir1pXS5g8yD6QktG6vL/GjlVPj1ERiYyvnRqhQvx1xetqRC7FiN1xS/DTPX5myVQw== 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=p8LLQp3zHRSWSnacjGf5qSBjctEdinbafUimocvkGnM=; b=IERfHUtTMUOqVM/vhZMfcKJD0mrp7u/Snst+BXioSqvfEGU9wkqDNGi2TQVHbXdQlAXFxxIDIVcLvybkiTTvg7lkTMZnqJhR0iUaqRgh0hsnuSGbmmnfhzJBsHzHal+HFwRKnjPoYI2hQ8XnDBKTzIH5TQkP3S9bEPVYUk2a9GafuBEL781MpS/UYMxtdx5Za/aBTSAGSTHLJmVg40WzW1NnW7Dq2vzz4DWyuLL0BzcEwzAVX7QA46e0QCUOVifqUsJgs3AnBXllaVr5Rz8w12UJxAdo3Uvaj6E4IzTb4yebQjvKR6B4e1H/QcomIutzFo4DkodTH5J9mjYHtH9BnQ== 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=p8LLQp3zHRSWSnacjGf5qSBjctEdinbafUimocvkGnM=; b=LTy6aQy1mnJlC/2rfnF1f5PpEY0nGyCQjzFEkDiJTyvkPmOMN3EZgPkbhwbN5VjUmw82V80qyCPqXymBbc6INTlyiWTcY/yJQIK2VsBfsDJBMaZTiJpLV3C2z8kOYB9JniudnIds7+9EmtPPqBChtxM9MCbQRRv8p+zOU2Rno1E= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28:31 +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.4778.012; Thu, 9 Dec 2021 09:28:31 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 02/12] flow_offload: reject to offload tc actions in offload drivers Date: Thu, 9 Dec 2021 10:27:56 +0100 Message-Id: <20211209092806.12336-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: ad29b60c-0328-4da4-8c15-08d9baf6439f X-MS-TrafficTypeDiagnostic: PH0PR13MB5494: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: ySDxlbgUKWU60mr3p3XQczGSwuOjTRhQX8kX6lQtDOylj4SX5+AjrihBKnTMYJpkS98yPqzSc+P1hxtcDs4LNOMFvRFaoYiVVA5q+2mVUOKR6D+nx4jXRNgfsKSLH/jnNbCeJVAfn2OFXyfSTSTKNqiAY9BlnLzVijpVj88cpCXhHsiYdr0Wl9b3dbtyzsqzJthfEiG4mquM8tTO3owyNBiTb39N1NBwkA1jzem2sDVM7fiwfpMljs9z0m1Bo9/vur6S/uuq92Ere3y9ODa4BbIxM6aAGIp8e9L0LVsEv4bqSnjYILlssaaa0qwHysilwNXjUox/UIsqcIlmEb3TJ35gP3Of4MZc41lB0aMJaY4pe1p8pEkgotkYzsoPdJUWsDqtfa2XSmXXuEeCyAMznR3LBcZKncekclwKyTjhrFYABnIl93HFEVUcUAHObJGc+BtMIVUSxX9VaXL6trBeK8Ba1eA8KA97etR2RLSNlzo6KSbEqe4VDdJFiG9juraf5dLKqWT+gC562q+erz/SNHKKL97S6oylPk+DiZ+YA9L7Fzh4DNTU2frvWdC7Vei76fTlxThq2RGr8Pp1C286DqauNR4bP4nyeAeGff1NOMs9ajQ1QCgUq0Qydtlpo+DAj+ug/Utg3a975tHkimLK8Q== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(86362001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(508600001)(54906003)(66946007)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e8MAw2jW0AWtiMSVRVCd6094ik1RE45cTF3oCAV1/HYjQzcJG4yUNfmR6yUAfp514IiJCMBIz6hhQJAcec5QrmWSCo/egglOnK7dYj2a5l1oHC5EOA58cUhTpGamPX+dvnJlfW/rvHaisXMkp9wOKcVTf6CCZ3E7qfLTq2o6q+ASHA7oABRMZS3yHhByEkrOSltzxLg5pbU/vKbE3HoWLTQlpH651PXsUSbJXWuzOzWgd3MF/BntDqRTwpk9OwNBL/glTCGr2TDNA2pXUnPbX7reVgqtJx2i1ZQkOdCj/J3HDCd+2x6fx9ZyWq/7xx8WY85dI4vN+rTUM82R9z8CoXwLGWPFog6FR4j6GqJwSRRnh0DB5WcYaSzJyz6XNqEHH3ctHqwmzBZLq6/0BJDoOSj1QPHwl0vkLJGBdUXvS2xJwMdyZr6HzGnuF81V7ZkFOAg8ltRl5I7T6Y99UgDgZw4rzqVsJ6+S5DGCEsNlhR4Ocq0htcRMRNvyH2waU1TLq+FC1gXONt0FGMcf9ii7W9PR50QZ0Fmld/vd4Aq4ee892np9lwAr012nJ+vctjhD1TWF56f8Vvbg/OUVCMjSfio9HqTE9EmXyJZMje5d/8nUa/vIBa2nSK2o1WoKvopHUtqmaP8gzV6FuLUv+S8WnrUJ87UFHJ9Kx1EvzIxWUexNPHbK6nCI5gw3C6JSlzMkhZC89KO8DeHzL+VgcLWtnHmV36JxVEDxadSjcc9YWsfCFe92RG679sAQ0DMoQZxZeLE/z9u+rPOdJy8XDzN6rXUrIhKQYvqZKcCrc075WVdTnGXeHgt6s9KXV/UeQ6qdP0IGWUN5lSTtdEfen5HjoOSybX1B8FmqghzDeXqUtsXHt3UZu6VgWfYZO43UJEVnWvH2Xo2HRRvc6VHufY6KzGRkQu27SZtaQgvsX5ssBGvJCJ6UfjdDODFL4J+3uLSR+yoD6zw5d70So5ujFWTQSN930x6Dx81n2QCoYEPMzocMAuvKiR7y1m+Pk/GlF+mxyqPph/aG0oLbc4Heulw8eY0ZT43tm7yjWnDXtwPkMCk4tQ05yIvO3GMUk1R4A6Skqb4zZbJBxK5gIqz8LoREU83skF1qr6FDMrABqCC0NTcKVy3JrrA/+UH7ITKXBRYFsq/vROfcuZDLhrVQXMoGP24ZtkYyG4+CxuVHw2WfO6xF5iLOw//yJTRHnCrFeER9i1G8k73u8eet53WnqwhvKloplhNkQz+PwioJsqON6xf8BWHbZtzdI2Qq8IRs5NxroWyWy9N7SO3H4rXPveLVz8nzlu8QMgkKDhmPMM42sf6j95V+t3fZoa+I3z8VSbXccdXZUcT+ZW19XeQ2sTTzf6o/2JZyrWUszQV8bhW3jvbJ+bBQ6209nqfevn5tblKw0wzuvKIdMjlcKKilNXpCWEqnNawrYcYLiqmXHxdcdsBSWTPvpq1z8a+1/X7xWm2U8IENgZ5c6glK5adPRCcWWG72lRZWiNo87ItERqNkST0DKnZIWx9QEAhZhXI7/3Q46tb4+euDj1cYJGDsp0NkLZ4bKGWZAagASIZGPNnUnzkrxtPIumFKPk8hp384kSc8rnZmv+wb+QN9nyTb5UIqBHLX0XwODEJYT6e+Hr4lKYSBGDVvdfEwcMkkeuZtIzi5qRtss8nuJoeh49O5nUIvjM2T2w3wTV3ETg50BH9+cgQAYDRbHgbGMUeY2oIKxGDZ+mJ4Cg4xSfKH2P5KvWBfdu4fCpPeV5MQDxldldF1qQs= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad29b60c-0328-4da4-8c15-08d9baf6439f X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:31.0091 (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: xK6PGBUw7O5Tc3IzkeAJwGFI+3h3oH6DiKccCY5X//nSwM7qiQCekxdKU96qZIJVk/tX+QaxzAUloKJZsJF/Ph+2tBvFc9wylgqsDrrxL/A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 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 Thu Dec 9 09:27:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666207 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 E12B3C433EF for ; Thu, 9 Dec 2021 09:28:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236225AbhLIJcN (ORCPT ); Thu, 9 Dec 2021 04:32:13 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236162AbhLIJcM (ORCPT ); Thu, 9 Dec 2021 04:32:12 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hteAAtfB32Bhp3xbnKOx4pM80NVr9K0pv4r1crgtTbPJkSyig2C92/lbSg1IrNJEvu/OULw37txOKSlkb+6I4JgQL+ABJU1qXwiJcae1eyOPjWB704fvCTaj98HbDBOZkt2Eht9EKoEc5nJIkpmDg4HjWZDTxFsGIbRiUhUFLxROq/jkFhSXXghhbNPCOB8K7WrbcEoXSGddzOmMDkfNKOSaeRMBZo8DIwT7CNIXQgtYMrvqc9jDUQSRt1pCwPk/joZ/z/Ijby5uY54ymyAFsHgK5D0SfTEjZToxrZZ2U0fu9xW8/X3OkiyGTqdCySPzbSOTRtMdhv0zafnBN2aOAg== 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=uYAphJeIrZbS+0EUgqska3nODFPf1MagZQ7IFbPquT4=; b=KDCtgNtIhQ8qIy733ArdItyJXSWkf6CC8kBH7SWxY7QqPDuMbLAhV/wcgjrOgvCGX5pCNSZZ/TgqxGfyxCni2V836TZVuqHulPLScWC9nHIxMcyjj2fTmLk7v4InTJkVWGWwbpXSP9D05yAeWiFGl24dhA+VxDy/sFTtBvAVAmQF1m4IAvM7jlXQKkJyzSTUzYIvl6oUu5HWg/OgFIs1sh7nxFtXha8L87TwFe9D1YfFX5FMqrcbQGwFqRDPbVZepjJKRJRSCW0Ntf7PLHI/CTtVR9p15BPxll3WixHmi+tVIkDcWE8YGkaLypu1rz1OEvzqmZKJY4No4QBCcACFQQ== 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=uYAphJeIrZbS+0EUgqska3nODFPf1MagZQ7IFbPquT4=; b=Iw/Q1zfpR+USp7SytkcuT1M2B6NaxmN9R5RlxD6v4ZyjoKHaTCYJ8i2jHBHVjyE6gt+6AHbiJY/IRceQ15oUYSVXJw7X7YIO5ANBODKW3xa9TBgDiYATVEAzrRej8wOY4wc3Yx5kIXeg/pZsG5K6C9AfHbUzLKxoZH5YiA4wcU4= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28:34 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4778.012; Thu, 9 Dec 2021 09:28:33 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 03/12] flow_offload: add index to flow_action_entry structure Date: Thu, 9 Dec 2021 10:27:57 +0100 Message-Id: <20211209092806.12336-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: 8b14cf0b-3456-4007-d54d-08d9baf64531 X-MS-TrafficTypeDiagnostic: PH0PR13MB5494: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: kmh9CpMJdDIL1S/eXXI00gucTkhyBZkcEr+9iL593vWI+ir/ycZLZRo5i50QyhDIL4MwWKXoy0lxUoaIDtaAWsfklCAAp5zxnpcXdofZ/zgqkNYxyujcvdClMrDzdtqg8Xq3N0ZNjJt02b1pV5abneqPxBzBMZ3WphThk55gyms+dNeG6qHsHbgTJPZPtH3lu7Yt3ChfJ2OqRRaXDVDL1ZKpv50nl0dA5eT7Doz2/f2QahFluiMe2jVTjDuuun0NmjJkI4omQn6TJHRlO98IHQq6moSmkBxS/3oPjrPfGPvUsm3C3KGdRu8ZvHVC6pbmTMwbpeviQFlc502gvPTHRCd84QZwjAuel1kNSRM0INO99sJbpPboi/dDLzgvt8o374WUaYFxVCaEeo4HnwunCMl+xs4yziOdBKnDI70EYGAa8VMV8vu3zU2S14zjkHXS2yNrJi3+LKtW02MT2FOfYleil517+NTYdHRhW/dfN5Ns7M31IhuZynJvzCv6p4Fk57e/vS9FHVpXU+hRSBz/Lj79LDkzlsm1SdXvYSOQKdugU33joFAmPW6NIOQgDQjGGwdQSY5Z2zoh/c/jHMkgwc1nXwvfW3kj3emkeIUmQywAoRjPDwvdggkXQUuWUaqRvMEOEfL6OcOC4kkFvLmd2g== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(86362001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(508600001)(54906003)(66946007)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hPPcPkkSqOD/ndLpZAajinDAuFp9QJqFNoaVuUNoz321JocRFvvEVYrTOagRspHEFT2V3+s7Wn4jUqamYCxynOtDZgptwSyT1ovE5xH5rc7XoqoVbwjZtZGKOb3Hp14YXlaYqCxm6eMC+hA5oLCTWMldyVILrcMuCUt+3nTQF8CT/L6lXd1SSxd+ISg5B9jJZNT6KGcoUL/nEajGk+yxvLAoXNhip7aXaJy9wyrpgrZPtgBf0Lf3R6eGBmM9+J6lT3df5gm4otoERHs/T181CoxvpihZ7sRNZHtqfHsxu5PPETp0+O7aZWgNKkkpChf2AySGHvO+hJovXX50IxZTz/GchbTPgj7IV10+XXNOOyE/jmA4Cqmm2+BKuNp7ue/wR8FGaSX4qHjgZ6cT2XAbDM6vE1NFspRxunbXr9VTLfsheYGgrT9YhAPFLf2EkILMkdJEkft5HFulyCy18U1JwS4BrrxTjrAc2l+mHqImiDf0DKN5UQnsl1ij5wYIrfsz39ud6+f8jwSDi534Ijmci48JEC05x4QCMNaC2WvXgcwkk+lFdP5Y+ZVOHIbU3aHsMQxgh/J6WRqTUkC1fNdBe55Pce7acckI31KmY06gDLAX2GBN2V4RPl7+uDfJtAI/DfCUxUTMYb6DqN0poIzDy11ZoI1sKyXzjgw8MLPxX6rE53ooURzVv6en0yHVEmtK0JOtrrE19OsNXJ567rr+hK8oQGGO9XSP5c9amZT/9nObj/Wu88I4sjMJoe/5052tO+j3w3fvPb1vZCPrH07x2xoXODI4tmFu8ZBLthnyflgQUXAAFhOxX/ChXPrsC+weCoH2qDbOAfSJSjSoFxH4hnquxy1rFyj8UTKsR895YxeCLNNMaFWNcS4l0bqk8+DFRpVvUznb7zXwkq1Ql3+4w0r3+JGRYP+dV8cLV8VHvuoTOOR6kL0wfxxO66+/apyUm/PuDcZZmuXJIPN9nfNoGFfOkHC5ApewJ8le0tk2RrNKGacrsCCkwrcs4rxUXqfJmK9I/XYABn79r1xS5OvECCoshOpyWC7UqDWIZ/JSAcIoMXBO4oljiv8biK05fLDFm1Y5wTyuVLUuH7wp5pPoUXT/uWx32mljzoq5XRCAQc0A+P9pR3QrEcbNCHeeWq9Y36pniRW1aaexMmlqemiWoEt7U+FIEjpsptfd6C2JkVebbasgtq0ZtD6MCzW7I6Yr6bzXgP3UhY9h1wO0ZtOJVv+OCBhS3TQhoV9Je4FA/QJpVel4AvAuaeuGEwSe16DAMAFoX9hYy9/+3dmXOB6ihw3mplcY8N7TO6vK4YNlm8IQ6QAN9nlXV5sh30YHX3YpJP68n1BwgEPDfOTrz3ItW6MmjtrmAjPtruYMOfhnFo+9Dzn5YoarimLWCYNmjDbUhov7SkZdJySi9XR1K52QBTg253OOVuf9aEx2c1xTdp6Jy3C7pMdcxNDGKjCPi5FZ7WELUEgh9+Xq155bDzPYQTNrpQOVqzyWqwwRp7tIB1JsxoirVXdckG7+1KVOT4cX0q32x40SpDDXuMa63R15RKdXasmqz+T47qzehdjOQDDddogc7RFn3ZfzEv1LAHnDkqk9blqBbfQ/AQQa3nfLEj3bYOsT0KFduEpxlZ6DT7t5WJH+qfetqOineJTY5eGm4+sKsIQ37NeI+a9MCMhVno+4U4mlYlq3HRjsxFYRHlcj+b9odI//rfMufQ4+LL8fiSq3teeAbczoiXlA3SYImFbjTKyuJuFux798GT9Tho8= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b14cf0b-3456-4007-d54d-08d9baf64531 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:33.7889 (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: AQ8iWg0jm5z82NAnA4Zb06pzWQeztSmQBIDWQTWSW2zKvl7Zb4IZBycWWnG3s+Tl1XrnbQCsokhMFXYu7729dc4EFfJi2U+t4D5n6fhd2uI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 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..8d9a8f386b1b 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->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->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..ff0b48d48576 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->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..04a81bba14b2 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->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->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->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..06c006a8b9b4 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->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..5e0d379a7261 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->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..f6970213497a 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 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 2ef8f5a6205a..d9d6ff0bf361 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->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); @@ -3697,7 +3697,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 Thu Dec 9 09:27:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666209 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 763B3C433F5 for ; Thu, 9 Dec 2021 09:28:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236231AbhLIJcP (ORCPT ); Thu, 9 Dec 2021 04:32:15 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236165AbhLIJcO (ORCPT ); Thu, 9 Dec 2021 04:32:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SFjcYGBNp5KHDK2Fk3T7FplW+Zll+BbMgZOraBSL2xJNaAdEDgMeLWNf/1TW3+7j55vvUuka0rS9sbY+NAUzf6axGcnLBi342QPiLOQJGIYYnnqYhI8v7mARj+UamCISPmkK/313w7RyexGfVPZe9Bj0fi0dYbWcnC+q+UXmqpHAHR1L2LOH1ZHw10AJ4eZNj5OfHnWkRn+h2SobS0eQlh5QwlIGTTkH25x2h3T/3pkDLwsHajRyTASYTez0EB0GdgSc3CAXVJ6NjGBigaMehMvHaFQgKr+Pb+h3odWmAjhZG6WElRmQEWluqY/dDjvtFqgsSQApxqb/JDpDWg/DSA== 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=5qGuUV7Fn2LtfbftPKlaN1D3mNogN4NqNv0+Wsw7CRI=; b=JC8zztihb7ZHYRwO1FXsDCgf+mBKyEU3/ht7PGFgJA34AiBvNd9wNjc2bqbMAvEOBmgtF+MQPl8tgggIXkNVsdRi9dgDA9zvUetyAA9Zh6+Ii9W6orJ8nahSp1aMoaN4jupsKAMzG40gyMBOpx8/DU7WVgh+LODJw6U5UUUZ8yOzBXHyv2rv7zyo5ZzSj5ijDCqpbXS8AoQT6J+zLfSXa7GZap/7ywV4FDF5slMD38pUr1bLevTV41LeHJWLUC1tf98k76yo/KDP6dWJ1yQabso/jmNLzEm52tm5k79eRKxMeufuPtjZZf9g/BuIU1SmPJo1Oep5uNVXYVsguz3wOA== 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=5qGuUV7Fn2LtfbftPKlaN1D3mNogN4NqNv0+Wsw7CRI=; b=oqvd0ENkvRlbT4b0o323URjY7hDnMsd7GVmDsmdPO+fd7KqoR3ZqK66NHYatOTqZRM24Vj2lIulfuBbv5z558qEaS4HQ0LitW609FZdqCUn6cJlUMQ6h38w9JvqUWMUsGiUQU3l7Pxrftpt29mpVxHqp7TrNFkAMNud9HOY6vck= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28:36 +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.4778.012; Thu, 9 Dec 2021 09:28:36 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 04/12] flow_offload: return EOPNOTSUPP for the unsupported mpls action type Date: Thu, 9 Dec 2021 10:27:58 +0100 Message-Id: <20211209092806.12336-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: 89a5cbbd-8dd3-4979-2254-08d9baf646d5 X-MS-TrafficTypeDiagnostic: PH0PR13MB5494:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /zGRNwgdr4tgluo/4oVcbZi4u3Nv2CI/oVg5Q5xZeunXeuQOeGt3ANOwp/zC/aR7uWRfVLqysnjNxdtXCrKeSj8JZxzO4aPvo9755Ozzp29y+bkyUjvvQFGDtUeN/Siku+DTzbrDaD+n0FECUfh1kYIqzKAOcXa+mLRMR2510cvg2+TYDFojkqrYHOu02qKAQMq3U8QJ3LCJ+Qzg0uuWiZuptJDgrws0X0M2y0CeY37onwECbkABFrMz48/ZHOEkNIwAEAtvReSSkTkTA8SMBoB3zsgOed3jWdFGVngAJgBaWaYvOB6Am+I+f70+K03wdE+aOwb/gNr3MEYkYkKSjVayJTge3qSDxVeICgPv7lSsFwBdG4LNvINM3MINL6qaSs+lxkOfACiM6GvC+O4Q3yKjM/180o/bnHCxBs7fOISj+RkfmIJ9wzMtOZTh2Bev7jnED4ewZLVtXqyb/IacmGWtsxqvzZFOuxgDJT27T3Q9b1P3MhdXnkxIGp08CTkBBJddX2eQshVIvPzGfU8/aLjfqiBAK0/SyHX0c1iLTbbKEU/rvnQoG1jDj+T/EpjFWomIfO3IUGHUQ1mam55diB22asisHStjPW+F3KHswa4eLkKOR/FPOGD2pbPk94/0jN2k6TsaqKT4A9sNZsehHA== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(4744005)(86362001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(508600001)(54906003)(66946007)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4jtHtEI3rqMYAUpm/2atJ0DgJzF/u0NhGoP72gQMKp/2K1UrSNfUy6lYTgm8lBsIb9V/nLvzfnIeqd+C2EsOGmljGgFDDKwaDWXGgG4x0gPu3Esy3zx08RH9UH7TsLRuCtlUyGCP/X90icygLb0d3k9qOfAqhsKZ6S51y5Vy4WSa+0BOPp3opoyrzDrIREDon+cR9M7y4h66IMDe5GdqhepMDVQherdeAdxep+lALyLb5RaoquPFiw9zxhGys+F1JnPPcWvl7fbceJir2lIKS3bDd8SckyrlMweclIVFfvxqGloGpp6U+kwneb3HuivRKRIn6h5ZzlitMogPOo7hunXVRN05M2odYpcOhI1JhhKkRdGF9sVQ/NW3sqhl7+mW2cE/42U8lncOuGTqKL3O7oY+wvrVHt7F9X0FRWZPiKsPAHX/JGItVY5NrCo7go0gih67MknOFodoyM5Zkv5WJwi7ODPliIeoYG7fSnIY7EaAZZTNwdwFk7Qj+ZKF1eiefiYXi3dj2dzqPIuSiXetzXr8ZwkUFgwn9iSSVMyX2+TN2N/s56xkXLJ4WojQgde1TZo5rMsgtF+3o5l4Y9YdOaHNcAxm/29BQYIlvG2QF8Nf22Ie4SUGCDkISu0uwsk9N3xWoVwO73SaPWtAvC/LIggHSRBrMn/tyybF1rkpEZVTALtalqm1KKtAuIxnnSWlL6jgwezNIsIbls5DQciHZMG9O6KlPeh+00H1mIi49E9YxpgaGcz/JVhAh4V9aKgBZybCsbDKB/vEimXarUXCjYxAHDs9fIBdb3+ZlQ2Ea/cN4sksJJLWPcAO/VvlzlzZ88Qw/vopO74TTuLKj0759xN6IWnieiLMpvbqudz56x08MJYRdg/hIthv5xTsscUg+pKzW/Ea5l7knVHS4TlmsP6QB6+tA12vnk1HMVdtoB/HcWykzpVQY5pyyzbycPNjoqyZ8evbtdwxhlL4h0L61L8xPXRTq66esNi+7nl43QQNepdZDvVMXQSZMPzIuNenhQZZ4H+ip3u2N5rQdbySc17RS4WlU1rRjYStT3dzqw2fiKlnNEk2qmwOf7wPsRHVJHTy4qMbEOUxkTUM+c/gz45fWXGw8lmiAr/zEiKmufZRryAphe0UVE4HYaNM+X84DbusHgFrDXmqVIYCokk9uW+4kYZtfVWWRrNnmHEbQnoyeNUa3BTwDd42Y2yXEn8OUUCrr+2MJ+NSN8DHo5S1oHzsqDxJC4kJdpupV15jZwr/KEXv6/kAZe20846gTwoYyhaBJJI8hQaOCUDVvU3tO+wun28t1wzk+dAgxTAsPOm8SKhXMOH3NuyhgFlE5rf5lsI6Ye7ue1YBDuBz3TZVeVqLYIqqadX3D1R32QINp4piywrnMW4xgbAque4BptLVWL3JyTceWa9v9fskF3vwpP+uZoM3r2m0Jy6qCrIThb3BcDDLtQ2LDzN5WO3ic+tDvyXAm9ZdS1iAT4h0ikSWS1eMByIBkQHKcjP0gbwuF9fr04bmMvsNWZ5mEdOdYsoLFslNHowgsxK77BcpODlEdpkGCHTvQpfXFKYYXsg7QI+QxGZrry7isrILGMJinM36AFoY+QenN1OjQo9DguwC+rxJ6ENOumn/F1TxEKDuGJp4rvCJ/5u2u8t7+76OGcGMsFnlswYRNr77U3AWIAIj2bs7vYi1ZU51Rjzax4YpY0s+4SF6BJs0+AsanzN1vYRU1wSJ3kCNlcahWXdkusrx4NgJWqNMmYWW19Kck1t8UBg= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89a5cbbd-8dd3-4979-2254-08d9baf646d5 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:36.5736 (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: 8ikKMmd3t1ub5ye2+S0bHlBif0PCoY0lhAegtxDJBVGCPCOLg9G1ziztuFQ93HQXFQnhY5ye7D1UaOCJ4Kb0ZdAAy/Mhybx4aamSwXRHLq4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng We need to return EOPNOTSUPP for the unsupported mpls action type when setup the flow action. In the original implement, we will return 0 for the unsupported mpls action type, actually we do not setup it and the following actions to the flow action entry. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman Acked-by: Jamal Hadi Salim --- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index d9d6ff0bf361..7a680cae0bae 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3687,6 +3687,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->mpls_mangle.ttl = tcf_mpls_ttl(act); break; default: + err = -EOPNOTSUPP; goto err_out_locked; } } else if (is_tcf_skbedit_ptype(act)) { From patchwork Thu Dec 9 09:27:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666211 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 73099C433EF for ; Thu, 9 Dec 2021 09:28:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236233AbhLIJcU (ORCPT ); Thu, 9 Dec 2021 04:32:20 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236166AbhLIJcQ (ORCPT ); Thu, 9 Dec 2021 04:32:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nro7JZ1UocQzK+elQGDE+7IdYlBMFGm5Zp8dDJnD7le+H6RgYL6RolB4yJDBclVRmVsVd12zg94mNk0TXW4HE3nW98rsZFouJQQB509AE5UJ01Nk8rkS/YZ1msgT66CjgVGLzyvdoKdPJ7h8gjxDuqpU1Vhk4zohD4qd6Vx3iPExPAtINQWJWrR+UtkpgqXciKnahQS9P5/aYvURF/qtWk68IC5y4JKtB689WfQqgJW+GH/wIJOJZsOXz7CLoBJ0/Ij7t5prbUyhAmzQWtj/fwib+xTJzrUoT3w5lfaC3FNf5FgJL17LrqCWaavTa+toF6/flXLEc78gIEyGrhP5Ww== 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=/KJkQqBjRhH/QFtaAHKTqLg4DI9cUk77d+4sWf3WKBY=; b=nClz+qJalVF3GwwxUhwIZq45/Kg1uX83tDzQslgffC/Ctp7jrYE7VBV007hSZSqomW0H+frDjoqwIYSKw7Xk4wPHb6X0u0Xzx0/UoBC4HpB/XS2khIiIpugEXCT1TYlKfdDZMjhSsWAHw0eXmKzmAnnhBijxF06Ag0wEB6JBB2hrXXyvngrTKxKmKfBNKteKGVjDH0NHqnmbVHC+9Z9fM/tz2Xsx5tRNsTbxm7KyHu78HiiPGJHRhCZxUvDZufA1+3DDbJP+ZiSi82vsikT4kd61nPnuUL3sDAwVEeRXTmTOke8Eg0F6rqkSBx/ocRtFAY2JjVdr2broGa/lickViA== 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=/KJkQqBjRhH/QFtaAHKTqLg4DI9cUk77d+4sWf3WKBY=; b=dcMLc9yJKV2oZj6Y4SFYw/HcbFd33BW+34+4JLY9WD8dt+Iox0R2CB316AT0OvSKipSTJT/Z+RFT+ea3QSO3U5940Z2KNof0OdLCpccCryFPhD82YdtLakyAOpQnEvyM9cGFdfwOSLNcaH3R21H96tT3KFRWcIVM3U7h7ehAK3c= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28: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.4778.012; Thu, 9 Dec 2021 09:28:39 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 05/12] flow_offload: add ops to tc_action_ops for flow action setup Date: Thu, 9 Dec 2021 10:27:59 +0100 Message-Id: <20211209092806.12336-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: b70eb062-3c7c-4349-354e-08d9baf6487e X-MS-TrafficTypeDiagnostic: PH0PR13MB5494: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: 1aZtkgOcYBxkm2xanQwFAao3MSq3SlarLcaQyGwiX2Sb1EnkGdi/9460UC5xqeF0YO+FYbWl6kkqYPpagyEk6b5kMeRb3d/ua3ZKVG/Cc3SxiKd4F0Iq36+6BNZQZM1GicJCxu7at33kM2As0lE//0utShN0gSWa04i7+Zs3ZkpT4/Po6KaZJAc3NpadHgjjkU5Pbd6ODymXPcyldLsrHa9Ga5uECpFg0vEhrKL2f2XtVGbdCwzsVn0BXVUuwo7I3xZTcgkk9OP4DnsNZt+suVb8I3em+Pb9Mm4xBqT9Mt+F89tXuH7GEw5Ad+UaqFUFUIofBK+UgAV7AtXWOCf9jFOHD5VQktM1aJpqompq2wvOWILFxRUyli/wjeMRR43tyTLQfO8e7USdQER0BYf1C9cbxWlKZ+phX0oSt7aBdHg5B4KL558BbU2QPtWRDetlvTYiFciN3jMS0HOA3p3N9+aJyvsK0L7K/mHm4UhjMe1r6qRyi2r5FVJ6F8yFvStHxPbNUfrSs7RTScMerjE8abNmquRuNgS9++66xE05Pu0svy+Q1CIcngTCwxW+7Y4KWDo9lZbFy/UBrvYIkFOzRi6qF4NvSQ0o09NppttJpeM4PXht5AOFLLi+KBu2gbsiHI0uowjMgE9yUWtuKrXJwQ== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(86362001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(30864003)(508600001)(54906003)(66946007)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RNNcQEtLlkvcAhSqgSQrhBHZdW2f1ela6V6uOHWOxa0wiVqVrmqMsmx3oQKOC4fZ/TbL0SK6A05V+0c8+TyVy+EwIJQHs8xtcpzUVGzVZsDqIm2ZlBtV1BJONYIpr/NJzMwQEfzaDe/CRtXQrAnrw6H81taSl8vBDk42U8g/AkRwgb9IJkjpOdSfGB2M/fsVDgoRWLnnSWrpqVOA2xn/l6fzILuu3KVGRq5KTdWyrbSlIn980Y+Af5pEdfPCxoExCRNFC9jetoUSHNuXktMukH5npmO4T8GjbVp9PSJ0opWEMO6DP36p/2FjyjJX1J+mH9LS4RPSL5AZIAufeE37ild5cvsoZadZTVC591lzNenoeXiJhm+37GfUF2LwEtkDLAt9WdDEXu8qCtXqeL5c9FBPOgIoY6Jl+285G4tIO8cdQZjWe71EzP0GhG3pGuDRYsFAZKtCiznzediKi7O2+Yt3XlgcJnnJ0jtbisL8iTeOPGj1+/kQusS67R16fVFK89VarGWZYUPuWiVHEbMEuWKkoR/AqHCKE1P2FscG0TVjqTjOI40Ldv3QpGVoa2qpsw50/WqZMbfRw/aM33scRl02OV4pPam/ctk64NSFsaryuiTM9T24kwheI7ULy9AQkSbpFhQycGAO/czmF2eKz22wRUos3LkVoFOUjxbrp6gYrBAMvsMJl2csU6XQYbFNT1BvJG3hRooObi9aCXJELkj2W0KI7m4sbGO8gPMrSZcIV11ONkNlpMx91P7BBSJDr725TC/g68h7tZQ7X6ao8Jo1Szfg3xFmD6UQ2UpPdhHsgPx7ddekDLnOJiyvG5uKztv53KIHOujlzNo6u2w0VqGXNVUrk6RWpR5ixDI5SxbU9at+zDsJaILPH73Tt3w0MGjXA92kEgAjN5Ky84D4bWFFwUcs4QBEfvkUdJ99GNK7ecice6ZNJgYq0ElnOyyl0OJcOyY4unF3ppRISCQa/KdkLBkGsxgjUYZewnQkNw4CgcmLsa7FSBr/BgN4jraSz+MsaAQBnn+rfUYsh6wnU6lo56EDplAZ5JVP356mFjYnsWUAxiCITUi/icSN4O15k3AVcOcxft+/JuSP5yAxZhP3cJc6d0BhiDdC5MwBiXoWYPV0tX1sva1oAk9c1iDc2Dmp51Knw7D3x+TqnMkKigcl9ZQG+k9pfDFxY9uyYK2+py5OCfrqN2Hfr1DB0J1M1owujrBujbbGq16jsVECQcqsfrneqN4Uv9/0wTTQ+sqsmerZY3wJZetGCOqq7bsRCxZ3apvq3QLnsPalU6yKX3DyhVdcVtN9VLgGT1XxDxdipheRPgY4KD4RE9zB/MvCd2P+qZpWfawPdgxm3BgIUQ8P1dfZvSrijyLE4mR8orfY4KgwEouiaJRmOJvIGh917BklaX/5xnar9qVda5jxxD90HMC/WRAiwN30RBZfW8jrrS6I6Ist5zLFkFtoa02Zj0dDdfw2WCf4fUhvmyH46QoaVJeLOmC9VzOjLoJOHyVKRyu8gKMyTWTfWye/QZ6BJ8uFtM0NRf8mR9yN0OHLOmnfEg+k+Po/fk1n4b21IAlqEsoFF82OgqCf9vhxfQLgwwnoInNDY3C+99IJijo4+IKoMrrUE0yHyKtvNoPAfSVZ+vCJsFjxmij65jYSaNWPR9O81ROM4tFh8hDR9Tvs8Ue5PYhEtRPBZEBIwqjXI2sRNiRHgW6NZeU5TH8sg3VklO2UJfju/DrWZeFepeMacgm2VtK324y/NSsbZ8iw03A= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b70eb062-3c7c-4349-354e-08d9baf6487e X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:39.2549 (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: r3pIAgTpv8p/shvCQqnhA1aP2skJBM5jrBT34Bk0NXPpDa/UrliQoG/RsmvdnfKgvAWXz8OGAT47KMM501qSxnXeez8zKfzZdRHs1EMVFsI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 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..73f15c4ff928 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 (*flow_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..b55d687e3adc 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_flow_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, + .flow_act_setup = tcf_csum_flow_act_setup, .size = sizeof(struct tcf_csum), }; diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index ab1810f2e660..9edfed3b0f4b 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_flow_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, + .flow_act_setup = tcf_ct_flow_act_setup, .size = sizeof(struct tcf_ct), }; diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index d8dce173df37..2342aa5d8284 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_flow_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, + .flow_act_setup = tcf_gact_flow_act_setup, .size = sizeof(struct tcf_gact), }; diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c index ac985c53ebaf..cbdcbe4376bb 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_flow_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, + .flow_act_setup = tcf_gate_flow_act_setup, .size = sizeof(struct tcf_gate), }; diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 952416bd65e6..3d96ee9bbfd8 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_flow_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_flow_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_flow_mirred_get_dev(entry, act); + } else if (is_tcf_mirred_egress_mirror(act)) { + entry->id = FLOW_ACTION_MIRRED; + tcf_flow_mirred_get_dev(entry, act); + } else if (is_tcf_mirred_ingress_redirect(act)) { + entry->id = FLOW_ACTION_REDIRECT_INGRESS; + tcf_flow_mirred_get_dev(entry, act); + } else if (is_tcf_mirred_ingress_mirror(act)) { + entry->id = FLOW_ACTION_MIRRED_INGRESS; + tcf_flow_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, + .flow_act_setup = tcf_mirred_flow_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..69bc9e10ee3e 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_flow_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, + .flow_act_setup = tcf_mpls_flow_act_setup, .size = sizeof(struct tcf_mpls), }; diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index cd3b8aad3192..ddd93909636b 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_flow_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, + .flow_act_setup = tcf_pedit_flow_act_setup, .size = sizeof(struct tcf_pedit), }; diff --git a/net/sched/act_police.c b/net/sched/act_police.c index c13a6245dfba..f48e9765b70e 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_flow_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, + .flow_act_setup = tcf_police_flow_act_setup, .size = sizeof(struct tcf_police), }; diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 91a7a93d5f6a..1b0bb501218e 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_flow_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_flow_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_flow_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, + .flow_act_setup = tcf_sample_flow_act_setup, .size = sizeof(struct tcf_sample), }; diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index cb2d10d3dcc0..b0d791560aa6 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_flow_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, + .flow_act_setup = tcf_skbedit_flow_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..14d8307c31a5 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_flow_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, + .flow_act_setup = tcf_tunnel_key_flow_act_setup, .size = sizeof(struct tcf_tunnel_key), }; diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index e4dc5a555bd8..5de24a995020 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_flow_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, + .flow_act_setup = tcf_vlan_flow_act_setup, .size = sizeof(struct tcf_vlan), }; diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 7a680cae0bae..33b81c867ac0 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3474,81 +3474,25 @@ void tc_cleanup_flow_action(struct flow_action *flow_action) } EXPORT_SYMBOL(tc_cleanup_flow_action); -static void tcf_mirred_get_dev(struct flow_action_entry *entry, - const struct tc_action *act) +static int tc_setup_flow_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->flow_act_setup) + return act->ops->flow_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_flow_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_flow_action(struct flow_action *flow_action, entry->hw_stats = tc_act_hw_stats(act->hw_stats); entry->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_flow_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 Thu Dec 9 09:28:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666213 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 8E44DC433EF for ; Thu, 9 Dec 2021 09:28:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236166AbhLIJcX (ORCPT ); Thu, 9 Dec 2021 04:32:23 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236162AbhLIJcV (ORCPT ); Thu, 9 Dec 2021 04:32:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bS66JnYVyz/tdWb6e1gD17/dFT/rgwnwkYJ/gQs9YIDwBkUKzVQGQBrIlE8KPB6kOwv+6N0EGiHm3VVu5eOVpO2uKIhV3+lAZkVzKxwmAs/NrBrtR8Qe7bhY4C8vWjzliBR4ZROcmQo7OZsGPqOhNL0Wa1ce/AOqml7GswiGdfM5loLFGYMOAbFekAFrWu/89RYZ7/1lZ/Og++59IjI5FTND/wlkDRFJWNqliPUml4uLR+abnnpYGfyV0nBTOc9S1A/mIgdySWae8H9Ct3G65l7Ol6J0r+66xNV3OcE0IdLwy4qY+g/1MGvcIS9V11Jw9yWllWbbpt+4v9CKE5Mfmg== 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=kMXewAGOkvj1qMD8CUch6gyto3oBWutEq1PlEo0eix8=; b=gpLTxCbMWrlz1yWlNrOGapLwLRjbrfWlmycOsOlFulkjGsEM7zQq84V/PWJJ4Zgizdvld+3553F2r8i5yLx/KUeDGl8O6o/wJhRAb5eM8t9OpSXj/Ol0k1AHUoXNzTJQYj9fsqhPmqBkn4ydzt/1O1Qvfc3ZOnKT0XaGc+RVfejondYFL1RL2ETTKRCu1IOmivbY9XVI2wJscYyfl75ucSiWHCr70JaZnPdneykgKJTVrDQQUKxsU24hts8ilK0dSpqd4EVjZS/i7STCx/JgrdRbfMPzEhshA30bAsBH5ErotmNrT1+RKYph7VUHWLeagZAzOt84X+mDW2Se9sAATA== 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=kMXewAGOkvj1qMD8CUch6gyto3oBWutEq1PlEo0eix8=; b=ZO3p4+HwBqAHGJzT8Xy/u8didH69NFxTallvDJqgw8H3D+2fbjKK6FXEic4ulPTMWZGiFsR3PStdpZmItKWhFDUeRlSdnbxuopKTw0b01LVdOZO1+eEwW/A2ujtwz4Ex7TFlwSRBvwKhT7+diJhpylbaPBvSqKkj6c5o8lbJ4lo= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28:42 +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.4778.012; Thu, 9 Dec 2021 09:28:42 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 06/12] flow_offload: allow user to offload tc action to net device Date: Thu, 9 Dec 2021 10:28:00 +0100 Message-Id: <20211209092806.12336-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: 29032c17-815c-42ea-20e2-08d9baf64a1b X-MS-TrafficTypeDiagnostic: PH0PR13MB5494:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hBpXxAD4jt+d/Ha9zOqw+WoYKbs9xtWp0G3urOPFwaaC8LeEe1KTDsT/OpMJLWIZJCdnNG82+Pw5AyuZp80hPrKFIyGR/fyDVaRVrRXJq/wEF+/u/w8Yr47NUb5Z69KyDP5fVrCbWwnazraiqqjUZGl04/RCLMQgkLWhZkGRffvtesj7dttDEvtGjRCe6y9Fymcz10qpa+FDpQ9VcPnmMyWt4gTxMiFSrQxYFc0Vjv1JZc6qolmGu5q/YL7JKpJs3olB7iPPUSDAH86CCxhmXnlbDK8/X0OzJh2gIP7qD/fEJ9P1/5fn89VLHGcEkhmFhWBWkPHvbAKREYti897RtyvQKOrJuTP1MnO4R4P/SG/7Gq6ValG3gf3aBODGbGhqHjSdsS2A3fmIxNfbLBglF+m4uBZuRvIwiRzjuRB8TUGANK8132ZF+GRuEdGbI/pwgCUUghh0mHhKyV45DhYdTAZ6y23irXKGLExdzPOjVeAc6aiW5ZrdrqBTO9FnmeIcxPDqeU7sDvCUIciaSByMWzN4MdM0uYIhBSHb2KqR34xrZ0dxh+eRNaS9wMfg/JIW7rYXd1QEdy9IZZXdqpxY8w1ykBAlCZjcK5t8p2/Qj21WM2ESlpJ3Iciw4fr1SKv2sp9Od5WSfU29FrMuaLgOug== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(86362001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(30864003)(508600001)(54906003)(66946007)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 20or4cZeS3XzVT9/qZrBoGtHZii7wXRqcZ9EEJU4BMkwECH0UwwiIu/eMq0FjDF4oZw3k5SukMfqreVpd/8+gCF9zbaqB3u11s25XPhv0t5osr0G3LwLpdXv7P/4ucx47awADjykHkk3X6OLmVsi2CcejSqoWmhmtglTlrudUB1ClcIrj1Y8324Ykz+yloi4VqZad6RpQj8F1/KkWTg2cTSP1+gOAMANdBcuZlXcaK/qmpnV+mOPZRrggHx9ibq+zNz7jqpyUn7X3uATvtFw4xo+nFA/9untVDgQVEC0wKQeJdb5yh1XIOP6/1xCFQs/Fwc74hbyhDS6Z67wL2VS3sk8JY03f8tlUULR7/HW9T/KUF3w4tnY929380lTQ75KpxrdJEJBhwe4N5GCNI2YorSFbbyu2VzUe3hlLrFAvaJ+6CDpeEJNi8xbdJu7MQJJyEjz/0uU3X4MbtUze3arxpXxJmFP0mFHk5BfoQNawlURkpO35eBlQWILiDCEAefO1KzOmXYPZ4VWQ8gO63XfqtEcEj6v3BZTrKuWUrcxWn77FyfKMgR9ihtqAMT27o8gjAPZgsVbJ1OOzYxFj9hX5PMk1NrQgbPLW5XOUtmtRgSJzHDDRo2Iy61+soWJSxnxMfKg45ySc/WV1q0HXKi1wJuZ4IvJce9pozD64XMue2U+qxxiiHABSVH2t+CEKOGC1F50YcNnCitZL/cyrGfQxuYoiW05zoOXIgNaIx/xH5nD+388jzwp6mRz1Exreb0mtqHD2M/ytqx0mlhj/EtPK6OVewg5uVML6t7iknh706fkgX6rhwGUxF4Dc6ujrDVk0wTpJHOQxIt11goFz9VRT5SuqcHwiOFFq+4Nj9gL2t+hM+UbMdhynLPqtyPMbQHrwwZ/J+EIq4onHKPEbqkQDQe0q5gr6WmKcBORu7BL3dN3TNunzbns37+kq0Ae+cafL0muo/IvrfjTqTC8MjTVviXX6cpc+1z1KZznwYu4SDWdVYlJ92HVYzAaxXE0hJlUOzdXcQY0LD6ucG6W3QcIi6uoLeWENSnLbzRBaqMVqCGNbevLLBK841QC/MY2D+rG6NaWEHhworg2RxgpZzmphfh5SzfF3ned8UEc3alsZ4uA6y5aejZJBtzSCYDiMvoG/Tr9Z5Rnkkm5Qm9/pRJ2bXirtLGDDJJl8oSWYwQqZPfCInp/E3jvvI1tznywxWpjLprpFOi+MeabWa5k6min2ikuE4aY8D/3df0XBxvIAI8SOXvdH2JDUbKx568WnmhYbGJkMUJTINEdg8GLXlQPF5Oqbn/hZTr2iK+BXyIsAiVTkRNICzqrXyQ/ma1C3tnWPYhYHzHOQ/HqYDKubbi8YovHuLRmymbc8KK1Y6aoyvtfCkpBJ6pdrWbD51qfiIzdAC/Fcern3SryifJMCuNTVNSuxGU28w61TkjNVfSOh+cy3j98st9UKCIYwYNHwo8m+wQty+F6EKOyGqbn4hrlEWCL1nPXr0SW8KwsGofbnVBPjp0G5opqCJVqzal7msTDuKCh0d16e3kI/MEcCC/RUCQof1s2/3rBffTH8HM+UwcGcd+2DP8gZspG/5gvVuQvofRDw+dbKx9aLNYw6RSCkQ2B6HDpa7DlsEM0eys9n8nYFtZNs41CCPWhkJ7VTgPsevd/kYXyIJl3aKMaKGYOQAClkaFV31t0AgjKqRe2pBkX86ixeUX9btjrIuov4SIckSe9DHTU7M3Y0zfxV7dE4nQSg5HxrcgWSRxJLVPIYic= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29032c17-815c-42ea-20e2-08d9baf64a1b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:42.0406 (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: tNwSbPrdH4mKMvBngO9yRhWq28GqC3Y1BHOAkE3bGmdePT1fSrwYkFBhjZN5CJlHAjB4e5eh1Pt4SMMEIJWP7HzvcmBZ2fw66w94Aq6cDPk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Use flow_indr_dev_register/flow_indr_dev_setup_offload to offload tc action. We need to call tc_cleanup_flow_action to clean up tc action entry since in tc_setup_action, some actions may hold dev refcnt, especially the mirror action. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- include/linux/netdevice.h | 1 + include/net/flow_offload.h | 17 +++++++ include/net/pkt_cls.h | 6 +++ net/core/flow_offload.c | 42 +++++++++++++---- net/sched/act_api.c | 92 ++++++++++++++++++++++++++++++++++++++ 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 1a748ee9a421..cb50574c5972 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -927,6 +927,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 f6970213497a..15662cad5bca 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -551,6 +551,23 @@ struct flow_cls_offload { u32 classid; }; +enum flow_act_command { + FLOW_ACT_REPLACE, + FLOW_ACT_DESTROY, + FLOW_ACT_STATS, +}; + +struct flow_offload_action { + struct netlink_ext_ack *extack; /* NULL in FLOW_ACT_STATS process*/ + enum flow_act_command command; + enum flow_action_id id; + u32 index; + struct flow_stats stats; + struct flow_action action; +}; + +struct flow_offload_action *flow_action_alloc(unsigned int num_actions); + static inline struct flow_rule * flow_cls_offload_flow_rule(struct flow_cls_offload *flow_cmd) { diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 193f88ebf629..13f0e4a3a136 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -258,6 +258,9 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) for (; 0; (void)(i), (void)(a), (void)(exts)) #endif +#define tcf_act_for_each_action(i, a, actions) \ + for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = actions[i]); i++) + static inline void tcf_exts_stats_update(const struct tcf_exts *exts, u64 bytes, u64 packets, u64 drops, u64 lastuse, @@ -534,6 +537,9 @@ tcf_match_indev(struct sk_buff *skb, int ifindex) int tc_setup_flow_action(struct flow_action *flow_action, const struct tcf_exts *exts); + +int tc_setup_action(struct flow_action *flow_action, + struct tc_action *actions[]); void tc_cleanup_flow_action(struct flow_action *flow_action); int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c index 6beaea13564a..31273a10086e 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 *flow_action_alloc(unsigned int num_actions) +{ + struct flow_offload_action *fl_action; + int i; + + fl_action = kzalloc(struct_size(fl_action, action.entries, num_actions), + GFP_KERNEL); + if (!fl_action) + return NULL; + + fl_action->action.num_entries = num_actions; + /* Pre-fill each action hw_stats with DONT_CARE. + * Caller can override this if it wants stats for a given action. + */ + for (i = 0; i < num_actions; i++) + fl_action->action.entries[i].hw_stats = FLOW_ACTION_HW_STATS_DONT_CARE; + + return fl_action; +} + #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..120e72d8502c 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,91 @@ static void free_tcf(struct tc_action *p) kfree(p); } +static unsigned int tcf_act_num_actions_single(struct tc_action *act) +{ + if (is_tcf_pedit(act)) + return tcf_pedit_nkeys(act); + else + return 1; +} + +static int flow_action_init(struct flow_offload_action *fl_action, + struct tc_action *act, + enum flow_act_command cmd, + struct netlink_ext_ack *extack) +{ + fl_action->extack = extack; + fl_action->command = cmd; + fl_action->index = act->tcfa_index; + + if (act->ops->flow_act_setup) + return act->ops->flow_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 command after inserted */ +static int tcf_action_offload_add(struct tc_action *action, + struct netlink_ext_ack *extack) +{ + struct tc_action *actions[TCA_ACT_MAX_PRIO] = { + [0] = action, + }; + struct flow_offload_action *fl_action; + int err = 0; + + fl_action = flow_action_alloc(tcf_act_num_actions_single(action)); + if (!fl_action) + return -ENOMEM; + + err = flow_action_init(fl_action, action, FLOW_ACT_REPLACE, extack); + if (err) + goto fl_err; + + err = tc_setup_action(&fl_action->action, actions); + if (err) { + NL_SET_ERR_MSG_MOD(extack, + "Failed to setup tc actions for offload\n"); + goto fl_err; + } + + err = tcf_action_offload_cmd(fl_action, extack); + tc_cleanup_flow_action(&fl_action->action); + +fl_err: + kfree(fl_action); + + return err; +} + +static int tcf_action_offload_del(struct tc_action *action) +{ + struct flow_offload_action fl_act = {}; + int err = 0; + + err = flow_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 +1146,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 +1193,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 b55d687e3adc..26e9036240d9 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c @@ -705,7 +705,9 @@ static int tcf_csum_flow_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 9edfed3b0f4b..485e4c7a086d 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1505,7 +1505,9 @@ static int tcf_ct_flow_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 2342aa5d8284..7d2f0c9587c8 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c @@ -272,7 +272,18 @@ static int tcf_gact_flow_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 cbdcbe4376bb..f149135c2e10 100644 --- a/net/sched/act_gate.c +++ b/net/sched/act_gate.c @@ -637,7 +637,9 @@ static int tcf_gate_flow_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 3d96ee9bbfd8..8978a5f86dd6 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -482,7 +482,18 @@ static int tcf_mirred_flow_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 69bc9e10ee3e..720f57ec9a48 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -415,7 +415,21 @@ static int tcf_mpls_flow_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 f48e9765b70e..b8b64c72d686 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -421,7 +421,9 @@ static int tcf_police_flow_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 1b0bb501218e..df7bfa688372 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -303,7 +303,9 @@ static int tcf_sample_flow_act_setup(struct tc_action *act, void *entry_data, tcf_flow_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 b0d791560aa6..c4fd5dc21bbc 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -347,7 +347,16 @@ static int tcf_skbedit_flow_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 14d8307c31a5..2ebc797c047a 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -827,7 +827,14 @@ static int tcf_tunnel_key_flow_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 5de24a995020..5f0ed3b5a5ac 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -395,7 +395,21 @@ static int tcf_vlan_flow_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 33b81c867ac0..2a1cc7fe2dd9 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3488,8 +3488,8 @@ static int tc_setup_flow_act(struct tc_action *act, #endif } -int tc_setup_flow_action(struct flow_action *flow_action, - const struct tcf_exts *exts) +int tc_setup_action(struct flow_action *flow_action, + struct tc_action *actions[]) { int i, j, index, err = 0; struct tc_action *act; @@ -3498,11 +3498,11 @@ int tc_setup_flow_action(struct flow_action *flow_action, BUILD_BUG_ON(TCA_ACT_HW_STATS_IMMEDIATE != FLOW_ACTION_HW_STATS_IMMEDIATE); BUILD_BUG_ON(TCA_ACT_HW_STATS_DELAYED != FLOW_ACTION_HW_STATS_DELAYED); - if (!exts) + if (!actions) return 0; j = 0; - tcf_exts_for_each_action(i, act, exts) { + tcf_act_for_each_action(i, act, actions) { struct flow_action_entry *entry; entry = &flow_action->entries[j]; @@ -3531,6 +3531,19 @@ int tc_setup_flow_action(struct flow_action *flow_action, spin_unlock_bh(&act->tcfa_lock); goto err_out; } + +int tc_setup_flow_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_flow_action); unsigned int tcf_exts_num_actions(struct tcf_exts *exts) From patchwork Thu Dec 9 09:28:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666215 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 2CF82C433EF for ; Thu, 9 Dec 2021 09:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233135AbhLIJcZ (ORCPT ); Thu, 9 Dec 2021 04:32:25 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236248AbhLIJcY (ORCPT ); Thu, 9 Dec 2021 04:32:24 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MIC8AuLX0f8+wGa1LY11ZvZNacx71cAg71SyzC8glYjvqRZ6XYpFAjQCW4RztNW/p4V7sKTbD9Co/+ASppgTQNcxwJ1DktdfJgRC25w2YwbM62KIOkEJmRJnPCGSnscd9w3t5ImCZqe44ur26EU27UwMR0zjZwek3FfmBpUdyNg575kPe9lZuW+2O5p8BL8Vg1pIQPNElzUp6AGWrN/z1+iFKlMDWxXWZ/NzI2scmYzb5G413NrZYtGSlDMuMcev1sljLfCOZZ8B5fuvdHwvxsXGmYa8IXezf2V4oAYvGe/6QnMUUO5jp5ChCDF3AsWaVHgVT5vquQ/G26Mp5kFu+A== 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=b2OBkj9X5POozdYrp2fPiEE+HrGJUsKKXizHoCL0ZFQ=; b=PzTi82T9b7Ti19UOvqkZtaA9b/x7p4n+SY2yhT2t79TdqB3XnNxJ89NbJwHYg55zwJdjs0fzTht3eSxVF8HfO0oUFJ8Tj1t5e83rKQLhekUN/xlWLPshgwGlZDfvOhj5/MCh+VD3CQrlatHzc8+VyC2BbJpWQB99Ih25aI9Ph1MQF9tAHSTwKH7pMKXHId13aQm/EGIkDjlGWmAtATBHLgMh2Z/MZ+v7eiVwKVfu3S9pjrk9XeDNVLZdJIk4yL/aILMM7Kxe9lbCGIMB/4TBvApd5YsntO/koVLX7GfpWJ8hKLCPhyJ1gzgGIFZr5Gc0pZ58UwuJa+dNkaS22SQHRg== 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=b2OBkj9X5POozdYrp2fPiEE+HrGJUsKKXizHoCL0ZFQ=; b=XCeRnsWVQfuIBWjr6oPu/0r6pGMJNjFq5NflJCMV59MlWY5uh9wQe9z4RgmYnmcSHO188AuHqw5p0BGD8r+TyE5Xah/dUsq+61OY1Tv81aF8+1Z4JRck87KMnv9RkG3je4ls9j9OesxeekKpcLe1fveZyzAnCFhv2yaYDfksKO0= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28:45 +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.4778.012; Thu, 9 Dec 2021 09:28:44 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 07/12] flow_offload: add skip_hw and skip_sw to control if offload the action Date: Thu, 9 Dec 2021 10:28:01 +0100 Message-Id: <20211209092806.12336-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: 3b1358c5-993c-4a70-cf60-08d9baf64bc4 X-MS-TrafficTypeDiagnostic: PH0PR13MB5494: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: m8I4aOGVm4sg2auJ4Ghmy0v9qm2OuEyfB/mvCh+8u65Gxp55VxSTZ4UI+gr0DFJhj5q3aHeg6Uym8n54ORssAwHQzinRfYpHfLYRFY0VmxUTsLP5axCikWtUTMGCt7EwjGn8J74438AirIl7qmRJFW5v3n9zdCnpDvC47qVuvoAzck9nbaU0QjErCZb6eVeFkQC8PfiD8/Ph4r0yW79XbDtVuY18GbffeRz6301T796Jwf8ZkANA9wOX6bDsy2pLy0AS4ONecoHtwikWkX76f+S4/Ot2ZZPSvMmDKu/L4BtqpEKvmIYr0tY7hKu9qlGwy5/SFlktxeFqvAv18wSOQywgDMTKlmo0Jnb6CS2l8Q0RvVXeqxyLaWRC2kohFf6guZUB30tUhuRiva71LZfqx3j2a/MM5NPq9kBHfuc164UiXOPNc+lDQcABU8uHju1iRKhbv7dkXg1PaxuwrpBcL4U89gYlYCAk5traryqLALLmgC5RTPWMIl7Hnqg0tFtkW2IlBlDlcFNpaiozdO8o1TNZjc65FI90/rYuTcteUxqUGfIVgkehhwF4/T7lIUoULwnJv1d7hogNDQ4MCbtP/O3WvwwsdoJ8U4UcJZZx6sBg1J6ktoLRLn6iNw+V7McVC+EAF5Z7gSuyRFe7k3tIfTHZVZCc8MIG02nKEGPJDtE/CZ0l4feUyAL2wjICchZgIZsqgMTd9uWdHC8+UVq7sQ== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(86362001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(508600001)(54906003)(66946007)(107886003)(309714004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nA9fEuKZifb77dSS+FIweYUautE3iULN2G+npcxSTI5W36yiaLKMguzjnWflNXCQ1ad1g1S/GYyuM876pGFhmQrfJc4kx2ZqG3hWrgxcIw5YhayJYP8XKKfBCWo+3ZKm3KEUBD6e4VBh+PYsmu8+GnempSsHEtzeyVBTa26z9k5rIpXwDBvpHLfM1IOhMBVNeMMGH+XLglQOIvBnxydVm7ombtKwHoFe/+woszkCbJtgQYhjofnF4tWH+Nq7PoGSjmy02xJ8M+xpyZzJh2IacXirpFUJYSAg+aXKTq+YflLULAZqiuz3+RNBcmtcXKNolJCRRreg/kh+DO7CgIvfssEzRx4pk0Y254tltJTpO3oXvkPtmzTaJhAJLobSTfCpcOplE8bpXQeA0+nM+s23SNDpLvPlS866EGxPQoh4V8Glfwgvv6uxWe5wWbDaO0WKc11ObtPRsJbAeSdXFZrIwE8bRQ4D3u6F7kfEwa7Vpk0D7dybGSnbh/i3hH5Udoemi5BXX7tFlynNexAd3Y0LIezbF/sWsLFvP04TiYINTgCrObeApgvkbBXYTCAjPlynTisyCFcr3nSQ8mCknAhhfxdzYojlPIZdFqJ9xXQnucAa+C0Sr9Cb+3/eV0eBQgEfqkcFXzIG7yTmPyU8llEnUTfDHEXJLVHweymESB18I2QeDZ9rVSVeVk5TUKP5nRzrWjr/s+lohZ2/zp9zPyHaL4pFpbT4JRWnJ/MRtwHeENaq1kyIB2HMJ3hUm3jsf/WEx6rz3IRxr05fCjj1Y3AScKocEfDXJ5ElkW/0V8E/NyYFJMAo2Zv9lg93FQuRq48654IF8w7dIIvCbYolg/0frmda5jryTTyW8yc/gYpChLTudSwPSrIp5a9x2eZrN/rGp4TzQFiqQVxwMP02HonMrnk/wzi7KvJFjE9RlQxVofxLyfrHzhR0ZPe/+zFNImtLS3Nrl3F6NjWQNUojIInPHPEuj+iVAK8kDeZoiwKO5PzHKkidAdrkgZBjxrZIeihs7eWwA3dWPlbqEoEJ+6AMzbgsL4ZXpS/n4imIaKRmZd2Jm4iq2uI7LL7534EEKq9fVj7jsd8N8LYOCBnqvJjHQIWlvNxR6Y+Dyz7jKUS8OGTIl1P9O6KRsAMON+z+Si2XBS1W/kThBLjA68pcaD23brcf1jnBsxw/faPmFgPl8lQ5ebSpq7eAaa94Xk5UmUw+uLWF8LFf5IL+fdLCufwwBSVU9zgRXIUB5q+YnVMpXsQSa0rAnejZ8F9t2hcSx1iCR4Mlzclcnh0Va8APeFLQk5QLpQciTkvj7es0WkbpsnIUGZThLWmJ2fK9PWgsyLPFCIoNGnqH6iPGMAmqJee0Jtb29eYKlMUsIhPsz4e21d9oTh6w9L4filNWZb2sJe1R/A1K/sbz5rTrhf4CnBFuHrT+M+Aoma+LQOOrS8mSNSOYt6MAfWZo8CK+JXUPMMViufMyxRlgatqqjB6JhH3xARqTAzVFbboqltO51PAdz87RkH1I/4iTksYElLIQF7je9SfKOuVp8x+aXVQ9jW6Stej9M/d1HdlxP/Um2Zu9JA8TM3OT9YiUuJtAINCuPCpAPw+obEwWzeLWwPWRo+/jYJWGBFhUwYd22kiED4kQpAPg4h2s2KXzj7uwBgnmCoksfDfENdWqGLvIZBipGDe3LSBwnFNTz633NJse2EihL+hoGuYH/CJPxH9vN74Di/pvnBXlov/EoQqzxSp6cXj9Vdc4jULxcs+RdIXtUl418yo= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b1358c5-993c-4a70-cf60-08d9baf64bc4 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:44.7089 (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: Ak7stEAr2/DH7vheOypjop4UIVs/UanaYaeJ53oyvwqhk9NXQQk0umdyK+L444pnuXZgxz/7yuioT5i6iV/Hzqh0fcYd9LUCYIM2aBNcA0E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 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 Reported-by: kernel test robot --- 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 73f15c4ff928..7e4e79b50216 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 120e72d8502c..1d469029f2cd 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 flow_action_hw_count_set(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count = hw_count; +} + static unsigned int tcf_act_num_actions_single(struct tc_action *act) { if (is_tcf_pedit(act)) @@ -139,6 +145,29 @@ static unsigned int tcf_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 flow_action_init(struct flow_offload_action *fl_action, struct tc_action *act, enum flow_act_command cmd, @@ -155,6 +184,7 @@ static int flow_action_init(struct flow_offload_action *fl_action, } static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + u32 *hw_count, struct netlink_ext_ack *extack) { int err; @@ -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 err = 0; + if (tc_act_skip_hw(action->tcfa_flags)) + return 0; + fl_action = flow_action_alloc(tcf_act_num_actions_single(action)); if (!fl_action) return -ENOMEM; @@ -192,7 +230,13 @@ static int tcf_action_offload_add(struct tc_action *action, goto fl_err; } - err = tcf_action_offload_cmd(fl_action, extack); + err = tcf_action_offload_cmd(fl_action, &in_hw_count, extack); + if (!err) + flow_action_hw_count_set(action, in_hw_count); + + if (skip_sw && !tc_act_in_hw(action)) + err = -EINVAL; + tc_cleanup_flow_action(&fl_action->action); fl_err: @@ -204,13 +248,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 = flow_action_init(&fl_act, action, FLOW_ACT_DESTROY, NULL); if (err) return err; - return tcf_action_offload_cmd(&fl_act, NULL); + err = tcf_action_offload_cmd(&fl_act, &in_hw_count, NULL); + if (err) + return err; + + if (action->in_hw_count != in_hw_count) + return -EINVAL; + + return 0; } static void tcf_action_cleanup(struct tc_action *p) @@ -820,6 +875,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) @@ -925,6 +983,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; @@ -1004,7 +1065,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), }; @@ -1117,8 +1180,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); @@ -1193,8 +1261,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 Thu Dec 9 09:28:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666217 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 713E9C433EF for ; Thu, 9 Dec 2021 09:29:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236300AbhLIJcc (ORCPT ); Thu, 9 Dec 2021 04:32:32 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236244AbhLIJc0 (ORCPT ); Thu, 9 Dec 2021 04:32:26 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FsaDsUO8piu3xiGv4sY/KVPmNNh0oPqSF7Rk8QSzstsV437FOQOvlQNf2282zZzckrzO2Xg4IaHaTlIejRMnxjEnFbG68Dcy15aY+IQGVunNqo64UO1rbR9HeDx/q3vL5bGzR02gQRUkE5AjY4iU4W8MwCSI5OzjNz6lBfMV/TPoYSk7Gd8vS3rC5+2bzOYyH1nezc565Jr9VzyCbZ8E2ZtOguzJJnNMUx+MtgbHsEWTNBdz7RJ3dgB/gxBxA0VKBRcIXa0GMuQkljLb1iiqgYyFZsUzA30xEXBUELv01bSow78Ux7wyAUtQzhtgED1std84jF0d7opU8zCYzIeqfQ== 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=YK04thQSIKcMbJnQL2ZpOwKD9hwAAD3KhRtWiyq6MSU=; b=iUOuDffqeZLIOaCVZJgkQsJbS71H/QALXb39jjx6EnFUEpiwhcDRQ7jgu8fGJlVjSxipsRzyvjKnQUZTHi4xOo0GnNqJXgqcYGdlAu+tO7FzbtXYg5B0tqF5RQvwW8JeW8D7qquwUhE3sA5jfpV3A2PVpC/GE2XZAsQHudzXPworkxKECFJDyVY5CWjI3zJ0/7X/UpbvzBiXicqY5kEfqWEqJrx6pUW+X7SoZ2acDC+3xZuRYGbyfWgtC1sZsEWqVEwUjgAEKoJV5Ng4vQ6jAPQUD7+oGOuVIh9yooXP/Izt1iHg06vrqchoquymmsrJia8u7UAStWCS4X9EEVAnqA== 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=YK04thQSIKcMbJnQL2ZpOwKD9hwAAD3KhRtWiyq6MSU=; b=hPrROG2O9zIgp3Cuuw6ap+p1NMQKKDsGER2p88SoNor/h772lskkogPPoBpxLVHlhowp1lH1/iZdr7J135vNGxLwVVqwiRhk/rU6qpxwWvHkWdBKqousuMbTTmuXLmFIQ1EI+n5l9NCaMU6R0ABevsRCM9vGxGu30BKL6tnbyIA= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28:47 +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.4778.012; Thu, 9 Dec 2021 09:28:47 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 08/12] flow_offload: add process to update action stats from hardware Date: Thu, 9 Dec 2021 10:28:02 +0100 Message-Id: <20211209092806.12336-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: 9824fbbc-8d8d-474c-0c1e-08d9baf64d5b X-MS-TrafficTypeDiagnostic: PH0PR13MB5494: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: VXOcZGP7Ds9abEk9AOG+15bJZL87XA39XSeb5CSIrt4pN7sdef7Stbrxz5YMYTc9SZf3XlTu3RNYujfbzeL0iedV77e7NN99QXdFloAC6LZgPXkmjqdYskkKsCjIJ3YGzU/9eZfcCr7QZpfns+OxPvtxMbpbrWcbhCdmfhH2rzEC4Y59K+E/7eYI4FOkA/dpUwPoUyDVbm0SmzhAbSuWWIyfP1hl/+9KOpq19dWB4FTtsGf0bMXqpUrRD1qdfgXJPudxTL/F9AfZRAdRrJu/z5M7qx9dz9QKGqSUeG8OVrrgYIamTauen9p4aF0XCrfIksL3rEvLrjHlUWDTf2zJFr8V0EAqui7Ax8FmJBgH1L4nVYLWVq9NroYIM1a/qI/dpVXs6gUzd9Sah0TPaLVayx6ImPZSQeyu93I3kxJ1NUBQvGAaIqGphePvE+I+57KAb7p6Q/SlKZfk4ZNU2B7OLWoOFBHj92kJBIpCsCLFNv5vtpg75sNBr+L3jubFi9j5orBMnwiVneB7xa16pwbShfGjRfd6dQtkcMMU2vXLSP5pqUOKVEZUVnp+/N8ovwlvBCE8DEr4L7h5AQZbeMA9vCyIQXh2FBlMnBKX4K9sJ511oF3lXFBTltFza8odGhgqwDDoLss0AcWa/Rs2JQtrhA== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(86362001)(15650500001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(508600001)(54906003)(66946007)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hHop6kytSUTokZZhS3tRnGQAG+d1MQon1oR6U1DdDwFBw5DMcH4knce3i/YsMwREyhGeYxTR1Q+8Nbn3nlkXeKeq9h6k2K/qK4Lhrc84Nllg9sE4kM2cD+hWoroqUy/qpLsxatHdMhBXJLdBu230tcCAn2di0ppe1jx8PUHoGXmjnNaUK8aU87yXXsCkoxMudgPBqg3p4JHghqT711AUrbr8hbtMNyGqBDFVqIaqVvFXHIsyW8oNbvICOzEuYyeYivEh9r1ZbKZTuoZNNH4LmtegoKHY1aQn7RPP7mqrilazH8+ydfg487MM0oX2rVMd4mVhE7FujWhGaUFtAfgQ6PyxuuXuvW+fc3xEa4+W1d809df4gV02UCzgXPVV9dwETsXCeRwRtKJhofITLpSEnRc16V91GNao7wrtWy87/N1sdVibZgkUhiHJx35z8OL0RN0jnpGdksWMz0EccY/bo8offLWEjS5Dl0Q5K1WaOALHpODdLhnwHWczQ7mTsJRn1zpT5u3qYxjgrm2ar5TxLpUMoKcmipYEn8sp95wTezGO//VakhJldDZmbp7WMiw78p3iLZLCi0HDht4wDK7X9uUENs4QGZeEHrOyZQfomtJZiWRIb5FbraefCqpBMCPUWBic1OQRyM1rLFmAQE/Y4m/zXH+HnL0wFxdaB/nwUu4xpGolzCw4nq/lVrt5Kw83oG9S+CChgLVfxhPL4b6sde9so2cyOn+YR6TUELbjWbkuXLR4a6+cA94VT+24K1OLnj9hNMAHuCfVMZVGRmqmIang9v5+qOQfvklpMQ2KcbLsfEc5WuH7Ew77Q5rzdwRm4Q93RqPQ6oM6s3D3QAG9QZYnPB8lSWr/1/NPEqlF6UWWpSs59N2XDAv7xbGPXUBd/6ygwcx717zuX1+xq71o1rd6tjdxfr15jOceN7rVHsyGHPsgN2s21yYAk7K/m15CqvgcfgBFXLRpnL5dJiadAbk87iyfps0U+HTplUaaPNlRNwj+tRk480BScHPmWSveUCA39c8SkTpGGidM/gsPWHJperS+fQQx3TKmzKI1cLQTMM6/2qowGGSKMaznh7VWzRbFpNfd3sV+0iDEZuq1OChJvplwuakkvv/bKgiWZz/KD8LYVS0mSNbMJF33+C2DpKJ9Co1v9jG/VZExXISRpoA5kOfTUckl3hBXVky27tKwprJRVkv2VLvKoJ12CkXRyUI1HEW8dXnDkLDyXQeH+MQs6jtThBC0yif87E3VYGzLz1ImCRj8HjXXc4ch1dJphDOA85Ua2tAuK7whar/aSoxaw7PIleK2B1pNATwMsliDqQEFNissxk5L4kZJzfO+HatoKCbUOykD0reSXv6pwJ/Mi8tOetSsVoxWJDd80f4qMiyatdQ+zXE8GatX0llITqCDWZjKapuu7jsjCHI/8glN2+EEvdqvLcg/Gs03GxNnqKGBeWCRX7ejUlz9KJqb9qGc2Cy40nT7n//j+doI1yHrp8Mxt012vLrd6cQFldDuwQ6olJgCn4vb6dq+vWjAjXuFMHMDCD6Ebgi4apLefzaetbHN4S/HPDHoRSFFM4I3mZqemZDq/2hv3eyPP7jwQRHty7623u7OxSFqu6+2Hy9rq7a8IVTWBu19SEMRUNZt5pF0ANjcjynnQ+2bsLM85buCN2kHn9/6JQYyHBJ/TlfrUA9BzZGIsEtFOGslq9lDT2UACG2nbGZ64Z746tIfuyz2yrE445a6YaYNnlMMZB4ggyFT+RIlf3MX9yIMvbk= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9824fbbc-8d8d-474c-0c1e-08d9baf64d5b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:47.4857 (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: 9mxNfpsAgqMYv5NEKdjpcpHa8Q1WmcdwyPc8epZ1ZqkOifm1qgrQjjjg2fBmcCoOafCywo+0Hi0Np+4+9FxPMMRCkMbWIbrffJHxjQaq1dI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 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 7e4e79b50216..ce094e79f722 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 13f0e4a3a136..1942fe72b3e3 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -269,18 +269,20 @@ tcf_exts_stats_update(const struct tcf_exts *exts, #ifdef CONFIG_NET_CLS_ACT int i; - preempt_disable(); - for (i = 0; i < exts->nr_actions; i++) { struct tc_action *a = exts->actions[i]; - tcf_action_stats_update(a, bytes, packets, drops, - lastuse, true); - a->used_hw_stats = used_hw_stats; - a->used_hw_stats_valid = used_hw_stats_valid; - } + /* if stats from hw, just skip */ + if (tcf_action_update_hw_stats(a)) { + preempt_disable(); + tcf_action_stats_update(a, bytes, packets, drops, + lastuse, true); + preempt_enable(); - preempt_enable(); + a->used_hw_stats = used_hw_stats; + a->used_hw_stats_valid = used_hw_stats_valid; + } + } #endif } diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 1d469029f2cd..4e309b8e49bb 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -245,6 +245,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 = flow_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 = {}; @@ -1317,6 +1348,9 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *p, if (p == NULL) goto errout; + /* update hw stats for this action */ + tcf_action_update_hw_stats(p); + /* compat_mode being true specifies a call that is supposed * to add additional backward compatibility statistic TLVs. */ From patchwork Thu Dec 9 09:28:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666219 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 2CE67C433EF for ; Thu, 9 Dec 2021 09:29:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236267AbhLIJcg (ORCPT ); Thu, 9 Dec 2021 04:32:36 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236246AbhLIJcd (ORCPT ); Thu, 9 Dec 2021 04:32:33 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i0ysTtRaQear/32hKzX+KHufc7nXFjtn0uAJ1nEeouBKrRuq8/wMDyU23epCd4ZmuWVB5eSyiDTMRYJHI2QMmraDvjT20O8WQOfoyj9z2QjssloajBnrLcBt0TH9ER+OE1p0Gnefy60PQfZlUYVCM/pM4AmpJuWQHvmJuCn8IgqKGWyrsEKTDpDkBe0DSO69n3esAdWGriPOKaFOxGfaQdC0xoexSfglw8Pw9ZV8+bgnrzqIX0WuRE5SHtYn+4U3zt6spHu1CO+X2FiR9D8gOaj5ccTwLYRklZcXWeWCYQbmKiEXjHnQxnPL+ue2vf93xz7x9QJ47H0z5C1qSPYHYQ== 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=Lh6WPemjbx317oyN9/BM6DLmJNvc13bAQG0u7nkGCDs=; b=XTxJ5ww20GOyMBUE0au7iXJ4mZzTyN0xk8CL3vnpdT5DoXHpY6jfmhofUnW5pdGit6tHN4UEnUoN/pKaruT2F0FpvUxHSYyalDWpUGv4aSaLtVmmMKYCqe17q411FWwahXkdcgY5nzByNpWPQ/kzN4fOfw14B2UY+aC8XRzSXVTlJjohHtKkNq5LnxziPgPpppb3d/MwRnQ3jG7bStGKThPE0eyCqIB9STkceDycds3jEcQnRx/SQ0ZjR9ye2gyksQSsrSLktBNNZRGp12iJYb2iNVMkIhpeCkARUEcRNpl1CnK7ZbMRqP5dgrgCHuT/cUNoVMXq/vALEkJQPFm/8A== 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=Lh6WPemjbx317oyN9/BM6DLmJNvc13bAQG0u7nkGCDs=; b=EsJqgaDa0fz2lkY1h1D7hbbcVxLK3b/CokK7kFN2WHXWHY5xjnYBmODVALu3pYoZb1nO2jOVPDGCYgqPYbeZrQ2fUkGEN72zdd8o0ErD0tgsBQXSS4BIGoOKfusqMTNlnqHArQlL7VkzpKhqa4hbufGCm5XQvViEUzgZamQBtdU= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28:50 +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.4778.012; Thu, 9 Dec 2021 09:28:50 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 09/12] net: sched: save full flags for tc action Date: Thu, 9 Dec 2021 10:28:03 +0100 Message-Id: <20211209092806.12336-10-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: f6382420-5b1b-4212-3bbd-08d9baf64f01 X-MS-TrafficTypeDiagnostic: PH0PR13MB5494: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: Q+H/9wWv5kb/XtTP3cDZDsc56NfXfktGN+ArgpcvjX1HFUdvgEFN783YqFPXQzt8Zr3ODE3itDb4UHVG6akEfzkDi96vh9tSuJQ/yinj6PESFftesSOfKCyBdTHtZpkORtIwm0mGbiN2eYgi8O/FkNeveP9eHwC5rmJdD5OpWQgrT1KBsvpZx9+eLPFjACMc2aOAsQBAcXFJW04B5b30GqCHaZ6QWD4SXypUGDiFWadGTtLjwTli+gKT/iSeBDoop+bvFV1S3GRTorj+sDh2hWk/wM5P7AGL4q5cTJwL44zswOMNo/WBMoaaePYdCSY+nIk29ptcBP+baKx7lfeASlS4omZvw/h00Qzg46hVhDmYKi50zzSXO+QXu/NjirWU5coxNKr2WSaxcqK2CtCzB++Z5xdSpb4JRarx7mpsb30vmHC5Opq63clL+EphR9YE91VGojK59Vv04uI3N+Tg5W4Fdy2XG1p8adtQq77YCH8ul7/lRunfEM3EDxOhPuPxTvWxBU7uwQ1iw+IWY3SXEGKzESo3rAGc0iZwy6MbBsLy0f8Hz4TOFRWEEuuma2HOP1hb89yXEMTat4fHF70Efp7HaEncVgVXX7HQSTeSkHfjuIfldiXnYIO5mCO/Piow6mgTiXpCyQJu7pX6V1zaOQ== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(86362001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(508600001)(54906003)(66946007)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +YHgXBnNKDnpsnjWXtavkheGZMhu8LnqjqQ0g+Sb/VYObCi0mp7WDv4tuHb9N1Db3G+bbFtr1IdGap/suAQ8pBsn3ur8RO6fFUsQinZOFkhEpkeyI+UU1DUGlWU4QYpfGLaB6bgaPDnPIMsjk/M4vg+MWg9MxmxHc/fqEbzoBz4V8fqjCJkjrjledB3KCNCX7cqNrpi8G9hZuJm/xyXBRPj6sFpqqRt6sCZGk42Zgeyb+OgZq6tesqAHnL3rVVGf7dWPXn4YEfYxqgaqCBw5wSTYmXWAfGcAjn8f2KTWnYWLF3hmxyEbMjS0Hmgt4iYOKE7d5ffR7JwVYmwsHFU61LSZc0kbbgzItGDdlOoiuG6WVO4JXRimp+sm0x4/G19I24eEHSlJy2ocl9XFhi8S7uDKnzt/mH9TGpw9yCYSJtZDyKuXG/ad5FeB50x7zMau6BTn5qtpPKWFi4nkiOTB6R9RCT65xl4tcE4ihRNtjc1FwL9D6/VCMX92if43RodhXUDbbcn3X75RpeJXp6eB+mW/nXtZ81jwGS11b3C/63+PSb1pUU7FKW5bMqisZWqDnGuKxr0G7u2dtVOU93iYiWRcda3WgW/k29derE5147Ei0gBbfnNV1do7wo2N9duywnEPi/UoreuRgVg/tH/3xxWadWD09pRsgJ/pAr/WnnIhxYTmuQ8wxdpCXTYXflqo2HK3oAN+V1RTU6dINxRGepyFSZ5DmrakkRJMn3vnw9IFIljm+LJw0XbYIysfRiM13fuzioNK3Tan5Nf1Yj+E9aeI/7wGWTHlIUIfQBDszrhGcJqG2DyExe7EEidtDf2ITo9H72/YWnLu/EbHy0wUZomwKtBBPXUCdrSfjarv9GaSLbOWvek2yx6uL6ZNMCTYOd/4a+9Uzx6WGH2wAc58t5818B5Vk2x63NE1We2ptDvdU9fL1019hK/BrTxP7JhxyLi4KBS6anaCgzFxYgr41N8XFqJpwh/wpUAT/KEy78KMAnnXGe49LHUBT6mwDnkTGVV7brjvTSzzsiXmhOF8RmDiHtTFgWTj/pAdmdhsL/aR3KIHfk4M+micJtZv34LW6lq89C8zTw8tIfzbXMaG9RmTipq85n0Fcu8kVtVMOl5rNTCQZwEFE8QhH9jQNeFVEUEpTpibRYSn26Fs4nq5+/Ip2iZra9JGpfsU2OerO+UFJN4ox4rDGG4cBo4wqbPyXIkYMnxMOVK57eUY816ZwK3AYU3i9gr0i9G78+BmvyX5UrGjh4UW5nIjZPxvL9saUPGpUCH9XFeRXoB4XIw6kgU3iKJUdWFDopYHBYroMlA9djm/6l/TgSYAurmN3CfpYKm/RTUMEvRmmuQKo+/k7atxuTubIANg5Vw2YZ3zG5qMiCOjiHX8Jw2ljZ2JZfaRdYLMZ5co1n6ODK2RMg0LNpXFh+EnMjN1awQdNAhfxGjsWw+KFKIddSlxU8tX8lEzzL+0Q+BrDRyXbyftJfP0uKKvniXUja/pHzdJiymkq1A6t7ga06Gc+rvPRq6BUmYiRmmycpwj5YC23w62ARhunlwndh7VcnhM/HQ3SmQ9Gtm5LMebzfdzYqf5M7+RoerwwexMGeUxCwpRy5V3WqJ/53PM8UkVK9vUTKdpRAyZgQinRD09sbX//Kx2pjWYXV5S6COtrS20VvbBvzCdf2W02dVjX4JksBDNzJWV62HffU1gfxONBSjfXRaEcc5xzox07/WoDyps/P3Mp4g8yr1rDTm20s1GivT9hfDLFbiIMoM= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6382420-5b1b-4212-3bbd-08d9baf64f01 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:50.1002 (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: eP1Oc9Gj9aYS1wVVv6i3fncNgPzMfu5EnnAJK/OXwP1V77cQUlFP9VOJphR2yZK88Yqei7VaGZFNfEgKHK86+uezCN+N96qJ6SxCvoGQiII= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 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 4e309b8e49bb..e11a73b5934c 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -668,7 +668,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, @@ -995,6 +995,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; @@ -1009,9 +1010,10 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) a->used_hw_stats, TCA_ACT_HW_STATS_ANY)) goto nla_put_failure; - if (a->tcfa_flags && + flags = a->tcfa_flags & TCA_ACT_FLAGS_USER_MASK; + if (flags && nla_put_bitfield32(skb, TCA_ACT_FLAGS, - a->tcfa_flags, a->tcfa_flags)) + flags, flags)) goto nla_put_failure; if (nla_put_u32(skb, TCA_ACT_IN_HW_COUNT, a->in_hw_count)) From patchwork Thu Dec 9 09:28:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666221 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 BAEDAC433EF for ; Thu, 9 Dec 2021 09:29:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236281AbhLIJcq (ORCPT ); Thu, 9 Dec 2021 04:32:46 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236295AbhLIJck (ORCPT ); Thu, 9 Dec 2021 04:32:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YgmDAXx0812EeX6bXouDUYGlKYBLTFkr30zv6lglMZGWeNxR6p3BxIA4EAZTTZVBRm2CvFR+5tw6Zf25OjJPZkuA3idTgg0xUsmmDyOM9y8sLJ3QZyRIwUr9WENmMzh0G9Pz1SoIrKccUdsMJgVtrwv4WbEpTp9/WfDyJ4Lp825rsUVDnpu8yyTN8CfwxJP4QN0QLxi1MV+Jxfd8A9xoZfA3k2qjXK5v15U1DkdF3DZPKa0xrssJpiM28MS8Rjb4BDKwq7CdDqxMWD0Wb8SZrXZ6+H2bzj1r2Znu+LMbyByETB6vuD2J8Gue96vsG0CPylIgAhY2SguoY0ZxZGhIUg== 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=HvpaDlMK2X3ry/GlYCjwdbRvVPvTH+SSfhoqeMONDno=; b=VEaUobJAHxAL8RMDMWiyIguq9xv92Bv94LmUy/RklaG6Wa63NipDntZ8KqEDm+5kwNgCTUHHNJ1+2QUSVfajRcmQ4xxaNlk/VPhzCoPiOrZadc9nurVJ6f6aJBB/0XuSjqCsNI59ww3MURjML4gJQiA4fkxHvpdDGWiv9K8kDUcxH82tdo/+1YUL3tdx7GFRkuCe8bNNhixx/MQHGaDbBHNyeDR5c2bVcMFZtA7YM1/YnY7QTMwTdG29MnqtIF3Gm0f0uUP2x5z6iYcBEc/bVOI1AZoPKWAyjsPIDxw6xy1XmDODUZq4X9Hb+GXrDjUZ1pMN2ekARporTgkvmLeeBA== 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=HvpaDlMK2X3ry/GlYCjwdbRvVPvTH+SSfhoqeMONDno=; b=GavY+6ptRsuNv7d4w7Zc6n7Nvd6ACD+yjlVC+y/e/cBAyu/zjfTabTuW5zti4cdUFrS52Kw9Z4lfuhbiCmDYkRRsLE5PKDuIOmtlKxn1N0gNqKL0u5aReNvZir3oEhMnArJG8QaSk5qgrhWluF13xY06VVnV5BrkFVWw3kR2Hr4= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28: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.4778.012; Thu, 9 Dec 2021 09:28:53 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 10/12] flow_offload: add reoffload process to update hw_count Date: Thu, 9 Dec 2021 10:28:04 +0100 Message-Id: <20211209092806.12336-11-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: 745a40f0-f6fb-41be-d78a-08d9baf650bc X-MS-TrafficTypeDiagnostic: PH0PR13MB5494: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: lP1zW0ZcbzCqe1WAZUtPFMdb7BlV/eTFa/7KeEiXOwoY0k6bem/CMgVHoxBaqIM2zEZ2tYybcCI78E04OVUyZE0ZDI9mCDbdOhtHdeyUFuFyfg8M+glyz0rIcIClov9IUJbF3KL8/fjmVUDbBf1Z1iZnTr43T7BqByk3nzaxTV3x7LSWW21Zx9mlthMsev1XrB6e1zEq7wKKh19ZJR+q5Toa2TNnoO+eu0SbeWTuL139Nq33uic0r1OpWA7jLWbT++68YGmz0BBvVW3eiSWiMk42s3J9mo/NkzZ07MpKVo05mqmJf5EDKlOzERBgyrLdgAVe4remfPRhQ1XLIgbarWXedQR5vcWsrf/ow0TyuvfjVJXozc2pYE2ZL7fBhKKfNb6p+FjsjhZ5u2GThGRLj9YT2m+A4bPTvA5J6A0bg+dS/SprXcBPdoyJYv8pFbpVhe9VX+9njjtlD164Pei0l8dp6VvArnXJQbzuNEIx4lHb/4TNa6/J71hCN+3dKsdvgeujc9xVrn8zHvI+SbYOKhRa2fYLu7uzAau0+PKAaU4IVZEbQ8zdx2epqH+zM7g98VrLFXkdFSTl1Y3VnD4wvsrJV3ztJw+sKrUsH07OfeF62Y76nhA69B8ksnw4Mp+PaBq2KNkKLxpjKuXRTdSc3A== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(86362001)(15650500001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(30864003)(508600001)(54906003)(66946007)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +drf0qHf4pvOeVld9WTIbptFAqjO5tzOXFVFyRJRbgt63TxXdyElg0S6O5dMo7k7cf8c84xyV8jt4++XgVHac2brAAerIdyGFzSe8W+f9MI4OWvKbdFP5MFoUTYQnC4kjMoykT7dN1PgMIzslayqjKDf63Q7BwC9QWIQPgatAqbGq1H3zeTMHCJqmZ+Uxg9ppLC/cwZn98E8CZtywa1aEQvix60rrYuxUZZZnQKTuSIBckAaTGegCDw9ff7so04heMA6ws/q46fOTsIwB8SGatIfz5b7WaIcYyLjXY/9RP1Skgh1FDXSVl6LrwpDL7uQddsp/VBMFxxxqxTdvc/H7UnRZJJTE3/hP7Re7kghM5jvZNY4NtOck1zMjEyB70r5nlNvx+FV+hzMoisZbHR+2TvBjv1GCw0SRlApsGTmd93+/SeMGjlCUGzZEXyO8EFVIpnVpdM4ZwSRMucF/LzZeCrnGTiWthAOAp1RhLA/pejeC9PGp+HPUEGsYBZ+dlberbT0SV1MPhfv5Ex68r42nGffWxU1b5bXO8zoD2AfcqhT6hgthAwoZBVFZ//C7Q98Yb2TAKUqn3CLYrydENPp/ZDqkd6EOYf18e9tux66LjubSqYW760ZqWvNcQy1FT7GqFk+OslXVV0WLq+PgyFCw6R3WosQr2UVb2pb+YqXiHP902+UnIerRoR87MQUYnSO+qnBSdKh0InRDq0ONh1/VDy3UPEo8qBekwMFibEhM2r7OYbfxohX9HxhlAu5OLAMOq54Keyo6an4Y0WH/r2XV/BgD2OyYjLyw+43q+3e0h99xHIU8pmxkW0wUpcx65tdRsFggKma1LU2eI38lot6dcNnuLUVHWT8fs8QhuOX3+aO7WaEvrtojg7YTVSuFhQgvGlVEjoU+DPuVq9rSkGJ315iLq298o6nVDEa3/gWUHfV9O1I1NAdzpzegnv/upMl52SUes7Je4FEeIyqwaCtf5bnMFua+1Kd2YObm3hwO0dG7Ky2eo3WqZN0gBOULxvimaufyvH5IfaQ2x7OCDULx0TJOQePPGnujPgJDmEgSFAXXPzmD2Hsnolw3Z2UMm2PT4NQDo4gaF9a5e4gdlHLDjWJvzWApWK0CyMeZPiSq+A0DfZswCZ+eSrER+3ry52tbC80GeUZwwGrtXYtFo3qp2WcFK39Mcpsm9vMK5Tf+YMtv7O+mAWfG4vkP5X1vYGW/Kv15Et0+9BAD0Ji8Kz/rekRkTqxvBT1qr3qq/uT9NEZhS0zhlOgDQ4Q/+il9MBPC3P0Mu17XVbnvg/YpgFxpNA5bk05+r1rVzCu/Y/t91Rb+iSn81QNomYQ8DZLxyoaVJs+2p7eAprm2hcD9DCUJHDcgx9r3eZHRRTgt2uffB+srIsS7aq2Efso8PiHCiWSYlJK5ZxrNWh5MbmlrbH72O9EjdoZGV7qXLVC07Gga/Qq936dwT2/uPlYAquesQUBGFU6mJcup5Mo1TDosRs3n+mgNkMPDh2qShkvGCUea5E2uIb1zivSBFG4uXavWAU2dqVmeFp+vLKIq+sf7996kHeusanMHUWwTL5h7LiM/KSbDUGuZCiUyJc2NEUqeOAewIoGaHT7TCo2v2Dw8YChYaY5Q3RaKjhD5YFKDLktZOqZM6jZEFq4D7BUaMb1/JD+bcnfBg6q3kMXH3KxCVpm0WUJMRrogLG9wNMsU33NbgRJRgLSI3HlUnZ6D+hw/WbEnzzSJ2oDSvGUi7pZm41ZzIs/CAUmnjr8xkUBuOk0k34= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 745a40f0-f6fb-41be-d78a-08d9baf650bc X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:53.1966 (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: uU0HeEH5IAX6D+7t+WCxHieI4eAgfMD9dgrI+ySBguE7JhbpTVTApsW70S3EwXtMn8DnzpaoJnC81cXLCZH/VC1gGdOuf41eVuWKBY3/cgo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 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 | 250 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 249 insertions(+), 16 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index ce094e79f722..87ad1d3f2063 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 31273a10086e..5538b289cd54 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 e11a73b5934c..668e596b539c 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -137,6 +137,19 @@ static void flow_action_hw_count_set(struct tc_action *act, act->in_hw_count = hw_count; } +static void flow_action_hw_count_inc(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count += hw_count; +} + +static void flow_action_hw_count_dec(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count = act->in_hw_count > hw_count ? + act->in_hw_count - hw_count : 0; +} + static unsigned int tcf_act_num_actions_single(struct tc_action *act) { if (is_tcf_pedit(act)) @@ -183,9 +196,8 @@ static int flow_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,38 @@ static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, return 0; } +static int tcf_action_offload_cmd_cb_ex(struct flow_offload_action *fl_act, + u32 *hw_count, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) +{ + int err; + + err = cb(NULL, NULL, cb_priv, TC_SETUP_ACT, NULL, fl_act, NULL); + if (err < 0) + return err; + + if (hw_count) + *hw_count = 1; + + return 0; +} + +static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + u32 *hw_count, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) +{ + return cb ? tcf_action_offload_cmd_cb_ex(fl_act, hw_count, + cb, cb_priv) : + tcf_action_offload_cmd_ex(fl_act, hw_count); +} + /* offload the tc command after inserted */ -static int tcf_action_offload_add(struct tc_action *action, - struct netlink_ext_ack *extack) +static int tcf_action_offload_add_ex(struct tc_action *action, + struct netlink_ext_ack *extack, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) { bool skip_sw = tc_act_skip_sw(action->tcfa_flags); struct tc_action *actions[TCA_ACT_MAX_PRIO] = { @@ -230,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) - flow_action_hw_count_set(action, in_hw_count); + cb ? flow_action_hw_count_inc(action, in_hw_count) : + flow_action_hw_count_set(action, in_hw_count); if (skip_sw && !tc_act_in_hw(action)) err = -EINVAL; @@ -245,6 +287,12 @@ static int tcf_action_offload_add(struct tc_action *action, return err; } +static int tcf_action_offload_add(struct tc_action *action, + struct netlink_ext_ack *extack) +{ + return tcf_action_offload_add_ex(action, extack, NULL, NULL); +} + int tcf_action_update_hw_stats(struct tc_action *action) { struct flow_offload_action fl_act = {}; @@ -257,7 +305,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, @@ -276,7 +324,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; @@ -289,16 +339,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) + flow_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); @@ -793,6 +852,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) @@ -811,18 +923,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); @@ -841,8 +966,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); @@ -1594,6 +1722,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 Thu Dec 9 09:28:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666223 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 D4340C433EF for ; Thu, 9 Dec 2021 09:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231617AbhLIJc4 (ORCPT ); Thu, 9 Dec 2021 04:32:56 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236270AbhLIJcs (ORCPT ); Thu, 9 Dec 2021 04:32:48 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JA9CeKD8mVDzY3+2KF1RYA4iopqcpf0BX/cdNnFbjz40jakg/8s7aJlW5CXJB7hA1jIzkFRmWokd544715ehuNwb2WUuVgAMoSw7cA+5CfcJrVq6cRK9KQrFcnGPxeoXn6+ozsaZgAPGly6dVtDY2duL/hUYd756W4BhsxcEl+2+4b3Kwf01Av70OBCxy9UzUT4K6iWZ6TGvSGXxiYPL7zkPG8X9fEjVZ/lscj+b8EwXkw2h26vBUxaXECV/l2tzBdXXmJewq0fgV5vFmvHu87+ciBfMkGeWO6E1jk5ODLNMyf1dQ/Eay0SQQ357mYPbNBFiUZjDnbt0zRiGUdAcxQ== 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=C/lmcJP0n7pHAKNjn3gzEc5hYOQt+3RQl2YyEOWZ2RM=; b=ChmWLladMmjuHYO1v+C2dVVefFwhkDHpU8h1KQPNqoFu02mmRwmSOLcv7tLkLr2AtPs4YISetuvmNMNwgoasLKzhRddFdSvzlHnkh9jfNKaihjqMPZx5FLcawhWCFyvpdPDKEfq+LlUGO30k/ZkdNBUPqavp7/0Q4Vox8Q5/BmWZDxKKCs6ptORrQXX1MWBz2ncPBCQEanZLDhzJRU0wbSAhGJxMgzMGYZFku0EA5rkLPdiZjf430FTAN+Pj73rLyTssBd4+bcXV+xHoQGcdPEoPa9V297Xbe/SYi9IjzBYF4gFzIDKqoiYnGU8diLmjPe5Syp35gmZprI6B/0Af+g== 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=C/lmcJP0n7pHAKNjn3gzEc5hYOQt+3RQl2YyEOWZ2RM=; b=N6uEXJjK59qgIfKgSrNq63z0gbR0EcjnDScMumL4p36qzb9BosHek4x6BuSq5ss1meV0gFMKVQkINXN+fThE8DsZngkNs3D9aNelzLQtnaWYPoUDDKG8WVbrnNNzKs//tIVfAPIk7+NNYxg295beaJI+ajT/kVZJLQkVLrqr5I8= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28:56 +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.4778.012; Thu, 9 Dec 2021 09:28:56 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 11/12] flow_offload: validate flags of filter and actions Date: Thu, 9 Dec 2021 10:28:05 +0100 Message-Id: <20211209092806.12336-12-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: 63ea9ff9-9fb8-4e57-aaca-08d9baf65285 X-MS-TrafficTypeDiagnostic: PH0PR13MB5494: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: 9bJKu7QFxzMXrbj4FmzHtX41z853fbZY7/zV2937gvioGUWpUNb7oH5oOOEroWlUr/8wQuEyi/KV340CusKfzNHYxwwD0HJSc5Mpeu7Ei/gTbvB4hbft+IYdEgmKCFPzEX7fwi7gI1L2nXayUrSXddWQptQMCGsHq+xFFJCU9tNJ0+Z3NfrBMmerI7iqzrDXGR1/4H3fjNo2/pjsIP/iILGAWf53mk7Pyk0vr+mHlZoXuQHI5NaGBODAuQsLsvJGav4wFfmKw4BaKwEVzYnXG/S6rA1UPh/xf14hjN9Sd1Kmv7O5LfzBnUPv3SrYiUMIsHhhIVCyP5yfcFnFoMZaujkyKUex3K/ncmgAJqzD2swjTw5mLGhNL8V2DvyjMY9FC/44nqw72LUwy6x8fTIBsv9j0wb0Lkc2NV57tw1twqLxY2XaSoyAPYoDBjP85+Eto+qDdOEysnjCjAcNotAfotSHipQr9tIcBElxQEiBc8iUK0bI4MyjF4IeCnGKIoKhQa5pLaV9mbMzw6OSnloboKI1jvzrZJ8vEpM0yP7mASduw0Wd4dSezYdKL+5mSaKlDKSdaZv6A7FNjsr9YSBUr5MNYC5+0q5EfWOiNPsWo/od5epBmvdQTKG9vY1eWdKyMVIk5XwkLEUPCSxblEd/YQ== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(86362001)(15650500001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(508600001)(54906003)(66946007)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sg5JcHGfOrNym9H5sS9/9j+Gwrm7f67PirIZSM8rIF2Or9UIS5Xpft2Y8VcEO9KRyXrOelqDIBrU3SKrx3oDDcPUeMIFR+ISw9KKU34cJCHi7OoStKyjZ0MKr1wulKx1nzuH0rpAVnmjsLwgQwNU4jkjkRoe5dKgPlrel8w+KGEbI2hEHEzN0EqNSKv661be9WQ/jX43rPUtrerqF/PdvdfwcNkVJ3bMiM+I8JaIkIsjFcmJwfLlRyIZHjiyzy8O3gZmcMcdLdeh53AEvqflT9zDCWLM6rPcXbJ0ChEDyzOF74ES/Sml/KBCfxAvb6nhyNiqU0TNOBwiQzWUqXrFNodBlQbzmxEYS9IdBwIUV6yvyIQGfyQYwebTEbU6EVexq7GoP8HZiSrAnwiOfo9oWIYs21v9BQbDNwKPtxOWtcj8wh2GEBhN63e1gdVg53OjnpwIibqL9L5G0FrgoSCf39GLQCKNCzoe5NsZC5NN10bP1ZXWaJ9YAEKKsbl9SYYC03coPbfgFp1ea94S1lvM2zXY7OoLRlqDSCyaSxAfa+0znffF/dVfiBY2A074bjbNQHCLZv902a5TlQXWKJcS4hS+OS14tuQqfGuHumIksyS/FodHiy38ap0aW0eNdo7eXfGkB6lB6Y1i3H+JE4jnPeJ5DH6Z67cta13YqlYJLyVYqusBkgGe9nyXt3mUncPtPGpS3CkShipABdvIHKSlGpXSDzeROsF8d/ITvE9eW97RJeSwCAfU93qpBkaj/rffNngPH66b7TTfGUqMqN9GlBIvmCTfDr1XaUOZEGvRvdJZ9OOuMEE/ISXLxwJRagT7dSyglLLi6aXpNk46BM4DoBy1LC3XEtjtKDQOdvp19LfKL45XH2hdSyJ01XY3HvUGtG8Su9hXyJ4zVMl3ATutylup+M6OfEs//AIa4MDgn+0ZOZhyI1CJzCUWzPGfbQhk3Zfh+l2ZZfj4Wryz0488SFzQqfzNT9SHPbUsPvgHHtW8gBTMeyxc19cRzP6PbuJhxO35/5eLV5xZtzbGgHcQoU/nY3opun0q3il4lha0NLVR8W+VtKP3Ie6a3ThyH8IWJo9rLPjr9eM/fxTtpzOwWJon7N0LWZr8MhBq2XbSDB6lqnXxA5M5t5Wini71fPXgM3tq29VB28nscvvqUEb22NPKq2iCJKjphXNERThUE8pvkqUtsY+JU1ph/AKipUbNua1q7Pk5PrmHo5pBjvfdKB7GHVc2kmaPJJWxs6hw0RViYYf1acdlzGxeKQe1nB2oeHb2sfl+bi2hrT9kObMc7mVbMihJKraL7XXUD+GAiRBieftyxPPVBaybUzJKNqofA1GyarZvQDCQcSV7rAokR4vhGLFlYdYnn/xSMSnwr/Q9YtA4YH0D2FPM8DdHAZy4zI1UR0tn/uO4hEX3g+XZR4+JybaeuxgtBlwhYKyhA+/qDHu1fNJIhOMuIPsmT6neWDlk0+h4atZo7EMU+fbhfYmghghbrg2Y1Bfnm/Z5jw1L6oFy8g7HudRz0CWWkCCP5gkFKbBlIlzB5JPnTtzNt36dFNE74LZqpMhHkHjIJmEtnEmTjzqXX9xbx02176f69nuijsX2Mw4WMhNkAoFRcYxBUCobm4n/FUtgs8l+NMcHVV5EM9AYq8SfQl3qXF2HYT2l+oAojPrgQWzsLA841ZmP0v8P1pJ/32CbHn/OGnTEYddBFW4kP+sHJLb5oNfzM7lTil/T2bzxJTZAa1sUoVEYeMoSg80Zr2YiudJaPss= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63ea9ff9-9fb8-4e57-aaca-08d9baf65285 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:56.0302 (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: zFG1N4vlWTfyR5s96ZFQY/J2w1zy8lcKXAX9w7jNHO5RNmfyju/DN2dwy7hDv6BEdA7MfMnUc8/jPWnfK55eOg6R0YR1lrWSBWUKZN22gMc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 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 87ad1d3f2063..39daa1bf1af5 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 1942fe72b3e3..55abc3c1d761 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -326,6 +326,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 668e596b539c..47532806dabd 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1384,7 +1384,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] = {}; @@ -1422,7 +1423,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; @@ -1925,7 +1937,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 2a1cc7fe2dd9..0894a1c90943 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 aab13ba11767..c3a104832a17 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 24f0046ce0b3..a0c2a81d5762 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 Thu Dec 9 09:28:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12666225 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 DE9ECC433FE for ; Thu, 9 Dec 2021 09:29:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236161AbhLIJc5 (ORCPT ); Thu, 9 Dec 2021 04:32:57 -0500 Received: from mail-bn8nam08on2090.outbound.protection.outlook.com ([40.107.100.90]:64096 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229803AbhLIJc4 (ORCPT ); Thu, 9 Dec 2021 04:32:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fdatoI8wW1zgdlzEGFltecHe/wFgzQLwPEfX53LFhyRdu+fovGJQG3LSDpPC0JDG9c7xm9VbYP1HHor1po9WY6Cznt7mpOwwPq4xgapuxwJY5+oSEXz6db+Iss0T09Oy8T5uuEoNOoPc0h4s4WQIpitURft6Rs1uEy+FYIjO8ZVCm1Wl2o/4I+cJWXF5uKt3iCTro6gM7HyFKLI3ZJ3dgO1uwdpINyTTKFhF5XkF2032FP3ZsTdqXsyG7ojg/xNpS0fqhdL/nOgK1MJilrxVLU3VicxUxWd+AaWs6yX/oh1HIeYGhoQzT1aa5vrRJbTbAUl+mD+N4bLdtt5+LkyvnQ== 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=kLD9VLRt+eoIXF9qZ6EZEbTy+gfLtdBLGZEzQQ6ouZ4=; b=TT2yQLhA+ahrpSchlynCc4rXZn1P/Qo34MvH4P56i3lWY8dRsuUfAU7e4ZgCs9X75ZPWPa1rCaC664LXDddoy5vnnNmactMx1RUW/dCdvtqWZvXf6886BqNlzf6KxxyU9XIrwAU2BdepEMTxh5LnrlYdVpGYjPlGLI1H+Gyi4iw6hsyO+/dTviKUFqqAs5AwLpcCnjSVGsvHcdsK4u8qEcdJOftHMOCwjJ+XsqhkVr5rXuIglmUB83zKcJ6zTVfYEf8vDk9JEwu+em6BnAaWIgaJwIVD1GwcY0JIT8+qoBLL3ZrIwyuX8NmItV0Twy76iPK/4yn2C0DIcWs1MaZVVA== 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=kLD9VLRt+eoIXF9qZ6EZEbTy+gfLtdBLGZEzQQ6ouZ4=; b=HTz1+8m7nutem6Le0C242mN9CkZISa60yPXU51N3mvS33t1qj0IvSb+5szDzmw63WkOH46qDJOFOzAXgJJgGM6jpjmBCXj2vvtrEB4ftvX4hbb51phrJMGRmbW7pvQ53hepgdkKaYJDp2DOqmM9/C/wFkirmEOi4X1RYu1/+vyc= 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 PH0PR13MB5494.namprd13.prod.outlook.com (2603:10b6:510:128::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.10; Thu, 9 Dec 2021 09:28: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.4778.012; Thu, 9 Dec 2021 09:28:58 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Dan Carpenter , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com, Simon Horman Subject: [PATCH v6 net-next 12/12] selftests: tc-testing: add action offload selftest for action and filter Date: Thu, 9 Dec 2021 10:28:06 +0100 Message-Id: <20211209092806.12336-13-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211209092806.12336-1-simon.horman@corigine.com> References: <20211209092806.12336-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0068.eurprd03.prod.outlook.com (2603:10a6:207:5::26) 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: 4f7aed65-7fbf-4567-ed9a-08d9baf65419 X-MS-TrafficTypeDiagnostic: PH0PR13MB5494:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n6tC/8LAiebUGCEcfiYuIL5seVflf+cb8OZ4HgMtkUBdqzn+zouvDnH6CmdCaJHmcwohmv7cwjvdhaZK5z3k6RAzx0dfkQiyIW0k+8pIoUy23/wEmjycEFi/l5cfDCHS8/p87N7Nv0z3lpyLeLlyysGFFdhoJtdntUNk7IYeq0SkTIqxc5bOZE70CkXxo0STe9NchMzR3djdyudHUTO3CQV58+iduMsmp6BxTMYpXaGhVsR7RHCrDa6nq8ccomYDa67jq65Un9le/aMCh40pHJb1lO54x+sv6DdYosERpcvrzNU8Lmu8ddofxGATEBHDJSXTFqbDSiq2VHuFGCDR+J0kfUfGSWIrbWiCyt4+8KMyvC89JDF3JgCPQcm5s6e8WgtNxJaTG5aWR86siNk3aUqT+vCogfXDP18Y9E4XZcRaCNT9taOcgzGj4gSlmy/ctd/JfuEFIVMpeSAA/ZeFoBul/7xZyrbyJ47+MYAML5gvItPJB+milrYUKy8Npt2RoNtiemDJKre4fNdTmZ23uxQaAIFgTPq92a71Wc9C6PAx5HrRt5SPglQ/8H5Ix6rm1REto77UykHOBXfBeAAE8ffJWrkYPMMx0Uv1dF4uDnjZSqx2PBBP0b6YiVXbe619I5GaO5QsVoswI2cwhDG7xQ== 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:(39840400004)(396003)(346002)(136003)(376002)(366004)(6666004)(6512007)(44832011)(38100700002)(6916009)(66556008)(86362001)(52116002)(316002)(1076003)(6506007)(8936002)(8676002)(4326008)(36756003)(2906002)(6486002)(5660300002)(186003)(66476007)(2616005)(83380400001)(508600001)(54906003)(66946007)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ti6YcI8CszEZHEOlPexIukFBUOZ4LcYDCXO8oQGtljr3rNocHNu9QmRYIwQPLr3w7hN7cHbh6TNX670xobpjuqEpwNHCNI1aW9hG2CQf0vgeumnv2Wub6Uis5fhf156nMfeCKrUEl8pzHyWX556KjdpK4FNWnit+GlNZtwkhyTqw6vvHkW9ogPsrUN8EIzWlGPb/8rarqZNH0dru79F457RvGw4RDPm6qBJpMgcaXhVsnfcovRMLsVUNe3lL88SMBR00bqUtFyP10Hr2+OPrf3hUbO4lOWNjzn4TiZZEVn3/omJPrkgjddvj2uw2Jhg5zSe5BIZKUV2bF+B9jYTv4unqwbcV+3+ev393Nz6LUKwqERaWFfyH1JQtMXfTrSUdZLdo91+kTi5SfiRmR2L5XEENINwkR9wqRJa9Wa+zbQZMkTpYlTRBDZwPIEeAbYVulXmI7QeoJRqyV9QlHJ/chpXOm2OJh8oqg1BBv4Yq9enswfKFQn1v8Ond5P9mfUQVIqSczNiOx86ZXP8mi25ubGevOA5XasKrN8of/RBNXsvo7fqWHIalYOcOxDQjWIrkPfRTUyxKVclOZbZvp6PuEWMUffbEUlmhLYVLGrGZaEcohiGpSO2YUcrh0WkHephMFBQ5WVXyxOJpiD5Rpoe6K6D+TQBC5SsKUhxTY/6YsYBP5Wc+UTChzwMrF/su1fknibsmMlhfYWh+q2ZkgQGbDjehk0YZK0Ei+ESwltCAbNMZ8OovXIcwnvlZTaOpHO8sMycow3nINwsD01W2AJGrhGP4BWFszCMiTxTZg9ZUAATHVvmvBLmIhsYadxfVdf8E/dxjUUmUl9VuUFugNVG1Gmv7hRlEy75V2ClJGqtqy4hszfKqRwwbrfJzEpNEi4nbdPIRSe+FZ6xmsV1Pb7N7EepCN78lin2wZDAPACdAh4FMxRTzIjtJ98NDwwvv05KH3o5m7zSVsZTYH2nDmjDJRkXb4vcfkWWggBRLUoeA6sLrGbdqgHeFBsj/fCRPr2dZtO9Yac2ETyQRun6pkGn5s0I46PIfUVONR8n2OH3BH/ieLikFVN+OqsiF5U718yyoLfdXKvq8o3KF5Shp+8kImShd3oFhc+9oCOy8iAU5TJ9QbtqoaUSOLau6GxAe4NReOwfuecoplxTncrAv4yK08kMItaDEzR9xla52AXQsffLESc/5U5OO28KPcjwj0GXBKl/MsovdhQe5jEAEAqHOWINDrT514zBNNHpgRGGBmOn89rO/x4dtNiFISS6/+MUgCXiwyVamB7YMKk3wtWqZDvmKmI7xu5SECDMq0BbKd4j8hXLqzT95KP2nZxP2NhBTZ4+xhwy1dyxrSD5GzFt+12GKXQIb3WGZdD1Mi2Ob+nY7DqkQiYafCYPUQCg/cWn2QQmthGJ7Jfku2QH+vPnjeCxoTL9LiseS+cvOY+dNJDuflCBxc//ZLzROmkvvGT1tKz3BYR+ORS/VDxh5QlXG+/3ZiWKK5fFMUVBlHxINPmTJBBhM3r9FOw025Syld1viVNGEpdmspYplsHesvKbqUnOpBEzzWE8fiYfF3aZ5Qzb4ImHRpQpmUifhCIRDkItFjgEi1FufGTtpFgeCK0RiYZ+pWxhksexCaSsiBwn+qbc53BdS1xAXfIIXE6vEG76f0yl2YWennzKVO9dOTmaWO8DuRg2vMVOZU+J9+0hyPy60DmBsTJC2G0K7sbacKeaDT0XaybGWqHyC5p4GPSCB6Z6PJFgiQ0DWcsOWe1fxFZw= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f7aed65-7fbf-4567-ed9a-08d9baf65419 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 09:28:58.7244 (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: LXrjJI3EYoz7snbQT1EYiz5Z6iDfPRNbKlRo9PkBe+nSB02bh2fPFTo2c+lYMv9HbnaPPIGeIM6Q0ee0iqsYN8ymHOZcXj10q2uFe0Lp9Hw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5494 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 Acked-by: Jamal Hadi Salim --- .../tc-testing/tc-tests/actions/police.json | 24 +++++++++++++++++++ .../tc-testing/tc-tests/filters/matchall.json | 24 +++++++++++++++++++ 2 files changed, 48 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..4a8d1c5fff29 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,29 @@ "$TC qdisc del dev $DUMMY ingress", "$IP link del dev $DUMMY type dummy" ] + }, + { + "id": "3329", + "name": "Validate flags of the matchall filter and police action with skip_sw", + "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" + ] } ]