From patchwork Tue Jun 23 06:34:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po Liu X-Patchwork-Id: 1314927 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=SJQo6jzB; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49rc0X2BS6z9s6w for ; Tue, 23 Jun 2020 16:33:00 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730962AbgFWGc5 (ORCPT ); Tue, 23 Jun 2020 02:32:57 -0400 Received: from mail-eopbgr10074.outbound.protection.outlook.com ([40.107.1.74]:17585 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730635AbgFWGc4 (ORCPT ); Tue, 23 Jun 2020 02:32:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iEgxzS9GQ+CcNJ0iH4gYWyNIdlBdmoHiqBbh21ledmkQLTG4Hm7lpZvJeIQ5ZRNuMR2aXy+WrpkvICeyxMWA1FfAH4z4p4EqvlYOyS9zHJi72qacRde0Ikdi6BwSoWZH5+pIKRg7tNab72Q4tk6Xgup5JH9K9/1PzQmqMBBTi+fVgjCK7yZD9IY/uOosogIyNoUc11m/TCWjmpAYpFu0loRPJk3IAVAXjgLK8sVD9H5aSdurLwf9ocyeOvqAi4wJ2RqEHiIYdF4hnNdM1CwQ9AjFByqBPvA+0GuPZircNoFxz5551L+k+HoQvQxD8J5BIlPEm9ZzKT2qhuVDAJYfag== 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=EaeDAoMV7F+rZLYpouIhZ3PIcYsLDXxL/vglhN6tsJM=; b=She3LaKMo8lABwnF3AQ3X3h9Bk5YJdRl8lvBh/FFqIYgSIAGXDfNAldK8wfWUnhj+ubCDucqgHdEY40xL79k7FxMrvUbp1ZkGQKNahHfOmQG6td0NGH+9HEG5pUX2lcQmrGp1SskZnj0fygCh9GfY9DMGCRoLFuA31PuW7qsraHGBLSLYAEre4LDRXgTqPUCtjeTXduEO2EPEkXqHSPqXPPp3Md9WD5Gf48Jc3WMNQHGNDfFOkupvDEGID5eZv706cRHKaVAWoIdZ7jiSDoHiLnJxznT9xkPcSE7lGpygZ/8b4Uxx2APfQVdqwG5eMwDTaIazC/z1pe1LQs8HnVWWQ== 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=EaeDAoMV7F+rZLYpouIhZ3PIcYsLDXxL/vglhN6tsJM=; b=SJQo6jzB4204iLCq0AwElcP15+X3B+sbGtMA/gbhOLsozWjHfjWe5cZv58vSKEQ2q1oc1DqRQhzECI5Q0q5h7OjtDLkKINEW/Vod/QeIHlF3jDJnTKyT8vRbzrHx4kkFgY4uqI6ONlHk3SXqBSua4OvOHNxA88Bj855Y8pWS22s= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) by VE1PR04MB6621.eurprd04.prod.outlook.com (2603:10a6:803:124::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Tue, 23 Jun 2020 06:32:47 +0000 Received: from VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::c1ea:5943:40e8:58f1]) by VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::c1ea:5943:40e8:58f1%3]) with mapi id 15.20.3109.027; Tue, 23 Jun 2020 06:32:47 +0000 From: Po Liu To: davem@davemloft.net, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, idosch@idosch.org Cc: jiri@resnulli.us, vinicius.gomes@intel.com, vlad@buslov.dev, 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: [v1,net-next 1/4] net: qos: add tc police offloading action with max frame size limit Date: Tue, 23 Jun 2020 14:34:09 +0800 Message-Id: <20200623063412.19180-1-po.liu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200306125608.11717-7-Po.Liu@nxp.com> References: <20200306125608.11717-7-Po.Liu@nxp.com> X-ClientProxiedBy: SGAP274CA0003.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::15) To VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tsn.ap.freescale.net (119.31.174.73) by SGAP274CA0003.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Tue, 23 Jun 2020 06:32:39 +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: 144b57fb-cae6-4d43-b8b8-08d8173f3e70 X-MS-TrafficTypeDiagnostic: VE1PR04MB6621: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-Forefront-PRVS: 04433051BF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9c/pku/HwBFZKduT7iiXaDGQQ+KfkiH+iRKcEumw6XvzEkjZfkLvCleH/NJvrBTkgDYMqJ9qz+/PybnlWJaORGurEmSgkmsDXbohmdb5d5yCe+/BYFuBEGXk1Y6T7ChJk9uxnQ2djUlZpC7yHaFZ9LH/hOw6TsV/f9XXdv9Qsbe56WBdOvBtaRkk1JVyoL8Fe24zgho8GR7VjtTq+ogiRsIjLqTMWv4G+XjXnw5GC8Nejs76ZkIXIF/NkvFt5tvd/g3Je+oDzEWApmDiGygtk7MiOjvE7ShQT8MmJ4irYDjmEJ/WdaNOCaCh6rsA/tQN 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:(4636009)(39860400002)(376002)(366004)(396003)(136003)(346002)(26005)(16526019)(52116002)(66556008)(66476007)(66946007)(186003)(6506007)(83380400001)(4326008)(478600001)(36756003)(2906002)(86362001)(6666004)(44832011)(1076003)(7416002)(5660300002)(8936002)(6512007)(2616005)(6486002)(316002)(956004)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: j1/5ErTf3GEHkRI2qqVpXBrcpf+rGglpm7zuHHvk6/obr+13S2BB7e7Li+tLqpqzz4kPc9XGudfC3WSELbz6CaVcJq/yq7zwdh2vpzNswrNEvRNq9qit1V505z85kzl4JdI+zpaVqGLBbJ2ePOAkx8UA2dKdPczrI6vds1U3CvTZ63KztFL80JFzV6DM/6L0NxDLYctA/CnkEUIYoKO+s8UN4QQx1aLKyXx3+Uw3Ehik/eYupvPajCtLRci+6dkL0kKBCiJ2eyNDCYt1Nz2bvULRTo5HeCz3jpxtEqRZXk7XOikRp5Gj3lsMkT8JuyHMZEUV9iedZKqv1zk49Hp2qQd13UMTl3a2gmm61R6vWUqSWtwO9sLXY4ofAbF7aZ90iCOL/g3NOMQUqgTrwn7DA5h8egdFHZX6d3iSaaZ9oxPOQn3NHLqLl1uB38YEngygeTSDvKRKgijO+LOcHcxRatJVpTJNaFK7mzGo+9Vx3U8= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 144b57fb-cae6-4d43-b8b8-08d8173f3e70 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2020 06:32:47.7844 (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: Ni9th+IsA6PZgytrdv60IeYnarKmfjg4E2cMid+aU3BWOz4S5Hzhh4BUvNgDbFK2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6621 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Po Liu Current police offloading support the 'burst'' and 'rate_bytes_ps'. Some hardware own the capability to limit the frame size. If the frame size larger than the setting, the frame would be dropped. For the police action itself already accept the 'mtu' parameter in tc command. But not extend to tc flower offloading. So extend 'mtu' to tc flower offloading. Signed-off-by: Po Liu --- continue the thread 20200306125608.11717-7-Po.Liu@nxp.com for the police action offloading. include/net/flow_offload.h | 1 + include/net/tc_act/tc_police.h | 10 ++++++++++ net/sched/cls_api.c | 1 + 3 files changed, 12 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 00c15f14c434..c2ef19c6b27d 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -234,6 +234,7 @@ struct flow_action_entry { struct { /* FLOW_ACTION_POLICE */ s64 burst; u64 rate_bytes_ps; + u32 mtu; } police; struct { /* FLOW_ACTION_CT */ int action; diff --git a/include/net/tc_act/tc_police.h b/include/net/tc_act/tc_police.h index f098ad4424be..cd973b10ae8c 100644 --- a/include/net/tc_act/tc_police.h +++ b/include/net/tc_act/tc_police.h @@ -69,4 +69,14 @@ static inline s64 tcf_police_tcfp_burst(const struct tc_action *act) return params->tcfp_burst; } +static inline u32 tcf_police_tcfp_mtu(const struct tc_action *act) +{ + struct tcf_police *police = to_police(act); + struct tcf_police_params *params; + + params = rcu_dereference_protected(police->params, + lockdep_is_held(&police->tcf_lock)); + return params->tcfp_mtu; +} + #endif /* __NET_TC_POLICE_H */ diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index a00a203b2ef5..6aba7d5ba1ec 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3658,6 +3658,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->police.burst = tcf_police_tcfp_burst(act); entry->police.rate_bytes_ps = tcf_police_rate_bytes_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); From patchwork Tue Jun 23 06:34:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po Liu X-Patchwork-Id: 1314928 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=REfXESen; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49rc0g3Sprz9sRh for ; Tue, 23 Jun 2020 16:33:07 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731054AbgFWGdC (ORCPT ); Tue, 23 Jun 2020 02:33:02 -0400 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40]:61054 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730635AbgFWGdB (ORCPT ); Tue, 23 Jun 2020 02:33:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GqpnZ7oLku8Hy5e4vxcBjU5Q0m3aRS3rbYUC7dsiNcQjJtyjAmTFGYL8zHLNDQ59e/hx5ZTUsefHyzWi3HNc8xKNjYozlaCidlWzqVHAFZvgN3LGdOUftTP/GTvfeARZ3LveXL7hVppSJrHqXg4a8Zxd3XBkpTMQ9O24ad9IAYd5h6/f2rmkPVl+0KkPmuocAoW3VyetiAKMrh2tuC+qnfFOOukdDQhK35KIl4aIaKxqlQgOqL541lDfKaxbaK1JzOCU/g55WRgxyyHrCo3AlVFLZ18k4llJHR6+i8Bj9j2rpjkoDBcLnCdS9d5NP6AQUzrAQ/pDhCKtgDWTWj7R8Q== 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=/2pQWPnyo6ZrK/SFWnPcjeiYriQtx3g8ATHZ9bdskWk=; b=NkAZOYGrrxKuc+TKy0bjcoU+VWR3n6kJ5Woio6BeeEdYSfZPmakw2ryEUCYcI9PYGy30Z2MCkBf7uOh1eQI9OmGBXs+f2zZeBoIAgiuboj8eBrx+IZDCfxfhRbkgk4LY+jhDWVE0iEffOt/7ohPztWRSugJh/cJUz6XNHuf6JdyJ6E8cd5sA5W9iw7jSUMUlwGZKl7mYjJcxHUu/QwU94z1O9xMUpKPwpznhA9g/QBw1Wn7ZTbTb9MqgQThOtQtbQPnRhV0sf/yOZnF3EW055/af51F/HpyXEqOWYMeFE1qavEFMpqncadrSkQFqkurXGizW6ftr9o13gE9reqnB4A== 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=/2pQWPnyo6ZrK/SFWnPcjeiYriQtx3g8ATHZ9bdskWk=; b=REfXESen+KyZroRQKBV/4vPzLS5YTB60OZ+ecAmefjXfhAYBrEvGp/Y6eEgR/kL5u1GFiaH/wbn5sj9wEOFU+5LUrgbM8Ub1VJeHBdy4fsMB0vALwk0SuHGeQXVo99x1OSU6ldIBYlI2Q/rJ2CWWMGnrkdtd4g0p1GrKs213sc0= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) by VE1PR04MB6688.eurprd04.prod.outlook.com (2603:10a6:803:127::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Tue, 23 Jun 2020 06:32:56 +0000 Received: from VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::c1ea:5943:40e8:58f1]) by VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::c1ea:5943:40e8:58f1%3]) with mapi id 15.20.3109.027; Tue, 23 Jun 2020 06:32:56 +0000 From: Po Liu To: davem@davemloft.net, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, idosch@idosch.org Cc: jiri@resnulli.us, vinicius.gomes@intel.com, vlad@buslov.dev, 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: [v1,net-next 2/4] net: enetc: add support max frame size for tc flower offload Date: Tue, 23 Jun 2020 14:34:10 +0800 Message-Id: <20200623063412.19180-2-po.liu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200623063412.19180-1-po.liu@nxp.com> References: <20200306125608.11717-7-Po.Liu@nxp.com> <20200623063412.19180-1-po.liu@nxp.com> X-ClientProxiedBy: SGAP274CA0003.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::15) To VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tsn.ap.freescale.net (119.31.174.73) by SGAP274CA0003.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Tue, 23 Jun 2020 06:32:48 +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: 522f5fb5-179c-4497-ae13-08d8173f43d6 X-MS-TrafficTypeDiagnostic: VE1PR04MB6688: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:751; X-Forefront-PRVS: 04433051BF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MH/DDBpAMjZqo4JKDe27KS4i71xcl3RbnECb/nznD/Slr3LvKCPPJ0j+xdJ+ENwvuwFVOqBMKA5fdo3tp/qd49/uaW8nH72AQ6RH0m+ChL/hSePil3sIVMLcYDgQIGRyuYIyK50kr329kJJ1ewUcSMQnmoldvtm1ttlE1yQZLfDKwFTgNYj08wfJdUx2BdnDVr5kteKBGIvQVLFmWLW7tvL9tKYO+dDujKGbX6htQ55A0nWA2rvPfe7YR+LHiHJkr5CJxHblcM9RItcDzguF2S7ZAOH9AfvFGRLWT1iuetxymo/URRKPENmqXpnd29uf 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:(4636009)(136003)(396003)(376002)(346002)(366004)(39860400002)(6506007)(5660300002)(6512007)(8936002)(26005)(8676002)(2906002)(86362001)(1076003)(66946007)(66556008)(16526019)(186003)(66476007)(36756003)(6666004)(956004)(4326008)(44832011)(7416002)(2616005)(83380400001)(478600001)(316002)(52116002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ZKFetZzAhXrJ4BUaIcb0iTwGlNzqXX8GhzwX05QQO2bw030GpeZFngDikZQrMwhOrWHrB+B//Xj0zK7wzQ7QHoRDcTJ6HSmBBhze9UCJBMK9bUXx3u3e6ejS+KYjbKcgQQod1x7dCU9y5x+4JaS95mupqEPzsfDwEOylRbyU6pQflNwU5b4+N8K09xS+XZhA+CKSywi+cCt57QB+RUE4L2W1VU5Pl9Rq5Ro2SkY8rTz1RX5dff4ndSbJK7J/SRFK+Q5Yf8iZlnDIU14NipzcADsyKS9dT2ycN0uuPIA8Lt0Q4Fb7DVZmUF22KPI/WWfxyH13xjIe4PoUwTzWUGG2H0tm0uq+L2KvIT4OIbNHp1V4hTCSbf2d92c8iXtHpwmD2zxHQ6mwzJkcHXPCirQyf4jubC9DAt288yTdzNLUzXa3nSGJQnB5PcL/Z0wn7biTUUTq/NVZaz6q/x7LL4K7n3LrgCenNJTTynmdf6VoSVg= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 522f5fb5-179c-4497-ae13-08d8173f43d6 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2020 06:32:56.4314 (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: tFvO0TniyXbfGmheZK+WsI8oVj9ykuSA3cHmP4fHvIc2Q/7J7dBorUelP44xtKrI X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6688 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Po Liu Base on the tc flower offload police action add max frame size by the parameter 'mtu'. Tc flower device driver working by the IEEE 802.1Qci stream filter can implement the max frame size filtering. Add it to the current hardware tc flower stearm filter driver. Signed-off-by: Po Liu --- .../net/ethernet/freescale/enetc/enetc_qos.c | 52 +++++++++++++------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index fb76903eca90..07f98bf7a06b 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -389,6 +389,7 @@ struct enetc_psfp_filter { u32 index; s32 handle; s8 prio; + u32 maxsdu; u32 gate_id; s32 meter_id; refcount_t refcount; @@ -430,6 +431,12 @@ static struct actions_fwd enetc_act_fwd[] = { BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS), FILTER_ACTION_TYPE_PSFP }, + { + BIT(FLOW_ACTION_POLICE) | + BIT(FLOW_ACTION_GATE), + BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS), + FILTER_ACTION_TYPE_PSFP + }, /* example for ACL actions */ { BIT(FLOW_ACTION_DROP), @@ -594,8 +601,12 @@ static int enetc_streamfilter_hw_set(struct enetc_ndev_priv *priv, /* Filter Type. Identifies the contents of the MSDU/FM_INST_INDEX * field as being either an MSDU value or an index into the Flow * Meter Instance table. - * TODO: no limit max sdu */ + if (sfi->maxsdu) { + sfi_config->msdu = + cpu_to_le16(sfi->maxsdu); + sfi_config->multi |= 0x40; + } if (sfi->meter_id >= 0) { sfi_config->fm_inst_table_index = cpu_to_le16(sfi->meter_id); @@ -872,6 +883,7 @@ static struct enetc_psfp_filter hlist_for_each_entry(s, &epsfp.psfp_filter_list, node) if (s->gate_id == sfi->gate_id && s->prio == sfi->prio && + s->maxsdu == sfi->maxsdu && s->meter_id == sfi->meter_id) return s; @@ -979,6 +991,7 @@ static struct actions_fwd *enetc_check_flow_actions(u64 acts, static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, struct flow_cls_offload *f) { + struct flow_action_entry *entryg = NULL, *entryp = NULL; struct flow_rule *rule = flow_cls_offload_flow_rule(f); struct netlink_ext_ack *extack = f->common.extack; struct enetc_stream_filter *filter, *old_filter; @@ -997,9 +1010,12 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, flow_action_for_each(i, entry, &rule->action) if (entry->id == FLOW_ACTION_GATE) - break; + entryg = entry; + else if (entry->id == FLOW_ACTION_POLICE) + entryp = entry; - if (entry->id != FLOW_ACTION_GATE) + /* Not support without gate action */ + if (!entryg) return -EINVAL; filter = kzalloc(sizeof(*filter), GFP_KERNEL); @@ -1079,19 +1095,19 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, } /* parsing gate action */ - if (entry->gate.index >= priv->psfp_cap.max_psfp_gate) { + if (entryg->gate.index >= priv->psfp_cap.max_psfp_gate) { NL_SET_ERR_MSG_MOD(extack, "No Stream Gate resource!"); err = -ENOSPC; goto free_filter; } - if (entry->gate.num_entries >= priv->psfp_cap.max_psfp_gatelist) { + if (entryg->gate.num_entries >= priv->psfp_cap.max_psfp_gatelist) { NL_SET_ERR_MSG_MOD(extack, "No Stream Gate resource!"); err = -ENOSPC; goto free_filter; } - entries_size = struct_size(sgi, entries, entry->gate.num_entries); + entries_size = struct_size(sgi, entries, entryg->gate.num_entries); sgi = kzalloc(entries_size, GFP_KERNEL); if (!sgi) { err = -ENOMEM; @@ -1099,18 +1115,18 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, } refcount_set(&sgi->refcount, 1); - sgi->index = entry->gate.index; - sgi->init_ipv = entry->gate.prio; - sgi->basetime = entry->gate.basetime; - sgi->cycletime = entry->gate.cycletime; - sgi->num_entries = entry->gate.num_entries; + sgi->index = entryg->gate.index; + sgi->init_ipv = entryg->gate.prio; + sgi->basetime = entryg->gate.basetime; + sgi->cycletime = entryg->gate.cycletime; + sgi->num_entries = entryg->gate.num_entries; e = sgi->entries; - for (i = 0; i < entry->gate.num_entries; i++) { - e[i].gate_state = entry->gate.entries[i].gate_state; - e[i].interval = entry->gate.entries[i].interval; - e[i].ipv = entry->gate.entries[i].ipv; - e[i].maxoctets = entry->gate.entries[i].maxoctets; + for (i = 0; i < entryg->gate.num_entries; i++) { + e[i].gate_state = entryg->gate.entries[i].gate_state; + e[i].interval = entryg->gate.entries[i].interval; + e[i].ipv = entryg->gate.entries[i].ipv; + e[i].maxoctets = entryg->gate.entries[i].maxoctets; } filter->sgi_index = sgi->index; @@ -1127,6 +1143,10 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, /* flow meter not support yet */ sfi->meter_id = ENETC_PSFP_WILDCARD; + /* Max frame size */ + if (entryp) + sfi->maxsdu = entryp->police.mtu; + /* prio ref the filter prio */ if (f->common.prio && f->common.prio <= BIT(3)) sfi->prio = f->common.prio - 1; From patchwork Tue Jun 23 06:34:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po Liu X-Patchwork-Id: 1314929 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=TqaIsmsp; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49rc0q46z8z9sSF for ; Tue, 23 Jun 2020 16:33:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731166AbgFWGdK (ORCPT ); Tue, 23 Jun 2020 02:33:10 -0400 Received: from mail-eopbgr60083.outbound.protection.outlook.com ([40.107.6.83]:33729 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730635AbgFWGdJ (ORCPT ); Tue, 23 Jun 2020 02:33:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HD1FHsJCVkH7+GBNkn+t4cv/4jr1N0XmAJXqI+L9xaC62MzoX3Fz94Q0w/Ze87Vsuwii4bIUuVu6rm92uXhSjda3WyyaGTRbZuWYxuYkHlrBJG6m6JBGC4gNHXdMKUamogTth4u8AKeuLVQg7v7KR41q2khQ/sdDQkIzOdkGj7LBsBlyKrixgF5GKVd+HlYaymhbaPbfS7qSHa6hZTX/lQxwCfwtRanMwTxsCssNogLRRbXeumcStDAU1q5ZYbsjbxVltG9H8wncQ78gu5dU62VbxHybG8GFE9qvm3ECSRnJQpB5ksQJbdkOlf19r/8vazAuR8wro+jmAw8/uE7ERw== 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=ByM5pfnHQSOGibcdoh8ZP/U1OQWwIzbxrsHPfSsnowI=; b=LBl6D8g5fdE/E9YFkMJk5CCv0F+iGcyP6o7dHIp2OXf+hp8/KyFugQ3Lxb/7CicncLYbX+Pc8c4fWPMw/VtVQEJGw+I9M3Qd9/XPbcG2DxELx1mYCRTTo0yWr8de8RtO5sJh90p7fbNMU7jAxtR3EYAT4WXvmWuXrMiT9KyJPLvR3b4WUGiaJD2SqXg1GUZ4C/WrufR7eRJzQ6XZq21LmkFydKJkCLRgBdon6s+ZemO3SucWs2+WRqBNljlvZMJ5+SBPAPsQUjh3XvOqUN+OuCw/yMotfi95J9mhAh91wJMPkj6tAEDp8jDFxwB0YTIztuq8fi3DaadkWHdAG7CbNQ== 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=ByM5pfnHQSOGibcdoh8ZP/U1OQWwIzbxrsHPfSsnowI=; b=TqaIsmspBUVZ1iyjVNWMGIEzZD/sJw4Xq3kqcD8LNjiy9hM+q8X0lrtudJbFNxBozget93fjODPAfGCP/FhQhGBv1xgntQ+6r8NJJc84DTps5SKT4pkr5ID2ff1xtmB9Obh3DSAWbgZydPXQIMNb4kIHXmDJkcRNbidOIG6U/vA= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) by VE1PR04MB6688.eurprd04.prod.outlook.com (2603:10a6:803:127::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Tue, 23 Jun 2020 06:33:05 +0000 Received: from VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::c1ea:5943:40e8:58f1]) by VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::c1ea:5943:40e8:58f1%3]) with mapi id 15.20.3109.027; Tue, 23 Jun 2020 06:33:05 +0000 From: Po Liu To: davem@davemloft.net, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, idosch@idosch.org Cc: jiri@resnulli.us, vinicius.gomes@intel.com, vlad@buslov.dev, 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: [v1,net-next 3/4] net: qos: police action add index for tc flower offloading Date: Tue, 23 Jun 2020 14:34:11 +0800 Message-Id: <20200623063412.19180-3-po.liu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200623063412.19180-1-po.liu@nxp.com> References: <20200306125608.11717-7-Po.Liu@nxp.com> <20200623063412.19180-1-po.liu@nxp.com> X-ClientProxiedBy: SGAP274CA0003.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::15) To VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tsn.ap.freescale.net (119.31.174.73) by SGAP274CA0003.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Tue, 23 Jun 2020 06:32:56 +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: 274df7be-6311-42de-bb0e-08d8173f48e3 X-MS-TrafficTypeDiagnostic: VE1PR04MB6688: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 04433051BF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NPvhIOGHNyJGUP+mu8n1ftgtsEZovAOjDsThG1OKP/PbcfN9QypqbrWN/Nwou9ASeD9uu53hiYsj1LUJhPugMLYNxIcHPA8QGpSh6iNqrp3zbTtHWKcLMeCMQzv+vrYtDU7Ph/hcl0hnnCdpBYNTaRXhulDn0AK4MMBBU3y56SEDdmIw8eOcroxMQDgPC82fhV4USeEm1NaZlLqcoW1kfabu0nAFCmUnD1crENwMptxQ49W6ZjaljSvT4zbJdyL9LnQ4lqrkJHhg6sGN6e14JjX6gbIiFtZW/Vcgw4VZjzeQPJlzPs7WMHAMMr51Sr2kDDkID3QbV1p/8t+ZfHh7Xg== 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:(4636009)(136003)(396003)(376002)(346002)(366004)(39860400002)(6506007)(5660300002)(6512007)(8936002)(26005)(8676002)(2906002)(86362001)(1076003)(66946007)(66556008)(16526019)(186003)(66476007)(36756003)(6666004)(956004)(4326008)(44832011)(7416002)(2616005)(478600001)(316002)(52116002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: qxZt4p9tBhh8MHRC+0t2zxUYzrTSgvw2hziTmUvQ467GYJch9rsl5eGKxttbQVOkFjdeJsrYGJErjtSJNvyKgC/KZM0jrQQlir05issGO9SBr0J8DF3lRsAnOWFoeCU0SQkNx3wZvgtomSGFTta46SPY+54bnWEQcPocWNi0jDa28f5Y9L4dOqtzPbkEP9Rz1wAZhHHace2ScVb3PXHVK0yN9YYNQDsJo/514slxNkbVBwiqKA/meUqHcFd9QfGRRkme2EwF9ic09C+ZWgniRx2cUVVsXMROyNu+PMC7UArpeWxU123zYo3BvhwLZUCBLCrUgXy42YCifXOPlr0qZs6w51rNHKHpUwaZ3a5abJvT9xM1nxQiKOw0G2sLhRp5oqvsCl+5o/t5WdBOImCJ3mXfeNCOPKbXm6MKUBbKDUPI8AKiFJXKfYE/y5otBiMuh5YcOIJTahZhM3uiZP+yadqBM//hVbWEZF4p8auRc5U= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 274df7be-6311-42de-bb0e-08d8173f48e3 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2020 06:33:05.5022 (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: N51uSnAEhiliDMfMcQLI0gLdkTZhqCYXTl/4MhTCh0MW7IIRMzu01Ku0szy4Hg79 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6688 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Po Liu Hardware may own many entries for police flow. So that make one(or multi) flow to be policed by one hardware entry. This patch add the police action index provide to the driver side make it mapping the driver hardware entry index. Signed-off-by: Po Liu --- include/net/flow_offload.h | 1 + net/sched/cls_api.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index c2ef19c6b27d..eed98075b1ae 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -232,6 +232,7 @@ struct flow_action_entry { bool truncate; } sample; struct { /* FLOW_ACTION_POLICE */ + u32 index; s64 burst; u64 rate_bytes_ps; u32 mtu; diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 6aba7d5ba1ec..fdc4c89ca1fa 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3659,6 +3659,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->police.rate_bytes_ps = tcf_police_rate_bytes_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); From patchwork Tue Jun 23 06:34:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po Liu X-Patchwork-Id: 1314931 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=V/GhyuD6; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49rc0z0jKMz9sRh for ; Tue, 23 Jun 2020 16:33:23 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731218AbgFWGdT (ORCPT ); Tue, 23 Jun 2020 02:33:19 -0400 Received: from mail-eopbgr60071.outbound.protection.outlook.com ([40.107.6.71]:22662 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730635AbgFWGdT (ORCPT ); Tue, 23 Jun 2020 02:33:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dgRYkrwmidFCybGk6oAUyNUj+5kDP4xyY4ZCIqtoWkw7e07NEQLBmcxLM5R/pwtkb3LQAxDwzye08Bpd+6fil13RmlGEVgFE5cLkfsKT/DhOTVwax3ai4a6I5HNX85DGYFg32TxG3oN0Gx7kxh5YnRNdvZBUtU9WlBwLfdPEjqdpFIzyl5/XzNfswnsOen/dw7D9tJCyU8vOWQ+8HzyET6xeJj07vZMVyOI45nKo6vv1+poo4lPdwMbJGId6vpS2nhnCKSFm/TZJorHB20eNyTsti9GbNdcnwYrP/b2LKw6JpaxGJf7HiDbpaC6BgUMgml/UgmkHlUjZ8mcQeBSyqQ== 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=h9eKvn5VAuc87bXOoy+Czi6VGwdHVOnK9nP4mcsC8dY=; b=imNArRJVWWcGcE6hg0lmdvQTX5qZfibRa2BTGnk0QVrrfl5AfvG9LRWJQz2KXZEKyaGdV50jqdEndJcJXQ4o8E7ICEMom6K7M3cyYphlLlqR6zv1sVZdMk7SfHN+f+iv73XEeGO+N2ZSrN+MtBJ5i/2Bz8obqn6HLA6fNb+J+ItblG9b8lW0NkFWJfzD9ZX8RwJFKfKQv5c07A3wqk9BRwYf18cdstfdYeVXV7OYoayAs4YeVp9TqOT8b4sCNpION1z3IZflrCGnNQ5G9/iKRNUIRnyKpNLNCHggF+YVF+T8udixgcB65RcNnoPTk4maIHv4n3iuOcXrv2IHmvPizQ== 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=h9eKvn5VAuc87bXOoy+Czi6VGwdHVOnK9nP4mcsC8dY=; b=V/GhyuD6y3XgcU/xj6mlfr7dR1b+rtci5LWMXmO9bnnDP30G08YYZDNua6HDvfOE0MrEnG7LgOyZCmLzVIOy7nqsX7jHyNoMCuHRxcHJh8cTdtJJZgNcgAkP6gPfEAF+NCYwcU5mxnpmNIxg6kv8Fd1Erg0/7LKUG3/lpCNjOpc= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) by VE1PR04MB6688.eurprd04.prod.outlook.com (2603:10a6:803:127::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Tue, 23 Jun 2020 06:33:14 +0000 Received: from VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::c1ea:5943:40e8:58f1]) by VE1PR04MB6496.eurprd04.prod.outlook.com ([fe80::c1ea:5943:40e8:58f1%3]) with mapi id 15.20.3109.027; Tue, 23 Jun 2020 06:33:14 +0000 From: Po Liu To: davem@davemloft.net, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, idosch@idosch.org Cc: jiri@resnulli.us, vinicius.gomes@intel.com, vlad@buslov.dev, 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: [v1,net-next 4/4] net: enetc add tc flower offload flow metering policing action Date: Tue, 23 Jun 2020 14:34:12 +0800 Message-Id: <20200623063412.19180-4-po.liu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200623063412.19180-1-po.liu@nxp.com> References: <20200306125608.11717-7-Po.Liu@nxp.com> <20200623063412.19180-1-po.liu@nxp.com> X-ClientProxiedBy: SGAP274CA0003.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::15) To VE1PR04MB6496.eurprd04.prod.outlook.com (2603:10a6:803:11c::29) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tsn.ap.freescale.net (119.31.174.73) by SGAP274CA0003.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Tue, 23 Jun 2020 06:33:05 +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: 84bb74d2-cff2-4ae6-4d3d-08d8173f4e41 X-MS-TrafficTypeDiagnostic: VE1PR04MB6688: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-Forefront-PRVS: 04433051BF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ufyHrnkLvNBWFlFjf9dVeOt3ZHOEhjeW00S5dPEo1MO40Z4RxiVVDNxExIgfgT6UQo9g0Aw8XcXCUaOqgZTPTE9jkXNZQHEEWhZlSaBFxfqM3AM/19BVKamOy7g9r2INK4sgDVxoPI7kMdQU87K6OuzZj4RpeATIMC71Z1IDjqgtmdpbLMu98HMGMsAhmwtd5YpUR86lLEepBP10rQKgEUYNr0IuEerd8+3xH9PuxsvzoL+XEgDtXOyqP3EqWEFQTNnYMnz8VqcPgPCh+988OjNCFEdarhKm6EfUuYGgvMOHwI/ZcnFVC5IONGbIwUHs 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:(4636009)(136003)(396003)(376002)(346002)(366004)(39860400002)(6506007)(5660300002)(6512007)(8936002)(26005)(8676002)(2906002)(86362001)(1076003)(66946007)(66556008)(16526019)(186003)(66476007)(36756003)(6666004)(956004)(4326008)(44832011)(7416002)(2616005)(83380400001)(478600001)(316002)(52116002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1PK5E273j8HetaaoDz4IM8iOOBOWWbcgjwFSvoyLxoNaKAlS5RrBpgqZ/8RkYQOXc4Uenr5NpOyMbDjOFJh8WxBBPR3cZYVkrA8U6USKhVJ8K3cbwcIwRQgVIBRyw6qSR5XE+i1sS1F1AhNpRqQzCLPdq0mPgQMjlo32WM7Aga7cTwL7vsmGzvJoKlr5qGmynhGuctolkY750SqkC0ltOU5zZznERqmgsODfRAY22Y56xuWrZII3QhRjbxQABXDUgN3132eXPG54XyMS7bXsV90H8fPB3FV0IZ72BGgNV52+hOJkq9402Ru+TJ7lU8L7p8B9mr0vfdNgRi1ZN0DeuWvt84S60RheBLXrq93wKGnUuqmhJFFNuVcrMZo0pMETyAbJvw4SAs/VlLXzNdwHWNwnY0Zm2TVrbb5AYg/LueRMwVJ0OCz+bFYoOXRNeudE60yVcBd+jh8TEwqFxiNnjh4k7Ut6VA5mh1CU+LfRHOY= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84bb74d2-cff2-4ae6-4d3d-08d8173f4e41 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2020 06:33:13.9274 (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: SGbbi5DcTL9qtnBdFq4j4kimUDwMVUFGzNe32t1xh/EWFJnkh+RBt3Hcc+SZbVQv X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6688 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Po Liu Flow metering entries in IEEE 802.1Qci is an optional function for a flow filtering module. Flow metering is two rates two buckets and three color marker to policing the frames. This patch only enable one rate one bucket and in color blind mode. Flow metering instance are as specified in the algorithm in MEF 10.3 and in Bandwidth Profile Parameters. They are: a) Flow meter instance identifier. An integer value identifying the flow meter instance. The patch use the police 'index' as thin value. b) Committed Information Rate (CIR), in bits per second. This patch use the 'rate_bytes_ps' represent this value. c) Committed Burst Size (CBS), in octets. This patch use the 'burst' represent this value. d) Excess Information Rate (EIR), in bits per second. e) Excess Burst Size per Bandwidth Profile Flow (EBS), in octets. And plus some other parameters. This patch set EIR/EBS default disable and color blind mode. Signed-off-by: Po Liu Reported-by: kernel test robot Reported-by: kernel test robot --- .../net/ethernet/freescale/enetc/enetc_hw.h | 24 +++ .../net/ethernet/freescale/enetc/enetc_qos.c | 160 ++++++++++++++++-- 2 files changed, 172 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 6314051bc6c1..f00c4382423e 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -570,6 +570,7 @@ enum bdcr_cmd_class { BDCR_CMD_STREAM_IDENTIFY, BDCR_CMD_STREAM_FILTER, BDCR_CMD_STREAM_GCL, + BDCR_CMD_FLOW_METER, __BDCR_CMD_MAX_LEN, BDCR_CMD_MAX_LEN = __BDCR_CMD_MAX_LEN - 1, }; @@ -736,10 +737,33 @@ struct sgcl_data { struct sgce sgcl[0]; }; +#define ENETC_CBDR_FMI_MR BIT(0) +#define ENETC_CBDR_FMI_MREN BIT(1) +#define ENETC_CBDR_FMI_DOY BIT(2) +#define ENETC_CBDR_FMI_CM BIT(3) +#define ENETC_CBDR_FMI_CF BIT(4) +#define ENETC_CBDR_FMI_NDOR BIT(5) +#define ENETC_CBDR_FMI_OALEN BIT(6) +#define ENETC_CBDR_FMI_IRFPP_MASK GENMASK(4, 0) + +/* class 10: command 0/1, Flow Meter Instance Set, short Format */ +struct fmi_conf { + __le32 cir; + __le32 cbs; + __le32 eir; + __le32 ebs; + u8 conf; + u8 res1; + u8 ir_fpp; + u8 res2[4]; + u8 en; +}; + struct enetc_cbd { union{ struct sfi_conf sfi_conf; struct sgi_table sgi_table; + struct fmi_conf fmi_conf; struct { __le32 addr[2]; union { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index 07f98bf7a06b..2d79962daf4a 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -408,10 +408,26 @@ struct enetc_psfp_gate { struct action_gate_entry entries[0]; }; +/* Only enable the green color frame now + * Will add eir and ebs color blind, couple flag etc when + * policing action add more offloading parameters + */ +struct enetc_psfp_meter { + u32 index; + u32 cir; + u32 cbs; + refcount_t refcount; + struct hlist_node node; +}; + +#define ENETC_PSFP_FLAGS_FMI BIT(0) + struct enetc_stream_filter { struct enetc_streamid sid; u32 sfi_index; u32 sgi_index; + u32 flags; + u32 fmi_index; struct flow_stats stats; struct hlist_node node; }; @@ -422,6 +438,7 @@ struct enetc_psfp { struct hlist_head stream_list; struct hlist_head psfp_filter_list; struct hlist_head psfp_gate_list; + struct hlist_head psfp_meter_list; spinlock_t psfp_lock; /* spinlock for the struct enetc_psfp r/w */ }; @@ -842,6 +859,47 @@ static int enetc_streamgate_hw_set(struct enetc_ndev_priv *priv, return err; } +static int enetc_flowmeter_hw_set(struct enetc_ndev_priv *priv, + struct enetc_psfp_meter *fmi, + u8 enable) +{ + struct enetc_cbd cbd = { .cmd = 0 }; + struct fmi_conf *fmi_config; + u64 temp = 0; + + cbd.index = cpu_to_le16((u16)fmi->index); + cbd.cls = BDCR_CMD_FLOW_METER; + cbd.status_flags = 0x80; + + if (!enable) + return enetc_send_cmd(priv->si, &cbd); + + fmi_config = &cbd.fmi_conf; + fmi_config->en = 0x80; + + if (fmi->cir) { + temp = (u64)8000 * fmi->cir; + temp = temp / 3725; + } + + fmi_config->cir = cpu_to_le32((u32)temp); + fmi_config->cbs = cpu_to_le32(fmi->cbs); + + /* Default for eir ebs disable */ + fmi_config->eir = 0; + fmi_config->ebs = 0; + + /* Default: + * mark red disable + * drop on yellow disable + * color mode disable + * couple flag disable + */ + fmi_config->conf = 0; + + return enetc_send_cmd(priv->si, &cbd); +} + static struct enetc_stream_filter *enetc_get_stream_by_index(u32 index) { struct enetc_stream_filter *f; @@ -875,6 +933,17 @@ static struct enetc_psfp_filter *enetc_get_filter_by_index(u32 index) return NULL; } +static struct enetc_psfp_meter *enetc_get_meter_by_index(u32 index) +{ + struct enetc_psfp_meter *m; + + hlist_for_each_entry(m, &epsfp.psfp_meter_list, node) + if (m->index == index) + return m; + + return NULL; +} + static struct enetc_psfp_filter *enetc_psfp_check_sfi(struct enetc_psfp_filter *sfi) { @@ -934,9 +1003,27 @@ static void stream_gate_unref(struct enetc_ndev_priv *priv, u32 index) } } +static void flow_meter_unref(struct enetc_ndev_priv *priv, u32 index) +{ + struct enetc_psfp_meter *fmi; + u8 z; + + fmi = enetc_get_meter_by_index(index); + WARN_ON(!fmi); + z = refcount_dec_and_test(&fmi->refcount); + if (z) { + enetc_flowmeter_hw_set(priv, fmi, false); + hlist_del(&fmi->node); + kfree(fmi); + } +} + static void remove_one_chain(struct enetc_ndev_priv *priv, struct enetc_stream_filter *filter) { + if (filter->flags & ENETC_PSFP_FLAGS_FMI) + flow_meter_unref(priv, filter->fmi_index); + stream_gate_unref(priv, filter->sgi_index); stream_filter_unref(priv, filter->sfi_index); @@ -947,7 +1034,8 @@ static void remove_one_chain(struct enetc_ndev_priv *priv, static int enetc_psfp_hw_set(struct enetc_ndev_priv *priv, struct enetc_streamid *sid, struct enetc_psfp_filter *sfi, - struct enetc_psfp_gate *sgi) + struct enetc_psfp_gate *sgi, + struct enetc_psfp_meter *fmi) { int err; @@ -965,8 +1053,16 @@ static int enetc_psfp_hw_set(struct enetc_ndev_priv *priv, if (err) goto revert_sfi; + if (fmi) { + err = enetc_flowmeter_hw_set(priv, fmi, true); + if (err) + goto revert_sgi; + } + return 0; +revert_sgi: + enetc_streamgate_hw_set(priv, sgi, false); revert_sfi: if (sfi) enetc_streamfilter_hw_set(priv, sfi, false); @@ -995,6 +1091,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, struct flow_rule *rule = flow_cls_offload_flow_rule(f); struct netlink_ext_ack *extack = f->common.extack; struct enetc_stream_filter *filter, *old_filter; + struct enetc_psfp_meter *fmi = NULL, *old_fmi; struct enetc_psfp_filter *sfi, *old_sfi; struct enetc_psfp_gate *sgi, *old_sgi; struct flow_action_entry *entry; @@ -1139,13 +1236,34 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, refcount_set(&sfi->refcount, 1); sfi->gate_id = sgi->index; - - /* flow meter not support yet */ sfi->meter_id = ENETC_PSFP_WILDCARD; - /* Max frame size */ - if (entryp) - sfi->maxsdu = entryp->police.mtu; + /* Flow meter and max frame size */ + if (entryp) { + if (entryp->police.burst) { + u64 temp; + + fmi = kzalloc(sizeof(*fmi), GFP_KERNEL); + if (!fmi) { + err = -ENOMEM; + goto free_sfi; + } + refcount_set(&fmi->refcount, 1); + fmi->cir = entryp->police.rate_bytes_ps; + /* Convert to original burst value */ + temp = entryp->police.burst * fmi->cir; + temp = div_u64(temp, 1000000000ULL); + + fmi->cbs = temp; + fmi->index = entryp->police.index; + filter->flags |= ENETC_PSFP_FLAGS_FMI; + filter->fmi_index = fmi->index; + sfi->meter_id = fmi->index; + } + + if (entryp->police.mtu) + sfi->maxsdu = entryp->police.mtu; + } /* prio ref the filter prio */ if (f->common.prio && f->common.prio <= BIT(3)) @@ -1161,7 +1279,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, if (sfi->handle < 0) { NL_SET_ERR_MSG_MOD(extack, "No Stream Filter resource!"); err = -ENOSPC; - goto free_sfi; + goto free_fmi; } sfi->index = index; @@ -1177,11 +1295,23 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, } err = enetc_psfp_hw_set(priv, &filter->sid, - sfi_overwrite ? NULL : sfi, sgi); + sfi_overwrite ? NULL : sfi, sgi, fmi); if (err) - goto free_sfi; + goto free_fmi; spin_lock(&epsfp.psfp_lock); + if (filter->flags & ENETC_PSFP_FLAGS_FMI) { + old_fmi = enetc_get_meter_by_index(filter->fmi_index); + if (old_fmi) { + fmi->refcount = old_fmi->refcount; + refcount_set(&fmi->refcount, + refcount_read(&old_fmi->refcount) + 1); + hlist_del(&old_fmi->node); + kfree(old_fmi); + } + hlist_add_head(&fmi->node, &epsfp.psfp_meter_list); + } + /* Remove the old node if exist and update with a new node */ old_sgi = enetc_get_gate_by_index(filter->sgi_index); if (old_sgi) { @@ -1212,6 +1342,8 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, return 0; +free_fmi: + kfree(fmi); free_sfi: kfree(sfi); free_gate: @@ -1310,9 +1442,13 @@ static int enetc_psfp_get_stats(struct enetc_ndev_priv *priv, return -EINVAL; spin_lock(&epsfp.psfp_lock); - stats.pkts = counters.matching_frames_count - filter->stats.pkts; - stats.drops = counters.not_passing_frames_count - - filter->stats.drops; + stats.pkts = counters.matching_frames_count + + counters.not_passing_sdu_count - + filter->stats.pkts; + stats.drops = counters.not_passing_frames_count + + counters.not_passing_sdu_count + + counters.red_frames_count - + filter->stats.drops; stats.lastused = filter->stats.lastused; filter->stats.pkts += stats.pkts; filter->stats.drops += stats.drops;