From nobody Sat Nov 30 00:01:17 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013057.outbound.protection.outlook.com [52.101.67.57]) (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 6E2E039FD0; Fri, 13 Sep 2024 15:29:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241394; cv=fail; b=IoaNBVtp4aO1jXfTKSEnOypj/5TXHbsi0pjhoB9uqgyJfArTD4b14rggNKqsUOiTIh8iSwXST3p9dOk/G37jE/9FiZ0qOy04P65ZNaGPD+zXvYtIVi6nIB9jiy9zK+h5eXQe3i+9DU8SqVkJuKOycTE8i7rEBJg51fBPhHaiXP0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241394; c=relaxed/simple; bh=TW7bC+EMo8EM2a/+zS+vxFKaYPJ0w7WjonrQ9anwBzI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ZmxPF011Cuufm9KFgcSGGfeUQAzADDqN+f8h3nxUX4lxb4v+CBQxWUyGqOAu9cBNB+DEn51WTMzJpdo/N94BVAS2qLnrKJakyhAzKLOas2o0CuoXtdp65YH5+STZ5Q7HOgCo9NFkMoJomWot/+Fg3EDEVKpk0E3mn23orkHJLNI= 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=ZaG1hD+6; arc=fail smtp.client-ip=52.101.67.57 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="ZaG1hD+6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L2IhJc/X45MsIQ/CftXpzatTJBVo4+0olmxKrabshWG/R2BAfP1hKdAIGZewLLDZkDAdb7ItyEItGUO3roiSmPHqtV5Fld9Ce07oPd2mUVXr5FvN0zxIs7YBnY+k9V3oQJR9eEozpqHgQ8wUPsCZ+tYilz6kt+DNSyvudZhQa4rSoeVUrEYtVnSOfjMixl72CuifR0hjXwFHaSJg5cgXV2t7fYVav14r1Fp60+jFD6HP70Cfb+SmPMseftXr2CN1lNqvBuomFLHRp9ug/zcHzOAOujGi6wwBV7fV1E8YB2ltNUm0ujLfL1dG3XduLrFabhCryiOxW2EK9Mk+KhJbMQ== 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=tq5vjG75ICKRqDau+yV+so5BrH4xQQBHKSvjhBIyuUc=; b=OmZPf6yZ51F/hDiDMAfoSFG1GxYp9BKYz+Um3xy93KFtwtJyIAhmerBxTOhPhJQvXlAOnWPRMuewfCM20JK7HYe5Kpmg/X8Nf2tXU8mmFt4iNwqJm0HIDM6ZH3CPRVDYPLZDfdk5oPgzdqYxxLzMzhwZUHzy6ETkQRlxnnt+oYHsuxQTB4ztZwHq4tdpxttIgDYeF/4pffsYKZT6oIcjATH/fcJr85TKwQo4/duSYCFMohV81O5GDJJD95CfaJ4y/ZDi1gVote90EbdO+uIh5JbzXbxdI9TvI0ttXtW5FCjfQ9tBCsRWIreRrK57IDMny4tyGjnnLYm6WlygjLHtzA== 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=tq5vjG75ICKRqDau+yV+so5BrH4xQQBHKSvjhBIyuUc=; b=ZaG1hD+6lvjzRgWbYKlPM3mXKTAZPLCQsyPaoBgeWCIYkQk0hSyUgnqAeKYRcfx24vlB+zyhC75tTNqNZBhBA3OrgNmJIAQzl2riv+c6RZnifMd2IB5R3acjrDLT9ESS0YVhH7xpArurBxjZgObgu9FVMM8r/gCVG/PZPVEDnAxMTFTaoQHgnEMeANYQWxlJT5xyxGC/eZi/AGcVPI5U1Ds7VOThixD2pSIW8E6/LfSm4QeLkRWl3A5qjCgaKE8RHmm/r+zNHrIOXa6kR1cIH7oS9o8T0vVM7arRQ+cRPDaUP6pynhEjGNCu6H61bZalK8zQPCXvGlwK1h1kSFcz2Q== 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 VI2PR04MB10859.eurprd04.prod.outlook.com (2603:10a6:800:278::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.19; Fri, 13 Sep 2024 15:29:47 +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.7962.017; Fri, 13 Sep 2024 15:29:47 +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 , linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 1/6] net: sched: propagate "skip_sw" flag to offload for flower and matchall Date: Fri, 13 Sep 2024 18:29:10 +0300 Message-Id: <20240913152915.2981126-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913152915.2981126-1-vladimir.oltean@nxp.com> References: <20240913152915.2981126-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VI1PR0102CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:802::18) 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_|VI2PR04MB10859:EE_ X-MS-Office365-Filtering-Correlation-Id: 77f70d8c-28bd-42ea-7d80-08dcd408e6a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?g4Ls7s574TlQGwdbWMWhdHhLOA8ODsItgHCxZ5KMkiqp2ZxeIqJ8pCwEPc0o?= =?us-ascii?Q?4DePSaLUeREAmvoyjB1uyBvp/BCbmeI4oJ9b9BJuKC1NGg8jXvohEhj59107?= =?us-ascii?Q?wcGbnt5fcZ34+2QPIJTcjO5hqB7A11ISi/YZl6wjzyJgMiok50joQNjR3Rs8?= =?us-ascii?Q?/A1vDKGqXrKbc4xw2ALXj+vdGwbCqqwlFB0O764agB9vBYlW0K2YvbGWYXXV?= =?us-ascii?Q?qj1YXIyM1rRuxJqn91ArtDgrBFpAiAyDJCIOWa6U95IKda9H/LYqf+pmRVfh?= =?us-ascii?Q?E6B4KvzeYRQ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FdbM4hIr?= =?us-ascii?Q?lQyux+EtUbdwN61+DDjffmCHyAYDHKirAgSQQJEZ9LKC2EaWlfC9H97p/Ri5?= =?us-ascii?Q?4NdeNGpchslgKnix3i7ROXnU2OcUj2Vr1cds9EFf65BDsT40NWRKv0Qux7Ys?= =?us-ascii?Q?hYEtbodUhHubcygh93XtLkwswPeUoK/LoggRDaj3QoNcnGgGpx1TC1CxYTUB?= =?us-ascii?Q?HkdQoli1DdmEMOm+sJ19fbPAY7YvRc4Wnb461nEwK+qtFf14Mw=3D=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)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4lk/0bc+L3fqXbOa1Wn+xEQnN69LTtHvVma8j2hU6M3sM0GRsWWnsyclqOcT?= =?us-ascii?Q?YtneoJLQAcoGZpsR5TjrHx3LGBDUYg89RXDYwSfW1KyxSZjvGjMW8qZp5Z6/?= =?us-ascii?Q?6sD17pI6j9LhYATqU0nkNNo7wQF7mMNB653eIWuNEkr+KT9cDDQHvI8ss2ta?= =?us-ascii?Q?hBmXBrGKmJpiA4MG/ZbUqlyZQMCtU1d9pqrE30NUI1uC249OlE8QiBGWsx6y?= =?us-ascii?Q?SQQiUSRQlOtVb7Wi/a2MtjWOonOTIpQs8PxOyCHFqYROiPYR1N68jS3G6vsr?= =?us-ascii?Q?PzpAyxrT9YL6R75O5Er14EF0MW3lS/duv03XWoSEdkqoM1vGzxP+MSCbrgLl?= =?us-ascii?Q?wBylVlLi31aia1vYNjPky/2u9/nz1Wu+F820B5NkTfAAzWBcuhK9pDvuI+S6?= =?us-ascii?Q?BuQdVIPFSVkyrlZx2M7RS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hBP?= =?us-ascii?Q?i2xxRx/ff6/ssP6EhD5+61UyNfd7ND6j5kjx+6sXtmnK/uDmADUBoHNdGRsL?= =?us-ascii?Q?TPiW8tWl4HblNAc5pWkojelgcZUatcdKUnqeIeOafHDOt+W1Pr8mlOM/S775?= =?us-ascii?Q?uRTdDgdBR5RwvJH1VhGOt5V3YeadnZzT2fQnEPPauexyvZLg6Y9g61eUiv6v?= =?us-ascii?Q?DoOrrb/qkDFHYHJJJJUd/sRZpPRHolbBfSX7WH358D4B1Aed0x54x8ZUX+FF?= =?us-ascii?Q?WCnJXsJpegg6h8k9sYqbEr8mbmTjvs2mfJB1jLWdlGSdHVK6QNZ5/sdWPawD?= =?us-ascii?Q?3w=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77f70d8c-28bd-42ea-7d80-08dcd408e6a1 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 15:29:47.6573 (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: ofde0l30xObtNm6+Soy47LGZaR88SZYv8AjTDG8ZF0rl2DlDh5oBye2t558zAeMzP+uwjwr1Ug8H12g++gghTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10859 Content-Type: text/plain; charset="utf-8" In some cases, an offloaded filter can only do half the work, and the rest must be handled by software. For example, redirecting/mirroring from the ingress of a switchdev port towards a virtual interface like veth/dummy/etc that is completely foreign to said switchdev port. The most that the switchdev port can do is to extract the matching packets from its data path and send them to the CPU. From there on, the software filter runs (a second time) on the packet and performs the mirred. It makes sense for switchdev drivers which allow this kind of "half offloading" to sense the "skip_sw" flag of the filter/action, and deny attempts from the user to install a filter that does not run in software, because that simply won't work. Signed-off-by: Vladimir Oltean --- 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.34.1 From nobody Sat Nov 30 00:01:17 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013057.outbound.protection.outlook.com [52.101.67.57]) (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 94A4152F70; Fri, 13 Sep 2024 15:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241396; cv=fail; b=niFEGNJU9UaFTnmQArkFOr3yrCtFAGfiu+TqHbLSqNe0XsPeUnwGduleR4uw9oQgnQW3+OnRKT/Bd8I5oaLtkiF2hc5Pd7rGfBJAA5SMIzGjVD9WmIZpx5GYECgcWQzjCYT24pDwDar6/EBs6XNEb/1as2+GoSl9dpOBnaZUnz0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241396; c=relaxed/simple; bh=OkfpFZ3dlu/yXKeKghVr4vgnmKA9vBJvoCXhKjeRBrE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=s3kHEU5owmVETy8W3y4hlZ+3WcSEFNTBIbSC9hmZlH7POefwPdbuUFZy4cf+FEHUwiQi1/YCm7nxM1KBf7QBrNuH7avJl2n5D4mP3XkLsvMmQxfKkvRGnrpLE9mFm+eiP5C6vMqOZ0oi1QKyH0OtFchMP/ZIrX+kOtpe/JrIGDw= 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=j9EGnJqD; arc=fail smtp.client-ip=52.101.67.57 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="j9EGnJqD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iN+/AZ86M3G45KE8RR5tO4K/lIkmT4a2aODfP5QGxEsujO+CnaeJCy2YIC2/eidujB/ujyynnvfQjO37TmEtTKkdiV1UMN5IcfQGxeOUrw1dTAcw1QdNl8azGiXPk56Z4Fg9w8eLNkhmaig5J9BfEzSiJYABTykF/hvO5Fm6lxArCrDrneUJoheaw6pJT6LYkzOEV7DHtzFtOWaNfN+OKdNfzzNTiSEX/M0K68aMiI2tUDHf5+5WYbiXJRS+h3ZmFtu4P6qlq0chMukvBYrdghKeswiaR4Cwpgut7JouEueiKn5fTqJJ2IxF34HSrYE0aRLzkims6of3QqYDu/0P0w== 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=QjeTHLE74iaElKzNULJuZZHF6JMuMUe/6vhKO7LRSoM=; b=UYBqUktRzZ8EQ7KVEsUx42U8Vk3VgLqQ2gF0b5NODGLu/zi5acKZIAlsFPViHyTiExeb/4ZOFOiSqfuDKRyY2wxYWN5iV76YESmFrObi2LPv2gqfYC+2Egoa+TmUcNhsAFbAR5N6bsXi/roRIbX28+m8XBE7EeIzfjLsxszWQFCdB3527SXtI4KD24VqG+QnjJ7xBsnF0V5fAS6VcI8flmJwalvo8MtExGcvWca2UPb3TQR2cUog0qK35R6WeyTSu98iO4o/caD0U0YZE77LyfLnq03Ombgej+X8aO7tBeWIFIY5bpyyKj4siWV9+X/pZb9EJurb1WdhwQqdBeiFIw== 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=QjeTHLE74iaElKzNULJuZZHF6JMuMUe/6vhKO7LRSoM=; b=j9EGnJqD3uzFy/inR2ZnRmwWCxRM77sc5A82OIHuToLYsm5NH47ZxfPxtvAcOByh8JrhM0nfFyGsV/KYS/0524MfopbSn4yMXOz8ulV7dreH32a/12TqBPZr8mueeRWKkwlGLKskrwtTFed0IaSXHmblHD++oTXZ7K+CKSr+f86ImLWRew1jPZDVXFKmka14bPA3jxGNk3WBz6JkwxEdHxAFWi3JqaWMW2XwXu9HhMdrhyj1j8vP9+SoOrPt7RiXK3ZETeT5lTk4XMB1tnXGoz5eLQP3+EdIRPY5uK4O3IR+5u32d6SvDCUUFuoLQlVjMXPeNO9zQFjl5XMh8cevaQ== 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 VI2PR04MB10859.eurprd04.prod.outlook.com (2603:10a6:800:278::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.19; Fri, 13 Sep 2024 15:29: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.7962.017; Fri, 13 Sep 2024 15:29: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 , linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 2/6] net: dsa: clean up dsa_user_add_cls_matchall() Date: Fri, 13 Sep 2024 18:29:11 +0300 Message-Id: <20240913152915.2981126-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913152915.2981126-1-vladimir.oltean@nxp.com> References: <20240913152915.2981126-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VI1PR0102CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:802::18) 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_|VI2PR04MB10859:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a8ef2af-2809-45d2-24fa-08dcd408e765 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?t0cf6njNFtZnrAS+4VIy7DOoEDbhlW0y7bH1bWgrviiycKdmJCcIxB7IG94Q?= =?us-ascii?Q?Z6AaRgudgr6u/70BWK5hkICBK9pDMxlutCVTS4x0eSpez73LPTIYJlPX1Wwi?= =?us-ascii?Q?zJl84eBcr0zVNZ1OY16DCVzxwNFj8k/6IHXGkfDn44dcRjUzhRe5iHO1KNV5?= =?us-ascii?Q?hJ6tIW/rUxSrUSbFDSANrBuVwGEMwXln1vk0B5MlX7H9hV7Uhg6nykQI7GeH?= =?us-ascii?Q?C5+l0/u4vVqiRA9CCXVHqnKupGR1RtsBCGNujXbtUNsiPAzGuWSygWZWbRmx?= =?us-ascii?Q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oyWojVvx9oKLm?= =?us-ascii?Q?/xXgkVeBD1c/I8ZN82Ck7Nqk0bLA6FouM6pp96he2RNTZHiwbwy05SBckCL7?= =?us-ascii?Q?BcJhXh+x90FNwf/iBYTXqkVrIQjVf7QLlyvCpj6Vhshevd1SrG/iXpK4avud?= =?us-ascii?Q?o2Nf+YJDdfpPX3BjIIvTXKzaRuoOHtxEZUYpUGSrayMDRF24zTLinkxBmaed?= =?us-ascii?Q?aEIA5wzhKal9kNzw43cM1rgfD+jAWEjlaolqjq26VsdrwUYBfQ=3D=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)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sMPUar5DiNgS+g/majGw32xnj6K9OlKfyfcfF4SSnuLl5Iabe0PB+dd4d4U/?= =?us-ascii?Q?Oq2G2ecup7q7aCr/ZaYBNBL4Sq4yrHlRWioNcrl8ftWQfg1Q6F4OEb5jNMLl?= =?us-ascii?Q?T6IZ/EYd4GgAmY0DpzjURm4gqK44GOVR0dD4YyJWpjxc+m5pan7wrMiMKlNN?= =?us-ascii?Q?1jppNf9K10rOwsRRWBpQj7AwiLioWFPtJiMSdHW/KjIS1gTeaKJWpr153Saj?= =?us-ascii?Q?0jN1PBNPC+lsAN+2nFEDNYZ44qmpzhVVc20SX7AOqleyTTJC3DTvAqKokeDs?= =?us-ascii?Q?H7LcUymGBn4NQA7FJSB+oTAKuKOX4QFmYmI8rvPv/oDiWKDq5RV3rp0AzLFp?= =?us-ascii?Q?dzntdiG6x5xj3z7ir7FjwH7QtYbnhzzuigla5lbCpm+XJwfXuqyPrJEQzkkA?= =?us-ascii?Q?ViE9tcMpQRx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mq1ui4TeDovxG?= =?us-ascii?Q?CLsQw4AfDSGqriRQRpIXNfCThCaZntJntbPLmn9wENDmp7RSQf0U71kWfwHW?= =?us-ascii?Q?GbfnEY+B3uxS8qpa8Xrp0dUgdFDryOJ3yz2CD92IDHclwtmBY2idytgdab2N?= =?us-ascii?Q?v/aA8Aiq1UyDPnahsvPcZDjz8FQyU4slmrIDwtJnCKq/+Fdym/Rh1vWhRiKp?= =?us-ascii?Q?tJJrMaDZnx2Lhi93arlEMH87yL+G9HZSCzXc85YYwqExAFKXFJgy9rSwxD/F?= =?us-ascii?Q?8E5ZtTZ2s7os+Ie5JGkCTFrARuKNJPdBQrYV556KObH91C2+z/SGtTg3xao1?= =?us-ascii?Q?9w=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a8ef2af-2809-45d2-24fa-08dcd408e765 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 15:29:48.7936 (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: QQb1puI78H570YYO+Uwu61XaLg+wbOAz65qgt0sfHPCXvGvHLwY//zyc5AtSPhmjJZls2JvatT7fG00ckxaCjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10859 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. Signed-off-by: Vladimir Oltean --- 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 74eda9b30608..143e566e26b9 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 @@ -1481,17 +1484,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.34.1 From nobody Sat Nov 30 00:01:17 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013057.outbound.protection.outlook.com [52.101.67.57]) (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 AD10769D31; Fri, 13 Sep 2024 15:29:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241398; cv=fail; b=gO81eAAeQ93x5rOz5OIywvvepzrFxrf3wOb8DGFTxAenDkWuLyFKhOi7q43ZkA8U+UdixU9OQhSgxDm8ukzpOSH4FWXqrOosSIHnOaryxcS0x5BCHPfbJyNps7oo5RWOZ1o6QeBPVXUmtJ1FgjTlAqm071Ret1BuyGPHRgsI9DA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241398; c=relaxed/simple; bh=w1jiKdaGVmJE1Xb7wA2kzHyilovYOsj6MrM2YXWpWbc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qKIuH9gI/ZfKiZis4riaRSUglE5xZScW9I2iJDzakqvnwPeFIJbjwPTcBhbhgxcuV8uJCaQGtM9g/MigoaWLyVft8EXevO3T601FEkBESeE6up6QT761pPjiqvBLXhc94xzbBBUO4VoFTkz1yY9o4zS3Pvx8twbSJYaDraaXIXo= 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=cG4HtMqt; arc=fail smtp.client-ip=52.101.67.57 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="cG4HtMqt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A0fs6BTtfwI3sO2iC3xMNl7Nw0AhaI5DIw1kaecNPqIZ8lLlvQiz2PYRCwAsAS/bb9VcCagkIh/FaTCJZKRD+czpPt/y8CJhgUHc2j17icKZCncJfA6ibGHYHWRZjDIbc9jnIxHgsGQP/ArqlrNooQLLeQ4eXQbz+26efobsViJ8h5xjWaKp+AROQ3Uk5LHOqOQNchLkUsBtOUtcPYJd8HT6Qaj4aIWSF359yhrFFAc0s1X5npvWAqdoInFpnad+5vAaXQUuegcG3ujz8vEwwmjcGjPJd7YSG69lN6vEBAd2Ebm7p1thRHj2fZZ40wY6D2t+cY0ZswENkuVL6LPmiQ== 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=B9CRiIOz405LWDfk/Rz64e69EatwwzxzYaab30d4K5Y=; b=VyLFTFxCXCL0mMYPmdbXA6gGI/7nES8mGmyuXMDcQlp6nUbFSca/JsewHMUFnLyZzSCEqxEUYqyi2mSIWKaDyyhQavMtLzQ4BtK433PtVy2nxYuNjGKjrXRAJzNL5vdKWCuZpHgCxFa1V0YD/CPzV78884w2vEwXiwl87e3V4CrepqxOpogP/VuazEnwFWMf6W9B2lEmJljJFibY/qQgn/mGAGluzNDn2Fz25AmtRZRtU4wUl9UGtWE58r5l+DKv/Frj9S4nIbfkrUd7R0fu4QoWaD1VgFZL75wWPp3NX2DvKGCYp/A+MNv+1C+wW2Fvjg9dAa5xKy17mNN/pbii3w== 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=B9CRiIOz405LWDfk/Rz64e69EatwwzxzYaab30d4K5Y=; b=cG4HtMqtBYnPS6RuIaLc5seqWSXLaEV0s/BYYMJYGpsz/n3mUSjbwQ/uID61aAHiHd+bVY99mPFppAASuy+wbio7V3AqLE269SCJ9YJdFZHv2g95iHCdLRj7/9a8U4Jdy84jBV/yYXmXpXmWhOvzCYgiGpxznWX4JnO2IuXGkz0BdoocZ5d407uQyJwd3b6kvVva77tyeOwbL6AzB4Yf4/ZQGO07fCEUZnqS1pMG0x3w8HpFaMNztOtt3DSbHuKwItczdooUvfpW7+cbzlaZpTP4uunaVptLPq2A8DusNsheCfMePVlItVTzc8B6J4f3Ng5uQiJ/QqhOrxKvkT43CA== 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 VI2PR04MB10859.eurprd04.prod.outlook.com (2603:10a6:800:278::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.19; Fri, 13 Sep 2024 15:29:50 +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.7962.017; Fri, 13 Sep 2024 15:29:50 +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 , linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 3/6] net: dsa: add more extack messages in dsa_user_add_cls_matchall_mirred() Date: Fri, 13 Sep 2024 18:29:12 +0300 Message-Id: <20240913152915.2981126-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913152915.2981126-1-vladimir.oltean@nxp.com> References: <20240913152915.2981126-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VI1PR0102CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:802::18) 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_|VI2PR04MB10859:EE_ X-MS-Office365-Filtering-Correlation-Id: aa7c9bb8-4923-4f84-7fe2-08dcd408e814 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Uj8yEzgW52k4NDe0OfDJhUiDMaNyKLtwaH7yo3ecYTgpSwEXHg+/NtbHD0Ll?= =?us-ascii?Q?dwgODxXGT3DwSITltdBa2aeZfSt/r/rnVC5LiB0QP7CNfNq3AnDh7N8wtZOo?= =?us-ascii?Q?v4ji3vCKvjZ5BCmVUTcGAHZWRL3r9EOK6pS8qJqlwwJ9yuhayX7yvO4yZ0g6?= =?us-ascii?Q?+YmqPlKM3DMIB2x6GfyiLg4umokuwkmZMmbSe2jPIFak4z51PpmEhb7i14rN?= =?us-ascii?Q?Q2LK7oR59znVDmyNdDIJPOsr8mvchzqXfjNaBQMskfGYoRDLferzUJHKO9Hz?= =?us-ascii?Q?GTaokM/CRUw+Qhn6dt/IM+LuoXJwpBy77q5FUD8lK1LQdk5ICv9xWjBSOvkC?= =?us-ascii?Q?dRKA2cUykLKy8bY9aSdSF4SpHJoM9Pes9QFmzGrMBVGGkw3iML6D+sLBmZnu?= =?us-ascii?Q?F+YZhOQbko2kOAQcame+ce0SLEwL9FI/L2ktfTr1VqSxOIYO2/+HIe02Dref?= =?us-ascii?Q?qjsQmJoFJn90UF+t6SUywREL5MBZR7qzM5ny2l2T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tYq0/bWYma+eOMPBB+VmGYJmPA=3D=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)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4XE2l3CwBTN2nG3X6k0wjKqwqbEpeRY5G+4F2i/R+muKBgLvyleKrb0i5Vf+?= =?us-ascii?Q?SZi5wAEL6VhFFhrkOa2zQEAUKvPTd/ZFZBxeNjuR0piHIFaUeQuuG8RQbU3s?= =?us-ascii?Q?5s9gUFZ4OK934To24uznK5l1ap/2kDltui/er5ir2EqZSKu9Fxh99J15l3iJ?= =?us-ascii?Q?PA2lDsbr4EzcsnKUuGFw5JNo8rgmyPX5kUPUr/YyCq2rhcX7ZuIoYNsWVpRB?= =?us-ascii?Q?9gBJlx3YL/CKUqqDy6IafjcXf7S8ji7MOcNiiQnJ6Rw4H/qhMBn11pG0bjXE?= =?us-ascii?Q?d19mg7ib02ukRBAShVaICUty9Rv/JnIn4UJ2bpmNEDYBxNUVVj1/uHSTMidO?= =?us-ascii?Q?yrTXh6qctrtZzLgDdbt+ML15ZjdVgZ811tzLI4SYy0JifHgvZniRFIkxI53O?= =?us-ascii?Q?UWKvDnVdOMpNez2cuO7GPR6w7smE89HnQx0NVvBaPC+/MOxCfO+erDcs5HFn?= =?us-ascii?Q?UrgpxIbUENlkFDz2P7QrqC7zncr65cxQV7Cz4/wo4CTJe2LsTeX2++05n2FY?= =?us-ascii?Q?Iuy4j9XpdfWPDcA3A9aC4kQ08u9AUYIIpFXjIHATd2iggOn3OMIzZ43zI9jW?= =?us-ascii?Q?5vZRMgQ41qjyQeRKD0vE5b6c6zKX38BZaD/uDRmRMqZyBjQCeN7zHzHqX0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yBCmY5hUqZFl/8/67l0sW+?= =?us-ascii?Q?wsu2+PREgqKaZdp0P9P0pM/lsbLwhJPUV//SDhhmUuJBBM1ob16SY4kQo7Ek?= =?us-ascii?Q?Og=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa7c9bb8-4923-4f84-7fe2-08dcd408e814 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 15:29:50.1466 (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: OI3MtosZivB20CNpSA1rjsQAzGMFrMvDemOX1FUc6rB3X3Jst4FkJ2ADoGvLJkMSq3GtnvtFD1E0DEXS3Ieqjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10859 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 --- 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 143e566e26b9..42ff3415c808 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, cls->common.extack)) @@ -1485,9 +1491,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: @@ -1495,6 +1505,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.34.1 From nobody Sat Nov 30 00:01:17 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013057.outbound.protection.outlook.com [52.101.67.57]) (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 CDE5874418; Fri, 13 Sep 2024 15:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241400; cv=fail; b=G9P15xNBTZGtY1ZCN/bZgNukEgeFKAiWCRTIm/uMsFc6kobWNKYZWVsOSIXKxJp50xcl2ewLj0YYQuBdZyz4RA3b3Mi2awMUEQAtwi+t9zPqLNxw26O5L914RA0y6FHKUrQ/tjg4GDx34+TKzkzdeuEWh2sDpBml6kLYOoVjQg8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241400; c=relaxed/simple; bh=KVWVyoBg2tKcQbKCBA2erSCDIOauYYuwn4e7KjUCoYc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ZV/qQOn9I5XdrovP47ZGKDGkgTnfnmKrDDVhaJksAQio8yKBOp0auyyvYtTAyK3UHRGyHDCx5sq1NiJZQ7h3f0Yf4xmqJf8qlfNdZhnis/NezheTIR3mCuwwu8mFuCkAcUROIs8mdQDlmgL3/TOLONyoFqCRtCOpjeDmf/qcQ14= 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=TLDd2ByM; arc=fail smtp.client-ip=52.101.67.57 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="TLDd2ByM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PL68MsaKh3VFvPuoHQATrCb7K12vdEClLyhPG8XWE1uDb0kv5zLZoi2ZQgUa0uj6Ld7e95bnFlQ8Bh8cfd/VOIJoSgn6+lxZHTAAvwVD6ODaBaKJSOATK6CAROo/kZK8/xOw0tYSWQSWIh39FWEc/47vghrLiqGof9T1sSrxoNias075mzbl8IPIZWDWx2ddz8Fa4lcge5jqw92HBuhOsqN1s2AdMA7L8/sEvFfNDKtUXOyD5b6SEtCeXwRq2CPmtBpJCY+ae5O3JREM9S3OQWxzMYrBZSjUHUA+MlKV/4XMJwhD4y/iUUpmBhkSz47KJ3RGppAwxNv+anIWPIC5HA== 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=Jiq7VkQ5r0Gt4T+SnucsAAt3eUWkpw/ZrSEdYpTcxsM=; b=QfzQfDJuM11ncuFXsmCrt4Eiu3+qMxTPpLc8qJp+DZRKDnqrLW82Zl5/mezb8+FVZPNkLu/4BfQ7pcruvI6FgFsNC6WmmwSkf8YrWriMzTgyO5R3soW4goO1WIeNxpxQTNYoNC5x7720olsmm7TA31+fFBYyJX/S9jggsG1Gk5HvvPCCZKi7AJV0666nc7ytJ6oDfuEoas55o7p4sMxCwLoStId75KmnTGan5RwzUQyB6bJawtC0Y4mVrUVBDngPZUs0qyoZBIMt7nesiIjFpxkZV3gR9CrpgEr/KL1+UQaMlAeCxgGhG7gRFRjqBlBsDSv9+XYMdNg8F+b2T4FExA== 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=Jiq7VkQ5r0Gt4T+SnucsAAt3eUWkpw/ZrSEdYpTcxsM=; b=TLDd2ByMsgUi8ZSq2UbX1S/aMAjZxXONfqxUi4NFRGFGMZabCOpRkeV/mzy1491yxSr7i0Pk+p3J9esIhOgkmyGdP6hOz+hHtNw2Wwft51XXtdycD/UEGw2RniUCaZr1HPAR0Nsd9dFAi1MdP/202WMhn9EgWw2ZvKhV5bIKnCcUaOAPWGPS3yKZnJp6O5I5nFbtzeAD+JBnK1mRkQKvyDU0xtdXifBd5lIXI9d0c8rBYxolIk/6hTFA+Snhgv52WUegXgdDoJoTgtKkU2F3itbhNK9B00e5u00hCwbC7g0amdvSZDRkXC+p1igmxA33grIlZhoAILj8wsYP462zSw== 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 VI2PR04MB10859.eurprd04.prod.outlook.com (2603:10a6:800:278::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.19; Fri, 13 Sep 2024 15:29:51 +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.7962.017; Fri, 13 Sep 2024 15:29:51 +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 , linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 4/6] net: dsa: refuse cross-chip mirroring operations Date: Fri, 13 Sep 2024 18:29:13 +0300 Message-Id: <20240913152915.2981126-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913152915.2981126-1-vladimir.oltean@nxp.com> References: <20240913152915.2981126-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VI1PR0102CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:802::18) 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_|VI2PR04MB10859:EE_ X-MS-Office365-Filtering-Correlation-Id: 2fe90960-c944-4bda-e316-08dcd408e8e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?+Qd6tFvOJkPaz/tcruIlWHZgFP9icAK8Hnqlp1pmBxiiEk0sWYKIBLXE2sf+?= =?us-ascii?Q?7CDKkjacoSKZ4MQblgDVQiNjNZD321UrEMZtAgIzsX7fkBmxY5cCrTFvoZ9u?= =?us-ascii?Q?ZeovDu0psMSoB6acgzNzvEDxyPU/FC70nt/dg2isKhkJop/RqQv43hM34sXY?= =?us-ascii?Q?1uOtJr/AkJ7S/QjwzAIQUvYFdGJnltuYOLBWoRAwbuPm5pQJu/c2POg1GX3I?= =?us-ascii?Q?1J4I2bNyjyEpzcQX9wkXcBniMvJ6C+khPDl44rblFTBilcunt+7SI72VdzrL?= =?us-ascii?Q?TRidDC9UHas8wVgzpkgXZERQM60bGcfhfra06UDzSwX+9GRr56/DJAlQnnmC?= =?us-ascii?Q?hfjvofC2zeW/uckAgH5792SKixypg9WNXFqBydGDNngaV6RdNGjnwNw9U7yf?= =?us-ascii?Q?MKIXQV4Z30GbWQ82rFtdlkn4YQU3kPoOPsuHwsZ+O16l9w5dT69TpdJEdF2G?= =?us-ascii?Q?Vqdcmnk5doTzcaxiWMZRgfP/Wb5XblhdhlFiQiKDhJvNYU294I9AQ8vQ+o6G?= =?us-ascii?Q?79sxqRvorOk0IKDkW6uhNNYhlJnuaiP9JznPEOOHAvOumBrkqrDWXHCQlrPV?= =?us-ascii?Q?HpdwfD7ZGZAJjsuObjPBveR4aqak68AmAd2qi1m7w4KQaoQzmqKQnTQ8cS0a?= =?us-ascii?Q?lSTNJTpu7rGfY2lIMyqeKKSFDzKhug+Nqq1XmVfvP8ymBnMp8NqWD9/+soCZ?= =?us-ascii?Q?3xGZvH89vWXZAOh2u8GgVkzR/IFFUdCFaCjCzVDaZOLNRLz8I/Q1ajlyb7Z0?= =?us-ascii?Q?h30/QizgGP0ymR8y6Ho2DvcSLbZ8HhkYM9TAPXOnxGDFtK3HgUC7ayEMYpYL?= =?us-ascii?Q?c1H3dBnamj14GKiONO79QokLfvEL/+Ac7vfmSaP4f7D11XaovGFz97Hc5gRI?= =?us-ascii?Q?fw9TY8yHIljqOvb6uOkUxeEOUxvu8uCAsFsx25qUdsY0N/7Em2RzRowQfkAV?= =?us-ascii?Q?TS/x1ecLB3ZC6qMOyDzHhMj1IR5M0LztmpU/kjygG9lemB7h7Uosp4RzF9kn?= =?us-ascii?Q?yBnXmRMXTpqyFByimka3WdJwr+fLWWsnGqZvxPnb5dagCaahqPBDvB/FrQC6?= =?us-ascii?Q?8FNquVEmrxr5l8kL/Vpuik8xlD4P2l0jqMg3vf5HV7ibOCiZtKzpARm/AKov?= =?us-ascii?Q?QL2njFYDoQCr4JiK0I3lFS2rNu7cpaCAqqCQPufJF7VKxGtUmQLAUrgCmV8S?= =?us-ascii?Q?mt2sDHacyvj1bDGb24lYcGdQ0DF3nV7RWFgeR3Bq+SHX6cJ656tIFF0wP8vJ?= =?us-ascii?Q?+1vwjBZTJ9KqdezTTSRMCooVSYv8/uoFIx04Arkh1yaZLmrbgahx7nCACW4p?= =?us-ascii?Q?Cm7xpRA2SS841AGReMTUtaqRBA0g1XZx2OJXCsBuavfnVt8a0WmwENj9C8Ky?= =?us-ascii?Q?WE8wkTkPU0ycs9Vo8GnHWOSFL1PPvS9WsRjsfJQlM435hIRMpg=3D=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)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?CrGoPsej3W8IphdXvmMBAtvnRhhJemz/jen2kkBVr0iD0BXUi2yoLo7EVd/U?= =?us-ascii?Q?R23m7zzJqoVH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7j0+e?= =?us-ascii?Q?FoZ5NzLthPv7xtqt1++IO0o/cq7cP2FbkYSvy8SmIMWx7qMr0QqYQqvNdILv?= =?us-ascii?Q?9JE0C8C7J27cAfx4YYcmz/TdGekEJcUdVlRp5ASw7GfrnybCetxAntQpEqCR?= =?us-ascii?Q?H/XRq/Pu0H2vmFcWIa1wLbuYyrxR7pSXgSamO6gW+G94/4LZQ5sPQD0GiL2j?= =?us-ascii?Q?nxN9MY0YbQwoQDGZPYoXjYwVYXc6wYxuHsN+IUpYxHF+Pc6zy20+9yIwf8/0?= =?us-ascii?Q?D2y4pAwzvlc8rlWstlHgiBa/35CclKILKEnIrMJnPAZw3ZufC9Wb+pwKgm5L?= =?us-ascii?Q?786ydLxJwynehpO/wM+Pqxd+eb/3FrNLltB+gL34Chh1AVhjXKAEOnTuxBJ6?= =?us-ascii?Q?yNr2CO/33e1eZ0z482n1vhRL9BkehLYjkYtgSAZSFebg3wckkT8D6zqgJt3a?= =?us-ascii?Q?N7017MLZH2j709WNRi832FFRzRCTPtig9FH14S7QTGf5ZX6vuERGJf9IABO6?= =?us-ascii?Q?omF6If16GcQRBFxAgD5NBmfWL1CofC6I3d27su+0xAX+DfV8krX7R9bLuTvM?= =?us-ascii?Q?cGGPDIqZBptubNcX7HQ+0hQXBepTzFyX83HbHRJYTki2XvnVVPBB8WpfrE0Q?= =?us-ascii?Q?aJGpVbSX52OyPf+I7GLaHaf9kFk99V+VNDR8zX8MnoSNVK2cRsOPr8HzLFO1?= =?us-ascii?Q?xA=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fe90960-c944-4bda-e316-08dcd408e8e4 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 15:29:51.7118 (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: EvRA0KN7WCsOG3LDM70EYJ12cYtTOhqgKg58AMVTxwfUxbqU20Qf2FtNN/r5X15V5AyoOCHX38KKRFLHzQlyqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10859 Content-Type: text/plain; charset="utf-8" These are not implemented but are not rejected either. Do so now. Signed-off-by: Vladimir Oltean --- net/dsa/user.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/dsa/user.c b/net/dsa/user.c index 42ff3415c808..c8ddbe22d647 100644 --- a/net/dsa/user.c +++ b/net/dsa/user.c @@ -1401,6 +1401,14 @@ dsa_user_add_cls_matchall_mirred(struct net_device *= dev, if (!dsa_user_dev_check(act->dev)) return -EOPNOTSUPP; =20 + to_dp =3D dsa_user_to_port(act->dev); + + if (dp->ds !=3D to_dp->ds) { + NL_SET_ERR_MSG_MOD(extack, + "Cross-chip mirroring not implemented"); + return -EOPNOTSUPP; + } + mall_tc_entry =3D kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL); if (!mall_tc_entry) return -ENOMEM; @@ -1408,9 +1416,6 @@ dsa_user_add_cls_matchall_mirred(struct net_device *d= ev, mall_tc_entry->cookie =3D cls->cookie; mall_tc_entry->type =3D DSA_PORT_MALL_MIRROR; mirror =3D &mall_tc_entry->mirror; - - to_dp =3D dsa_user_to_port(act->dev); - mirror->to_local_port =3D to_dp->index; mirror->ingress =3D ingress; =20 --=20 2.34.1 From nobody Sat Nov 30 00:01:17 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013057.outbound.protection.outlook.com [52.101.67.57]) (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 D544678274; Fri, 13 Sep 2024 15:30:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241402; cv=fail; b=VNoIAj+w6oO419wKZuld0MOGDppcYvZDKf9nWwrOtOtmmg9XGz+Js+62usHH8P5HSFtUeupeln6Vty90W4Q6G+mKsTwQkMajeuqP5NVvnINTi7/6WOHfEN1UFJGrT8QeaHZroQOiRpcT1ntTztK7IwWwsNydy443wnHzlLGG+cE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241402; c=relaxed/simple; bh=2Se3rDJhvDhtVigxdSwLsLYyZRn52VwmRM21FMzMJOI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Mzkfkw2wtfvgF6D9T44O/rxTHD0x9ZE9YBOePNqthX8PmHWe1m89kt//MdDlCPw0q3jXZNyUU7cQ0NvUHgSuPV5ofhaO5TXyvUUb6+wsbF3JA1AbtAbTqPVMl/W3GJNr3Nc0dWqhffAwQJfAN9cbTtwM/rrfBjVVf9uVbF8CI7Q= 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=Kmls93rO; arc=fail smtp.client-ip=52.101.67.57 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="Kmls93rO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F0tuXL+Zb7huInzHxpzH27Ch521isbm630LD4DyMiWzkuFqTuTp4cKzMZ4kRlIiNkMixBOA1YdIQSg77Iq96lWvoQlk7X9vGX67jFsJUT58gJTY9bqPzOWPTPEzMP0QQzyQ0PLMZoeX/q+/PHjy2iY2ZR3ZC80F7zriuXleRntWJbr8nl6L19hQCWss5etxfStor4NDyARIW4bC7ZcrugNFjEEBAJus/MToFO0I3YIb7oZrfWLrFeAf+osKwN28ESODJWK9S7F/TdPv2O4h1EwDFC0KvLRgQj8SBIiZhjs+GyHz51oKjaSSFrr4EF0b2kiMdrdpzWhcbAeV8h/q8gw== 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=DchtiU/jQuHINxUB9m8ahl7bth2S63ZrtTh0jYxO1D8=; b=RFz4PH+gh0jReZ5ZXzg6Y4HAIj8yIAoWh3VQs7wfnVM9tExFOlZfx2ivX2uyDq0wg8+fb/OyCtkcvgLU9/KR+A77GN9KuCBq60poc2+4s+oF5q3UcpUTNBz5FJ4sD/l2o56g+6PWbsm3ayJtuLJewtocvTCY+PWAA7zNCc7V3fmsD7TvFqhm+Kn7t5RmBm5thuonGJtnQqf7ELBlPoNR82kFAZH9wckXLaBb8/i1g3nq2vzqKgim0FOlUewAMaTK7TIls4bVxg0563+BNB24yR6YR3Ao0ETBjglTYQtbZxyE+0V36ivjR+XSsEPxTnaFMg7bFZTjI5ZRVXBBtdHM+g== 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=DchtiU/jQuHINxUB9m8ahl7bth2S63ZrtTh0jYxO1D8=; b=Kmls93rO/V5rA6iwSASbXY8GMtEpg9VIAZGcjA0wNam5hbCvOmZCgDa6GzBF9S+er4iySAc7PClsQtgzYFReelTdt+DVPizFV1Ur2CrBtPAiQpZcOfJmUX2goXHFHPZY1KIKZzyMSuj4fnFprOl8Nk5ao1HU4JpJw3zEos9Nh1XEhdgg8w7YZeO6YEqfg3wm2sfKqrcaom+HJg2G2JtdmONXSDdIoe6RrAQk7X1NBOrkbr1ihkLzNz+IG3aDcYY0cZXHpAWVjN35cdiTf4lqP2VlxPLY9mWZnpkY6Pp7Gu1LvLgQRGt/5/DqGT27nF9Ruxha9Elx0gsFkUpu0AfygQ== 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 VI2PR04MB10859.eurprd04.prod.outlook.com (2603:10a6:800:278::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.19; Fri, 13 Sep 2024 15:29:53 +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.7962.017; Fri, 13 Sep 2024 15:29:53 +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 , linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 5/6] net: dsa: allow matchall mirroring rules towards the CPU Date: Fri, 13 Sep 2024 18:29:14 +0300 Message-Id: <20240913152915.2981126-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913152915.2981126-1-vladimir.oltean@nxp.com> References: <20240913152915.2981126-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VI1PR0102CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:802::18) 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_|VI2PR04MB10859:EE_ X-MS-Office365-Filtering-Correlation-Id: 7deef44c-d956-46e5-deb0-08dcd408e9f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Vs7lg7YsTeyUa8sO7owIQp10CloYJ4SaGukZkXtUCRyFcZiwaT+VW1B93IMK?= =?us-ascii?Q?KrhJ8ZZOTKXxvvqp0lxevv9QKHh9ug+GaHiBRE45t/x/JTSm+2HCKKeMhXsk?= =?us-ascii?Q?TpmmJuZ4ZPcFXpbnbTRigx6ovDs3SIHeqj4p1tYMYTUdWgDG13i0+wZuciWt?= =?us-ascii?Q?C2cfeVeLyGbGz+IHUKtAnm7PoF6KLRKYBkR0O7cDqwnrtuAtBd5GQDyDVT5B?= =?us-ascii?Q?jzksPtpTdrtn85M1eF/AC/drL9t3iswAOkElgLnPIw9YvhrTkBlEXDoR+bgp?= =?us-ascii?Q?AAisEB1KAsS7/23YMbgsWcEVTYdnf/nl2l5VOIcq8S6yieMal5d2P1zwKptu?= =?us-ascii?Q?teukmy8+ZJpYTPNX1YZGr7lGj9BoWLZ7YAR9xDZpOcA1P3tzZNwjbe5Cmo4N?= =?us-ascii?Q?3qF1ZLI6OFuWT+6KZan7FuW/Qt3YQxj5d6ZWCoMf2upGQ627ACqgMIm4Nyvt?= =?us-ascii?Q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+nfPj4J?= =?us-ascii?Q?ordTc5z1GSm/IuEkyeMjPlP6He9IgAN0YARZ5YRbf0Z70f3yYA=3D=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)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?TgB1rIaTvbAg1KxdipKrkj6GiDpRs8C7nWAYes3qpQG43/SuEHCqfVHjroSo?= =?us-ascii?Q?UMObHNo6J+EY1G2JH1s3T8pyPHd2oZSn0FQLPR7jra7uDptEcne2kvh2w6hk?= =?us-ascii?Q?x9qmiFX4c4opJoiHnpct7Cc7J70JhrjauU0/plG1SsAgKAbXorY+OcqToVpt?= =?us-ascii?Q?YPgIoKuau+egxBV9mUPUwfKPOIEJZ5BmhWCtkt4BDotOHBCHoj2R9AUCVB8Q?= =?us-ascii?Q?SaCqg2QQyKyIt3zHwHdUBBjdvDN5hKmqmkQWXGV5VXOjzga/9u+uYgIdrqHH?= =?us-ascii?Q?Fhuy50rg+JDjeP1pkzeW4Vek41k9Jyo+foub3MbUqVKWanhgFj7fgMe/G7W6?= =?us-ascii?Q?X/8MaWDmPXzTF9lkscnPp8sczBB5vev4JZrFJUmg2LDwkp1S9rCbrxYw2KuN?= =?us-ascii?Q?TSho4sYskHh0xGVVhCljs926zvi9smRgzrhMFKXl5FWYV6RurbGrYpaDc6OY?= =?us-ascii?Q?0A/JIWMwZC5lEPXZpcDknG1C5tQOpSCCxKKwm2zpasAU0GjqJI5E7PuDvvJu?= =?us-ascii?Q?s3zKQbUdyedE2o0MN9ET6602epzBkEUeFM4PsMHZJdvfx1Ib/8oOfGSFi/2b?= =?us-ascii?Q?XAYYubQa5zOzmzwii21zVUiY6H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aaZBrDFA2oMeLmEFCC0ZLylC2y2kjwE/sZoEOEfbMQCyb5nhGvWaPIPCR?= =?us-ascii?Q?sngGQDdZJFBzSZDZ9hd1sfQX9UqIxQylVeMvy5z3Eb7GNdk4SNlaQQZd9r7v?= =?us-ascii?Q?GQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7deef44c-d956-46e5-deb0-08dcd408e9f1 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 15:29:53.5195 (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: rEGs//RPpBJrvTo6bo7Uw79bddCFJ+oyyX6fKb9e9VoutGGs74HDR10V77wdJgbkPS9L1llnAn9sQldRvwfdAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10859 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 representation wouldn't have even helped. 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. 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 Signed-off-by: Vladimir Oltean --- net/dsa/user.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/net/dsa/user.c b/net/dsa/user.c index c8ddbe22d647..bd3e3944931e 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); @@ -1398,10 +1398,25 @@ 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) { + NL_SET_ERR_MSG_MOD(extack, + "Cannot mirror to ingress of target port"); + return -EOPNOTSUPP; + } + 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, @@ -1506,7 +1521,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.34.1 From nobody Sat Nov 30 00:01:17 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013057.outbound.protection.outlook.com [52.101.67.57]) (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 260FA58ABC; Fri, 13 Sep 2024 15:30:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241405; cv=fail; b=ZqmJuh6wA8WjP+MR3SafzfT51ofzww3f88vrTkZh+tV5Na1+mTOUY6lvJ2ShEbnJIzQnAFOvqnA7pnSi/xHhIws8O4beOAKEUVprah74eWRtJ2Zwwgr6ncOn+OmhajVI+JLsSTIolNNtBn3QBu4TJT1TZzX7PQ0YSFGYzsC6m3I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726241405; c=relaxed/simple; bh=CFTQkXARLrbiWK5Fjt+9IWoCYC7i0aLvyV97d58THWg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=leBg/SuEuqdXPj/Zfl2sRpgVu2LvS5XpjcoG3M4hJg2yu4nxtayGZ0ZgGVKFMd55OF8ETHfNkxrOgpW+Syk0COu0ix/1pDe1bodowpf8nOtmk5boR3JVIjl+ijgPYuY7ieCaIv+8rTGBawXhuAFneka2hSKB1h9eGg1b+2SRjeo= 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=I53Qhe10; arc=fail smtp.client-ip=52.101.67.57 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="I53Qhe10" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XvS3f+pSXVYMy3nIyOlTAtjnf7HB7WjAq4Y+DzK03lrJUNPD423/iW4cCNTD3S64fLL9khyhygsEIagpck4DEhV+RHGH9BXMgeCHmx9F8/y2wU9WzIB5BiWafYggoFKNR1EqelABsU326M0//PeVz5G5hCSPMDd4NjS2f4isjQ/EZDhz7RhIYnqTrmaZa4bR0wExCa3vGQq2OfQc3/ji5a9H/DcePqKLBDNq+mdttSOr92Dg1W6LzMtlNhtAzqO0SBsXa7oNCtHAbLQI3F+gLxngAer0n1PzomtrxiNb8AiCm2jILHNllc6Hh7yrjOK5j2KUOHXBQ6QnkzSD+Ds0FQ== 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=vp3n0w8kiu08ys3ePnJtcAdFwmPlCL8Ag7hSZf169v0=; b=QL3NSWS+qwETmCy9pDG3oSstzElPKkihaqvQSXl68PsVxfw9o10rG8lmHfnPSRU8aYawOp1nM5nrkzjg1B0s0XpNnXgdNcl619CvrmLeY8PM8Bv76LlkzvP7dHi3gUyOQBK6h4jn6vx5WbC8XsqIWH7aqRIjJaafPmYJVfwHFkBgcSEv3CrZ2jk/rMlrKjpES4kwYS2e765xhUO0fE8DHOynl2BhwCUsaduqYp/XSovPhzKpnGX0HIGNurNxpx4V224cGXQEYUkstdxKwxf2R9U09QVfm5lfvoJgedjGbacvHzTqFMGeqOmvUzHJ0+DXSx3GqKshDhT88urSvwepLg== 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=vp3n0w8kiu08ys3ePnJtcAdFwmPlCL8Ag7hSZf169v0=; b=I53Qhe10swltE+KtkPW0aZ02H9z4SHm4xuCAePALm+KDkJWABjVQy7Zyu9Phzw1KlrWsYgQcgPSgME+g18TrGKsoukHXKuSqV0wJdN4pkIFw4QqRkCtmj0pG9tdQzGk5HUkkwxt/R9CXQ79cDDbX6eaIlkOMZZQqk8XbTbuJMrrHEF4+zLhbpFqRAiZveMuJVdgnjNJZrxHAHFHM1IICQfIIa0T874qnIQhlTfwZrXc4BmOHAcHSETkKeQb57JQoAlOWvO2XKnl8IUZTOuUE/zdvwlTZC8OmugwxIdJX/R0cL2oeS7SErMQ+5nTlYkzIeRPn4c2rtIhdWhkCKltZDA== 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 VI2PR04MB10859.eurprd04.prod.outlook.com (2603:10a6:800:278::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.19; Fri, 13 Sep 2024 15:29:54 +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.7962.017; Fri, 13 Sep 2024 15:29:54 +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 , linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 6/6] net: mscc: ocelot: allow tc-flower mirred action towards foreign interfaces Date: Fri, 13 Sep 2024 18:29:15 +0300 Message-Id: <20240913152915.2981126-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913152915.2981126-1-vladimir.oltean@nxp.com> References: <20240913152915.2981126-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VI1PR0102CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:802::18) 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_|VI2PR04MB10859:EE_ X-MS-Office365-Filtering-Correlation-Id: 1deb5022-b4e8-4512-bf17-08dcd408eaf2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WSW9zz8Mq6YRv8MJe6qC7IYzY4BDm1eFy/9PQbLaIlxy5GLnJiUno9RRbhXe?= =?us-ascii?Q?dAQQ7vBBzTWKNdA72j9rrAh3VIO5UMw/EtOtOXkBSWlpNjahQ6+77b9TH4za?= =?us-ascii?Q?plDe+y1eK2Z99yLPY1vBAg+Hge7UC5cDUR6Er9U7RlKCSOl1RVXoQ760XJQ/?= =?us-ascii?Q?HDSE61mla/Ce5m7k5lym3dtW7IN4K3SGKa+8Mwl1wqEidHWlFcQchNvIDUAo?= =?us-ascii?Q?JbnS9XwIjrecX1YX3/vtLwGrFNcJINrLxGRqN920aXEzY3DgeS4roS9CPvb5?= =?us-ascii?Q?TP6qogik2wJyDOhlm76B1++0UuSMA4p2Ra8cyeYs3dpMZtW39i9CvmkDV5dc?= =?us-ascii?Q?u68Q17Xg28H7ZbwQzhVzkvbX6ijI/i7/SFu8uUmpOx/RnopoUKbPIKvmrzLd?= =?us-ascii?Q?QnmKeSbzn4uLzOrLDr0sVtjZJt/UybZE8JS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tiz5qe9oluh8cRG7Afge1tnQaVpZAnBuE0DYHLqf2Q?= =?us-ascii?Q?EFNCur3wINEVVMkPebnTklcVfqSoo2joSPXkuT9OQ6v0yEcTxA=3D=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)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?kKCbjCgtUp3/5wDdCGQEXeNywbG+uTf/tR72vUhl0v6e2v3eCL2GXChX3xni?= =?us-ascii?Q?O2YM/BmcfuQRvJxx77gVYSh36Zg7dgmO4l3MXegMW7F/SSGtZfW87cDel9lA?= =?us-ascii?Q?GUlfQA477emXgjZX/TfOvgkR0Z+uziIAIKXrTDvcmNj78Vyz2vTDVqW9pIpg?= =?us-ascii?Q?oxwXwrQPwqif/fFgckV8nIfdDl01iDkQoD4qRrcO8mpyjkrgd5qjKd84FasP?= =?us-ascii?Q?joNRcN5TLBR3rIyQaZLUL1CHeYu7yFff5PN6PvJN66fRbvEX0Ut9zHpdSyP6?= =?us-ascii?Q?+VEN12rjlhqHsAqGIF/yoViMxAy1/bcRiYpV9afQNNOirFgPFDgldAQtKoJS?= =?us-ascii?Q?vfhMK2yaEAtc6aUfZxUweNML4uk43bez4oggTpg0rm1KbUwKdCfLdoN/muqA?= =?us-ascii?Q?vRD2/q5wdidUsHzNB9r2hb0CQGPrG2jHAXJPdhp3SsaU25cqYLwfAOhCtwpl?= =?us-ascii?Q?FLaE+e/jGKW/GvKWh6Xgd4pgq+dGV4RqRAB00dpZBS3NtmjvQTgPV1luCY0O?= =?us-ascii?Q?t4EPLzvX+7A5rGfPyn2HUN7hTYrGZLAoRkVH1Macc5o0GyE6Nx33lEk/ZBGC?=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NBUt3R0XACAJ5zqO1FoVVJWIbT6Q26ymvF0q0i?= =?us-ascii?Q?5FUB1eDyhWBc+emxDEubU8OX/NZgnTISUxYo+DwFdQenCZfXo1Ti6JbhG/3X?= =?us-ascii?Q?0iiGcETmF6inmLn0ExvGoZtizNJJDsu3AGcnFHUN33ufBseHJzxZQE2hJL6j?= =?us-ascii?Q?3g=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1deb5022-b4e8-4512-bf17-08dcd408eaf2 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 15:29:54.9020 (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: M29167tPjEEa2YeE0tuUnYotwCTJSEAQ9PHAhPm07NqhaqE4+oRaltQhIvUzUE2Kf/knN65ZYsLEF3+gWqZpVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10859 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 --- drivers/net/ethernet/mscc/ocelot_flower.c | 58 ++++++++++++++++++----- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethern= et/mscc/ocelot_flower.c index a057ec3dab97..d03a7e636290 100644 --- a/drivers/net/ethernet/mscc/ocelot_flower.c +++ b/drivers/net/ethernet/mscc/ocelot_flower.c @@ -228,6 +228,36 @@ 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) { + if (f->skip_sw) { + NL_SET_ERR_MSG_FMT_MOD(extack, + "Can only %s to CPU if filter also runs in software", + act_string); + return -EOPNOTSUPP; + } + egress_port =3D ocelot->num_phys_ports; + } else if (a->id !=3D offloadable_act_id) { + NL_SET_ERR_MSG_FMT_MOD(extack, + "Can %s only to egress of ocelot port", + act_string); + return -EOPNOTSUPP; + } + + 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 +386,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 +397,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 +420,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.34.1