From patchwork Fri Dec 3 12:24:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655033 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AC36C433EF for ; Fri, 3 Dec 2021 12:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239925AbhLCM22 (ORCPT ); Fri, 3 Dec 2021 07:28:28 -0500 Received: from mail-bn8nam12on2112.outbound.protection.outlook.com ([40.107.237.112]:29079 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233378AbhLCM21 (ORCPT ); Fri, 3 Dec 2021 07:28:27 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lbc13lNBI9uqTu3p5nK6FB7x89zdydMap0xF2/QZk0Cpu++ImMbJlZqw2BHmKPrN0VbIvG7L4BvmzyVO2BKqO0/o95tuSw75z8KAukY14Olx1lasw/spe9afy/u1cX5G2QBE1Po2PEKTNh0RX7AH3ToT5//hW/y5WjEOw6xRQ4uyNFd84xHJUjicSFBT9QMdLuRhnEQm2OlsnNc/s20QhnqMLtwOKpnSm39nuXgmS4XDh9gF4Chz+40w9ZsbjLq3Fjg+GLxMr6kDj45wJRcyGZC5w0dhbcjydVKR2y7wyuH6vdPfJeH3yVrwerfUX5zkthBD3VHqIaj2gvmNXKPmtQ== 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=nY38to/AwRDUYwZmz7i2aTpZHbmhAk/8SJCx0+6767a9h99W4PIRmDKhM5qUKPIE9zAMUIm3yOm+bue/4c+W6fzjWmdWhqJ0IC7tX/wcP9baWesHRrfIlJI5aCvJstctGOOuvA8Pz/9aDeDNVNSp995j9DlA7rh5JyjUGe9lcN5PBfgzHt4U1eS+CLkQv3LIEJboaqHiUy7lRjnBIsEgKoe299hL3QDT5JXir6neO4si6x6jsvbX9kkjnhJ6MCSaDkVUxHk55H8t6FDT0MjiMdWWF8HI3+7EhFdiwIpE7F2hP9ukFrp6BH1xpXUCHGfb635XDBO2H7lIty2LD5pwoQ== 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=Zfnw7G7g93iL9kOB1oC/fbix+0vxFPWb6Gi/wTLaO22WkJqjO3s/eKEv7MnI4yq3iWjWhEGOE0bi/BLTeoRdVmA9DahYidx7mzUW44Cm4U2/i0kkD2o1DP8kMpc2kRe9yvljzoM2iKWGxJmss1W11TDEzP1E3UQUlekCiv3CDro= 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 PH0PR13MB5423.namprd13.prod.outlook.com (2603:10b6:510:12a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.7; Fri, 3 Dec 2021 12:25:01 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25:01 +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, Simon Horman Subject: [PATCH v5 net-next 01/12] flow_offload: fill flags to action structure Date: Fri, 3 Dec 2021 13:24:33 +0100 Message-Id: <20211203122444.11756-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:24:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a8b6a9cd-d868-4090-48ab-08d9b657edc1 X-MS-TrafficTypeDiagnostic: PH0PR13MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:179; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /ZR7FdKVMckJ+5zcpP7Xg+t4Yf+v5yjSYruPy1m5ddUKW1cNIpV0lcgOvqbLWZtOrjymHd4q4eRaz++aHetU6IOn4H4Pcd3alV5x7GE9htXhFPTJIRiDb+GbE5fobGLkPBQbcJSvjbUF689Za9DDpbszGeukvvx35KuylIwACoRhGgLbztfy0k7domXuGiKEu0iuyysgl5HtXlS8RlJlAKmLnV0qvO+j17SYbF1LXgj2fkMDIUCtZSO+YNAcfKT9/fFoxuPW3ym4WQO6ot5QoeSAD53EoSxJHs0VwgRyKhYzdL39/n47871cawABUev77Dc4b4lWOCMXvnvHT3J3PJWzGjFzMJJlXArCkJ+N7yXtUK4l6go/CZ/uWCTtUSVWOgmSjMMoswMyaazWsXxSeUNRzEuX8UNmYlcvSPZkZf+F4LfwZof01kqKdLmRkkaZiIWn/GTJU8QyM6+rrB16cCsqPvLrKpJ08owlxacGmVeYPAlP3CUkYsplo4M+SQBiNl4I8n4juduh4/pcDFWRxg7LLi+fRM3fADrXNv6fFCEmTkb68X2DT/sMMko8Re6UIpNnY8u0W6iw06LCtPSHA5keosyLZOnfr/iWByjUO7yCZZmImbcmhLSi0rRbueyuDqxg55STRxcnEHHcBlgiCw== 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:(366004)(346002)(376002)(39830400003)(396003)(136003)(6666004)(8936002)(38100700002)(2616005)(6506007)(4326008)(66946007)(66556008)(8676002)(36756003)(186003)(316002)(1076003)(44832011)(6486002)(508600001)(66476007)(5660300002)(107886003)(54906003)(52116002)(86362001)(83380400001)(6916009)(6512007)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0Jj+34IeTPT5pU0GcXj+vrv0GFKNb0NKaY1+ylp0iD2RZKbH4MWUemvnbcaMUo199eU3mxpEgC9K0VTILn4HHC9npkFvdzEOiMB0OyDambHTy4nnaouc9Rd4i9vzWl/BLuIlYcRNsmUf+7DNGWcyu9rdcTVJOQBEmAGr/pBpa8+1sYq+cldwPrX2EOFhW7ih5v/g0LAcOyNUTMQRBAkTAtig6aF3KElsTvNRmR/+j+nsOIyfEq7hmQCdRP1le10oBKg238euSSbaUQNkWuvzwBlFSX78HNhaFCP8hbjcDSMYZOWMjqwRleczvEvJmbms5xHIwsJwxX7nTxda3p4rDXbS/j1DiTmv7EMfjdZtj81yFqo/JkbpVpzNWP+Y9id1RdyGeLXcNO8tNSrSfnnsKZtpzTpXJiC/06ZpoNPyaITPJJhxIGU73WBJKyO0LYDe27NTBWsO3tgAgMRF7pcxQEjAwaFEm2iy02RNJS0b+uvF3sgHucReJaw03qkmXHJWeWvb6P8oRW+PI0RF21nFEL973JYj97XwZpRr/wbqHKGh5idtIG/Sz21uusBttU5S2oHJeHkbUjp+hJ4Dzp+KT14aC0cPVE+y9Ulh2vQcywTAkpS2UjCGmSIweD2rCp6gZAIwGG+62XBm49uYPA7u13gR98YGboz4NnFzkcx10Lfc7yot11AmerUgHqv6f4dVGZVVGyLDiR0MfW7AOYsNFiyvwsny8UjPNdlUiffSMhjGY45P7puHbzzNq6jhw6WBVb16rD/x4JLdHgnzosBWqK5S+2Y2jb8Kg4SRaJulWT4K8152pj+g4/ay3SOQiYFL96pyxmr5sAf4qUAgrrn6Nkq8hHaz4Fa0qRjv1PFn8Uk9HgO4ktIVj4uere6gt6iDXc6DPWcL9Ld/duPGdv1HoGWkXoBr/wMRfwIggQj15s9S/Ku9yx+EuwvFIMpn9Z+tN9BxwXwgpRDBrVjHuZB2QotPWMl16zJrNwuyOa49cxgFuYDfeF9f58uXtfscR5KhaQR2dOiE2YR911v1tSeOgP/lZADIcK+9ik0pbsEvCKAgZrO1huLaLsstZsPEkZlk2faCSAoqhMp58NdQnQsooTOGoi05JJOUpNhlMijJoZKPJ4dxQg28M8XC6+JTC9fI/451EUgQ/kp4MRXkYQXcgGFK66X/F1GndnYU9ZLbNXlI0CyXxxjTGOJ4XKsxhVRPSzl56Tqskq7SmCe0Z1tFVZN3JGXx7aN215cxS9sP/Oh1Ha2H/YdVSxreLg7nkwNGULQP4FXRRvhycPs3mpYsE5dROLWbjf142qAl9V19sDEekYoPpQhbJUO6Jt+OrG1VSyG3pLBsXLbUCf2HWiALCfCa5KC72C6eeP+rme/TBai4zbHxb6vDogU6XSym1POe7mdij2H5Hf2CkucXVhss4lXQOP7BNGG0icZChAvl1lrrH/Cbr4ViP9U46XaZfEIV1/YwCuSfRP61ulmAWLhoA45Cj6K3F5o7ba741bUSWb1POaGVQaJFUqSvEU0kW/yvhXV/vA++1yv1GnZ6tczD4dxkehWoxWeEtoQJp97ABCusxBzJyAIP2wdF6GqNIwW8yHofrmzg2Zbha4g4ei6V2EsqYlvh0CvpwXJueWjuZwZfx5XYSxEeBvVryQv1pyFWA59UHUX0+L1tx4VEBbq5/iAfq908ywoolqaNiqiA7YhlFcczvAC6EtzUtF8RmIMurMdaGtRMde/5/yjiMenCag== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8b6a9cd-d868-4090-48ab-08d9b657edc1 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:01.8157 (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: DtFzaKkKaCAn0mBERXIfH4qtCTbw59azO+5rm7C3qK1y1u6UIZp1l24toDIwUBreqbn2nvcbZdMS1vrfJGlxT2uwuxNhBcpMXYLGl8rYxw0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5423 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Fill flags to action structure to allow user control if the action should be offloaded to hardware or not. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- net/sched/act_bpf.c | 2 +- net/sched/act_connmark.c | 2 +- net/sched/act_ctinfo.c | 2 +- net/sched/act_gate.c | 2 +- net/sched/act_ife.c | 2 +- net/sched/act_ipt.c | 2 +- net/sched/act_mpls.c | 2 +- net/sched/act_nat.c | 2 +- net/sched/act_pedit.c | 2 +- net/sched/act_police.c | 2 +- net/sched/act_sample.c | 2 +- net/sched/act_simple.c | 2 +- net/sched/act_skbedit.c | 2 +- net/sched/act_skbmod.c | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index f2bf896331a5..a77d8908e737 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c @@ -305,7 +305,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, ret = tcf_idr_check_alloc(tn, &index, act, bind); if (!ret) { ret = tcf_idr_create(tn, index, est, act, - &act_bpf_ops, bind, true, 0); + &act_bpf_ops, bind, true, flags); if (ret < 0) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_connmark.c b/net/sched/act_connmark.c index 94e78ac7a748..09e2aafc8943 100644 --- a/net/sched/act_connmark.c +++ b/net/sched/act_connmark.c @@ -124,7 +124,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, ret = tcf_idr_check_alloc(tn, &index, a, bind); if (!ret) { ret = tcf_idr_create(tn, index, est, a, - &act_connmark_ops, bind, false, 0); + &act_connmark_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c index 549374a2d008..0281e45987a4 100644 --- a/net/sched/act_ctinfo.c +++ b/net/sched/act_ctinfo.c @@ -212,7 +212,7 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_ctinfo_ops, bind, false, 0); + &act_ctinfo_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c index 7df72a4197a3..ac985c53ebaf 100644 --- a/net/sched/act_gate.c +++ b/net/sched/act_gate.c @@ -357,7 +357,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla, if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_gate_ops, bind, false, 0); + &act_gate_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index b757f90a2d58..41ba55e60b1b 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c @@ -553,7 +553,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, &act_ife_ops, - bind, true, 0); + bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); kfree(p); diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 265b1443e252..2f3d507c24a1 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c @@ -145,7 +145,7 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, ops, bind, - false, 0); + false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index 8faa4c58305e..2b30dc562743 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -248,7 +248,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_mpls_ops, bind, true, 0); + &act_mpls_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c index 7dd6b586ba7f..2a39b3729e84 100644 --- a/net/sched/act_nat.c +++ b/net/sched/act_nat.c @@ -61,7 +61,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_nat_ops, bind, false, 0); + &act_nat_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index c6c862c459cc..cd3b8aad3192 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -189,7 +189,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, err = tcf_idr_check_alloc(tn, &index, a, bind); if (!err) { ret = tcf_idr_create(tn, index, est, a, - &act_pedit_ops, bind, false, 0); + &act_pedit_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); goto out_free; diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 9e77ba8401e5..c13a6245dfba 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -90,7 +90,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, NULL, a, - &act_police_ops, bind, true, 0); + &act_police_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index ce859b0e0deb..91a7a93d5f6a 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -70,7 +70,7 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_sample_ops, bind, true, 0); + &act_sample_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index e617ab4505ca..8c1d60bde93e 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c @@ -129,7 +129,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_simp_ops, bind, false, 0); + &act_simp_ops, bind, false, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index d30ecbfc8f84..cb2d10d3dcc0 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -176,7 +176,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_skbedit_ops, bind, true, 0); + &act_skbedit_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c index 9b6b52c5e24e..2083612d8780 100644 --- a/net/sched/act_skbmod.c +++ b/net/sched/act_skbmod.c @@ -168,7 +168,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, index, est, a, - &act_skbmod_ops, bind, true, 0); + &act_skbmod_ops, bind, true, flags); if (ret) { tcf_idr_cleanup(tn, index); return ret; From patchwork Fri Dec 3 12:24:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655035 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01619C433F5 for ; Fri, 3 Dec 2021 12:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244220AbhLCM2a (ORCPT ); Fri, 3 Dec 2021 07:28:30 -0500 Received: from mail-co1nam11on2130.outbound.protection.outlook.com ([40.107.220.130]:65377 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233378AbhLCM2a (ORCPT ); Fri, 3 Dec 2021 07:28:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j3C1NDmlLFgwdDfClgb1k6bTjfk4khFs7XAgPSJmh/yJE5i/CLcztGq4uoIzmCDytq2YJFDgKN3H64iwdKBELISYRNCxWmZIDMLm1LWCDlDnJMzZrK+MWj8R3JY6hn5rqJ0e1pm+GHGt8p3gaZSRExSdYpYqhUyX7szYOXeVTmh7xjzhK3up7FJd7rkRj+2kcTOph0IS1sMaMT8pPxptxQ7puJv+6MW+6c6nbyn2fuNAWidl6NQn68kCFeZcAAdm0QnU9B7SZz66b2LA3RXYpnr/sCM6EheWzGq/1Pw11ucDZAZuw7FInU6U7VkQpbGdnUt3NU9+u3RgWia7SPsq4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p8LLQp3zHRSWSnacjGf5qSBjctEdinbafUimocvkGnM=; b=KWikxh+zCvYfbFi/lsPFmMEfzFau1jYc212yjoB0vLz+X5lN+eRCmJ8XPi9MbRUfQfTKfP4VVwzMjX5j5xKP/sLeSqq4YnVj0MQqWSiroerWagjLbAFMiG2UWRWn7qDLVBYOEiv8JQt55mtM1QJBumma+Gu5mErEkQM7yGQD7+34x76nh46aI/AQTeW2GuaTXgG0N5CwfG1ngLAgwiPGNhQjORd6/ZULT7P9ntE6w2G7LtAex1ajd61Kg84y6OoivayImadk2IkEogS5oHfKQyOSh9/TTLeiCNQgY2PbNCJb5X4CXdgpeuVoalJXRPNLVS95kF9yQl69j3hWfdugpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p8LLQp3zHRSWSnacjGf5qSBjctEdinbafUimocvkGnM=; b=rwKVj+RiFgrRxCwt7FF217sRrr5EEIRrtGl9ZwQcu5fOESOqL3njpRgSuSM0o2OB0Ilu5Xjq4O4hgojjj007YSvj1Hvx+R6HQ9EiLOu9jpnii1ifVOYPgRI0u6+dkY2CjzJ2f4TYla3AqjcMzIvlmPhi+bxC+63Kr1ESqkZlxx8= 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 PH0PR13MB5283.namprd13.prod.outlook.com (2603:10b6:510:f4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Fri, 3 Dec 2021 12:25:04 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25:04 +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, Simon Horman Subject: [PATCH v5 net-next 02/12] flow_offload: reject to offload tc actions in offload drivers Date: Fri, 3 Dec 2021 13:24:34 +0100 Message-Id: <20211203122444.11756-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 657effab-3a54-4886-4292-08d9b657ef7e X-MS-TrafficTypeDiagnostic: PH0PR13MB5283:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7dxzrIE8MOTt7TO+bIBvN7rYmo4Gs/R6wBfbE0mODNlus/g4AG76Rr2/mR9pinK4Fyi5ZL7quY2WFYt/oNp3efbZfaCdL15KpryMNpfwB1pgGDp80yfXzRsgrlln66OiqoXN9vCKOTXdKafYby4Cq2r+iH40lBVlCcXT32lsrjsj2zIRielwpwfN1Y+LYRFiIkjXqH/oUSfwJ9+dgtn4LeORlZhe3WW4xqwyzdNXteaXag41BrLIRJRMeKZTpQvYObcP+LpGgsejwVl4LA43pVmWc/S0UwMzb+97+d3LMMzJiwQYzrdljB6v/19q6F99rDFHFxEIXHtXfLgURW6VCx+zU77dqGxfIRTb+VYa2OJUjXa3oareZxmWB2DPFMwFDWO9o0FvZFE0r3U7SeUvtmhUdr+K1S+3zRG6ilrlNMJ27k+H1EP4fAHbFrt/89ivjKzTf5rhNJfh5UulSBwC/QcUW0motWAeMX9ssjYvFE1QeR4tVVXLzREW3JLPU0gtVK4LkgATq1YmxFGp60kEFm6qkXQrCFEfzspqXXEM12NnAVgpbHzQo1QNPzlgMDK6n3IzQR95HsmtlHRtl6VeQfqeoPEywLzgXRCQlZ43BqkWLVLrcqmlsUkwOZvCwcl2DLydGXzPfaDwSSfUmyA0mQ== 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:(366004)(39830400003)(346002)(376002)(136003)(396003)(86362001)(52116002)(36756003)(44832011)(508600001)(186003)(83380400001)(6666004)(6486002)(66946007)(6916009)(5660300002)(316002)(2616005)(66476007)(8676002)(6506007)(8936002)(107886003)(2906002)(6512007)(54906003)(38100700002)(1076003)(4326008)(66556008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RRqFQ9swKtOpDz1EzjqqGHYlHJYrgZNoSjpLjigJyrF9+idlquaMcg/2WlH+SrCZ7u4nk0Msih8r+5TlGFt3kPlNnVbLMRVw6lkvUQWEr+EeLBpMX6Zw6rVI2ope043y6MC+7lW/1xrT2ObvlrpAdijSD5ENBz4vgz6ZZ+/JAbP9bzgYYvL0f7Q3gR2VGw13F6oc40oaoZlZFKb1STozNNMBngHXJrXZSIU3vI17B4FrdHCrgTISm87dKSIckzJjhbKVfYVMC+XAaVTBByxfU78VvEwK5PLyJGWNGOeq4AH/wcpme6Gtt4ionJEJ1r+lo8cLaXUgqoePyvd2nyB5/tK3lm+kl1XXvkQ2Gkg9Hd0BJRtGriLzA60wNLjIWmt11wUYsnqjdzkMsd22doV9IgfK0MqVCY2SspUg6w92R0XLPQwFp7DNiiBOrKJS9KNvDUnZf8TefkDTvPk41+uVEMQ6gzmqwJKmaBv8OR8jcLcu7bUsZWo8oKd62EiJdaEq33uH7+V0S4V8LvnJJetl0EpYL7fIJYRlciHUDZC5cFwhQlUttprDiRpMzF/aJjr/KqgvWwgVD2lzXEZqPrW8B5DQGNMyl2WyTdXYjEkXdA4z4L08mmUO9mmAdfaQkKLPWXPmVItRhiJOwMIw4QeqXpX080Y2sgngeF8FSkDoFYhfMpqyu5QEA61Qm+9nsEsL8KmMbL8UOCwDg9SK+dXMecmQ0smB7Kxi0p9LLv0906pXyzp7etvCoIx3xRKGA46dckDHe+tU7TL/8leAbCyG0/dwHPHr2Moaiwo8j2Yi1sjD7vXktbsmWHW69aqoOszzsDhE6syKmJPIU1KoWNFycGKZx1XY6q00YJ0prGComVW/x5v0Z3bQ27lvOZDwah6cIwO8H4gZmvYs5UhNCRnYqvhPvUxsoktZDfqiYdRoLzqt6sBGNDcXLVzxFHvksIxNWBOmYAMAwdReWNvDm6BnzgouHRdhk3eHc6IoVy3irEr0X74JNMWTsiDCWf9DJ7u58YigZ5t6ywbWxvbd/nQooS25XyMWaD9+VDLcjxsbK7bDsLisAtG6x9F3L0GokGDtSmlgnri+uWPPfDJzS4JXAbO4Y0Z3JmhsoGf9ggcKAKECAU304uudA/LVUKFEUjgZ6ACPkrnr2d53dYXIpJ9W/DqLH3g3PKEdaUW1oVnJUk1b6r+HE4/IVq3gORvSDpso8bAQ0zXXUPzVJKPq3+xkhT4BJ/xwj3IVEdl0wBIpVgmJkLjHUXcr71Fe2WWdN8ZXaUEoQRiE4o+S8nhVYP6XuKzMPfgm+dHOoPsR2TRgthFIZCFiJXDSX93zYo+nc2QdgGwupawnsdxEU4UMedohx6/9Q5LXcg4UU+KI3Fwj7T2GHdudEBWcDyWJD/aDHXlVP6kc0vqEyIP7qOMuZ5/I+7sDhGI44qVDt5YqFUBXr1t6n3De642ERuMGcrYWZDxQ6TBVykKRdx+eiibKHgOXiOGPxoMKDUGhBlZe21LIxJUZFIAbbh4g0FseMDyUe6eTHcxNOV8liytxbwF5YASEIgzvRTEVUU6fz32OS7wIiMEUiDa4t1a32znTQ9tY4pNN4kIdSnO2b5LRrDYyUB+v9pNqkt2PbAgln+Q3QG/AOxJBD0PuWlE8Clf7eywcATZAx5AhfazvrcvNMhY+z6Zd+MQb764nGoZoayFGpzsZ3Ugf+30sgX4ws+Evmfq0QJ5bQ8ABmDHsO3uLQ90ZQzWaYw== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 657effab-3a54-4886-4292-08d9b657ef7e X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:04.7249 (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: xuOl6amvHDUpWb3ncyXlTMva7zk7M/zblkLmcDNKxG5UkAlqfyVoXPcdPyvRzKhHeZ/bXNES9yQLBlAVYAizEyBhEKEbwq8EhMqPJMZo6sQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5283 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 1471b6130a2b..d8afcf8d6b30 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c @@ -1962,7 +1962,7 @@ static int bnxt_tc_setup_indr_cb(struct net_device *netdev, struct Qdisc *sch, v void *data, void (*cleanup)(struct flow_block_cb *block_cb)) { - if (!bnxt_is_netdev_indr_offload(netdev)) + if (!netdev || !bnxt_is_netdev_indr_offload(netdev)) return -EOPNOTSUPP; switch (type) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c index fcb0892c08a9..0991345c4ae5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c @@ -517,6 +517,9 @@ int mlx5e_rep_indr_setup_cb(struct net_device *netdev, struct Qdisc *sch, void * void *data, void (*cleanup)(struct flow_block_cb *block_cb)) { + if (!netdev) + return -EOPNOTSUPP; + switch (type) { case TC_SETUP_BLOCK: return mlx5e_rep_indr_setup_block(netdev, sch, cb_priv, type_data, diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 224089d04d98..f97eff5afd12 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -1867,6 +1867,9 @@ nfp_flower_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch, void * void *data, void (*cleanup)(struct flow_block_cb *block_cb)) { + if (!netdev) + return -EOPNOTSUPP; + if (!nfp_fl_is_netdev_to_offload(netdev)) return -EOPNOTSUPP; From patchwork Fri Dec 3 12:24:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655037 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 412EDC433EF for ; Fri, 3 Dec 2021 12:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244320AbhLCM2e (ORCPT ); Fri, 3 Dec 2021 07:28:34 -0500 Received: from mail-co1nam11on2097.outbound.protection.outlook.com ([40.107.220.97]:50502 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244247AbhLCM2c (ORCPT ); Fri, 3 Dec 2021 07:28:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CFmKYKzWxFbom+cVBgcJkgqOUpERUE1Nz/opbQBzsINNCgD0JOiOkmVJpzRFJXPQdmfOuymTI7uCrafHP8RIisY1Osq7HOFng+cB3CxPpoR7hxfJzjJ7PnFFPZWxBf0oYq3lcCKWrqYcF1rA2mrIw0szp3zUHNi9ncipcvy2kjqFlzrXJ4L1OtMoLHcdmvSKRK/RV/Df5hzLDy86nq0bo4/XIr8gGBQqk0sN3baeQCdBX31PpmrYoFotF9NRTLgvFRGGugyFPcv4x4c0h2YxZx2vo9uUCwu/divBLE4uBvaBxJbeWGS1QOzQmYDWfpLw/MCQOHlssA+XvmVIrbkm+Q== 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=OimqGES5noFBcMrC0mua++CoK1sjjWPHvy6v/bW4KQg=; b=XJ+8T9KrS4Mt2DqC+8lmeD9pVzb88OSVmOO7sR314veQ+kdPDjxNZgKFsimsOUsdqu83Y0Ex+AP/6Bm4DasLzjPjb9dADy1UBFwbwtosPFWKy/D+giMXwd4zitLVqCXh5n/AqLm1FZ7ySOV5h8EekGH/vkOJOfon0b88vVX0sPdxO16A9trqtGL4S2hWQ3ES5PB0tLgkli/GpItH7LDfkvGnOdfO+7ExoOlE1jFFeySx7Lyf7nbLVJ8brgVZoF6CyHM7xQTY/DdETTHB+L2M/TGb1fhTvrQnvyw07EnUE40WiNLLVzG/Bbzcbuh7U3qsPBVeSWFlshDqQdQZNrJU+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OimqGES5noFBcMrC0mua++CoK1sjjWPHvy6v/bW4KQg=; b=BBbVi5AZsN2bi+Ft5donvFBmIDKtW+AvxJ6OJo213DAoz2agUQI8bNuqBF0DPJvSFy8UzYXKaezKhuvyHLpbMkuUNrxQ/A1U6jidfDQyGVVkm87NT2fRB9aTv5NSffqKPcZz2PNm1lHNJQfYATf+ElboGG3nDjmEXGjEml+zY34= 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 PH0PR13MB5283.namprd13.prod.outlook.com (2603:10b6:510:f4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Fri, 3 Dec 2021 12:25:07 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25:07 +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, Simon Horman Subject: [PATCH v5 net-next 03/12] flow_offload: add index to flow_action_entry structure Date: Fri, 3 Dec 2021 13:24:35 +0100 Message-Id: <20211203122444.11756-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 22857225-4c95-4ee2-df49-08d9b657f0f6 X-MS-TrafficTypeDiagnostic: PH0PR13MB5283:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:64; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: acGcVOyEcrosctiWjc1RhN/HzPvHqSfvCkrRg512FpNSzO5JtsuJoAuD8Q549d9m+5BktYEt16Zh/RBPyg0XdZ7HWU+U9F3WxPDDFZsANipcz7GPirUhTme3qJ9x9eE2VRn9Iczy7VVRKY+9hptXwMRC2Y0G302QtR4G/rugviXnVr1avggP0+a5MEmKFj3dsSzTZcFQD9qNSvxyPvQ9OQfdNW6890Y3UhWw9MLDkkjdC0Giim2zj1u9DlqeFvSCV2v5mu5cIrqfCfJF8i6P/FTpCiIdfNMxjPA5t+MsJYzSGOMbN4SnzUzbjZBuBcBRxlP+4FtSqfwZ19KuEhZx7VodR1rSYxqbWTmbWK3cx2eoVBA0qhhE/QyanIfJSHHgNbDxkbcDHqdJ0n/rP6x91Yxae1EocKJfFsPTtvwQjEQf62Uo+83SHOYaPLTBEj5eD+aFnsOtYOitcIc+PLvnblBieuFIcLToeZ5YHGX/f/VkuYvhaJtEmUIuBQ0FxRlkJmoLtsyR9iiPv89m4JW4m8bWJJEAhVurSJXPAXKgsx+RiZn+rvmEiIa+F1J97modE4xvJrgUdP/aliqUMjxytpH0ftSN565fvv+b1QDWM1O2G+mO8f8IElVZVBi/L/waqnaI+mB52gnj3zKHdHBTkA== 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:(366004)(39830400003)(346002)(376002)(136003)(396003)(86362001)(52116002)(36756003)(44832011)(508600001)(186003)(83380400001)(6666004)(6486002)(66946007)(6916009)(5660300002)(316002)(2616005)(66476007)(8676002)(6506007)(8936002)(107886003)(2906002)(6512007)(54906003)(38100700002)(1076003)(4326008)(66556008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RCAYLLyXiYdpg0Q3rKE/FG9yH8lKdIQHDC8vgQyLQy7CuaQzVB7Wr2fIrJiFowI0iBwcCjCc+isqIlKpvNWqSSazHwdfVLsdhvA2IWWCLND2OHSg2oOX+QmbHKPp8GeG0axUhXiiPzVP123nY/+RarSGs+gp4dOSlfAA3ZqENtNlnPeekI8UMGsbqmk7DXKtf6hEYGz7FbNRaQsyTYEXBOiTwuDujPF54WryFSn4rkB3o7HZidcnfoIop/UMwf4HALaH3eaXo2xdqyDjGydnkSB/xsuXLrrdGjEc0bkInwbikmhaK5ZYSlIBd9QovwXDuY2BEquAwOgdgcadc7Ai3700Sp3DPZbHfaXuWMBkk0fRkKJRAr0MQYQyj5cNre6wrUbMBkm92mk4psIg2zlDD3yhz/MtstjvPSY9dOhsdi29gBgLC8/ZrYy634Sh7Ibey73lhUmEm7bUsF4bg3Fo1phg3cYHNNLaFQ5OqFPb8secZckBow9cnAxHpDqCNEtdwc9CxwWVi2MsY+I7jyYcMaNHyMtrlKm/vIiCg75cWvqwuymlk7ybov90zl9h7LBHJo7ZM39LvOW5zVJ4rx8+hJUsZT1nP5GX/zpIKQfFCoFIVYv2HEXgqNqRwMogLxkkdUdBWQxxcmAYHqbZjcPutLjTNsgwvQtw9tPRGz0iXSjvKPWGtcQOwRXRUq9EEeYRU4SHvWLVAU+cP8myLSCZMP53fUA1G1u/GAGuTIj2ZDPZ+5OVXTk1MxzPLJBCP11xQK6W/cUqZ3WqKWuVJXPP6ktrNN+fYsnR1aLS25B50t0fA/PY8H8FC3HvO07jOkIib9MyP+Rx4mKdvqLQDyL/rVisWavdYh0jgH0iFmhqQoqE//1i8akMSAxpcc1o73/lMKvAScgkQh5MN2fL+CBsW627/Gfg7Dbn6D1YfVoSVVfJSCuvZZYM2uplwGv0kbOtD2VM3XA+pCKZ0TpcrusSabWNUUC2g+ZfQtEVWeV65k/3VhPlxe1ZfYipHDCZAvjT2Oiwk2zXBzt2uppyvHyvzPs4GaxtoHRJgA47RGp2FCYvHLLN+fjNnI6vBJpaf1rDWPTR7EUqHV57vW+gIgg2JY0ihYLn5xbmRBex3OLH1SdDhsJBw3WvCUqeXK1OO2pfCRYVm/KPgVql7xAfT38/KSCwWhLtf4Z8ePzZxEt9F9uqd8mJ29gAW/CbMMX4wAmiXBG47ZOk1nRMbSnGnZ1DjLeZ5ZYm8eADSz4po0DWGtxJgRhzF6N5JLuodubDJxFJKqER69oHcA2M3ymZ9iOaMJEtplvHSC9zRxHJ+A3XYxhhLkLCkewQw/+JHq/2BS6JO+GWlxc68W58YIpsftB19wF0QWRB1WGSpD2Z+nOx1oEjBNdaCSwimrfbocAiDf3GDk+9UThF+i2HPkWzVpXmwNz7Dvo3sjbVa+1k85Gg1XrWeM6eUr7I2a1kRNOj3rQsTJfzICt/fvyYdOUy+dcIES3pw5fA6J8b7Ar8c1QZ/+0+SADMDdxYhaNjaQTiukd8/idG9sEbuq2oTtyNlmCTPY2l63eD7dxM+NNRVEEMbz50uMFDIU8CYZ0m6yD/2q/eTTRx3ifEcGhohextH43XcC+gorrlULH+EfNXzrsbwjcZL2pZhIoCBcCgNBn3R7y9lNe9oiPLAhwdNtoCnK1BwWVnUuarubdhcUQD1Kz2B5m6FCZc5HgWFbwqXWRSerGPnmIYWvw0d97gmBGrjGIMpg== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22857225-4c95-4ee2-df49-08d9b657f0f6 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:07.3235 (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: CTOqriN6uDgYFxdEDdbg0KfdEX/LTgcM9gIiub/S9EbMp6Z7aaN7Er2mWR9mpzGOBVb1bVYOdTELLv4Ip7yLPwPet3fj8PSVS6TjrgiUm8k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5283 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add index to flow_action_entry structure and delete index from police and gate child structure. We make this change to offload tc action for driver to identify a tc action. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman --- drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++-- drivers/net/dsa/sja1105/sja1105_flower.c | 2 +- drivers/net/ethernet/freescale/enetc/enetc_qos.c | 6 +++--- drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 2 +- drivers/net/ethernet/mscc/ocelot_flower.c | 2 +- include/net/flow_offload.h | 3 +-- include/net/tc_act/tc_gate.h | 5 ----- net/sched/cls_api.c | 3 +-- 8 files changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 9add86eda7e3..2dc29423d850 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1746,7 +1746,7 @@ static void vsc9959_psfp_sfi_table_del(struct ocelot *ocelot, u32 index) static void vsc9959_psfp_parse_gate(const struct flow_action_entry *entry, struct felix_stream_gate *sgi) { - sgi->index = entry->gate.index; + sgi->index = entry->index; sgi->ipv_valid = (entry->gate.prio < 0) ? 0 : 1; sgi->init_ipv = (sgi->ipv_valid) ? entry->gate.prio : 0; sgi->basetime = entry->gate.basetime; @@ -1948,7 +1948,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port, kfree(sgi); break; case FLOW_ACTION_POLICE: - index = a->police.index + VSC9959_PSFP_POLICER_BASE; + index = a->index + VSC9959_PSFP_POLICER_BASE; if (index > VSC9959_PSFP_POLICER_MAX) { ret = -EINVAL; goto err; diff --git a/drivers/net/dsa/sja1105/sja1105_flower.c b/drivers/net/dsa/sja1105/sja1105_flower.c index 72b9b39b0989..ff0b48d48576 100644 --- a/drivers/net/dsa/sja1105/sja1105_flower.c +++ b/drivers/net/dsa/sja1105/sja1105_flower.c @@ -379,7 +379,7 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port, vl_rule = true; rc = sja1105_vl_gate(priv, port, extack, cookie, - &key, act->gate.index, + &key, act->index, act->gate.prio, act->gate.basetime, act->gate.cycletime, diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index 0536d2c76fbc..04a81bba14b2 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -1182,7 +1182,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, } /* parsing gate action */ - if (entryg->gate.index >= priv->psfp_cap.max_psfp_gate) { + if (entryg->index >= priv->psfp_cap.max_psfp_gate) { NL_SET_ERR_MSG_MOD(extack, "No Stream Gate resource!"); err = -ENOSPC; goto free_filter; @@ -1202,7 +1202,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, } refcount_set(&sgi->refcount, 1); - sgi->index = entryg->gate.index; + sgi->index = entryg->index; sgi->init_ipv = entryg->gate.prio; sgi->basetime = entryg->gate.basetime; sgi->cycletime = entryg->gate.cycletime; @@ -1244,7 +1244,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, refcount_set(&fmi->refcount, 1); fmi->cir = entryp->police.rate_bytes_ps; fmi->cbs = entryp->police.burst; - fmi->index = entryp->police.index; + fmi->index = entryp->index; filter->flags |= ENETC_PSFP_FLAGS_FMI; filter->fmi_index = fmi->index; sfi->meter_id = fmi->index; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c index be3791ca6069..06c006a8b9b4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c @@ -203,7 +203,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, */ burst = roundup_pow_of_two(act->police.burst); err = mlxsw_sp_acl_rulei_act_police(mlxsw_sp, rulei, - act->police.index, + act->index, act->police.rate_bytes_ps, burst, extack); if (err) diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c index 58fce173f95b..5e0d379a7261 100644 --- a/drivers/net/ethernet/mscc/ocelot_flower.c +++ b/drivers/net/ethernet/mscc/ocelot_flower.c @@ -303,7 +303,7 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port, } filter->action.police_ena = true; - pol_ix = a->police.index + ocelot->vcap_pol.base; + pol_ix = a->index + ocelot->vcap_pol.base; pol_max = ocelot->vcap_pol.max; if (ocelot->vcap_pol.max2 && pol_ix > pol_max) { diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 3961461d9c8b..f6970213497a 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -197,6 +197,7 @@ void flow_action_cookie_destroy(struct flow_action_cookie *cookie); struct flow_action_entry { enum flow_action_id id; + u32 index; enum flow_action_hw_stats hw_stats; action_destr destructor; void *destructor_priv; @@ -232,7 +233,6 @@ struct flow_action_entry { bool truncate; } sample; struct { /* FLOW_ACTION_POLICE */ - u32 index; u32 burst; u64 rate_bytes_ps; u64 burst_pkt; @@ -267,7 +267,6 @@ struct flow_action_entry { u8 ttl; } mpls_mangle; struct { - u32 index; s32 prio; u64 basetime; u64 cycletime; diff --git a/include/net/tc_act/tc_gate.h b/include/net/tc_act/tc_gate.h index 8bc6be81a7ad..c8fa11ebb397 100644 --- a/include/net/tc_act/tc_gate.h +++ b/include/net/tc_act/tc_gate.h @@ -60,11 +60,6 @@ static inline bool is_tcf_gate(const struct tc_action *a) return false; } -static inline u32 tcf_gate_index(const struct tc_action *a) -{ - return a->tcfa_index; -} - static inline s32 tcf_gate_prio(const struct tc_action *a) { s32 tcfg_prio; diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 2ef8f5a6205a..d9d6ff0bf361 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3568,6 +3568,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, goto err_out_locked; entry->hw_stats = tc_act_hw_stats(act->hw_stats); + entry->index = act->tcfa_index; if (is_tcf_gact_ok(act)) { entry->id = FLOW_ACTION_ACCEPT; @@ -3659,7 +3660,6 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->police.rate_pkt_ps = tcf_police_rate_pkt_ps(act); entry->police.mtu = tcf_police_tcfp_mtu(act); - entry->police.index = act->tcfa_index; } else if (is_tcf_ct(act)) { entry->id = FLOW_ACTION_CT; entry->ct.action = tcf_ct_action(act); @@ -3697,7 +3697,6 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->priority = tcf_skbedit_priority(act); } else if (is_tcf_gate(act)) { entry->id = FLOW_ACTION_GATE; - entry->gate.index = tcf_gate_index(act); entry->gate.prio = tcf_gate_prio(act); entry->gate.basetime = tcf_gate_basetime(act); entry->gate.cycletime = tcf_gate_cycletime(act); From patchwork Fri Dec 3 12:24:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655039 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3226AC433EF for ; Fri, 3 Dec 2021 12:25:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244527AbhLCM2g (ORCPT ); Fri, 3 Dec 2021 07:28:36 -0500 Received: from mail-co1nam11on2092.outbound.protection.outlook.com ([40.107.220.92]:63725 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244247AbhLCM2e (ORCPT ); Fri, 3 Dec 2021 07:28:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Znjb+21G0QS6FkEAnwlnrcp6LO5TYbTkxLd2K/dJdyvYHdXruE3K0tWIpNYRuXZSbH50geYQ7mDP/3fkcG4hNrE31/tTieuV4M5prluo8eQlXrCceH2PR1dSYJbKJw/KIoWfIxZaedgpAqmzq8x0uJlDSxDkPDcUZOLx3ViaPzpHI7kcjay8iCXYE24xMh186WMTvZAZrFsuJug9cLwii/8ELOCvHYkkxqoOKWzFVNND5aBr/YYGHCd/P2JOb9EK9O4f+JhickccZpGqUmGXI7iQEMnGGbfmJLdja2Ztg1n3q21h145/W2/P08wYtP+kKDwHqr7UHw9XqhdsqYndFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5qGuUV7Fn2LtfbftPKlaN1D3mNogN4NqNv0+Wsw7CRI=; b=BaROHjc4ty07K0sOGY6AXYhs7Yj+PDTs5zsidxkYMjupqwTIvZJEFv2fp291/Ta1/MmgaW1MsS0W0Xqs7NOk7/EDYPsBm3WWPnc5ii1kniOSwn+rrcnz5vbYhA2YgIgEcxo6cAKp9E/dWB5hKTceHd9SW6BluKKOy/X/awlVRSqUNB3fKueSNgqBJuD8AVAgWOjULzZaWrlKH87236w55qQMDCLFD3HCk1Bv/N7cfwG3bIWBNFitAT+jCpBIRCD2abm+ydLNJmhhNBpAdRTEH3AvaNksivYq3O8aKptaYFXgBWw4XOhvVv7qHJL79cFVsuWJhChitPpaNVxjDNYJnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5qGuUV7Fn2LtfbftPKlaN1D3mNogN4NqNv0+Wsw7CRI=; b=Wp3K/AsagAhd1Q+Czw0vPNX+6zmMM6el/J+TvFxNphkRS/50YWnzfqg/vKcsEnTeJjJbTJl6z0GpVl3AeZXqGgt4X5ijdNDvWvIOghsRmWD6s1Um5x/yPN/IqW8u3gMsPlXqv4KYE5NOK4GVE2Jw1NbophLZJ4Q7rTjOIFIjxiA= 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 PH0PR13MB5283.namprd13.prod.outlook.com (2603:10b6:510:f4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Fri, 3 Dec 2021 12:25:10 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25:10 +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, Simon Horman Subject: [PATCH v5 net-next 04/12] flow_offload: return EOPNOTSUPP for the unsupported mpls action type Date: Fri, 3 Dec 2021 13:24:36 +0100 Message-Id: <20211203122444.11756-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 59614945-9656-49d2-6977-08d9b657f28d X-MS-TrafficTypeDiagnostic: PH0PR13MB5283:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IHg+eaHG5FaK9w6vdHOg+xpSAiQXSAIvvRC0NVogeZDolHbyx0AnEE0Gp3ypYhQfGWUTlMAKJcjsQ1JefaclW0ToIXDZOXYYnIsb+h1keOcIGRqQ0LVKVWfT2pBfqdGXdN2mexQ0ENfvgBOFend+PCRyJYMkpMWal2ft9v+d5GFUkI4E8Kh6ZaM62TeenixuR/rMb3f9p5qzvGX0Yl0SAtHVePrpwXndMTTPC2ScnZPgIMAykbsw8COGEIEibde2vN1t7v8ZRkQ8M4Xv+HM+ygwC0A0hleLkc574V9dL3uMj7o5GpMjvoHYmQiGbup+r1qHzvCEv0ju/AD4VbPLptNZnmIzcbTJMmlz3vvRwSKwOLhhjF/7p+3O8gfMrfsBNvB8mpQgrWqxG+VUOaGsxbz+Y3UdpJkDTmHk+oGXEKdSg0G7anuoEBZyCCaR9MZKhyu4fDL3uL1BlNA7PuNqpOYDkcXMo6cwEqr2dSvA3RzuTvXUFpjmkTqQN1RC2sFRfGyfoqwVsz9g0YbF+L0YYYH5kiLKfKnCbiixdY2cfWzLs7Xq0hu2I/z2fCcSo5Ug1vIkfuqx/jJY1hR9M4xFCFcNlAfq9nQIi11wSpR98TWcYtpSbN03UShC+xlwjqnnnP3WW17XrVJt0yJTyBiIoIw== 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:(366004)(39830400003)(346002)(376002)(136003)(396003)(86362001)(52116002)(36756003)(44832011)(4744005)(508600001)(186003)(83380400001)(6666004)(6486002)(66946007)(6916009)(5660300002)(316002)(2616005)(66476007)(8676002)(6506007)(8936002)(107886003)(2906002)(6512007)(54906003)(38100700002)(1076003)(4326008)(66556008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AurayV1lW0cknAl3zeM+Jy6eKSVFX0mZW2En3gXaFEojE4E87PtZXpXy0FgLfqs+z877d8eMxMKHca+OARgaUiTeLxSSGHWhE5og5S9VFI5pr1tdJiwOEahYBHF33lNNimGwlmQrIEk6XXeCkNXsiX+KiNQEM+783OksqVGv0mE/zOiCbsaiImARTUdg7E6Xo1KFKbSmGO0PdrKcYLNsCPcHzFDlpHuDYsPgNe1ANDZVgyMuldrOgdhlsqpdGZA2FsrUvpabAHkHot92G+OB2RJzjtE49k4iNTg/IAAUyGtfeLxxqk89Wa8oPWl1yaY73C9r75Q+u3WXGo2Kiy1B8wTMzopI1eJnKm/81i78VYkR1NK6eakLEkd8IjdStUwD2tBjIXtPFqxft2dPcIYXt54kL826kvkiSqNgIxE30arTEvSaxzOly6I0KARX2jiBq8/aDHc6aX45qsqX5SxVBiWk85shp6s1rBJ0CiqNubKuCfCq+gb3e1Sry7e6PTFTGBP9H1T0fTp5I8pRQtOBlnJLM9qzilg+pRIOLr2Vd3yOxxkt34mp7oep0j4orwG6V2rxxxusp3YdC1zEcD2rPnIXsaWcDaCqlQHm9oxcIcwJ/sVSiGiR/RKQk0jiVY+YbjieRe2wPG34llucKBtk60Ay3Nf3dkPbks1ZnKnqWn0CTjJ4/687r89IpsKRKcYUwgI1MbYmCvHYkjyd50kJfIO568vEwVaJlBlsYbnIpaEvhffjNSoSTxs+uU5+dfG/ZkyQ4SvCuAGjUUo43Z9qGbERlrCVnjdkY9BLMXGkMXiuazfNmBZZXtGB83a5i6OFHKmlt6MVNintqtHWqvufzy9uHdvh7ZW/a8yZALMnDvGHE/u1kiyMcbMxBRuzVdiwvksExTRxMNR1Dbcd/oxizfJVO8UdIFrWTMqJvBRTND52gWjnhFp0bOFWcWwPKE49T8epZlgRPCmKFucJc4Xbvr+X6pemP6nGqbc1vmccgw3WW4oDklj5Ml5G/KU/02XUgmyPrqjAvY18MDetT57i6vzNKNr7i2zyQA+w6z8PX2SlZGvybkxVSnIdm4XRgOaw8l/MXOW2NL5hVbXll1h9o2eu4x23h8y1Bz1vD0ZTpvbWzc07pGslAgHGVyNY7qvMPHImD9Fwrw6Yq7X/w6o35tx8w4XQHyd6QMKzRCJomu1fEV/+TIwO50oCt26L123sDtozRPOMWAsWMFkscqGNa03HjuJho+2MFdVagrCyxiaMREtGd8x4sRp5myqu93Y7tD8BBC8EgAmOOLpQ4mY39QG4WuEJuY9LDtw8ooGHlFtb9GWGqeYpiOSc/ejV6jo0wRNXeH4vA8BHGGF2we82OyW5U+WzYV7CCZk/E2TAmgh47L13W5SXgyCcEk2NrgPBP73iKSE1lutbxx57EuDU5UUEqykw2ANcX6OJyaus/8inepn+pa8Z6Mw7V5a5jcdfQeU7uLLmZNlmTAGmsT2ogMWtR5h79puwKuV6v6QNIL6XQFtRG1lhm7uTB+Kb7koi3BKp59irOzzUHOsvA1FNGPcw+sPucx1zQjfyiqSnKWEQHf4BvHr7TWYWs12Gq4pwe3Cdj0ftlO9p6ly+7P8ZzTUFf55IcuFXjOKfZ/bIQ8+9xHuXxpHOyV/YLv86dLWu8GvcPUmrj2mlhe/q4H2ni1Jipv7wxU6XqwY3nIsANDlsZXtvydpJH5RelbeqMRieOvnhplCd7f1Tg0RCkGphZg== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59614945-9656-49d2-6977-08d9b657f28d X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:10.0127 (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: 2ZtucRQa5I7DSCPiVnuvzgvPsyIqpIbuflQ0ijjUq9b6x0AaHlked3LM3f4LzKN/S9DP1qsAKsf3eTiReMnGbpoWOXMwT050C6KyAhAIaBM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5283 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng We need to return EOPNOTSUPP for the unsupported mpls action type when setup the flow action. In the original implement, we will return 0 for the unsupported mpls action type, actually we do not setup it and the following actions to the flow action entry. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman --- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index d9d6ff0bf361..7a680cae0bae 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3687,6 +3687,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->mpls_mangle.ttl = tcf_mpls_ttl(act); break; default: + err = -EOPNOTSUPP; goto err_out_locked; } } else if (is_tcf_skbedit_ptype(act)) { From patchwork Fri Dec 3 12:24:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655041 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C4AFC433F5 for ; Fri, 3 Dec 2021 12:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244571AbhLCM2j (ORCPT ); Fri, 3 Dec 2021 07:28:39 -0500 Received: from mail-co1nam11on2101.outbound.protection.outlook.com ([40.107.220.101]:17504 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244531AbhLCM2h (ORCPT ); Fri, 3 Dec 2021 07:28:37 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cV8vawNNU08qk01btz7psprwjADbf4NyQu7+zVl5l8UV4wxwgFJHVXupZYDJa+xAHQwiFbjfEi6WR97rU5uXnilFVo+VId7gPgJLvLWSgm1ZNIWXCLPrN6zWQCMcaCvGgRefi2GQTP7Xt2UT/M0Sk6XKdOYj9jnFJ/vIB+kHaG/JW4LF6PO/jmrnCTqdYD3wXCCSayzbvnX286HgTe5todt09OL2/WwpfxSm6rxR93F7mwVhl8h9AUNmytQmb1xc4pdsuaIKiLYUY5HU+PXgG05rGvsfR0cPRQwliAHLUg41MLP9aEUJ0tWmUiLizdTNRv9WCfcQQXYm+TtCUSCr0Q== 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=937RczJ/0qLoChymm0oYEEFrZkYaHmKo/ttsiiwj3Mg=; b=YW9msriTNQY3RNxKNMiG2ShRe9b0XhZumEEaLaE7iEhtxIiyRe1DR4Eb+mwycm+QxoGepwH+ke2WpKzBEIBP9bXuTzdJeTgq32TL42Y8znMRjY/R2ftIUaqI88LllUpjtftW2FG86+SUfPp1E0NolIFAlGXYFG5qUzuoGANuq3RDDowWspfbEzBp5mXA1se6HKdqIAE7o0Gouj/SZAmF80r/UUo7jLvgbrB1ni3bEdzt/lfB8lK7TPhQ1BEj7OhrjSJ1K9rhjCofWW0pyg6W4N0kyIx37uYoxjVCFZ6t+d86f1fv3HftRr2BNdKILvSCgylZAuRQ4T2UgLkoO8Sg1A== 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=937RczJ/0qLoChymm0oYEEFrZkYaHmKo/ttsiiwj3Mg=; b=EuH94Glj11nLqO6xYRG/V2H+eXxMMN6fN1lG5qMQspy1o87Edkx/KHuB7WQMk3LybRmXgg6Mxg0fyaXbqFE3zuppeQVeijgg/3PmWSTkkq7pvH3NooyjpXbyQgXE+RIzbXw4LSLNb9aAzcppXH4NX2ooLrSGbniBu+InoeYClTE= 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 PH0PR13MB5283.namprd13.prod.outlook.com (2603:10b6:510:f4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Fri, 3 Dec 2021 12:25:12 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25:12 +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, Simon Horman Subject: [PATCH v5 net-next 05/12] flow_offload: add ops to tc_action_ops for flow action setup Date: Fri, 3 Dec 2021 13:24:37 +0100 Message-Id: <20211203122444.11756-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3f4b43da-9afd-48db-6b6e-08d9b657f41d X-MS-TrafficTypeDiagnostic: PH0PR13MB5283:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:586; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /ZB9dY8/cILBla+GNudi8JEn06HJQySfFb6209VIQ4mVrNP2OYkCatLUMEeqosYF0MSgxyCH8unCwalcQCosBc2eZeyMrjQE0d1JaamuoEZy96XV8qY9Kiudk+oh9z9nvCUiwaKIQ0xBnC9iMrmbf7a+3LL6hk8J3cnErhGDEPrDzra8Edlt934NLPcM2OhRBHRKTzQgXoDozz9ITAE+4wFFfl6s00MxHGL8UxqbE+ZuedD0oNFYh7QCSC9bwJbW+vxKMq2tGo+U0+EtFGKqiLPtM7gVhiKVK2USgZksowcOjHpsm9joUkvFFD7BZIlAT1Du/cxlUHNgbmJnhHf3U4c5PUPKeTrrjzj535QbPtcLYhoO5XnN7JyLZLHbTpqsgp4qi646/clNsku12se8nabzxXkOl8joRXO8QHINe1siHs0WF7N+MH82HpkzUB8Z2lZ/pAdXxcHBdNse/twXMwNYkjUpZMQw2/x5gTuWYxq/L5CYJKPwwx8BDqnTxL380WBQr4jOJInPQ2KXEzANKBjUjSESRV3hQXh2lIvSd3ZgB8IMRYhThcuM3thsj/gcyP1/j2mUYwbCzXNnHZF7tEeKAr5R0IdcDL8mFFEum/e89iWdfYMNWjGqYSHAotCWhbtbLq8qTyNlPsR9Ls7PZg== 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:(366004)(39830400003)(346002)(376002)(136003)(396003)(86362001)(52116002)(36756003)(44832011)(508600001)(186003)(83380400001)(6666004)(6486002)(66946007)(6916009)(5660300002)(316002)(2616005)(66476007)(8676002)(6506007)(8936002)(107886003)(30864003)(2906002)(6512007)(54906003)(38100700002)(1076003)(4326008)(66556008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dB2+8bt3hdVhQj0ci5CMtdJ4NesEboWngoFvCz/w3/KjEmQ3k6JuY+XmdedqnR3n00jGv9tdx/b4jXLoIvrFObUD1kWytIyNqruWgtdO40Q9mMiqcyw0JxIqDzv3/SrADOF8FXbB4gGM1H0AB6G8E9LT6U0ek5QQSIl5qkyNmoVMjugHxxSDz5KiSPmHWTaOG5EA3d/wFfBv8OwcY0y1Ou/nJr/KM2R2PRc+XA+31UyYJfDDpDiZP8CfBMftmIE6qNQkWmP38/I9Vfqpaq+2XVN8U38/URXCEZZQDs7sVYGJQoCmRCcWj/nJ/l9kHzGr9GRGncLknaPd2fhdjdhZGBRWDJXGTLl60E6SGU5Z/cj7vPYKZyobul6Nr8vCW4Dnke3Di/YXENQp+EU6nWgsLaBdCK9Gn3A4/QF+zejnuLtbwjyBi+hU1PBpVDZgL1zky+grq+urCU+hgK2wbFgGDwzEY/i952grXh63Brske27ZuWAGHzSS1q5cYekoEIhilJYZjQm4dr4lCqxXnwfJ8dI//D6kCR/1pAz33TMgsVL385gI7cPogYztLJg6jbx3f1VyOvGk+ZI0LG5zN6BSWJyr7sZHVQhhGm2tVTSJcErHzCmMWaO35zBt73VtsUBtUoX/ImXu74CsvTIdmgQwTqZDuaYP3ob9LdjyhKqo+fdigAVZYk1spoJGqY0i89VOdRoF845ohAXNhR/Mn3gA7hQJAc39CFzKCWV/SnJGKA2HszsVBGR3oNfnhD4Y3Kq8iR+zcvYV0exAPSHFK150uUa1zQRh3xcBU1+DqVrqdI3fQPGR5Mq2QrYbxPWd3PpBaAnrJkG2ri7QfSxL4EI75oBMYotm0/4IWXtgGG5rtatWedjSE+9rZis23/yjxkswlVoSTkx31FLIqQ6JTg7I9oWMaGjwHSeXbAPxtuYyrjWKTFDZFERSkGJhYjsL7WHbj6sjGBEWv8hMpkpMSO3s+cmLWiL82XF2Gj5LKGvm1EJxlOKlzQHv5oq8gUftNcTQvCVGtK0+iEU8FUizh5XFAamdD3AvoJYAwqSsJ67VZrwZeA6SVzxsdDn6Ub5fuOI9qWaim/jPgM13zb4mKslGmP3FjTB+A3bKsN1ytZOQ8+NvPwsskrHuVU/Zmy6kPecfuEDMB06rxqV23NZQJrvvKkFKRodtXZh0QIgMDpP1FzEc9Q9bGU6S2MpRCwPhQzWzN61mq7USGeQMKHidK0UJxgAC/bJzWZJQFhBM1wgRctomBZPFtqO4yLV2mJ0V8K6QH6nnFshpTAHEMm5zrDI2kNjxfdrCcYKkbMZAtw9IV75CzNTY0tq66k39/5XRgL0mhnuLbLzjZdnysjMcSLyxTiZte0skD85uXUn6XKWrpu0opuEbqnYLlSnnx0Q2v/q1Io4cNe3g3lPrxWyUe7JxjGDamzWeEo4bv+oVEie63G+IkGFjvEQe9tLx2juk+BuRmA519M5SbB5tVfyvP/CnaElE9ggRwkQfRTd1UQwI3IC/JPXhxRiiiBnAo7ConPwAEVvqYJC8C4AXnkT8YKYr0LL2exzufa9jc/KvR3Ep6JmCOmx8OGoXX6B9pxeAHihGhNY2FL7gy0A1C1KbPx0/w0kwxOCQozHNIaICPgtbkjsNtRJHX4/bv6xUavkyhUxpfm9agZ1NgJ01c/x5lKwAU6OLJ/jYDKjc6y1IJ/1svQ7wjn80RWbc6JMO2wLgr28Cb7HUiewjFVzfU7WpyBpg/W/f5jmaP8wo96F70IEvQrg= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f4b43da-9afd-48db-6b6e-08d9b657f41d X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:12.6163 (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: ibd7392R8uMcQ/bfdp7YYvRLKtBU0k5EPA0B1Dan/F0kUt/J1eJ+P9RQtSpoZxxISuy8Lfk8pT0N7y0FvidsGubWGy+Jm/Et1DhyNX2ab5A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5283 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add a new ops to tc_action_ops for flow action setup. Refactor function tc_setup_flow_action to use this new ops. We make this change to facilitate to add standalone action module. We will also use this ops to offload action independent of filter in following patch. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman --- include/net/act_api.h | 12 ++ net/sched/act_csum.c | 17 +++ net/sched/act_ct.c | 19 ++++ net/sched/act_gact.c | 27 +++++ net/sched/act_gate.c | 47 ++++++++ net/sched/act_mirred.c | 39 +++++++ net/sched/act_mpls.c | 38 +++++++ net/sched/act_pedit.c | 34 ++++++ net/sched/act_police.c | 23 ++++ net/sched/act_sample.c | 28 +++++ net/sched/act_skbedit.c | 27 +++++ net/sched/act_tunnel_key.c | 47 ++++++++ net/sched/act_vlan.c | 34 ++++++ net/sched/cls_api.c | 222 +++---------------------------------- 14 files changed, 406 insertions(+), 208 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index b5b624c7e488..73f15c4ff928 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -88,6 +88,16 @@ static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm) dtm->expires = jiffies_to_clock_t(stm->expires); } +static inline enum flow_action_hw_stats tc_act_hw_stats(u8 hw_stats) +{ + if (WARN_ON_ONCE(hw_stats > TCA_ACT_HW_STATS_ANY)) + return FLOW_ACTION_HW_STATS_DONT_CARE; + else if (!hw_stats) + return FLOW_ACTION_HW_STATS_DISABLED; + + return hw_stats; +} + #ifdef CONFIG_NET_CLS_ACT #define ACT_P_CREATED 1 @@ -121,6 +131,8 @@ struct tc_action_ops { struct psample_group * (*get_psample_group)(const struct tc_action *a, tc_action_priv_destructor *destructor); + int (*flow_act_setup)(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind); }; struct tc_action_net { diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index a15ec95e69c3..b55d687e3adc 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c @@ -695,6 +695,22 @@ static size_t tcf_csum_get_fill_size(const struct tc_action *act) return nla_total_size(sizeof(struct tc_csum)); } +static int tcf_csum_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + entry->id = FLOW_ACTION_CSUM; + entry->csum_flags = tcf_csum_update_flags(act); + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_csum_ops = { .kind = "csum", .id = TCA_ID_CSUM, @@ -706,6 +722,7 @@ static struct tc_action_ops act_csum_ops = { .walk = tcf_csum_walker, .lookup = tcf_csum_search, .get_fill_size = tcf_csum_get_fill_size, + .flow_act_setup = tcf_csum_flow_act_setup, .size = sizeof(struct tcf_csum), }; diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index ab1810f2e660..9edfed3b0f4b 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1493,6 +1493,24 @@ static void tcf_stats_update(struct tc_action *a, u64 bytes, u64 packets, c->tcf_tm.lastuse = max_t(u64, c->tcf_tm.lastuse, lastuse); } +static int tcf_ct_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + entry->id = FLOW_ACTION_CT; + entry->ct.action = tcf_ct_action(act); + entry->ct.zone = tcf_ct_zone(act); + entry->ct.flow_table = tcf_ct_ft(act); + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_ct_ops = { .kind = "ct", .id = TCA_ID_CT, @@ -1504,6 +1522,7 @@ static struct tc_action_ops act_ct_ops = { .walk = tcf_ct_walker, .lookup = tcf_ct_search, .stats_update = tcf_stats_update, + .flow_act_setup = tcf_ct_flow_act_setup, .size = sizeof(struct tcf_ct), }; diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index d8dce173df37..2342aa5d8284 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c @@ -252,6 +252,32 @@ static size_t tcf_gact_get_fill_size(const struct tc_action *act) return sz; } +static int tcf_gact_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + if (is_tcf_gact_ok(act)) { + entry->id = FLOW_ACTION_ACCEPT; + } else if (is_tcf_gact_shot(act)) { + entry->id = FLOW_ACTION_DROP; + } else if (is_tcf_gact_trap(act)) { + entry->id = FLOW_ACTION_TRAP; + } else if (is_tcf_gact_goto_chain(act)) { + entry->id = FLOW_ACTION_GOTO; + entry->chain_index = tcf_gact_goto_chain_index(act); + } else { + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_gact_ops = { .kind = "gact", .id = TCA_ID_GACT, @@ -263,6 +289,7 @@ static struct tc_action_ops act_gact_ops = { .walk = tcf_gact_walker, .lookup = tcf_gact_search, .get_fill_size = tcf_gact_get_fill_size, + .flow_act_setup = tcf_gact_flow_act_setup, .size = sizeof(struct tcf_gact), }; diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c index ac985c53ebaf..cbdcbe4376bb 100644 --- a/net/sched/act_gate.c +++ b/net/sched/act_gate.c @@ -597,6 +597,52 @@ static size_t tcf_gate_get_fill_size(const struct tc_action *act) return nla_total_size(sizeof(struct tc_gate)); } +static void tcf_gate_entry_destructor(void *priv) +{ + struct action_gate_entry *oe = priv; + + kfree(oe); +} + +static int tcf_gate_get_entries(struct flow_action_entry *entry, + const struct tc_action *act) +{ + entry->gate.entries = tcf_gate_get_list(act); + + if (!entry->gate.entries) + return -EINVAL; + + entry->destructor = tcf_gate_entry_destructor; + entry->destructor_priv = entry->gate.entries; + + return 0; +} + +static int tcf_gate_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + int err; + + if (bind) { + struct flow_action_entry *entry = entry_data; + + entry->id = FLOW_ACTION_GATE; + entry->gate.prio = tcf_gate_prio(act); + entry->gate.basetime = tcf_gate_basetime(act); + entry->gate.cycletime = tcf_gate_cycletime(act); + entry->gate.cycletimeext = tcf_gate_cycletimeext(act); + entry->gate.num_entries = tcf_gate_num_entries(act); + err = tcf_gate_get_entries(entry, act); + if (err) + return err; + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_gate_ops = { .kind = "gate", .id = TCA_ID_GATE, @@ -609,6 +655,7 @@ static struct tc_action_ops act_gate_ops = { .stats_update = tcf_gate_stats_update, .get_fill_size = tcf_gate_get_fill_size, .lookup = tcf_gate_search, + .flow_act_setup = tcf_gate_flow_act_setup, .size = sizeof(struct tcf_gate), }; diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index efc963ab995a..8c953b2dc2d5 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -448,6 +448,44 @@ static size_t tcf_mirred_get_fill_size(const struct tc_action *act) return nla_total_size(sizeof(struct tc_mirred)); } +static void tcf_flow_mirred_get_dev(struct flow_action_entry *entry, + const struct tc_action *act) +{ + entry->dev = act->ops->get_dev(act, &entry->destructor); + if (!entry->dev) + return; + entry->destructor_priv = entry->dev; +} + +static int tcf_mirred_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + if (is_tcf_mirred_egress_redirect(act)) { + entry->id = FLOW_ACTION_REDIRECT; + tcf_flow_mirred_get_dev(entry, act); + } else if (is_tcf_mirred_egress_mirror(act)) { + entry->id = FLOW_ACTION_MIRRED; + tcf_flow_mirred_get_dev(entry, act); + } else if (is_tcf_mirred_ingress_redirect(act)) { + entry->id = FLOW_ACTION_REDIRECT_INGRESS; + tcf_flow_mirred_get_dev(entry, act); + } else if (is_tcf_mirred_ingress_mirror(act)) { + entry->id = FLOW_ACTION_MIRRED_INGRESS; + tcf_flow_mirred_get_dev(entry, act); + } else { + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_mirred_ops = { .kind = "mirred", .id = TCA_ID_MIRRED, @@ -460,6 +498,7 @@ static struct tc_action_ops act_mirred_ops = { .walk = tcf_mirred_walker, .lookup = tcf_mirred_search, .get_fill_size = tcf_mirred_get_fill_size, + .flow_act_setup = tcf_mirred_flow_act_setup, .size = sizeof(struct tcf_mirred), .get_dev = tcf_mirred_get_dev, }; diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index 2b30dc562743..69bc9e10ee3e 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -384,6 +384,43 @@ static int tcf_mpls_search(struct net *net, struct tc_action **a, u32 index) return tcf_idr_search(tn, a, index); } +static int tcf_mpls_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + switch (tcf_mpls_action(act)) { + case TCA_MPLS_ACT_PUSH: + entry->id = FLOW_ACTION_MPLS_PUSH; + entry->mpls_push.proto = tcf_mpls_proto(act); + entry->mpls_push.label = tcf_mpls_label(act); + entry->mpls_push.tc = tcf_mpls_tc(act); + entry->mpls_push.bos = tcf_mpls_bos(act); + entry->mpls_push.ttl = tcf_mpls_ttl(act); + break; + case TCA_MPLS_ACT_POP: + entry->id = FLOW_ACTION_MPLS_POP; + entry->mpls_pop.proto = tcf_mpls_proto(act); + break; + case TCA_MPLS_ACT_MODIFY: + entry->id = FLOW_ACTION_MPLS_MANGLE; + entry->mpls_mangle.label = tcf_mpls_label(act); + entry->mpls_mangle.tc = tcf_mpls_tc(act); + entry->mpls_mangle.bos = tcf_mpls_bos(act); + entry->mpls_mangle.ttl = tcf_mpls_ttl(act); + break; + default: + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_mpls_ops = { .kind = "mpls", .id = TCA_ID_MPLS, @@ -394,6 +431,7 @@ static struct tc_action_ops act_mpls_ops = { .cleanup = tcf_mpls_cleanup, .walk = tcf_mpls_walker, .lookup = tcf_mpls_search, + .flow_act_setup = tcf_mpls_flow_act_setup, .size = sizeof(struct tcf_mpls), }; diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index cd3b8aad3192..ddd93909636b 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -487,6 +487,39 @@ static int tcf_pedit_search(struct net *net, struct tc_action **a, u32 index) return tcf_idr_search(tn, a, index); } +static int tcf_pedit_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + int k; + + for (k = 0; k < tcf_pedit_nkeys(act); k++) { + switch (tcf_pedit_cmd(act, k)) { + case TCA_PEDIT_KEY_EX_CMD_SET: + entry->id = FLOW_ACTION_MANGLE; + break; + case TCA_PEDIT_KEY_EX_CMD_ADD: + entry->id = FLOW_ACTION_ADD; + break; + default: + return -EOPNOTSUPP; + } + entry->mangle.htype = tcf_pedit_htype(act, k); + entry->mangle.mask = tcf_pedit_mask(act, k); + entry->mangle.val = tcf_pedit_val(act, k); + entry->mangle.offset = tcf_pedit_offset(act, k); + entry->hw_stats = tc_act_hw_stats(act->hw_stats); + entry++; + } + *index_inc = k; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_pedit_ops = { .kind = "pedit", .id = TCA_ID_PEDIT, @@ -498,6 +531,7 @@ static struct tc_action_ops act_pedit_ops = { .init = tcf_pedit_init, .walk = tcf_pedit_walker, .lookup = tcf_pedit_search, + .flow_act_setup = tcf_pedit_flow_act_setup, .size = sizeof(struct tcf_pedit), }; diff --git a/net/sched/act_police.c b/net/sched/act_police.c index c13a6245dfba..f48e9765b70e 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -405,6 +405,28 @@ static int tcf_police_search(struct net *net, struct tc_action **a, u32 index) return tcf_idr_search(tn, a, index); } +static int tcf_police_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + entry->id = FLOW_ACTION_POLICE; + entry->police.burst = tcf_police_burst(act); + entry->police.rate_bytes_ps = + tcf_police_rate_bytes_ps(act); + entry->police.burst_pkt = tcf_police_burst_pkt(act); + entry->police.rate_pkt_ps = + tcf_police_rate_pkt_ps(act); + entry->police.mtu = tcf_police_tcfp_mtu(act); + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + MODULE_AUTHOR("Alexey Kuznetsov"); MODULE_DESCRIPTION("Policing actions"); MODULE_LICENSE("GPL"); @@ -420,6 +442,7 @@ static struct tc_action_ops act_police_ops = { .walk = tcf_police_walker, .lookup = tcf_police_search, .cleanup = tcf_police_cleanup, + .flow_act_setup = tcf_police_flow_act_setup, .size = sizeof(struct tcf_police), }; diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 91a7a93d5f6a..1b0bb501218e 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -282,6 +282,33 @@ tcf_sample_get_group(const struct tc_action *a, return group; } +static void tcf_flow_sample_get_group(struct flow_action_entry *entry, + const struct tc_action *act) +{ + entry->sample.psample_group = + act->ops->get_psample_group(act, &entry->destructor); + entry->destructor_priv = entry->sample.psample_group; +} + +static int tcf_sample_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + entry->id = FLOW_ACTION_SAMPLE; + entry->sample.trunc_size = tcf_sample_trunc_size(act); + entry->sample.truncate = tcf_sample_truncate(act); + entry->sample.rate = tcf_sample_rate(act); + tcf_flow_sample_get_group(entry, act); + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_sample_ops = { .kind = "sample", .id = TCA_ID_SAMPLE, @@ -294,6 +321,7 @@ static struct tc_action_ops act_sample_ops = { .walk = tcf_sample_walker, .lookup = tcf_sample_search, .get_psample_group = tcf_sample_get_group, + .flow_act_setup = tcf_sample_flow_act_setup, .size = sizeof(struct tcf_sample), }; diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index cb2d10d3dcc0..b0d791560aa6 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -327,6 +327,32 @@ static size_t tcf_skbedit_get_fill_size(const struct tc_action *act) + nla_total_size_64bit(sizeof(u64)); /* TCA_SKBEDIT_FLAGS */ } +static int tcf_skbedit_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + if (is_tcf_skbedit_mark(act)) { + entry->id = FLOW_ACTION_MARK; + entry->mark = tcf_skbedit_mark(act); + } else if (is_tcf_skbedit_ptype(act)) { + entry->id = FLOW_ACTION_PTYPE; + entry->ptype = tcf_skbedit_ptype(act); + } else if (is_tcf_skbedit_priority(act)) { + entry->id = FLOW_ACTION_PRIORITY; + entry->priority = tcf_skbedit_priority(act); + } else { + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_skbedit_ops = { .kind = "skbedit", .id = TCA_ID_SKBEDIT, @@ -339,6 +365,7 @@ static struct tc_action_ops act_skbedit_ops = { .walk = tcf_skbedit_walker, .get_fill_size = tcf_skbedit_get_fill_size, .lookup = tcf_skbedit_search, + .flow_act_setup = tcf_skbedit_flow_act_setup, .size = sizeof(struct tcf_skbedit), }; diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index d9cd174eecb7..14d8307c31a5 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -787,6 +787,52 @@ static int tunnel_key_search(struct net *net, struct tc_action **a, u32 index) return tcf_idr_search(tn, a, index); } +static void tcf_tunnel_encap_put_tunnel(void *priv) +{ + struct ip_tunnel_info *tunnel = priv; + + kfree(tunnel); +} + +static int tcf_tunnel_encap_get_tunnel(struct flow_action_entry *entry, + const struct tc_action *act) +{ + entry->tunnel = tcf_tunnel_info_copy(act); + if (!entry->tunnel) + return -ENOMEM; + entry->destructor = tcf_tunnel_encap_put_tunnel; + entry->destructor_priv = entry->tunnel; + return 0; +} + +static int tcf_tunnel_key_flow_act_setup(struct tc_action *act, + void *entry_data, + u32 *index_inc, + bool bind) +{ + int err; + + if (bind) { + struct flow_action_entry *entry = entry_data; + + if (is_tcf_tunnel_set(act)) { + entry->id = FLOW_ACTION_TUNNEL_ENCAP; + err = tcf_tunnel_encap_get_tunnel(entry, act); + if (err) + return err; + } else if (is_tcf_tunnel_release(act)) { + entry->id = FLOW_ACTION_TUNNEL_DECAP; + } else { + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_tunnel_key_ops = { .kind = "tunnel_key", .id = TCA_ID_TUNNEL_KEY, @@ -797,6 +843,7 @@ static struct tc_action_ops act_tunnel_key_ops = { .cleanup = tunnel_key_release, .walk = tunnel_key_walker, .lookup = tunnel_key_search, + .flow_act_setup = tcf_tunnel_key_flow_act_setup, .size = sizeof(struct tcf_tunnel_key), }; diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index e4dc5a555bd8..5de24a995020 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -368,6 +368,39 @@ static size_t tcf_vlan_get_fill_size(const struct tc_action *act) + nla_total_size(sizeof(u8)); /* TCA_VLAN_PUSH_VLAN_PRIORITY */ } +static int tcf_vlan_flow_act_setup(struct tc_action *act, void *entry_data, + u32 *index_inc, bool bind) +{ + if (bind) { + struct flow_action_entry *entry = entry_data; + + switch (tcf_vlan_action(act)) { + case TCA_VLAN_ACT_PUSH: + entry->id = FLOW_ACTION_VLAN_PUSH; + entry->vlan.vid = tcf_vlan_push_vid(act); + entry->vlan.proto = tcf_vlan_push_proto(act); + entry->vlan.prio = tcf_vlan_push_prio(act); + break; + case TCA_VLAN_ACT_POP: + entry->id = FLOW_ACTION_VLAN_POP; + break; + case TCA_VLAN_ACT_MODIFY: + entry->id = FLOW_ACTION_VLAN_MANGLE; + entry->vlan.vid = tcf_vlan_push_vid(act); + entry->vlan.proto = tcf_vlan_push_proto(act); + entry->vlan.prio = tcf_vlan_push_prio(act); + break; + default: + return -EOPNOTSUPP; + } + *index_inc = 1; + } else { + return -EOPNOTSUPP; + } + + return 0; +} + static struct tc_action_ops act_vlan_ops = { .kind = "vlan", .id = TCA_ID_VLAN, @@ -380,6 +413,7 @@ static struct tc_action_ops act_vlan_ops = { .stats_update = tcf_vlan_stats_update, .get_fill_size = tcf_vlan_get_fill_size, .lookup = tcf_vlan_search, + .flow_act_setup = tcf_vlan_flow_act_setup, .size = sizeof(struct tcf_vlan), }; diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 7a680cae0bae..33b81c867ac0 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3474,81 +3474,25 @@ void tc_cleanup_flow_action(struct flow_action *flow_action) } EXPORT_SYMBOL(tc_cleanup_flow_action); -static void tcf_mirred_get_dev(struct flow_action_entry *entry, - const struct tc_action *act) +static int tc_setup_flow_act(struct tc_action *act, + struct flow_action_entry *entry, + u32 *index_inc) { #ifdef CONFIG_NET_CLS_ACT - entry->dev = act->ops->get_dev(act, &entry->destructor); - if (!entry->dev) - return; - entry->destructor_priv = entry->dev; -#endif -} - -static void tcf_tunnel_encap_put_tunnel(void *priv) -{ - struct ip_tunnel_info *tunnel = priv; - - kfree(tunnel); -} - -static int tcf_tunnel_encap_get_tunnel(struct flow_action_entry *entry, - const struct tc_action *act) -{ - entry->tunnel = tcf_tunnel_info_copy(act); - if (!entry->tunnel) - return -ENOMEM; - entry->destructor = tcf_tunnel_encap_put_tunnel; - entry->destructor_priv = entry->tunnel; + if (act->ops->flow_act_setup) + return act->ops->flow_act_setup(act, entry, index_inc, true); + else + return -EOPNOTSUPP; +#else return 0; -} - -static void tcf_sample_get_group(struct flow_action_entry *entry, - const struct tc_action *act) -{ -#ifdef CONFIG_NET_CLS_ACT - entry->sample.psample_group = - act->ops->get_psample_group(act, &entry->destructor); - entry->destructor_priv = entry->sample.psample_group; #endif } -static void tcf_gate_entry_destructor(void *priv) -{ - struct action_gate_entry *oe = priv; - - kfree(oe); -} - -static int tcf_gate_get_entries(struct flow_action_entry *entry, - const struct tc_action *act) -{ - entry->gate.entries = tcf_gate_get_list(act); - - if (!entry->gate.entries) - return -EINVAL; - - entry->destructor = tcf_gate_entry_destructor; - entry->destructor_priv = entry->gate.entries; - - return 0; -} - -static enum flow_action_hw_stats tc_act_hw_stats(u8 hw_stats) -{ - if (WARN_ON_ONCE(hw_stats > TCA_ACT_HW_STATS_ANY)) - return FLOW_ACTION_HW_STATS_DONT_CARE; - else if (!hw_stats) - return FLOW_ACTION_HW_STATS_DISABLED; - - return hw_stats; -} - int tc_setup_flow_action(struct flow_action *flow_action, const struct tcf_exts *exts) { + int i, j, index, err = 0; struct tc_action *act; - int i, j, k, err = 0; BUILD_BUG_ON(TCA_ACT_HW_STATS_ANY != FLOW_ACTION_HW_STATS_ANY); BUILD_BUG_ON(TCA_ACT_HW_STATS_IMMEDIATE != FLOW_ACTION_HW_STATS_IMMEDIATE); @@ -3569,151 +3513,13 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->hw_stats = tc_act_hw_stats(act->hw_stats); entry->index = act->tcfa_index; - - if (is_tcf_gact_ok(act)) { - entry->id = FLOW_ACTION_ACCEPT; - } else if (is_tcf_gact_shot(act)) { - entry->id = FLOW_ACTION_DROP; - } else if (is_tcf_gact_trap(act)) { - entry->id = FLOW_ACTION_TRAP; - } else if (is_tcf_gact_goto_chain(act)) { - entry->id = FLOW_ACTION_GOTO; - entry->chain_index = tcf_gact_goto_chain_index(act); - } else if (is_tcf_mirred_egress_redirect(act)) { - entry->id = FLOW_ACTION_REDIRECT; - tcf_mirred_get_dev(entry, act); - } else if (is_tcf_mirred_egress_mirror(act)) { - entry->id = FLOW_ACTION_MIRRED; - tcf_mirred_get_dev(entry, act); - } else if (is_tcf_mirred_ingress_redirect(act)) { - entry->id = FLOW_ACTION_REDIRECT_INGRESS; - tcf_mirred_get_dev(entry, act); - } else if (is_tcf_mirred_ingress_mirror(act)) { - entry->id = FLOW_ACTION_MIRRED_INGRESS; - tcf_mirred_get_dev(entry, act); - } else if (is_tcf_vlan(act)) { - switch (tcf_vlan_action(act)) { - case TCA_VLAN_ACT_PUSH: - entry->id = FLOW_ACTION_VLAN_PUSH; - entry->vlan.vid = tcf_vlan_push_vid(act); - entry->vlan.proto = tcf_vlan_push_proto(act); - entry->vlan.prio = tcf_vlan_push_prio(act); - break; - case TCA_VLAN_ACT_POP: - entry->id = FLOW_ACTION_VLAN_POP; - break; - case TCA_VLAN_ACT_MODIFY: - entry->id = FLOW_ACTION_VLAN_MANGLE; - entry->vlan.vid = tcf_vlan_push_vid(act); - entry->vlan.proto = tcf_vlan_push_proto(act); - entry->vlan.prio = tcf_vlan_push_prio(act); - break; - default: - err = -EOPNOTSUPP; - goto err_out_locked; - } - } else if (is_tcf_tunnel_set(act)) { - entry->id = FLOW_ACTION_TUNNEL_ENCAP; - err = tcf_tunnel_encap_get_tunnel(entry, act); - if (err) - goto err_out_locked; - } else if (is_tcf_tunnel_release(act)) { - entry->id = FLOW_ACTION_TUNNEL_DECAP; - } else if (is_tcf_pedit(act)) { - for (k = 0; k < tcf_pedit_nkeys(act); k++) { - switch (tcf_pedit_cmd(act, k)) { - case TCA_PEDIT_KEY_EX_CMD_SET: - entry->id = FLOW_ACTION_MANGLE; - break; - case TCA_PEDIT_KEY_EX_CMD_ADD: - entry->id = FLOW_ACTION_ADD; - break; - default: - err = -EOPNOTSUPP; - goto err_out_locked; - } - entry->mangle.htype = tcf_pedit_htype(act, k); - entry->mangle.mask = tcf_pedit_mask(act, k); - entry->mangle.val = tcf_pedit_val(act, k); - entry->mangle.offset = tcf_pedit_offset(act, k); - entry->hw_stats = tc_act_hw_stats(act->hw_stats); - entry = &flow_action->entries[++j]; - } - } else if (is_tcf_csum(act)) { - entry->id = FLOW_ACTION_CSUM; - entry->csum_flags = tcf_csum_update_flags(act); - } else if (is_tcf_skbedit_mark(act)) { - entry->id = FLOW_ACTION_MARK; - entry->mark = tcf_skbedit_mark(act); - } else if (is_tcf_sample(act)) { - entry->id = FLOW_ACTION_SAMPLE; - entry->sample.trunc_size = tcf_sample_trunc_size(act); - entry->sample.truncate = tcf_sample_truncate(act); - entry->sample.rate = tcf_sample_rate(act); - tcf_sample_get_group(entry, act); - } else if (is_tcf_police(act)) { - entry->id = FLOW_ACTION_POLICE; - entry->police.burst = tcf_police_burst(act); - entry->police.rate_bytes_ps = - tcf_police_rate_bytes_ps(act); - entry->police.burst_pkt = tcf_police_burst_pkt(act); - entry->police.rate_pkt_ps = - tcf_police_rate_pkt_ps(act); - entry->police.mtu = tcf_police_tcfp_mtu(act); - } else if (is_tcf_ct(act)) { - entry->id = FLOW_ACTION_CT; - entry->ct.action = tcf_ct_action(act); - entry->ct.zone = tcf_ct_zone(act); - entry->ct.flow_table = tcf_ct_ft(act); - } else if (is_tcf_mpls(act)) { - switch (tcf_mpls_action(act)) { - case TCA_MPLS_ACT_PUSH: - entry->id = FLOW_ACTION_MPLS_PUSH; - entry->mpls_push.proto = tcf_mpls_proto(act); - entry->mpls_push.label = tcf_mpls_label(act); - entry->mpls_push.tc = tcf_mpls_tc(act); - entry->mpls_push.bos = tcf_mpls_bos(act); - entry->mpls_push.ttl = tcf_mpls_ttl(act); - break; - case TCA_MPLS_ACT_POP: - entry->id = FLOW_ACTION_MPLS_POP; - entry->mpls_pop.proto = tcf_mpls_proto(act); - break; - case TCA_MPLS_ACT_MODIFY: - entry->id = FLOW_ACTION_MPLS_MANGLE; - entry->mpls_mangle.label = tcf_mpls_label(act); - entry->mpls_mangle.tc = tcf_mpls_tc(act); - entry->mpls_mangle.bos = tcf_mpls_bos(act); - entry->mpls_mangle.ttl = tcf_mpls_ttl(act); - break; - default: - err = -EOPNOTSUPP; - goto err_out_locked; - } - } else if (is_tcf_skbedit_ptype(act)) { - entry->id = FLOW_ACTION_PTYPE; - entry->ptype = tcf_skbedit_ptype(act); - } else if (is_tcf_skbedit_priority(act)) { - entry->id = FLOW_ACTION_PRIORITY; - entry->priority = tcf_skbedit_priority(act); - } else if (is_tcf_gate(act)) { - entry->id = FLOW_ACTION_GATE; - entry->gate.prio = tcf_gate_prio(act); - entry->gate.basetime = tcf_gate_basetime(act); - entry->gate.cycletime = tcf_gate_cycletime(act); - entry->gate.cycletimeext = tcf_gate_cycletimeext(act); - entry->gate.num_entries = tcf_gate_num_entries(act); - err = tcf_gate_get_entries(entry, act); - if (err) - goto err_out_locked; - } else { - err = -EOPNOTSUPP; + index = 0; + err = tc_setup_flow_act(act, entry, &index); + if (!err) + j += index; + else goto err_out_locked; - } spin_unlock_bh(&act->tcfa_lock); - - if (!is_tcf_pedit(act)) - j++; } err_out: From patchwork Fri Dec 3 12:24:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655043 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D884C433EF for ; Fri, 3 Dec 2021 12:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244247AbhLCM2l (ORCPT ); Fri, 3 Dec 2021 07:28:41 -0500 Received: from mail-mw2nam10on2100.outbound.protection.outlook.com ([40.107.94.100]:55489 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244538AbhLCM2k (ORCPT ); Fri, 3 Dec 2021 07:28:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LaDNRldCIduyQvHSBAwW7PTnoPirirQCcyof5S37mlfQdYUmXIjX0u9938M/AwywhOkBsuTw6A5rfpS+lF1ybuTt1NWK12zcMafATZPCiNr0nKjQ5CVRb2uGvIHZEt1bhjJXfyEcksogr3ZIUcCKQuRAhGPDoXEqHgG/Y0YZMlYXVePtiooxMDVDR+bigoGSyslKkHELo790dJseANEiWLjO0EslcTQt2R+A+wGJ9CPYS1mjsNXtUodCwI0iinh2rtmXV9lDKu6XS1pDeFmL1fHoCBIddSMKx1N66p18zMNxIWovRAbCp67HLWUWSE1VpR23TINjdx8D3BdFc3Ee+Q== 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=KnB7WVGHd7JN7xLxjRizJF50qOlzkzaf598O+3qEPtM=; b=Fi1pN8rg946/7cYyn3/BEEY9tPUOZQwcnl0CxgVR5UqkNDSZ9zkCdcf0L55270d1Jk2GYKdaOI7tx2rh6hMUvgk7ta6/7iJxxAAdfCjNAIL9eiLhe8fSDuFj1V/1dWE1yhSXkysRaQgtp0lxGLMs81USOZhUDA/mGxTgM9Z5Y2Min52hTiips5UKmj02Fdk2N+IlmslcPZU9GeGt8sLrwxWYvIFZLq+KbMzwucrnv32awayTlghcLskCwEB3+PRyjszrzUjKzNd8979+fkClJmGfKigRlCcKmxFfP75ZrMcXd9cp3rnEl5WjI04Ybn6jrNav/szEKCywdgZhqpYSnw== 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=KnB7WVGHd7JN7xLxjRizJF50qOlzkzaf598O+3qEPtM=; b=s4MT6mU0BFT6En8a9LOyiT6g7rqbn1VIfUc2j6+b2rYE73WSVEWpcQReQTGuRxGBqta61ZqkI+hodVSp7mcv5wD56g6jNB8DMgRmLpDqa2ppNJcfLmfl4W6rNJPNnz/CGvzhyKDWVg0ToLnTYePLNrpUH1nszyDkONp4HyK8nSg= 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 PH0PR13MB5423.namprd13.prod.outlook.com (2603:10b6:510:12a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.7; Fri, 3 Dec 2021 12:25:15 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25:15 +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, Simon Horman Subject: [PATCH v5 net-next 06/12] flow_offload: allow user to offload tc action to net device Date: Fri, 3 Dec 2021 13:24:38 +0100 Message-Id: <20211203122444.11756-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ee9bd261-82d6-4a7a-3c3b-08d9b657f59e X-MS-TrafficTypeDiagnostic: PH0PR13MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nJzqFK/8Wjj4Gf7PoMHzNQaw4BQFaylKD2+P/cKhRLBySU6TiHOlzYMlTwHXsbvU1AP2dx1lIfxgHpSjq3lmgNUhmiGjAPpZn/+X80jXLszSSD2V81Gw/yXelGo+ehN53ycIL1FpyYOauWZ4W3rl3dMN8dmod2Vj2KVgLmf1EoN+LNlzejVF02HAOyWvFf8I+7CHUQX5qjvoK/YWOv4dxWBtDHaG9W0LUN5vxdHK1A0jUzGZ8aKAZ8K7F0MCLiXrPSuTHXsOvOV3of4Df9gFZ5X3Yob2kYh5/xgSKMB+LaECwLLmBjm+TWNdl+zYI5zMVdUMG78071BOWnMmJBTluuozx0xVFV3FdfEwJmgobgrGNTY5lytpEso1k+8taZ4NXbyWh4v+yZDH+QQ5cz9KC8WDNkMsINRC3CQR2WcCn2MpjUrLdOpcUosHD2UT8c/eMnyJK44nVXXaSxB1WmdE7yJnDeSn1AtSIcR2lC0N4QGB0tpjlLnDKxufFo4OhoBkJGa/TOy/LLexUotERzaDF4XVSCmNvbLeL7s3K5I8fmJUqZtzObkSdQb/7uiTVIuktwct4O/E1HtZMvsUgwDGtcjOU3w6AOAX+3YxXYlAn5Uv2l/m7cf+GBJQMYHk8o472hcunUYeQJO4YbCDZQfEvg== 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:(366004)(346002)(376002)(39830400003)(396003)(136003)(6666004)(8936002)(38100700002)(2616005)(30864003)(6506007)(4326008)(66946007)(66556008)(8676002)(36756003)(186003)(316002)(1076003)(44832011)(6486002)(508600001)(66476007)(5660300002)(107886003)(54906003)(52116002)(86362001)(83380400001)(6916009)(6512007)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S4xjouXuln9fewhNB1WnAHlFiXow5DKsHCG9q9E8HfUQImIUkKaQTFkKGVXyZbfaKgoA8mhq7I39aTj0BF8Ab2/18cVQmklQd1WXRVDqHwOjaZ3ncMsILJO6TfgVP4pKbJNlEkC3iquAG1nDmNK7Ue08KLmgj0Eu4mqXH/yvbPWE92RxcYKH/POxQWtJXbkOWleAb4dQ6N2+JprUAtrD90dXTvDeKHjhoAYAARyjNvAjf2PCogBADgazHLIj53eWO9V75AxyNqe6/9oN1auxCt276C6DQAouOJgskF3j+0OV9PHv+YHS00fOUzYUH0mZtc/GXxpDu/Q4UmdsDNr5gHts+skhTvXcrLNSx/3w3I4Umn2gZIB0SWUAotTMTrAC3AYe/yu/yGGAACneKl0yTilfHZ4224n66i557sfPm0tDdOX4WDjwpgHELDcL74zjPiua5KsWdYeCzxWF+QzpiduXaPQTKA5/jnchqp/maRfnrxZOE4vdmuU02atknygEEJwQjkWw7bzUkIGgKND8lMqYAWk0y1NKEGuQ4RCYGE4NYeO3mnYIuzBa4OBKRRx2E+qLODt41ou5/iutZsIJlVXvAs2ppb95dEbqp6fvhB3vArmm1xQu060+vBH8g+LUhyxgIyOCWRtpqzlUTzJZEpRoJigrVM7YobxeJxy9PLpR8Bnj6rXlVr8A9Q//LZ6ACdJcZCrpUUJlRKEhRo4Jrbx28Qv1Nmlqo2cLbMCADT4/aJVAFswmkCVl4HZYXmIaNDbhyUkdv/AsQRFmQooPFReP54faBmiUEgNNofwGCo0hsGU4pyhQpYxhTkiZnlsui9+zxf5ZJJiJd1RihL6tjgoi973F/ZKc8OSGjLr/lyBmSnLHg5bS3VSTpdswfoN9Xp3VPtD4PaMXYvG9YZEue6y7EORu92Cs7bTdh5VJn28XbjFF9k2CukYl8Nl0omKkSMP9a57hKRj9pPR0HMeTaaRlgTO0aPpb+Cn6Iudar8tfhZnC5Isg6mhy1UtBxppEuhMvj6eV/x7TLQyPJISROysQ6cFSJdfuwxVNq1NJgHQg32O3w7IxzSv7/SY/Eih0N7/OdJCzarF8MTkcdGjzpCUl+uAM18gHn1LDGuGCpAN2CDc/OmMvo+F4y8ErvY3TSWoKEmuzYjFxg4svqAIm7RIDU4Y0fhaSo49ZQfkIJqSgGeM5shgs2iuzG1ey/UBjvKygmDYSPmmMc7GkquNuEhcKDtu2xB66Kx10mAYTB2T82tZ7Xb5cY5evutRnoFnvseSGhvhilPISojslYZP7I9C5ug7g/IaR/lF7r8Ofwg+ppUHgU+W1f/zRRUvEFYqwvMsDvUJdAjcB5pDke2XL1NLkRxZKjIjFMITKlpjlPiwAwl79k4ygvbN39DIEFveasEwC1Obpc3GmqVo3z7nmjuU+nLpJEn+AdWZqjhtgX1XygQoaKMSmADlRtQRVzfcaYi2XSezjDTwrs97HjoTORPybhorTD3ZUeRIqAHa8fXaNRU4sTeS6a7nfZbiqoe/F8gK5Gz1WsbnHMmBejVOdh1//KvDcAWXJdU+Y/a/02DbmpgiQPgW6SDk/t6gfq7Dl+SiB9JVgJ9QPJ6CUSB4Z9G6U6lmbScYV5D0IrinHH79nACOHtJ0tXb2Vvq8ElOwgBdEi0hI/EmJ7vH6mnbX3ZCXm2HeYRt0sd9qLnfFy6eVy+Qj9sskOht7IIMQevU5YXv3l2gu5qVyJWxXEzQRevbtuLLK2EJtAcM2BCSUQx5E= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee9bd261-82d6-4a7a-3c3b-08d9b657f59e X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:15.0267 (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: pOb5XyzwHywpEVoOBcBw1aZXRJHmMzafO7cTeqn3Q7inx6LIQRdKmSlXQjdzL4E/zBZeHEZ4vDnxPPmKhUHmbPtrgPK4M3kdIQvyLoyI03I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5423 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Use flow_indr_dev_register/flow_indr_dev_setup_offload to offload tc action. We need to call tc_cleanup_flow_action to clean up tc action entry since in tc_setup_action, some actions may hold dev refcnt, especially the mirror action. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- include/linux/netdevice.h | 1 + include/net/flow_offload.h | 17 +++++++ include/net/pkt_cls.h | 6 +++ net/core/flow_offload.c | 42 +++++++++++++---- net/sched/act_api.c | 92 ++++++++++++++++++++++++++++++++++++++ net/sched/act_csum.c | 4 +- net/sched/act_ct.c | 4 +- net/sched/act_gact.c | 13 +++++- net/sched/act_gate.c | 4 +- net/sched/act_mirred.c | 13 +++++- net/sched/act_mpls.c | 16 ++++++- net/sched/act_police.c | 4 +- net/sched/act_sample.c | 4 +- net/sched/act_skbedit.c | 11 ++++- net/sched/act_tunnel_key.c | 9 +++- net/sched/act_vlan.c | 16 ++++++- net/sched/cls_api.c | 21 +++++++-- 17 files changed, 254 insertions(+), 23 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 65117f01d5f2..037577cbe3f0 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..13f0e4a3a136 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -258,6 +258,9 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) for (; 0; (void)(i), (void)(a), (void)(exts)) #endif +#define tcf_act_for_each_action(i, a, actions) \ + for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = actions[i]); i++) + static inline void tcf_exts_stats_update(const struct tcf_exts *exts, u64 bytes, u64 packets, u64 drops, u64 lastuse, @@ -534,6 +537,9 @@ tcf_match_indev(struct sk_buff *skb, int ifindex) int tc_setup_flow_action(struct flow_action *flow_action, const struct tcf_exts *exts); + +int tc_setup_action(struct flow_action *flow_action, + struct tc_action *actions[]); void tc_cleanup_flow_action(struct flow_action *flow_action); int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c index 6beaea13564a..31273a10086e 100644 --- a/net/core/flow_offload.c +++ b/net/core/flow_offload.c @@ -27,6 +27,26 @@ struct flow_rule *flow_rule_alloc(unsigned int num_actions) } EXPORT_SYMBOL(flow_rule_alloc); +struct flow_offload_action *flow_action_alloc(unsigned int num_actions) +{ + struct flow_offload_action *fl_action; + int i; + + fl_action = kzalloc(struct_size(fl_action, action.entries, num_actions), + GFP_KERNEL); + if (!fl_action) + return NULL; + + fl_action->action.num_entries = num_actions; + /* Pre-fill each action hw_stats with DONT_CARE. + * Caller can override this if it wants stats for a given action. + */ + for (i = 0; i < num_actions; i++) + fl_action->action.entries[i].hw_stats = FLOW_ACTION_HW_STATS_DONT_CARE; + + return fl_action; +} + #define FLOW_DISSECTOR_MATCH(__rule, __type, __out) \ const struct flow_match *__m = &(__rule)->match; \ struct flow_dissector *__d = (__m)->dissector; \ @@ -549,19 +569,25 @@ int flow_indr_dev_setup_offload(struct net_device *dev, struct Qdisc *sch, void (*cleanup)(struct flow_block_cb *block_cb)) { struct flow_indr_dev *this; + u32 count = 0; + int err; mutex_lock(&flow_indr_block_lock); + if (bo) { + if (bo->command == FLOW_BLOCK_BIND) + indir_dev_add(data, dev, sch, type, cleanup, bo); + else if (bo->command == FLOW_BLOCK_UNBIND) + indir_dev_remove(data); + } - if (bo->command == FLOW_BLOCK_BIND) - indir_dev_add(data, dev, sch, type, cleanup, bo); - else if (bo->command == FLOW_BLOCK_UNBIND) - indir_dev_remove(data); - - list_for_each_entry(this, &flow_block_indr_dev_list, list) - this->cb(dev, sch, this->cb_priv, type, bo, data, cleanup); + list_for_each_entry(this, &flow_block_indr_dev_list, list) { + err = this->cb(dev, sch, this->cb_priv, type, bo, data, cleanup); + if (!err) + count++; + } mutex_unlock(&flow_indr_block_lock); - return list_empty(&bo->cb_list) ? -EOPNOTSUPP : 0; + return (bo && list_empty(&bo->cb_list)) ? -EOPNOTSUPP : count; } EXPORT_SYMBOL(flow_indr_dev_setup_offload); diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 3258da3d5bed..120e72d8502c 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -19,8 +19,10 @@ #include #include #include +#include #include #include +#include #ifdef CONFIG_INET DEFINE_STATIC_KEY_FALSE(tcf_frag_xmit_count); @@ -129,8 +131,91 @@ static void free_tcf(struct tc_action *p) kfree(p); } +static unsigned int tcf_act_num_actions_single(struct tc_action *act) +{ + if (is_tcf_pedit(act)) + return tcf_pedit_nkeys(act); + else + return 1; +} + +static int flow_action_init(struct flow_offload_action *fl_action, + struct tc_action *act, + enum flow_act_command cmd, + struct netlink_ext_ack *extack) +{ + fl_action->extack = extack; + fl_action->command = cmd; + fl_action->index = act->tcfa_index; + + if (act->ops->flow_act_setup) + return act->ops->flow_act_setup(act, fl_action, NULL, false); + + return -EOPNOTSUPP; +} + +static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + struct netlink_ext_ack *extack) +{ + int err; + + err = flow_indr_dev_setup_offload(NULL, NULL, TC_SETUP_ACT, + fl_act, NULL, NULL); + if (err < 0) + return err; + + return 0; +} + +/* offload the tc command after inserted */ +static int tcf_action_offload_add(struct tc_action *action, + struct netlink_ext_ack *extack) +{ + struct tc_action *actions[TCA_ACT_MAX_PRIO] = { + [0] = action, + }; + struct flow_offload_action *fl_action; + int err = 0; + + fl_action = flow_action_alloc(tcf_act_num_actions_single(action)); + if (!fl_action) + return -ENOMEM; + + err = flow_action_init(fl_action, action, FLOW_ACT_REPLACE, extack); + if (err) + goto fl_err; + + err = tc_setup_action(&fl_action->action, actions); + if (err) { + NL_SET_ERR_MSG_MOD(extack, + "Failed to setup tc actions for offload\n"); + goto fl_err; + } + + err = tcf_action_offload_cmd(fl_action, extack); + tc_cleanup_flow_action(&fl_action->action); + +fl_err: + kfree(fl_action); + + return err; +} + +static int tcf_action_offload_del(struct tc_action *action) +{ + struct flow_offload_action fl_act = {}; + int err = 0; + + err = flow_action_init(&fl_act, action, FLOW_ACT_DESTROY, NULL); + if (err) + return err; + + return tcf_action_offload_cmd(&fl_act, NULL); +} + static void tcf_action_cleanup(struct tc_action *p) { + tcf_action_offload_del(p); if (p->ops->cleanup) p->ops->cleanup(p); @@ -1061,6 +1146,11 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, return ERR_PTR(err); } +static bool tc_act_bind(u32 flags) +{ + return !!(flags & TCA_ACT_FLAGS_BIND); +} + /* Returns numbers of initialized actions or negative error. */ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, @@ -1103,6 +1193,8 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, sz += tcf_action_fill_size(act); /* Start from index 0 */ actions[i - 1] = act; + if (!tc_act_bind(flags)) + tcf_action_offload_add(act, extack); } /* We have to commit them all together, because if any error happened in diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index b55d687e3adc..26e9036240d9 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c @@ -705,7 +705,9 @@ static int tcf_csum_flow_act_setup(struct tc_action *act, void *entry_data, entry->csum_flags = tcf_csum_update_flags(act); *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + fl_action->id = FLOW_ACTION_CSUM; } return 0; diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index 9edfed3b0f4b..485e4c7a086d 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1505,7 +1505,9 @@ static int tcf_ct_flow_act_setup(struct tc_action *act, void *entry_data, entry->ct.flow_table = tcf_ct_ft(act); *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + fl_action->id = FLOW_ACTION_CT; } return 0; diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index 2342aa5d8284..7d2f0c9587c8 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c @@ -272,7 +272,18 @@ static int tcf_gact_flow_act_setup(struct tc_action *act, void *entry_data, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + if (is_tcf_gact_ok(act)) + fl_action->id = FLOW_ACTION_ACCEPT; + else if (is_tcf_gact_shot(act)) + fl_action->id = FLOW_ACTION_DROP; + else if (is_tcf_gact_trap(act)) + fl_action->id = FLOW_ACTION_TRAP; + else if (is_tcf_gact_goto_chain(act)) + fl_action->id = FLOW_ACTION_GOTO; + else + return -EOPNOTSUPP; } return 0; diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c index cbdcbe4376bb..f149135c2e10 100644 --- a/net/sched/act_gate.c +++ b/net/sched/act_gate.c @@ -637,7 +637,9 @@ static int tcf_gate_flow_act_setup(struct tc_action *act, void *entry_data, return err; *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + fl_action->id = FLOW_ACTION_GATE; } return 0; diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 8c953b2dc2d5..7104dca72469 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -480,7 +480,18 @@ static int tcf_mirred_flow_act_setup(struct tc_action *act, void *entry_data, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + if (is_tcf_mirred_egress_redirect(act)) + fl_action->id = FLOW_ACTION_REDIRECT; + else if (is_tcf_mirred_egress_mirror(act)) + fl_action->id = FLOW_ACTION_MIRRED; + else if (is_tcf_mirred_ingress_redirect(act)) + fl_action->id = FLOW_ACTION_REDIRECT_INGRESS; + else if (is_tcf_mirred_ingress_mirror(act)) + fl_action->id = FLOW_ACTION_MIRRED_INGRESS; + else + return -EOPNOTSUPP; } return 0; diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index 69bc9e10ee3e..720f57ec9a48 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -415,7 +415,21 @@ static int tcf_mpls_flow_act_setup(struct tc_action *act, void *entry_data, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + switch (tcf_mpls_action(act)) { + case TCA_MPLS_ACT_PUSH: + fl_action->id = FLOW_ACTION_MPLS_PUSH; + break; + case TCA_MPLS_ACT_POP: + fl_action->id = FLOW_ACTION_MPLS_POP; + break; + case TCA_MPLS_ACT_MODIFY: + fl_action->id = FLOW_ACTION_MPLS_MANGLE; + break; + default: + return -EOPNOTSUPP; + } } return 0; diff --git a/net/sched/act_police.c b/net/sched/act_police.c index f48e9765b70e..b8b64c72d686 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -421,7 +421,9 @@ static int tcf_police_flow_act_setup(struct tc_action *act, void *entry_data, entry->police.mtu = tcf_police_tcfp_mtu(act); *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + fl_action->id = FLOW_ACTION_POLICE; } return 0; diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 1b0bb501218e..df7bfa688372 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -303,7 +303,9 @@ static int tcf_sample_flow_act_setup(struct tc_action *act, void *entry_data, tcf_flow_sample_get_group(entry, act); *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + fl_action->id = FLOW_ACTION_SAMPLE; } return 0; diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index b0d791560aa6..c4fd5dc21bbc 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -347,7 +347,16 @@ static int tcf_skbedit_flow_act_setup(struct tc_action *act, void *entry_data, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + if (is_tcf_skbedit_mark(act)) + fl_action->id = FLOW_ACTION_MARK; + else if (is_tcf_skbedit_ptype(act)) + fl_action->id = FLOW_ACTION_PTYPE; + else if (is_tcf_skbedit_priority(act)) + fl_action->id = FLOW_ACTION_PRIORITY; + else + return -EOPNOTSUPP; } return 0; diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index 14d8307c31a5..2ebc797c047a 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -827,7 +827,14 @@ static int tcf_tunnel_key_flow_act_setup(struct tc_action *act, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + if (is_tcf_tunnel_set(act)) + fl_action->id = FLOW_ACTION_TUNNEL_ENCAP; + else if (is_tcf_tunnel_release(act)) + fl_action->id = FLOW_ACTION_TUNNEL_DECAP; + else + return -EOPNOTSUPP; } return 0; diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index 5de24a995020..5f0ed3b5a5ac 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -395,7 +395,21 @@ static int tcf_vlan_flow_act_setup(struct tc_action *act, void *entry_data, } *index_inc = 1; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + + switch (tcf_vlan_action(act)) { + case TCA_VLAN_ACT_PUSH: + fl_action->id = FLOW_ACTION_VLAN_PUSH; + break; + case TCA_VLAN_ACT_POP: + fl_action->id = FLOW_ACTION_VLAN_POP; + break; + case TCA_VLAN_ACT_MODIFY: + fl_action->id = FLOW_ACTION_VLAN_MANGLE; + break; + default: + return -EOPNOTSUPP; + } } return 0; diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 33b81c867ac0..2a1cc7fe2dd9 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3488,8 +3488,8 @@ static int tc_setup_flow_act(struct tc_action *act, #endif } -int tc_setup_flow_action(struct flow_action *flow_action, - const struct tcf_exts *exts) +int tc_setup_action(struct flow_action *flow_action, + struct tc_action *actions[]) { int i, j, index, err = 0; struct tc_action *act; @@ -3498,11 +3498,11 @@ int tc_setup_flow_action(struct flow_action *flow_action, BUILD_BUG_ON(TCA_ACT_HW_STATS_IMMEDIATE != FLOW_ACTION_HW_STATS_IMMEDIATE); BUILD_BUG_ON(TCA_ACT_HW_STATS_DELAYED != FLOW_ACTION_HW_STATS_DELAYED); - if (!exts) + if (!actions) return 0; j = 0; - tcf_exts_for_each_action(i, act, exts) { + tcf_act_for_each_action(i, act, actions) { struct flow_action_entry *entry; entry = &flow_action->entries[j]; @@ -3531,6 +3531,19 @@ int tc_setup_flow_action(struct flow_action *flow_action, spin_unlock_bh(&act->tcfa_lock); goto err_out; } + +int tc_setup_flow_action(struct flow_action *flow_action, + const struct tcf_exts *exts) +{ +#ifdef CONFIG_NET_CLS_ACT + if (!exts) + return 0; + + return tc_setup_action(flow_action, exts->actions); +#else + return 0; +#endif +} EXPORT_SYMBOL(tc_setup_flow_action); unsigned int tcf_exts_num_actions(struct tcf_exts *exts) From patchwork Fri Dec 3 12:24:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655045 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94D3FC433EF for ; Fri, 3 Dec 2021 12:25:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352150AbhLCM2r (ORCPT ); Fri, 3 Dec 2021 07:28:47 -0500 Received: from mail-mw2nam10on2132.outbound.protection.outlook.com ([40.107.94.132]:46432 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244531AbhLCM2m (ORCPT ); Fri, 3 Dec 2021 07:28:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cX5cX9JBcEG8JeTQDrXisTulPwwBSHq+5ymxITWhKROexXaX1lAxYfdpQIJdzu8RKZBh3HIlMh23BtW3HNqZl7OAvVdycAiQxnJJ8GvXSlfe+0fUsfLwmbm2gBt7+taoZC+xdq35E7bZB2QmAWU7koazwZ3DZ94vcjRePLOxKDkRBsKVCKiBKCwbIsvgRpol8TM8sF+NziN4LEdgDJLPDvbQJZtwwSfacUj9r0KcMtoR9adQ98BGk57ObX3NtQ8Ai3OUjlCvV/kfa5CaVdeWOC+6ux98vyzn+yE5/84AD3uxHUF/PKNZKVn99fU/XHXomvHcYigzfW9VV0W+/631UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b2OBkj9X5POozdYrp2fPiEE+HrGJUsKKXizHoCL0ZFQ=; b=Ebbf5qoSmnR/5A4ocXjoVBvruKOy1OB7C+ZyqC4ikcKJMq1sZLLlYj/feNH5fXipmQdJn/bjVvmoaWdJMD4HKCPy8SEHONCEg28xiw1mslk5tPvDt5xiyASAMov9j4kAYNkny+6E2kVAa5fRchYRAj4CRnY25W/Tcqd6dtwOpldb6szSSJY04PTX3HpQF5TzXfY7pHrWLM+5fb7EtODGo/XEQu00OzON//RsnZaW/XOqALQN9mhcOXYjasU6eflu1ET/u9OIqhPYZSaBtZKum6pw1m5c6YvDqFNgnHGhQMCI4S4nqGQAWmysa+ahwqeLimiH5kpAHhsljYK+rze7RA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b2OBkj9X5POozdYrp2fPiEE+HrGJUsKKXizHoCL0ZFQ=; b=TLSctekniCuzvlGdKw6eGTpZwqNpk2WEGSm5ALcBL3vCP3IiAz8Wmcv+nSH2WOnyuY5M+P/dh/PTYRMYz0vLzxdC+ih2yENzfySCeacTzfMHurRpvdEN3smwu7i7kRTHAHv4XMmql0kUwTc176a8NYFofWJA2uvydNZa1ul5exY= 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 PH0PR13MB5423.namprd13.prod.outlook.com (2603:10b6:510:12a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.7; Fri, 3 Dec 2021 12:25:17 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25:17 +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, Simon Horman Subject: [PATCH v5 net-next 07/12] flow_offload: add skip_hw and skip_sw to control if offload the action Date: Fri, 3 Dec 2021 13:24:39 +0100 Message-Id: <20211203122444.11756-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: deeed9e6-3fc9-4975-4340-08d9b657f708 X-MS-TrafficTypeDiagnostic: PH0PR13MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:568; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UXHDwLWyOMh2BBuUHcg0gjSIeUetyfk0UV/2RaD32PuLDnTmvT3S/8j7dUwzeVvFn2rhVN48j/56lMzrQ+fjjZQqOHgTHqMf2nT+GijTtDo743fAXxvS81uVixrTobngWGub0vL1t9shWW2sigpw2k+RuprEqUv5A+52B5pYoVQW8AApqAPt4XqiJaINmYCXUZ8/3RCz4AgzIOkJ+1grXwoo+8PYS9WmKwScuzwNCPgo//EHJWuLHKiF3Ajcc9uZ5RwJ3Ia9CFtSup5SnxXiYzJyjOHDSgMWxbG1vZAwNZx4fe1cSCVgR/pwMDqohVC9oP3DuHUybV2bWUPlCvCkc/QWnMhLHq4fpgYggtZfxSRHuCy9G+2SZs2pG+E2Gan10sYsx4JSZtHWM5JgI95GZvOQtltiXaA2Be73Bche9mPsK7b4gGZgRjnoQ5hhYLLq8yL9ywA1gwxxbeZobspm+SY7ETNJHL2/K6uwBA6vQRKtbW6+fhpm9LiWDgH6D/K9xSRknjKXBwzW+CCSXnFCxglOU9w2dEvK9a36NVZXbfw6uZk3hS6fWE3bIOIL2v7l6gfaK+wkt8jgB53E3oLmtEFRl4yJyj9JyLOWYyFCaYWlIgZR0Sl/duwtBJyNjWxlNNn5QldTPDqlQBWuHmjQ1eD0YLDtbMdv2fMu8quUIKU1EG8/0BrwbNKruJPKhtO9L/iegVDtNab087/wHDGs9A== 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)(366004)(346002)(376002)(396003)(136003)(6666004)(8936002)(38100700002)(2616005)(6506007)(4326008)(66946007)(66556008)(8676002)(36756003)(186003)(316002)(1076003)(44832011)(6486002)(508600001)(66476007)(5660300002)(107886003)(54906003)(52116002)(86362001)(83380400001)(6916009)(6512007)(2906002)(309714004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fnCkdSsVaRo3z3tihPqAXSYJTvO6x6M/k85HTHAzQNjFyaRGYQrJP08t6FxVR3sb6Xy0SX1xzrCC98XwbQOPnj6TDB3Ygb5B2ZSO76Ietc7ljGndRLDJPQuOMnDZd+W5aoZxd71KKT7WiLay1+63qaJAFnEoIDh/b0EFcm9prTebeOPWcjnJKTe3kPWHXdncDGwblvFQPltO7JKpZt5XL3cXbllZKp218rPQ1qT1Gfs6asOtnr7c5oN5wHOJL81GyYWNsqoqnnUQVS8KamXM2u33+VJWX9iZznd9eBfxpb1zsjZ5qzpLz4TkXDVNigOGbwDAUQZF0BYei4l3EiaidTHaygRTo9fV+o288jccgcjf2IlTvgGQ+2G6iMttWbTj3UnxbahKX77a96WQiwwIsJ/jWyV5t79op2r961gp1z+e7GdSYl07pLebSiBP3g/eiG6saL+6Wpez5wkm81gp2tpliOBjTX+HOdE/87iJ6POwPd0UjZpX3EtdZ4BEsuyJ6MUViIBWB1pOYu1FePPxdaMvryPVCmvkYpoKo2VMXGeUzxy0uwwbYBNQOLM1ETg/Y5mKj26oeHF6Zr3rLtXFbVMzwLbDwFdAZpskYpEHhjl+eokLE7jMstUmFQX7/cbkLHecYK5v++0cu94KAoAFDrZl9YF7xgJBr53trqoKEgTLh5eI7nhIX9WYLKVf4S9Iz4z4sfbVqXtbS0PgV5l6bqmiaNl9HvoFeaw4WHhAiqYjNS69XY+Kdu+4tmx83Uh2z+rTV0vHsYMUsJrlDznJGfKK+JEeLeCALS4c8V9DhmnueYE5Epo/XlR+VssK53ReFThepbIJQMmGsAdsJ948wPJ4WNBmwL+5C5F9+dGde9jMM3kabCnWbMhdALS7hP4hBh6kTjWCB7114Q7wVXhADE4rQL9O8ORZ7GZSghTblfqedH0hnNo4ySJnybas3+R4tORHIHwoFjfsUV4C7rpRnq4tqSxCqWy/faQrSu9fifAdKKJQX4Y+PFPVIs63rgD/rQT14EP3oI6Y912si+ZF31B2mXvLt+z5p/J8E5Y1xUKOcvzsc2K7HR26Jns6z/P+sFFWgM2GExGNgv02o8aesPCEuaOIoiZzUX4sQ/4WOT3lbFV96vPVEB/2gaXpqry7VjvJ/zRveaVmuPc9EH2nt4po2/LwV0nMSaOvRITDN6EA7C7vuRR082/Id1yqh4meNqi0+u5aetsL/mUm6EH/2IQH8vc7f+LHRQ5+NyOThjlW3S8eUzVBwEepZdbzi35rVT/IlqMKYob5vFW5PXgzwd/mrmLfs53XjsKItBIaHbJ+OuJuxe4uY2m7ga55e3xse/A+Rk/rwRe7j91yNG/CHejQvxhXULS66FdXIPW+GyBZK/hzTCrQbekx67lTkJbQftfqUFT8p1reCgIjB7qM8Z6Sig5rX7rS/9dfDHKnNdIJ9nw07QJxnaUVCR91ULxuZXS8BoPuII/VJjMOMZIWHSCOkbThYj9FMzko33yo3pxPdV8exNwnf7ufkO793nAr440h+Ivr46orQE4gtYOF7eT/LSlU0sovcFNmm6C139EFQFdqnG2X/eEJGb03NIU8rR428N18JJ2dKqlw7LR+9AXzh3jFr8ad8cUnszOum7RXzlE1SHqFUHnpKzgYHqanVbiqSfdBH9BMQVfnFibFSOM0fq4/whk8oiQW1GZXE7CZ0wct965cDf5gUceEMFp1uMVs4aQnEq0LQa6x4wtKUYHBpoL9mRDFYpYDYYGtEas= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: deeed9e6-3fc9-4975-4340-08d9b657f708 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:17.3784 (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: vFh+fankTopdcMolOWVa3R7S6U6pMVl4KZv2qgDpAB9rxwVb1uxFS8f4u6mkWlD1O0TylGje1hsPTzzVvkz7nKQQpLSoVzg4Jfya7Zdrhf8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5423 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 | 1 + include/uapi/linux/pkt_cls.h | 9 ++-- net/sched/act_api.c | 83 +++++++++++++++++++++++++++++++++--- 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 73f15c4ff928..7e4e79b50216 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -44,6 +44,7 @@ struct tc_action { u8 hw_stats; u8 used_hw_stats; bool used_hw_stats_valid; + u32 in_hw_count; }; #define tcf_index common.tcfa_index #define tcf_refcnt common.tcfa_refcnt diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index 6836ccb9c45d..ee38b35c3f57 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -19,13 +19,16 @@ enum { TCA_ACT_FLAGS, TCA_ACT_HW_STATS, TCA_ACT_USED_HW_STATS, + TCA_ACT_IN_HW_COUNT, __TCA_ACT_MAX }; /* See other TCA_ACT_FLAGS_ * flags in include/net/act_api.h. */ -#define TCA_ACT_FLAGS_NO_PERCPU_STATS 1 /* Don't use percpu allocator for - * actions stats. - */ +#define TCA_ACT_FLAGS_NO_PERCPU_STATS (1 << 0) /* Don't use percpu allocator for + * actions stats. + */ +#define TCA_ACT_FLAGS_SKIP_HW (1 << 1) /* don't offload action to HW */ +#define TCA_ACT_FLAGS_SKIP_SW (1 << 2) /* don't use action in SW */ /* tca HW stats type * When user does not pass the attribute, he does not care. diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 120e72d8502c..1d469029f2cd 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -131,6 +131,12 @@ static void free_tcf(struct tc_action *p) kfree(p); } +static void flow_action_hw_count_set(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count = hw_count; +} + static unsigned int tcf_act_num_actions_single(struct tc_action *act) { if (is_tcf_pedit(act)) @@ -139,6 +145,29 @@ static unsigned int tcf_act_num_actions_single(struct tc_action *act) return 1; } +static bool tc_act_skip_hw(u32 flags) +{ + return (flags & TCA_ACT_FLAGS_SKIP_HW) ? true : false; +} + +static bool tc_act_skip_sw(u32 flags) +{ + return (flags & TCA_ACT_FLAGS_SKIP_SW) ? true : false; +} + +static bool tc_act_in_hw(struct tc_action *act) +{ + return !!act->in_hw_count; +} + +/* SKIP_HW and SKIP_SW are mutually exclusive flags. */ +static bool tc_act_flags_valid(u32 flags) +{ + flags &= TCA_ACT_FLAGS_SKIP_HW | TCA_ACT_FLAGS_SKIP_SW; + + return flags ^ (TCA_ACT_FLAGS_SKIP_HW | TCA_ACT_FLAGS_SKIP_SW); +} + static int flow_action_init(struct flow_offload_action *fl_action, struct tc_action *act, enum flow_act_command cmd, @@ -155,6 +184,7 @@ static int flow_action_init(struct flow_offload_action *fl_action, } static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + u32 *hw_count, struct netlink_ext_ack *extack) { int err; @@ -164,6 +194,9 @@ static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, if (err < 0) return err; + if (hw_count) + *hw_count = err; + return 0; } @@ -171,12 +204,17 @@ static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, static int tcf_action_offload_add(struct tc_action *action, struct netlink_ext_ack *extack) { + bool skip_sw = tc_act_skip_sw(action->tcfa_flags); struct tc_action *actions[TCA_ACT_MAX_PRIO] = { [0] = action, }; struct flow_offload_action *fl_action; + u32 in_hw_count = 0; int err = 0; + if (tc_act_skip_hw(action->tcfa_flags)) + return 0; + fl_action = flow_action_alloc(tcf_act_num_actions_single(action)); if (!fl_action) return -ENOMEM; @@ -192,7 +230,13 @@ static int tcf_action_offload_add(struct tc_action *action, goto fl_err; } - err = tcf_action_offload_cmd(fl_action, extack); + err = tcf_action_offload_cmd(fl_action, &in_hw_count, extack); + if (!err) + flow_action_hw_count_set(action, in_hw_count); + + if (skip_sw && !tc_act_in_hw(action)) + err = -EINVAL; + tc_cleanup_flow_action(&fl_action->action); fl_err: @@ -204,13 +248,24 @@ static int tcf_action_offload_add(struct tc_action *action, static int tcf_action_offload_del(struct tc_action *action) { struct flow_offload_action fl_act = {}; + u32 in_hw_count = 0; int err = 0; + if (!tc_act_in_hw(action)) + return 0; + err = flow_action_init(&fl_act, action, FLOW_ACT_DESTROY, NULL); if (err) return err; - return tcf_action_offload_cmd(&fl_act, NULL); + err = tcf_action_offload_cmd(&fl_act, &in_hw_count, NULL); + if (err) + return err; + + if (action->in_hw_count != in_hw_count) + return -EINVAL; + + return 0; } static void tcf_action_cleanup(struct tc_action *p) @@ -820,6 +875,9 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, jmp_prgcnt -= 1; continue; } + + if (tc_act_skip_sw(a->tcfa_flags)) + continue; repeat: ret = a->ops->act(skb, a, res); if (ret == TC_ACT_REPEAT) @@ -925,6 +983,9 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) a->tcfa_flags, a->tcfa_flags)) goto nla_put_failure; + if (nla_put_u32(skb, TCA_ACT_IN_HW_COUNT, a->in_hw_count)) + goto nla_put_failure; + nest = nla_nest_start_noflag(skb, TCA_OPTIONS); if (nest == NULL) goto nla_put_failure; @@ -1004,7 +1065,9 @@ static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { [TCA_ACT_COOKIE] = { .type = NLA_BINARY, .len = TC_COOKIE_MAX_SIZE }, [TCA_ACT_OPTIONS] = { .type = NLA_NESTED }, - [TCA_ACT_FLAGS] = NLA_POLICY_BITFIELD32(TCA_ACT_FLAGS_NO_PERCPU_STATS), + [TCA_ACT_FLAGS] = NLA_POLICY_BITFIELD32(TCA_ACT_FLAGS_NO_PERCPU_STATS | + TCA_ACT_FLAGS_SKIP_HW | + TCA_ACT_FLAGS_SKIP_SW), [TCA_ACT_HW_STATS] = NLA_POLICY_BITFIELD32(TCA_ACT_HW_STATS_ANY), }; @@ -1117,8 +1180,13 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, } } hw_stats = tcf_action_hw_stats_get(tb[TCA_ACT_HW_STATS]); - if (tb[TCA_ACT_FLAGS]) + if (tb[TCA_ACT_FLAGS]) { userflags = nla_get_bitfield32(tb[TCA_ACT_FLAGS]); + if (!tc_act_flags_valid(userflags.value)) { + err = -EINVAL; + goto err_out; + } + } err = a_o->init(net, tb[TCA_ACT_OPTIONS], est, &a, tp, userflags.value | flags, extack); @@ -1193,8 +1261,11 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, sz += tcf_action_fill_size(act); /* Start from index 0 */ actions[i - 1] = act; - if (!tc_act_bind(flags)) - tcf_action_offload_add(act, extack); + if (!tc_act_bind(flags)) { + err = tcf_action_offload_add(act, extack); + if (tc_act_skip_sw(act->tcfa_flags) && err) + goto err; + } } /* We have to commit them all together, because if any error happened in From patchwork Fri Dec 3 12:24:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655047 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CE94C433F5 for ; Fri, 3 Dec 2021 12:25:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352003AbhLCM2t (ORCPT ); Fri, 3 Dec 2021 07:28:49 -0500 Received: from mail-mw2nam10on2132.outbound.protection.outlook.com ([40.107.94.132]:46432 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244731AbhLCM2q (ORCPT ); Fri, 3 Dec 2021 07:28:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RD9VqbKU9OTIL5kKWEoPR656XdAQKJgLUvgxdzJ6+iTOlcJWPUURuxBrArrEsNn8TCk6YKHD0k4PqFfd8AWiTW0rOLQQSO9ezGnP1aYtV6MbqZnzlDF6bfG1Lawzx7OHoYYyQZwBfCcMfRfokq5C54WXoFWV3EWiaisOzrOLibwRdBxGwLBk86lOQm26oiTZBz0TFH15mCGDgc1fC3Qpu96IlbgODJ/wPC4+6Yndf9HGJl/kaN03GtC9D3JZ5fiGipltiK8zc2nyR7apHh6iq5gzyBw1BgPM5DrdSKmss4JQ/sw8NmR6pyRwXP3Da+wossqwPs3l9Lz3kprO18R1ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YK04thQSIKcMbJnQL2ZpOwKD9hwAAD3KhRtWiyq6MSU=; b=WJNZ4C2IrVH3pf5JTHKyg8TLamY+q6YDmHZ/ydxAntlabI0r/ok+csVHbJQ1iHM9Bc5yQWXIPqYvofKjAAZ+vHa5MrVQ2P+cJ0SWcAjaEPMf4yqYIA77Yl0aRdsCcp+LeDzLk6cMengmsa5ojdu3BhtNns0iGmci0i+bZQ8onswFiEs6H/iIX+qN4yLsbLOtIeo6ns3zpB9N4djxPddjNe5QHddcUVZJcupO/5QkHZX+Ycm4svAfZfJzclrPsUcCLE/Y1M0GOHi0Do6ZUZYfrITuht7uCAXIUbB53y4UIensD86LSRucGrNlNFulPcLPzuwF/k36mqgVMYOmlAXKqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YK04thQSIKcMbJnQL2ZpOwKD9hwAAD3KhRtWiyq6MSU=; b=k5gJfNgUce5fawlmBeOfDlZQyaCQPw7pExOl4dMN1/rfDyMPxjIq84AefC3WmELMO5QlyJpUFmsN2vD3i2g5IiTY0ANFPNg45r5Eaiu3LhNd5MXVQvB5+dztq6NpT+VpwR9Fi2GasW43QqZNNgPgAugC8bd7yroZnxzBVMCOFNg= 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 PH0PR13MB5423.namprd13.prod.outlook.com (2603:10b6:510:12a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.7; Fri, 3 Dec 2021 12:25:20 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25: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, Simon Horman Subject: [PATCH v5 net-next 08/12] flow_offload: add process to update action stats from hardware Date: Fri, 3 Dec 2021 13:24:40 +0100 Message-Id: <20211203122444.11756-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a926f687-94dd-4277-0b17-08d9b657f89e X-MS-TrafficTypeDiagnostic: PH0PR13MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:363; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZwZHpO4rNWrsFEVptrxL9g1A6+dfcWajWlOWag/v433wbmO0dxfThjntcyVWmG07zbhDQWpn7NHq/YQa8MWdwKCpSmy/+sbimoPoNz/cC546TyxbzSQkEHK5XjmHqIOhf2aNfwevZbAhUFXccMF5vrfoCo93o1W1lq3MAzs4AAPEkBRYeYJAtnDB1ei6i3DfGp5FLW4uxlZJsOWrX4IP6TNH5dmeTeAuD+CcVCsAJyxspHy+W0y9CBACsS7mCriILBqGpROus+cTnZ+Er8JeBltk1uyWMduViOXZbvibPsYO8U9qjUIA9EYsBYJEYb1ATgwHkhOm166xOfOmalRiMEUT4AjNjj8wYcSoU7Y0z4qHo+V+2e+NAEtUQpTOVBQkkC5vkY+2OIWW7YAii6xv1I0R4X0suwG/B9/RQfsGeX+uuRcw8MYpvzno7uQpkt/QOYwEhnnW5aKLQ3O+F2bq7lPfnu7Zw+Z/lIx5a/9bswcGZpWzAV6aY8WdDxA0nofEYOrheMt8kXV5wNJtbPbS3B5Y0yA9QQDKydyCfBPoezb8IC87qR2N2Lq1+rALMJzmT7HHLOejh9qM5/YUvC1gpv76hjwsPUE1wk/USpjHQHXOmSpsD3rdHqfeokIAZHGNYWiT50C7Jgckn+r9RxOXCQ== 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)(366004)(346002)(376002)(396003)(136003)(6666004)(8936002)(38100700002)(2616005)(6506007)(4326008)(66946007)(66556008)(15650500001)(8676002)(36756003)(186003)(316002)(1076003)(44832011)(6486002)(508600001)(66476007)(5660300002)(107886003)(54906003)(52116002)(86362001)(83380400001)(6916009)(6512007)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sTbTrKpROrlIj6XAEANMUnOFsylgSeKzlPiOUOrb7xvj+wGD38Qky/7B8QukOI7c+GqOyoek1wZugN8+7JnQQIa7P9hYnqGCfpcEPou2s00Brf0+LPwndfsfn98lytrwaAzSDQ1l7q/OD0H8LUprsSgbvMlw2Dx7OW+VPR0hwmu750vcv8NT1f+hcoY2UiVnfsP+dbQ2hBcN8j9T+GkpBwuNbo3UJUmR+RbN+Hib0m4uO0QvXjmmgtJNiYd9rWDMJSJiwlvLnph07S+EyzcpuQ7ehFbcc79VaFb3eQsZI1U4K3qef3vYuHK9xAvCZnBoCgMrhseFezTOqwwS48zuYg90NljZZg+jTwJ2YwxttYpLyWqFPm0ehkDnF0B7uzSx5JTsOX5XQnI0CeK1nL3K8iXm5u7UKHrzGW02DTklmCrOrl9N77+/BAgN/8giouoSnGIP8SJIZ442Z/EnqU+wkOMPpi6r/6XnSo7MAzXQMkQkyMMxuY2qp9kWZV9ei7FszjF2frSvuU8JWIg6xKi3cXv9/AhDhYf/9QdScyns9FJym+XlBrYfz79YPKyhyy8MY2hrruP7bQmyn3yxtTn0g/yH7Z8e1ZdGztsi2BMxZzhM2B4cRcTRnBxSkq5MGgyyCm/0cXGb2hg+Z6+ZcFI3EbVhPDNk7DH9qx1nCqVii23gO9W96xKYSv711ClkCWvwAvhaE8yAVOSBGJ1lRM9C9Yjg6dT1KyGlMUcjvSMYPz73LdVUg1Afx+2oImG+K+63l6RA/ihEHdHsX2lDoFwgNkXdEUyhzyr3z2LtESTe1YuLPE8fekScgWmy0b8mtm2rMb+GzTgfbnBRsZnZZs56q4+ayFUx3aak56oBrICMuDmgOfa5sRvvVFcqNcWdAOcZrn+E6GAW9TWmI2Evz8C5hcokWOo2YKU1XPp3oB3mdB0coNiyNMjpblaexQlEdZmpNB8ikA0QemaGB3gvjOvHFbIPtuy9JOPlqtAs7ZwrnA2QrE6sci7e2OEhW1K7pyUXdOMTqEYRjwwF/hdNGEvpUmp/lZd49oUvQP3ICIyUhqxF5aumARcKWreskvu78CqdycR37OE+2phyZSWlK6oUxFPg0jGyeEzJjDWRCafZ+dfygYlciYcLR82MlQWNotmhYlbVwKqVV6ewU82DLovG6qIPDyn5Vgk/84b1p04Fs4O8VOJgpc/V6xxhpNfp0wVjGfT2yOhaE5U8Gs/3YPjU0aY10rlNS0CluMHcWxUSjLzFWF06o1Z841Qow9tG+B+Iz0274n6iuidzZChifjwioC6XAqpPcGbpeSiHsPV3PsvWZZzpwyXjUjXqC2QNVL0w89feO0HwAef2FexI7hHVEhYLpurUrOdir6uQdNkqd7dI/OX67IcZGv99AjWjGC4RLdnl3yHo82MHBh+GN9LjNA2f2Ooizo5YxTS7ARNP+BvQ/3G2oZuN+I1bdk++a128KzQSHmKSG1EzoUP8mWLocqxjMhnlX1Fa+ZPjH+0XV2KpietWF1iLrzSq/XSs6z2SsnROAfMXfr4K7AEfRu9RxI/IDXYuINd6TjlABOSn3nLkfmfOszRgkZfTG+alsKj7dy8wJuu2eHC74qcevMVG9d92b47QggY5oOhi64oMk8d9Y25cEuKaaXEVd8ToJ8VMoDqdEW8tL1xVraWZQlTHQNk887Pg5vE9yVIWu1t1sO6YWJeSLtlvvubX7erORot2abQEfDHv6BwZzGb4C9ceSKqXLfhDGst2zxzK7Bmg1WU= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a926f687-94dd-4277-0b17-08d9b657f89e X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:20.1124 (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: BEqsvKGTjxyEPsyo/saEdsyEwaYaPD3tOCiazX1AvitNmO1U+32o5dtwpVE/ulYyltYQGczJl3q0PcgL4ypXLyymVfVIG+JX1RL6uuhONGE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5423 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng When collecting stats for actions update them using both hardware and software counters. Stats update process should not run in context of preempt_disable. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- include/net/act_api.h | 1 + include/net/pkt_cls.h | 18 ++++++++++-------- net/sched/act_api.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 7e4e79b50216..ce094e79f722 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -253,6 +253,7 @@ void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, u64 drops, bool hw); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); +int tcf_action_update_hw_stats(struct tc_action *action); int tcf_action_check_ctrlact(int action, struct tcf_proto *tp, struct tcf_chain **handle, struct netlink_ext_ack *newchain); diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 13f0e4a3a136..1942fe72b3e3 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -269,18 +269,20 @@ tcf_exts_stats_update(const struct tcf_exts *exts, #ifdef CONFIG_NET_CLS_ACT int i; - preempt_disable(); - for (i = 0; i < exts->nr_actions; i++) { struct tc_action *a = exts->actions[i]; - tcf_action_stats_update(a, bytes, packets, drops, - lastuse, true); - a->used_hw_stats = used_hw_stats; - a->used_hw_stats_valid = used_hw_stats_valid; - } + /* if stats from hw, just skip */ + if (tcf_action_update_hw_stats(a)) { + preempt_disable(); + tcf_action_stats_update(a, bytes, packets, drops, + lastuse, true); + preempt_enable(); - preempt_enable(); + a->used_hw_stats = used_hw_stats; + a->used_hw_stats_valid = used_hw_stats_valid; + } + } #endif } diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 1d469029f2cd..4e309b8e49bb 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -245,6 +245,37 @@ static int tcf_action_offload_add(struct tc_action *action, return err; } +int tcf_action_update_hw_stats(struct tc_action *action) +{ + struct flow_offload_action fl_act = {}; + int err; + + if (!tc_act_in_hw(action)) + return -EOPNOTSUPP; + + err = flow_action_init(&fl_act, action, FLOW_ACT_STATS, NULL); + if (err) + return err; + + err = tcf_action_offload_cmd(&fl_act, NULL, NULL); + if (!err) { + preempt_disable(); + tcf_action_stats_update(action, fl_act.stats.bytes, + fl_act.stats.pkts, + fl_act.stats.drops, + fl_act.stats.lastused, + true); + preempt_enable(); + action->used_hw_stats = fl_act.stats.used_hw_stats; + action->used_hw_stats_valid = true; + } else { + return -EOPNOTSUPP; + } + + return 0; +} +EXPORT_SYMBOL(tcf_action_update_hw_stats); + static int tcf_action_offload_del(struct tc_action *action) { struct flow_offload_action fl_act = {}; @@ -1317,6 +1348,9 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *p, if (p == NULL) goto errout; + /* update hw stats for this action */ + tcf_action_update_hw_stats(p); + /* compat_mode being true specifies a call that is supposed * to add additional backward compatibility statistic TLVs. */ From patchwork Fri Dec 3 12:24:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655049 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31D9EC433FE for ; Fri, 3 Dec 2021 12:25:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380773AbhLCM2t (ORCPT ); Fri, 3 Dec 2021 07:28:49 -0500 Received: from mail-mw2nam10on2132.outbound.protection.outlook.com ([40.107.94.132]:46432 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244687AbhLCM2r (ORCPT ); Fri, 3 Dec 2021 07:28:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k1QSvpxjSjpOBG8L80jGlt5p88/U8fSTYjLcfxlTHFedAp9w9dF1/QPGAC0mjwJ9Xxz9SvR3FbD8riiYsdj1zLQPUqnMae++yUtTbOjI4HAb6Ja5coNYrs7EkoYxzTRnMMlruf5VOa+FB7DQZHv1pMi8jssDutaIdcSRJITytu02Zjovzd7FdNfdppx4/QoTUywbXTDqRgKhDV/szCDNJPEgFOx8Hk10WWl6P7q5K0dubH74/AZzadrq7p5BMTtFu3fEOnn/bHqMVSBFhDWMGSkPPJKWUlRNCLrTRdck46cFVJJg/y0yJf82MlMGAL/Qz4r19S9z70sdRXrJQFGGBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Lh6WPemjbx317oyN9/BM6DLmJNvc13bAQG0u7nkGCDs=; b=X8RcUp2bmLM8FDT6NRQPR/YX1eLaLTxnTuoN6ExyH0rPsCKFnv82Rhxoq9X4jA20J6g4UUeGCLDV5qaEdjAqFEYh8soPZCge2L5UXbyhMo9+Qm3p70vTi3THxXs0GoN0OvOn1SDpB8BbAierRuNptREfwhjLx0xeh2dxUe4MomOzPpuinne9HURiTZYcXRH+ZfZlHMVO5EkMKZpUflFjuUGvYCSx2pWupG4g994zYLK8MdpfscvLOcu6Fk+yrZt4wb1klmHmdPoop9jRf/O0JQfnnxwEtHB/VOM3XfbKTsHqI0wLqWw6Eh9WfUTDkCO97D25BY53SUQ2HoCG6pQYYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Lh6WPemjbx317oyN9/BM6DLmJNvc13bAQG0u7nkGCDs=; b=dEMuawqGZyuY1GkOqUc/ppLXi3v2cAF3fmzuTTmSO98ByjOKeYF+sHzjVJUTQsunoZai5HEOLH8af8YiuyQ9WCkBO7wpEjrUPWgRsITotdMImuyda0ZWpnFvtHl39KnsGeYUUZ3C6bSqasz9lJJ98/zBTOdHCbPiGEeqWE0YTTw= 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 PH0PR13MB5423.namprd13.prod.outlook.com (2603:10b6:510:12a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.7; Fri, 3 Dec 2021 12:25:22 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25: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, Simon Horman Subject: [PATCH v5 net-next 09/12] net: sched: save full flags for tc action Date: Fri, 3 Dec 2021 13:24:41 +0100 Message-Id: <20211203122444.11756-10-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dde3ce8e-f4ea-461f-f8ee-08d9b657fa1b X-MS-TrafficTypeDiagnostic: PH0PR13MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KYWhsz/+NIictNN4vsOF3KT9l9Do7HDxku9Q76JYYozm/d0svitj7vaIBqSZeQ7ATKuxfCEpvNQbpNgNvfRk/QeHWU4zsK6L0tdy5aIvhFL0nJVe9hJeGP5jmk+tbXbgVUL9u+y7VsFX7n2vR44udMDGJ1IC0qgGWK9se5gWyMOzrhjKpm2HKa9hAdwEHdbNRuLrPNP1GwwtXU4cn2QCfJXcwi2AtuQsKhSIOMwE9D5NmC7fdeve8d6toEsgOcWVw3/BTwDUGnxDF2OkgogA3SJg027MNVH5ezq/on6/Pn/GdUxoT+nwXQAe6OnxvprJPo4j4UD1YdNxgqtivAmTWMkzrHGkCXk6LjvkRY+OL3sy4ebtDm7uL0DHSIW3y/ZyfAxLAwRIOdHMkQ3f5Cjzh4lZtya7DusAoQ11bjjAbN/enMMa0PRHNJ0VhgAuv90aQQ5/X9LFA4NNfWWXEoQdOiZhEmEoPs88SVeEzsxqP7syTZpFXmDNDzto0X5MIACcLmHC2gtpmV2D7mP/+bwCx6Zu4rJyCdri6Rv/VmgJ29ZyIoHfmxH9xywy05qPFGhIu85S6ne3GdzteEZ9E+D4PqEmhPJZMitM/DC8WbsnfI/fJHrXLyL0Hoc4q+M3zKnpd0itEnr/hKvHV+ZwgB88Jg== 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)(366004)(346002)(376002)(396003)(136003)(6666004)(8936002)(38100700002)(2616005)(6506007)(4326008)(66946007)(66556008)(8676002)(36756003)(186003)(316002)(1076003)(44832011)(6486002)(508600001)(66476007)(5660300002)(107886003)(54906003)(52116002)(86362001)(83380400001)(6916009)(6512007)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c6ga1W6W9aYM3HsEcwyB1ovxgjS0DEHtyWJmAZp0jdPKxqEVRP0QFvRtFsQxchg7692doQ0p4XIWrylXBMDPhszfB6IVBe4vAzEXxHAF9DIc32QN5YtGDiv8yMBBYxcmI0cqEr1Kd50vpPHycJATXL+WtqQ0/Y+wKogopRQqr5ZeHVfJ5B1OusvphcIXVAIUjRldoI2Yhyb2/t7/ncS7YRm1MEEYbvH3BSSEgiO3hxKKZf7cdodITbCWhuK25swKq+Yps2yBj/JKlLEQ6KidmUlTUszha3bUpttcC92EsOOEMaBzG52rrlPO+UmEGoqRxf2XWTQ64PuVMsKqh8tTpJTvREaMC0BxHi3OIyj4jBYVtLKc42sZWiuN88HYGA+cv8UaYrr8Jtc/ZufyosdKIUMbCbAYzlEXYq6GETGMaNq35vTZtvskoEB84902MilXqoVpCM0lQnwl9jKx7r0oFJkSxSjBbQWM/BYExHVKZOFbXirXeSniNjtMBRediSxlTZPW2lM/3uODr/kcPKPLzvAifODYBC/RyBQOAYg4f4HxgMgGGu0ZhQaKWEeifl2bOHGiqwAHsxkKDZIFSo19UhhZeQTE1loJwqASbqPPkfohndEYGoCtS5XO8/LaxVhqbk3FT1ZJd8FFff0oIwZjnKnjd0DXqbL5FzvmRB4swRI9HvfAoiEhxvCHCAcMb29TS0IO+7yP/0mY8MeQjlTBJxtZ0PmutuyBU9bBcXhvmiY4vnMvBMXjNdrTSae9ajX6g06orL1rbqzH2hA2MwC2xfvwy4A5RloYw+NzSyPyZPtHQTDMWisQvFtIgLviKEH3oXx9pzK0VTbnFFu42fZCIUcGBjBnA/1xRGOgoPeJ+bETqm8DzevJp6iRSrWopDxvyK9voKzAvvc+TPfSeWY/cnViS3wWw22NOpQq7k86yUyV19E2dVnAVj7vo1NHwU3aEmSmvoy7H2rO+r2x++VNeLx6Ej/OANIPASdutmbMA5LY2GzqoyGJwAuk1whmL7UUjDNxerQdHLy7QrbLkvxwMCdnYKkKW61XTu4ZvTkjUS/9/HXWczBPEwJoaIgakCUtslurTiAvUReKa8bqxUr8uimdnSAItbhFi4aKqsU3lleEfWqsVyroUON0oPfsW4hVYNYeILIJ//8fsC5aFiL4p6i8gLkpGWX5D8GVhxP0rns9Wr4s9/lqzRe45nKymwn81m04ZtOLtUnxd1avbG2Za252iiNH2md66Ug5nORNeBaY0BqO6V6DdHXdYipETF6tf4pVwxASBB6ac0FdTHyooBRtfVUQwi+/AbdFkferkaTndb0kMZ/c1m01mmRyUuU+fSzbpJSe2Ezv6x+2CCVZOOVYH4GwE5XgkiUAjTrEmccHD3+lZSX6xG+JbjGQDm6IoUdChWCnJssKnuMc0goC3i0WF7tIc8ONz4mdqA/I7nmmnGabY/oarKmMKbsl0PU3vGoMVUtE+KyO+VOva5L/CM/McoP2vWgDnG9UHHyX5PU10KxXtaTQWe8x9RolLo7VAf2cw1PIlvLqh73cWKYSZoSQwF8jgfoyEVwVS5/ew74XDyGxGOx1HYc+IGPH4nuATGkZvmEidAwAvzRtiEvf9p4F8Qy1Ksia9TYYx3ls/pujcpI+3fPxZ3bZZudmiDnyi8Fhm8HARB5q4/yvZaN/xvQKicrvOQUgPbsbxlD/hKUf28gCqi2KnxZnoRorJSM8foMYUibWstA71oW+gcfCUVvBa2NekP2fiaxOw3mu058= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: dde3ce8e-f4ea-461f-f8ee-08d9b657fa1b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:22.5327 (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: //RQ3ZyeNIgMTmEIgCk7sCsUJhwCEOYRAqRiKGcDb485+25F7UBZUjdC5ll1zpKwEdwaVXrKnQS66f/IFho1GaXcag5OqCR00XEDmjQH7gM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5423 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 4e309b8e49bb..e11a73b5934c 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -668,7 +668,7 @@ int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est, p->tcfa_tm.install = jiffies; p->tcfa_tm.lastuse = jiffies; p->tcfa_tm.firstuse = 0; - p->tcfa_flags = flags & TCA_ACT_FLAGS_USER_MASK; + p->tcfa_flags = flags; if (est) { err = gen_new_estimator(&p->tcfa_bstats, p->cpu_bstats, &p->tcfa_rate_est, @@ -995,6 +995,7 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) int err = -EINVAL; unsigned char *b = skb_tail_pointer(skb); struct nlattr *nest; + u32 flags; if (tcf_action_dump_terse(skb, a, false)) goto nla_put_failure; @@ -1009,9 +1010,10 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) a->used_hw_stats, TCA_ACT_HW_STATS_ANY)) goto nla_put_failure; - if (a->tcfa_flags && + flags = a->tcfa_flags & TCA_ACT_FLAGS_USER_MASK; + if (flags && nla_put_bitfield32(skb, TCA_ACT_FLAGS, - a->tcfa_flags, a->tcfa_flags)) + flags, flags)) goto nla_put_failure; if (nla_put_u32(skb, TCA_ACT_IN_HW_COUNT, a->in_hw_count)) From patchwork Fri Dec 3 12:24:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655051 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D3C9C4332F for ; Fri, 3 Dec 2021 12:25:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244687AbhLCM2u (ORCPT ); Fri, 3 Dec 2021 07:28:50 -0500 Received: from mail-mw2nam10on2113.outbound.protection.outlook.com ([40.107.94.113]:9754 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244538AbhLCM2u (ORCPT ); Fri, 3 Dec 2021 07:28:50 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=avHOtRwzPPoQRWAwxoi9V6XgVJ+SRIjUg6Vi4K+iLq+oDy2a88Hkz+Q32HTo6ftM2Nxl7ZfHCwzqLufb0uqiT6vZy3h9Oim2lRVBLO5nOBRV/jDEqblg1p1enpmJ+ew3aWsciOHDPQI2GRTCJJG3Z5ljoVZtqwswnuCvWkE4gEA9EzC+mIHStMmkeqcArQ67l8tKos6tnl4bCcVoZD8ZxS3Bw9Fkq9Z7wuLrgtDYo1L1PJNcLfzOM1f98ox+mGIeaa2+AXtC6mDGctZaVPVcZ7jRzR5v3kLHkbLObdaXpxVn1qCfP1bO29cvFAJwlAdJB7otNLzbyFNFQ2zlOz4iNA== 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=LGg9bi+IKJ99qOlGxEQbQgloJRsSsZ3+7gSZrBfAdMM=; b=TzT+39/O/3xi3/xsG2aDwGYYpCvzkwwHuiqy0pSmsPr3ec1lwvr9+T69PW7c7S0tBvjcT6R8YModKK3VVFka5J2jfU93SoMTnMFx8K300/exRemgG/2Jzaf76jK/MLVD0FwspMPPipQhmoamJbd/orDuOzMAZizMdhBM/E7NSuXIcRNFzSW5fsBRXOyBnrmhTc5skZjXoru6RKPay1r9YuTPymjPsmfP/Ilq12m0g/2k+cAAfANfoAjrc3+jD3FsUKZFttBzPyh6b92rIxm5zvKpezGTobdRSzHlMlMIeBec+HSRFcRZmSzx4vzISO4fuH2rqNW2OgbMDKv1zFEmow== 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=LGg9bi+IKJ99qOlGxEQbQgloJRsSsZ3+7gSZrBfAdMM=; b=VvtUlBsa56zsWjBokofBtJZtmtswTjg6ZL4OU9cpsb9bShjQoVWztLS+payXLkklQ8LpTia7mCJujYUl5J7PGEk14Rln9AHXX+QsJBPrwfo3uJKSxsaRECB3Bo7lykoldYYHhqIGuloZd1RnM/KdvEfvcNOTBonITH9BwbwiKcQ= 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 PH0PR13MB5423.namprd13.prod.outlook.com (2603:10b6:510:12a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.7; Fri, 3 Dec 2021 12:25:25 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25:25 +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, Simon Horman Subject: [PATCH v5 net-next 10/12] flow_offload: add reoffload process to update hw_count Date: Fri, 3 Dec 2021 13:24:42 +0100 Message-Id: <20211203122444.11756-11-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75ff977e-c589-4452-dfe8-08d9b657fb8f X-MS-TrafficTypeDiagnostic: PH0PR13MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +ufPpXjqJPsCkbPTZryqIIN6AFV1pujljPphgUurYTsop8HRKM0MrTh+a7GgEzVgjlUDja3yeaA2pvkinMemzfxaBIiYsbnVuoopFU+r0vJlOQfMrkH2Yvawu/98U0bFDbtwiboSJTrNXykfHnchXmqABTI+L8GMfWe0wXQ4bxAN3qLqztdIwHdrZMsCktFZ/R7XnQZSLNF2dN1VjbBaqI1hHCYSSKsUUp5DLVUWQCvOllPrbT61tCa1JonGJzFsS5hxdFOQQLxRdE+LfNUcpNTqDyPk9pMyV2izKQJq5ZgyNhEDN0EaFNLFza6LNDYSnAay7PEgtGrPqocX7dywqNumcTDskknZASpjZ1Tr5Ei9pcaj9dspEPBGHluLucMdaO7bAqU6WPGGlLf12OVq0sGdfwBKLdTv/Zgxl84SOo7SIH4Hb3FrXZVkD026CV00xdQ1vX71ZOtjcknH+KaqbQVpst6yJJiLGKp8N06hWtvbty6esN+ZQ6c3qLR0TqWOe1L0BN0wE78oCcpyy/iByiIK9ZgCnwr74ok8XT8vgx4C9v19swWxskM9hsBSesotZKyFLCjoXocGTEC/lL6HNHtYUjamYqvCu5mcViks4wpnM4j4mN9jDp9zvP9Eg/o1je7mvwuwNa8i9atTPRTNjw== 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)(366004)(346002)(376002)(396003)(136003)(6666004)(8936002)(38100700002)(2616005)(30864003)(6506007)(4326008)(66946007)(66556008)(15650500001)(8676002)(36756003)(186003)(316002)(1076003)(44832011)(6486002)(508600001)(66476007)(5660300002)(107886003)(54906003)(52116002)(86362001)(83380400001)(6916009)(6512007)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CeHgHQ6clOASSpCcs9VE845vSXkkZxmUoYyRxzoKNsV5+wQ+V6WxWPWtQQr3dEtFKu8FLHNif7HQE5Ce4tm8RHcdmdjP5AXkADdlb+bbrE+l2jkXvGDtK3ckTlhejF3wBXNLvlf2EEjuBu7nNU8DI4KksOCbxf5RaiBramCxtBvkJL5f5yNQRqc3m0UwxPxMhsny1c7TLkDWtxw5mMgJzWL0+lfMfnMDwAVKBwsU10Mel/cKFc8MpQg2bi7C/QRNk4spMjMjXFoghk/ra6kVKAE/Fnkq3y2z8fTPp/FqA9xwE+EtkV8IJ+SEurZc9rtAYuikJsZtf0EenhSiYc3QEpanwbHnToLJUi6IqI8j5Z4Viyi187/BXVHNk6nVnd8LJi+C9livB+ZD3H/s9oSWL9PYlFNFVTOzSGoVJPTKCodJxcGxEa4iwA9iOOTvMBEgi/JKfBbH+abMF0s8fyLR22DaAfF/5TmJ6HiM1cUKnZy5MmkMiv+B0cNFaVq8Vnq5Wepw9kU7jT3qiNLyh4n2tVOs8n7kwzZF269Bzw3sC2+Ei29QUoU0R7EbXFILMobaCAfDz0PnN1VM2gWABz3cQi7tbBK/o0pTt1eJbhii/EMSUHDLuIIm1nADqvPw/kHQtUBkSeEdm8roqRQhTx13/Ww7bH3aYeGc/B4zND8bhAe1mo21cj1IQlEdxoiWE4zJiO0QnTHWcIFplnBCvsJuifUZETIh58HX9dCahv+6LmVPb0ctHqzPMQ0cbZkT/KsQJjdFZSF7UiGTj8kLaQR/Z+ihDx9D4mZpSvl05O8a1PfyB8okEFIVwgjSblZBtvBp2u0YxWQdOTg3dQqPLRM2yvoR8hCR7n1M3oj/NAt+NHOOq+gq6Hqf6KXhPrh67LwGdgFEFcKq+0RSp2LFat6RIad8goYw9ZFRCsd/h99DdTKQz64ICgP3FTAzZwG+pB/vcXuCcrye/jr/U6oO9s7fgbsPdrKRRiRnCi0r024p6YIbK2rBFxSOOpw6qzY83052/L4QPfRoQx6mY1OGwcVuAV7fdUOic4FzEcFazjW9krjKhCIGeg45kL8aPJL19F+Fd2jfgizBjai2/Bft4h3OxGhXj6jBUv9PN5lRF+L9fi7n90KaYpWNBN+iRNPUA7JvUBtNxZd4VI0yM2VDCLfs3tOEdOM78bvI7GG5qnoU+09xFJMvyGi5SNcFnVLjlXYbLe6VK3e1fR566X7Nt6OkA+riMw/onzH3r0hJqMENLtquNW14UqvBtGa3kGOd2kZTe5esex3X70PZV3+3dX91Z1u/LI+zAh/WL4Ir2wA5vHkomCuqcSwzf5bzm/QMJwnKphtDE/PLP9lymZtTUDWgJ4Hqdrm5ta41fjMeqm14SeM2qNRL1GGCCj3ujRFMsxHOt/+RZQpn3zvymmE1vXyhETGG/7rsLQsLRCrTCTa3QBeXn2rFKyS2/6Ap46OklQJmDYgyTWGXp67os42cXt1J8Ksr9bTFZX8GaAUPwyu3PVIujuxDn8WT4ETGzCM8XF9M+7MaNuhEy6EiLXLXFRqkdBr84xA3QwirxkLA9yE622tLAQCxLzmRGam9jLXT/R2mXoZFyELDFi5s7RWSVqGduE0S/yuuVKl6Go/r7N/IWgB5I5dr8LvqOrildR7ducfM8qCzhwv3M/2x7z0JJOL8AJ4E9COCHoLuC32Umr0JdJVaUnI+HpnoJ3jFTQAmzoY+73vABQe/c/SfgKZQPTdalyXnKj3BREkfrIZYybDqWkc= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75ff977e-c589-4452-dfe8-08d9b657fb8f X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:25.0298 (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: he/+YfZkRSX+tp7Iz+ChBqmq/s6b1l9FPiBUoDnGoztqaSqdSK249632I/grjt5oz7BKxUdgNQwtxmG0NJsT9EMf3CALyK5dugvxD0j+tEk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5423 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add reoffload process to update hw_count when driver is inserted or removed. We will delete the action if it is with skip_sw flag and not offloaded to any hardware in reoffload process. When reoffloading actions, we still offload the actions that are added independent of filters. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman Reported-by: kernel test robot Reported-by: Dan Carpenter --- include/net/act_api.h | 11 ++ net/core/flow_offload.c | 4 + net/sched/act_api.c | 249 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 248 insertions(+), 16 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index ce094e79f722..87ad1d3f2063 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -254,6 +255,8 @@ void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); int tcf_action_update_hw_stats(struct tc_action *action); +int tcf_action_reoffload_cb(flow_indr_block_bind_cb_t *cb, + void *cb_priv, bool add); int tcf_action_check_ctrlact(int action, struct tcf_proto *tp, struct tcf_chain **handle, struct netlink_ext_ack *newchain); @@ -265,6 +268,14 @@ DECLARE_STATIC_KEY_FALSE(tcf_frag_xmit_count); #endif int tcf_dev_queue_xmit(struct sk_buff *skb, int (*xmit)(struct sk_buff *skb)); + +#else /* !CONFIG_NET_CLS_ACT */ + +static inline int tcf_action_reoffload_cb(flow_indr_block_bind_cb_t *cb, + void *cb_priv, bool add) { + return 0; +} + #endif /* CONFIG_NET_CLS_ACT */ static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes, diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c index 31273a10086e..5538b289cd54 100644 --- a/net/core/flow_offload.c +++ b/net/core/flow_offload.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include #include +#include #include #include #include @@ -417,6 +418,8 @@ int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, void *cb_priv) existing_qdiscs_register(cb, cb_priv); mutex_unlock(&flow_indr_block_lock); + tcf_action_reoffload_cb(cb, cb_priv, true); + return 0; } EXPORT_SYMBOL(flow_indr_dev_register); @@ -469,6 +472,7 @@ void flow_indr_dev_unregister(flow_indr_block_bind_cb_t *cb, void *cb_priv, __flow_block_indr_cleanup(release, cb_priv, &cleanup_list); mutex_unlock(&flow_indr_block_lock); + tcf_action_reoffload_cb(cb, cb_priv, false); flow_block_indr_notify(&cleanup_list); kfree(indr_dev); } diff --git a/net/sched/act_api.c b/net/sched/act_api.c index e11a73b5934c..ec80b5411a62 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -137,6 +137,19 @@ static void flow_action_hw_count_set(struct tc_action *act, act->in_hw_count = hw_count; } +static void flow_action_hw_count_inc(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count += hw_count; +} + +static void flow_action_hw_count_dec(struct tc_action *act, + u32 hw_count) +{ + act->in_hw_count = act->in_hw_count > hw_count ? + act->in_hw_count - hw_count : 0; +} + static unsigned int tcf_act_num_actions_single(struct tc_action *act) { if (is_tcf_pedit(act)) @@ -183,9 +196,8 @@ static int flow_action_init(struct flow_offload_action *fl_action, return -EOPNOTSUPP; } -static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, - u32 *hw_count, - struct netlink_ext_ack *extack) +static int tcf_action_offload_cmd_ex(struct flow_offload_action *fl_act, + u32 *hw_count) { int err; @@ -200,9 +212,38 @@ static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, return 0; } +static int tcf_action_offload_cmd_cb_ex(struct flow_offload_action *fl_act, + u32 *hw_count, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) +{ + int err; + + err = cb(NULL, NULL, cb_priv, TC_SETUP_ACT, NULL, fl_act, NULL); + if (err < 0) + return err; + + if (hw_count) + *hw_count = 1; + + return 0; +} + +static int tcf_action_offload_cmd(struct flow_offload_action *fl_act, + u32 *hw_count, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) +{ + return cb ? tcf_action_offload_cmd_cb_ex(fl_act, hw_count, + cb, cb_priv) : + tcf_action_offload_cmd_ex(fl_act, hw_count); +} + /* offload the tc command after inserted */ -static int tcf_action_offload_add(struct tc_action *action, - struct netlink_ext_ack *extack) +static int tcf_action_offload_add_ex(struct tc_action *action, + struct netlink_ext_ack *extack, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) { bool skip_sw = tc_act_skip_sw(action->tcfa_flags); struct tc_action *actions[TCA_ACT_MAX_PRIO] = { @@ -230,9 +271,10 @@ static int tcf_action_offload_add(struct tc_action *action, goto fl_err; } - err = tcf_action_offload_cmd(fl_action, &in_hw_count, extack); + err = tcf_action_offload_cmd(fl_action, &in_hw_count, cb, cb_priv); if (!err) - flow_action_hw_count_set(action, in_hw_count); + cb ? flow_action_hw_count_inc(action, in_hw_count) : + flow_action_hw_count_set(action, in_hw_count); if (skip_sw && !tc_act_in_hw(action)) err = -EINVAL; @@ -245,6 +287,12 @@ static int tcf_action_offload_add(struct tc_action *action, return err; } +static int tcf_action_offload_add(struct tc_action *action, + struct netlink_ext_ack *extack) +{ + return tcf_action_offload_add_ex(action, extack, NULL, NULL); +} + int tcf_action_update_hw_stats(struct tc_action *action) { struct flow_offload_action fl_act = {}; @@ -257,7 +305,7 @@ int tcf_action_update_hw_stats(struct tc_action *action) if (err) return err; - err = tcf_action_offload_cmd(&fl_act, NULL, NULL); + err = tcf_action_offload_cmd(&fl_act, NULL, NULL, NULL); if (!err) { preempt_disable(); tcf_action_stats_update(action, fl_act.stats.bytes, @@ -276,7 +324,9 @@ int tcf_action_update_hw_stats(struct tc_action *action) } EXPORT_SYMBOL(tcf_action_update_hw_stats); -static int tcf_action_offload_del(struct tc_action *action) +static int tcf_action_offload_del_ex(struct tc_action *action, + flow_indr_block_bind_cb_t *cb, + void *cb_priv) { struct flow_offload_action fl_act = {}; u32 in_hw_count = 0; @@ -289,16 +339,25 @@ static int tcf_action_offload_del(struct tc_action *action) if (err) return err; - err = tcf_action_offload_cmd(&fl_act, &in_hw_count, NULL); - if (err) + err = tcf_action_offload_cmd(&fl_act, &in_hw_count, cb, cb_priv); + if (err < 0) return err; - if (action->in_hw_count != in_hw_count) + if (!cb && action->in_hw_count != in_hw_count) return -EINVAL; + /* do not need to update hw state when deleting action */ + if (cb && in_hw_count) + flow_action_hw_count_dec(action, in_hw_count); + return 0; } +static int tcf_action_offload_del(struct tc_action *action) +{ + return tcf_action_offload_del_ex(action, NULL, NULL); +} + static void tcf_action_cleanup(struct tc_action *p) { tcf_action_offload_del(p); @@ -793,6 +852,59 @@ EXPORT_SYMBOL(tcf_idrinfo_destroy); static LIST_HEAD(act_base); static DEFINE_RWLOCK(act_mod_lock); +/* since act ops id is stored in pernet subsystem list, + * then there is no way to walk through only all the action + * subsystem, so we keep tc action pernet ops id for + * reoffload to walk through. + */ +static LIST_HEAD(act_pernet_id_list); +static DEFINE_MUTEX(act_id_mutex); +struct tc_act_pernet_id { + struct list_head list; + unsigned int id; +}; + +static int tcf_pernet_add_id_list(unsigned int id) +{ + struct tc_act_pernet_id *id_ptr; + int ret = 0; + + mutex_lock(&act_id_mutex); + list_for_each_entry(id_ptr, &act_pernet_id_list, list) { + if (id_ptr->id == id) { + ret = -EEXIST; + goto err_out; + } + } + + id_ptr = kzalloc(sizeof(*id_ptr), GFP_KERNEL); + if (!id_ptr) { + ret = -ENOMEM; + goto err_out; + } + id_ptr->id = id; + + list_add_tail(&id_ptr->list, &act_pernet_id_list); + +err_out: + mutex_unlock(&act_id_mutex); + return ret; +} + +static void tcf_pernet_del_id_list(unsigned int id) +{ + struct tc_act_pernet_id *id_ptr; + + mutex_lock(&act_id_mutex); + list_for_each_entry(id_ptr, &act_pernet_id_list, list) { + if (id_ptr->id == id) { + list_del(&id_ptr->list); + kfree(id_ptr); + break; + } + } + mutex_unlock(&act_id_mutex); +} int tcf_register_action(struct tc_action_ops *act, struct pernet_operations *ops) @@ -811,18 +923,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 err_id; + } + write_lock(&act_mod_lock); list_for_each_entry(a, &act_base, head) { if (act->id == a->id || (strcmp(act->kind, a->kind) == 0)) { - write_unlock(&act_mod_lock); - unregister_pernet_subsys(ops); - return -EEXIST; + ret = -EEXIST; + goto err_out; } } list_add_tail(&act->head, &act_base); write_unlock(&act_mod_lock); return 0; + +err_out: + write_unlock(&act_mod_lock); + tcf_pernet_del_id_list(*ops->id); +err_id: + unregister_pernet_subsys(ops); + return ret; } EXPORT_SYMBOL(tcf_register_action); @@ -841,8 +965,11 @@ int tcf_unregister_action(struct tc_action_ops *act, } } write_unlock(&act_mod_lock); - if (!err) + if (!err) { unregister_pernet_subsys(ops); + if (ops->id) + tcf_pernet_del_id_list(*ops->id); + } return err; } EXPORT_SYMBOL(tcf_unregister_action); @@ -1594,6 +1721,96 @@ static int tcf_action_delete(struct net *net, struct tc_action *actions[]) return 0; } +static int +tcf_reoffload_del_notify(struct net *net, struct tc_action *action) +{ + size_t attr_size = tcf_action_fill_size(action); + struct tc_action *actions[TCA_ACT_MAX_PRIO] = { + [0] = action, + }; + const struct tc_action_ops *ops = action->ops; + struct sk_buff *skb; + int ret; + + skb = alloc_skb(attr_size <= NLMSG_GOODSIZE ? NLMSG_GOODSIZE : attr_size, + GFP_KERNEL); + if (!skb) + return -ENOBUFS; + + if (tca_get_fill(skb, actions, 0, 0, 0, RTM_DELACTION, 0, 1) <= 0) { + kfree_skb(skb); + return -EINVAL; + } + + ret = tcf_idr_release_unsafe(action); + if (ret == ACT_P_DELETED) { + module_put(ops->owner); + ret = rtnetlink_send(skb, net, 0, RTNLGRP_TC, 0); + } else { + kfree_skb(skb); + } + + return ret; +} + +int tcf_action_reoffload_cb(flow_indr_block_bind_cb_t *cb, + void *cb_priv, bool add) +{ + struct tc_act_pernet_id *id_ptr; + struct tcf_idrinfo *idrinfo; + struct tc_action_net *tn; + struct tc_action *p; + unsigned int act_id; + unsigned long tmp; + unsigned long id; + struct idr *idr; + struct net *net; + int ret; + + if (!cb) + return -EINVAL; + + down_read(&net_rwsem); + mutex_lock(&act_id_mutex); + + for_each_net(net) { + list_for_each_entry(id_ptr, &act_pernet_id_list, list) { + act_id = id_ptr->id; + tn = net_generic(net, act_id); + if (!tn) + continue; + idrinfo = tn->idrinfo; + if (!idrinfo) + continue; + + mutex_lock(&idrinfo->lock); + idr = &idrinfo->action_idr; + idr_for_each_entry_ul(idr, p, tmp, id) { + if (IS_ERR(p) || tc_act_bind(p->tcfa_flags)) + continue; + if (add) { + tcf_action_offload_add_ex(p, NULL, cb, + cb_priv); + continue; + } + + /* cb unregister to update hw count */ + ret = tcf_action_offload_del_ex(p, cb, cb_priv); + if (ret < 0) + continue; + if (tc_act_skip_sw(p->tcfa_flags) && + !tc_act_in_hw(p)) + tcf_reoffload_del_notify(net, p); + } + mutex_unlock(&idrinfo->lock); + } + } + mutex_unlock(&act_id_mutex); + up_read(&net_rwsem); + + return 0; +} + static int tcf_del_notify(struct net *net, struct nlmsghdr *n, struct tc_action *actions[], u32 portid, size_t attr_size, struct netlink_ext_ack *extack) From patchwork Fri Dec 3 12:24:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655053 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE37BC433F5 for ; Fri, 3 Dec 2021 12:25:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380772AbhLCM3A (ORCPT ); Fri, 3 Dec 2021 07:29:00 -0500 Received: from mail-mw2nam10on2095.outbound.protection.outlook.com ([40.107.94.95]:24832 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1380775AbhLCM2w (ORCPT ); Fri, 3 Dec 2021 07:28:52 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AuI3A621CAQ8JY0kYamIBC8cr87Tkj5PljCBh5pJ1c4djrj/UxCJS8a/HQG5156tS2Al9PYoGhaK6GO16fCDYDp5ZbPf9Rkcte6seUyWbNIqWjd3UFtFPai3OEpZjLkMXzbsXYm8fcSCG/Voe9IGk9N2QhSAzm5clUf9RkYDbuAp2uVBh4fe5vn1IKgmJ0lUKsde3Ps3XTXfvjG07kGVmHaG/Vnr8qX6qNoDnHsBSPSWh0gCfh+u5+tkly30V9kVG26OtIsib1s+W6pQXKjr0Xlw3f8p0DmHqw1PwG0biZL2Of5ihvm3CvRU382UO12gNJPYz6/3ZciWqfCvZYiauw== 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=iQgWj+DCdO0wPFHB6SobC+E+Z6UytmFuAHLSUykhOEM=; b=jE5kRdccfzMseJCKkT+guKiXuveZJO3y8rryiqWp8JAIKcpFaAwPtGC1xYkg478Q5nq1i73K6IfIO8YMRem6hTV7+0Y572TZyRSDklvsQgYKgfqRxlf5jfR3jngVKzqMeF2XkbbXibazi1h/UCmrJtQgbeX/c5OUJb3ZODHQD8hVVHXtAT7F1A9KViJCbha6qRAfbbNMQ2VMVyv8bGFF+RFgVksPno4n/sTGihbqkgEvsR1afEFuNX9GauUwJZAi6DmKjVSDD4we0NMGK3k6o1lMXqo+q3IAISVdZJPTy9HrqTl/SIhAwktAM84kk2EQ2LqBiv31jl4zN0+GLNyipQ== 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=iQgWj+DCdO0wPFHB6SobC+E+Z6UytmFuAHLSUykhOEM=; b=aVNFurqWcVnCeCN+r7fCybVuz6tU27AuxlWB5FHojEsqvvVkvHsQUpbGwlkyh4lUVYTAOypXDlfA2qT1AeTB9OxKRVAbJtSJz/XPrsNuM/w0dIRQgy0fy0TDyUXLr+Sv29XBJZmaTzNTgI35h6fZZYT2OehpID6lSNwm05nFXWM= 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 PH0PR13MB5423.namprd13.prod.outlook.com (2603:10b6:510:12a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.7; Fri, 3 Dec 2021 12:25:27 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25:27 +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, Simon Horman Subject: [PATCH v5 net-next 11/12] flow_offload: validate flags of filter and actions Date: Fri, 3 Dec 2021 13:24:43 +0100 Message-Id: <20211203122444.11756-12-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e986c2c-bbdc-4b04-1e73-08d9b657fd07 X-MS-TrafficTypeDiagnostic: PH0PR13MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:16; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ScpKmWRRQtH1CIuHTklOW3u7HH5uEbT1uBeU2WJtjPjSeDqyNhfNi6M411qqkl/+TQttYG94/ReX64Yf5gXsNQcLK35tVll9MJMMEUrwySoCnAicJZ3QY9ibX7veurAeu13GzhYqMMmT79YiWyGMVjZz0nYsXV+U/zPkGPePjnJKo1Eq4egNkTM6a1RxE9SVMw0nb77YPSGCEV338/5LNcV6N95s6R1yvGpkFj9wsPntbQ6pTvzyCg81dsTztjEY5QlwIGMUKPc+CnIxBLJfiG/dK93PAqNkCrE9X46pJ6yljJDesrTaZYWu9o80BoZuBHsMeD0G1GAJlAJpoAzMhdHYOqXeFAa25TUsmG4bWcOUsdvmlRuC23jzYGiwpVCXYLtrIRMnleXbRv4Y0S8MrnxfuP5ZWflwr6ABNSNaoGDLczKMwKydyzW8FXMTnNlKYK1GrbD2vpSLKoScj3RVKtfARo1yvO/5UH5eD4RYNoscztRgaRkprcE9kkZuCcsAd0BV1XKp4uIPculyusGqK2M4vQD3n4BTpCLCT7GesS4fpGq7ahHgQIuq/hfCR86k1jzVKE2RzALcyV9o4zWlJVQTsSLfonMUW6YMb9Dn+VBAaSdnA8rvKcsuGCrA5EBqULqnEa8Js9y9Ha+oPmNh8w== 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)(366004)(346002)(376002)(396003)(136003)(6666004)(8936002)(38100700002)(2616005)(6506007)(4326008)(66946007)(66556008)(15650500001)(8676002)(36756003)(186003)(316002)(1076003)(44832011)(6486002)(508600001)(66476007)(5660300002)(107886003)(54906003)(52116002)(86362001)(83380400001)(6916009)(6512007)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SCy0dqFkSRyo6+zdLhcoIOcJi3NRKnRKAyyJfjO3Pq+vuYMB8QEptAaydhmnKHS4zYZESwW2ZQBB8ba6bJedSF4x/7Ii5DkvViK+OEAEJA9FXI1lEH7FqLRTF42XRETzKYIJZ01ZAfRCoPgBLgX1TVf3UbkzbITtJw/z7LgiMKxKx4syia3R3s4SRc5GGuC04XG6T3TR9SfLuDlBf2nD7s9A+V2aNMgYwR+Bl53t4L4PGSIiT2WarCntgrUdqfQZpTdh0jq1oqbbvBx5prYTe1NKXMtCbL6YXk9VAbC3IeUw6VqeH8UR1Ql8LeFS5dPkK56o+ZFDYSDDTnB5RTi6yiz5qYGwWkCeM2g2v1st6+kh1xL/jHtT1hdnbTKJX/+S74Jg7So375O50UneHKA4BhxL3UZB5IzMeyjMm0sURD7dS9QR7HgRnWudiJhDLIfZAfKYDs5CuCCSr9zC+j/f8NVA9L3amIq/vkiCDybktFRyMhLV3lWIaFaS2QelaBhFs/Fu/GCeT6kmaarruK9ACediXPzJwDBSbMWUNvFsjfIPqVA8KK0KUoARn+XReGHrnmJUunt04WZzWzLOzfbZMvGt2IEZILTRkTK9IQBB9xQralPlC2BOOCOWHczOBHY39gaCBAak1rbJVDL5V0GT6iTvIWNiTa5AcRRn/nBezbfut/knpyP5Aq/snZ2Nt8dkMDn4IjibkX6G2CIXHygmFY+dzVa70BPxPeX+bH1siLGTELAzq+Q9ArfVA0Y1AGiIOeNyx6a1CCpBN3Z6638Xj/JdrW07qjsfAKYS/07luqsjuH1E4F/mMAjqppPj3aL/zkhlBbJlqDfaJc0LTjqRNYnxGkYwNB3+Zz0iLTvpUrTLWlbyRbbjfw9XW6KrMyPBLH/RFwxNPgYs26qc/3pS5t4pz+hhcHLrM/5+7xgk85E2JHblLnfzIEa+pJ8xWfltYRwfguCrstfY8tStIBJVf6Z4FIM26cth1wIiW72vzL6TlnZM2UspabeKSVKc4+JffmSFgaWqd+8OWVWRquvsODZSNJmoXrYDTOnXNViTESIR7khH686zTmxlANCVRsRXEUQYD3DTi8sSGMReAHh3Hs4T0sGHc8a+RV2Mxp4dnIgFIRhJGl3quYoRF4VOhHERhf0bKha1rwf2Ufbwz5ykuTU6Cf8UUuVJiRXPMnCMmGNCQILYT6O8wQCUuNjTE/qV5qKU0wXZ6/VHokCFjkSNSgnUC+5GEiDK6zKkYnePgu/gq13x3cDdA6wPwO9zs4Hf5jbbypGGwd6t39ZwMOd7VnxpWvxdOVbs+XzNIbAQbk7uGZso21Z/Lm359SMpOW0I9q4SLZCjxIoFqPYOQcDU81a2p82z8zWoWOfqRNOnNUte7PuUUIkokGdaw1mKATXxznDWPoXxttNL+Mu5rY2hxUGiJTiFF4iGQvDT21be91ZyGfI4omTbFgaA3MzlyNCL8BOXkW+U4OQuNLdfJqBV6nOfgKACVyBk+WK5N3nAp8u1PrJmsFroXEe3dzxin2+o7XMfpM9iLE3bwN+eP0OcjOwpYxVyL1w8FnDCE9uOWfIq77x0P6Wi08hxstr/YbcHZ7jiyU6v+WOQ7W8VzWyFShv+n9G4MYbLyelSkUywD5h9grOyJPTgl/ipCbn7qhe+mf4ty7ZdsASErelnmRepKhrB0PqQ1XiOP6rxX6RGNf2vHu6A1TyvRPFJNLirRBo2csrgWJsBHB70H1dQiIkEyHL9PojkyA19oEXCIoFgiOg= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e986c2c-bbdc-4b04-1e73-08d9b657fd07 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:27.5647 (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: pRiFCJ8SJxStKMQUYCmzWMj2dkRpHMWLpYraO0YSL1wOSg0GUEYlH0LWzUR0nCYNhcu64DG+3d1UePA+9CRClzdB5p7p9ijcP1yfTVNPmhs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5423 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 87ad1d3f2063..39daa1bf1af5 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -203,7 +203,7 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, struct nlattr *est, struct tc_action *actions[], int init_res[], size_t *attr_size, - u32 flags, struct netlink_ext_ack *extack); + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack); struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police, bool rtnl_held, struct netlink_ext_ack *extack); diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 1942fe72b3e3..55abc3c1d761 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -326,6 +326,9 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, struct nlattr *rate_tlv, struct tcf_exts *exts, u32 flags, struct netlink_ext_ack *extack); +int tcf_exts_validate_ex(struct net *net, struct tcf_proto *tp, struct nlattr **tb, + struct nlattr *rate_tlv, struct tcf_exts *exts, + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack); void tcf_exts_destroy(struct tcf_exts *exts); void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src); int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts); diff --git a/net/sched/act_api.c b/net/sched/act_api.c index ec80b5411a62..2b85d07dde05 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1383,7 +1383,8 @@ static bool tc_act_bind(u32 flags) int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, struct nlattr *est, struct tc_action *actions[], - int init_res[], size_t *attr_size, u32 flags, + int init_res[], size_t *attr_size, + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { struct tc_action_ops *ops[TCA_ACT_MAX_PRIO] = {}; @@ -1421,7 +1422,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; @@ -1924,7 +1936,7 @@ static int tcf_action_add(struct net *net, struct nlattr *nla, for (loop = 0; loop < 10; loop++) { ret = tcf_action_init(net, NULL, nla, NULL, actions, init_res, - &attr_size, flags, extack); + &attr_size, flags, 0, extack); if (ret != -EAGAIN) break; } diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 2a1cc7fe2dd9..0894a1c90943 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3025,9 +3025,9 @@ void tcf_exts_destroy(struct tcf_exts *exts) } EXPORT_SYMBOL(tcf_exts_destroy); -int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, - struct nlattr *rate_tlv, struct tcf_exts *exts, - u32 flags, struct netlink_ext_ack *extack) +int tcf_exts_validate_ex(struct net *net, struct tcf_proto *tp, struct nlattr **tb, + struct nlattr *rate_tlv, struct tcf_exts *exts, + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { #ifdef CONFIG_NET_CLS_ACT { @@ -3061,7 +3061,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, flags |= TCA_ACT_FLAGS_BIND; err = tcf_action_init(net, tp, tb[exts->action], rate_tlv, exts->actions, init_res, - &attr_size, flags, extack); + &attr_size, flags, fl_flags, + extack); if (err < 0) return err; exts->nr_actions = err; @@ -3077,6 +3078,15 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, return 0; } +EXPORT_SYMBOL(tcf_exts_validate_ex); + +int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, + struct nlattr *rate_tlv, struct tcf_exts *exts, + u32 flags, struct netlink_ext_ack *extack) +{ + return tcf_exts_validate_ex(net, tp, tb, rate_tlv, exts, + flags, 0, extack); +} EXPORT_SYMBOL(tcf_exts_validate); void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index aab13ba11767..c3a104832a17 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -1917,12 +1917,14 @@ static int fl_set_parms(struct net *net, struct tcf_proto *tp, struct cls_fl_filter *f, struct fl_flow_mask *mask, unsigned long base, struct nlattr **tb, struct nlattr *est, - struct fl_flow_tmplt *tmplt, u32 flags, + struct fl_flow_tmplt *tmplt, + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { int err; - err = tcf_exts_validate(net, tp, tb, est, &f->exts, flags, extack); + err = tcf_exts_validate_ex(net, tp, tb, est, &f->exts, flags, + fl_flags, extack); if (err < 0) return err; @@ -2036,7 +2038,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, } err = fl_set_parms(net, tp, fnew, mask, base, tb, tca[TCA_RATE], - tp->chain->tmplt_priv, flags, extack); + tp->chain->tmplt_priv, flags, fnew->flags, + extack); if (err) goto errout; diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 24f0046ce0b3..a0c2a81d5762 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -163,12 +163,13 @@ static const struct nla_policy mall_policy[TCA_MATCHALL_MAX + 1] = { static int mall_set_parms(struct net *net, struct tcf_proto *tp, struct cls_mall_head *head, unsigned long base, struct nlattr **tb, - struct nlattr *est, u32 flags, + struct nlattr *est, u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { int err; - err = tcf_exts_validate(net, tp, tb, est, &head->exts, flags, extack); + err = tcf_exts_validate_ex(net, tp, tb, est, &head->exts, flags, + fl_flags, extack); if (err < 0) return err; @@ -226,8 +227,8 @@ static int mall_change(struct net *net, struct sk_buff *in_skb, goto err_alloc_percpu; } - err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], flags, - extack); + err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], + flags, new->flags, extack); if (err) goto err_set_parms; diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 4272814487f0..cf5649292ee0 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -709,12 +709,13 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { static int u32_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, struct tc_u_knode *n, struct nlattr **tb, - struct nlattr *est, u32 flags, + struct nlattr *est, u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { int err; - err = tcf_exts_validate(net, tp, tb, est, &n->exts, flags, extack); + err = tcf_exts_validate_ex(net, tp, tb, est, &n->exts, flags, + fl_flags, extack); if (err < 0) return err; @@ -895,7 +896,8 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, return -ENOMEM; err = u32_set_parms(net, tp, base, new, tb, - tca[TCA_RATE], flags, extack); + tca[TCA_RATE], flags, new->flags, + extack); if (err) { u32_destroy_key(new, false); @@ -1060,8 +1062,8 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, } #endif - err = u32_set_parms(net, tp, base, n, tb, tca[TCA_RATE], flags, - extack); + err = u32_set_parms(net, tp, base, n, tb, tca[TCA_RATE], + flags, n->flags, extack); if (err == 0) { struct tc_u_knode __rcu **ins; struct tc_u_knode *pins; From patchwork Fri Dec 3 12:24:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12655055 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04F97C433EF for ; Fri, 3 Dec 2021 12:25:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244731AbhLCM3B (ORCPT ); Fri, 3 Dec 2021 07:29:01 -0500 Received: from mail-mw2nam10on2095.outbound.protection.outlook.com ([40.107.94.95]:24832 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1352069AbhLCM3A (ORCPT ); Fri, 3 Dec 2021 07:29:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mv8dtA4bs0002SWuVqRU2wj4hHyKEa8IH7oIOtgJVAPQUnLVhqVC4F9MkxvZ0bDBZD2I8iFhtrdy2AFmU9bMWr26pFp2eWAKnbyjEnKS61hWdBz2ZQGZSvCk6nLM8WXzktIAYSwPBGWZxandLemrH/6UdQHakTS3bOX7+YgDmYY5c2xWV+M5nCzteM+1DsHEcrHt6J758jiTQLTTChYmCt4xJNBP/jsr0or/QjL7gLJW/nZ8fs23/bNUPKvkD81WE48H0Xbs7CNO6pF9jvS4oIWjNa//JcWfkH/OdqcwonxcUF4mOT96v0hGYfnt/T8wNSnOyAqsiYeLh9QyMj4eIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kLD9VLRt+eoIXF9qZ6EZEbTy+gfLtdBLGZEzQQ6ouZ4=; b=chH0F+AT8fpjJgwh25kK4J+7hL/ORtE048gFN17+xUpVuvXsd0FD+hJQwiaQ0GKKlyg7xrooUH3YuSsCPGETl8MDKFcnwmAnZDRoz6GcF/y9XNyQdOhLojGdbvVkvQLOQ3uUNachNLYyQqANQTTPdCzndQDTSJrrGbMcDnTAgqXXsFZsKDO1w7mxBuBd6zC86ZnQsoPHZ3nSj+JQXVwE60XMupRoix1oXcBivccLX0XJsPUnDENrxxBO+jg5QO8H43TdyXmZQk0mGFTQDv4Opj8eqC/Ozo5qOAEathcndXh0+KKpvZkIWY6OAL78I1uJ0x6UKV/ftaxvlH7tHn+6sw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kLD9VLRt+eoIXF9qZ6EZEbTy+gfLtdBLGZEzQQ6ouZ4=; b=i+/wvOnFsrRLy8LwnVLtWTi9VOpNelMfMMmS3oRgsFfjO28u5itTZAB76TgJ91XojRys27m+wZuM9Iv1St1ac2bJeOgRhtSVb0k7Hnj2jGcM+MraDlxncaDqq0TPhNRigG4ijORmBLE4VNvzN6yOxAF9Y3ntYZeV73Ht07eaw8o= 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 PH0PR13MB5423.namprd13.prod.outlook.com (2603:10b6:510:12a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.7; Fri, 3 Dec 2021 12:25:30 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::a01a:4940:c69a:e04c%9]) with mapi id 15.20.4755.015; Fri, 3 Dec 2021 12:25:30 +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, Simon Horman Subject: [PATCH v5 net-next 12/12] selftests: tc-testing: add action offload selftest for action and filter Date: Fri, 3 Dec 2021 13:24:44 +0100 Message-Id: <20211203122444.11756-13-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211203122444.11756-1-simon.horman@corigine.com> References: <20211203122444.11756-1-simon.horman@corigine.com> X-ClientProxiedBy: AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM3PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:207:5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Fri, 3 Dec 2021 12:25:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8cd62442-c24c-4caf-645a-08d9b657fe94 X-MS-TrafficTypeDiagnostic: PH0PR13MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P1DXBD3DDQnJocCcoC2WEo6LF3D6k8uDe1TmOAi8J/iw4+W7Ae+lS4DBCN+SxhaTVBoskljl/EQ6D0gFe0A6Y4Ha9lP5G4QSbDyWb4l0xF0LiigpgP9P9EyFPD79ijoLdUKhulPNQJWzK/XIVCBXSzVBz1FbQxLUcynrSb7MIbJmd6vX3yr7qPfuSGSjhXwlGREY8wpSh7FG+RUvOLOOQ5Bht45Bb13G6ZYJRKceIusFZrKfTmuvSfknMd+YdwXY0Qb+Odg39qbJ3GPd59SPKKGu/RhYTaJRgpTxPRAaG0zeVVlpFA4O+d4nTLcP/mKHLkS4fu0YVsVNnkFHuF0f0dSeQM1wI0sFJzI8AuSGUiP4Xnuxxxt6zihZxhXHEZxRFA5fk5W1pUXcJU40MlfTWr4ANu7ViUoPTGygTRinpE7mAC58FTXY8suVatUrCpReWb7kgkEuoWaoB764Plj3MuGHFiljGBKeawQkSH6bn3djlbj3x2OMHGzQn1iuZzZWkksbALMma+1/C9zjh/q3D3sVxwWgUzmunmjGbCNhrhgrbVffcbX9KscrKeSQ1mMNmytW8c+Dds+UXlBct0dcRJIMw5yBa8eJofBM1FkwOam/5vgfS1ryXlTNg1X2/07m183mj2OZmv4pFsbyqE/4kA== 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)(366004)(346002)(376002)(396003)(136003)(6666004)(8936002)(38100700002)(2616005)(6506007)(4326008)(66946007)(66556008)(8676002)(36756003)(186003)(316002)(1076003)(44832011)(6486002)(508600001)(66476007)(5660300002)(107886003)(54906003)(52116002)(86362001)(83380400001)(6916009)(6512007)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UN3z1V7oAtZW6Pgt4nojW7J8r1nnRlG0KpWxyMHRcO6TNGA0qRmJ8BSDzezflL01+SfrA2eCtdlclaZp5ggoHVGfmKo/VPSsToKGHU9ZbixNye6Rah+Hsng6ZjixBbRWi2OXO6wEy/kvcQGi/vAwj1Vs44S6mj5dNwo026o1cneGv3wbqBc4N6Otkaxvmgdh04nr++NiBm2iXGtDjZZpfHjNUjr+5beAtyB0qMAimSrPZoi4mtSIdjrC6jSe1wt24J52sYUzQrcCdFaK47ud2TTt96CQvjXyJv7DMWbDI52b0CePTjF6Q+ipzaJv9uiB+qAybbWJKR5wxjWh75oZt02slGw2jlT05v4dwtYCXxk20bHl5X0TQD3ndBJChnGYiPfEG5XUfG1d1oDfG9TLcmPpprtL9nfHgo1q/iNjpSrCawCxpRFyLBzzZRsvL8h9vPhK/Ksy4cLaSi6gIsPUGQoR9xGr9lGSWniQW8NUMXCKzMMV8+EX7DmjNoHgS4y7WabQzc03rzxQ9GL2FYXnHaF0nf39mTas0rlKklRcdpLcJG9UzX1Zr5/u3nGy1uKNl1+s0qVUE6K3YPRVmRBhb4qXXgbD0zJBQaUAJNFjG8vkPK1ahHyjjf8wiblywOVI+yNaleex4yZQKBSTdycwb4slrngDlxLN2wM6B4RtwH2gX5ZXyexmiqc/RN8nLFNmICbmVT8zq7WhoqtQyFXRAooUWt+kN/hnvUuy3gOl3mdyj6NXsx0Mlw/1G4VpPEgrMldlS7Z0sW0B5/Rhg/+afcotHLz2NSW/fi6TsM+MsPMVRRwelS639LYcEXs96PvAJcaozN4qKZsinEM9hVF4YXJWSoMn+jFepEUg5IrwDtUZAY2F7goXAY2qwJ7jhTQzmnfW4SnfzrYp/TM5aP42JQjcrh8zeOmGl3mcdxw6v1RwXHUBs7dqZQIF6bML5CHk2WvH4wksqZqwTnYTCZ+aglJGW4fEyiY9GVzT9cUHZkQ0zTGbJafRlcklbTIYNd2X+KUW71if1ea9LL5SA5JhiLriMklYRCCvALdWfgHzwfXnAGCpDpOcqidKxcmH+L/eyY0ojbQTXKNMByOHWKhCutL8CF3SVnLZ8xWvQxVnDuGBYyDNfJBCRtyPIUCVsUmvfCQwLcXq1oFqb6OGWp1LL1qAMFnnpmNTS9iu+2BjEo/vJYGQyYqfSaq8tr+XHG9tn2ddWi7NO7wyDRC/W1huqD/d86M/1zCaHx2+glUerIPb94VXUkQUQnxA3kKajNKMuNnPvPmU/uMdFYIjA6zwYw+hgMOEurTEC/fXuJfnR4mvwh05wTDwHtGkR4tsuH7mmbd22PPMRjaGEqTrjrQkn9zKEJxH6T2OJyn/gfMaTeDmYa0njJ5y+kqf16zkPjx/tK+IJsrDjffvmres4PKv5FrsQXVZEh0TD1pFOPADXJaxqYAJrKz7mb45SqUw3r0ogL/sIuizc9NoyI16eaBM7lrQ4jxaFrAB25KJfKziqClh34MpYTa8aLmm+nNkeZc6VG7mIZctXjieH+TdZas12oRk3Q1xzwFRSfEry4zmrbTtfAQHQe5v/itRckOT9RV1eXGyLdXE5ce73mIigqRrvoOuCJsxjdUa7Pc0RuY8CwuT5M1/wwiF0cahDrpiYWMtJ/QQXtV6BI/Tzv3DO74u885QzIbQNmnZXmwOT+MjXWD9pWsgBOXLaYp2E2heOpeMlWitCUZsJUJZoN6Cv59wDnW8HRfbvjfAzuVhPtlJBU0= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8cd62442-c24c-4caf-645a-08d9b657fe94 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 12:25:30.0617 (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: W/FrFwU6GhW89gpSyJzoCiHX0M1ztm5tFElKlwc+KfeIsbHdiX3hDn4JC6vT1rVzx73yV2Xlz+esI03c3fi8vRKPKCyc8QV92Xauw0+FC+w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5423 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add selftest cases in action police with skip_hw. Add selftest case to validate flags of filter and action. These tests depend on corresponding iproute2 command support. Signed-off-by: Baowen Zheng Signed-off-by: Simon Horman --- .../tc-testing/tc-tests/actions/police.json | 24 +++++++++++++++++++ .../tc-testing/tc-tests/filters/matchall.json | 24 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json index 8e45792703ed..b7205a069534 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json @@ -812,5 +812,29 @@ "teardown": [ "$TC actions flush action police" ] + }, + { + "id": "7d64", + "name": "Add police action with skip_hw option", + "category": [ + "actions", + "police" + ], + "setup": [ + [ + "$TC actions flush action police", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC actions add action police rate 1kbit burst 10k index 100 skip_hw", + "expExitCode": "0", + "verifyCmd": "$TC actions ls action police | grep skip_hw", + "matchPattern": "skip_hw", + "matchCount": "1", + "teardown": [ + "$TC actions flush action police" + ] } ] diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json b/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json index 51799874a972..4a8d1c5fff29 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json +++ b/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json @@ -387,5 +387,29 @@ "$TC qdisc del dev $DUMMY ingress", "$IP link del dev $DUMMY type dummy" ] + }, + { + "id": "3329", + "name": "Validate flags of the matchall filter and police action with skip_sw", + "category": [ + "filter", + "matchall" + ], + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true", + "$TC qdisc add dev $DUMMY ingress", + "$TC actions flush action police", + "$TC actions add action police rate 1mbit burst 100k index 199 skip_hw" + ], + "cmdUnderTest": "$TC filter add dev $DUMMY parent ffff: handle 0x1 prio 1 protocol ipv4 matchall skip_sw action police index 199", + "expExitCode": "2", + "verifyCmd": "$TC filter get dev $DUMMY parent ffff: handle 1 prio 1 protocol ipv4 matchall", + "matchPattern": "^filter parent ffff: protocol ip pref 1 matchall.*handle 0x1.*", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY ingress", + "$IP link del dev $DUMMY type dummy", + "$TC actions del action police index 199" + ] } ]