From patchwork Fri Sep 13 15:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13803788 X-Patchwork-Delegate: kuba@kernel.org 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> 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: netdev@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: g4Ls7s574TlQGwdbWMWhdHhLOA8ODsItgHCxZ5KMkiqp2ZxeIqJ8pCwEPc0o4DePSaLUeREAmvoyjB1uyBvp/BCbmeI4oJ9b9BJuKC1NGg8jXvohEhj59107wcGbnt5fcZ34+2QPIJTcjO5hqB7A11ISi/YZl6wjzyJgMiok50joQNjR3Rs8/A1vDKGqXrKbc4xw2ALXj+vdGwbCqqwlFB0O764agB9vBYlW0K2YvbGWYXXVqj1YXIyM1rRuxJqn91ArtDgrBFpAiAyDJCIOWa6U95IKda9H/LYqf+pmRVfh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Qoli1DdmEMOm+sJ19fbPAY7YvRc4Wnb461nEwK+qtFf14Mw== 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: 4lk/0bc+L3fqXbOa1Wn+xEQnN69LTtHvVma8j2hU6M3sM0GRsWWnsyclqOcTYtneoJLQAcoGZpsR5TjrHx3LGBDUYg89RXDYwSfW1KyxSZjvGjMW8qZp5Z6/6sD17pI6j9LhYATqU0nkNNo7wQF7mMNB653eIWuNEkr+KT9cDDQHvI8ss2tahBmXBrGKmJpiA4MG/ZbUqlyZQMCtU1d9pqrE30NUI1uC249OlE8QiBGWsx6ySQQiUSRQlOtVb7Wi/a2MtjWOonOTIpQs8PxOyCHFqYROiPYR1N68jS3G6vsrPzpAyxrT9YL6R75O5Er14EF0MW3lS/duv03XWoSEdkqoM1vGzxP+MSCbrgLlwBylVlLi31aia1vYNjPky/2u9/nz1Wu+F820B5NkTfAAzWBcuhK9pDvuI+S6BuQdVIPFSVkyrlZx2M7RSdTGg8PHPNQVg9ZjHvT2bSn55+TfxtVGyie8f019k3rC1k+dxvZFCaxHdy268CN4pPOWOfTI7Fh7gIf2sox1ZdjJyxD04TDu7vFoalUTO11ahI9Q/5uO7DAZSdUQRWtoxlkSObXXRtZ8i2KrywpP+IzPkL9I9Qcn45pkKYO1FiKAG8nnCoEfs19RPzsjtbZJ5uekv2x+AvWSRbdiaSaWZuHtUaEdcgzQBhdu2WdHrXyD03xDZmiUqgPjy82kQ/CudSQIU7LKC2aVen4xQ3lcpFQx7CxBiXqM1ttNZWLtddX3+ZSC3Wqo6tSrxUSzkVW8S1cJvV53JvaOEe3L3pYzys4KlAeZizsBi4eiRXQB/3J9HJDxsIGGYxA2MUwDeZet8hFUae48Ic8IKfyoEywU0R+RyRBycbvSsF03v6N3YnjLMH2BQq1fGchSUHaeDLRQxpciTBVDFCn8ajaICHOau1GqmIb53GIDZtmC4cgkt7tL2VX4/GACb6U5UDDpXjHdZbQSdcJad72AHotFXJSYU+DPSDnRE8f8OY1e1QL5UfVRrGDQaZ2lo4deA79TND1lzxW3412DpoG1+Z/gyWze47TtiE6HZiL2qDv1H6THUbpmci7BC5z9Y1A6YCy/pHRUTt96rjw0Ekb6AURTky+WvEHLJ1gzSze7AwEVVCSOJhAVzDnWagYo25jW2ahjEv13GSTn7u7gxxiXf+AknAr4yYNJyZoYgyTiww05WAemTIU2Oq0gPXP9OGgPxeZ8pFF2bLg4wOXDmZ8HUaUEnLsGSnNIFyPl4bU0D4CY81LRg+rAuq0bZAmg1Zxh1dW6gQP/L/6AfbTKD1FKVGhGqLnRjajTeE5JZ9jmMAvPEhK1PIlAzhBPi2xxRx/ff6/ssP6EhD5+61UyNfd7ND6j5kjx+6sXtmnK/uDmADUBoHNdGRsLTPiW8tWl4HblNAc5pWkojelgcZUatcdKUnqeIeOafHDOt+W1Pr8mlOM/S775uRTdDgdBR5RwvJH1VhGOt5V3YeadnZzT2fQnEPPauexyvZLg6Y9g61eUiv6vDoOrrb/qkDFHYHJJJJUd/sRZpPRHolbBfSX7WH358D4B1Aed0x54x8ZUX+FFWCnJXsJpegg6h8k9sYqbEr8mbmTjvs2mfJB1jLWdlGSdHVK6QNZ5/sdWPawD3w== 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 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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; }; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index e280c27cb9f9..8f7c60805f85 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -480,6 +480,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, cls_flower.rule->match.mask = &f->mask->key; cls_flower.rule->match.key = &f->mkey; cls_flower.classid = f->res.classid; + cls_flower.skip_sw = skip_sw; err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts, cls_flower.common.extack); diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 9f1e62ca508d..9bd598f8a46c 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -98,6 +98,7 @@ static int mall_replace_hw_filter(struct tcf_proto *tp, tc_cls_common_offload_init(&cls_mall.common, tp, head->flags, extack); cls_mall.command = TC_CLSMATCHALL_REPLACE; cls_mall.cookie = cookie; + cls_mall.skip_sw = skip_sw; err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts, cls_mall.common.extack); From patchwork Fri Sep 13 15:29:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13803789 X-Patchwork-Delegate: kuba@kernel.org 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> 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: netdev@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: t0cf6njNFtZnrAS+4VIy7DOoEDbhlW0y7bH1bWgrviiycKdmJCcIxB7IG94QZ6AaRgudgr6u/70BWK5hkICBK9pDMxlutCVTS4x0eSpez73LPTIYJlPX1WwizJl84eBcr0zVNZ1OY16DCVzxwNFj8k/6IHXGkfDn44dcRjUzhRe5iHO1KNV5hJ6tIW/rUxSrUSbFDSANrBuVwGEMwXln1vk0B5MlX7H9hV7Uhg6nykQI7GeHC5+l0/u4vVqiRA9CCXVHqnKupGR1RtsBCGNujXbtUNsiPAzGuWSygWZWbRmxPSxi1RS20ulf2h5K4RH1gMzamlBaHdOKvLKxPmFXMnmWdY3wv+MZ1/sLO4NRAVEe2eTDIvqalkrLnt16pSfuPrrC4VhGXogWutWK5u+HqIVmmY2kGtAUEQn5552kf3QIzoYLosl/82t59AhfV1HOW0IQ18iL+LhoMyM6YVyLxoko8yzu0EP6QSKdUas90hP09QSvHb9TAMF2UPSBbVQgzlFTh9+9oSXk4upUJgqQOSSbE+XgJcQHYryvXeXqzX9lUkduM+UN86ACqDaAh6a145ntPUubbxZhLoapdPYpUswQPtL1rkrhEbKPYcmFogdnaPAFl1hhf+c8H4o/WtUGedEpDIhBWxoaaWj0dmss/VTOyf8Lj7xrW+Ogxiv19T0UdoDkXzlIGrBtSTHk8iQfi1qOoivLXmpMwnAitQEd/WaFU1YInSy3bh339ZJTfv4moIuVSvLN82wKWF4T7RVuuvJ5zaXeaTGZ4glfIbo7gWjRCMEbd/ih2tkIIU+3VbYs/t3WoddF/D7JzvtjQ7mo34w3rrLE8K0VxI03zLH48I3iUP8MwAXaKpSwLwwHnaqsY96DzfJe8tPfArn+IGGKaVQTu0beaM7umL8NO1AjzQKbqvBUNSG3WXc4xUvcc2OQVxbcstzGEqVRVIQXbIEhfx9AF2ttRsEPO3b2rM1GgjZyWlS0N/I5fKsHwTc2J/XyozpEryi2D1fSoQebQQmgd87lEDaXJef5/OfLwokJxI85pH1CbruKRTfupNeBil3LdvgeY+8NUe8fcEFIluRnD9Ok8LPjKfxtfXcd5TJQp0ktPZGnRIEj9NoZHF+SZABX5fhCGxs+Qkq85rS3RwEaRVCPoq9dTpSbGuaDj45OkpsAjDzc7A2uUYNoyWojVvx9oKLm/xXgkVeBD1c/I8ZN82Ck7Nqk0bLA6FouM6pp96he2RNTZHiwbwy05SBckCL7BcJhXh+x90FNwf/iBYTXqkVrIQjVf7QLlyvCpj6Vhshevd1SrG/iXpK4avudo2Nf+YJDdfpPX3BjIIvTXKzaRuoOHtxEZUYpUGSrayMDRF24zTLinkxBmaedaEIA5wzhKal9kNzw43cM1rgfD+jAWEjlaolqjq26VsdrwUYBfQ== 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: sMPUar5DiNgS+g/majGw32xnj6K9OlKfyfcfF4SSnuLl5Iabe0PB+dd4d4U/Oq2G2ecup7q7aCr/ZaYBNBL4Sq4yrHlRWioNcrl8ftWQfg1Q6F4OEb5jNMLlT6IZ/EYd4GgAmY0DpzjURm4gqK44GOVR0dD4YyJWpjxc+m5pan7wrMiMKlNN1jppNf9K10rOwsRRWBpQj7AwiLioWFPtJiMSdHW/KjIS1gTeaKJWpr153Saj0jN1PBNPC+lsAN+2nFEDNYZ44qmpzhVVc20SX7AOqleyTTJC3DTvAqKokeDsH7LcUymGBn4NQA7FJSB+oTAKuKOX4QFmYmI8rvPv/oDiWKDq5RV3rp0AzLFpdzntdiG6x5xj3z7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iq1UyDPnahsvPcZDjz8FQyU4slmrIDwtJnCKq/+Fdym/Rh1vWhRiKptJJrMaDZnx2Lhi93arlEMH87yL+G9HZSCzXc85YYwqExAFKXFJgy9rSwxD/F8E5ZtTZ2s7os+Ie5JGkCTFrARuKNJPdBQrYV556KObH91C2+z/SGtTg3xao19w== 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 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 *dev, struct dsa_port *to_dp; int err; + if (cls->common.protocol != htons(ETH_P_ALL)) + return -EOPNOTSUPP; + if (!ds->ops->port_mirror_add) return -EOPNOTSUPP; @@ -1481,17 +1484,21 @@ static int dsa_user_add_cls_matchall(struct net_device *dev, struct tc_cls_matchall_offload *cls, bool ingress) { - int err = -EOPNOTSUPP; + const struct flow_action *action = &cls->rule->action; - if (cls->common.protocol == htons(ETH_P_ALL) && - flow_offload_has_one_action(&cls->rule->action) && - cls->rule->action.entries[0].id == FLOW_ACTION_MIRRED) - err = dsa_user_add_cls_matchall_mirred(dev, cls, ingress); - else if (flow_offload_has_one_action(&cls->rule->action) && - cls->rule->action.entries[0].id == FLOW_ACTION_POLICE) - err = dsa_user_add_cls_matchall_police(dev, cls, ingress); + if (!flow_offload_has_one_action(action)) + return -EOPNOTSUPP; - return err; + switch (action->entries[0].id) { + case FLOW_ACTION_MIRRED: + return dsa_user_add_cls_matchall_mirred(dev, cls, ingress); + case FLOW_ACTION_POLICE: + return dsa_user_add_cls_matchall_police(dev, cls, ingress); + default: + break; + } + + return -EOPNOTSUPP; } static void dsa_user_del_cls_matchall(struct net_device *dev, From patchwork Fri Sep 13 15:29:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13803790 X-Patchwork-Delegate: kuba@kernel.org 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> 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: netdev@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: Uj8yEzgW52k4NDe0OfDJhUiDMaNyKLtwaH7yo3ecYTgpSwEXHg+/NtbHD0LldwgODxXGT3DwSITltdBa2aeZfSt/r/rnVC5LiB0QP7CNfNq3AnDh7N8wtZOov4ji3vCKvjZ5BCmVUTcGAHZWRL3r9EOK6pS8qJqlwwJ9yuhayX7yvO4yZ0g6+YmqPlKM3DMIB2x6GfyiLg4umokuwkmZMmbSe2jPIFak4z51PpmEhb7i14rNQ2LK7oR59znVDmyNdDIJPOsr8mvchzqXfjNaBQMskfGYoRDLferzUJHKO9HzGTaokM/CRUw+Qhn6dt/IM+LuoXJwpBy77q5FUD8lK1LQdk5ICv9xWjBSOvkCdRKA2cUykLKy8bY9aSdSF4SpHJoM9Pes9QFmzGrMBVGGkw3iML6D+sLBmZnuF+YZhOQbko2kOAQcame+ce0SLEwL9FI/L2ktfTr1VqSxOIYO2/+HIe02DrefqjsQmJoFJn90UF+t6SUywREL5MBZR7qzM5ny2l2TuTyzb28ap6agka4Zxp9ZWaNCOr5yjugaSuKuH+lj9OE+UdmazcQzDLXwpTJQRmcT8lKlAZoJlp8wY4L0qabJS3+97y0CEQlZjr22s87aQqNcQ8ebKtQXzrft4QRAUL060gQYYnlzYNZaIWBOw796pFSpT5Es0qg0VXsUDryFs5u5/vVlWbKSgvWViJ3h7snDbmhFmm0tjZ7+jrr8YLY4lAFPKRZ5x9DVC0lptIziRRrPYS/G3SMD3EV54uOcRE7nUDjcgXpBIQ4NGNIbD+y3Az/YbSS72Ohbtep5ryTKm9bJb0CAc+CFGX0go9SRqpmzL83lIrUqKRf55XlKXO20AlVufo+BWlYsgqM47jUs37o+/Bb5gu/y3CKpyaTECzVvRVAihX7oTkVPaigJhOfXp7Ca2uoQrxNV80bFipuhU+FsuWXyGW9Wbj6qXlP7hA175LIs+/RmchNzBDFJSKn4TgKczSf6OfYbAaHA5simKHULeYaQDcTQUlwFhKC0RyLsERnySfld7AFZgocnF5b+zjHP6IsdswMyqqVOtma2SPRvgECf3oYhYCFKEoKhYG2kndKk4uWuRjVCxLErN3GNlW8RwjZu2QR7W18FgIjFchq9eic/asHauhfUYOVfcAnLWZvs1xAZZoqJ421w+VMVlz6ecR/G8EXYaUCsFQMsu/JK0vTewT2+ywBBXQ+kqtlWBDyezqMjun+tEAX2TBfNW4wwgUhIWeAvXXQtkGK9ihbHE33NgvmWsOnnbmloXh8JYSjH5WiCypZKySvKgaGQuUu2zDmMQMuaeuphZq+ucZdSg+eCF791CLEJLqenfs0nXD8EW/tuk8Lo/Ry1jOGAvdwo7b30gB/F84tDWBNvnsrMzmCOPLVXtYq0/bWYma+eOMPBB+VmGYJmPA== 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: 4XE2l3CwBTN2nG3X6k0wjKqwqbEpeRY5G+4F2i/R+muKBgLvyleKrb0i5Vf+SZi5wAEL6VhFFhrkOa2zQEAUKvPTd/ZFZBxeNjuR0piHIFaUeQuuG8RQbU3s5s9gUFZ4OK934To24uznK5l1ap/2kDltui/er5ir2EqZSKu9Fxh99J15l3iJPA2lDsbr4EzcsnKUuGFw5JNo8rgmyPX5kUPUr/YyCq2rhcX7ZuIoYNsWVpRB9gBJlx3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kDrodC+WFluBnRSWdKuKeH6TpwI4PCfD20hhnfSWWuaiCMGuAfrzceQgg1NlEqQnMlYVNjTGV8b5pzOqMs6XbHK+FxbcQmm3o5HKSYpccXpIPmCLe1vMu4NHqbdkQWj44eHXrtqplqeSgp0pmN3EGkORsWDgplxw4e8ACoCmTEPw9hEk5r8jjK83GSHAkta5Fp1ggvWbofbTfYfyBCmY5hUqZFl/8/67l0sW+wsu2+PREgqKaZdp0P9P0pM/lsbLwhJPUV//SDhhmUuJBBM1ob16SY4kQo7EkOg== 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 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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; - if (cls->common.protocol != htons(ETH_P_ALL)) + if (cls->common.protocol != htons(ETH_P_ALL)) { + NL_SET_ERR_MSG_MOD(extack, + "Can only offload \"protocol all\" matchall filter"); return -EOPNOTSUPP; + } - if (!ds->ops->port_mirror_add) + if (!ds->ops->port_mirror_add) { + NL_SET_ERR_MSG_MOD(extack, + "Switch does not support mirroring operation"); return -EOPNOTSUPP; + } if (!flow_action_basic_hw_stats_check(&cls->rule->action, cls->common.extack)) @@ -1485,9 +1491,13 @@ static int dsa_user_add_cls_matchall(struct net_device *dev, bool ingress) { const struct flow_action *action = &cls->rule->action; + struct netlink_ext_ack *extack = cls->common.extack; - if (!flow_offload_has_one_action(action)) + if (!flow_offload_has_one_action(action)) { + NL_SET_ERR_MSG_MOD(extack, + "Cannot offload matchall filter with more than one action"); return -EOPNOTSUPP; + } switch (action->entries[0].id) { case FLOW_ACTION_MIRRED: @@ -1495,6 +1505,7 @@ static int dsa_user_add_cls_matchall(struct net_device *dev, case FLOW_ACTION_POLICE: return dsa_user_add_cls_matchall_police(dev, cls, ingress); default: + NL_SET_ERR_MSG_MOD(extack, "Unknown action"); break; } From patchwork Fri Sep 13 15:29:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13803791 X-Patchwork-Delegate: kuba@kernel.org 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> 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: netdev@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: +Qd6tFvOJkPaz/tcruIlWHZgFP9icAK8Hnqlp1pmBxiiEk0sWYKIBLXE2sf+7CDKkjacoSKZ4MQblgDVQiNjNZD321UrEMZtAgIzsX7fkBmxY5cCrTFvoZ9uZeovDu0psMSoB6acgzNzvEDxyPU/FC70nt/dg2isKhkJop/RqQv43hM34sXY1uOtJr/AkJ7S/QjwzAIQUvYFdGJnltuYOLBWoRAwbuPm5pQJu/c2POg1GX3I1J4I2bNyjyEpzcQX9wkXcBniMvJ6C+khPDl44rblFTBilcunt+7SI72VdzrLTRidDC9UHas8wVgzpkgXZERQM60bGcfhfra06UDzSwX+9GRr56/DJAlQnnmChfjvofC2zeW/uckAgH5792SKixypg9WNXFqBydGDNngaV6RdNGjnwNw9U7yfMKIXQV4Z30GbWQ82rFtdlkn4YQU3kPoOPsuHwsZ+O16l9w5dT69TpdJEdF2GVqdcmnk5doTzcaxiWMZRgfP/Wb5XblhdhlFiQiKDhJvNYU294I9AQ8vQ+o6G79sxqRvorOk0IKDkW6uhNNYhlJnuaiP9JznPEOOHAvOumBrkqrDWXHCQlrPVHpdwfD7ZGZAJjsuObjPBveR4aqak68AmAd2qi1m7w4KQaoQzmqKQnTQ8cS0alSTNJTpu7rGfY2lIMyqeKKSFDzKhug+Nqq1XmVfvP8ymBnMp8NqWD9/+soCZ3xGZvH89vWXZAOh2u8GgVkzR/IFFUdCFaCjCzVDaZOLNRLz8I/Q1ajlyb7Z0h30/QizgGP0ymR8y6Ho2DvcSLbZ8HhkYM9TAPXOnxGDFtK3HgUC7ayEMYpYLc1H3dBnamj14GKiONO79QokLfvEL/+Ac7vfmSaP4f7D11XaovGFz97Hc5gRIfw9TY8yHIljqOvb6uOkUxeEOUxvu8uCAsFsx25qUdsY0N/7Em2RzRowQfkAVTS/x1ecLB3ZC6qMOyDzHhMj1IR5M0LztmpU/kjygG9lemB7h7Uosp4RzF9knyBnXmRMXTpqyFByimka3WdJwr+fLWWsnGqZvxPnb5dagCaahqPBDvB/FrQC68FNquVEmrxr5l8kL/Vpuik8xlD4P2l0jqMg3vf5HV7ibOCiZtKzpARm/AKovQL2njFYDoQCr4JiK0I3lFS2rNu7cpaCAqqCQPufJF7VKxGtUmQLAUrgCmV8Smt2sDHacyvj1bDGb24lYcGdQ0DF3nV7RWFgeR3Bq+SHX6cJ656tIFF0wP8vJ+1vwjBZTJ9KqdezTTSRMCooVSYv8/uoFIx04Arkh1yaZLmrbgahx7nCACW4pCm7xpRA2SS841AGReMTUtaqRBA0g1XZx2OJXCsBuavfnVt8a0WmwENj9C8KyWE8wkTkPU0ycs9Vo8GnHWOSFL1PPvS9WsRjsfJQlM435hIRMpg== 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: CrGoPsej3W8IphdXvmMBAtvnRhhJemz/jen2kkBVr0iD0BXUi2yoLo7EVd/UR23m7zzJqoVHA3y5KlLNgzIoaEUzY1sIzoD1QTE1/3FBa+hQGS59NewlnjIeC0RLuUjPQj+DswZi1rpgGjDTsqVcUUwozfGs8XpYLhcv1pA5qnRbC2q0nvqGUNUbclBlBzcDGaoO4+3r+qOw+s1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d+eb/3FrNLltB+gL34Chh1AVhjXKAEOnTuxBJ6yNr2CO/33e1eZ0z482n1vhRL9BkehLYjkYtgSAZSFebg3wckkT8D6zqgJt3aN7017MLZH2j709WNRi832FFRzRCTPtig9FH14S7QTGf5ZX6vuERGJf9IABO6omF6If16GcQRBFxAgD5NBmfWL1CofC6I3d27su+0xAX+DfV8krX7R9bLuTvMcGGPDIqZBptubNcX7HQ+0hQXBepTzFyX83HbHRJYTki2XvnVVPBB8WpfrE0QaJGpVbSX52OyPf+I7GLaHaf9kFk99V+VNDR8zX8MnoSNVK2cRsOPr8HzLFO1xA== 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 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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; + to_dp = dsa_user_to_port(act->dev); + + if (dp->ds != to_dp->ds) { + NL_SET_ERR_MSG_MOD(extack, + "Cross-chip mirroring not implemented"); + return -EOPNOTSUPP; + } + mall_tc_entry = 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 *dev, mall_tc_entry->cookie = cls->cookie; mall_tc_entry->type = DSA_PORT_MALL_MIRROR; mirror = &mall_tc_entry->mirror; - - to_dp = dsa_user_to_port(act->dev); - mirror->to_local_port = to_dp->index; mirror->ingress = ingress; From patchwork Fri Sep 13 15:29:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13803792 X-Patchwork-Delegate: kuba@kernel.org 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> 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: netdev@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|1800799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vk6IKGVlIPbOoapWAvxWneNtOrhIuZxugm7I+eNd3uZ1KCPRtQpvT5IU6qhRJbvc1yevdbrurLenR7Cn3PH168dnZjNbIzhY6R1POg7Cg6dfuKXT0lWYZNSr0QPUAswqYEtaBXi+1m95Obgv1fCSs40iClRFwUAEeTIpexG5NqSkyMpwCAchXvGLINYlMRTF6FSjWCnMGv69WlBwrzoSiDg5o7vFXvsIOhKamVfOwlKYwV+UHnuYw32+27fasALolO6smFyE4bfSXiuu6BDq4fkRFwHFkq27Dp+zlpFNBR+dPxrsRniaS2XG4LGfLuFfsXkhQgAbqTTvd80+nfPj4JordTc5z1GSm/IuEkyeMjPlP6He9IgAN0YARZ5YRbf0Z70f3yYA== 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: TgB1rIaTvbAg1KxdipKrkj6GiDpRs8C7nWAYes3qpQG43/SuEHCqfVHjroSoUMObHNo6J+EY1G2JH1s3T8pyPHd2oZSn0FQLPR7jra7uDptEcne2kvh2w6hkx9qmiFX4c4opJoiHnpct7Cc7J70JhrjauU0/plG1SsAgKAbXorY+OcqToVptYPgIoKuau+egxBV9mUPUwfKPOIEJZ5BmhWCtkt4BDotOHBCHoj2R9AUCVB8QSaCqg2QQyKyIt3zHwHdUBBjdvDN5hKmqmkQWXGV5VXOjzga/9u+uYgIdrqHHFhuy50rg+JDjeP1pkzeW4Vek41k9Jyo+foub3MbUqVKWanhgFj7fgMe/G7W6X/8MaWDmPXzTF9lkscnPp8sczBB5vev4JZrFJUmg2LDwkp1S9rCbrxYw2KuNTSho4sYskHh0xGVVhCljs926zvi9smRgzrhMFKXl5FWYV6RurbG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IPCRsngGQDdZJFBzSZDZ9hd1sfQX9UqIxQylVeMvy5z3Eb7GNdk4SNlaQQZd9r7vGQ== 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 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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, unsigned long cookie) static int dsa_user_add_cls_matchall_mirred(struct net_device *dev, struct tc_cls_matchall_offload *cls, - bool ingress) + bool ingress, bool ingress_target) { struct netlink_ext_ack *extack = cls->common.extack; struct dsa_port *dp = dsa_user_to_port(dev); @@ -1398,10 +1398,25 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev, if (!act->dev) return -EINVAL; - if (!dsa_user_dev_check(act->dev)) - return -EOPNOTSUPP; - - to_dp = dsa_user_to_port(act->dev); + if (dsa_user_dev_check(act->dev)) { + if (ingress_target) { + NL_SET_ERR_MSG_MOD(extack, + "Cannot mirror to ingress of target port"); + return -EOPNOTSUPP; + } + to_dp = dsa_user_to_port(act->dev); + } else { + /* Handle mirroring to foreign target ports as a mirror towards + * the CPU. The software tc rule will take the packets from + * there. + */ + if (cls->skip_sw) { + NL_SET_ERR_MSG_MOD(extack, + "Can only mirred to CPU if filter also runs in software"); + return -EOPNOTSUPP; + } + to_dp = dp->cpu_dp; + } if (dp->ds != to_dp->ds) { NL_SET_ERR_MSG_MOD(extack, @@ -1506,7 +1521,11 @@ static int dsa_user_add_cls_matchall(struct net_device *dev, switch (action->entries[0].id) { case FLOW_ACTION_MIRRED: - return dsa_user_add_cls_matchall_mirred(dev, cls, ingress); + return dsa_user_add_cls_matchall_mirred(dev, cls, ingress, + false); + case FLOW_ACTION_MIRRED_INGRESS: + return dsa_user_add_cls_matchall_mirred(dev, cls, ingress, + true); case FLOW_ACTION_POLICE: return dsa_user_add_cls_matchall_police(dev, cls, ingress); default: From patchwork Fri Sep 13 15:29:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13803793 X-Patchwork-Delegate: kuba@kernel.org 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> 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: netdev@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: WSW9zz8Mq6YRv8MJe6qC7IYzY4BDm1eFy/9PQbLaIlxy5GLnJiUno9RRbhXedAQQ7vBBzTWKNdA72j9rrAh3VIO5UMw/EtOtOXkBSWlpNjahQ6+77b9TH4zaplDe+y1eK2Z99yLPY1vBAg+Hge7UC5cDUR6Er9U7RlKCSOl1RVXoQ760XJQ/HDSE61mla/Ce5m7k5lym3dtW7IN4K3SGKa+8Mwl1wqEidHWlFcQchNvIDUAoJbnS9XwIjrecX1YX3/vtLwGrFNcJINrLxGRqN920aXEzY3DgeS4roS9CPvb5TP6qogik2wJyDOhlm76B1++0UuSMA4p2Ra8cyeYs3dpMZtW39i9CvmkDV5dcu68Q17Xg28H7ZbwQzhVzkvbX6ijI/i7/SFu8uUmpOx/RnopoUKbPIKvmrzLdQnmKeSbzn4uLzOrLDr0sVtjZJt/UybZE8JSHzQ6Jx1efjYo51BKzX+UM2QAOKkiAzkUIVHT/S82qE4CAODDOk0CbhVunQsqTMtieYM66g21H0vw7c7h8md5ET9Lgf+7AhxFrVoHpNNzNSF625gdTd1vEuBVequ/DU+t4cMMZKRP5uGJAys/oxR9gFPnotBrCn/nFxv+qGyBh6qPM/4lCDfL0DkFBP/FV76firpjqwWSm4tmMqRblg1XUNlbWqNGOmuWzi3wBBZ8NvhERtpHp/oqIguelZxYDPcLmqyzs9dQjQGQ3fa3LoWF3pKsGe6To9yHqX2kqyjuQ6CDXig+nDDn8S099fAlPuDij9P4CyFZ1X3QptwLT65GmJYE6T4lczr/RUVfgDzipTok9u41zlMcQi3NPzO0fvhT/IwSFWLR3bRjaYWLr2EAda6WB8ap2aDhTJKYEGyk3q48ut1uocMNAwXLEXkTE6H7C8fMF21EIfU5oKywlZxurYt1AEYEAP4HuXABkDzJ9DLySsonNLFtRwxXqra+r1Bt9ttlHjHme3nc5lm7Wwt6aGW1J/w/nWsXCuSu00iolWexbCdMQLtAcFdWXIaHwMxEPM5fUrt1LGfmDDBnMA30NJ+i+OpBeoDaUamVyIos2CoO1i98rAINqsJZoT3BtLbvnVZ7KG5PTbWlzqPgWDftdSHLombESDdncafU4Pg6aXFrkBS3iB4nINI5RfJF08op8coWnmm0rVEeG04cZfRRBgm+PsmppLmbJkfJZYtzIL0fhm+sRGcPWrjuDP3Q78ThwvveDNlr8dLdayeL8NdkwZSdYnyYVKJcg40iDWRDzt9UtSMbrvslGPRpBVtdb4CeQ9Nntu8sktzqb2XcCfwEMHwgmvOzU8LYqKRF2RRvChUlBb8iiGGtiz5qe9oluh8cRG7Afge1tnQaVpZAnBuE0DYHLqf2QEFNCur3wINEVVMkPebnTklcVfqSoo2joSPXkuT9OQ6v0yEcTxA== 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: kKCbjCgtUp3/5wDd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VJeV7b6xy4TyBBnemcx5HAXGcKz/YYC1ub8vMDWvcdpG2+QacJXssnWC4DUCNu7ZVEHtSxsJ/j4ZhmO1z5USkbKZMgaQkJFS3HLwrbHBRFHFP/VeivVmIuKgerIjrqASP+kQ9FfG+H9+ncumwypZvqeERSk5LuMpp9Af++2TqzLIoH9awru5XbuDG5SuLCZg1pTTJGufY7hkYiUGQiiBy4aqOYAkEehb44pbYMRdwLCF8Cm+hAUtL7YmG9SuTVUFAir4zr/FFVpgVKNVTXqVjew+88N65/+JmBBfnmCVN4vpujdU9jWTeVmInx3ROOzqPiapSAoBV/+0+5GeLJ9qKKZaSVEjCKumrlMHy4QMbbFCtQB9YA0/A8d73NBUt3R0XACAJ5zqO1FoVVJWIbT6Q26ymvF0q0i5FUB1eDyhWBc+emxDEubU8OX/NZgnTISUxYo+DwFdQenCZfXo1Ti6JbhG/3X0iiGcETmF6inmLn0ExvGoZtizNJJDsu3AGcnFHUN33ufBseHJzxZQE2hJL6j3g== 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 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Debugging certain flows in the offloaded switch data path can be done by installing two tc-mirred filters for mirroring: one in the hardware data path, which copies the frames to the CPU, and one which takes the frame from there and mirrors it to a virtual interface like a dummy device, where it can be seen with tcpdump. The effect of having 2 filters run on the same packet can be obtained by default using tc, by not specifying either the 'skip_sw' or 'skip_hw' keywords. Instead of refusing to offload mirroring/redirecting packets towards interfaces that aren't switch ports, just treat every other destination for what it is: something that is handled in software, behind the CPU port. Usage: $ ip link add dummy0 type dummy; ip link set dummy0 up $ tc qdisc add dev swp0 clsact $ tc filter add dev swp0 ingress protocol ip flower action mirred ingress mirror dev dummy0 Signed-off-by: Vladimir Oltean --- 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/ethernet/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_vcap_filter *filter, return 0; } +static int +ocelot_flower_parse_egress_port(struct ocelot *ocelot, struct flow_cls_offload *f, + const struct flow_action_entry *a, bool mirror, + struct netlink_ext_ack *extack) +{ + const char *act_string = mirror ? "mirror" : "redirect"; + int egress_port = ocelot->ops->netdev_to_port(a->dev); + enum flow_action_id offloadable_act_id; + + offloadable_act_id = mirror ? FLOW_ACTION_MIRRED : FLOW_ACTION_REDIRECT; + + /* Mirroring towards foreign interfaces is handled in software */ + if (egress_port < 0) { + 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 = ocelot->num_phys_ports; + } else if (a->id != 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 *ocelot, int port, filter->type = OCELOT_VCAP_FILTER_OFFLOAD; break; case FLOW_ACTION_REDIRECT: + case FLOW_ACTION_REDIRECT_INGRESS: if (filter->block_id != VCAP_IS2) { NL_SET_ERR_MSG_MOD(extack, "Redirect action can only be offloaded to VCAP IS2"); @@ -366,17 +397,19 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port, "Last action must be GOTO"); return -EOPNOTSUPP; } - egress_port = ocelot->ops->netdev_to_port(a->dev); - if (egress_port < 0) { - NL_SET_ERR_MSG_MOD(extack, - "Destination not an ocelot port"); - return -EOPNOTSUPP; - } + + egress_port = ocelot_flower_parse_egress_port(ocelot, f, + a, false, + extack); + if (egress_port < 0) + return egress_port; + filter->action.mask_mode = OCELOT_MASK_MODE_REDIRECT; filter->action.port_mask = BIT(egress_port); filter->type = OCELOT_VCAP_FILTER_OFFLOAD; break; case FLOW_ACTION_MIRRED: + case FLOW_ACTION_MIRRED_INGRESS: if (filter->block_id != VCAP_IS2) { NL_SET_ERR_MSG_MOD(extack, "Mirror action can only be offloaded to VCAP IS2"); @@ -387,12 +420,13 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port, "Last action must be GOTO"); return -EOPNOTSUPP; } - egress_port = ocelot->ops->netdev_to_port(a->dev); - if (egress_port < 0) { - NL_SET_ERR_MSG_MOD(extack, - "Destination not an ocelot port"); - return -EOPNOTSUPP; - } + + egress_port = ocelot_flower_parse_egress_port(ocelot, f, + a, true, + extack); + if (egress_port < 0) + return egress_port; + filter->egress_port.value = egress_port; filter->action.mirror_ena = true; filter->type = OCELOT_VCAP_FILTER_OFFLOAD;