From patchwork Wed Oct 23 13:52:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13847132 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2089.outbound.protection.outlook.com [40.107.22.89]) (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 897B21459F6; Wed, 23 Oct 2024 13:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729691587; cv=fail; b=YV5H/cBQ8yeo97nRxgwqdxXh5v99tWwldwxxrvXq4KEZ5vkSlbTq28C/YF9UF5CTqMb8TBPaaa3SDcViEWnuKdDd4eKe9/fOtwFbmU99rbh0khdO9OagDWw6BKWK5vtGoGJZsfCJ0LFutUncpX2VD357e7NIW8phZ68ts6qsi5A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729691587; c=relaxed/simple; bh=T72fg7Ne5lix6U3308YwmDg0Ll2VaI1TYQYhdXvPYho=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=dRgOyKL2SPgLJUbwvm8b1G9DZXl3ixVh9R84WRVim5aLlS4WS3LiZA1KL0uGQI9xiS46l4DtEP0GtRsjqFDdtu6CrQclRB2TIb1+4P+D+v5XmIfizN5uj9yUSoL8F5SuuaoLOWxr/NYg7xsuOcxJdGSf+5zx91qwIgy6tdB0l0I= 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=CscA1IPH; arc=fail smtp.client-ip=40.107.22.89 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="CscA1IPH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d87MF+RRvVF8nZ88Xjy7B80roMp2ygvH16mznPUIv0jK559md9caxEua2Hi6K/xHUPufM2p34o1qxIzKkf8LvPlxHvnxMu3qb/XzuwT/cMdCmG02wZ48ukKhbtIWDkh/bd2C8azn2sMEq0AWRYMDD456wifGgkmVzzJQD5cgGrDXY6Mm+IQ8PI86OhZd10BnhDWWMvhWcD3WqdDLhueOFydE9mSxt0wDQF+sIY4FPV8l3creB4SVdHhyiPwR7rHFeCiG1X+oCrqiIeNr8fHER5akv7WPtXZC+2kYIxkk6oG+1aaWZ+YolFWJumEOwOSeWfEI9xPV0XFa8GooO0xHsA== 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=XC9CkkBWy48ZvFpZrYmDlYf7RiN0PSG3KohJ4frxgQs=; b=qJ0k3HILqDTlzi+IoisHol7yj4/WJ0IHFkzexpEZwjZ/J+oRfeE5yw88UWVlmL7u3lZKpz+bNOoFNh7soMKQ2fjtjg70dKSOaaSyhQpqDgwVacRh7RbgEVPxjblzp/PaLzhOiAoQ+/mP4MYzA6Np7dI9McXeuV0XiQgdaP+Ya1F9DW1TDrBvvQlzZ0EHYTefLeAAjXo2IQIoQ/Xdtd4mnaLygSQZA8fSwZ3fvSF8nVg4ThSoPBg2Cv6F7WYLasWnwpJHrncipb94FANGw7UFrRkaAz8i5HQCQ0BvJDLPmwOo0dssFlP4gnVc541m8Ht4SuuTJ74NT8hAKxPXeNZFjA== 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=XC9CkkBWy48ZvFpZrYmDlYf7RiN0PSG3KohJ4frxgQs=; b=CscA1IPHt8+h02EdASF23BOw0TY6IhOWx6RDqeCMjCpY+84SC+SjRlfGmXEacxM4NtjikTfUz3pNmd0TA1mhD0/nuRUgbQTxPROQYiTbd76y3I+ZEr+q/CKGpDZG7tCU6LM6sJO6eHGPQeZk9SdtoD60khpSlM98vh+hLptUlcbenrIq8kbf8XRZI7ef+A1VK5jMg2EHzit7c3my0Ituez+cwJ964LffH637LfbNQG35XvQH4S6UkbSW21fpuJOrP2Tok6oHZbE0HLj4ubcG28IOl2uE0sXm50Efs3KtJklvMOtZtFKxiCU7AERmua/sRiNDLrtie1KuHmmm+1boSA== 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 AS1PR04MB9683.eurprd04.prod.outlook.com (2603:10a6:20b:473::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.18; Wed, 23 Oct 2024 13:53:01 +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.8093.014; Wed, 23 Oct 2024 13:53:01 +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 v3 net-next 0/6] Mirroring to DSA CPU port Date: Wed, 23 Oct 2024 16:52:45 +0300 Message-ID: <20241023135251.1752488-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: VI1PR10CA0105.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::34) 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_|AS1PR04MB9683:EE_ X-MS-Office365-Filtering-Correlation-Id: a6a536d3-6498-4219-2421-08dcf36a0282 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|366016|52116014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: gkKYxX8bEml9iBt1p05v/mI4sWl5WVfHVgddSMEGd4SbkNcl671C0hJid0wJSFYoin7gZumXuqjdy3GQ6RjB5Kj471YdmUqfmKOwEfwdARzKbgia2VoNRPhHY/kRxsxmkwL9x8ss9zTqQrsQnh1PGARU0YJPSq4CyA2gZAnCeguT8e0Sh0UXPmCpfI+oCNtGbM5zRCuMTPNiDzYB/rfoAehN4w26hdBF9ig+2+oambx0WsPPEMLyvqRqVA40pevyXANUwGfyj6WR7NUaDGDJzQ+1zabdXetmkfx1HQSOOED2IfbggQqsXnYNh73Fjg8CBrjXXM2da+Fs/GqgaSrToErFd9A9zHBA2J9CtIynsQ6Jt0ByS0UfejjU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:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(366016)(52116014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uo8Aypmr2au7/7KRUsOmB2QXExcIOG8jLF7F7AbQ3VgGV2Wlc1g79E2jVfbSljDuAFVB9pWchOEfZ2MXmBERZw3x0g6Q4JIIXMIHfd9GSPwJzNXzVIa5lwLS8+cbLflrXRVt50U/TB2We1MctwHgfhU/SCppz1CJyoog9jhBHk6y2mJd6gjOdxyjxKlKzQzZSWe0pTxdUhxXxn2FU7PwlV90Z80A+HonwqbJ+eR75RMfgSc2R4L+L7ZJ2eGdHMNxHleLQ1I5Zvhb2UAROcWMLtyd7sO550rqitnrA8BsOXX00yRo9m+xg8tNGdSmZxm8S/97vTJfXv7eaqSMUZgTaH6IwzuskY/QVHx3UaI8KW3L3ZyoRsnIYdcCDC3jVkyMqfNYaq8HEN0NK8JUWVw9Os6Ak5F53k/I5cE0ZfO4Ti+mcALAuBK2rWQ4IrYAPcFrfiYSHHUWBUSkWuztPWFn2wLucNZ/puwGEDsX6xmXnrJrthmTRZlVYwGooxsAsYk3sKNHHwsbPt64urYt22FxBjAqGEff6CqYo/Y8dHl9G+vS0UFlxbz0T8GwjBISZIG3bVTsf56tPNhFHd5IFuHiAuVb4VcD+P9jxlUBbV4uX3NgDUnV7ANMdl0VbN5pLQuVaxp3cETevgFAPVqsq9XFoZpJ3cnI85bZEOTwZ25LmgaEH0E+SiZnhh970ioP/Ls33Fe8dBj6LGhkeClqdwk+EGg7xJUhq+GtxkifMVrJmLBz6Ih4aatnoi7qMY0e22CJgX5hBgBMkaPu1d5tXZEWPFdhX3hAUdyoisoiyyd+pY0IAhBCp/C8pfr8trtCy6jXquRsxNuFTMh5AGDjpf9sZoDrnZmtq7uxmLiqLGZzeFom99932m/a88mh++CEZaK2hqomOQC+TbqtcJemyWXiqG39W3IYNSeD/4fK9EyUtH4V9E2rOttSzB5Q5McXg6NzCXzmWwxsarQX3IpZwBWZPBQP2pGGE4qI1PkXrvLpqVTUJUFp/nfIzkEwt5187gBUdxZuRbP93uoDqx5XufbChPgjdELE6nXiY7hbIfhoi3xCCI6C4Ejjh0pxmISQE0//c/UTjoAHSXOnw8tzMN0V1GO1IuzfsSBbzuJKaKXciVkMml2E0hUawxHAAxsJyUFH6kPbDbWtC20koPcYU5N0Mg+g9RB3uETLAB45oSAzVSAZ1ApKBRUREMOcJHoYEEPcH03ANPY0rJMEdFWEdh9d5hAjKTiY/qzk9SYJTu75DRSDlfjz9saw7Fog/02vHHg4UdB193G3DPSiQhTblcLPdHr3jTKNCsdxPP+6KbE6mYdi+7lVmDxNF635zmt9QFL4Bz+nWvREw+3xZUcyFJTzsLChC5KGFU4XOAHB8xgCZ73TVEZLaVj96nH6AvJFqgH1Dj+5quwhhKIlM6Hsmsx2sIGdqZLu0UzbBEo63eOo+hAGIk8yKKCTx34SrcZqCFOQJ+Z88LcXOsvu0SCuNUYG/p0w8ymFdlDeiIbYjOrbj5fXVZFsuBSwzUaWCKK+xwScdX0NWn0daJjICIZdw3kIgNk/vUdufx31AnwEuqka6SToT5DIBL7Taw2u94bnQdu30vh9RElyjQFNP+7szH1I4w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6a536d3-6498-4219-2421-08dcf36a0282 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 13:53:01.5634 (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: UqL/D8qHVlIzDI00eNhXtamM7wht4laOYPdUtRkiJ+Obar376NMqkECVv+WAG/h7L3ZBl32OYusd2tdCriCxDA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9683 X-Patchwork-Delegate: kuba@kernel.org Users of the NXP LS1028A SoC (drivers/net/dsa/ocelot L2 switch inside) have requested to mirror packets from the ingress of a switch port to software. Both port-based and flow-based mirroring is required. The simplest way I could come up with was to set up tc mirred actions towards a dummy net_device, and make the offloading of that be accepted by the driver. Currently, the pattern in drivers is to reject mirred towards ports they don't know about, but I'm now permitting that, precisely by mirroring "to the CPU". For testers, this series depends on commit 34d35b4edbbe ("net/sched: act_api: deny mismatched skip_sw/skip_hw flags for actions created by classifiers") from net/main, which is absent from net-next as of the day of posting (Oct 23). Without the bug fix it is possible to create invalid configurations which are not rejected by the kernel. Changes from v2: - Move skip_sw from struct flow_cls_offload and struct tc_cls_matchall_offload to struct flow_cls_common_offload. Changes from RFC: - Sent the bug fix separately, now merged as commit 8c924369cb56 ("net: dsa: refuse cross-chip mirroring operations") in the "net" tree - Allow mirroring to the ingress of another switch port (using software) both for matchall in DSA and flower offload in ocelot - Patch 3/6 is new Link to v2: https://lore.kernel.org/netdev/20241017165215.3709000-1-vladimir.oltean@nxp.com/ Link to previous RFC: https://lore.kernel.org/netdev/20240913152915.2981126-1-vladimir.oltean@nxp.com/ For historical purposes, link to a much older (and much different) attempt: https://lore.kernel.org/netdev/20191002233750.13566-1-olteanv@gmail.com/ Vladimir Oltean (6): net: sched: propagate "skip_sw" flag to struct flow_cls_common_offload net: dsa: clean up dsa_user_add_cls_matchall() net: dsa: use "extack" as argument to flow_action_basic_hw_stats_check() net: dsa: add more extack messages in dsa_user_add_cls_matchall_mirred() net: dsa: allow matchall mirroring rules towards the CPU net: mscc: ocelot: allow tc-flower mirred action towards foreign interfaces drivers/net/ethernet/mscc/ocelot_flower.c | 54 ++++++++++++---- include/net/flow_offload.h | 1 + include/net/pkt_cls.h | 1 + net/dsa/user.c | 78 +++++++++++++++++------ 4 files changed, 103 insertions(+), 31 deletions(-)