From nobody Tue Nov 26 13:19:24 2024 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?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?WYjMGstpj59Nc+bc9YZ71pDydlsoYQvq1FtHrujZ7y5OsOvImN2T4N2ULZkw?= =?us-ascii?Q?s2digPbxS9Gz77me71JVDr/mpNdkKajix41bvrtM1xlGoYOlyHvwmZNQkiV/?= =?us-ascii?Q?Dl9H3mB629HsTSN/Aj9PuzuO+9s3rE8XJ8clF7frtWCDO7dQzH97y1wJrA9R?= =?us-ascii?Q?1LrCjHfSecFEBKSiHWbRfRvJuzHjk/yEv+CcFoj8FwmuQWDjFhnkGzXikXgW?= =?us-asc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opo9tLWyrr1ScA48P?= =?us-ascii?Q?joH4BmH85agIIcf6IP9L+1G8JxrGDc+crAn7qzzOGX95fBqj2kZsa+mhUlqN?= =?us-ascii?Q?/vxZ1wDPKVbu+jAeBuTjAO//m+piaBxwlqKJz2TSah0xUY9QvWOTPp67oxOq?= =?us-ascii?Q?WPEcdHPrXUF/yBUBkPDhNHCHK14b7ksW5p77ixQa4q2DfXxCpRXU8KXaPv0V?= =?us-ascii?Q?7+pcu8PSrS/GaxZfBcUZjySdE4TDJpPBTJ1spU/tkJnHXNaQsb+RGc9+shr5?= =?us-ascii?Q?8WclV1OifYYDEvwVYLbaf+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: =?us-ascii?Q?WDEeuu+whiBvgjXbY8Q6AcSxyRd6AnQTuhF9gDHCKWMZlBaw9cFjbgZC86Y+?= =?us-ascii?Q?5NuncixhVy6dPd7ZMa5+0WinM3vav+luOvjrloCyseYlo2/WHB1jJAcCUSbc?= =?us-ascii?Q?GRSbnqpCNB9G08ZXA8VgEoPt+KpAPosewjC34m0E+CS+oW4abXP9kwGmhiAj?= =?us-ascii?Q?Bo5bLQW8Ea+KBHBMKbsk0uvZ5yZ4V0Ke79BR8XZfsdxzBEmi7yTp2DGyNLdl?= =?us-ascii?Q?xYpiJ5VrCHFQSWrLNMFIHBCVSLe+IQSpeL5O1xq+V+mvc8LSHcq5d3U/Cn5A?= =?us-ascii?Q?MpOorv+x1Vm3CXZ0wCeAG+6ZRuG+nu86wuEfr2pL7FT156g059UXkSAX4F0z?= =?us-ascii?Q?L8DRnzNnZJjupWtyFVKYg6waVlf3n1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wM/5QBlhRcarzY756Lgn9n0GHz5bpwKR8wwJHPfH2R70QTC8VWaW?= =?us-ascii?Q?mycEKcTi1qDXvYaMLnkCPeq0SrdQqbo64e+S4BY7QNZV0/MDzdt2PLxPETLn?= =?us-ascii?Q?MmlfvTtq3AB1s43XHV9J6xapeU7dB1D41bmv2FCNKU88p1zCRs6imkxaq/jd?= =?us-ascii?Q?0hsyUbn6+3uFPqfGK/i6iPIkOXQtk6aWZThLfSJ1wPaIO0oq28ULFGVpYBX6?= =?us-ascii?Q?SABbVxmfOYjpwXMzUeN5qcV5czBV9xFEc2OjvA+IezirY1VeKN5UWJfZxfTi?= =?us-ascii?Q?8zYSNgtgqAJUTEK9XnEOMrOll5TCPWiUmo9ZNC5JJ+Yf6sUmj8nKaoXYGNt1?= =?us-ascii?Q?Ng=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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; }; =20 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 =3D &f->mask->key; cls_flower.rule->match.key =3D &f->mkey; cls_flower.classid =3D f->res.classid; + cls_flower.skip_sw =3D skip_sw; =20 err =3D 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 =3D TC_CLSMATCHALL_REPLACE; cls_mall.cookie =3D cookie; + cls_mall.skip_sw =3D skip_sw; =20 err =3D tc_setup_offload_action(&cls_mall.rule->action, &head->exts, cls_mall.common.extack); --=20 2.43.0 From nobody Tue Nov 26 13:19:24 2024 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?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?3xDsgLo/Ibsie2Z/3+YS1t+oqw1CTf4Bhj32sF8TlyJI3WBd5UBlhmkImD0o?= =?us-ascii?Q?DU6L8SoQsv8s2Z4mGqz1CqomSjQhl/6D/1qTtiYLEgJrq8VNZa7T62I+bUl8?= =?us-ascii?Q?2EP3dw3m4zfnke6cBRG360wMMUwu+6KtIq79Yqcpf8MpEbLzKLJlMal1uVBc?= =?us-ascii?Q?v5E6np8KO37DlBPZVkfM/VgIeMw5p37KlP+TNMEehJBMDLpSyIo6kN+74VZi?= =?us-ascii?Q?I7p3T2nyjCm2bRUTJKno6TvJ5C+BeBZJH2r4FcXCl4yLon1mT3jH+BCzsSk5?= =?us-ascii?Q?PgbM1cM2rurZAFGcMHa7c4WqngTcLtQrem3r54YWnpF9SiZL0MkEpRsl+zxX?= =?us-ascii?Q?SMbCgjKK82TE8cUh5sj3Qii/UWQAYUaGeMk48ruayElSbEH/thC6T1QuZP1d?= =?us-ascii?Q?/Coj0jIqXnUtkPW7EvD+hiFBlv76jK+L8XBw4NCrwUhZZPiNu/8zaoi2eZ2X?= =?us-ascii?Q?HqconhY4fqoZbXeBlTXDr87Sbv2UgNhe1FgdAm7GAR2oWdPTx6yBhJuvGz8E?= =?us-ascii?Q?W8r/iV+fEOIysAOaRCR8wxKia/8jOlfkiV4h7sjL9g0SRX7qfh+gRRdj2gxr?= =?us-ascii?Q?4gRYHjjyHXnHkoa8v89aTyd2sTPk7FkFnUeBAXkAiCF87UgZQcV4F4cMqRyz?= =?us-ascii?Q?MeKA2cp0fHfS637uPGOoESpb8LZ4FAQEIbMd4o4RAea9lrqfilLHbsfq/SwP?= =?us-ascii?Q?iRKy59qYKFZM/bTqloqAUJQD4NwLzpHx73+tFSpXJYYHNuuCcYI44vFSjwcW?= =?us-ascii?Q?tt/vRdnK3suCtp51IRknxNS1SPYzvcvaVN0R8HXR8o37J/STqPCz4WqL7f92?= =?us-ascii?Q?6rfH8FSAoNqmv5nurZoFvdKFPIV+snLQPYC4u5g6fmMnr56qivfmNOKLJT0I?= =?us-ascii?Q?zwCajrhHUTtIHqm7CpTAPA4JaFtFEaBJvh7BaGoQu2mwXPJlgUzYXUxZW9+r?= =?us-ascii?Q?CLXdjfTFxvNH+d9w9pHSSIokBk07ub/82+ieTeIA0Z6DiK02JM3UaSaCB5jG?= =?us-ascii?Q?fy3xgl9GameQkgtEdULKBKJ9g29RUagPUPyeKTnlS70Bc2Ugn45gflfNWEfd?= =?us-ascii?Q?A203Z2JkI/9UAmU7UGJzQQkO2/9To+hnAJvD44unw6GKqhy1mrP7noXc0myi?= =?us-ascii?Q?Or99myhFwedTvVR9MDzAsHQny9JeZ2vQfWAi7CouLzsA2T9eo7Y+G5NgFWBq?= =?us-ascii?Q?3du+AFVLaB1UbKxPN4w0shI6KLbM51fr3mhTvTKIHZoHb+LwE9BKrw/R7wpN?= =?us-ascii?Q?SglxMGSfCRA6fweylYyNnubpI5T1Am20kprUcx1uK+NYgnWihcHk/L8CPyHj?= =?us-ascii?Q?YWhnWtqjAEGIv9VDLXwEvRoWuObYNVsrpnZFBCnQAI7ZraVPaN21prqdRDAB?= =?us-ascii?Q?Hn0d0w8=3D?= 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: =?us-ascii?Q?FHIvQWrXYpvTt6xWWzVQ0sS4vA1zZJeFfReHSMu36+Cx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WSZgCJA0eiIxcYoE1OZF2KCKqDYiIPPTjE+5v2bCjIL5M?= =?us-ascii?Q?r0s7NMgNP07lPjRHgJ71ciE4L4yxM87xtSHD2wSb1xmWPgD52sw1Iz/yDPCm?= =?us-ascii?Q?LYocc2L0vuEijTrO//k7hYPFY9hExeesfslZA2nYYn1my+MnTFm7my0T726s?= =?us-ascii?Q?oFh7cvZVVmobLbk5awVUM5gXufRHuTcFXHzeUUwnR1Rx9tHgxEXcfNNco5dI?= =?us-ascii?Q?YMJ6HYgmRuHgDvAxjoJO42TD3+s7fpmfEJaDN5gPIZTsN1hWqF2bbNRVPy1s?= =?us-ascii?Q?aG3kYlnHApe3IR1Du1QdgJpUpeADMetqr7xOQhTMsxqTCpTcrbx9LgyFa7Dq?= =?us-ascii?Q?efjtU+gYMkE9PBUifOAaWUqcWI2wAJbYWAVi6S7xMlJNBbp7ak2FfajL7s4Q?= =?us-ascii?Q?pfc0FAXz7DIboTdit7PKZSbB9fs+Kn9Nt38P0w+1Bvb5mjzduqHsGytqBBhM?= =?us-ascii?Q?586RQm0ywI5kr715a2ad6vus9bKzKnyrXYaxfgaWybvc+OUnniv+QpFcCNqs?= =?us-ascii?Q?ay5pYfanPbaAsTBYLxiuBr1zPd1cpot58o3vovebrf2asG5yGS5L8XUSp8PV?= =?us-ascii?Q?g5nC9LH5ZNOytyJmZX8KwrUnqvyX39k+6iGzh+u99N79j8S2Ghi0QyhFSrws?= =?us-ascii?Q?QXxxYo4aEXgUaMuwlmFOucxZoYR9nMIn34qYz2tGBhGhkpEAIBdnGfQJTeiw?= =?us-ascii?Q?DA=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 *d= ev, struct dsa_port *to_dp; int err; =20 + if (cls->common.protocol !=3D htons(ETH_P_ALL)) + return -EOPNOTSUPP; + if (!ds->ops->port_mirror_add) return -EOPNOTSUPP; =20 @@ -1486,17 +1489,21 @@ static int dsa_user_add_cls_matchall(struct net_dev= ice *dev, struct tc_cls_matchall_offload *cls, bool ingress) { - int err =3D -EOPNOTSUPP; + const struct flow_action *action =3D &cls->rule->action; =20 - if (cls->common.protocol =3D=3D htons(ETH_P_ALL) && - flow_offload_has_one_action(&cls->rule->action) && - cls->rule->action.entries[0].id =3D=3D FLOW_ACTION_MIRRED) - err =3D 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 =3D=3D FLOW_ACTION_POLICE) - err =3D dsa_user_add_cls_matchall_police(dev, cls, ingress); + if (!flow_offload_has_one_action(action)) + return -EOPNOTSUPP; =20 - 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; } =20 static void dsa_user_del_cls_matchall(struct net_device *dev, --=20 2.43.0 From nobody Tue Nov 26 13:19:24 2024 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?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?nwJTQTYmue3rmqx4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= =?us-ascii?Q?fUKxOLQAjef0vznbwcFdGMgHqvLoEhDB9gbC5NXLZaZkF3AxabosBq8zCCC/?= =?us-ascii?Q?C5wuFst7BRRKycGQQo2N3k6TCC9CA4DHjwdEAcCtRq8/SGlOCCtwa3GeZMsP?= =?us-ascii?Q?WCIFsV3kT9B2ZlEyz/5Gx0POdAcNyslAI64gdnbgaqGAJtVblA9s1/WSJrsg?= =?us-ascii?Q?hGoNGF353G/6zD6L1nbBKbecLGvOqxiCImHl61s3zSokRvKX4YBUAn/mY9nA?= =?us-ascii?Q?Fz5dMKFbeANELSH+0xHUq7A3rJAVZGDaI17ac7wM08MycXCLqECEgRZZ2GqJ?= =?us-ascii?Q?aWh0Iz9I86eD6HJv24/dNteAfA/YvhTpUD4EKbsu/r3xt4nrMp4V2/4vnzDA?= =?us-ascii?Q?+2BGtECYjbfRWfgWNcwHQrIRglPF2EmN02LwASmMtqMkOPrQgGKRciqTsaCS?= =?us-ascii?Q?D+s/1kPl9X4/lZktbQtXYoqjx9J1Vjll6U2Z1XNCIiXh5YumstqLWm9vHXA1?= =?us-ascii?Q?IyfURZE=3D?= 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: =?us-ascii?Q?xjN4XW+RgcpRFWKTuV4sJC/MCVGq4dNLeoLHaZhpaSa4q7Qc4e0627Pt6l1n?= =?us-ascii?Q?Z3+Brm8S3UeFc1IQc7hDwH4ZaNfAR96py5lNbhknqtf7XDapingSVkiU1KLY?= =?us-ascii?Q?pV9ZfAmh/9gasbOO/gEaLRQJ9H7jBiAECOlUV9IO7Tjsu3gZXYgS6DSrd5cm?= =?us-ascii?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RM5BZrGqt9BNMcCIZCxcsWG2Ft?= =?us-ascii?Q?Re5cmMMO9pB6rky2Xtr0Ke89FZaRzU0FxPQuSa6m3ZiLan2EgkIgFqR7gjNf?= =?us-ascii?Q?mk+FbjLD2fesRKPFHM45jvGEs9j2AWpMVFXIQGS3duyTW/3k6GxLxMZMpdCv?= =?us-ascii?Q?Qf+Vc0lX/q6gWbAsgiaTHzH0HVmCy5IlsHltazBjeBfuMT6kGKXMuC0Mfm6u?= =?us-ascii?Q?XnM0Lq2zz1WwZshVKCYmwG0ltXPG9KNkaxItQD7hX1DOLUHdQ82Xc9aC8hKG?= =?us-ascii?Q?j8UYDTev3kAiOg2S5kW3R6wr88ajZvLeZR113BpfraMu2w2sFUKSU2y23+Zh?= =?us-ascii?Q?vmT7ZMXAry4TLlWgiVGpSNwKRYVjoJRV07j5jfV8m6SY+RWUMn3Y+tniipdT?= =?us-ascii?Q?nbfhsUUzfaCP+kp5uvNCl9MukLxIsfswIU4D6Ay/oKQR/UbcMDBXTxdaO/qT?= =?us-ascii?Q?9pCej5fjd6XNfd25+d5LwCI75+3M/ElR98Kqg/JdtK//e9/rbgSNKL24J283?= =?us-ascii?Q?f7QeTEKszjPMgsJveO1zAov3AIbW/luVPHUS623AUkAj7M1sSRXQ+32fKtN4?= =?us-ascii?Q?NA=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 *d= ev, if (!ds->ops->port_mirror_add) return -EOPNOTSUPP; =20 - 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; =20 act =3D &cls->rule->action.entries[0]; @@ -1450,8 +1449,7 @@ dsa_user_add_cls_matchall_police(struct net_device *d= ev, return -EOPNOTSUPP; } =20 - 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; =20 list_for_each_entry(mall_tc_entry, &p->mall_tc_list, list) { --=20 2.43.0 From nobody Tue Nov 26 13:19:24 2024 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?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?ZWHDjk1MaeQOtJUjzJumCn6n1dUgziDk648F1TgmSO5iTgfxGBLIUMlZ9k65?= =?us-ascii?Q?XjpqmeGEzOpCvk0+j2Q5TnPb5aMhFwY7yN5KZrRGkMN4lAj+1sHayybjqOZB?= =?us-ascii?Q?i0XuidXjM1ryH30Rly2awQCdhF6PIQZ767MPjJM1qn7JOqnFO4ZD6hovLlL3?= =?us-ascii?Q?I9M2OCjuhn9fmnU7PEvLoMCFDPWQeJuHmrc0VeCcWQoq0MvL20Vdb23jBjIR?= =?us-ascii?Q?GGiyw5L8gqcE6GK9wfr3wPtPZujrZ8qNn4KcoEmBxBBrdTy9uGuvOR0sIr4l?= =?us-ascii?Q?xbfAolki+MIz4Yobg2nL3HWwxCtr7VaaH9lq1+JrTdlzldsPfRmQ5pzq6cJd?= =?us-ascii?Q?FIVq7Azm1I6URM6tTxo56/ctlzWKiBnEKVSYa9Am9W5OlOjaUeEH4Hb2kvfz?= =?us-ascii?Q?H4M0v+hOP3skdG0INjNAZTr126c85u9tR9JYB7beDr8y0NHZmPndYZaTxwoa?= =?us-ascii?Q?TBKAg9iOQrxut32DOvVTiXIm6NFbz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ijdH4jA=3D?= 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: =?us-ascii?Q?nU2YwVH2QkEbFxF+B6nnP7WG/29p5d4YQec9eSVD8+dpq722NQfGG1gGq7Xt?= =?us-ascii?Q?HDRaaHfwlORtNMaAs8x+l2YgDZwgscRlo6It/anHspr8/ytXdOYgi0M1cdBg?= =?us-ascii?Q?wVv4hgt0goI/0U29/FNxnHBAcUAGLiEFrv/7y7Wyd30JReP+zMIs5hZVVvBh?= =?us-ascii?Q?N/b9Dp3qLpHf6utSqNxGtiTF0eVYoTwZDW001F34NG6yE7SXorLBS6QQd97g?= =?us-ascii?Q?G4VLPU7hGHe77hDGtcQGq5O493/viLWII0tLrZzlmCvMmMw1VtlsIfdTl532?= =?us-ascii?Q?x35NB7yE8/0SSx/ecPwwNidiNgdJhDeFKsUR8MrS5/bmljjwhK3QMySpCF0/?= =?us-ascii?Q?XvcoL/PPxQMnb5MqKazZM9B8Xo/w/iITDNG7W2MsJzZJY8ODxsMK8VlMez/q?= =?us-ascii?Q?z7oLgk4T5gQYecowGFZYnAbHpnRMeeMZd8HeGEvs5lV/Uok9zTuaE1Q0vkxZ?= =?us-ascii?Q?fcbQumQGnvsPzXUIf/iM9y8d3i8yTDAvhNzKVGRtDIJhXGx78KxtHXlU89m5?= =?us-ascii?Q?cV23B/qLg2onBBF4YKn6vIcRxiGVZn6Czi1Pnzk1NtyEnKKOMH5xNalYBLVz?= =?us-ascii?Q?QVhcjDA2NMvfw7XsCarmfs8xsEd9k/DXqthBt3/HRCzU3mHXogi3PoxDiRXV?= =?us-ascii?Q?LYMWpDUm1WkOu26LbIA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Q?OlznNPoK+R0usssdIdDkoUTo0AiczOQ7kFI38pfxMlKCfcfojn2lH3hOxs/t?= =?us-ascii?Q?OQ=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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; =20 - if (cls->common.protocol !=3D htons(ETH_P_ALL)) + if (cls->common.protocol !=3D htons(ETH_P_ALL)) { + NL_SET_ERR_MSG_MOD(extack, + "Can only offload \"protocol all\" matchall filter"); return -EOPNOTSUPP; + } =20 - 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; + } =20 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_devi= ce *dev, bool ingress) { const struct flow_action *action =3D &cls->rule->action; + struct netlink_ext_ack *extack =3D cls->common.extack; =20 - 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; + } =20 switch (action->entries[0].id) { case FLOW_ACTION_MIRRED: @@ -1498,6 +1508,7 @@ static int dsa_user_add_cls_matchall(struct net_devic= e *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; } =20 --=20 2.43.0 From nobody Tue Nov 26 13:19:24 2024 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?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?N/boNtQjfbpXU/QcfYP7nqosjVGs6DiuFxEx22IqXWK1iAd3sespI+DHrHYe?= =?us-ascii?Q?HcqgE97kgOfR6iMBVpWDIxe7pigr8S2GJ81NlQJMnfSm9tt1bWfCy7D2Qu3i?= =?us-ascii?Q?m6yOumTsCsIO7jprDm/An3UVzYPnwFjxIq/RNBvD+JlkfL9wBwVos46Cebvx?= =?us-ascii?Q?AcDSg/5qxlsWhH7P+a6Tiq+NBWANo+OyyDzkPC7QCXmYGJjUc5wcoXqTxkOi?= =?us-ascii?Q?zPyvNgRF5vtDc1ZcoZaUyn50J+4yrXKaBiZFIltMLycJL2yj5ny78u7cCzE5?= =?us-ascii?Q?ZGFgf1im1LuEUluaNqy4bqko3+7xHLz6j/iwFpmpH1dPno9KmWGX7uiq1HJI?= =?us-ascii?Q?IVB+EM419MKjPrV7fM3gxEVK8bbFrCQnZYTmXHNQ1buGFP9c+4c9gSYvF7gr?= =?us-ascii?Q?fS1xSEFXMRbJdJ69fpxIKGXXIa46978mUbvPqCue2gu8XhXyLWW1p13JHjcf?= =?us-ascii?Q?68nR9Laj6tvHeVwThjJIId0WDJffLTbCqWwPowcw1Ss5II5d7qZmtQd5gn0Y?= =?us-ascii?Q?umL9sEWebBES6ZWR+zOkVASg1yOgujH4SudIXpxcscV1ho3lFOFNsaZnVLG2?= =?us-ascii?Q?ppDyavWnPZ4/LFzNiS+amLOqb/+7bFXP6Slv1vUvSlKwWATfbVZe8Ub/qw91?= =?us-ascii?Q?OoiRcrwZyhNo5tmak/JDzdfoFwEpQ8V9OFzQcj/pRognnt2B6gM26ks7/tgI?= =?us-ascii?Q?lOBoEVIP5BMSZFC1TwfKuOOq3qjwoBXYFzsjuYTsgbFin/E+/rByHfn/Wdav?= =?us-ascii?Q?A0a1ohuLbkoIyAH86nrA1ydvucP3Yv4Hrl5S1X5Xry9ZH6xOeqyco7bgk1qe?= =?us-ascii?Q?45azl1WJDPGLlkWPRiu4qRGdtEtmHI22Ewe/zb28VjmktPwNUoaE71uXZv8U?= =?us-ascii?Q?G9Jvx9kA7n/C52zpB9CIkwLo7Au+zwgZx5Eyb5ffkveOMdE+FK9o9MVcPSvD?= =?us-ascii?Q?kLOXB6b0XZYgocut6phc9WjyAOtV8lnPvMRXJ7PaDvYApGMfjz3BPNyCXzZH?= =?us-ascii?Q?3NAVhRb9lNzuPgNnrCwB2mzZOncxqi9y/g+YONHq6qwRm/oXFdJN3I+/oU5l?= =?us-ascii?Q?R/5rki9GPxf7k1RTCubh7WgjSb2ruiSTuIAS63BpY5BAf2CxaLKTEY1gBnRV?= =?us-ascii?Q?H7+XG0V7QAIHd9XWXRfQ24+3p6OPUJQNYCKprEE6MbZRddqA/O8eR0LL7vdu?= =?us-ascii?Q?7kY12vhiwxq+IEPkcn2INvkJ3bTkfioRIDzd4zKTXpC/7l3sOkkCbt4g5P55?= =?us-ascii?Q?Eeonf7j7rWBbAY97pwypzn+n+URNhNZgdNdlLWFJd9Qe3a8KiMJciGkf7mi4?= =?us-ascii?Q?H/jzOPcfBVv6FsteDwpgaxj/TBYcGaZofSgPSaN4kwCf9VZpacWrJvze+Gpb?= =?us-ascii?Q?PJHgSeXFcohZNKOH+6/yD1ITEPAJ?= 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: =?us-ascii?Q?nRuuVUDwKrqt5geaYuHjE+AyC/qadtwsFStQM1d5xVAsAcloi3+qUYh98cP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tjFp79drVIC6aYXpFXpJUxilQC?= =?us-ascii?Q?dGB8+R5XaxZHHR9TIpnAsab9Ux4KuvEKFcj6pYlsSRM2m30jNf+YqqM9QrNf?= =?us-ascii?Q?yEjjHZfDV0s4GTagW1czuqW4CsGWhU5/I88zwL8q33BgQ0nXsE1GHAh4K8WG?= =?us-ascii?Q?6zo0l3InIvcnRJ4dGsir3MfAkiUr/uE59Lo5I4KoJOJbDCL9nOETreE2jCDI?= =?us-ascii?Q?OASXw55jVpvzxRNL6UdHMznU/Cl9FG845bzOsWE850dU3yeKUfmkPtTj+U7n?= =?us-ascii?Q?pfrTYN7m1PXJga+HfS5myoXz+E83RufyM7vR1B/yyrewwVIvq+AHXJ2ltalf?= =?us-ascii?Q?uUSVHh5p65Yis8yB4gyBGZfZ5yJpVLewYcOushAJHJx7+0PO1uvQALsmeDhO?= =?us-ascii?Q?NRNOd5G0Bl9hJkzTKgDh5xb4+UKn+IXKLiIK0Gy9toboGaBTHYV407R052N8?= =?us-ascii?Q?/zQ12UABWH0Ku5GQAJAzdPtLBWL8bXKlc7g6oM0cBZe0Y24aMBb64MMbgQfE?= =?us-ascii?Q?DCxsThcvEIaSp3V8yqBnxoIPQerme7zVFHRoAjk0bLmS51YsAhlBd0kLcA25?= =?us-ascii?Q?C84WT0Vn5vEd4HXNXJDizoi/nSHrJUOlmMjF1iykg2nFovMee4t1+43IBb0Q?= =?us-ascii?Q?xT1zVEF8vOIAK2AwkbRk59EyinZRbBul1NMZQ/ZiKO1TWgACSNjrC4TfFp1q?= =?us-ascii?Q?/w=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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, u= nsigned 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 =3D cls->common.extack; struct dsa_port *dp =3D dsa_user_to_port(dev); @@ -1397,10 +1397,30 @@ dsa_user_add_cls_matchall_mirred(struct net_device = *dev, if (!act->dev) return -EINVAL; =20 - if (!dsa_user_dev_check(act->dev)) - return -EOPNOTSUPP; - - to_dp =3D 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 =3D dp->cpu_dp; + } else { + to_dp =3D 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 =3D dp->cpu_dp; + } =20 if (dp->ds !=3D to_dp->ds) { NL_SET_ERR_MSG_MOD(extack, @@ -1504,7 +1524,11 @@ static int dsa_user_add_cls_matchall(struct net_devi= ce *dev, =20 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: --=20 2.43.0 From nobody Tue Nov 26 13:19:24 2024 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?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?GcQrJcVsTqPWSmRHZ1gGL5Rhav5gb4codOflKeA6PYbn33PIhIilUeuxbqfG?= =?us-ascii?Q?+6IdZ8Yz02I+tmg+gArCisvIEWths6/aWozeOSMh7dkfOASbSEtIsYu+LamS?= =?us-ascii?Q?FFIZoULe2K1pfgPKwHHZfhZYLb83kJVbo8rb9FVq4iUzpppKYHB81HfpGsmg?= =?us-ascii?Q?D4jVzrmWgZnZO/ERqQZPXmvaLkaDez7HdBLbDZElFgsMzHZoy9Ex2G+yAwXI?= =?us-ascii?Q?oVkv2Gxo4Sfcm3+LV/fxaQREqIlcayRjXZvqXKv6obtr5s8ymJo/FmbV8zUJ?= =?us-ascii?Q?/c1SSswcLYMxCc3XPrifGYgFjqu/9DtxZwTtld0/uS3QjEemajmG+1yQ1Wif?= =?us-ascii?Q?h3+1QvtqMqFK2LV7Ud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OmzTFX0W?= =?us-ascii?Q?hK2gh6UuXhUOjU7ZaVf3sVEAQEp6NXBc3VDhwZtQvb13/TyKcPGd3GtNwQqD?= =?us-ascii?Q?jlV63vCKNCakZcVSVQpLAK0lwUtHWMs3Flme9YqBLBCUjb/UyqT56rQD6LpV?= =?us-ascii?Q?LDbPqJk=3D?= 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: =?us-ascii?Q?YSqBdQtUnszXuyHGQETLJEFWn94aJqQY3yTXeOvNzGUaGim2Pab8IG4DVRvS?= =?us-ascii?Q?B6tQhWCjCY2ClkEC7R2V4D0Lde+LQ5ABQMCG7nrKG5kYH/uKw2wbQHHnuWN6?= =?us-ascii?Q?v5+ztPUQ8x5N5PgzDiYDuLDpal84rdaWmlPeTgPnZ1KQ7LHAhPR8k9D3RAgW?= =?us-ascii?Q?MFER/o1gAKBc7gGVgg9D44oBmtCjVEIh2HaYkdtVlCwAU4Nx5svzH8BEmsnt?= =?us-ascii?Q?pkJMNYiFBXlGUNvnMRuR/hS50W/Zvoau/Zkj+rslJT6Oeq+4Mgg7ukc9H4f/?= =?us-ascii?Q?Zv4tXBzq0fPBU5KebhJvWR4q+SylWoNKwVq88R+7W9nE9NglRZDrs8qzPX8x?= =?us-ascii?Q?lakn/UJyWyVz3CrMBnX7VfyBewVCmVkgYCqiY9JFd2l0neCx6ZWOZeNcVNYP?= =?us-ascii?Q?KaErxyRZbOcS78ZrANrKwPCiYa3EQUgJnTxoau2QDReXPDRJaX6nedHNuZ/Z?= =?us-ascii?Q?k1e5RW0G1JTeVJPUNnkOSwaYNqbw+a4Yd360Zrmp3raP26hO2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ESwUILKzrmzK+ybUsoxqtnpr52y412fHeLGcuObLeA?= =?us-ascii?Q?xT+3MF4ZKy3HSzwikwAy7Gshq2u/Szy9N34DKSxBv/JSB8D+DuVr7CaKQVpu?= =?us-ascii?Q?nUTewSWPcHleLnvIaUXUCMA4WhKeb6kDCXrf+ZTBjEuuY0w+aWMbugwTSqm5?= =?us-ascii?Q?60KE9TTf5JgkEGJZuCwNg+AsebvzuBu0TNFLbg1AGVjVhe4JiPEED59XP6ql?= =?us-ascii?Q?DA=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 m= irror 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/ethern= et/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_v= cap_filter *filter, return 0; } =20 +static int +ocelot_flower_parse_egress_port(struct ocelot *ocelot, struct flow_cls_off= load *f, + const struct flow_action_entry *a, bool mirror, + struct netlink_ext_ack *extack) +{ + const char *act_string =3D mirror ? "mirror" : "redirect"; + int egress_port =3D ocelot->ops->netdev_to_port(a->dev); + enum flow_action_id offloadable_act_id; + + offloadable_act_id =3D mirror ? FLOW_ACTION_MIRRED : FLOW_ACTION_REDIRECT; + + /* Mirroring towards foreign interfaces is handled in software */ + if (egress_port < 0 || a->id !=3D 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 =3D 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 *oc= elot, int port, filter->type =3D OCELOT_VCAP_FILTER_OFFLOAD; break; case FLOW_ACTION_REDIRECT: + case FLOW_ACTION_REDIRECT_INGRESS: if (filter->block_id !=3D 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 =3D 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 =3D ocelot_flower_parse_egress_port(ocelot, f, + a, false, + extack); + if (egress_port < 0) + return egress_port; + filter->action.mask_mode =3D OCELOT_MASK_MODE_REDIRECT; filter->action.port_mask =3D BIT(egress_port); filter->type =3D OCELOT_VCAP_FILTER_OFFLOAD; break; case FLOW_ACTION_MIRRED: + case FLOW_ACTION_MIRRED_INGRESS: if (filter->block_id !=3D 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 =3D 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 =3D ocelot_flower_parse_egress_port(ocelot, f, + a, true, + extack); + if (egress_port < 0) + return egress_port; + filter->egress_port.value =3D egress_port; filter->action.mirror_ena =3D true; filter->type =3D OCELOT_VCAP_FILTER_OFFLOAD; --=20 2.43.0