From patchwork Thu Nov 18 13:07: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: 12626973 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CA54C433F5 for ; Thu, 18 Nov 2021 13:08:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0075361026 for ; Thu, 18 Nov 2021 13:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229624AbhKRNLX (ORCPT ); Thu, 18 Nov 2021 08:11:23 -0500 Received: from mail-dm6nam12on2106.outbound.protection.outlook.com ([40.107.243.106]:52384 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229674AbhKRNLV (ORCPT ); Thu, 18 Nov 2021 08:11:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VxHAE4S0wCyQjl7rB3HtkE+/4gqBnDFmtPUbeCr6/tXe6TO76dAuE7Ys05oHYpIsDvsNdlEFcrngdOmJglvTRruJwKzTDMxlMi/ZOYAnZfzj+2X8kZKRnHn15TCwnU6Ywk58ig2uLYKkqSWV2hsIMAIfP8HWqDuJcXHiAgKDhVsKL8ttPcgCuWe62Mhc2S5NkUFAqnSUjHo7kc/arf6vrwknXMqlHqIDLYQ4rP8lerSeFpxe0QpTgVkHznd5RZyNIwS9hA0DjxZQYeByxhJuewTP1me2vsnMv28xEWffj4Xpx2+XobeQpWxR0BwQ2hxjfahWSD+8Xo63v9CXIGXvTg== 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=SN86wcMTwXleQFYy6RsxgUHQShK+9WSEo0+gNF89zZ/Iffv3hQqw3iaabd6kqEDZEna3AZphZ+9N0DHhIke6BQxrZZncJ+o+h+hdfK/+y5uEi+CykSBM2SE9FWT4hEhdV4YB/YUBWJy1tely34fvWwrwC4h5Yu6NQX/fJ/GMlouzronDljE63LcrfL87I9Lak4+RH2R0jQZhA7tgIdBqaYx7Kn13ejjyDykc9R2TaUB8DmWRg8F4k0e7OIil/UWKRbsXDrxSimm2xatu97gevvN4tAp8Qr802fbXJ4vpdG8wda+ic4rMNWbraJpfoVXL+6R4JgSPOYynpwyoVSXHEw== 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=rPprk3IPAEr3WBuxkSGiPQ0sbZhgzdxzEAXU12EzCwoqV7/l2ws1oS0C+py3sskXulVsjo/4Ut6UfRXi9csCp3fI5gBdfaL86YhYzktkg6d3FqG4hpNRCadty2SbDvNVyH2wq8ooEkFUejayZUiYygGoQtVZByCeQlMxy/5t8YE= 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 PH0PR13MB5422.namprd13.prod.outlook.com (2603:10b6:510:128::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.10; Thu, 18 Nov 2021 13:08:20 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7%7]) with mapi id 15.20.4713.016; Thu, 18 Nov 2021 13:08:20 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com Subject: [PATCH v4 01/10] flow_offload: fill flags to action structure Date: Thu, 18 Nov 2021 14:07:56 +0100 Message-Id: <20211118130805.23897-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211118130805.23897-1-simon.horman@corigine.com> References: <20211118130805.23897-1-simon.horman@corigine.com> X-ClientProxiedBy: AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:404:a2a4:c5ff:fe4c:9ce9) by AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 13:08:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bd74c7ff-8fab-4778-8465-08d9aa947e15 X-MS-TrafficTypeDiagnostic: PH0PR13MB5422: 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: 1FvoWj+IC4zPtQ5Th3BArXmkqJz3xOSQ075ifMw/ZiolX6ZDzXPmvQUZ4wn/OHds7VIVmV9yGM/FlEsqpycZ1OFLbF63J+accjnZ9eh5LkndM83dhpqVYQnU8pqGoawhJZAB8m8FMXBLlYoaQTu6SgHAr4+WbeagIM7bYu3WzEB3viA1D57kRpzbOdEhq7wy9eQeYmL5g5dYPCEbJ7HK7gAwkMzYFa2i0PDcOLzmzhY08UFB/ktLRRgXJHURVbfbfP6bd+q+nngQmvyMCh0OZHzVp12w4agKjwumdlxOw6T5oLk9q/m5qIi23Fvq52AfzWpDAw3p2V/d38vGPD6Wwev4nzEbzfY3L+2ejT/6Mje5O1GU/AIHQ9koIVcntP78FWNX1y1l2vR6rx2Bjrpg+7U+SWT+z8LBOq3XCOgW20h7KKxZWSWQ81y5dLzKrPfZ4a/qGB6o1snGHjgWuBmS0xzUCn1uA7/pMBi53qNRTFu519d4PVOl8yQsVezgmjxySgMOXS925uG81t2SukfLYRXDj7g7QvkAGOzaZla25hwL7n2ke4s+7K+yzRURVetw7W/EgnWNjDUL+rk9ippS9Uq+iITdrew+qXkBFUHSS408QJBMVQRAULmpxbx3aSsYjsjs/4hl9r/VyJg5uD6yOw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(39830400003)(136003)(376002)(346002)(6486002)(2906002)(54906003)(6666004)(316002)(86362001)(52116002)(6506007)(1076003)(38100700002)(186003)(6916009)(107886003)(2616005)(44832011)(5660300002)(4326008)(8676002)(508600001)(66946007)(8936002)(36756003)(83380400001)(6512007)(66556008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e4iaHZlQbGoe90ZoHvIE8grgBxLeKYSIJctTd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ir3q/keb4rd51ufQaVHeWtkb5uBPFm31LzytjifIvB7941UU4n3hBNKHA3rxL4qnKLrb5QlrtC64uEGyF/xuvFtm3Vz8SaZyPTNmXo406wLOrXUmJ1yJ7vqCs3Gb+gkD3FDH+3kYC2yAaGHM4y5Pw+x/9nuiBLPU/3F5XufD0UgbE+mitpCZgfNnnJwkkVfTX09akaztsc6TmpNiKwJV8h3fKSphw3j4XVH6bX3rpL+uD00NzwChD6Nj9gEVO4ciL1qitJEwBdk/Pu0kMG5K5O4hbBsUKGDIIYPq2NqEHNhUWrTzrJ+CKsoEVNkRp3SSPTHeIGpoB4XBavgVgL9ekRm9AcgzaEGkk2SDCWlmpCKoajOnEwF26oRiejQ5H70U2dn9xtHZhH6VRqOq1drlaQz9GV3TJE0WFkINiP6NQHlAQcJaQigvu22HoH6W5tiguxn5LIvqz9taoQxLZow84hsR4+62f0fGIH2+gg7e+mhZ9D1lJ1SBZXcHvfi8KXtE3WWPvBqxmw5bRduT7AU+9ZU8HNf6dF8pLGkyCYiVAUr4psAXLj74fSE19mMmKddMKl1DLaEwychSApwqan8+hlY29ZiJIb8E0KPUTalVXoi9bc9rXctg19o14TtxVZUClkGgbW3I4KL+KHHiVjVigg= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd74c7ff-8fab-4778-8465-08d9aa947e15 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 13:08:19.8479 (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: xhs9yZ6UjmAjo7VK/8qEr7MbNPiexUdXYxwWOp8y1wNPfNGFtcpjnphs+jy//mkZhckuHssFSzk2aBwdF6WFrTmFBdrrkUZcJeLRCq4z2I4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5422 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Baowen Zheng Fill flags to action structure to allow user control if the action should be offloaded to hardware or not. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- net/sched/act_bpf.c | 2 +- net/sched/act_connmark.c | 2 +- net/sched/act_ctinfo.c | 2 +- net/sched/act_gate.c | 2 +- net/sched/act_ife.c | 2 +- net/sched/act_ipt.c | 2 +- net/sched/act_mpls.c | 2 +- net/sched/act_nat.c | 2 +- net/sched/act_pedit.c | 2 +- net/sched/act_police.c | 2 +- net/sched/act_sample.c | 2 +- net/sched/act_simple.c | 2 +- net/sched/act_skbedit.c | 2 +- net/sched/act_skbmod.c | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index f2bf896331a5..a77d8908e737 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c @@ -305,7 +305,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, ret = tcf_idr_check_alloc(tn, &index, act, bind); if (!ret) { ret = tcf_idr_create(tn, index, est, act, - &act_bpf_ops, bind, true, 0); + &act_bpf_ops, bind, true, flags); if (ret < 0) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_connmark.c b/net/sched/act_connmark.c index 94e78ac7a748..09e2aafc8943 100644 --- a/net/sched/act_connmark.c +++ b/net/sched/act_connmark.c @@ -124,7 +124,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, ret = tcf_idr_check_alloc(tn, &index, a, bind); if (!ret) { ret = tcf_idr_create(tn, index, est, a, - &act_connmark_ops, bind, false, 0); + &act_connmark_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c index 549374a2d008..0281e45987a4 100644 --- a/net/sched/act_ctinfo.c +++ b/net/sched/act_ctinfo.c @@ -212,7 +212,7 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_ctinfo_ops, bind, false, 0); + &act_ctinfo_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c index 7df72a4197a3..ac985c53ebaf 100644 --- a/net/sched/act_gate.c +++ b/net/sched/act_gate.c @@ -357,7 +357,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla, if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_gate_ops, bind, false, 0); + &act_gate_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index b757f90a2d58..41ba55e60b1b 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c @@ -553,7 +553,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, &act_ife_ops, - bind, true, 0); + bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); kfree(p); diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 265b1443e252..2f3d507c24a1 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c @@ -145,7 +145,7 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, ops, bind, - false, 0); + false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index 8faa4c58305e..2b30dc562743 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -248,7 +248,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_mpls_ops, bind, true, 0); + &act_mpls_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c index 7dd6b586ba7f..2a39b3729e84 100644 --- a/net/sched/act_nat.c +++ b/net/sched/act_nat.c @@ -61,7 +61,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_nat_ops, bind, false, 0); + &act_nat_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index c6c862c459cc..cd3b8aad3192 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -189,7 +189,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_pedit_ops, bind, false, 0); + &act_pedit_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); goto out_free; diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 9e77ba8401e5..c13a6245dfba 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -90,7 +90,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, NULL, a, - &act_police_ops, bind, true, 0); + &act_police_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index ce859b0e0deb..91a7a93d5f6a 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -70,7 +70,7 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_sample_ops, bind, true, 0); + &act_sample_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index e617ab4505ca..8c1d60bde93e 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c @@ -129,7 +129,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_simp_ops, bind, false, 0); + &act_simp_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index d30ecbfc8f84..cb2d10d3dcc0 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -176,7 +176,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_skbedit_ops, bind, true, 0); + &act_skbedit_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c index 9b6b52c5e24e..2083612d8780 100644 --- a/net/sched/act_skbmod.c +++ b/net/sched/act_skbmod.c @@ -168,7 +168,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_skbmod_ops, bind, true, 0); + &act_skbmod_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; From patchwork Thu Nov 18 13:07: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: 12626975 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA3F1C433F5 for ; Thu, 18 Nov 2021 13:08:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E32B61ABA for ; Thu, 18 Nov 2021 13:08:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230088AbhKRNLZ (ORCPT ); Thu, 18 Nov 2021 08:11:25 -0500 Received: from mail-dm6nam12on2116.outbound.protection.outlook.com ([40.107.243.116]:35937 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229926AbhKRNLX (ORCPT ); Thu, 18 Nov 2021 08:11:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LrHBN90DRhQMIbmGF6/XeMKcoRYIyyN0ouuFcLtB+9wpH3APEsTnLPv9n8L4aHYhBBZl3lkYfbPLQS5fG0zqOcuuqhktarAvBIwiSkXxpQSDLX4vK8S7EkqymSpS7Fu0uZ7odQkktTwrU4CftYFexfTqR3RM8vrcppakJzCEHJdaoWH6atGVrwye81mllpaXXKCu/LnXoOhehOmX3QJrGqyuu8275lcGj3iGWsXozwEse8Zy/yqWYopuSfMUcDLJ+iyYwAPMtzKoMXsCEuoyFjSQ4AylZfB2piYfbMdCoXPoFKTc1/OeU2hO/alRCapBygr8O1XSOzDZRENZTrtFNA== 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=IKgMD78T+BBXTZoPJgrErs2iq9YAMppak90n+eVV24w=; b=O7lDa3o9e+PLFTILthreRXB2FXnhZ66zK0qIZTzUplgtLBO6OBkPgwPvvASOMECuB+O92LjefbndktwtPVE1nDHfwEBk53PgRuIWD5d/ehA/HrSPe3/H9trUIW6OrBOgY28Ea73PuIdZjVQ7E+0gKiA6TuzC1f8cxlYII0EZRurDYYfMpzRLn2/H9gMBQHE4FvERgaYIOWRWLHS0ZuHDKeBueJaGv46FwANjipBNbXmqjD3RrMyT4RYsiQPcHHKI3LoTyxYuVUSS0gLKVIOIdw2Y8zoFftMQ4xZFV98zRktc53lG8sYq+YigfuW7/WOziGTSvFrIFG3eLI+y6BGImQ== 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=IKgMD78T+BBXTZoPJgrErs2iq9YAMppak90n+eVV24w=; b=nDIFBtr5ghBA6SYV+InesC7lZv1IoyaebNo8LZp3TZeRSslI14R/HvGjWrf4uDni5AIoEYNUhwJtJAC5nzoucSJ2K4WzUG8Z2yEtIJafYqKkA/RW97K8H9GSQsJS01jAqNPESu3XOixw7b8zZMYiNf6lwBdcJEbN+QG9+ONQTfA= 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 PH0PR13MB5422.namprd13.prod.outlook.com (2603:10b6:510:128::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.10; Thu, 18 Nov 2021 13:08:22 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7%7]) with mapi id 15.20.4713.016; Thu, 18 Nov 2021 13:08:22 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com Subject: [PATCH v4 02/10] flow_offload: reject to offload tc actions in offload drivers Date: Thu, 18 Nov 2021 14:07:57 +0100 Message-Id: <20211118130805.23897-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211118130805.23897-1-simon.horman@corigine.com> References: <20211118130805.23897-1-simon.horman@corigine.com> X-ClientProxiedBy: AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:404:a2a4:c5ff:fe4c:9ce9) by AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 13:08:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73b484cd-cb25-4906-63a4-08d9aa947f67 X-MS-TrafficTypeDiagnostic: PH0PR13MB5422: 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: dpddt4zat/oFi5KSsK4Fk/1KgkWC2qwjQxMpzgzIrFCYN/0Q7jfwxO03rsoHNKz3zYNU/4n6cYv4oaPz7T6E8BY6rRAlj8GTXZnl10AXuxHl17bRZE6GiR8LXlcbzIxgswztuMYAm9+FCxHqNhhItzSJmkrJfhYKvA8Cqy2cGyOyt7qH9Xnes/Irc7CLzuoemvENnWpf04ayxcW5tLNabdgqxPN77b9GjleiiREew0bkz5oAXsOPGq6+o+czAW/EckCxjixywLzO3rJzDWQp+NoGenVmCRdT+JFDDBotSfFbLnKI22Tc1NXZXVBxrnP4hky1Ujd+ISRn9J7wjAxhymvkCE1mxrDIRee1fQqwV/8tdjxmMUDrAAZnAAFn6xqFhJvng9ne/FC2L93dAmXgpnG6k2h9vza65yxkQIMtYDU5M5zmhwg3ndNAULK/ZhrbZTpVuxCJS+NhVDsbL+yYKswitIeNfIoPSsjwWnr2c/ZqLBs9REmxqn/ZrcYPSkeH8GY0fPPPE//IDc3JbLgGRUfKmx6uNxwya/ZxM7K4kkWRCZMYhzjFUnOFpXrPSaL8PMtzE2+Iyj8eVpkOUdUJs9wI/EgwGLuK07fBOrmvOdLKWPUu9A9YaRIo7BqlkeuUxmwMe3RihxmlFi4967BXhw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(39830400003)(136003)(376002)(346002)(6486002)(2906002)(54906003)(6666004)(316002)(86362001)(52116002)(6506007)(1076003)(38100700002)(186003)(6916009)(107886003)(2616005)(44832011)(5660300002)(4326008)(8676002)(508600001)(66946007)(8936002)(36756003)(83380400001)(6512007)(66556008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ijqAqwPR+N1l4HDKXDEZgGdecBn8yW5KCMtSZtZbqMYKVC7dsg/gaBCAshpZsCbYVwNlmPdf09FX0VOKN+npt74Y37BGdtlb22MtGSEcdBXZ5Xv88QVfoKt/S0wRhrDhVhg3woW2ateNRe5qPJSEcArT71ulDcIw5AYjxwrJXjqfPgXnyZOokNjlzvRGSAlUprlD7KfaUm6C5uvuqW3pzyyRwJ+Q2uWDHvoXZ9Kd7a5nqBMtc+xAEdhsQ+ymUqhWgPr09OsMk1AnY4pdrQYBOEv0766XM3oRGb4S4w9rk4W0HDUwnNcp87VHwjckVm3r46ksnKOWZ+Fu1UlCOUZScjKrpLcxYr8JSf1ntW9qL3Gul5ncq3FSMmyFOVPZgRm+e8JebmJW8mrdj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F5/WaE5mVz3jBraCf3TXJP6ASJufqNVosOu0jV/ojoncuxngPwrL3KuWw97vEsBvQZ10MW+qgXzd9r9ImLuQecq2tkkxokCH3X4CsUmm2zKmTqgpJUj7RBwu78MWBEvBFVsNHzQRPkfJQku1QMRgzffYzH0UXn9m0y8yVdWLs9Oynzlvbg2WmFDXfwMDXvGTPD8xsNXkNHXPMQfdrlRL7PNEpTfXpzfAqVBkp5S2ZAt4FTxL+2Cspa1qtmQwREoKQK9We4djNbyuz9XJkmCMfNc/R1Pr9ntPG5JE1MtuUpqZbE= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73b484cd-cb25-4906-63a4-08d9aa947f67 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 13:08:22.1468 (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: h7sYyinFqjNFzAgAphzYjTHdMV9v3BjGf0FUmYrCmIJUWcJooRcVUDOcpGczENdmYp9/FGgd/eymVnfgGjWw0e5PevkTe49I5a4zT/btsrU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5422 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 --- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 3 +++ drivers/net/ethernet/netronome/nfp/flower/offload.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c index e6a4a768b10b..8c9bab932478 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c @@ -1962,7 +1962,7 @@ static int bnxt_tc_setup_indr_cb(struct net_device *netdev, struct Qdisc *sch, v void *data, void (*cleanup)(struct flow_block_cb *block_cb)) { - if (!bnxt_is_netdev_indr_offload(netdev)) + if (!netdev || !bnxt_is_netdev_indr_offload(netdev)) return -EOPNOTSUPP; switch (type) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c index 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 Nov 18 13:07: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: 12626977 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EECA6C433EF for ; Thu, 18 Nov 2021 13:08:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D616A61ABA for ; Thu, 18 Nov 2021 13:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230146AbhKRNLd (ORCPT ); Thu, 18 Nov 2021 08:11:33 -0500 Received: from mail-dm6nam12on2124.outbound.protection.outlook.com ([40.107.243.124]:6945 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230105AbhKRNL0 (ORCPT ); Thu, 18 Nov 2021 08:11:26 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RaZiPH5/kA94VdWppSHBvgTXkZy+rm4yERUwCU0x/Lzsel5joSE2f26LUYrPgb6un1auObX9DM1j+QiOyZQjW2ZNNwDEy1O0D2Ed8gWisWgaXld6z0M/PFbVkOpaFACtTDz4KvRwgSvZ4DSaBW7/O85gp+mJ4kSPlBS1xw+Kcgtn1Xa2Hyu/yOWAm1gdDCCPaN5LY/CNOsQJopl3gzufVQR59wwbSaD37hxFOPttjUS8WShzSJGz+SDyz3Jo5lhpBqGrkUkiWHNpogJaYmOFj66yx/f7qV4F4+HjZ0Hg3V5OuX1thl0BEPSEzl+W5uuj1AXGw75UaiEBQSyId70+uA== 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=Ek1rwnU9+tgZx3wdUBg5ANZwSq3RjpJtHq8v6CpT7DY=; b=Fg+TrxUMvLxyqTQh1qegWKF1+/novxvPbRLBoc3OqEpWqkLL2rNIOJh/qCwxqRMqH+3gcnAVDsJgzhh7Oj/ovsrdjhLg5HZsHnRRA4UbQH6Tes19xD2KV+CJzWzpwRLkWawkVMWfFmfcLLR1v6sqgo9e4qu8CyGsQqrU1KVzKhPwy7I741L+sGnSfeYgo7QU3/iT699rWCophyrdJL5Y8DTDpSsc5mup3dQvkWxil9E5mFaQwoHKAwdKR5I5vv8YPir1htBwA9g0K2mC1Hl+eeW7EwyvkJhjfTSFLKSSRhPiPImY0WQXTPyeHBn5hSRZBAyHkGS6t8dNtIYs6r+hHA== 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=Ek1rwnU9+tgZx3wdUBg5ANZwSq3RjpJtHq8v6CpT7DY=; b=i+R6K2iK1tzBziwdNc4P2lNxvNhANjVybmNtNgnzrv1YI3wX6ZiLYsAr6dj1a9DQI2ggv1JBASH1nRNqzlgibGoTOz1yBsi/oDPodCGPbbu7tCCIPxdRndeFaw4Dd+setWYL/7eEWNUmjb7xzIOBOT1cgC/ib8JPJx38QAqeTeU= 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 PH0PR13MB5422.namprd13.prod.outlook.com (2603:10b6:510:128::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.10; Thu, 18 Nov 2021 13:08:24 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7%7]) with mapi id 15.20.4713.016; Thu, 18 Nov 2021 13:08:24 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com Subject: [PATCH v4 03/10] flow_offload: add index to flow_action_entry structure Date: Thu, 18 Nov 2021 14:07:58 +0100 Message-Id: <20211118130805.23897-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211118130805.23897-1-simon.horman@corigine.com> References: <20211118130805.23897-1-simon.horman@corigine.com> X-ClientProxiedBy: AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:404:a2a4:c5ff:fe4c:9ce9) by AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 13:08:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f994185b-fd38-4875-e8b2-08d9aa9480c8 X-MS-TrafficTypeDiagnostic: PH0PR13MB5422: 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: 8dimG6P+egL7sOwXgpDL3SwO5014hV7oOaTp6p9BZHMWIc0hVV640Vyo5n81DobtPWs9wyvZQwmfKl4Ku+SSi4eWnpZR+f3VxEdU6MS0vhFBg169Wus/ct5COnheNzFEbx9XOJj1UgLxU7/hxbdawawXAhqnbFHeW9qno+E/OJ/S5sGU10rRc7SU2MQc9lQzvoZITzu1058qXl0SG8FADbJDXZMcwau0y3UXjx6nJXDDf6icgyaulS5VyCclT0Pjq+MFYHeUoVGjIo5O0zS96WcHuSIZTdXJQksARuyG9iNGKKQcxZ48gbEV+sgD2PZmeN2Id8VGk9z7SrPQYYTcwB9auAL7NxxmpYpqrcGmCqcVnMNWF94WuA+4QPNkI2rBqkSHs9Kik36oFGVcesvC3U5G5OYWKx4lw/mSUG7mFQVarJU+t8YngsN4UkhVRI6wJ5ubIAFTTkR0M1a1EIt6DBP/jR+ukEHhYi4/J5TIhb9hIzteLbgLjpM0PKyPUeBwTAvqM5szxgYfp6fsGND301NXlGUr93B2L6eq/bOjrcWtNGakItBlApqAK93FbCuOrqGSPRj9/sjGsmoFxxj454eC843w8lDRP3zsjxfaBS9PcJFWucpodVl9JFmfRTwXQYsON4porYFjZyTL/YmFwQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(39830400003)(136003)(376002)(346002)(6486002)(2906002)(54906003)(6666004)(316002)(86362001)(52116002)(6506007)(1076003)(38100700002)(186003)(6916009)(107886003)(2616005)(44832011)(5660300002)(4326008)(8676002)(508600001)(66946007)(8936002)(36756003)(83380400001)(6512007)(66556008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pCDkXst3d+tW5df+bB02lvcWjltdoDlNeoZ5oWWAGRw+93xheUlraIKef6coKVHqLu6V0V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3eRLLHgQQyqIfKO5HfvDNHxBMYpBimn/mFeQQKQphOWofXZ92msuxOVOfGGm+FjMEoe4l2xIp/paFjbMgjrtODOWuIRLGERilVGO/iMANbPg16uqvg+6Nm7a1JHGLtmeMXgLEGNIk8CT0vB1abVDMFel17SAIomid+OmYo6HbEbzBgAlpeckbl5wpxDLXdU0RKJOIYJs0xOzFFjSjs5k/sjc9X4Vwcv9zqK0gbypUgQ+rUB9ZkzFybLVuPt6oVX6vI6aW+SqRjhvjDWRZqA0yq5VqidUJCXi3PlLbxhgPQkVL5qp9kERMZn+YNtL0ab5NAkDOFFvF7x7A6A6zctma3auBpgj82LMSw+GlY5TeYJpBQo2c2beV+XiBOCV9Rv9AXiLRZuVhw6uLxB9x8noh3gFdT+y0Iw1h86QpYvWLZmr7FpT+2gO+UA0Lvbv5n0dzjKhiFm8kuUZe3QjqYVNciys4v3PoP5n3nmnuE2xz4Y4t405eWTVsnt+jrvnMUjtzkibA2hMPbb8d/GjtyJw10ycdkHD6ybP2vVwro4x1UBl6ekkRsobitLqILpxDzW1AZqlXUL5Y+Lw022uEj7hulkrD6mrDT/a0AK6LIgzslzgBuNwKiGpG6Zc= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f994185b-fd38-4875-e8b2-08d9aa9480c8 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 13:08:24.3721 (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: TsLyF7gcayQBY18E9hnV31aDgnQS5gJ1ncZwFUi7SqW96SXT8H7eiQEkWKdbQPZ5C13fYV9JPsi6O61isaPa89ZhfY2h4oqlSj0JowmcbnE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5422 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/sja1105/sja1105_flower.c | 2 +- drivers/net/ethernet/freescale/enetc/enetc_qos.c | 6 +++--- drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 2 +- include/net/flow_offload.h | 3 +-- include/net/tc_act/tc_gate.h | 5 ----- net/sched/cls_api.c | 3 +-- 6 files changed, 7 insertions(+), 14 deletions(-) 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/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 Nov 18 13:07: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: 12626979 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D485C433EF for ; Thu, 18 Nov 2021 13:08:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72FF661ABA for ; Thu, 18 Nov 2021 13:08:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbhKRNLl (ORCPT ); Thu, 18 Nov 2021 08:11:41 -0500 Received: from mail-dm6nam12on2124.outbound.protection.outlook.com ([40.107.243.124]:6945 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229887AbhKRNLc (ORCPT ); Thu, 18 Nov 2021 08:11:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UBf77JcQyOQyZUM3uft2Zs4Sqp7xZn3zE7PhXp7w2Taq2Q6iEHDIsVNF41Ix5bFJvdwYUWzUONOTtb0uo1nhyIZuKkg4AjNL7AX10oRm1cgXXt98pMddpsPEYvK47eqtY1g/ABzQ1rD7MiNWAGcYmbxFJgaMED2NC1pPRaL2XUZCoAqJ18vNxXeqb7OVC1UzGs52QK78nrZlJmU2qfWqK3AaJPAurdDCn+PTAHmOAt1vDMjmYVPf3lYh5VQJ4VYUgzjVhgW+EOvxOU3cFbaiUuyQguS7sopzGXZeqihCnOBkKp3NRDMsiMtegP0KZ8qJyqt2yxVXDqHqBclRnmijJA== 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=mgjvcmGQ7V1WPR1zmAfeMLysgmMkCqXP7JmmdCTKJIs=; b=fAzzimUB/bTI+/ijOr9+BLGY3xEyMLi6l454IsagX4fHIhsDnRlaQG5NZnJVsAvD78VZqsSE7r1OWHvNIKuN6bvy1ozGMY3mqFybUbxi5nAm3nC6aohS4Cg8/pgybU6kRFOKTX1YfxP3SArjBYw3cTVlK60hYx66yEz0+wkSZlc7IBp2SukYWkraMrccsOVo0ZXcHWFWMt36CDJFW3pfxAwGkeFSBeCguDWQxW4iQgGMauhnmqqRpBZssJo1UIgxnpkT8y+K5ZmieXyW/bTKH2TR5ahZCbRx8/8Q9yUbTAF2CkYec8Rsh6BczvuMaJi6Nv6jC1k5+I9FMf25iJuKeA== 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=mgjvcmGQ7V1WPR1zmAfeMLysgmMkCqXP7JmmdCTKJIs=; b=cYpFJQugzlkHxk0TUlw5aQIoBcJc2CtqgRAXxtyz5PGHiMPuXzQ+9OOj5pgTMVNsvQey7uff2IJq/RXhl1jIgBFgUfJs7s4YTe7o5l0GfwHUiN/CkWX6Ao0Fl6PC0BCSuBGFV3Mhlo6J5Qop+3jKNepzpUw3HFicWwRaz9aiPLw= 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 PH0PR13MB5422.namprd13.prod.outlook.com (2603:10b6:510:128::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.10; Thu, 18 Nov 2021 13:08:26 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7%7]) with mapi id 15.20.4713.016; Thu, 18 Nov 2021 13:08:26 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com Subject: [PATCH v4 04/10] flow_offload: allow user to offload tc action to net device Date: Thu, 18 Nov 2021 14:07:59 +0100 Message-Id: <20211118130805.23897-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211118130805.23897-1-simon.horman@corigine.com> References: <20211118130805.23897-1-simon.horman@corigine.com> X-ClientProxiedBy: AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:404:a2a4:c5ff:fe4c:9ce9) by AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 13:08:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81ccfb55-9384-40f6-59a0-08d9aa948218 X-MS-TrafficTypeDiagnostic: PH0PR13MB5422: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:565; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tFsPPFYMDUX1vfElZTsmKf8Z0+UE0/289WJ/byq263vKL+xhRhODQPmT+CuMnwLb5AC1GqmgyXsfh0RiYvpn88+OnOHe9KDCSRbIO6C1MhVZaKHHFG08bz8opXxer0Jk0Lsn0u4sLQxBYVdhDKqCnmDg8FUohb0llnmiG/BoQMuO7DIJHeg9EuxK7xno6Zoc37B5SWCuA/aYU0JU75xvFoM/wxujPfvE/97gFvput50Eqsu9SRsk8xowWGqhg0ne3pdg915V2nkHubHmIpvKi0d55Y4kkqs7emipoyBcKH2lhNgWDkhQcTRxehs55K3wVCjZ4oXK4ri2HCSClyg8Q+m/TOfXeGAgWWot0oPlVK0WZ2wZiRE71FLBiY6pz1u34sOwCuoy7/6S8KWhsbf62fiJa6EENwN/hILFKEfp01i2zGO5NGL1GZ6m1E+vVQjT4OBwHn9qvrWAJI+kuvLhLwJLP1fXXsnhEJ0rld0I2FwZ2c56CDu/haIBFSLfB4c3mnvs8YxmNF+jhSctbKX4He2iYcQyJH2upzrbjA41guWvy2nlYIOzQd4c4UxyT3DAFNVOHmEiv6BGKPr8K3E8bH+KCATPy8cVD8zQVh/Ye3dW2HwB4xtBdINS3S88DGcKA+tukNoHfIMDicgWlI2B1g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(39830400003)(136003)(376002)(346002)(6486002)(2906002)(54906003)(6666004)(316002)(30864003)(86362001)(52116002)(6506007)(1076003)(38100700002)(186003)(6916009)(107886003)(2616005)(44832011)(5660300002)(4326008)(8676002)(508600001)(66946007)(8936002)(36756003)(83380400001)(6512007)(66556008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o98FOawFHbQ1JbBbVnA+8Jy+ZhQZcM2AMwTtB92k7+x0Hu6HuWzQJd3iWS2eeWPvtQ63QDKGCsgFUpLrHvbmFCm4HcAtQSfbQYPqV2JWG9kTsXlDSFwqR0/JOseWT77pV3M7WEQSBtKTm2XTTYDrP6/3cqT6creE/tJ8GtINApXtHNHsAhiBr+C76KKwKZJFAw74GXxPKINSimGviAjhcP4NP5YA+tVEaSrpZXLV0Xcg497hfR7InyCQDLN4oFsQIBlXzGafYmGUf3TfJCwQQ+SCNTKMdHTMPB3OG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LBHfhFpGzNZLUUPUFkldkjsqYuchEGxUYxmLYN5HBQd4yhBIVef/VhI+SAtFpq1ACIVDogt3zHWoLZ5rWOknXNqne3BvN/bMIQXgEnd8e0iLXgHYyjGiU5xzfUtQ1EQkzzXfoeKBFTLmv+IeRXZ/evIzKrJX/6U5FgSznlQT15AhsY2aRMxqA6RZ79nu4XTxGRcQKkhNtpK8176TKUNW3NdDj2/eCkUE6QfDibdLlmHue4lDhZcFXIPlO3pxaCFerB/4GTBQBg6hLLT/eKpJN4oTKMdeBTN+ylFJgp0zM8qoawpeW4IILMiTi/Qbp+SulyW2MTv0SWZLwPeHpZvR8b4kM8pu1/ZX2pCHkhbNeRriK6zJqJxQBoXYKhH3Ue2tgD3HES0I= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81ccfb55-9384-40f6-59a0-08d9aa948218 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 13:08:26.5475 (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: Hevctfop+UP0Ff5zk+76xMEHLxvOpoh7IjkPxL866Mw/XMaGyZAbqKMC/u00vmcBWfsWQqjUAp6Kd2oI9Htfkklo5JiytpOrUDVat5hjc3o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5422 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 | 12 +++ net/core/flow_offload.c | 43 ++++++++-- net/sched/act_api.c | 164 +++++++++++++++++++++++++++++++++++++ net/sched/cls_api.c | 31 ++++++- 6 files changed, 256 insertions(+), 12 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 4f4a299e92de..ae189fcff3c6 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -916,6 +916,7 @@ enum tc_setup_type { TC_SETUP_QDISC_TBF, TC_SETUP_QDISC_FIFO, TC_SETUP_QDISC_HTB, + TC_SETUP_ACT, }; /* These structures hold the attributes of bpf state that are being passed diff --git a/include/net/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..14d098a887d0 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -258,6 +258,14 @@ 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 bool tc_act_bind(u32 flags) +{ + return !!(flags & TCA_ACT_FLAGS_BIND); +} + static inline void tcf_exts_stats_update(const struct tcf_exts *exts, u64 bytes, u64 packets, u64 drops, u64 lastuse, @@ -534,6 +542,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, @@ -554,6 +565,7 @@ int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp, enum tc_setup_type type, void *type_data, void *cb_priv, u32 *flags, unsigned int *in_hw_count); unsigned int tcf_exts_num_actions(struct tcf_exts *exts); +unsigned int tcf_act_num_actions_single(struct tc_action *act); #ifdef CONFIG_NET_CLS_ACT int tcf_qevent_init(struct tcf_qevent *qe, struct Qdisc *sch, diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c index 6beaea13564a..6676431733ef 100644 --- a/net/core/flow_offload.c +++ b/net/core/flow_offload.c @@ -27,6 +27,27 @@ struct flow_rule *flow_rule_alloc(unsigned int num_actions) } EXPORT_SYMBOL(flow_rule_alloc); +struct flow_offload_action *flow_action_alloc(unsigned int num_actions) +{ + struct flow_offload_action *fl_action; + int i; + + fl_action = kzalloc(struct_size(fl_action, action.entries, num_actions), + GFP_KERNEL); + if (!fl_action) + return NULL; + + fl_action->action.num_entries = num_actions; + /* Pre-fill each action hw_stats with DONT_CARE. + * Caller can override this if it wants stats for a given action. + */ + for (i = 0; i < num_actions; i++) + fl_action->action.entries[i].hw_stats = FLOW_ACTION_HW_STATS_DONT_CARE; + + return fl_action; +} +EXPORT_SYMBOL(flow_action_alloc); + #define FLOW_DISSECTOR_MATCH(__rule, __type, __out) \ const struct flow_match *__m = &(__rule)->match; \ struct flow_dissector *__d = (__m)->dissector; \ @@ -549,19 +570,25 @@ int flow_indr_dev_setup_offload(struct net_device *dev, struct Qdisc *sch, void (*cleanup)(struct flow_block_cb *block_cb)) { struct flow_indr_dev *this; + u32 count = 0; + int err; mutex_lock(&flow_indr_block_lock); + if (bo) { + if (bo->command == FLOW_BLOCK_BIND) + indir_dev_add(data, dev, sch, type, cleanup, bo); + else if (bo->command == FLOW_BLOCK_UNBIND) + indir_dev_remove(data); + } - if (bo->command == FLOW_BLOCK_BIND) - indir_dev_add(data, dev, sch, type, cleanup, bo); - else if (bo->command == FLOW_BLOCK_UNBIND) - indir_dev_remove(data); - - list_for_each_entry(this, &flow_block_indr_dev_list, list) - this->cb(dev, sch, this->cb_priv, type, bo, data, cleanup); + list_for_each_entry(this, &flow_block_indr_dev_list, list) { + err = this->cb(dev, sch, this->cb_priv, type, bo, data, cleanup); + if (!err) + count++; + } mutex_unlock(&flow_indr_block_lock); - return list_empty(&bo->cb_list) ? -EOPNOTSUPP : 0; + return (bo && list_empty(&bo->cb_list)) ? -EOPNOTSUPP : count; } EXPORT_SYMBOL(flow_indr_dev_setup_offload); diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 3258da3d5bed..c3d08b710661 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -21,6 +21,19 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef CONFIG_INET DEFINE_STATIC_KEY_FALSE(tcf_frag_xmit_count); @@ -129,8 +142,157 @@ static void free_tcf(struct tc_action *p) kfree(p); } +static int flow_action_init(struct flow_offload_action *fl_action, + struct tc_action *act, + enum flow_act_command cmd, + struct netlink_ext_ack *extack) +{ + if (!fl_action) + return -EINVAL; + + fl_action->extack = extack; + fl_action->command = cmd; + fl_action->index = act->tcfa_index; + + if (is_tcf_gact_ok(act)) { + fl_action->id = FLOW_ACTION_ACCEPT; + } else if (is_tcf_gact_shot(act)) { + fl_action->id = FLOW_ACTION_DROP; + } else if (is_tcf_gact_trap(act)) { + fl_action->id = FLOW_ACTION_TRAP; + } else if (is_tcf_gact_goto_chain(act)) { + fl_action->id = FLOW_ACTION_GOTO; + } else if (is_tcf_mirred_egress_redirect(act)) { + fl_action->id = FLOW_ACTION_REDIRECT; + } else if (is_tcf_mirred_egress_mirror(act)) { + fl_action->id = FLOW_ACTION_MIRRED; + } else if (is_tcf_mirred_ingress_redirect(act)) { + fl_action->id = FLOW_ACTION_REDIRECT_INGRESS; + } else if (is_tcf_mirred_ingress_mirror(act)) { + fl_action->id = FLOW_ACTION_MIRRED_INGRESS; + } else if (is_tcf_vlan(act)) { + switch (tcf_vlan_action(act)) { + case TCA_VLAN_ACT_PUSH: + fl_action->id = FLOW_ACTION_VLAN_PUSH; + break; + case TCA_VLAN_ACT_POP: + fl_action->id = FLOW_ACTION_VLAN_POP; + break; + case TCA_VLAN_ACT_MODIFY: + fl_action->id = FLOW_ACTION_VLAN_MANGLE; + break; + default: + return -EOPNOTSUPP; + } + } else if (is_tcf_tunnel_set(act)) { + fl_action->id = FLOW_ACTION_TUNNEL_ENCAP; + } else if (is_tcf_tunnel_release(act)) { + fl_action->id = FLOW_ACTION_TUNNEL_DECAP; + } else if (is_tcf_csum(act)) { + fl_action->id = FLOW_ACTION_CSUM; + } else if (is_tcf_skbedit_mark(act)) { + fl_action->id = FLOW_ACTION_MARK; + } else if (is_tcf_sample(act)) { + fl_action->id = FLOW_ACTION_SAMPLE; + } else if (is_tcf_police(act)) { + fl_action->id = FLOW_ACTION_POLICE; + } else if (is_tcf_ct(act)) { + fl_action->id = FLOW_ACTION_CT; + } else if (is_tcf_mpls(act)) { + switch (tcf_mpls_action(act)) { + case TCA_MPLS_ACT_PUSH: + fl_action->id = FLOW_ACTION_MPLS_PUSH; + break; + case TCA_MPLS_ACT_POP: + fl_action->id = FLOW_ACTION_MPLS_POP; + break; + case TCA_MPLS_ACT_MODIFY: + fl_action->id = FLOW_ACTION_MPLS_MANGLE; + break; + default: + return -EOPNOTSUPP; + } + } else if (is_tcf_skbedit_ptype(act)) { + fl_action->id = FLOW_ACTION_PTYPE; + } else if (is_tcf_skbedit_priority(act)) { + fl_action->id = FLOW_ACTION_PRIORITY; + } else if (is_tcf_gate(act)) { + fl_action->id = FLOW_ACTION_GATE; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + +static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + struct netlink_ext_ack *extack) +{ + int err; + + if (IS_ERR(fl_act)) + return PTR_ERR(fl_act); + + err = flow_indr_dev_setup_offload(NULL, NULL, TC_SETUP_ACT, + fl_act, NULL, NULL); + if (err < 0) + return err; + + return 0; +} + +/* offload the tc command after inserted */ +static int tcf_action_offload_add(struct tc_action *action, + struct netlink_ext_ack *extack) +{ + struct tc_action *actions[TCA_ACT_MAX_PRIO] = { + [0] = action, + }; + struct flow_offload_action *fl_action; + int err = 0; + + fl_action = flow_action_alloc(tcf_act_num_actions_single(action)); + if (!fl_action) + return -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; + + if (!action) + return -EINVAL; + + err = flow_action_init(&fl_act, action, FLOW_ACT_DESTROY, NULL); + if (err) + return err; + + return tcf_action_offload_cmd(&fl_act, NULL); +} + static void tcf_action_cleanup(struct tc_action *p) { + tcf_action_offload_del(p); if (p->ops->cleanup) p->ops->cleanup(p); @@ -1103,6 +1265,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/cls_api.c b/net/sched/cls_api.c index d9d6ff0bf361..55fa48999d43 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3544,8 +3544,8 @@ static enum flow_action_hw_stats tc_act_hw_stats(u8 hw_stats) return hw_stats; } -int tc_setup_flow_action(struct flow_action *flow_action, - const struct tcf_exts *exts) +int tc_setup_action(struct flow_action *flow_action, + struct tc_action *actions[]) { struct tc_action *act; int i, j, k, err = 0; @@ -3554,11 +3554,11 @@ int tc_setup_flow_action(struct flow_action *flow_action, BUILD_BUG_ON(TCA_ACT_HW_STATS_IMMEDIATE != FLOW_ACTION_HW_STATS_IMMEDIATE); BUILD_BUG_ON(TCA_ACT_HW_STATS_DELAYED != FLOW_ACTION_HW_STATS_DELAYED); - if (!exts) + if (!actions) return 0; j = 0; - tcf_exts_for_each_action(i, act, exts) { + tcf_act_for_each_action(i, act, actions) { struct flow_action_entry *entry; entry = &flow_action->entries[j]; @@ -3724,6 +3724,20 @@ int tc_setup_flow_action(struct flow_action *flow_action, spin_unlock_bh(&act->tcfa_lock); goto err_out; } +EXPORT_SYMBOL(tc_setup_action); + +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) @@ -3742,6 +3756,15 @@ unsigned int tcf_exts_num_actions(struct tcf_exts *exts) } EXPORT_SYMBOL(tcf_exts_num_actions); +unsigned int tcf_act_num_actions_single(struct tc_action *act) +{ + if (is_tcf_pedit(act)) + return tcf_pedit_nkeys(act); + else + return 1; +} +EXPORT_SYMBOL(tcf_act_num_actions_single); + #ifdef CONFIG_NET_CLS_ACT static int tcf_qevent_parse_block_index(struct nlattr *block_index_attr, u32 *p_block_index, From patchwork Thu Nov 18 13:08: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: 12626989 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62A14C433EF for ; Thu, 18 Nov 2021 13:09:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E9B661026 for ; Thu, 18 Nov 2021 13:09:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbhKRNL7 (ORCPT ); Thu, 18 Nov 2021 08:11:59 -0500 Received: from mail-dm6nam12on2130.outbound.protection.outlook.com ([40.107.243.130]:54048 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230158AbhKRNLq (ORCPT ); Thu, 18 Nov 2021 08:11:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gu6XcbAGh/lzVfQs+t+3VECwmL4NjDg65MYMA4A6RPt2CCegfT9nd7QmzbyLa/lIgeCZHWdbRvnsRIZjfKVr6XE7oi+q4KO7qDKZPuDXDqWlbZKjU+a+VNeT6Zaf9MzI8pa703DyqXLVEAQEay+X/u16uRmfCMHhHqaYA5kPKZNinJs71JHzhx4qGS/usG6b5Xwq3YdF4aR/PfFkC47bgdxdwsuQdXsy8bz2fIPG/B0Y3AhJdxiBh5nN7RrSelbxIFM7kv9XMh9JBLrzkgDxlu4sRR8K3Y0X/a5814PLQYpgLik5JOuvUCSZocdSCy+ScZWQAY4UYcRad0WbhlBseg== 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=L7E7CF/0TniKHGZRey+E2tmeuC2vw0i0JnH1eEDf1U8=; b=hZM5GDiEnABJUlbhG2UskGjUA+H1GuonPJYXw+ze7TvZWYvCaq34ij1Hk2fYAl5inmWDcPGc9gzjTJCH9eHIcOACGPRG0++sm5mBVAU5SkndVVEnXi8BLXMobWa4ihu1Fn8SftERnuCPrNCSPnPtm+eVOiQhCOpiy5R9ozs5BK0R5/WXog5bnSIflUnvIP050GG4Dcfa0ftNyKLbp9pQOLKiDPXy/wEyR/cjfMTRSKx0+8js6bduG4An3aVor2ypxzGQm77G39FFslHBG8VE8Xio+C8kMhnJz8FmuJbkgKV7mKZec0HAZ3TTe653zD/IYbA6h3/4aqvJYc/gH5RSnQ== 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=L7E7CF/0TniKHGZRey+E2tmeuC2vw0i0JnH1eEDf1U8=; b=Hp+bVd0YznMe0Y3P0yiQ8RgiA30jzLGFouB68AAsScQhJ8W0mIW9oLXbjTwv+cx2uBnnfFvFn9hoVqIeyYaWLF7mOa6m3y+qWAHbmEvqC8q/k86yL7+aE91YSahp9AsL4YtpbFTyk0nbTXjiR+suKRQMNHYLMXSQYVD7cjRVCAM= 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 PH0PR13MB5422.namprd13.prod.outlook.com (2603:10b6:510:128::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.10; Thu, 18 Nov 2021 13:08:28 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7%7]) with mapi id 15.20.4713.016; Thu, 18 Nov 2021 13:08:28 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com Subject: [PATCH v4 05/10] flow_offload: add skip_hw and skip_sw to control if offload the action Date: Thu, 18 Nov 2021 14:08:00 +0100 Message-Id: <20211118130805.23897-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211118130805.23897-1-simon.horman@corigine.com> References: <20211118130805.23897-1-simon.horman@corigine.com> X-ClientProxiedBy: AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:404:a2a4:c5ff:fe4c:9ce9) by AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 13:08:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9ce1b9ac-d81b-439e-55f0-08d9aa948367 X-MS-TrafficTypeDiagnostic: PH0PR13MB5422: 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: QummTjObpkxEloiV1Ndwd7iy5u1PPxKUSfwf9kKWayHXCBL5aD3uRUh2g8GUWmJh5mrin+qlcLpC7AVlRfPYXI/D8LfIgkKu9VNBeSbcLi4bO2odyQagZXEOQ2Bd09hPmjYAYhaGP4WWgKKhcoeUwfWNnnOFXw7F91QkCxZ6dw5BX4bu5rgdK4/tSZaF1ZCZgcv0zhsgkncriGoiH9UEYVbxMSIJzPdF5DALRzSXVm5q+TJfPm9SNXwwzfxaYdC5SA0PwQYm46L7FTlRcdZq5DS0nPR4QVjzmr6s9QEGusCENVz3z9SnzZc1/svt2qthlMFqmDfbbuR29q4ks6Juy6r/IKicuDUY2/zoCpAuWjSV68jwo9JLmKvekpyaYAZ69zb7yfKS1xIkv7ieRxfNoKHD8CFHWwLcBVZfYDfzoRNHbHEl9XG6R+Sv8aD31NMEO0Lk6JDiQpJvQHVEVBHvILhaCRuHKEgqLyBWBGLDrpHfDDk1veJbQZ30vELvN9koqq+Ho3PpRgjnDes3xe/PF7nwWZ/kxlkeatwmRq5PYwqPCLoJBDCfk5KFPpXpEq9wgsRUivGwt+qFOGV+zT0OGBv052K+VUXgWFu/Q5cPHtClGO+nKo4dB1c6gANySm8lQegmZ0opXfE/NCVlz0hFZ9swbg+noWHy9hU/pRpZyTCuO/u7eliFBazNxNovFzC+y/kQxfZGWh9XWy7u15n8IA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(39830400003)(136003)(376002)(346002)(6486002)(2906002)(54906003)(6666004)(316002)(86362001)(52116002)(6506007)(1076003)(38100700002)(186003)(6916009)(107886003)(2616005)(44832011)(5660300002)(4326008)(8676002)(508600001)(66946007)(8936002)(36756003)(83380400001)(6512007)(66556008)(66476007)(309714004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CCeaS4Q4mflzVnurRn0Kix/cffXwVfuYMFOdvEG7j5SgBOQkLhuE2NNth7yZitRafg41+0dR1UgC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q/cslohxNTuEtJ4KZTy1G/KrBEhsqW32iBF5rXa4J12tfJBCpicupB9yYQQXt6SNRgEvuQHtpv/IbcvVHMvT1TfD19gLJcoJYEIq/W4t9giXS3Pi0FupIox9vVNxLQlP/pyOO5hEW2KnDBClhClpayohRV6hDKxrRno3lTBYcwpdPcLNJ/GQ2LXdAZHFh4Ae+/pUBaeIcUw8Tr1viLNaHBefOvF59Ef9bRDSNn2bo7BUqlknRCg9CZFG/OR+8CP6dvrPBueyEwREXbEuz4aPHU8Xzx1SJ1hDJwF1K8TfLoKroyEeJXBP+4EIJtWS94cBJDyfQ88gXj/KNkNsUnZw0uQmHxHmQsxTKUxb4sO5tRtsjLDOZ4euGmNo7forP5osL8WycVXmqfvZBCzgxlrAiDGRiGWpJSLkvexqfI0WeVK6UdufF1X3RXtcQXTJOXCkhq5kuD78DvV+WHNF88B3LPkF8T2k86c9AUpnvOvgJ/VdfA0EXOrzOKzEC5DessGzdHdtOn0Y20oT7uNyGNEG9EXXDEZCXCTvF5caQBgFwc0rIFWLAPO7PDII76SkQSjq5TJJsMpzsecmgb93C8AJrJjqmBjjoxQ4rlE= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ce1b9ac-d81b-439e-55f0-08d9aa948367 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 13:08:28.7588 (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: jx4pxF+o1O9u5LzsTamwaKLXsRFs8ectQYVHHmwNN4WTEkCuMnarxWUoYPa28vLk4PwGR9EiTvhajp9WTchCH71bi+oegd2QaMId0QrBKcE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5422 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 --- include/net/act_api.h | 7 +++++ include/net/pkt_cls.h | 23 +++++++++++++++ include/uapi/linux/pkt_cls.h | 9 ++++-- net/sched/act_api.c | 54 ++++++++++++++++++++++++++++++++---- 4 files changed, 84 insertions(+), 9 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index b5b624c7e488..68d6f245f7e9 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -44,6 +44,7 @@ struct tc_action { u8 hw_stats; u8 used_hw_stats; bool used_hw_stats_valid; + u32 in_hw_count; }; #define tcf_index common.tcfa_index #define tcf_refcnt common.tcfa_refcnt @@ -236,6 +237,12 @@ static inline void tcf_action_inc_overlimit_qstats(struct tc_action *a) spin_unlock(&a->tcfa_lock); } +static inline void flow_action_hw_count_set(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count = hw_count; +} + void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, u64 drops, bool hw); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 14d098a887d0..b00fd421e7c0 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -261,6 +261,29 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) #define tcf_act_for_each_action(i, a, actions) \ for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = actions[i]); i++) +static inline bool tc_act_skip_hw(u32 flags) +{ + return (flags & TCA_ACT_FLAGS_SKIP_HW) ? true : false; +} + +static inline bool tc_act_skip_sw(u32 flags) +{ + return (flags & TCA_ACT_FLAGS_SKIP_SW) ? true : false; +} + +static inline bool tc_act_in_hw(struct tc_action *act) +{ + return !!act->in_hw_count; +} + +/* SKIP_HW and SKIP_SW are mutually exclusive flags. */ +static inline bool tc_act_flags_valid(u32 flags) +{ + flags &= TCA_ACT_FLAGS_SKIP_HW | TCA_ACT_FLAGS_SKIP_SW; + + return flags ^ (TCA_ACT_FLAGS_SKIP_HW | TCA_ACT_FLAGS_SKIP_SW); +} + static inline bool tc_act_bind(u32 flags) { return !!(flags & TCA_ACT_FLAGS_BIND); 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 c3d08b710661..29fba4fa1616 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -226,6 +226,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; @@ -238,6 +239,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; } @@ -245,12 +249,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; @@ -266,7 +275,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: @@ -278,16 +293,27 @@ 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 (!action) return -EINVAL; + if (!tc_act_in_hw(action)) + return 0; + err = flow_action_init(&fl_act, action, FLOW_ACT_DESTROY, NULL); if (err) return err; - return tcf_action_offload_cmd(&fl_act, NULL); + err = tcf_action_offload_cmd(&fl_act, &in_hw_count, NULL); + if (err) + return err; + + if (action->in_hw_count != in_hw_count) + return -EINVAL; + + return 0; } static void tcf_action_cleanup(struct tc_action *p) @@ -897,6 +923,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) @@ -1002,6 +1031,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; @@ -1081,7 +1113,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), }; @@ -1194,8 +1228,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); @@ -1265,8 +1304,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 Nov 18 13:08: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: 12626983 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12E68C433F5 for ; Thu, 18 Nov 2021 13:08:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBF0D61026 for ; Thu, 18 Nov 2021 13:08:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230179AbhKRNLr (ORCPT ); Thu, 18 Nov 2021 08:11:47 -0500 Received: from mail-dm6nam12on2130.outbound.protection.outlook.com ([40.107.243.130]:54048 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229674AbhKRNLm (ORCPT ); Thu, 18 Nov 2021 08:11:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WoeQ65B8fTevsoPkQXk+wcGfntVpbuvZCmY0vIA1MNOH2fIsaguCkh2lreZA/ADhqyWsQzHBL0NCMYVNCuzzs6KCrzPza2gF+pH5n2wL2gwLW1UkEC/4MuWmCMq9Hsl4MHINyYH4xsB7ZIbWK+Ew2UZEmww08uc7uXLbzbh+IHo4cwVz7kfOK6B3sjK5epCyMaNQydG2zkGt+n3KrpCxszzWkcFuqAJ4tcE57VyFFEEO3UTA0F3iVruPwxLCNtaO8kE0sLm/xSDrp/znouiO0ZqRfPDuIL5qMGzyRYMZ+3wcZH0gtBq4s7PWml4NfOSFHiHOB7jr/gfHYvVlPrJKcw== 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=nYPAPMMD3ajgyir6wXyZE77OfTZq+n63W8BjxoM6ylo=; b=W+kIBaQITq5cxi9Rs279Al1ot+KXfmAZTHQPie7ezJXNqK9Jd8LOSDaKu3f7/HdS4i6e/cOCUdxfnj2DMNK0M164Jx5oPPeI6M9+TiZrJmgDjW/MrH1xCEjz2bdkuSDQ0QoGRSucvQmSwTkZIS29mlFEMb94d+c4KaLd1ESE2c/EWX6LZy5LhpO4AzBLRFs13lJ3N+uKPvWhmzxabtzAsKpkgfGzh7jpCnJLOooEbWWCZzGN8yde4koYQmMKeQuVi8HqkjJ+fxGFf6ScKfM3TUBBtsuBVZNcFBl25cyMNpyaOUepvypE1rJb79slwj4kSgm5ROQd9TtNSLrkF8+idg== 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=nYPAPMMD3ajgyir6wXyZE77OfTZq+n63W8BjxoM6ylo=; b=Lt1ObXwXubG3i8TOS6oHH51RGnDubQXPzFkZP6az6gQqTOkfKrUyCHoflnQCaTG3nX9DWJ8kWenna6RHMqCK3kSi1mFxHQe6ZTe+yY9K652qVzZFFtQ/usWh3yJN+fq5AfXqWiXvEDEULgLl5D8qwwsL3/9F999VEgM05r1VnHM= 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 PH0PR13MB5422.namprd13.prod.outlook.com (2603:10b6:510:128::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.10; Thu, 18 Nov 2021 13:08:31 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7%7]) with mapi id 15.20.4713.016; Thu, 18 Nov 2021 13:08:31 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com Subject: [PATCH v4 06/10] flow_offload: add process to update action stats from hardware Date: Thu, 18 Nov 2021 14:08:01 +0100 Message-Id: <20211118130805.23897-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211118130805.23897-1-simon.horman@corigine.com> References: <20211118130805.23897-1-simon.horman@corigine.com> X-ClientProxiedBy: AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:404:a2a4:c5ff:fe4c:9ce9) by AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 13:08:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b370b8d3-1416-468a-c6d9-08d9aa9484b6 X-MS-TrafficTypeDiagnostic: PH0PR13MB5422: 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: /HG+88wsUFBjtsRH88Q+KunaKdWAgTRzuoMkJNngmpRIXKNvxQDI63U303qu4TkkO1vvmov513RoedS40uIPRT9Todh9QL+RYzHzvnAzE/JsD05/UQRi0FfOaBnmqDeFXpoXa4t0Y2E/8mzduJ+BiWncdF1WuJde2m4hjIv9iYi4e7EXcYvBj296fPJyRte12WTMWbRtaPfjk7aKdJNwDfeNRj8uhHz8QVTPecXOeU5mt6HyylveKrMa9RVIquGPgAY8KYww6EYH8W6dlD5M2ynHANUi4o5E2Zf1b1NQUUFAjXO9aTWgWJhZh67FgZ4ziE5MBmsBtSzvCbe20H9S/IZa+oR3S0ny53xx5+ZpQ1ERvQZ4P2ajYbHuLdqi2q2GEcPBo8WLYFzPz1e/xhhdqLGtFqVV3D9yLTIWBnYbMXoUnrjPgGHiD5aJHmqVT1dX0EO8u53jsQbIGN5hni7n8ys+bXT7Msxj6y2gMfGkghVNPeNOl3llQx0ZOHfbw8weUQVxzHE8Y/AxRzNaKfR0Huk8z8kCHrcXdvfScU/xvzbgSGoRRaLdpmB7ZgJU4sREj2q8ozsYxKRWzI7Av+UdQqo+cRhO836kH6cWlmzzmWWkEMvvikSAVfSPIwDbZuhKArJRwnqWp+n+Hz5yZ4NYww== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(39830400003)(136003)(376002)(346002)(6486002)(2906002)(54906003)(6666004)(316002)(86362001)(52116002)(6506007)(1076003)(38100700002)(186003)(15650500001)(6916009)(107886003)(2616005)(44832011)(5660300002)(4326008)(8676002)(508600001)(66946007)(8936002)(36756003)(83380400001)(6512007)(66556008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6S0nMoKsf/NGeXPEBcOnuoCCZT0abPD215k7KmhdzHElUrCrS3v/4nER+2t+Y9hYHPJmc1pQy9OWRdUGLgRwgPoysjnYmmt3Wy7vNZ+iRjc5k3i51202WW+VhIbJQGS3RX6i6W+XdoPx7BX4W9WIFcGCnrzJMHKmQ7ARlmIcVlZbMYe1NahqjVvx8ZjS1VHsVGOeIbkU95WdbGg3Wd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ZA8KJj7px3Jy4qAqwQ1wo4VJcJTL4P50hKGbxpZI2YiTMMTRQ+ATdXpk1ye0CyaMa8NEp3mPDylQKJAZbuLrs29nnx/bfo3Xd6/35D/DL4bT5hEXZEFrP6X8zcCuS3B1rYQTwgvRXhyEgdwNege5iqyPfiksSeOMntbm8/ISDSK5HPtt2uav+AJCKhUr9dLDjXrDsdaGx8W899K4cxLQSjWMlYHef1lJ5+5fJS3wCY1Hi2/xIOkvQQA0drI/c1JPFB6nr/HUBhhM2ZsSgVHMFAiPL7hAk4rjebYzhtYw3ZOpmLrzm6W4BbzpVqj1rI0sFdk+mQ3R8rSoh6q9+mf4/iSoRs9Suas+fWHOcTCBldbU+z/4bBaOJkpw0n7KMpfgGcX6OstUsIQLNHVoGuVIoFV8dqP7tY0QQSg6u2m+piQZ+KC6r5dU2DZXUTIR1V/nVWcwMvr5ufEHngNFyTbCt8+DsUAizao9TqaHq1sQ= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b370b8d3-1416-468a-c6d9-08d9aa9484b6 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 13:08:30.9343 (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: 1WLidFLUqGpWV3pIg5ACXU1L4qcjFTtUTlQUV8Ok+dI30C/Y15tiq/W5Vx7jaT8meq20zlDBNtVpzxKwMgDVKGkjtFhJDfzWOtSSwhXeV4M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5422 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 68d6f245f7e9..7900598d2dd3 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -247,6 +247,7 @@ void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, u64 drops, bool hw); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); +int tcf_action_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 b00fd421e7c0..c8e1aac82752 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -297,18 +297,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 29fba4fa1616..01f0bed9c399 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -290,6 +290,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; @@ -1360,6 +1391,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 Nov 18 13:08: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: 12626981 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC881C433FE for ; Thu, 18 Nov 2021 13:08:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B47B461026 for ; Thu, 18 Nov 2021 13:08:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbhKRNLm (ORCPT ); Thu, 18 Nov 2021 08:11:42 -0500 Received: from mail-dm6nam10on2122.outbound.protection.outlook.com ([40.107.93.122]:47280 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230164AbhKRNLg (ORCPT ); Thu, 18 Nov 2021 08:11:36 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oFpCnTR1O5h6t5NYdLxtM16sLZOB7gTEbKMBFFaF2HS3qfTLVH41yIkW/5+7ayu0iexOokSG/hoOAVSgET5q3aBKBQ5joBraFZ35rJRPlmPRoQ3puO2P+AmmwqweHCmNvFxf5V/VQlm+GsYYYPFlVHDAlr9KCzbTtUJpCcIj8GKuMW9iaLnyt39eAreTLA18jKfZ5Wi9VXc0CVQIQcwVwl9vZkuB7Bvl+JiirwEzD97xWmEJhuPIEpCLqnomLFE0FQZ088cdGBkadhIqpd5updpVlKr/lBV/IWIFVWHcfRStPIG+9kMY97k/N3KilbKKUC8zwXFWk9rEgx+7xVhFGg== 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=0ftIQusN75fnz6kLEUlq2GQu0roP7XoM/2a9WSrXoqE=; b=ENEQ9b04vD8rbOL98ksO7ltXNGqw1uJ7o+S0Bw+b7+m0BC3GiKtAW/00YzyGzyK5AnZ/f0hxRk9yb75U4ObcHXbvKZuIhV3EhraQVaYXUZHg19Lv6C4ktmXomCsOl9ITs0VWHqYh3ZiuGgYyuyn36BwgZ2em7xWDNZQoaBSCS5nF6070Ljk+dNebV4oXY1YZet1aUIvpsPkNC/JnU/ZGqdAGB/vkL9t/OUgPkpzJ338xVLy2tNuh05eKsXf505Vc1kTX1kerD+RKoG6CA952+Zy4/d+l7MBU/DqBV98dcu3KbcEA1XNOAduQcHUmm/6cgsUSOb1NwenEC4aqM3OyMQ== 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=0ftIQusN75fnz6kLEUlq2GQu0roP7XoM/2a9WSrXoqE=; b=h/EWPgU/uSu2WwdkR2BXGnICaibARNsqFAV3LCDM2rZ48yo2nIxt4SLIpknjUs+lHgjJ2Vx2GfZDUzMfBkGli0fXhniCAB1oa+OAMvYYkBoUnR2g6d/iqIIFN8OSCIILdXZxwyuf+kdKQ9rChhfNYMrDqKa2TZIalu7ARE6iwoE= 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 PH0PR13MB5780.namprd13.prod.outlook.com (2603:10b6:510:11b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.7; Thu, 18 Nov 2021 13:08:33 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7%7]) with mapi id 15.20.4713.016; Thu, 18 Nov 2021 13:08:33 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com Subject: [PATCH v4 07/10] net: sched: save full flags for tc action Date: Thu, 18 Nov 2021 14:08:02 +0100 Message-Id: <20211118130805.23897-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211118130805.23897-1-simon.horman@corigine.com> References: <20211118130805.23897-1-simon.horman@corigine.com> X-ClientProxiedBy: AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:404:a2a4:c5ff:fe4c:9ce9) by AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 13:08:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de6309fc-3a27-4589-fd44-08d9aa9485ff X-MS-TrafficTypeDiagnostic: PH0PR13MB5780: 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: Jpieo7THcDZixC15i95da3y6gCCnd9WlMEEeQAMkMAYQacvysq5yvspvD8ZNbnAXcVV+Nylk5houNgEVLCJT8E+I/yBNxKoHkMaT/xHb5a9kMSrblaZujz9rgzjjdyQ3mwJCshtjlAzGKhaBUO4fE6QY/BaftnNqSp0y+7Ggjo8kxIlB7vfVubJn+Ah88D/JZt/AI9mPxvOy8droFuEnpEN88HJImL2nuEBBo8PGODfvqxvUslXl4XrofBM1zcuGCqGyGVta8ZbW+OB85Ne9UBlShWh26YvhNPkj3z2aQoxog3jJIK3TPhOBb/SkBLMdXd+wAn2dcKBrT+Gd2lswH3pPfDtGy477Lxl2+9slWflg8iqAcnYSz+m3aG6S8E6Wp2t0RFvI0e05sDtKmbF6Ik5ezuX8g3Y9nJ9zcTvWhDeWgCq8XbyNBn7+4tpJvEMVdYIpSlvbMFpp2EAv15Ft/9Z3FkmkW5XV+lDEpEdSgdnKf8pYz/jGRF2NV6UoFTjrp9Y+ym47rx9I9UvmHxYfwxTT+5P8BzG/Y70g4g6gR418n5/h6UzYurm4Y9QdoOFRhQDfO14+3JsSLKWFPT/+bKJOgPlT0nDXm9CJ2TcMbZLRBLHbbplJP+b2vj5VlC3ekjZDtwYwN4OSP0a9cWZa9A== 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)(346002)(396003)(366004)(376002)(136003)(316002)(66476007)(6916009)(54906003)(66946007)(52116002)(6506007)(8676002)(6486002)(66556008)(186003)(86362001)(4326008)(6666004)(44832011)(6512007)(83380400001)(107886003)(38100700002)(8936002)(2616005)(508600001)(5660300002)(36756003)(1076003)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VfEyeN8nc7UC4ZBaY/IELlIEHtW6nvoq88ngVU0s8AGkBWNIJTN2XHsodPUw40ghFlxrT5cEgp4IgpbGGcruy3T/nBGmlXMDYp8KuzABRTM68uIoaWD+CWhmciiV8C742PnWIWCwMT7G8zOnNeZCslQIkCYRiHo9FRrgcPpOJq/7Qf035tODqtLPWeqgcZ/6Yfs1187TyFe8sh38RwRyyMAdyZXG7Mpb/0ZSxoahvsiL017nphVlPpI9SIzYf6qaBzfK9uhIy827J59IG4Ckf3AWKpQyHPKGOUUezD6j45PbsmZa8c6eSw2RITh2qXsk7obA79XejJKlfgceoTfyJJ2HcZljOy93/9J+lNnZbjRIi7glu13gdiFlJgZF+Nf12FOlaX7L9B5haA/T7wXCIFMi1nL7pUZIDYU2WGVPvhK5CAW9sUFgH4NIE9JZQbXrk8Vf2vmBui2NRdvMEJwe2+KMtl+hn1vGi/84V1VDsf6aXCp/HrCuBZP0Vmt6ew62svDp6p2EKSqI7kg9+1TCjIe6Q+s+60GgWVOxnw55bo8VbokcbBb7D6dUED/GieoVG8ODZwbFHVlI/Q0cAHWtv6q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HDYDhTBk6K5CTVbjfwIMqgcV5q1QLpsNXGKk94lY19focCwdBwHAVLD0PFT5HdxeuGCJZalV9e6/P4uE= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: de6309fc-3a27-4589-fd44-08d9aa9485ff X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 13:08:33.0888 (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: NF6UeYKDAV3sLaVVuoJJPDWX7090+KWPaq56D5HdYZyJgKtNaSEEZtKurt/TPWQu0CqL5sbJDto/xoohvylQa7FEUykFCizS2bu1EpNe2xo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5780 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 --- 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 01f0bed9c399..f5834d47a392 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -716,7 +716,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, @@ -1043,6 +1043,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; @@ -1057,9 +1058,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 Nov 18 13:08: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: 12626985 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 950D0C433EF for ; Thu, 18 Nov 2021 13:08:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80B6D610A5 for ; Thu, 18 Nov 2021 13:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229957AbhKRNLr (ORCPT ); Thu, 18 Nov 2021 08:11:47 -0500 Received: from mail-dm6nam10on2122.outbound.protection.outlook.com ([40.107.93.122]:47280 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229732AbhKRNLm (ORCPT ); Thu, 18 Nov 2021 08:11:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PnOP4DD2XrcasOitlmxXz30IF9f4KZsb8WU0XfwiC14IyQTqgKWfK0DeauhPZ4Um84U8/lhcdY8oncAFKyJv/qRq+pHtRVTSPOX3oFGwQWN1KiwBsymY5OTi/SJH1Io5qN6xBGHWD8xm1GQMxG6ePC8thqdoihzDKA9Psz0yuMuBGIv6zgldtrTRQ2EP0QO26TN3d461KTZCsiSUrhqnwFiCPSRVMzpHfWMT/4MYqq+FPchwahxuK8I9y+3jxZj9RIzBU4DWNgWSqMH7Yf2QQMmChBZmV9t/jrYCjl1g+ajcKD9rttdD5Ws5uFQvDNQ7Jy3/2YSU0bHFMPiIu1FmjA== 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=6oP3UUnV8L/QrVlzpQVtIOS7nz5c8izoyFXmJaDgUGs=; b=PlM5cPwC36LEwbKBkmI2wlkSBzyIWvZ19VBKcNsPJC7LSOnEkJhJ0hb/w8rK734maukxH0mv190PVzMKyopoUnVXViSVmCEby9MMH5RMLl41PgeNNTujmShGt7plCzy/Sl8riPDIyxwGBMnSj3RBMQLVMKXxsMgcAV7NltyTkOIoWKf1obpaPnNfwk68dKxs6g8Ym6JzN9KrUJ1MRJIJGRh9hryJ1FSYJ1YThZERPcGPTtnL+/Xw1W7NwPKBnzOwcGUkHsiQoG9z/faCuVdZ+lJRRz4EYWvppb11jB6+F8x95tvLPdbn6M5NZVIziM8UpJa8eij43V2Qj+DZ2fI68w== 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=6oP3UUnV8L/QrVlzpQVtIOS7nz5c8izoyFXmJaDgUGs=; b=QxpvDJVrM0ao2Y576OOv/5DbpYohVWNMQby/iqJSXfUtTlmedn/Qg1CdBfO4SXtUt4Ctel2+l/FdQcCnGCmneZjUHvko3JU/51DoQY4wC7oRNUsGMye3QPk/VqAacVCmo/I8fVnUE8H0QFLksGHN/UvPL79wmjyKVRWoVlbxtY8= 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 PH0PR13MB5780.namprd13.prod.outlook.com (2603:10b6:510:11b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.7; Thu, 18 Nov 2021 13:08:36 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7%7]) with mapi id 15.20.4713.016; Thu, 18 Nov 2021 13:08:36 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com Subject: [PATCH v4 08/10] flow_offload: add reoffload process to update hw_count Date: Thu, 18 Nov 2021 14:08:03 +0100 Message-Id: <20211118130805.23897-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211118130805.23897-1-simon.horman@corigine.com> References: <20211118130805.23897-1-simon.horman@corigine.com> X-ClientProxiedBy: AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:404:a2a4:c5ff:fe4c:9ce9) by AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 13:08:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3fb55770-714e-4d07-e75c-08d9aa9487c7 X-MS-TrafficTypeDiagnostic: PH0PR13MB5780: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g3MEelB8uLXlpDI0u1C36vNovwOItPMe7fGzJEHApSx15h6P/WI04w8NxOAVjwv1IKRnW5gZMAp43vnhdg95p0qphiyzUkV4rF/JBK2fxRk3ji/+G7rrUXgP925M8jafLRJ2J9mr7cmegHPRfGCs9IQEKkqQ1UfU1MpODyhSUeAwGOyO0fDULkRwwR+h8GCqZy5nWngc7vtrvYo5YL/qmSNuVxnvr3QlZQFIp1LzcSR84hbUkxmpjLAMUfrJ+pGYrQvooh80UaXyfAXfKzXZ0+ZAUW069GOC1NTGv3DkAn6/8x8/2NzCZt27XBUWuqdsWBwKVktTAZ7h7Of5FjUGLSc5o9NSunWbZFYQ0/7SEtgzWyX6RfeLwwexvSKa7VyA26uNstgBRznYUftQBiiJ8qV/3njzshb+0mFn8ZWIT+MTgOssRfyTYs01Xp3iPHLjTMgfpYno2vXkgNxh/7OxhoSlzFsUf57RQmIpcNNEOTrDKLAFSfRxRFR40yX7xdNkq0ARUPz7b7dM4Lj75BW2jJkKDBL+nBiVG6sjzrBpcpBiaXuUbQK5Hcd77bHyogajM+dNA6nkXk99qLk7wts/zzwrB8bx1t28HR91e01k913iPH92Jmtnl0GvRd2Lc1oFtByH+XpT3C0SP0tSThtnRA== 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)(346002)(396003)(366004)(376002)(136003)(316002)(66476007)(6916009)(54906003)(66946007)(52116002)(6506007)(8676002)(6486002)(66556008)(186003)(30864003)(86362001)(4326008)(15650500001)(6666004)(44832011)(6512007)(83380400001)(107886003)(38100700002)(8936002)(2616005)(508600001)(5660300002)(36756003)(1076003)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +iMO6QiLXVhlXeC2QbQZSgryoq8nr7azSMF+uW57KVZZr9dWicQdmneb+tK8lSvyUfhpApqhPwpKAgwlL6r734c1mFLINXnkhDlrwKFr3QDwrp+fhPBYWE7XKNxRSEuLeCs+gW0nsMdEdYyM3NlK0LH2C8FHTi4592YOWV5crs9Rrvnt53vlowCzY2tUNEG7PHBgPaqzHtwwk+G5zO+gbriizDJcllDKKqJmf1kWXr04Bd0m9olHKUBAeUK8OB5Dlx/m60YYBODDhSaGQBI+E/2ie8qy3PRpyIPR/qdx2cO8azgDLN3kV2r3xpeAP0T/NlhqXb3BlGnXw22DiKfgDnD5i8huwsWkm2v6dz6n/UkhRUDTPfYN2r/VKGJfJgBMl0mmdVzmOs/EwPeWDpyN7cOkkS3HR9jYavF1k6u26Nfb4Uq9ebYjn45WNMPiu4Qpt3t1aTNJmw5CH32ufANcfSaIztwwkV1PTXQwCbnNzol+5FJeIvdO6M5LFVZMnYfHCLYn2083iIyBxjQpBISo7mmjhOEOZpvTQUQt48izBDDLxn5iGdpGkQMsDAZeEN6PeRxNyxh653b3RH9Fxv3joGAU8bZRG0P2ILgsOwhcFY1pqht0X+FEttXfQOiLRa/RQgB/bUvTi+/CFMRx2mTJfBvXHv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gzpyFyJupWRd+QQGysJe6AcglOSAjky3KrhXVY= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fb55770-714e-4d07-e75c-08d9aa9487c7 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 13:08:36.2310 (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: XqkyPshkj9A8cmaGc5INtJt/N8J984/KtAwXshDVPu1+JBw5gXDQg9qQfVgrvGMiP268EUOZsxTCP0s1x8d9BjZBuGIIzb86ndiBj96T5/0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5780 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. When reoffloading actions, we still offload the actions that are added independent of filters. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- include/net/act_api.h | 24 +++++ net/core/flow_offload.c | 4 + net/sched/act_api.c | 213 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 222 insertions(+), 19 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 7900598d2dd3..e5e6e58df618 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -243,11 +244,26 @@ static inline void flow_action_hw_count_set(struct tc_action *act, act->in_hw_count = hw_count; } +static inline void flow_action_hw_count_inc(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count += hw_count; +} + +static inline void flow_action_hw_count_dec(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count = act->in_hw_count > hw_count ? + act->in_hw_count - hw_count : 0; +} + void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, u64 drops, bool hw); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); int tcf_action_update_hw_stats(struct tc_action *action); +int tcf_action_reoffload_cb(flow_indr_block_bind_cb_t *cb, + void *cb_priv, bool add); int tcf_action_check_ctrlact(int action, struct tcf_proto *tp, struct tcf_chain **handle, struct netlink_ext_ack *newchain); @@ -259,6 +275,14 @@ DECLARE_STATIC_KEY_FALSE(tcf_frag_xmit_count); #endif int tcf_dev_queue_xmit(struct sk_buff *skb, int (*xmit)(struct sk_buff *skb)); + +#else /* !CONFIG_NET_CLS_ACT */ + +static inline int tcf_action_reoffload_cb(flow_indr_block_bind_cb_t *cb, + void *cb_priv, bool add) { + return 0; +} + #endif /* CONFIG_NET_CLS_ACT */ static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes, diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c index 6676431733ef..92000164ac37 100644 --- a/net/core/flow_offload.c +++ b/net/core/flow_offload.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include #include +#include #include #include #include @@ -418,6 +419,8 @@ int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, void *cb_priv) existing_qdiscs_register(cb, cb_priv); mutex_unlock(&flow_indr_block_lock); + tcf_action_reoffload_cb(cb, cb_priv, true); + return 0; } EXPORT_SYMBOL(flow_indr_dev_register); @@ -470,6 +473,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 f5834d47a392..ada51b2df851 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -225,15 +225,11 @@ static int flow_action_init(struct flow_offload_action *fl_action, return 0; } -static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, - u32 *hw_count, - struct netlink_ext_ack *extack) +static int tcf_action_offload_cmd_ex(struct flow_offload_action *fl_act, + u32 *hw_count) { int err; - if (IS_ERR(fl_act)) - return PTR_ERR(fl_act); - err = flow_indr_dev_setup_offload(NULL, NULL, TC_SETUP_ACT, fl_act, NULL, NULL); if (err < 0) @@ -245,9 +241,41 @@ static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, return 0; } +static int tcf_action_offload_cmd_cb_ex(struct flow_offload_action *fl_act, + u32 *hw_count, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) +{ + int err; + + err = cb(NULL, NULL, cb_priv, TC_SETUP_ACT, NULL, fl_act, NULL); + if (err < 0) + return err; + + if (hw_count) + *hw_count = 1; + + return 0; +} + +static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + u32 *hw_count, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) +{ + if (IS_ERR(fl_act)) + return PTR_ERR(fl_act); + + return cb ? tcf_action_offload_cmd_cb_ex(fl_act, hw_count, + cb, cb_priv) : + tcf_action_offload_cmd_ex(fl_act, hw_count); +} + /* offload the tc command after inserted */ -static int tcf_action_offload_add(struct tc_action *action, - struct netlink_ext_ack *extack) +static int tcf_action_offload_add_ex(struct tc_action *action, + struct netlink_ext_ack *extack, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) { bool skip_sw = tc_act_skip_sw(action->tcfa_flags); struct tc_action *actions[TCA_ACT_MAX_PRIO] = { @@ -275,9 +303,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; @@ -290,6 +319,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 = {}; @@ -302,7 +337,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, @@ -321,7 +356,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; @@ -337,16 +374,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); @@ -841,6 +887,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) @@ -859,18 +958,30 @@ int tcf_register_action(struct tc_action_ops *act, if (ret) return ret; + if (ops->id) { + ret = tcf_pernet_add_id_list(*ops->id); + if (ret) + goto id_err; + } + write_lock(&act_mod_lock); list_for_each_entry(a, &act_base, head) { if (act->id == a->id || (strcmp(act->kind, a->kind) == 0)) { - write_unlock(&act_mod_lock); - unregister_pernet_subsys(ops); - return -EEXIST; + ret = -EEXIST; + goto err_out; } } list_add_tail(&act->head, &act_base); write_unlock(&act_mod_lock); return 0; + +err_out: + write_unlock(&act_mod_lock); + tcf_pernet_del_id_list(*ops->id); +id_err: + unregister_pernet_subsys(ops); + return ret; } EXPORT_SYMBOL(tcf_register_action); @@ -889,12 +1000,76 @@ 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); +int tcf_action_reoffload_cb(flow_indr_block_bind_cb_t *cb, + void *cb_priv, bool add) +{ + struct tc_act_pernet_id *id_ptr; + struct tcf_idrinfo *idrinfo; + struct tc_action_net *tn; + struct tc_action *p; + unsigned int act_id; + unsigned long tmp; + unsigned long id; + struct idr *idr; + struct net *net; + int ret; + + if (!cb) + return -EINVAL; + + down_read(&net_rwsem); + mutex_lock(&act_id_mutex); + + for_each_net(net) { + list_for_each_entry(id_ptr, &act_pernet_id_list, list) { + act_id = id_ptr->id; + tn = net_generic(net, act_id); + if (!tn) + continue; + idrinfo = tn->idrinfo; + if (!idrinfo) + continue; + + mutex_lock(&idrinfo->lock); + idr = &idrinfo->action_idr; + idr_for_each_entry_ul(idr, p, tmp, id) { + if (IS_ERR(p) || tc_act_bind(p->tcfa_flags)) + continue; + if (add) { + tcf_action_offload_add_ex(p, NULL, cb, + cb_priv); + continue; + } + + /* cb unregister to update hw count */ + ret = tcf_action_offload_del_ex(p, cb, cb_priv); + if (ret < 0) + continue; + if (tc_act_skip_sw(p->tcfa_flags) && + !tc_act_in_hw(p)) { + ret = tcf_idr_release_unsafe(p); + if (ret == ACT_P_DELETED) + module_put(p->ops->owner); + } + } + mutex_unlock(&idrinfo->lock); + } + } + mutex_unlock(&act_id_mutex); + up_read(&net_rwsem); + + return 0; +} + /* lookup by name */ static struct tc_action_ops *tc_lookup_action_n(char *kind) { From patchwork Thu Nov 18 13:08: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: 12626987 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0732C433F5 for ; Thu, 18 Nov 2021 13:08:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A73B861026 for ; Thu, 18 Nov 2021 13:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbhKRNL6 (ORCPT ); Thu, 18 Nov 2021 08:11:58 -0500 Received: from mail-dm6nam10on2122.outbound.protection.outlook.com ([40.107.93.122]:47280 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230161AbhKRNLq (ORCPT ); Thu, 18 Nov 2021 08:11:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dEbD3f0nPwTFOJqpz/OM0lMQqNvRqaC1foNU3l50jXb1Q7HSXge4ixFNr7D300cNj8Ok/8zuCaoNxtZKzHR+PvT+/PsRJJULcVBaikH7ax4AmEZoGzlzJKe2W1PW0Z9DmjgP0fEub0dhsxv7HzexVjphZ4PRhC7b1XsFaQjBmM1F1grav/jmqNrg3G0iNdNdUbE98WY/Si7N1RLciMDfpeRC6c954PGYBO9EfXwLBTIeCbLE92A1yjaVyoagI4vrz5+khpZVOpTMfmkLo+GlwfPBjBWBEqaV+fRPabalLJ8z/lHoH2zlWoWhaCh6wfRF9kMeAx1Y6OI+fB3jKxU9lA== 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=Qn3uz3CLQ/Y0YrGv1CQoN2WLN/wuclM7MSKo2y1IVcw=; b=f0Y1+Pk/HD/fMsFuTrvpC5MAZupSYSJdgTYbzmgayp9A2yEIDbpzvXMkE6fVr3gdaTyE4Ja/kubwdWqLI3AxSUAGvnq/AR8dSs19NlYebjqLmA3v4TzQgehIRwr5wRlx3tJ589n2OyKnvOqWkJWxUrShLW9dM+fFbktQMchmOSOSl3reDrIkTWqw8wNaJhbizt8aVG6BbVLaqgqWyF6GB3pVzwH0lTRpouqmqSI8KxVVd7zSy1BenlehsznvmwWZ6/IBCr3FdO1/keLaRaykGFhThRQz3b3qjEd3GlznS63j1vjFqZ/T6G7c7RHXdt3NbQNT5VquywGdXszVFdVUjA== 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=Qn3uz3CLQ/Y0YrGv1CQoN2WLN/wuclM7MSKo2y1IVcw=; b=NxFSa5PxDx9YHxpq2gBBNXDiWqtWQg3k3cJGE6XDAJF0WhfQ2fvNeTQvB3T/2BOMvkCM6HGSX08+XFxF9jurWiaYxn/FxRz972p9hzNDmwlJT7nw+wSnZCwm8F6pINdO7u+IETAF1IR3tNP5BWsqYs0FpEfkvC+xPp/rkJEimXM= 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 PH0PR13MB5780.namprd13.prod.outlook.com (2603:10b6:510:11b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.7; Thu, 18 Nov 2021 13:08:38 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7%7]) with mapi id 15.20.4713.016; Thu, 18 Nov 2021 13:08:38 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com Subject: [PATCH v4 09/10] flow_offload: validate flags of filter and actions Date: Thu, 18 Nov 2021 14:08:04 +0100 Message-Id: <20211118130805.23897-10-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211118130805.23897-1-simon.horman@corigine.com> References: <20211118130805.23897-1-simon.horman@corigine.com> X-ClientProxiedBy: AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:404:a2a4:c5ff:fe4c:9ce9) by AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 13:08:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bd81860c-f3d8-4719-763c-08d9aa94892c X-MS-TrafficTypeDiagnostic: PH0PR13MB5780: 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: PwyJEgrR8Zhco5/gcjbCFUUmTjJCuA4rBMf7NjjCd7JQY/A2cf3kPu36Yxd4Z7cPhZMZfAO7p538wcq/Rpgo5k8hOlTjPJ1871Kf7U8GNPwtCUPTXarn8bK1pmp5wle4XIbE6luZn77d7MslVK5FzansDOsXz6AG8UC2Lp7bACYmdiM8qe1qlsJBeCW10ZizjVQ64997kfKJYh0AM+OBHUq61Wq47pfx9rgofePhIhTIpPW2gsTBFrl5B+3JPD+RKDE+WKlZfgOIQmZEMZJi7XFtaV68UKvJHlT3O8WF0FffPy0tHThqLjYBhy+6mLcn88Gl4R/+Dz0yPIBxVU+dBOiRgOb6bc321aHPLVg+OSqYPWDgRm2KEePpuCTnFmTO9VaIYFyTnMBgM1u4k5FiqVI+JUAjqUlLiY3mj+59Muq5pXz620L7tHBLOaWOgUUIBKKuAH1YtU3GwcErPyoUxWJvOr9byFfx6ZToDKaTKG8skMs4twmHPCpUkcQHjZpSIG8jzmG+QdAN2wVO2susn/jch55xNiFgABLndaiy+w0/r4Jr+QfIvuHoTlMdX9UCxgm41wBLwiuyGbkuNte/ePV2fwnu7W/sh8oFaiAE0DrdGaHrhsnPTZs+UqBXTZ8zlkoiwxvPIG0NLjQiMQp1Bw== 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)(346002)(396003)(366004)(376002)(136003)(316002)(66476007)(6916009)(54906003)(66946007)(52116002)(6506007)(8676002)(6486002)(66556008)(186003)(86362001)(4326008)(15650500001)(6666004)(44832011)(6512007)(83380400001)(107886003)(38100700002)(8936002)(2616005)(508600001)(5660300002)(36756003)(1076003)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ykAiRxCoz3ncwbyYoTpKfXQlJ+nyTaWfocUZNfxMSQ0zFJI0CINW2Jqpet5XJ+Bz9DR3cBQL/SCh19Xm5W1J++9kpIusFHG+KmXp9ChJt7+91G9niOycV4QB3mIAZN3YtSIfcsPnzYDNTh5kciFa7TORgn/TVaI17ceVFfRKtIfbyn2sA2s6K2Lnu00C6NzD/UjWvFAeN77r0lsmnImuSd55tJpBE2xxY0xo/JSUTdzIyTEpb5ZtjHKhms4wy+q3A/Am+SHck4szL9AoQmdGtL+rF3wB1NJd+tDpKL9Yi2sbAC58rVlqckR/InaIuRzfMi6EzwOvWKcl5n8+JmGqYbsFOtlBHGGA0oK4OjXQFdJ8YBvCX96pbd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XdUfkCQ7V+yiXFkFJkbP1hVlQrkF0tvQBWE0Yt5iSWz/caBxu8LAu1gArmvVU52m4f5zvNkhkQAvlINObDi0csRbHRs5U4K0oVj34yQsrymjbdpxD5TAshP72WB+r4/ZrOm28NKauVz9nldskOt+NlrCLXIwRfV8i0HKRxF0OcgPL6GUc0i68J6SBWVq/oMWghVWsj8Mxg0m5rbnDH9dDX2ENu/u8ZTMx4G2fg4Ye/biTRVK4NWuUCqisol4cSaLTSEFZewzti1eVLo23TlHTkjlOMdb930BA5rwksfhmUdy8sTsMCPDviekIWEZE= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd81860c-f3d8-4719-763c-08d9aa94892c X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 13:08:38.4144 (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: jbaiE6/EH3MSm283DvQ4vKOtEzUpLRsxOF0x2wcinM06luPlfAZvj3TdvVwawMWEuAyT1HoJkapzjrrDnVXsDvhak/qVWSpQAi8TXlfHVv8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5780 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 --- 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 e5e6e58df618..10cac4486a1c 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -191,7 +191,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 c8e1aac82752..94439d0521e3 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -354,6 +354,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 ada51b2df851..23ef884c1681 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1474,7 +1474,8 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, 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] = {}; @@ -1512,7 +1513,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 55fa48999d43..e0426202215e 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 Nov 18 13:08: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: 12626991 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E0DDC433F5 for ; Thu, 18 Nov 2021 13:09:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0677961026 for ; Thu, 18 Nov 2021 13:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230026AbhKRNMB (ORCPT ); Thu, 18 Nov 2021 08:12:01 -0500 Received: from mail-dm6nam10on2122.outbound.protection.outlook.com ([40.107.93.122]:47280 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230118AbhKRNLz (ORCPT ); Thu, 18 Nov 2021 08:11:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OFRWVJAqHA238OkCXrBt21EyaKeNCWUIXyh7kEyFva9rEkeQT7uXxLAojyhNCbfLlAdfpliTf+FiqNbRdp39fowNb2+jpU8o+RwkSHkEZ6X2UptY0D+zg8PDhmX8fYPN4Qi0HiOj+hFFyO8zXQOEBNEAN7UQi7V2Jv+6wA3VttSG3YzkMzTSopKXb7dzLyziW6gX00jq+P8KvPXDRh1OcRQijTaJuOPdfcSvtEaNEt2adrdZlqPGmHo6SrUsBhlsDVyd2n+MibmPxuqzqVGCZzXtrq1mpB+GOsjcwWB8512XRdeh0Kl9QUj0DVDb2RUeIkSRth+N5ppzzDUuBIeODQ== 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=YF7Oo71/m9T9UVj9D8GyGXu/xxV35RQWMkAHxdXMAXM=; b=nNx4YLD0XaOYXSgxlE7MlYUFTOScA4uEFWib8/rD1mD3p2NldKI6a0OW4OC0oOeonqD9b7Ls3g0ynm9WBxjRkML5QtvoMJCzbMc12w0b2Be7NELbHXDD11Y1SGnLdLJULTtqJtNXk0Sz8HWm5h6pvp41Si1FX3vK/IXvaSYwoNGbbWO4Z3xyN0G1aUjp45VXScErc+A65fdkyjQWnPRdIMjgYhKmVNedx6eHxjLhubDKCmFZMaem+CRWjEwgumZx34F+iJ7PCksKRNOZvSe5OJYGwT4N2FObujb/5uOC3D2Tu27hsn6PKC4X7TgYU8VDogP+EWkW8I8KobIubdpZog== 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=YF7Oo71/m9T9UVj9D8GyGXu/xxV35RQWMkAHxdXMAXM=; b=pIO7XqbawXhlXN70CjCRJJBeg611T7AwE2vCkNRAGQH08skUJzJzByF1gmiu6wlJjZ5rRaWTcD76p8NuhQB4Wi6/E3DzPxkDRJeMRmy7tIe3fiDKLgBzF8PgNg3ZiPYAUAI5pq1Kw+0IWWFl/Y6f9iNPWITawe6gG2WmKR8Ooho= 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 PH0PR13MB5780.namprd13.prod.outlook.com (2603:10b6:510:11b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.7; Thu, 18 Nov 2021 13:08:40 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3152:9426:f3b1:6fd7%7]) with mapi id 15.20.4713.016; Thu, 18 Nov 2021 13:08:40 +0000 From: Simon Horman To: netdev@vger.kernel.org Cc: Cong Wang , Ido Schimmel , Jamal Hadi Salim , Jiri Pirko , Oz Shlomo , Roi Dayan , Vlad Buslov , Baowen Zheng , Louis Peens , oss-drivers@corigine.com Subject: [PATCH v4 10/10] selftests: tc-testing: add action offload selftest for action and filter Date: Thu, 18 Nov 2021 14:08:05 +0100 Message-Id: <20211118130805.23897-11-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211118130805.23897-1-simon.horman@corigine.com> References: <20211118130805.23897-1-simon.horman@corigine.com> X-ClientProxiedBy: AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:404:a2a4:c5ff:fe4c:9ce9) by AM4PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:200:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 13:08:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33ba0278-cd84-4e87-b016-08d9aa948a7a X-MS-TrafficTypeDiagnostic: PH0PR13MB5780: 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: +D4kF+criaSzy5bw0glyc0owVDZkkrywP/VkDjhxOo6DBshS73D8RTUixczJkHamFQI1f1lYSkQl+qPAdXCxeYpIBS+XZRk0FN+XSCBoJdjAN90l2Gpc9upLT5m7MFq5ZG2N2+0Y5bQPGXnyph+nReqoUbZD4gnM4u1WLnUU9oEE/dTwuYOTGT0v0Mz6YC3L+wPruTj9EoO4a4fPJiKqvjd9eDOlsTS0Sh5z/sSnH2FlThnyvbS9g3x4VKWqSm/xFvxFKvTkAOdF+c6DhD71SBM0GkTgWqD7iCgbLjCgKPNOuv3psHKt8NHb6+C2t+01u6+6j15R+0Q5XDEvUmwyhXQl16oWBcrcg82/vICHgZKGzpaMAzTqXylWFOl+8OpQgc1Mi8axThzr5FVfB6HOfufzjvtdGK4Usdmk31F0O70Jns0DZ8CSD4BeqBR6QNbZk68akoxHM5L+gYYdOFFL0gTWSxfMSJ9ciu5LammnKIICXxQOWZr1MHCUmW/QTGnbAubyabY7pZY51F2DlesIJ9U7TVMjSOqL5W7t1RqFubGYejBINw67PWe8R+L1ovNUYnuHpTU+fMffZ1cPx6vFZF12NkMHrvaBFT7TqDinOc/GkUCWg6PgMEM9tcd2FfRbU59Ae/mKnkoSEr8PJ8GEWg== 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)(346002)(396003)(366004)(376002)(136003)(316002)(66476007)(6916009)(54906003)(66946007)(52116002)(6506007)(8676002)(6486002)(66556008)(186003)(86362001)(4326008)(6666004)(44832011)(6512007)(83380400001)(107886003)(38100700002)(8936002)(2616005)(508600001)(5660300002)(36756003)(1076003)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: K0Ab22rRLjAewiQx4sWQWTj4I8fvb9ngm5eFHcWHcOJRcxWrFj5EnxblhLFNzF5ZFU0cKX+sUpkrb2V2EiGGPvwPkNdKT9u/Js8cLhasTlYmFiaN4/zOVUWOMBCC1qDwr77RWIWl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uBPRwv7AoTkrp+Vd4Msx2Bwo2lYVmdQHHrjUvUZKL0JSI/mv0D7Oto7Cq+WBLGcaBiwjDgQTaiv8Ozd7HlRLlMiF5exTfGDJxlXw7rfiX+nYl04UOpgR6yV7nuh38JpoAXK0bQlYZaCeCZg6Wa5uAXelEa4NPxgtQb5gGfpmIzbJWzE2F1Eijjma4vOdv5pX9JtAGkEEPZscUJwJPNZeCnPBGqzu6J2JhxH3ZpLN237NY7CisHA7AKsYa++KHsIFvPsEK8gylBwv1XoY2uQMKkC8oxeyjHagorekfj3uTQP7AZrLUruDX0IgLAtqdZrbIZkttUtf3k1iDYqSHg9CACZYLPJZoIiTQN6rAaT9kyyxUODuF9WtqTFSwRROdqetKWhR22yeaZkGAlGoqruoDgcfJ3XWPXWAYavCW18Mb4GdDj6vOONv7xIROh5OlcNNZNq6yLzXSVJFwjbbdcWwoJzHEuJJRvRx1Lzp4HUNjwsV8t3fyWtoKKJRZr/VMf8xs6uud2pnsi+c0wuffL1jyaJPSqt55TPTS1E= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33ba0278-cd84-4e87-b016-08d9aa948a7a X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 13:08:40.6227 (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: MLMgb5QwdveeGYuj3U4PpcE7TzeCgVhkFQX1hANJzaAhFyw9rxcW6inGd5Y+0Fni3r7MZPEtk9eM0/ulFFXAoczYFVjnOGxWMgnvV5PEB6o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5780 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Baowen Zheng Add selftest cases in action police with skip_hw. Add selftest case to validate flags of filter and action. These tests depend on corresponding iproute2 command support. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman --- .../tc-testing/tc-tests/actions/police.json | 24 +++++++++++++++++++ .../tc-testing/tc-tests/filters/matchall.json | 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..c17d277f0ab6 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_sw" + ], + "cmdUnderTest": "$TC filter add dev $DUMMY parent ffff: handle 0x1 prio 65535 protocol ipv4 matchall skip_hw action police index 199", + "expExitCode": "2", + "verifyCmd": "$TC filter get dev $DUMMY parent ffff: handle 1 prio 65535 protocol ipv4 matchall", + "matchPattern": "^filter parent ffff: protocol ip pref 655355 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" + ] } ]