From patchwork Thu Oct 17 16:52:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13840373 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23F6F1DFE09; Thu, 17 Oct 2024 16:52:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729183972; cv=fail; b=FnofPzNSHmbVq7iVYJ+XxvwQCESv06ZWTjfWuH43qJUX7O3w9IJgolfH19MXRUiaiFfLyfco+MI5x3SjF3MF6dN10VNqHnYpyiJh1Tihz/FmJYV0OCgJd7gN5eFten4gDK/hU16PIezh4kGP1W+5pewIYXWXKkRQEkqCP4tHrDw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729183972; c=relaxed/simple; bh=8X/ng/ITkku5TuCag9lOPC01Pjy6+sBzmUo9OwDKPhI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=mN0bFkLm6UIawFezKPvxs+fGLIn+FDsLo8Wpa7SY0T/74xCJVfpsO1Wo+mMASyxt0yC5kjMT5/4jRSkVa0jw+xwA3ipYRvQFPmUugVYVrmo7biiP8BKJOm2apjT5mXwkPHGIx0dbQtQ7on+Mbm3UHKtyhugAzgGeGbgVoVoiCII= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Ve8DJ0Qa; arc=fail smtp.client-ip=40.107.21.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Ve8DJ0Qa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p492kbJOV3Y1JKAS1ApjUItyvhMWz5xl81O/RIcnv/4QZuOfhVtuRDpUcXLFALlXi8//uM3eKxFlgQpvkTUtJIZMs5lHu4+jOjZJg4cbZjIUNk5cyL1OzR9Qvm1+8bxCWHlk1Aj1weJO9IkjZT+AFA2uvx8Gbp/2z5C80tPVgsrrRN3+qLgFVfZPlOWI65ai5cTRf65Hupa16V5bVpoIDCtsX8T1SQJSwdKbDQ0dv21KskShrw8zbC+B8c7B8RP6/t+rxbxbB8rMP8PNIa+85zC7XxyjOJCzgTEdwZTMYx16xpAACaT2fHl57gyYnN7lfNBT7r3frnHm4x4NBKi1MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=CjTGaZx7m/Ncoc+EIeo0xDgDS0nmB+x9+grt1iYqvJc=; b=loAkcdCLiTKCCObCuxz9Ij8V3YTL3lIMzCeCTHh2k41Z2nE3rSfItqxavNM3n/kbScZdqQabhNpWd5lEdRI6YhHJ6YBeAnOOHXYb+fOaxl9Sgyy/ekBHzPlVsU+5NjHdrIoAV0wvMwjOo1RHRIii7Cm9kp55pEoeY8FmF2stZhlJqcYVB3bZrPGMs2Cl1QFTc9Ys6i2V6hs3QasZDUuraV4RvbbS+IPenSglV+g8aSnptPU6k2/ZIVlfEiquFujRdKwbaTBUWpX0uiFJzsjrWYC9Dzj7VOLVSneJoLDgTC+oeGjiRwnYeuJv/ZDxT+ipdsaWS/pzuJNCb+qmv2Eiug== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CjTGaZx7m/Ncoc+EIeo0xDgDS0nmB+x9+grt1iYqvJc=; b=Ve8DJ0Qa9ld9YFeK+r5YHUxEeh1DcUG28TGAqJlL2XK6/UA/ZY6DtuU21jzJVx7NNhHPKAP+7XaGIRon76+Ip/GK7JtcR4NMODNQlO/bSILuvAb2v9aWvUICqY73DEj3iyXI1krrwlFUD4MTKu2NI4Xbz6N+aF8d+j64hkNv2buTxKFHDN+kVqUXKUDXImQifg3YJgxhJ/haftAgWpk52VdFe+Gw2fe/yZGGetXoNfxgMqkg5NgVec4Mn5zasiv1FcpNd1eEl+pK/MmoRPclMl1Vw29CC4R37P0OufvnNAPkDPqOhq1LKjQWqzeVWPWUg/UgaqNH/2v9HefC5Mv3JA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) by VE1PR04MB7456.eurprd04.prod.outlook.com (2603:10a6:800:1ac::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Thu, 17 Oct 2024 16:52:42 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%3]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 16:52:42 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Petr Machata , Ido Schimmel , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vlad Buslov , Simon Horman , Christian Marangi , Arun Ramadoss , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 1/6] net: sched: propagate "skip_sw" flag to offload for flower and matchall Date: Thu, 17 Oct 2024 19:52:10 +0300 Message-ID: <20241017165215.3709000-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241017165215.3709000-1-vladimir.oltean@nxp.com> References: <20241017165215.3709000-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR07CA0259.eurprd07.prod.outlook.com (2603:10a6:803:b4::26) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|VE1PR04MB7456:EE_ X-MS-Office365-Filtering-Correlation-Id: a3b51cba-900f-4ca2-1756-08dceecc1e09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: WYjMGstpj59Nc+bc9YZ71pDydlsoYQvq1FtHrujZ7y5OsOvImN2T4N2ULZkws2digPbxS9Gz77me71JVDr/mpNdkKajix41bvrtM1xlGoYOlyHvwmZNQkiV/Dl9H3mB629HsTSN/Aj9PuzuO+9s3rE8XJ8clF7frtWCDO7dQzH97y1wJrA9R1LrCjHfSecFEBKSiHWbRfRvJuzHjk/yEv+CcFoj8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xCpRXU8KXaPv0V7+pcu8PSrS/GaxZfBcUZjySdE4TDJpPBTJ1spU/tkJnHXNaQsb+RGc9+shr58WclV1OifYYDEvwVYLbaf+ksUqcV X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WDEeuu+whiBvgjXbY8Q6AcSxyRd6AnQTuhF9gDHCKWMZlBaw9cFjbgZC86Y+5NuncixhVy6dPd7ZMa5+0WinM3vav+luOvjrloCyseYlo2/WHB1jJAcCUSbcGRSbnqpCNB9G08ZXA8VgEoPt+KpAPosewjC34m0E+CS+oW4abXP9kwGmhiAjBo5bLQW8Ea+KBHBMKbsk0uvZ5yZ4V0Ke79BR8XZfsdxzBEmi7yTp2DGyNLdlxYpiJ5VrCHFQSWrLNMFIHBCVSLe+IQSpeL5O1xq+V+mvc8LSHcq5d3U/Cn5AMpOorv+x1Vm3CXZ0wCeAG+6ZRuG+nu86wuEfr2pL7FT156g059UXkSAX4F0zL8DRnzNnZJjupWtyFVKYg6waVlf3n1qdXdbpySZ5MLXQnq0tj3BgPF86YksFWXtCqKLCnP/cdDRmGYEPGlV0GyaXielw55g7BLz2xtwammqCvY/9zyzqKY8MXtGyRE12ockRn9sk6YyeBVmIpOih7Q2whD0hRXlqiWYGZKe1HOMZQBSDkVkZjShcTvv1/gYOkaNvMiRP/Y6d+0z355mUztmNnC1t9SBoVg50rxjyZMu7WhM2Mv5w3lNcJPJtvFcfTr85okc+/6RMxnydmSslQhYbKYCcLosHQGGf1mMbqWTurHoabuWq83WNqxlykAnOlYi1RV+I9owoMtOWSw05VYBZ8XDbavigOA6QtlR6Yy2vkPNebPSJDWnGctcst3V8nji5m3TFNoy2/2xQPAK3RcW7g7TSzWfaVYla27SVsgcNccUZ5tPqvy4VUB+JlSBME0SoNa3pg8yNsSpl4ZzJFabj+X8p4MWHEvceEp+veV/noht8PB/IRzUO5gq/67NpCXS+0LLoOVyUoTsF+Dm/FEvtjdfmlgfF6Ac14IOXAiHuPNtB0UyAxGSDaphmdlaxZF3zBVvwUQmacDO8/buTD5BjXOsPNnMcXfx5k/Ul3XzfCkjd47hVM5Zz8I+KPtO0d/2XGTQOsluuxZ6dEv+2pD+vb2xqWjj59EOQkR3NMjqHsyWoMRCCAzWG36bh1O6SNMibgHMNm9Zpb80qA+YPKOxeKdbQukBjtJUKq+phnufmPJ47r/MuOdK2fg48AkF/EqIv93ERBnTZNAyMYhJxF951h4ugXYqKX8UH+RW7B17W+4hO/33JBhLSxVMMRkaW3V3RabVHDt88pfbo2JL2Jh8qgoq14ILjei2wFAovhrMFTdaC2urzQsUjqZ4QI/DHwhKRCAdgDES3wM/5QBlhRcarzY756Lgn9n0GHz5bpwKR8wwJHPfH2R70QTC8VWaWmycEKcTi1qDXvYaMLnkCPeq0SrdQqbo64e+S4BY7QNZV0/MDzdt2PLxPETLnMmlfvTtq3AB1s43XHV9J6xapeU7dB1D41bmv2FCNKU88p1zCRs6imkxaq/jd0hsyUbn6+3uFPqfGK/i6iPIkOXQtk6aWZThLfSJ1wPaIO0oq28ULFGVpYBX6SABbVxmfOYjpwXMzUeN5qcV5czBV9xFEc2OjvA+IezirY1VeKN5UWJfZxfTi8zYSNgtgqAJUTEK9XnEOMrOll5TCPWiUmo9ZNC5JJ+Yf6sUmj8nKaoXYGNt1Ng== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a3b51cba-900f-4ca2-1756-08dceecc1e09 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:52:42.5702 (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: K30xbE9RevnM4427SBta+gzCmRSGOz+nudhk8hEqu/7/10PhTrGinnr0AKd2xTcuwYnEa6hy5GNgqrh7DjXphg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7456 X-Patchwork-Delegate: kuba@kernel.org Background: switchdev ports offload the Linux bridge, and most of the packets they handle will never see the CPU. The ports between which there exists no hardware data path are considered 'foreign' to switchdev. These can either be normal physical NICs without switchdev offload, or incompatible switchdev ports, or virtual interfaces like veth/dummy/etc. In some cases, an offloaded filter can only do half the work, and the rest must be handled by software. Redirecting/mirroring from the ingress of a switchdev port towards a foreign interface is one example of combined hardware/software data path. The most that the switchdev port can do is to extract the matching packets from its offloaded data path and send them to the CPU. From there on, the software filter runs (a second time, after the first run in hardware) on the packet and performs the mirred action. It makes sense for switchdev drivers which allow this kind of "half offloading" to sense the "skip_sw" flag of the filter/action pair, and deny attempts from the user to install a filter that does not run in software, because that simply won't work. In fact, a mirred action on a switchdev port towards a dummy interface appears to be a valid way of (selectively) monitoring offloaded traffic that flows through it. IFF_PROMISC was also discussed years ago, but (despite initial disagreement) there seems to be consensus that this flag should not affect the destination taken by packets, but merely whether or not the NIC discards packets with unknown MAC DA for local processing. Only the flower and matchall classifiers are of interest to me for purely pragmatic reasons: these are offloaded by DSA currently. [1] https://lore.kernel.org/netdev/20190830092637.7f83d162@ceranb/ [2] https://lore.kernel.org/netdev/20191002233750.13566-1-olteanv@gmail.com/ Signed-off-by: Vladimir Oltean --- v1->v2: rewrite commit message include/net/flow_offload.h | 1 + include/net/pkt_cls.h | 1 + net/sched/cls_flower.c | 1 + net/sched/cls_matchall.c | 1 + 4 files changed, 4 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 292cd8f4b762..a2f688dd0447 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -692,6 +692,7 @@ struct flow_cls_offload { struct flow_cls_common_offload common; enum flow_cls_command command; bool use_act_stats; + bool skip_sw; unsigned long cookie; struct flow_rule *rule; struct flow_stats stats; diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 4880b3a7aced..7b9f41f33c33 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -782,6 +782,7 @@ struct tc_cls_matchall_offload { struct flow_rule *rule; struct flow_stats stats; bool use_act_stats; + bool skip_sw; unsigned long cookie; }; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index e280c27cb9f9..8f7c60805f85 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -480,6 +480,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, cls_flower.rule->match.mask = &f->mask->key; cls_flower.rule->match.key = &f->mkey; cls_flower.classid = f->res.classid; + cls_flower.skip_sw = skip_sw; err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts, cls_flower.common.extack); diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 9f1e62ca508d..9bd598f8a46c 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -98,6 +98,7 @@ static int mall_replace_hw_filter(struct tcf_proto *tp, tc_cls_common_offload_init(&cls_mall.common, tp, head->flags, extack); cls_mall.command = TC_CLSMATCHALL_REPLACE; cls_mall.cookie = cookie; + cls_mall.skip_sw = skip_sw; err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts, cls_mall.common.extack); From patchwork Thu Oct 17 16:52:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13840374 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D37E71E009F; Thu, 17 Oct 2024 16:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729183978; cv=fail; b=CABe+M1jGH2azNg8S1CgePpFaxW9l2Tx4AQvSwS4aSKUMQkMkvLQEz6x8sc/8eBOXml0ZPnGn+RZ+SGj5QXRsSroiCXD3Bxdn3LNKMLqdCuaYnli6/FjhDqjICYiqXnZ40ziLzgu1BgQMS65nmBBAlFHAKSLlV6m9lKnbNHMnI4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729183978; c=relaxed/simple; bh=31tmF4kLJbhHgaJRvm0DZziFfsCarFaJXWweS8OS9fU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=eTwoOFKorXgS7qMh5Vr0l8SPLbJV1y5gi0moT+ugjlpWotQYG71TJtUVI0bbtxKN/0TjwLHKJt70EQueV73ZADf57nCWqqeLR1drWPVdfiQYvFA3PvjJ3pIMCFcQzc4QyY1zTeTxXmu1/drTUowGNOJH4JdGnnH+yjbzyN7HXzQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=W/C4meqX; arc=fail smtp.client-ip=40.107.21.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="W/C4meqX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eH85WQUdtvLwMKCGiX5FJ+5zwhYuihmYY7Vhchc24zq3KhzJNNG4DnQvnelfroAKxr7OmxHCDrFPRxVadr3Sts3UsBIzy7DXItUh3CQ6f8xmsI2pjHCjOOMZTT+PIjwWNyrTyJ1LCyi7fPIiikL7akSqsJsdU3xmIYa2ZhBXfhkwkK01yGt5SbbjFiS+2uARBi/JqzAOUPMdYDJTyo04pHo83NRw5QWvBvgTY6pee5YkO+jGIbeiaWO6wwTbHI/dNhF48ynLHINr/5Oa8FV4enVHYC+89OUp5ldd/VIEBHQubfKCmuME5OLs5Y+mKn7089ISsO+5Od2ve723uA/9QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Rqz/vP4IrFr2mLRViP7hbPritajETwABJJiZ/78zPrk=; b=T/t4CCLqLjpVRX34jB2xDtmsUoo9mbxL858KetIc6YMGsU+T2XmnEotd+puRXDT41/mpyGxNg+CQsc0TffpypWOKe1fRp371DOC3trLp9fS6HqgRs3PWHSHbir1GaZUIcDzyjaknb9vOqYku/qJIogJDIy6BrRk0ogpdhwuZfOuwIBHBTM9jeLoSsuOL8WuBoKmxQIZbXm58b0ebgJxZtXb//BQAoir7UlyHbzQGudvlj6J0+07mjWdCq1ie3lThCK6CkM/83Ck9v/JHdwcrv9p1vXMDOp1ihduUjBEz4omy9FDZsFY4ode38gDP524XLWiaGJeHTlr5bhGd+OAYXQ== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Rqz/vP4IrFr2mLRViP7hbPritajETwABJJiZ/78zPrk=; b=W/C4meqXUWCtpzAkcKZlIIllSACYHBXc7cQJQaLuCp7CuDiGNSTNeIyNfLnXb5BIocviHT5Qn8c+GsyM4YZobmKHIrJUGcytgUHo/rFMXi+gD3gglvXf5IJo0nDz93RiBg1lE0aCCl2z7zA/2ltSIMtNiqQ8ZL7AwVvjTcq6CNrHgwMAMQPrNMZ8O53Cf1TGIdKhix1FdOgm58GqUa8zRQUZxRJE5/d6TzmtoVvt6+pCKHyYxPy7cFkk3WQstpe/4paG8bKtG5FRTNuNWzkuSI6e7UURowKNYNq5+bLm3A1/RsLHEUnZ6VNqiWPsGhieCjKFpbP59tDLuE1scYxYSA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) by VE1PR04MB7456.eurprd04.prod.outlook.com (2603:10a6:800:1ac::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Thu, 17 Oct 2024 16:52:44 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%3]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 16:52:43 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Petr Machata , Ido Schimmel , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vlad Buslov , Simon Horman , Christian Marangi , Arun Ramadoss , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 2/6] net: dsa: clean up dsa_user_add_cls_matchall() Date: Thu, 17 Oct 2024 19:52:11 +0300 Message-ID: <20241017165215.3709000-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241017165215.3709000-1-vladimir.oltean@nxp.com> References: <20241017165215.3709000-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR07CA0259.eurprd07.prod.outlook.com (2603:10a6:803:b4::26) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|VE1PR04MB7456:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ef1db57-3ff4-4d0d-faa4-08dceecc1ed6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: 3xDsgLo/Ibsie2Z/3+YS1t+oqw1CTf4Bhj32sF8TlyJI3WBd5UBlhmkImD0oDU6L8SoQsv8s2Z4mGqz1CqomSjQhl/6D/1qTtiYLEgJrq8VNZa7T62I+bUl82EP3dw3m4zfnke6cBRG360wMMUwu+6KtIq79Yqcpf8MpEbLzKLJlMal1uVBcv5E6np8KO37DlBPZVkfM/VgIeMw5p37KlP+TNMEehJBMDLpSyIo6kN+74VZiI7p3T2nyjCm2bRUTJKno6TvJ5C+BeBZJH2r4FcXCl4yLon1mT3jH+BCzsSk5PgbM1cM2rurZAFGcMHa7c4WqngTcLtQrem3r54YWnpF9SiZL0MkEpRsl+zxXSMbCgjKK82TE8cUh5sj3Qii/UWQAYUaGeMk48ruayElSbEH/thC6T1QuZP1d/Coj0jIqXnUtkPW7EvD+hiFBlv76jK+L8XBw4NCrwUhZZPiNu/8zaoi2eZ2XHqconhY4fqoZbXeBlTXDr87Sbv2UgNhe1FgdAm7GAR2oWdPTx6yBhJuvGz8EW8r/iV+fEOIysAOaRCR8wxKia/8jOlfkiV4h7sjL9g0SRX7qfh+gRRdj2gxr4gRYHjjyHXnHkoa8v89aTyd2sTPk7FkFnUeBAXkAiCF87UgZQcV4F4cMqRyzMeKA2cp0fHfS637uPGOoESpb8LZ4FAQEIbMd4o4RAea9lrqfilLHbsfq/SwPiRKy59qYKFZM/bTqloqAUJQD4NwLzpHx73+tFSpXJYYHNuuCcYI44vFSjwcWtt/vRdnK3suCtp51IRknxNS1SPYzvcvaVN0R8HXR8o37J/STqPCz4WqL7f926rfH8FSAoNqmv5nurZoFvdKFPIV+snLQPYC4u5g6fmMnr56qivfmNOKLJT0IzwCajrhHUTtIHqm7CpTAPA4JaFtFEaBJvh7BaGoQu2mwXPJlgUzYXUxZW9+rCLXdjfTFxvNH+d9w9pHSSIokBk07ub/82+ieTeIA0Z6DiK02JM3UaSaCB5jGfy3xgl9GameQkgtEdULKBKJ9g29RUagPUPyeKTnlS70Bc2Ugn45gflfNWEfdA203Z2JkI/9UAmU7UGJzQQkO2/9To+hnAJvD44unw6GKqhy1mrP7noXc0myiOr99myhFwedTvVR9MDzAsHQny9JeZ2vQfWAi7CouLzsA2T9eo7Y+G5NgFWBq3du+AFVLaB1UbKxPN4w0shI6KLbM51fr3mhTvTKIHZoHb+LwE9BKrw/R7wpNSglxMGSfCRA6fweylYyNnubpI5T1Am20kprUcx1uK+NYgnWihcHk/L8CPyHjYWhnWtqjAEGIv9VDLXwEvRoWuObYNVsrpnZFBCnQAI7ZraVPaN21prqdRDABHn0d0w8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024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M87xtSHD2wSb1xmWPgD52sw1Iz/yDPCmLYocc2L0vuEijTrO//k7hYPFY9hExeesfslZA2nYYn1my+MnTFm7my0T726soFh7cvZVVmobLbk5awVUM5gXufRHuTcFXHzeUUwnR1Rx9tHgxEXcfNNco5dIYMJ6HYgmRuHgDvAxjoJO42TD3+s7fpmfEJaDN5gPIZTsN1hWqF2bbNRVPy1saG3kYlnHApe3IR1Du1QdgJpUpeADMetqr7xOQhTMsxqTCpTcrbx9LgyFa7DqefjtU+gYMkE9PBUifOAaWUqcWI2wAJbYWAVi6S7xMlJNBbp7ak2FfajL7s4Qpfc0FAXz7DIboTdit7PKZSbB9fs+Kn9Nt38P0w+1Bvb5mjzduqHsGytqBBhM586RQm0ywI5kr715a2ad6vus9bKzKnyrXYaxfgaWybvc+OUnniv+QpFcCNqsay5pYfanPbaAsTBYLxiuBr1zPd1cpot58o3vovebrf2asG5yGS5L8XUSp8PVg5nC9LH5ZNOytyJmZX8KwrUnqvyX39k+6iGzh+u99N79j8S2Ghi0QyhFSrwsQXxxYo4aEXgUaMuwlmFOucxZoYR9nMIn34qYz2tGBhGhkpEAIBdnGfQJTeiwDA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ef1db57-3ff4-4d0d-faa4-08dceecc1ed6 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:52:43.9682 (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: aBZiSVWzHQJUQFa/i/xMeY8CiF/WkFsxg2Uyq8idhVdycmH4ZZdnupHHm868nzHPNShd+KTMlIWzFe/PPnb8kA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7456 X-Patchwork-Delegate: kuba@kernel.org The body is a bit hard to read, hard to extend, and has duplicated conditions. Clean up the "if (many conditions) else if (many conditions, some of them repeated)" pattern by: - Moving the repeated conditions out - Replacing the repeated tests for the same variable with a switch/case - Moving the protocol check inside the dsa_user_add_cls_matchall_mirred() function call. This is pure refactoring, no logic has been changed, though some tests were reordered. The order does not matter - they are independent things to be tested for. Signed-off-by: Vladimir Oltean --- v1->v2: add some more info in commit message net/dsa/user.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/net/dsa/user.c b/net/dsa/user.c index 64f660d2334b..5d78a881ddc2 100644 --- a/net/dsa/user.c +++ b/net/dsa/user.c @@ -1377,6 +1377,9 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev, struct dsa_port *to_dp; int err; + if (cls->common.protocol != htons(ETH_P_ALL)) + return -EOPNOTSUPP; + if (!ds->ops->port_mirror_add) return -EOPNOTSUPP; @@ -1486,17 +1489,21 @@ static int dsa_user_add_cls_matchall(struct net_device *dev, struct tc_cls_matchall_offload *cls, bool ingress) { - int err = -EOPNOTSUPP; + const struct flow_action *action = &cls->rule->action; - if (cls->common.protocol == htons(ETH_P_ALL) && - flow_offload_has_one_action(&cls->rule->action) && - cls->rule->action.entries[0].id == FLOW_ACTION_MIRRED) - err = dsa_user_add_cls_matchall_mirred(dev, cls, ingress); - else if (flow_offload_has_one_action(&cls->rule->action) && - cls->rule->action.entries[0].id == FLOW_ACTION_POLICE) - err = dsa_user_add_cls_matchall_police(dev, cls, ingress); + if (!flow_offload_has_one_action(action)) + return -EOPNOTSUPP; - return err; + switch (action->entries[0].id) { + case FLOW_ACTION_MIRRED: + return dsa_user_add_cls_matchall_mirred(dev, cls, ingress); + case FLOW_ACTION_POLICE: + return dsa_user_add_cls_matchall_police(dev, cls, ingress); + default: + break; + } + + return -EOPNOTSUPP; } static void dsa_user_del_cls_matchall(struct net_device *dev, From patchwork Thu Oct 17 16:52:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13840375 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ABE41E04A2; Thu, 17 Oct 2024 16:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729183983; cv=fail; b=BeDLwZr+rdbqzYoico5J/j4/kfQ4gxch7jpdXUZVXiRWHrE3HTl3SvZFKbLoYl2QfaGrXO6WjDAywlyCIzwdyI9PUio94pOczmOnVI/25a6g5HmIcq8zFo9V8vB1k3YdRbeu9IgSylUnOQTLH5J0cF4GfeOLVtg16I+fRj0r5g8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729183983; c=relaxed/simple; bh=8b2lBFWMZFnDB/CmIFrwVlT5saDWlM7kb5KDGDNG8Sc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=QXYbOaP4GRQtiWgJho75+9k0LhhypIkB6fmVVZe2oyYIaaPPjRKpeXB/XF9V/U6VKYalksWIwzd8KLI48FUX96cMKuh1Lz8o8D2xtNurCaf2wY4WDfLEYlXSvtPFvr9FKLyHn3s0UKiUCV/fFcyV9ieJif1+Q4+DrlJ1He/YcqE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=TYxUOJLO; arc=fail smtp.client-ip=40.107.21.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="TYxUOJLO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kg4m7SH0a7KLXO6c+jk3+QbQt6q/EmRMLq10wwJgH8sasTfJeeOzosZJ6MNMuM+zk8/iEipooORXpuG+XvCVWABpKAIjmsJdc9Jmbr9PW/jRylviq79hO8UL1T1bgrVE9b4EryeXo6IBLxaM5O0noYy7byDsee0SOmSBdQzlehZxoHEyXa1WqR5G7FCdY1fWfyfMiYRzJ/23idn79X940ET8XF6vFSHPmuBv6IyF/UviOBNNohsd2+T4M0jFDdV1glaKYybs5FLBAVym07379o4Vzo9QvdSvHiumUEtFvm5Beg4IHWAy9/1XxJbYO26/zxIEWBy4d1/rvkFW7ouLAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wZVLzQwC4jPpGj/O4aSD6GwfDxudDb60l4OfODEf6o8=; b=xVMNpsvyoj7QKwj5X2E3tRCINjyEUUhwiBn8OIzX9NuItMJJ9HkWJ0TkcZQPwptEG5Ad3C4YaHnLBNpy5MDP4+W+Ojdg7jzRn1MwmaoDKuOiAPeEVTnD5B0VEri0BFbMiNiDeaiVKXZyLD7sec71SJCkVNgjXIqA8nSyHQbfjRzB5EH12LYqRmn+5ZNJZ9InG3YMLzRRTKlZTs9URUEhcJ85xxUY8/6X74tnjDkoE2RfdDeBcHdsOHrkaWHvENAjNCQmf98V5fXciYb+4S+6rYhLPnX2Y9xsuFyBn5rarPA2oao2dluFYKPOcEoeLdmnmfR0iL5m5hNdLhHlDre/pw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wZVLzQwC4jPpGj/O4aSD6GwfDxudDb60l4OfODEf6o8=; b=TYxUOJLOmEg90Sxz7q0JNTDwzIuwBU5d+Mo8n9IusXu27LMQFfRW7SwyRy6ccYNzoQA2/ci2PJMP4U4sWSpCWNqBOAF3vfutTwYGUVxpZhedemWANtT4IwLqFp+/a6hmuJYPh8kdt0OMTgE181gmlFSrwwd4WgYdVJ290OeG91MgCNBFbsS6DYXPpfxyWu5dyZ27XSIn9kF9UnpTvxCfwuWOGfsIAU7GQAbsqy3r9uFgPH6PRKN1nKuBIQNVXEKCcXg38BVINAdXkYfJuosEC3ZSWaL27R72t0ldS8T2voClOKo7S0+7H26OxSL2mFYwF23bjC/Te6d744MHfVjStw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) by VE1PR04MB7456.eurprd04.prod.outlook.com (2603:10a6:800:1ac::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Thu, 17 Oct 2024 16:52:45 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%3]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 16:52:45 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Petr Machata , Ido Schimmel , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vlad Buslov , Simon Horman , Christian Marangi , Arun Ramadoss , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 3/6] net: dsa: use "extack" as argument to flow_action_basic_hw_stats_check() Date: Thu, 17 Oct 2024 19:52:12 +0300 Message-ID: <20241017165215.3709000-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241017165215.3709000-1-vladimir.oltean@nxp.com> References: <20241017165215.3709000-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR07CA0259.eurprd07.prod.outlook.com (2603:10a6:803:b4::26) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|VE1PR04MB7456:EE_ X-MS-Office365-Filtering-Correlation-Id: 88a217a5-e6e6-4bc5-b66c-08dceecc1fad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: nwJTQTYmue3rmqx4mdUP+FS1z7YLkOsP+xgN1C987uYGWUoBXQ7XtnpbvR9zcZRr8Z0Apwzd2GtPT0fXwX63CaZDnpJAM33I8GQCLBdkKyZpXMJvBDKzZtPNT3UT8nUf68322tJNfd7pgmXqqj0JQX68DCeLddp1Q5e+VFFyQE69tK2usda5CJdIGjWFxLhv32aFOEf0ZZSpetXy+Q3iaIEeZmdfERHWfOlbRH0yP57+nr0e7srAzAWhLVajKy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tXYoqjx9J1Vjll6U2Z1XNCIiXh5YumstqLWm9vHXA1IyfURZE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xjN4XW+RgcpRFWKTuV4sJC/MCVGq4dNLeoLHaZhpaSa4q7Qc4e0627Pt6l1nZ3+Brm8S3UeFc1IQc7hDwH4ZaNfAR96py5lNbhknqtf7XDapingSVkiU1KLYpV9ZfAmh/9gasbOO/gEaLRQJ9H7jBiAECOlUV9IO7Tjsu3gZXYgS6DSrd5cmgyTxht4bBNfR8+7ZAT9sXtjNIpd8iJBz6WkFWlhRliZfIIFLIDV4/jx8Xp/4LTqVPxQBFijStTEbx/NUB1vQmWM9gwayG7V+8uJPa1voDmgE6udN0N3CK8O00K04Ge9MlT7TdCrVoswjL+9hOjtN6QH061CdITkxyhMVSKo1lKkQ7fDNTUcfRx8wIjfr5dvFtVrwAiinFLrF3iVIwkCsVTcghOY4aCMRFv4Or9hMMsVppSKzlVGbhj0+4i6oNbbHQ+wdl9JZj6APTqLhPv28h0kp/VMADv+xhWnXgKx4D4q7Xn3DpvNuBtNhqwVjck77TRaoSmwP93PkoO8p1YWghs6S62sx2UPTSFWOBiGY2DB3M9FaNKsZpd/5yiEo1/CXL3vh2lRxZ2K19CfGf2kA3RkmdPSbwPp7zE6Ul2+liXtj9NcnkzI2a3LRSSntx4YUhBhuRTJKg4TL7xcQpuxm+zyzyv4RkhcWxVcFNj9G/2fgw8AJht9B4nieeW/FcI0135ffPkhwecZwo4zNoCF6+4jYNDSyM2Z0DwY2DzmZ/U/Pil7R4VwmDi7QjsdjnKBGVLEYcjYsjEFbs7rg7G3651P56BPdAYSI1/miSWm2/u6ilWSxwGBKR/qeSr6yQvA88O0r+glR1JdVSh0rKVCG0fxJCKWHnnvny4apNfk2+rOp6xAMEB0D2rBRLveFY0vJoCq9S8p1G/cE1Y5sAR6X7XBjV6Ushcaqjv7qMpZgXtBWou/r2WwpYOW3eDD3C5L9i2wUG6xUnYi7JaBb6nr4aj79VsAJHM+LrmDfnCrvo7Y91TaBVFHAaSSAaNo5Y3iEoklyVpVl156gNUThvKZfVdEkOQmXH3o5twcXaiyLdwRM5BZrGqt9BNMcCIZCxcsWG2FtRe5cmMMO9pB6rky2Xtr0Ke89FZaRzU0FxPQuSa6m3ZiLan2EgkIgFqR7gjNfmk+FbjLD2fesRKPFHM45jvGEs9j2AWpMVFXIQGS3duyTW/3k6GxLxMZMpdCvQf+Vc0lX/q6gWbAsgiaTHzH0HVmCy5IlsHltazBjeBfuMT6kGKXMuC0Mfm6uXnM0Lq2zz1WwZshVKCYmwG0ltXPG9KNkaxItQD7hX1DOLUHdQ82Xc9aC8hKGj8UYDTev3kAiOg2S5kW3R6wr88ajZvLeZR113BpfraMu2w2sFUKSU2y23+ZhvmT7ZMXAry4TLlWgiVGpSNwKRYVjoJRV07j5jfV8m6SY+RWUMn3Y+tniipdTnbfhsUUzfaCP+kp5uvNCl9MukLxIsfswIU4D6Ay/oKQR/UbcMDBXTxdaO/qT9pCej5fjd6XNfd25+d5LwCI75+3M/ElR98Kqg/JdtK//e9/rbgSNKL24J283f7QeTEKszjPMgsJveO1zAov3AIbW/luVPHUS623AUkAj7M1sSRXQ+32fKtN4NA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88a217a5-e6e6-4bc5-b66c-08dceecc1fad X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:52:45.3964 (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: 55uxQ0Cyrwb4cuXRrvrolpCJ6guERlvps3/GdY3sek26MT3e3Bw00bH//I6LuCq0KpTrKamWoR0ecNljCXpzlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7456 X-Patchwork-Delegate: kuba@kernel.org We already have an "extack" stack variable in dsa_user_add_cls_matchall_police() and dsa_user_add_cls_matchall_mirred(), there is no need to retrieve it again from cls->common.extack. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new net/dsa/user.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/dsa/user.c b/net/dsa/user.c index 5d78a881ddc2..c398a4479b36 100644 --- a/net/dsa/user.c +++ b/net/dsa/user.c @@ -1383,8 +1383,7 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev, if (!ds->ops->port_mirror_add) return -EOPNOTSUPP; - if (!flow_action_basic_hw_stats_check(&cls->rule->action, - cls->common.extack)) + if (!flow_action_basic_hw_stats_check(&cls->rule->action, extack)) return -EOPNOTSUPP; act = &cls->rule->action.entries[0]; @@ -1450,8 +1449,7 @@ dsa_user_add_cls_matchall_police(struct net_device *dev, return -EOPNOTSUPP; } - if (!flow_action_basic_hw_stats_check(&cls->rule->action, - cls->common.extack)) + if (!flow_action_basic_hw_stats_check(&cls->rule->action, extack)) return -EOPNOTSUPP; list_for_each_entry(mall_tc_entry, &p->mall_tc_list, list) { From patchwork Thu Oct 17 16:52:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13840376 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B762A1E0B82; Thu, 17 Oct 2024 16:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729183988; cv=fail; b=jn9ONk20Z2wzfQV82umVqF/if9ayvdKVopWqeocXGgVrvKzpgDykA2V/7MLvHA/bHIbCFcdN/Wqd+Zujf/GKxfOZTHJvxrpDdaPIWGsyVlDhXT/vlfE5irziTph1AodL9IZd9Vb0uwgjE+8LiGbwc+pienAYDcliycpGhu0bGr0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729183988; c=relaxed/simple; bh=PntiEBqexw0QfEoQA6A3oK0bsZq5itXTlRG1cvsDOTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=rmZJ7IpiLh5Ay/knARPaU7bAbi22gyM2y930ModzqMjxC7tg8VPoE5TsGW59mdYZq+MDa1BTuQ/Ox4Qx4lhxnuI7VwTEs97aIG0HpuTyBeNO8Kw1+6XGe3/wZhDuru2RwA52Ma9nhOLUTmZuvpWz5Cf73ZB8tRDBn2B8zBUJdmo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=MHSQvDuh; arc=fail smtp.client-ip=40.107.21.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="MHSQvDuh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pHvfftrhYIuypu2J2CCS2V5Gnub9y6lAngeqVI8VQvcGobk0dek7rChQfK4QW9xrLqm8AYoXwy7NQ8GRHkD7n5TEwR7PD2LrFk3mp1a0Y6+8+adQ9x/Ge0bEf/GEruPTwAKXkZunLOkD+pKEtme+XGRtvZuGyskgd0KTEYIdTy12dEpbdWWZM+KsKMfyya5typ25AM7rb5a1tmzrtu6/5z9cL+BqbJbWkBWlnSq4KXUzlkldgzc9MCXvszRZH0bolDVUy0Cr91cmkoIosXHpzITgZVp/2iZn9w06uY6INQuG4llKWid8MuHOY/lMQ3kNRwufkMtssDluWMA4tMZg2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=gGYLQ0WHKOepT8HqoJkQzEoU2goA8RE8A0SaxCVq3Ak=; b=fQUfEPtcMwVm1lx677lLzrwkRYkHtd4PS/gSqvAIMToCEtFV5S4s/zenzulLu5CWY+kiLJYXrjxumSX+dPwzTcTFDr7Up/MvinUNRqb8l+O/RD9IWfgPPtod1thLY5qkHAjYyu+2XdXn40+sg0S2Zl144x74O0BoDVlx9thzzaGP49+9byM28u9jiV26F3qGvRvdmjPcC9qBtsts7HjgSpnMGFO933tkjXs1gR8GiFJVGwYJMmdT0J6UcuYn2bbeMIM8opE9abv3knHxhpp2ggTcP0nxKhGgwDnN6Rd2OSS3YnKuOqeUnBQ+9HWk6giFmw1kMrVTbxKzp8rPC7ETCw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gGYLQ0WHKOepT8HqoJkQzEoU2goA8RE8A0SaxCVq3Ak=; b=MHSQvDuh592Y7KYQHvYrKsaIrmt/fyDyeii4ZXszVqvkn4sd9D8pRmX56KTSePSoUAKVKS/kXao/1/fqjSK91OsyiP23UpP0FkF3CzAb0aOR8S7n7U78fL4tJbXm3gfjm1f/THJopcYZwmdsgRLWsMR/oNCYpkUmKfna5Gw2Twy7REX8wPvXZZc8e3fAXmnBNNDHcg+RyuPcu4J783yyq8lMLJgU8stN+uYTsaN+Ydb/9DjqGN1Yf+YIku35nKS2u+PPQlX1ovKi2CcdcEymoaZAh/+Bj+MKt4uG5m84FJgKEOwiWQg4l8s+/c1SGaC2AMk2Iyj1WHkd6iCnjhmrgw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) by VE1PR04MB7456.eurprd04.prod.outlook.com (2603:10a6:800:1ac::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Thu, 17 Oct 2024 16:52:46 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%3]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 16:52:46 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Petr Machata , Ido Schimmel , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vlad Buslov , Simon Horman , Christian Marangi , Arun Ramadoss , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 4/6] net: dsa: add more extack messages in dsa_user_add_cls_matchall_mirred() Date: Thu, 17 Oct 2024 19:52:13 +0300 Message-ID: <20241017165215.3709000-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241017165215.3709000-1-vladimir.oltean@nxp.com> References: <20241017165215.3709000-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR07CA0259.eurprd07.prod.outlook.com (2603:10a6:803:b4::26) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|VE1PR04MB7456:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ac8c848-78bb-4ea4-b410-08dceecc208c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: ZWHDjk1MaeQOtJUjzJumCn6n1dUgziDk648F1TgmSO5iTgfxGBLIUMlZ9k65XjpqmeGEzOpCvk0+j2Q5TnPb5aMhFwY7yN5KZrRGkMN4lAj+1sHayybjqOZBi0XuidXjM1ryH30Rly2awQCdhF6PIQZ767MPjJM1qn7JOqnFO4ZD6hovLlL3I9M2OCjuhn9fmnU7PEvLoMCFDPWQeJuHmrc0VeCcWQoq0MvL20Vdb23jBjIRGGiyw5L8gqcE6GK9wfr3wPtPZujrZ8qNn4KcoEmBxBBrdTy9uGuvOR0sIr4lxbfAolki+MIz4Yobg2nL3HWwxCtr7VaaH9lq1+JrTdlzldsPfRmQ5pzq6cJdFIVq7Azm1I6URM6tTxo56/ctlzWKiBnEKVSYa9Am9W5OlOjaUeEH4Hb2kvfzH4M0v+hOP3skdG0INjNAZTr126c85u9tR9JYB7beDr8y0NHZmPndYZaTxwoaTBKAg9iOQrxut32DOvVTiXIm6NFbzLeeKv2SvHf/rnzPjLFF0cn/YxTBct2gr50XIoThuu6CMkle9QGCH7qBTh1XmovO1LR8wQjFS5j53Bv/89lX/JqWNNsGDu3IJPqkKLdNhuW3tzZr5P5EPbAeiDOqFKS3iw6jp/GkIhvvnZX1fFNplFBi9pOX0E08tEcpcPPG9ipESqt6cBYYi8YVjmLB30DRBUC1oWh1vbeWFvtzMJyTunSIhA3gkOKtlq2QQNg1xkH1EaiXkepG8QQeB2GSa4+hYOk2qK1FOLogSD4wReNJ5SIzHb6co+VvEKDXxH4kN+/zKHTFOdhabvw+WduqxsnEkBEy+GOK377UaMFIvIz8gTPY9quzh16gfqKarmxsJ045eF/2IsNeRqFUR16EzmnGq4v4EqlPhAxqB96Mrb6vmW1aGjVzFjHUyxrOkG88PQebPfONjIjcsI1uRMjwJ/wjPBHROSIe/HCjcTrv4IKTFyrukTRm4Xe1jGquBuCJJR2z8dgK2lUInzqn6Aoeczh9gOWfwQOXifm7KD0m7XjKCk2+q6OVyo7DeyJc9PILVvJwK7Ag1fJnVz3PwNK5qdkk16J56+an7D+zxRouyB6wRxReSPSos9G4sy5NLQyjUacnqho21MeQ6WXNwGsNJEWatS1smocJTpWzdQGAb5CFskLiNw9EJu02/mxKPMHW//MoRU/oWmFX1S8y0H0h8zwkFuppbPz1SlSRv5E1Ib1BrEMcfds1Mmte6LCxhRa4Q3gQJXDvpxBnGgMuibrcYYRaKjU5wj2gMYhV5ou2aEuuzZrl6nKF0sUIxijDOjEoU4TZb+hzf9vBg6mvwVYiM6ubSysDDItkoxHCZZvg1KsmSFN2oZ3zSHYFvhyr/mrMijdH4jA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024)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+X69FEhqe+gtsk+h5580R32yNWNgfGxrK1l8G/uSDH2texn7snsuDX+3rOb1a6wBd+iBgC6zM4kTWMxZgivSl+Nj3ThusdiRveaMyAelVVHvqCzN1azMD3GAzZKFd1LVZmiFBeB3TW83kU810ewDTNgu1+EnqvSEC+3JsscfU1ZefxOreKfbigHLWv2NCwgXR2AN96vc72EgLKOfpTicApE9iK4wM2KUFRVfjwRGQi/DKo1l+M3F2g3d1j656Czjqb48pbqNTuX7B/9j0tQZhVU12g4CA5Q50UG2E7SIH7oFwvS0qQah6xuSJ8nDGgUctj1DwG/yhdeNU4akY1VBK40xR4MwdwB6ImyUTWHGhPCHEhrjonoNKqC0W9rlo4JETuVU1YbrVDyV8xXBp6Bmm9RSAQTwzuDxF0Yne2PcgwzVXuUqfjL72bWXqXYkp5RXJK0TtGoeLHu3aTd6neQgF2fzMMpfjitmKihenN4sEWiBML4bLLTaqsXRIahK4cP4AM3NlCD5+QGqAi8N6EHQamYtFSv/gXhgq+b+P22l80Ex/TMWpv6B7nzOlznNPoK+R0usssdIdDkoUTo0AiczOQ7kFI38pfxMlKCfcfojn2lH3hOxs/tOQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ac8c848-78bb-4ea4-b410-08dceecc208c X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:52:46.7754 (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: FVIU66MNl/GCCqSbyBnJFyaQxNVyO9AygsZFxFs712gFdcwgLHqQBF9DTAALgw9diqGY3bqnbsWxNjHxJ/ntjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7456 X-Patchwork-Delegate: kuba@kernel.org Do not leave -EOPNOTSUPP errors without an explanation. It is confusing for the user to figure out what is wrong otherwise. Signed-off-by: Vladimir Oltean --- v1->v2: none net/dsa/user.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/net/dsa/user.c b/net/dsa/user.c index c398a4479b36..2fead3a4fa84 100644 --- a/net/dsa/user.c +++ b/net/dsa/user.c @@ -1377,11 +1377,17 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev, struct dsa_port *to_dp; int err; - if (cls->common.protocol != htons(ETH_P_ALL)) + if (cls->common.protocol != htons(ETH_P_ALL)) { + NL_SET_ERR_MSG_MOD(extack, + "Can only offload \"protocol all\" matchall filter"); return -EOPNOTSUPP; + } - if (!ds->ops->port_mirror_add) + if (!ds->ops->port_mirror_add) { + NL_SET_ERR_MSG_MOD(extack, + "Switch does not support mirroring operation"); return -EOPNOTSUPP; + } if (!flow_action_basic_hw_stats_check(&cls->rule->action, extack)) return -EOPNOTSUPP; @@ -1488,9 +1494,13 @@ static int dsa_user_add_cls_matchall(struct net_device *dev, bool ingress) { const struct flow_action *action = &cls->rule->action; + struct netlink_ext_ack *extack = cls->common.extack; - if (!flow_offload_has_one_action(action)) + if (!flow_offload_has_one_action(action)) { + NL_SET_ERR_MSG_MOD(extack, + "Cannot offload matchall filter with more than one action"); return -EOPNOTSUPP; + } switch (action->entries[0].id) { case FLOW_ACTION_MIRRED: @@ -1498,6 +1508,7 @@ static int dsa_user_add_cls_matchall(struct net_device *dev, case FLOW_ACTION_POLICE: return dsa_user_add_cls_matchall_police(dev, cls, ingress); default: + NL_SET_ERR_MSG_MOD(extack, "Unknown action"); break; } From patchwork Thu Oct 17 16:52:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13840377 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33D911E1036; Thu, 17 Oct 2024 16:53:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729183994; cv=fail; b=g/wS37ldv98c5ovtpUapMlRTASFY78cu2H87Uu2ZBFSdu7/X0uGwn65+vugvYJNn5+ig8TdC4Ds8rkRNsVCGDm4h8sI2V3XgX+68ILzUxolsy5GghkeXkw8v5Ss364nslKWETdSGUtgRDiWVTDzW00091ZtvaHB3vuv7H8LwFbw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729183994; c=relaxed/simple; bh=T6Ig11DHJT8EIwQ9E0wmYkCRLCfPS6i3714CZD2uEpg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=caz2rimvKLQA0OsBH13/8EKMUb+lB8U4LWOzZOt4Y1cd3aZ7GNH1ZY9xUc2JGfGbKCh3ocjh9rkwDmIvN6pWaCYHWVpEq33TWAl2LKM9s/1ktiUUTwE4s8ACldAiGU8WdNr2fgD22jo18cGkunKyZRAKidj+my8Ko/cl/58HRL0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=EVUffOhk; arc=fail smtp.client-ip=40.107.21.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="EVUffOhk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eSlF0c0kOc5u6XCydBxur4gJ9N6HN6pqIJ6SRoZWZhR/AZ30PWNPnFN+IrhSc/6X0M+3FXjbMART9UUf21V+ztrxZUt3g7jPX9wXkiQA7VXpF67bP7MG9chcu36d5lVRDCrijTUGRG8dDpFO48w6aLJr9En6sV3/QQetMVTenu0fibMrsrNLAbuv8ESdyfP7GLnbMb6B7BZZwjTbypzYMP+b9dFjwDQ8RxI4WsqzpcpsnhvB+rMo76TH4RuKx+K8/zostTNa5KZVTxz2AcwLWRyEQYPua4YAPRVU1lL0Lftl+szIbIfqtYVgWWRyM5kLwXJT9e+wDDX+rz5Y2AA8hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=IhzlxU/Pro+meJHzcv0up5W96hJe0GH4HG1yRWby8uU=; b=biCbxH06Vpht/rSTLQ4UDIcYGmFsQq3DyR4/eAR57LN82X5vn9h6hJ6Dg4NDeE3+/ywVTsDl2ESBc925zZVqq5sHsuvKCsvel3O4rluzMQJbiPahwDL8OCU9s7PYP22/QCyAEi9wOt9zC6s1KbzM/JuU2hkRp1rOo9QxEu8WsTMmjd1pKfYFBF9pbxao+0CJyo/k2OQafi2d8OUCnvJRWyleVwI71JgvEOKrN6zx1+DsZfYu87RNMYFV4LLPHKqawmfqLalMwEjqVs055VAP+Z5cmFuqp8NxM+cH9MaJDcrhWD5OzFFxLHAUv08JLjBcJEheWo1C0wQPFk/qLCQQtQ== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IhzlxU/Pro+meJHzcv0up5W96hJe0GH4HG1yRWby8uU=; b=EVUffOhkYBmTxXsb7EEXkNOoNYO+WkQ7Sl6FB/fkVlCckfWLY3rjZWo3uUDL4AgBnXVgkeggWLvcKlsGdDIQq8MiGzo3U280++bZ+8016WoJRlsjE9n5e1GeOrlKdH702IY+7imQFZXB1eXWJ34AyFchp3OyA6WFmMbZT8Fhv8Z8WCbjOcvV9jR5d7DBU+gktFA/Bjpcj0Z3bXzU0ol9QsVrbJ6VJGSjZg6c/X/iH8oxO7zMh43985fSS3ZdZ2x+SfNFD7dJ4r9DnG4Wkl6nmHCnsrmuKDVBxv7Y5QjRKWHSlBkvGYN/+bI7CtZr6yKv2fHcesoMd7yVs/kjlFZg3w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) by VE1PR04MB7456.eurprd04.prod.outlook.com (2603:10a6:800:1ac::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Thu, 17 Oct 2024 16:52:48 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%3]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 16:52:48 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Petr Machata , Ido Schimmel , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vlad Buslov , Simon Horman , Christian Marangi , Arun Ramadoss , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 5/6] net: dsa: allow matchall mirroring rules towards the CPU Date: Thu, 17 Oct 2024 19:52:14 +0300 Message-ID: <20241017165215.3709000-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241017165215.3709000-1-vladimir.oltean@nxp.com> References: <20241017165215.3709000-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR07CA0259.eurprd07.prod.outlook.com (2603:10a6:803:b4::26) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|VE1PR04MB7456:EE_ X-MS-Office365-Filtering-Correlation-Id: 1af06c69-47cb-4df1-18bc-08dceecc215a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: N/boNtQjfbpXU/QcfYP7nqosjVGs6DiuFxEx22IqXWK1iAd3sespI+DHrHYeHcqgE97kgOfR6iMBVpWDIxe7pigr8S2GJ81NlQJMnfSm9tt1bWfCy7D2Qu3im6yOumTsCsIO7jprDm/An3UVzYPnwFjxIq/RNBvD+JlkfL9wBwVos46CebvxAcDSg/5qxlsWhH7P+a6Tiq+NBWANo+OyyDzkPC7QCXmYGJjUc5wcoXqTxkOizPyvNgRF5vtDc1ZcoZaUyn50J+4yrXKaBiZFIltMLycJL2yj5ny78u7cCzE5ZGFgf1im1LuEUluaNqy4bqko3+7xHLz6j/iwFpmpH1dPno9KmWGX7uiq1HJIIVB+EM419MKjPrV7fM3gxEVK8bbFrCQnZYT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:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nRuuVUDwKrqt5geaYuHjE+AyC/qadtwsFStQM1d5xVAsAcloi3+qUYh98cPd3bF2SMZPfxLd/oxgqYwtOITgmS/3vHDoq10rxHboYYkurNNrB0ieCy5ixEMLKUBwGZuR5MY+AnFdnXUGfNDrtWOXJh16VQHkQ6qSOH8GMm+SMSKIiy7rrC2VVTqLabBYygvHhe8V4xmPxbHV4+faVaMd/qP6MQV2jRfkiuAsU0Lpnqg8fBgNfSISJKLjFopEIPsYLEVEpNxIN8z2BLhu+pb8ZAAiuWEDcEw5+RRUVzx7KliXX57CXITWaVtubWxS3htKjFUk5U2I/LqIV3EacrOovyp+s8HJZUlkCO+LBMn/v3QCgv7AFnvuDdB1KlWrPym57Jzqat4jVAbwFPErGX0RHcvObnrXENCKoXHbJKM0FcOgnel3VDYyeiimpCcZyzQ/EJvqKwrUeutRlQYrJgXIP0pKxc7vdC38SOUkT1D8AFB4s5jqJQdQQ4WmB+RLy+6T5X2laWXvYUqj7IidQPF83CtYg/YddEHibBA7E9QtrKH018slFsg03dQ7vF+PKHhnmKN9S1uusdCnJhg/4i7/0ntffzwqVfP8sfJQRpGbL7fzRucRgTLLwu47EXYlHqh4k0en3+f5CM8/oUU3bPLlTWOYBW0sSqhA1og1q6kuDOv9hgwMsTahyOi0abYwJwETAeQVV23YBAGPd07+fDVpHvqMPdFFz0RPeXSFgc8gtiFukDZZhmVvvC5naMjP1ysZvYCpZcJ07K5dKqVrRXP+FHRcAgzKsWwphK7RZtvz4JqeEI6XFN9sX19FqrR5bGGLvLkHt+jYwC5pb33Mjxm18jLLXg2OASQeWzNySKqi9k5/VKLw5OKA106LHKWVyvVeqLNnnBQeAMYwf6eB/QSkzzsAHuGkQ7GJi5VuuLtjFp79drVIC6aYXpFXpJUxilQCdGB8+R5XaxZHHR9TIpnAsab9Ux4KuvEKFcj6pYlsSRM2m30jNf+YqqM9QrNfyEjjHZfDV0s4GTagW1czuqW4CsGWhU5/I88zwL8q33BgQ0nXsE1GHAh4K8WG6zo0l3InIvcnRJ4dGsir3MfAkiUr/uE59Lo5I4KoJOJbDCL9nOETreE2jCDIOASXw55jVpvzxRNL6UdHMznU/Cl9FG845bzOsWE850dU3yeKUfmkPtTj+U7npfrTYN7m1PXJga+HfS5myoXz+E83RufyM7vR1B/yyrewwVIvq+AHXJ2ltalfuUSVHh5p65Yis8yB4gyBGZfZ5yJpVLewYcOushAJHJx7+0PO1uvQALsmeDhONRNOd5G0Bl9hJkzTKgDh5xb4+UKn+IXKLiIK0Gy9toboGaBTHYV407R052N8/zQ12UABWH0Ku5GQAJAzdPtLBWL8bXKlc7g6oM0cBZe0Y24aMBb64MMbgQfEDCxsThcvEIaSp3V8yqBnxoIPQerme7zVFHRoAjk0bLmS51YsAhlBd0kLcA25C84WT0Vn5vEd4HXNXJDizoi/nSHrJUOlmMjF1iykg2nFovMee4t1+43IBb0QxT1zVEF8vOIAK2AwkbRk59EyinZRbBul1NMZQ/ZiKO1TWgACSNjrC4TfFp1q/w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1af06c69-47cb-4df1-18bc-08dceecc215a X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:52:48.1388 (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: gi4L28zqBaMYpAsaRbPzybIC6MnMHzARnPXijGzIsINU6IlBXx1Bz5MrFgryhhpNZosrTIres5cDef6APo0SGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7456 X-Patchwork-Delegate: kuba@kernel.org If the CPU bandwidth capacity permits, it may be useful to mirror the entire ingress of a user port to software. This is in fact possible to express even if there is no net_device representation for the CPU port. In fact, that approach was already exhausted and that representation wouldn't have even helped [1]. The idea behind implementing this is that currently, we refuse to offload any mirroring towards a non-DSA target net_device. But if we acknowledge the fact that to reach any foreign net_device, the switch must send the packet to the CPU anyway, then we can simply offload just that part, and let the software do the rest. There is only one condition we need to uphold: the filter needs to be present in the software data path as well (no skip_sw). There are 2 actions to consider: FLOW_ACTION_MIRRED (redirect to egress of target interface) and FLOW_ACTION_MIRRED_INGRESS (redirect to ingress of target interface). We don't have the ability/API to offload FLOW_ACTION_MIRRED_INGRESS when the target port is also a DSA user port, but we could also permit that through mirred to the CPU + software. Example: $ ip link add dummy0 type dummy; ip link set dummy0 up $ tc qdisc add dev swp0 clsact $ tc filter add dev swp0 ingress matchall action mirred ingress mirror dev dummy0 Any DSA driver with a ds->ops->port_mirror_add() implementation can now make use of this with no additional change. [1] https://lore.kernel.org/netdev/20191002233750.13566-1-olteanv@gmail.com/ Signed-off-by: Vladimir Oltean --- v1->v2: allow mirroring to the ingress of another DSA user port (using software) net/dsa/user.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/net/dsa/user.c b/net/dsa/user.c index 2fead3a4fa84..8be2e39c14e3 100644 --- a/net/dsa/user.c +++ b/net/dsa/user.c @@ -1365,7 +1365,7 @@ dsa_user_mall_tc_entry_find(struct net_device *dev, unsigned long cookie) static int dsa_user_add_cls_matchall_mirred(struct net_device *dev, struct tc_cls_matchall_offload *cls, - bool ingress) + bool ingress, bool ingress_target) { struct netlink_ext_ack *extack = cls->common.extack; struct dsa_port *dp = dsa_user_to_port(dev); @@ -1397,10 +1397,30 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev, if (!act->dev) return -EINVAL; - if (!dsa_user_dev_check(act->dev)) - return -EOPNOTSUPP; - - to_dp = dsa_user_to_port(act->dev); + if (dsa_user_dev_check(act->dev)) { + if (ingress_target) { + /* We can only fulfill this using software assist */ + if (cls->skip_sw) { + NL_SET_ERR_MSG_MOD(extack, + "Can only mirred to ingress of DSA user port if filter also runs in software"); + return -EOPNOTSUPP; + } + to_dp = dp->cpu_dp; + } else { + to_dp = dsa_user_to_port(act->dev); + } + } else { + /* Handle mirroring to foreign target ports as a mirror towards + * the CPU. The software tc rule will take the packets from + * there. + */ + if (cls->skip_sw) { + NL_SET_ERR_MSG_MOD(extack, + "Can only mirred to CPU if filter also runs in software"); + return -EOPNOTSUPP; + } + to_dp = dp->cpu_dp; + } if (dp->ds != to_dp->ds) { NL_SET_ERR_MSG_MOD(extack, @@ -1504,7 +1524,11 @@ static int dsa_user_add_cls_matchall(struct net_device *dev, switch (action->entries[0].id) { case FLOW_ACTION_MIRRED: - return dsa_user_add_cls_matchall_mirred(dev, cls, ingress); + return dsa_user_add_cls_matchall_mirred(dev, cls, ingress, + false); + case FLOW_ACTION_MIRRED_INGRESS: + return dsa_user_add_cls_matchall_mirred(dev, cls, ingress, + true); case FLOW_ACTION_POLICE: return dsa_user_add_cls_matchall_police(dev, cls, ingress); default: From patchwork Thu Oct 17 16:52:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13840378 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E54261E0DDD; Thu, 17 Oct 2024 16:53:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184000; cv=fail; b=M9FVZVqkDVFVG9HB9MxhfimD7kzNTDSYXuGnA1cKlMWVUZ5AbQrcv97S20PTpJsJy76Y1dLYCBgJM5Z2Dq8+Hki/G6Tfzw2AX05RIL2DH8ziN6fpaQPDrz0ZZ5cfypylKO+m8E8XphtYdtWQhgUecZCKH2dWssLLN9RntWU0K38= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729184000; c=relaxed/simple; bh=pp/6Hc+CF4lcRCy0fDbuM11wJ7x1nCijkK5SXkZ/zgo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=t6ETSaQdOwgDoiWGJwACwYBb2/6bcq9lxR2pMBFoHJH3uO+l4/WBGYOxDkxPKEsk/WSvjCANzJB+1dwp4nOJHQDjdmP6zI5jlA5ieDg1roXZuHkmHh78kbGDLLPGtmBVwlJuUNzvjhNix/ORqw+vYTaCPM5zm7AiKfjHQxLe5Q4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=T7u3pwdC; arc=fail smtp.client-ip=40.107.21.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="T7u3pwdC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GVy1/ml0eSouyJDAzyp5ZeHN2oSCmqkMGXgs9HhUZe7ebE5HRTVUU+tw8QWqbaTkVtt+wK5mtEp4FNqKdnaEop8pgaNG+eP5/EkXshv9Em6sQu3Cfee815WyZDuVT2q6ClzSKgQf/0wxWvYIGwqcyy9o5a3Iw1vx4zfd9B5Lhm46Oi/kTsO1ExDf1LEVDdo/Mrkkn8u8+IbWdjZuHULZexJq8ePULmecdOLjuoXzvRhRbEp+3pEcnUjKvChw7VMKQNmEZLMcl+kmxcV11Yzi3TGjmNrUIBcFWo4Gpa7ibqA95NFDh0uYzeNSLhOcXii1FUY5JHmpgaBJpsRYmTH93g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=8FbCvt4SDdBMdT39XRoF1F5uTz2UYEJVMtFE5iLC5tM=; b=x+KRLk/Zm1k0KNCy2ORWGDguYZgdWEpakT/QJHNKNurAEgSCLYWhoSgwJ7HBPYFnWuj3pOMz2sFdREtW9pr8dLL1jogf3WMvK9bxqIV+/TZyhJLEo/mJiF3wPeR/kR7oD01RdLYaGJu2Sl+n8D5+y+m7B5oNa1oeqi/DfRphMoaLDEdaOXDpXLzgwklhIzmaFdbHLnPVXD6v2nfKLlp+vLQtDACGvYf8TYOoUXWUwDaFc9l4MfcjMqsFZ+LthuRZTv83sutkkJ1g+8YqUJsyt2NBRvdocPtAx7c876I7bJiyAAD5VABqtcZsCFFqOWRFRfRte8axd1Q37ExmGrBFzw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8FbCvt4SDdBMdT39XRoF1F5uTz2UYEJVMtFE5iLC5tM=; b=T7u3pwdCjwBvv7OX3EVZe0kpraLSXCvSou86YoTgGLVhH/79CzaB5F/7mjJdpHhPuMX/yjPgoKq1byYzls0qzY4YtG33R6aE6otTadu9fYsEiDlpoYRGhw/FQUfSu5iroT4495GtuRvgt5OY8Xlmd8ME/gaENNPxcVySq7KU+LmpZW6AgUYRToKuwmKYY2CaBbmV1kuEiTEJ3bCN6r3Lbpsq4kVT6adhqJHRmrvjDkJ2qtRhlwMviRYgbZcS+vdehfOPK9K++ApkwTf12XMTSe7CT2CeK2VqojySww7js2dJfia9n78YZ06lprSrWyRmQjy9IKWtyq2at7fJby2Vsg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) by VE1PR04MB7456.eurprd04.prod.outlook.com (2603:10a6:800:1ac::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Thu, 17 Oct 2024 16:52:49 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%3]) with mapi id 15.20.8069.016; Thu, 17 Oct 2024 16:52:49 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Petr Machata , Ido Schimmel , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vlad Buslov , Simon Horman , Christian Marangi , Arun Ramadoss , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 6/6] net: mscc: ocelot: allow tc-flower mirred action towards foreign interfaces Date: Thu, 17 Oct 2024 19:52:15 +0300 Message-ID: <20241017165215.3709000-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241017165215.3709000-1-vladimir.oltean@nxp.com> References: <20241017165215.3709000-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR07CA0259.eurprd07.prod.outlook.com (2603:10a6:803:b4::26) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|VE1PR04MB7456:EE_ X-MS-Office365-Filtering-Correlation-Id: 658cc462-abe2-4e46-5bcf-08dceecc222b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: GcQrJcVsTqPWSmRHZ1gGL5Rhav5gb4codOflKeA6PYbn33PIhIilUeuxbqfG+6IdZ8Yz02I+tmg+gArCisvIEWths6/aWozeOSMh7dkfOASbSEtIsYu+LamSFFIZoULe2K1pfgPKwHHZfhZYLb83kJVbo8rb9FVq4iUzpppKYHB81HfpGsmgD4jVzrmWgZnZO/ERqQZPXmvaLkaDez7HdBLbDZElFgsMzHZoy9Ex2G+yAwXIoVkv2Gxo4Sfcm3+LV/fxaQREqIlcayRjXZvqXKv6obtr5s8ymJo/FmbV8zUJ/c1SSswcLYMxCc3XPrifGYgFjqu/9DtxZwTtld0/uS3QjEemajmG+1yQ1Wifh3+1QvtqMqFK2LV7Ud17h/XrAUuQ9ElM3hr6v5v2Wu5yKmU6G8XucxdWTVyQvmc38vBquQZoSCvhgm8BfTo/ypycVgvAExKUZ9jFM9vbZB1HboYZ5uLE0EG1y6d+RFBgNBRygT6Lpo9ojXVq4ja2D/D/oBgseJ+D4Kogv+D7lNCxuhTOgzdSlsvuIvHuubt7ZHlCa+RLAwWDmPI74ZcakCACxKJ5IriHofZ9/PE66tO4PaIospgcz3o1TAZ3BQZwC7dbTUbElJ/jtZ976dqaXOiHotRHaEkhYYhlceyy/hg8+fJgYkCFJ7oXQpM7lAUpY3Ub5yKMzVJ/MDEIsWW9ymdjUOQsVVMH1Jrz4m94aiCGHfM2bzjnykFGh1GDWAR58ltdbAP6LF/Xm0jAlyYvaNNx2eozVD9PL3JH1Sqg1Zv/O38r1w3HUWmoUn6GDSSMtyKi2xXq0Ym1iEMK1NWtkTqgfIMtog2WrGBjimgZPJXHqG8FhARsMqXZJ8QBxPgtNXxJwIIR7emoCfexf31bGEHBpjplCbVHReTSO7ca0xEuNc9loSNBa69uDIfkQKnaMVWx3cDupG4yZ5+VtwuhbJwRsRtfjN+hsMM0dTObSbAuiboooWzLkp/M1gsZRoKG6qTpoSWpsC8oHs8io0UdduE2qKCOlDht6Y71k0HOrWx31yiXRK3NSOtQTaSSuVozXNqlpcgPKr5zmGxY3FiTVOJgWjL4tIkcA9wnN+LheDzk6iW83IjAyRKNvsj9sHoTTSxy/tpKE/Km1nqMzE0K9NbKrlHkjuUVa0OQBPS3l39YyVXhx/zyQmti1BYsz21Y5McuOTY1YfC61tQQIOA1vttibYBjk/t9azDlSgYsL6azePddr2pEe/7MSCrWOmzTFX0WhK2gh6UuXhUOjU7ZaVf3sVEAQEp6NXBc3VDhwZtQvb13/TyKcPGd3GtNwQqDjlV63vCKNCakZcVSVQpLAK0lwUtHWMs3Flme9YqBLBCUjb/UyqT56rQD6LpVLDbPqJk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YSqBdQtUnszXuyHGQETLJEFWn94aJqQY3yTXeOvNzG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6mZIVs3Kvv8Z1WKZX+3eAz7teqkuW+mcuXOZPy3WfXiAlsrlveqk+YNg0T/BycZ1RsKVO64vEJpljKUoqRjLrCUhTq/mjJWIz/5no+VFGmQGU8oJWxrH2N3rrkTnLe1RahyOM+MimGLIwtFCDTqDBGwIcRKWFNnSVS5Jzuom2Qa/W75v/VdXqK/OJPdSeJupGDsvTlyvUry5QM8SrG2aoD7iTgAwNAvR+MXgzKjFBO3kjOHSo7dFITZaLvyiqffRlF9wyoP10pzNdYCaOXwK0Wrut+CiY+8kDYESwUILKzrmzK+ybUsoxqtnpr52y412fHeLGcuObLeAxT+3MF4ZKy3HSzwikwAy7Gshq2u/Szy9N34DKSxBv/JSB8D+DuVr7CaKQVpunUTewSWPcHleLnvIaUXUCMA4WhKeb6kDCXrf+ZTBjEuuY0w+aWMbugwTSqm560KE9TTf5JgkEGJZuCwNg+AsebvzuBu0TNFLbg1AGVjVhe4JiPEED59XP6qlDA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 658cc462-abe2-4e46-5bcf-08dceecc222b X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 16:52:49.4981 (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: 2atl3tRqzsMuUzqW4Jg63DTM6ckvccjItkih3oOxcilseEv3HGn7dhueG/PcWTQif085yjCjJGLYBtV8S5N0Qw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7456 X-Patchwork-Delegate: kuba@kernel.org Debugging certain flows in the offloaded switch data path can be done by installing two tc-mirred filters for mirroring: one in the hardware data path, which copies the frames to the CPU, and one which takes the frame from there and mirrors it to a virtual interface like a dummy device, where it can be seen with tcpdump. The effect of having 2 filters run on the same packet can be obtained by default using tc, by not specifying either the 'skip_sw' or 'skip_hw' keywords. Instead of refusing to offload mirroring/redirecting packets towards interfaces that aren't switch ports, just treat every other destination for what it is: something that is handled in software, behind the CPU port. Usage: $ ip link add dummy0 type dummy; ip link set dummy0 up $ tc qdisc add dev swp0 clsact $ tc filter add dev swp0 ingress protocol ip flower action mirred ingress mirror dev dummy0 Signed-off-by: Vladimir Oltean --- v1->v2: allow mirroring to the ingress of another ocelot port (using software) drivers/net/ethernet/mscc/ocelot_flower.c | 54 ++++++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c index a057ec3dab97..e502226df4e7 100644 --- a/drivers/net/ethernet/mscc/ocelot_flower.c +++ b/drivers/net/ethernet/mscc/ocelot_flower.c @@ -228,6 +228,32 @@ ocelot_flower_parse_egress_vlan_modify(struct ocelot_vcap_filter *filter, return 0; } +static int +ocelot_flower_parse_egress_port(struct ocelot *ocelot, struct flow_cls_offload *f, + const struct flow_action_entry *a, bool mirror, + struct netlink_ext_ack *extack) +{ + const char *act_string = mirror ? "mirror" : "redirect"; + int egress_port = ocelot->ops->netdev_to_port(a->dev); + enum flow_action_id offloadable_act_id; + + offloadable_act_id = mirror ? FLOW_ACTION_MIRRED : FLOW_ACTION_REDIRECT; + + /* Mirroring towards foreign interfaces is handled in software */ + if (egress_port < 0 || a->id != offloadable_act_id) { + if (f->skip_sw) { + NL_SET_ERR_MSG_FMT(extack, + "Can only %s to %s if filter also runs in software", + act_string, egress_port < 0 ? + "CPU" : "ingress of ocelot port"); + return -EOPNOTSUPP; + } + egress_port = ocelot->num_phys_ports; + } + + return egress_port; +} + static int ocelot_flower_parse_action(struct ocelot *ocelot, int port, bool ingress, struct flow_cls_offload *f, struct ocelot_vcap_filter *filter) @@ -356,6 +382,7 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port, filter->type = OCELOT_VCAP_FILTER_OFFLOAD; break; case FLOW_ACTION_REDIRECT: + case FLOW_ACTION_REDIRECT_INGRESS: if (filter->block_id != VCAP_IS2) { NL_SET_ERR_MSG_MOD(extack, "Redirect action can only be offloaded to VCAP IS2"); @@ -366,17 +393,19 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port, "Last action must be GOTO"); return -EOPNOTSUPP; } - egress_port = ocelot->ops->netdev_to_port(a->dev); - if (egress_port < 0) { - NL_SET_ERR_MSG_MOD(extack, - "Destination not an ocelot port"); - return -EOPNOTSUPP; - } + + egress_port = ocelot_flower_parse_egress_port(ocelot, f, + a, false, + extack); + if (egress_port < 0) + return egress_port; + filter->action.mask_mode = OCELOT_MASK_MODE_REDIRECT; filter->action.port_mask = BIT(egress_port); filter->type = OCELOT_VCAP_FILTER_OFFLOAD; break; case FLOW_ACTION_MIRRED: + case FLOW_ACTION_MIRRED_INGRESS: if (filter->block_id != VCAP_IS2) { NL_SET_ERR_MSG_MOD(extack, "Mirror action can only be offloaded to VCAP IS2"); @@ -387,12 +416,13 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port, "Last action must be GOTO"); return -EOPNOTSUPP; } - egress_port = ocelot->ops->netdev_to_port(a->dev); - if (egress_port < 0) { - NL_SET_ERR_MSG_MOD(extack, - "Destination not an ocelot port"); - return -EOPNOTSUPP; - } + + egress_port = ocelot_flower_parse_egress_port(ocelot, f, + a, true, + extack); + if (egress_port < 0) + return egress_port; + filter->egress_port.value = egress_port; filter->action.mirror_ena = true; filter->type = OCELOT_VCAP_FILTER_OFFLOAD;