Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp255727ybz; Tue, 21 Apr 2020 20:11:17 -0700 (PDT) X-Google-Smtp-Source: APiQypLR3rg7CkvJNeaj3mliZIaD47zQkPoIRYQzpT6B0suYMYbC/JWtATNT7aI5zgF6QpTH3Avv X-Received: by 2002:a17:906:7b53:: with SMTP id n19mr24920129ejo.244.1587525077126; Tue, 21 Apr 2020 20:11:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587525077; cv=pass; d=google.com; s=arc-20160816; b=jSQr8a1vsAHiE00p2SD3SLL065beAVR9nQg99ZaNZgE/Gv0M1SNwBwk0DWyGC7AKXF v2ydecDUcA5YWy9WunRxZqS3JOdwPEezGQE2vu0BeDV492FuGTvYOf7k7FXQ+VQ/g8nt 3jA+QxsKM66/UM/8wm8Wqs1OLeouHEa/hWUi2UuiGuip8DO1pxSRzkITiJGNqBWmc3kA ecDgjguphe7XJUwmFUGo+XqH5lys2NiwhHcjHupUGHjsoKosJOzWYA47dF8Fisj3yYDt Fh7GD9Z0wcNuf9uaoyQd3ATDgCELbmjYWCW619S4X+qX0FajXnVw6z4qDdmOTfSRhaEC DHqg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=B3tjwLDZOMIKOrBKykS+1WS7+fR5vzUVsVL81AHn1bY=; b=vm3yDopSqjLYAO6KOfeS7GnaGP3iDzmuy2efNSqrLRST7Iv5XulIgaKqXpjZKwGNBI IVlSitgpO8w0rU0v1XedvLl8LQWXylDPh/BcddqwCtYzwi2ijqBUQ+8TI4jXrVjiJQ1a suFgBGi4AsuQIm4qeFaV/1w+bfUYvBre4M16M91ijOgYwMeTAeFER7rMcXM1Z5eTZ8rT hhtYz9D7DDUxusucFeiO0Ae2Iqrz0BNU4wOE8eQf15R//j0ObJzCuyW4Blz8OX9moLGt +Ish40Q46h1rzKlTI31SI6wKkPoiB/i+nNTg95IoMpO74lKCmm07I2Is6sWhNPqIL2Qn 2g7A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QKG8G8gD; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si2857036edx.91.2020.04.21.20.10.53; Tue, 21 Apr 2020 20:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QKG8G8gD; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726463AbgDVDJ0 (ORCPT + 99 others); Tue, 21 Apr 2020 23:09:26 -0400 Received: from mail-eopbgr140074.outbound.protection.outlook.com ([40.107.14.74]:55286 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726294AbgDVDJY (ORCPT ); Tue, 21 Apr 2020 23:09:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BMU+QbzOcQc7yw324Rpj997oQs2D2EGTQ++QvXsoGoqUaauDDHJR3qHiQIwf3MzeQNDc3kVfkEU4LeRCbB1lXY3hPi+TVJmsYx7e+1OPR/jlGYC3Q4oi/3QOiY7wfLlujCyzDjXSCkpGk6l7xivKvEjp66G8THkTVBJqIuCKHMtVxXfQvji35ZtzxzNY0A+6Nx3xRw5XDqynG9PTdVMTn2T8sPWaheAVcsK4l4Rx3ccSKVPo2Rglbo04PrlVtKyizqVzb6AXWjFr9knXQ0WivW48pSks/w8yhIt+NmTQeh8U+hdAh1GabeDCAxZndMZyZgJwyn5Rl7C1lCScpijmdg== 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-SenderADCheck; bh=B3tjwLDZOMIKOrBKykS+1WS7+fR5vzUVsVL81AHn1bY=; b=jnRWv1elrzpdRslueKkB/tybVAv1E3JD4UHJE3JO4e062vRZeU5apPHH2gUrEPFQnWyGjKAS5NGGmnBYE8WpWAVFErFYOivNdZpWDD7QV045GHppf4ebBooWsEXtTPwlNYof64QkGWsKTkwULMeNzeA2i9ZVZ+cfd/TpUaN696xGTSo9Kg7Xr2d7kih2g8V2ZlBKkCdGQyo8E0uH+2oCrZcHUbNZApnfORvw2x5r7Rm4ISer9tSUI83gppMnGHHHnUtgsnhQVirj/teYOtJemwWMyuVzmIbPpy5P1IvY6BydUbL8KKhCZm5qBqIyHGBAUz3q8wlomhmYz6Kp9d9IgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B3tjwLDZOMIKOrBKykS+1WS7+fR5vzUVsVL81AHn1bY=; b=QKG8G8gD0nsjhyZ3jyxmmMWuGNg3IpkP6zp2cBpFghevy/Nu3kA6rBU3K2GqneIOuv2HcbNdGbp8dTgg/wzLfXvbJtJksg3JqJktngoxrW47dHIFv4vJ9MwkIVgsCCDpifbf1MXzLA+K+gnd9niz8924cWD9/IQ4hKu4hvoCvJs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=po.liu@nxp.com; Received: from VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) by VE1PR04MB6430.eurprd04.prod.outlook.com (2603:10a6:803:11b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.27; Wed, 22 Apr 2020 03:09:20 +0000 Received: from VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::1479:38ea:d4f7:a173]) by VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::1479:38ea:d4f7:a173%7]) with mapi id 15.20.2921.030; Wed, 22 Apr 2020 03:09:20 +0000 From: Po Liu To: davem@davemloft.net, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: vinicius.gomes@intel.com, po.liu@nxp.com, claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, alexandru.marginean@nxp.com, michael.chan@broadcom.com, vishal@chelsio.com, saeedm@mellanox.com, leon@kernel.org, jiri@mellanox.com, idosch@mellanox.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, kuba@kernel.org, jhs@mojatatu.com, xiyou.wangcong@gmail.com, simon.horman@netronome.com, pablo@netfilter.org, moshe@mellanox.com, m-karicheri2@ti.com, andre.guedes@linux.intel.com, stephen@networkplumber.org, Po Liu Subject: [v3,net-next 2/4] net: schedule: add action gate offloading Date: Wed, 22 Apr 2020 10:48:50 +0800 Message-Id: <20200422024852.23224-3-Po.Liu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200422024852.23224-1-Po.Liu@nxp.com> References: <20200418011211.31725-5-Po.Liu@nxp.com> <20200422024852.23224-1-Po.Liu@nxp.com> Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.73) by SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13 via Frontend Transport; Wed, 22 Apr 2020 03:09:12 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.73] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ebab1560-763c-4509-1952-08d7e66a8cf9 X-MS-TrafficTypeDiagnostic: VE1PR04MB6430:|VE1PR04MB6430: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-Forefront-PRVS: 03818C953D X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6496.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10009020)(4636009)(39860400002)(346002)(366004)(396003)(376002)(136003)(6486002)(7416002)(26005)(2616005)(6506007)(8676002)(316002)(4326008)(2906002)(6512007)(478600001)(52116002)(6666004)(5660300002)(66476007)(66946007)(66556008)(81156014)(1076003)(86362001)(36756003)(8936002)(69590400007)(956004)(186003)(16526019);DIR:OUT;SFP:1101; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k96XRwignMqzuTcrWwWi7hvFsz0rhHFx8QAACgCXksN1DKfT55W3gRXvkExHu3BZzj2Q+mj7HKwWNTkFS2odzocV1DtFsMjx32yYOc9zHtvGZGAW3NaG0q6u2Rn3bh1wQRQq7S6XQrebhYPLFpX+D+ibrfHh3zPbqpL5qGbTkGopdJ3Y5vYOKYj9yIpT1wRM4QfFIqMqC2sDy+sGrhDfT2pvABAMRFEaWMrA9laqB587w65wpRV83d/RoK7tjkVrmkp9/2IhmSZtjS12E/mwCKjEw4PoP+zUWi+T9GWHAM59cm8b5wqkqZa8PyikrGTYj+tFeqV5CyiMinPbud3mZZ8tep6Q7ETHe3MqYFKGk4I2c14Cmm+wSnHpNONC9GME/axxiG0RwS56sqMq+XMPSRKkouND5Rm1N7yDWlRWaxvZssEUSOYOA0Z4NlSZw7hWxAtXWCqLLf9GCWboIE1342/ZqTlv1LZtviQ0ee9O6dj8EHpJB7sTeNMXYKXKFVXP X-MS-Exchange-AntiSpam-MessageData: qoAlbKUzuM2GmXglyxbyrPmcZSydol26MQceJfDcM2deT5L5VcWHEKb0cl7PnNRWMvUoVauaYzS0F/MNXweEKGeclQmFSjJv0OJvYaec7ugptWeV3qm2y/5gaBi2ZVXqcJckomftlHZDWNOURaEDBQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebab1560-763c-4509-1952-08d7e66a8cf9 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2020 03:09:20.4860 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /Si97LR7bxcK/EZ80xbSqnRL8jghAhBt9gQjO4S/tCxevN78lEMUGSua1w65PXMb X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6430 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the gate action to the flow action entry. Add the gate parameters to the tc_setup_flow_action() queueing to the entries of flow_action_entry array provide to the driver. Signed-off-by: Po Liu --- include/net/flow_offload.h | 10 +++ include/net/tc_act/tc_gate.h | 115 +++++++++++++++++++++++++++++++++++ net/sched/cls_api.c | 33 ++++++++++ 3 files changed, 158 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 3619c6acf60f..94a30fe02e6d 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -147,6 +147,7 @@ enum flow_action_id { FLOW_ACTION_MPLS_PUSH, FLOW_ACTION_MPLS_POP, FLOW_ACTION_MPLS_MANGLE, + FLOW_ACTION_GATE, NUM_FLOW_ACTIONS, }; @@ -255,6 +256,15 @@ struct flow_action_entry { u8 bos; u8 ttl; } mpls_mangle; + struct { + u32 index; + s32 prio; + u64 basetime; + u64 cycletime; + u64 cycletimeext; + u32 num_entries; + struct action_gate_entry *entries; + } gate; }; struct flow_action_cookie *cookie; /* user defined action cookie */ }; diff --git a/include/net/tc_act/tc_gate.h b/include/net/tc_act/tc_gate.h index b0ace55b2aaa..62633cb02c7a 100644 --- a/include/net/tc_act/tc_gate.h +++ b/include/net/tc_act/tc_gate.h @@ -7,6 +7,13 @@ #include #include +struct action_gate_entry { + u8 gate_state; + u32 interval; + s32 ipv; + s32 maxoctets; +}; + struct tcfg_gate_entry { int index; u8 gate_state; @@ -51,4 +58,112 @@ struct tcf_gate { #define get_gate_param(act) ((struct tcf_gate_params *)act) #define get_gate_action(p) ((struct gate_action *)p) +static inline bool is_tcf_gate(const struct tc_action *a) +{ +#ifdef CONFIG_NET_CLS_ACT + if (a->ops && a->ops->id == TCA_ID_GATE) + return true; +#endif + 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; + + rcu_read_lock(); + tcfg_prio = rcu_dereference(to_gate(a)->actg)->param.tcfg_priority; + rcu_read_unlock(); + + return tcfg_prio; +} + +static inline u64 tcf_gate_basetime(const struct tc_action *a) +{ + u64 tcfg_basetime; + + rcu_read_lock(); + tcfg_basetime = + rcu_dereference(to_gate(a)->actg)->param.tcfg_basetime; + rcu_read_unlock(); + + return tcfg_basetime; +} + +static inline u64 tcf_gate_cycletime(const struct tc_action *a) +{ + u64 tcfg_cycletime; + + rcu_read_lock(); + tcfg_cycletime = + rcu_dereference(to_gate(a)->actg)->param.tcfg_cycletime; + rcu_read_unlock(); + + return tcfg_cycletime; +} + +static inline u64 tcf_gate_cycletimeext(const struct tc_action *a) +{ + u64 tcfg_cycletimeext; + + rcu_read_lock(); + tcfg_cycletimeext = + rcu_dereference(to_gate(a)->actg)->param.tcfg_cycletime_ext; + rcu_read_unlock(); + + return tcfg_cycletimeext; +} + +static inline u32 tcf_gate_num_entries(const struct tc_action *a) +{ + u32 num_entries; + + rcu_read_lock(); + num_entries = + rcu_dereference(to_gate(a)->actg)->param.num_entries; + rcu_read_unlock(); + + return num_entries; +} + +static inline struct action_gate_entry + *tcf_gate_get_list(const struct tc_action *a) +{ + struct action_gate_entry *oe; + struct tcf_gate_params *p; + struct tcfg_gate_entry *entry; + u32 num_entries; + int i = 0; + + rcu_read_lock(); + p = &(rcu_dereference(to_gate(a)->actg)->param); + num_entries = p->num_entries; + rcu_read_unlock(); + + list_for_each_entry(entry, &p->entries, list) + i++; + + if (i != num_entries) + return NULL; + + oe = kzalloc(sizeof(*oe) * num_entries, GFP_KERNEL); + if (!oe) + return NULL; + + i = 0; + list_for_each_entry(entry, &p->entries, list) { + oe[i].gate_state = entry->gate_state; + oe[i].interval = entry->interval; + oe[i].ipv = entry->ipv; + oe[i].maxoctets = entry->maxoctets; + i++; + } + + return oe; +} #endif diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 55bd1429678f..ca8bf74be4ba 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -39,6 +39,7 @@ #include #include #include +#include #include extern const struct nla_policy rtm_tca_policy[TCA_MAX + 1]; @@ -3523,6 +3524,27 @@ static void tcf_sample_get_group(struct flow_action_entry *entry, #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; +} + int tc_setup_flow_action(struct flow_action *flow_action, const struct tcf_exts *exts) { @@ -3669,6 +3691,17 @@ int tc_setup_flow_action(struct flow_action *flow_action, } 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.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); + 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; } else { err = -EOPNOTSUPP; goto err_out_locked; -- 2.17.1