From patchwork Fri Sep 13 13:15:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13803435 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2074.outbound.protection.outlook.com [40.107.249.74]) (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 A70291DA60D; Fri, 13 Sep 2024 13:15:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233343; cv=fail; b=RGEeK4ruRzIdm54X/W36WswvtgvUsx1hwh6erdNqIxDbvUoVNbAnJN2LbKzLUWpHPk5HWE9TXh/NqtRuIfBVKsTRua8bV1D4FeOcMq9Kz9JjzTsxqNwvBtyhv0lP/qFffBmpIr01DnpFgt6kTy4WgoTqAmYDD/uucA73Eqo1j5A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233343; c=relaxed/simple; bh=mBiH27qIQkNOYyjsBYwZe9gydW6vawrMe00CXCyE5AU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=kuEgn4uCa0IFr3wH9hO99s7eGIdMK7CX5hzw1Iaybs9TGk7oU3RxUKK1gyFQM4TZInH62p6kamgTwYmDSOw8e6buN14hxYZ2wyYSp5DtloJx5zgn4g0TeFFAurM/Fm2gGbjgaxZIN4uZyWhPm7ic2GMWaKYn3nnQEcCA181C/zg= 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=DOfPYcWu; arc=fail smtp.client-ip=40.107.249.74 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="DOfPYcWu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=myDiU47NZnfstoNOZaOBwOh34t99tXqRNwKWm4C+6zqXFVW62xonE4Wux/QNRhD3yDlvRAvN0r6SsgYj4Odn6gxzIQ+9iu21LPSU4rmg9yKbnXeugcfZJJeQMoeXhTxnCMQg7wnZ15TagnFaO8CB5s7ZL7m3gGmvEWyaenebN9zCG14guM+FHQbKn64I35NpPG4wruOtDheleZLPvx97WSoi9Tm271Dy7vCFdatoqy/53sBjxXxw/09RFB+CkLS0nyZtZO8guF0pCq4oEqtkTfYddyA+0i560JHNW44rWvirp6AZ8RxyOB7FbxX0AdkguOFg1L5JN6SFiRwWXBJ7DQ== 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=LfxJ4Xpgjd1PLn398qFkkTVpKPX7SCSSEO+Cb3FY3xY=; b=hI8He/ns12od3ck6eQx3SaxJyu/CwZaAk1PvCiJ6uj1DSDbP7o9QIH6L6udxLYGrqwFMwyDiW1acT5ABDQILBwuCrcx34k7DnCEazssYkvL0fZmhvPytj9NPgtKSrPiBsHgpRXvue3m6sNTEiE45wnfvvLtM7+kqMGnSFGcP18fcoj2yL3g47DAxq9Wz6ZcSHpdj9vnqNhRoVe1AHMUiWlks30bYOfw8XpDOkbrmHl9aout/V48qIQChmrgIFvfin5gD/V/57pMqkzNXy97dnNkxgklaMHmz12+tDzolr1SkzbJ8BG54kRIgmkuWlCPx1rig66Ara6QTVolsJed+Dg== 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=LfxJ4Xpgjd1PLn398qFkkTVpKPX7SCSSEO+Cb3FY3xY=; b=DOfPYcWuw3smIXUeT1ILOi9gSE4gF/VB/j/E1gzDeLZ43Lx4fSZ1fJM9vQRnbnLHarB0inYAafFgtXc3jDtDftJl4J0qZMxRuSEswlnPEaRgYZ3WD7KxSc8myMOxNOGmKyMNDvEJrHETRioIJBNdWbhOP3RbYN7VYZ9tfAhNh9xKLuVl9rqlGYSQ0H70dtrkv8LFsVX8q64yKqDS99sc0nnx5eVdgc7NXgMsBP2GLA2+lPjxccTaZTKI39nh5GCWD9wYc9Wk0bpQ5rjuxOUoP6HA4uewqJh+wf2SkGx3RjZ9zcBJIT0gZagkfW+NnlBS61v5Hq0rvBu/1FaOpq30MQ== 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 PA4PR04MB7519.eurprd04.prod.outlook.com (2603:10a6:102:f3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Fri, 13 Sep 2024 13:15:37 +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 13:15:37 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/4] net: dsa: free routing table on probe failure Date: Fri, 13 Sep 2024 16:15:04 +0300 Message-Id: <20240913131507.2760966-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913131507.2760966-1-vladimir.oltean@nxp.com> References: <20240913131507.2760966-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0119.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::12) 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_|PA4PR04MB7519:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ec2d3e5-b48e-4302-925a-08dcd3f6284b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: 4Zc2P7wXr8bQ6CAGwm7sxQm1ahYCyhrWuCAuqYypJKIQiowACSMAr3GoNkoWz1R6ImoLypoQ71LjT1ppb8S0KIM2aY30Dl+6yT4p8EGesW7Kquh8vG+lcDyzEXTlCplfjF9MAJ/GNxvH00dPPn7uNkRTZrEcXTDgQkX8s4FrscBo6Dib+U50pIgnW8rqISDIsfMtMySVTpZLEbZzkVZkoo7MB/TwOa1sLGnA6YNtqgIXEkMwylX0c8nes1Ewu67w4F3QoPP5WxRV48hObNoAZvqiEHKtgACpsYlcykUn/Qnt/5pLj53gGFs4PEBXo4REAOYJ8RKuE1/r+9FnrNbPTGSF+n8KJljqfJuDsO07oniM3/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report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(52116014)(1800799024)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mp1/9iFW9F+Wr+EWUcmVyhEvIPGZKobKDqSFJQXfK3eZHmks96x8Btrpeofl85ccIO2Ri2qO9xdhkh4gWGWBCJ2YbfADEpKMCyoiO+72RqpGKb+y80IgTKznzOq5eMHqjHVgni88UTZQMUSjdwF3ANV0H+T4Wkr+9px7Sl0KL1pw9Bg6Rp8EfcwLGLcmMbuEY1EHXO5b0+nKb9iN1dXcAzOvvt82ar5lS/MhbHUIFH5uW+5AXE2qVOS+YxymyaOvfYyZmeD+Lf9nsE2cfM4LQ+1xezbgVi4f1U9pEyYjZ7K/Lg3yqpbCfcBFrPkr2KSYpHyGjiU+0Q/OtcVlBNiUVryXkI3onxrdTrgYWDpBmkzCVFQWxL2ujYN0HXs52z/ypzhPB37pxHPHVZHJefRIj6nOPs0VhTR6djwR5v+ZZcFZoFLtkcK0XCBlQ4ougdWt+ABH5Kck16EWUb53iih6uazznB9osquDV+W1A8+OeTPNm/d13BMd5w1je9UW7kU+5QFpaO6NJ7twrTW3b7UDap4W1u064jb1Txln/Mwck4hFKyLez81YjYdNiVYCaoAsPMwzeLB6AhwGXAAK6jpKIpVrn6WkeqFg+JvqBk3yfzoP/p+H5bAitMogUqyGySFJZKmWFS9AiSzoaIfT099LYcVsdlFwDX9F7YSMf0nt89FsYu5Coe+5MlEmtWUWKJ6sv1xFIQIW+YPzakznWyjftNkozlTKNZFz6FMntrm4zhYhG0JzKu7EU6ZqSDPcKT4GhlP9e4AoQKbmK1f/MLQs1NJ5D/VeVQ5W+PdfFwygAaUT+TCtGHBFaIY9SWP3usoZJL5L2x2ShL9voBLghau4vI6Yh4buixW/L2GFayy9LnMC9WGOUzfx47sAK9ZOPOX1lqyY22jOHj0u/TDAAk1Jd6OCPorGIpfzQj2ePklvvoJ2HnkjH3Z1hVQbvIEN84ehUAvi1ySJcZJpxdIGFuPSAFXSZWt+1ogmNuyi6ubcEjh5lpHIb1TikIW1YkUhP+ViqIgQ+QXWto+E/IK3Nl8VBVnXEZeuZTryQG5ZwDE2+lt10g5Tk+zyW81fnqgJDL0qn/A9lL+zBKx3ETgfYtMeUjSKh6Dw/68rLSvIYZXC4B5SGlQf83f9TuxktaLLm+c0k0Sgjv98LtVvRKyav4wdva4jRdTpn8ufukwmXi+QghYo+Hp3mrOqHSGD7fbQY3iZ1etWWDXfYltqXCCaB2/olS+Dx48TrYM/nvwSX53nnkpd07tzveysE+JqC7Gf/TBDA3jZW1/L+5VMZKF4KyoG4TLZmj8pVquWt/J+cyxW7/UpdN7krxUUGcmuZYZCrhOf5SjkA45sqdVukUSIhXDQsATWWoyV37EU+p3khi3IvvX5+Wu5tb1253ij11gpVa+l+7KlP3C5OxrnRXfOXjjYK22SI5Tr+q2yCuvzW8GJXDbhi48xvFudRqxTJ7MebTBU8kTOBfSuTsB1+OtfSnFsKupxySP4JHyza+C9HaXYTUE5bCQD9+AfR4SYs56LU0NPVg6dZ3ArAwk/WpQboaP4Z1CtLPlIX88b91EwwMQRbjKqkvFSRRpJf4hBf4XeAm591a2AONQHmYU95dyqTIo6bA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ec2d3e5-b48e-4302-925a-08dcd3f6284b X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 13:15:37.4198 (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: YkXy0GJbQfTsiIqt2TAmYJwd8jVGDxl1LTqTGYgM2/nICu/PVO+96EsAj9G5xHZwuwUQT09tZVBTW1ctPtFP4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7519 X-Patchwork-Delegate: kuba@kernel.org If complete = true, it means that we are the last switch of the tree which is successfully probing, and we should be setting up all switches from our probe path. After "complete" becomes true, dsa_tree_setup_cpu_ports() or any subsequent function may fail. If that happens, the entire tree setup is in limbo: the first N-1 switches have successfully finished probing (doing nothing), and switch N failed to probe, ending the tree setup process before anything is tangible from the user's PoV. Because the dsa_switch_tree is still technically referenced by the N-1 switches which succeeded in probing but are practically useless, the memory pointing to "dst" and to the dst->rtable is not actually "leaked", it is more like "blocked". However, we could just as well free the dst->rtable, since a subsequent attempt of switch N to probe, for whatever reason, _will_ trigger issues. First, dsa_link_touch() left behind references to ports owned by a now deallocated struct dsa_switch - the one which failed to probe. Second, the dst->rtable will be regenerated anyway by a subsequent probe attempt of switch N. There was no practical problem observed, this is only a result of code analysis. Signed-off-by: Vladimir Oltean --- net/dsa/dsa.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 668c729946ea..a543ddaefdd8 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -862,6 +862,16 @@ static void dsa_tree_teardown_lags(struct dsa_switch_tree *dst) kfree(dst->lags); } +static void dsa_tree_teardown_routing_table(struct dsa_switch_tree *dst) +{ + struct dsa_link *dl, *next; + + list_for_each_entry_safe(dl, next, &dst->rtable, list) { + list_del(&dl->list); + kfree(dl); + } +} + static int dsa_tree_setup(struct dsa_switch_tree *dst) { bool complete; @@ -879,7 +889,7 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst) err = dsa_tree_setup_cpu_ports(dst); if (err) - return err; + goto teardown_rtable; err = dsa_tree_setup_switches(dst); if (err) @@ -911,14 +921,14 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst) dsa_tree_teardown_switches(dst); teardown_cpu_ports: dsa_tree_teardown_cpu_ports(dst); +teardown_rtable: + dsa_tree_teardown_routing_table(dst); return err; } static void dsa_tree_teardown(struct dsa_switch_tree *dst) { - struct dsa_link *dl, *next; - if (!dst->setup) return; @@ -932,10 +942,7 @@ static void dsa_tree_teardown(struct dsa_switch_tree *dst) dsa_tree_teardown_cpu_ports(dst); - list_for_each_entry_safe(dl, next, &dst->rtable, list) { - list_del(&dl->list); - kfree(dl); - } + dsa_tree_teardown_routing_table(dst); pr_info("DSA: tree %d torn down\n", dst->index); From patchwork Fri Sep 13 13:15:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13803437 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2074.outbound.protection.outlook.com [40.107.249.74]) (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 DCBFA1DB54B; Fri, 13 Sep 2024 13:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233345; cv=fail; b=JBfgdTWxQri38xsG1zh+eHtPUg1VPaZg0dXkBA/fTKvQQkl9j8JkLZDy/hQIO+hibFAgxsLw7FRhjakFVPE83x18+6briGPILU9aeFuFY6svVuuFPLNo/6x+cdx7wl96/6Ywhnovrk+qb97F+czqHH7YXb8CjwuJstWZJwH7FSw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233345; c=relaxed/simple; bh=6ic6d9dfmb7+QNHTOnBonp71/ao7ZJxf7ZqSMwZmw6I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=s4nwt0X/mnNblo7nyEKFNlthfnpFmZoNIC4IKafH+vKxteh2Sw7nyNReCsSure8RP7XGb5iHH+ggC4ddB5JACAzSPgiM41AYafQRbf19nGsNbRnW1WjlNKkBVjSUqEdAAWAVH8lz0DjaNgV5yE4N5sYfLbcrSq25PWfh29c5PKA= 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=fvBIeWAK; arc=fail smtp.client-ip=40.107.249.74 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="fvBIeWAK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BfXIqzswSlccr6nc/rbd7rDtj1csvxVEOGjL6qykJy3h03DwpQmGLfikdGZdPP250yO1UC3R22dtQNgE/1UKIBOc5dY05gMWYClxnzWIEKNilQrdnf2lE08LM/TeiFaQp66Rull13nBaUMBVPmJgkfh0A8ZQ5kRw62B+ZSGA2zvWoKFvWN6FjgAcDEJYOVV76/hO/z9muHurTCta32zUrgfPPBiNbH1Ww6w0KMyK5NMsgIRncQ/XkKjmENsf3kggmS8NZBekgEeaF6TpKASP1hwjT6iUz9/Hyau+1cQGzdF1PYjySfTUVjNJj20bJVvNjx13PjOLo3MdQy6dptWMbg== 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=3lUuomDFyLmNbtceRJ6dWGdAT6VpTQI2dbWJv3mHiBM=; b=v0l6xLZ+LObG+tAECOWImpW5feU2h2mR08Uof4CeKVzuoi0WWr72+lJQWTTFzDTLTEl5rQB1EqT9XRBZlYn/iaKimTWSRd+Qo4uYUF/OQ//vhKUtkbqz5XE3QWzKg17JwZmGUYF44jtYxlCHFnwZMILxqmMTrrvL+Iza3w4yPI75+nP8Wssc3VgjQ566WJjwm5VlUE4N913JyCU2it1MNcOo6oiA+oXtI0LOYAhdQrZOzZkv90UoHvZgzlkbasZyQty7R6wGjid4VkArKHZlGDg2ekMy3TVNcbDhbbCjZpU3Pi2sz+V/j8ci3PxmwzcHyZc7GoxOWjtDwtH4InH6pQ== 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=3lUuomDFyLmNbtceRJ6dWGdAT6VpTQI2dbWJv3mHiBM=; b=fvBIeWAKHHqLg6zkP9FblvtzGmTfQ0gd933Q5iwy1qZJvlz8QTTvWsGAuzir9jOkr8uVA/SPTxsQdK9/0dDYlyM/3zALH8vl+sFjFNv8lfLDVVsbzhIPk9I2jBjvuoJckf209l1z30aYda+wCf4BuQkPu5aj75PRg5fTRT+zF7LbPpFA9OOAUmRQ5vFigS5QXHbT67gvNjegCF4c4Iw17TvsB4Ddt+PpElGog3Kbaxpgh12/lBE5kQY1SDxGpmV4MAeQ3PedXrcfU+UpBSEfAG0ju3fh1L6UY698adwZy1iK+P9lhFwG4pitRVrmM8Wu/U6kIiHJUeowqs8FMDDynQ== 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 PA4PR04MB7519.eurprd04.prod.outlook.com (2603:10a6:102:f3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Fri, 13 Sep 2024 13:15:38 +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 13:15:38 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/4] dt-bindings: net: dsa: the adjacent DSA port must appear first in "link" property Date: Fri, 13 Sep 2024 16:15:05 +0300 Message-Id: <20240913131507.2760966-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913131507.2760966-1-vladimir.oltean@nxp.com> References: <20240913131507.2760966-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0119.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::12) 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_|PA4PR04MB7519:EE_ X-MS-Office365-Filtering-Correlation-Id: 6eb24c48-91ca-43ee-b56a-08dcd3f628ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-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B/LHPfjs6teI6ahh3YCMe7IZ257dWuHSTmVcZKi/bPojtgfXCfJKq4xAsahpdbIsH03cUVVjeHjQckz+abu7Pia0YuWiHTsCkItx3ijQi/fAOgARvsZrAB2IvHgLvzQ6wSnKrC2TDrQGMo7J2iJ9oCpovwtAU9aHTTQX8OXxiXVDaheVfs6zoECNRcL75+Ch7oK6z8xhBkxFNP2OgE47tVWGmtUXMfOUP4a0ev7lCjSqZlgWnufizwpAnAXmAmzRKQOWRqNxhiZYjNLezr90HJYVUgToga4iKGjqIp1XWoXPb7yCOdrT2Vn1T8XBGA27FvBPa8NsoJY0TA1dXv9FVpqfCyBNQvg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(52116014)(1800799024)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: On5wRgqgf0yD0vLsmN4hTU02bh+Yjw9E3ReCvApXpbM2cyTu4rfvEop1Y0vHGxvhSOngcNq5g2Bh0wF+GzlNZR+4f0Z4sasMyHDt1Hnz09D5Z1gbs0XaM/R0fKUAA8ZUohZDIwnGfFeFrF4vw27b0eCjT5euPGxhLmp2ZDdaliR0nJBUts+hQpEIF7lruFy3b89DVIjLSCqELJdf5XVtGfqDUT5uzhS4yXfyO7iowBjIZG3Kg+UTFRQ55LfmiBx9214Ow6tuoVtUGn+6XMRqnqsYaU3q0S1sPCONl+n+Dqaxk4TXe+J4Pd59CxSpCvYSjP3P52MKC+9aPw/CAlTWaf7rcuH8+VHJUFiPfvCEXK7fPEhaHWfGayuXLgRBgFYgoBwx+ITdRTzfEgR0j5wtRYhbMP3H+OMYWj6PXW15zMn7fyfzOEifVx/8rGr3uGaw51l6ka9qLZ6pLezrTNd/phTMW20QUsAdA9C3Hz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xqgYTXdgzd95GEPZ5pnYoQvqVUT4w9HXaEM/9jxS6jvySv5vq7uzi6etOg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6eb24c48-91ca-43ee-b56a-08dcd3f628ed X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 13:15:38.2953 (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: R/BjQFNPL2pbY29u7dgF2H+AFWYCngGU/EcMAe+XnDXdNiM4ARhLVQiCTqoEW9fb/NuQInWoBWrZDF5kCfbZAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7519 X-Patchwork-Delegate: kuba@kernel.org If we don't add something along these lines, it is absolutely impossible to know, for trees with 3 or more switches, which links represent direct connections and which don't. I've studied existing mainline device trees, and it seems that the rule has been respected thus far. I've actually tested such a 3-switch setup with the Turris MOX. Signed-off-by: Vladimir Oltean --- Documentation/devicetree/bindings/net/dsa/dsa-port.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml b/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml index 480120469953..307c61aadcbc 100644 --- a/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml +++ b/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml @@ -31,10 +31,11 @@ properties: link: description: - Should be a list of phandles to other switch's DSA port. This - port is used as the outgoing port towards the phandle ports. The - full routing information must be given, not just the one hop - routes to neighbouring switches + Should be a list of phandles to other switch's DSA port. This port is + used as the outgoing port towards the phandle ports. In case of trees + with more than 2 switches, the full routing information must be given. + The first element of the list must be the directly connected DSA port + of the adjacent switch. $ref: /schemas/types.yaml#/definitions/phandle-array items: maxItems: 1 From patchwork Fri Sep 13 13:15:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13803436 X-Patchwork-Delegate: kuba@kernel.org Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013046.outbound.protection.outlook.com [52.101.67.46]) (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 AEE0C1DB547; Fri, 13 Sep 2024 13:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233345; cv=fail; b=ZRWMr4xd3dmHcLRtQOwbLYqxYeAL7a0Fk2jKaIjYjYIR6bgW+TePIoQESpcQIIJAlfJfW3+6cz2OO1zWwLuG2scmh+C7FkQmjvuYM7n5T13/sTkhSk/y6kgc3A4LED7QrY8tHUpShZEbKy5ox8ZcveZTRLrlV20ys1rbi1UboMk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233345; c=relaxed/simple; bh=oE4GIebNruOquM/to4+TKpsHL8xLeuvg0WhH1ivlZvY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ECY2MgBBWgeEgf8HsQOshwMLyTEjRa1pdNNIQY7BoAlO34C30yX9qi7jjRPjQ+TZBwcSK8viRVPpkJHaBo4UpySAKpCMT0PfkgfwfilNOUaX4iGOn567larvfHtBCzlQkZHuSFjv0zH8GZgmmzwX9kO6LlCxz1W50kVIPafXN9s= 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=B/xsxTtl; arc=fail smtp.client-ip=52.101.67.46 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="B/xsxTtl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tnwZv2kw422S33rwxfekWJ+EYkPgTM+KLZA2jyK1Ez8vHsl81NAHFUxJetC3E9ryCQlQk5aRHWqUwPVjbAw+lTwy/nhSKFhFMBmIVSQPoQCJ3AUc+LI+AaEtY9loyhtlR1VRkLl7cQbdSeMseXYv3awct3APk/tp/l12vFFZh926j8MOEJQK4K8M43rTbVLfDPp574qZVWyqrWQhR0ShFARdCUpApioqAKU/TzjkMiuzLaoEbq/hE07COSAyw+cBBrHkUYnQbXkxtCXRxqJXZ9968yLFpr4wqO9EhgvhDlDbn9AkKN2aBUR7JWiIVNiQuMVvEam0AhUzMYMM5mlBuQ== 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=FwOcq3KLsAa5C2pQ+xwbI7hCpo+OW9TC/dIfZBFRQKE=; b=CUaeMymkIopryz7ruQhakn9aW4tQA4/ucDb/fjWuxolLkLTyCAxNTGED6spuYApG4mrmGQ+AJZJjT3lxWmtZWFpR3tvboFsIekxv74J9Yr3mSXeWTPhCl7OMynAhGSVzS7BXUYLgynpc62qp5sX1ugWrvpdejPpXL29OtvCWwYnJKFygA9XVPF1V0tMFPJcx7Xse6pvsQcmNu+htxsWaC1w0CuDXpoPZGPNduBLLHbJ/R0eKVspiAweN/AOybVWWHSLTvJMLDAAhvmcFzeWy8Vfq6/nt/rRdwJI/l8oOtaFeQy10w6u/xM7L77x6KmJTCsF2Shm1gmJMwdWMZUmpfg== 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=FwOcq3KLsAa5C2pQ+xwbI7hCpo+OW9TC/dIfZBFRQKE=; b=B/xsxTtlhlpc/KNrVo4kGro5ESCjMWhQzA8vYoJtdWQ3/TAkuPQUCLBdWdUf/xTtogY9KL7WUbAwpO6jnDkH1UIKmZtRO5aeZk8tf72Ymb53oZBYXulPtt2Hh2ygkd8aTkeIIaQ6m2D6NKvvBvth27W9KRFc1xSWhFyDXAXXy3OYS1r0Ck+IK0M2LFYxbiGqUA0eGmDaMz1E6QmBkirqDWXpp8fvXKTmspQ2UNQswe25U6WE3QODbvss9bgLUSBKGK/HIVrkaMiTJoM+tkynIpmS2Y7fk2SqC+w682HrxKoPfa6Wx0y2p7HsCi7KUWZuUIh3/G0gENHJQavNUlzkRw== 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 VI1PR04MB6815.eurprd04.prod.outlook.com (2603:10a6:803:130::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Fri, 13 Sep 2024 13:15:39 +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 13:15:39 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/4] net: dsa: populate dp->link_dp for cascade ports Date: Fri, 13 Sep 2024 16:15:06 +0300 Message-Id: <20240913131507.2760966-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913131507.2760966-1-vladimir.oltean@nxp.com> References: <20240913131507.2760966-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0119.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::12) 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_|VI1PR04MB6815:EE_ X-MS-Office365-Filtering-Correlation-Id: bba1e107-1846-4ed4-35da-08dcd3f6296d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|1800799024|7416014|38350700014; X-Microsoft-Antispam-Message-Info: sVza3UAeedVrh53yz45FNrpYRDGc7kDLuM4RkjFHxpk/39WolJbj7r63tXRf3rG3G6wX3csZBLfagsP1tOZeOxnGVlpEHDer2cjwl2JIlu3wiQXvEg/watMEDBfPfbcKSl5R2fm3kE5ckS5am08lYr83G+4B8sWQSr7Gj6FdPrHnCzz/N41t/dGaSz74EfQcf048seHTOr/uSxkrVqar1ivNbpPdr+WzDmePyP9vMuHFzKQKnPOsM5NqOPhPs4FXTfIL8ucnnK3LCpBFr5Er9m6ZOUG43OzO1RcwXw6G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IDeWgHpXvRVCX0+swAVgl5X7RziLPIHP0r95otgqcYarlo1Uw== 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)(376014)(52116014)(366016)(1800799024)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0LWDoPPMpO7MmBq1kbp9gQPMCDohDIVQovFED5kvgn1U3tP6607qyrBF003u2/gzFLvGqRrEVb4IuFp4teU/sK/U2/wRSaStY3dbqt2t+e7F5EvZaCtQHEEZNQA2Vm9r4hMCgYFRnvuAV2/AeZx71Ci8GIn1rrcobDxHDC1C8wUbci5Z5XsTWgslKxm1GAYkKgzTVUBQe7iC1aovOhXXOpOiUpT6WMiUFrFA7nsiwHCNgW2z/e5jPESVGr14IlABkDF6jMdI9v7RcTbmcrFv/IS/Zgif3/AH7q/HirgjHomzcCgQwyuS4OwWLkkgu2wJ19zU/8OjnydOI5QeSr4IkADfgGImczn9sQuDK3+N1i3uULVcF2KkOgCE7WtPWR4DlVdOm8iIxjL3CqW9h9HG98eEpQx136xommcGFxIsiKeQv8WLHdxuJHeqW4Co4Hg+3DI2XqNF3UTd6Tdxp5BxlxlbBWZghLMwpDSj8TY3MKHJRNl7/oARfMfaeMor0e0LXBsMTVQb9Jj+PqCn3z1jxsq6inbE+9CHtQ+z2qsWtYzekX3Irbx5VbturvA/0KDzURSyHnyhKLxj+4bI1viCCsUT8r2hqXRWzCUMKp+UiP1dDexzHDH8SfH8xiznNUJNzEOHUsM2L5yyZSNlEjj4i3yHwm3BN7hmzos771wWXDcvFpU6LVNGdx6SSikJib7GOAdtZ7ancUbxmMMfvt3hASuG8r9vex0xss/+u9upOxqIfvGuNHZ3Ss8WrwaFc2kWzeNbL/jQR9aTr8I9ZVwtISwt/Hn1vkLplyRmX07o/+hbu5blfE2wr48CNDi44eC7PJ8IPBnJyCfrRR/+snwqzzn2xBEHZIcymflMMTDG2W1XZTOy0NuBgD8f9Y3p8QBaUIFfEqYcbKx+fSedGp7yWtJTvIaTNXiYB45yysxIh8OOwQKu9VdVdndss2Zl/f4h8wuVLkIKZCOXjZf8BsVAGiZi6oGn4o9xxZwv4gYOC6Rr/A3uUaQZgMmokadKcsgm+QyDY9tpsc2PvR24tOIxqE35bll7uz9J6OteOW0fGSYGibfXzMHwkwnxflFkSnvJWGntnts0cj0lvcgCrSV3Wr2zql6duxBuQ2HHoosRrZSpzf7pGXTQN65Ob0HCbACYbnWDndu+tapKzzHSQ7bhEHzZaeQvXUknRN6InZqQL6++LbAlNwe/uQ4cmDPpr6Twvt1ucaJ56++zmWOKLmdrFHoOOsFFzQiTDCnL2uJL/Crt+cHLhEHo6udMaIHHVyzt9/wQB59VbBhCc3A4TNYMAIsRnrUJW40g2Ksa62JqE2/ttex8/h8hc7lho8RbGh/KOZoSGT73rJ/EBgCZ77QhKiup5zpB5U3/mgtMsXBh1ficA2P2VJYaXXrUDB49zkMsqNpyNIvX4LNhPCAq5FpddfATxJAOUKjQ1nDm9001MPPFskhaOyoMndk28aWGL2ePlIxDRnDYip8Eu1iDEcwY2bhONgb/I41tgPpX3GuNgs8N9rm5TiSUq0beELXUfjCKMBsHh1rnGCEqSQSJenIsnj19VnVObJEfLVViyjzQcZFWpJ+wSBPE+uuoxMjM1xzZFT5I1f7Ow88n6BT2wAvIBg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bba1e107-1846-4ed4-35da-08dcd3f6296d X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 13:15:39.2611 (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: 9LhAbxIwEH+yq0qfvUhpMl3oq2/oSsMoWvW1SiJQJGoG+B7wXLzG/Bqo3z4XC+u1IxuhQP/CeSwSqQKHqyueYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6815 X-Patchwork-Delegate: kuba@kernel.org Drivers may need to walk the tree hop by hop, activity which is currently impossible. This is because dst->rtable offers no guarantee as to whether we are looking at a dsa_link that represents a direct connection or not. Partially address the long-standing TODO that we have, and do introduce a link_dp member in struct dsa_port. This will actually represent the adjacent cascade port. Signed-off-by: Vladimir Oltean --- include/net/dsa.h | 9 +++++---- net/dsa/dsa.c | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index d7a6c2930277..586efb76f67d 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -265,6 +265,7 @@ struct dsa_port { const char *name; struct dsa_port *cpu_dp; + struct dsa_port *link_dp; u8 mac[ETH_ALEN]; u8 stp_state; @@ -332,10 +333,10 @@ dsa_phylink_to_port(struct phylink_config *config) return container_of(config, struct dsa_port, pl_config); } -/* TODO: ideally DSA ports would have a single dp->link_dp member, - * and no dst->rtable nor this struct dsa_link would be needed, - * but this would require some more complex tree walking, - * so keep it stupid at the moment and list them all. +/* TODO: DSA ports do have a dp->link_dp member which represents their direct + * connection. However, dsa_routing_port() requires full routing information, + * which _could_ be deduced based on just the adjacency, but it requires some + * complex tree walking. So keep it stupid at the moment and list them all. */ struct dsa_link { struct dsa_port *dp; diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index a543ddaefdd8..8b4ec00de521 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -285,7 +285,8 @@ static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst, } static struct dsa_link *dsa_link_touch(struct dsa_port *dp, - struct dsa_port *link_dp) + struct dsa_port *link_dp, + bool adjacent) { struct dsa_switch *ds = dp->ds; struct dsa_switch_tree *dst; @@ -307,9 +308,23 @@ static struct dsa_link *dsa_link_touch(struct dsa_port *dp, INIT_LIST_HEAD(&dl->list); list_add_tail(&dl->list, &dst->rtable); + if (adjacent) + dp->link_dp = link_dp; + return dl; } +/** + * dsa_port_setup_routing_table(): Set up tree routing table based on + * information from this cascade port + * @dp: cascade port + * + * Parse the device tree node for the "link" array of phandles to other cascade + * ports, creating routing table elements from this source to each destination + * list element found. One assumption is being made, which is backed by the + * device tree bindings: that the first "link" element is the directly + * connected cascade port. + */ static bool dsa_port_setup_routing_table(struct dsa_port *dp) { struct dsa_switch *ds = dp->ds; @@ -317,6 +332,7 @@ static bool dsa_port_setup_routing_table(struct dsa_port *dp) struct device_node *dn = dp->dn; struct of_phandle_iterator it; struct dsa_port *link_dp; + bool adjacent = true; struct dsa_link *dl; int err; @@ -327,11 +343,13 @@ static bool dsa_port_setup_routing_table(struct dsa_port *dp) return false; } - dl = dsa_link_touch(dp, link_dp); + dl = dsa_link_touch(dp, link_dp, adjacent); if (!dl) { of_node_put(it.node); return false; } + + adjacent = false; } return true; From patchwork Fri Sep 13 13:15:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13803438 X-Patchwork-Delegate: kuba@kernel.org Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013046.outbound.protection.outlook.com [52.101.67.46]) (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 089A81DB945; Fri, 13 Sep 2024 13:15:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233348; cv=fail; b=hcp3OmjozWkzdC7n0xPfEsQifzZvTySVmWGVAGOfAV9IF5RcsFJX1yntXJlofql9KdfsTm9RMr9I3RIp7l2zGVSmHQl+SgTtXB0wgE/7Jy+yEBESR7O4VtM+0vqJWJrLnEDNZHeUpJ1mXznHLjMdNaUujHmBRSrLw6CNamw2at4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233348; c=relaxed/simple; bh=Y8jAcM0DwmNS+pYme63HMI063Wr6n8TpzOt7T0+tN6k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ngPV92ZOuRd+ZMyrRpJlvw8HrhhQrK8Es9iG8Qq0Arlsn7KYVvjbiB/7RTG1cbU3w0/MWAAsNHbMDHhqbx69SKOs2/TJ6YMgeuWrVKP4GYw8bnfCaATTc2moSESDAERRtUublLyzGO5rTo2USKj7JPtYS2ZTfU1U1N74ggGiG8Y= 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=YwK3Hk0G; arc=fail smtp.client-ip=52.101.67.46 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="YwK3Hk0G" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OR6JubokfeTq3GOjOixHZFIPrTmlV18D/733mbeQw2Wdk+3FWcE5e8ZHzfVsxeaQjEW6cb4gGeiLTuMmwzp0+pojVzq9gS0MTT6ritXT4yzcMlMwwWwYdvnuMiLSyrtEa/bY+FPUJ5iQB5VtV4yPKy08gh1e8Udw4go75JnqLCTWE+Mwn1f015mGZ7lvpzCQ6J64LLaU81pjylEZs+7Psl6mjsNToy7iIfywFr7+gYwdJLLibEEO9FMHwViNduqc82l0aY1IkFxKHrjc5lu5dUiuyhGX0tGVw58TSX2ayUntek72UYKI4Z3xtN2fJOEN9lZ5/1AtlFG4fvFCtz4wqw== 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=iOPu78po+cq5e+bR7gG85KCvZtieG9JQiuIfcPzNtUw=; b=qi43/++8sijj05vcxFOdza8B6N14PHRuBD2idp9S5y6efc0fRRvGcaNZ/QqwI9nIA0h0Npi/xwHBoR6KH4L1dHNW+KXYduwB9ts8kIGy6tt8gI8ocSdM4aercdS0hyjwIlY07hc5LoP1KjEOgiRf3UUFN9BAotSWkCNe2jqbzfTUo42Sngva0TCbD5X6+cqFIvjFjFeZQN05HieiKGBOe0wPJsiaQF+WFCyUntM8ViRcMNte4J88vU9NbD+BqC9Iw/HkYkhQ+iD8IEKT4yi5AdfMBsyzq1styot6BIe8v8VcZbgAgH36kjVvXAZy/L/TXO29L1pEe/zhM9SDRVavJQ== 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=iOPu78po+cq5e+bR7gG85KCvZtieG9JQiuIfcPzNtUw=; b=YwK3Hk0Gy04kOUFoEmGoKuvdwdOCBGph0FduX9x9QJ33AMe8PNiWJlDyRTLBVU4Yk7navt+RrmgW8C3B/ZOudjQu3l5elkF/bxtOgYbKZzwbYLweQYkRfr3HE3KK4BKAB0pHVKfzgOR2FhOYbL8pbk1UY+yN5LhscTVRrEGNWxzhcR1haIOlcA/gXJIaOPPIDkr24LuDyOFxK5ou0QS03IpNXwuWZQsq1yFPPyWagWL7pHH0lQF1ZZQ1c3IyKZ9JgaGFNC4vLornw5/MAkJCa8r1DyDiNUlocSeEA5gs/icdWSWHZg/2S9DwsufFO2whQR5xSGjIvliuphJ3eMWJIw== 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 VI1PR04MB6815.eurprd04.prod.outlook.com (2603:10a6:803:130::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Fri, 13 Sep 2024 13:15:42 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%3]) with mapi id 15.20.7962.017; Fri, 13 Sep 2024 13:15:42 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/4] net: dsa: sja1105: implement management routes for cascaded switches Date: Fri, 13 Sep 2024 16:15:07 +0300 Message-Id: <20240913131507.2760966-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913131507.2760966-1-vladimir.oltean@nxp.com> References: <20240913131507.2760966-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0119.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::12) 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_|VI1PR04MB6815:EE_ X-MS-Office365-Filtering-Correlation-Id: 790c0f2d-14ab-4877-378f-08dcd3f62a00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|1800799024|7416014|38350700014; X-Microsoft-Antispam-Message-Info: fync746b7aZ19z/eEPaMyYIaIE0IFPFDWSu+G7eSmRk539eA1iTQ7XYvoFVpwSg7mXWWbkwQ4QMMEoBcdmOyhhtRarCdICrTk+VVkVUwzGw/OL71d3cA4AFPpUHi52t6z5HqZswb5VrlwZcZaXgha5OoDkF2O30V694M3SPNxLD2F4YkLm1N8yY1SO5PR+PAh/mDBiDk42MUxDlBedRkBCVxi0DSl0rGVkm08LMW2y9WmSo2/+luK/Sv+KYSRiHwGx2PnP0OkRLn0BW9blxHLyUpI+STmd8ubF5vCHAwf+piwHZ1DyFc3EhoYNI6hF9fRQSoCauE1m/GZyes/BA0D+zKzG0qfS1k3hDfNT4KTRvwRHax/3za72tnue+N0sQVU8pC9D+xBxTFimFBnAlpD2Cyf0MaYhRCs+792UcEKXQFC2ItVLSwym4Zu/MVx4Qa3WGPfdyTZZPw5AnJ8AXS9M+vbYs3XcrxrALdxZ1RBi2OPhC1kjAM1eqT6feNBn43MuAsCW8bUMHrQH46eX+ayZwLjwV3/lj7BjDiv6v5YMUTLeoIDR9Gsu1mfYaF4NKr+jzC3G1DBnKIR+ph8Jjp7Lt3dvL0n/JmMNxrm8+wzitA27MQ/76nbGoWKU2YH/h8k3DRn3Yo8ce2yoe0pWDfO7OXJ5YAj9SNb9RBXVXnSDidzmSrJ8tDlRDJAOTYJAL1KITY7XBhhUtDAc31UYns+V0NNNNLy+7JawqStYl2R8ASZ0QDSCFkakNaIB0eXyAKYWIm5lbJOZ8TEmyLAKWxmFqx050Tp+71UhIiFsZgn4Jijtn9tgvbaHfjTIozuzdQ9o2+5/F6NmLrUy7bauTr8f2ynTBgiO1xrWKGihutExZG5hYQYTKu8phW4S8OrL5QmQnGmcRBo2HVaU/EsiNFagsPo+Ub4eF8DDldRYoWaXn0ZI6d867s5R1sRjoXpRExSuSi31ZXItqRmIDOdXu4RVpZI7QCSd8+ON99raqvHeRNc0MzFJzRoAjfv+/t/WFMCbYuhBX+/pZL4KgnMsVWgfzymw3asP+J/Ny9dKTeTZubUFh2ICOOwN3XQhIb9mkMAWlhSL/G2SGqwQj03NYkpZbmn84zCBe2+dmnpHgqvbH8IapEpzlUBWQqjm+/0MUzLQgWu9bcS+BVyeJpmHgv1McT7QxUA1+er7OMNBBvLVFvSttRW19tM97LjK3+qF/mKccsIJGvAsOHPH2g6HFia89on0MFe1Vv+nv+azLSk55USf6Q55n6XUR/vOVdw6roLyRgsdMbUrUA3vXi+tXXmK4ic4i84U/iQ1p9nrD2bwnVQ2A0gI9Mstne4LLGML3V5K6brMn5TgEllZgHdVE4JO8xzr+tAT85u/uZQfM+jROOmKrlJm2X+RQZ90+qa8tHrxE2la+BR5hi45VICkPn6A== 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)(376014)(52116014)(366016)(1800799024)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3n2YGvYGd3cf9s42by6UBQwqFcKXP09S13GKZPY5RhHxQ7X8G5Ci9+YwAL8DT/Z3Giif32cBlfXY+6qDJ4ZFau6AwQpUrlVyvqgqXDmxOTp+Cj61Whn+AnKHh5Sc8EIID38wd4DtJRmyNssUpoyirdsEDQc6HH7l1HoQzbmHyYL6XpMZ87GH71P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JtPameDzJOF06b+CCVwI5yy6v4ONjETbx2XY+dRXmjthhbgAm5FlpjARnFtW0jtQUQtPCNmOhK0CY7GIelzgT5sYyflG1ovxFCssqKVenOyynBRr6juERR/wlP0PPecCEGAAT0Cvn86hkJ5qAnLkSSgRIh/J/D6wzUUUawJtMXg7vPomvCSAvRj3z7+Xt24v+KyiEZ+FZT4TbL9oKKUEk+N/IyPIJfx6TVGRFfBzvAZPEJ9WTpxa+qGSEEzoNuSyzp4w+QUkCKN4e+HVa47rUYJQ1ga5tz+h4n8ErsGbRefEb/k1CyGXB463qVQGD9fIMTorpGARo6BwDw+QwnXIF6JB9QV6GhLS+oCaE0o4wA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 790c0f2d-14ab-4877-378f-08dcd3f62a00 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 13:15:40.0968 (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: BtuubBZz9VaYDTnFxstipijO/M0vyYJZjA4a4Ab/pC5nzGp7hhpGxsR3SYtcte5NNUmoPy3VN5QFBdvOIAwCVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6815 X-Patchwork-Delegate: kuba@kernel.org The SJA1105 management route concept was previously explained in commits 227d07a07ef1 ("net: dsa: sja1105: Add support for traffic through standalone ports") and 0a51826c6e05 ("net: dsa: sja1105: Always send through management routes in slot 0"). In a daisy chained topology with at least 2 switches, sending link-local frames belonging to the downstream switch should program 2 management routes: one on the upstream switch and one on the leaf switch. In the general case, each switch along the TX path of the packet, starting from the CPU, need a one-shot management route installed over SPI. The driver currently does not handle this, but instead limits link-local traffic support to a single switch, due to 2 major blockers: 1. There was no way up until now to calculate the path (the management route itself) between the CPU and a leaf user port. Sure, we can start with dp->cpu_dp and use dsa_routing_port() to figure out the cascade port that targets the next switch. But we cannot make the jump from one switch to the next. The dst->rtable is fundamentally flawed by construction. It contains not only directly-connected link_dp entries, but links to _all_ other cascade ports in the tree. For trees with 3 or more switches, this means that we don't know, by following dst->rtable, if the link_dp that we pick is really one hop away, or more than one hop away. So we might skip programming some switches along the packet's path. 2. The current priv->mgmt_lock does not serialize enough code to work in a cross-chip scenario. When sending a packet across a tree, we want to block updates to the management route tables for all switches along that path, not just for the leaf port (because link-local traffic might be transmitted concurrently towards other ports). Keeping this lock where it is (in struct sja1105_private, which is per switch) will not work, because sja1105_port_deferred_xmit() would have to acquire and then release N locks, and that's simply impossible to do without risking AB/BA deadlocks. To solve 1, recent changes have introduced struct dsa_port :: link_dp in the DSA core, to make the hop-by-hop traversal of the DSA tree possible. Using that information, we statically compute management routes for each user port at switch setup time. To solve 2, we go for the much more complex scheme of allocating a tree-wide structure for managing the management routes, which holds a single lock. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105.h | 43 ++++- drivers/net/dsa/sja1105/sja1105_main.c | 253 ++++++++++++++++++++++--- 2 files changed, 263 insertions(+), 33 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105.h b/drivers/net/dsa/sja1105/sja1105.h index 8c66d3bf61f0..7753b4d62bc6 100644 --- a/drivers/net/dsa/sja1105/sja1105.h +++ b/drivers/net/dsa/sja1105/sja1105.h @@ -245,6 +245,43 @@ struct sja1105_flow_block { int num_virtual_links; }; +/** + * sja1105_mgmt_route_port: Representation of one port in a management route + * @dp: DSA user or cascade port + * @list: List node element for the mgmt_route->ports list membership + */ +struct sja1105_mgmt_route_port { + struct dsa_port *dp; + struct list_head list; +}; + +/** + * sja1105_mgmt_route: Structure to represent a SJA1105 management route + * @ports: List of ports on which the management route needs to be installed, + * starting with the downstream-facing cascade port of the switch which + * has the CPU connection, and ending with the user port of the leaf + * switch. + * @list: List node element for the mgmt_tree->routes list membership. + */ +struct sja1105_mgmt_route { + struct list_head ports; + struct list_head list; +}; + +/** + * sja1105_mgmt_tree: DSA switch tree-level structure for management routes + * @lock: Serializes transmission of management frames across the tree, so that + * the switches don't confuse them with one another. + * @routes: List of sja1105_mgmt_route structures, one for each user port in + * the tree. + * @refcount: Reference count. + */ +struct sja1105_mgmt_tree { + struct mutex lock; + struct list_head routes; + refcount_t refcount; +}; + struct sja1105_private { struct sja1105_static_config static_config; int rgmii_rx_delay_ps[SJA1105_MAX_NUM_PORTS]; @@ -259,13 +296,11 @@ struct sja1105_private { size_t max_xfer_len; struct spi_device *spidev; struct dsa_switch *ds; + struct sja1105_mgmt_tree *mgmt_tree; + struct sja1105_mgmt_route **mgmt_routes; u16 bridge_pvid[SJA1105_MAX_NUM_PORTS]; u16 tag_8021q_pvid[SJA1105_MAX_NUM_PORTS]; struct sja1105_flow_block flow_block; - /* Serializes transmission of management frames so that - * the switch doesn't confuse them with one another. - */ - struct mutex mgmt_lock; /* Serializes accesses to the FDB */ struct mutex fdb_lock; /* PTP two-step TX timestamp ID, and its serialization lock */ diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index bc7e50dcb57c..81e380ff8a56 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -2302,8 +2302,8 @@ int sja1105_static_config_reload(struct sja1105_private *priv, int rc, i; s64 now; + mutex_lock(&priv->mgmt_tree->lock); mutex_lock(&priv->fdb_lock); - mutex_lock(&priv->mgmt_lock); mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries; @@ -2414,8 +2414,8 @@ int sja1105_static_config_reload(struct sja1105_private *priv, if (rc < 0) goto out; out: - mutex_unlock(&priv->mgmt_lock); mutex_unlock(&priv->fdb_lock); + mutex_unlock(&priv->mgmt_tree->lock); return rc; } @@ -2668,39 +2668,41 @@ static int sja1105_prechangeupper(struct dsa_switch *ds, int port, return 0; } -static int sja1105_mgmt_xmit(struct dsa_switch *ds, int port, int slot, - struct sk_buff *skb, bool takets) +static int sja1105_mgmt_route_install(struct dsa_port *dp, const u8 *addr, + bool takets, int slot) { - struct sja1105_mgmt_entry mgmt_route = {0}; - struct sja1105_private *priv = ds->priv; - struct ethhdr *hdr; - int timeout = 10; - int rc; - - hdr = eth_hdr(skb); + struct sja1105_mgmt_entry mgmt_route = {}; + struct dsa_switch *ds = dp->ds; + int port = dp->index; - mgmt_route.macaddr = ether_addr_to_u64(hdr->h_dest); + mgmt_route.macaddr = ether_addr_to_u64(addr); mgmt_route.destports = BIT(port); mgmt_route.enfport = 1; mgmt_route.tsreg = 0; - mgmt_route.takets = takets; + /* Only the leaf port takes the TX timestamp, the cascade ports just + * route the packet towards the leaf switch + */ + mgmt_route.takets = dsa_port_is_user(dp) ? takets : false; - rc = sja1105_dynamic_config_write(priv, BLK_IDX_MGMT_ROUTE, - slot, &mgmt_route, true); - if (rc < 0) { - kfree_skb(skb); - return rc; - } + return sja1105_dynamic_config_write(ds->priv, BLK_IDX_MGMT_ROUTE, + slot, &mgmt_route, true); +} - /* Transfer skb to the host port. */ - dsa_enqueue_skb(skb, dsa_to_port(ds, port)->user); +static void sja1105_mgmt_route_poll(struct dsa_port *dp, int slot) +{ + struct sja1105_mgmt_entry mgmt_route = {}; + struct dsa_switch *ds = dp->ds; + struct sja1105_private *priv; + int timeout = 10; + int rc; + + priv = ds->priv; - /* Wait until the switch has processed the frame */ do { rc = sja1105_dynamic_config_read(priv, BLK_IDX_MGMT_ROUTE, slot, &mgmt_route); if (rc < 0) { - dev_err_ratelimited(priv->ds->dev, + dev_err_ratelimited(ds->dev, "failed to poll for mgmt route\n"); continue; } @@ -2720,8 +2722,36 @@ static int sja1105_mgmt_xmit(struct dsa_switch *ds, int port, int slot, */ sja1105_dynamic_config_write(priv, BLK_IDX_MGMT_ROUTE, slot, &mgmt_route, false); - dev_err_ratelimited(priv->ds->dev, "xmit timed out\n"); + dev_err_ratelimited(ds->dev, "xmit timed out\n"); } +} + +static int sja1105_mgmt_xmit(struct dsa_switch *ds, int port, int slot, + struct sk_buff *skb, bool takets) +{ + struct sja1105_mgmt_route_port *route_port; + struct sja1105_private *priv = ds->priv; + struct ethhdr *hdr = eth_hdr(skb); + struct sja1105_mgmt_route *route; + int rc; + + route = priv->mgmt_routes[port]; + + list_for_each_entry(route_port, &route->ports, list) { + rc = sja1105_mgmt_route_install(route_port->dp, hdr->h_dest, + takets, slot); + if (rc) { + kfree_skb(skb); + return rc; + } + } + + /* Transfer skb to the host port. */ + dsa_enqueue_skb(skb, dsa_to_port(ds, port)->user); + + /* Wait until the switches have processed the frame */ + list_for_each_entry(route_port, &route->ports, list) + sja1105_mgmt_route_poll(route_port->dp, slot); return NETDEV_TX_OK; } @@ -2743,7 +2773,7 @@ static void sja1105_port_deferred_xmit(struct kthread_work *work) clone = SJA1105_SKB_CB(skb)->clone; - mutex_lock(&priv->mgmt_lock); + mutex_lock(&priv->mgmt_tree->lock); sja1105_mgmt_xmit(ds, port, 0, skb, !!clone); @@ -2751,7 +2781,7 @@ static void sja1105_port_deferred_xmit(struct kthread_work *work) if (clone) sja1105_ptp_txtstamp_skb(ds, port, clone); - mutex_unlock(&priv->mgmt_lock); + mutex_unlock(&priv->mgmt_tree->lock); kfree(xmit_work); } @@ -3078,6 +3108,165 @@ static int sja1105_port_bridge_flags(struct dsa_switch *ds, int port, return 0; } +static struct sja1105_mgmt_tree *sja1105_mgmt_tree_find(struct dsa_switch *ds) +{ + struct dsa_switch_tree *dst = ds->dst; + struct sja1105_private *priv; + struct dsa_port *dp; + + list_for_each_entry(dp, &dst->ports, list) { + priv = dp->ds->priv; + if (priv->mgmt_tree) + return priv->mgmt_tree; + } + + return NULL; +} + +static struct sja1105_mgmt_tree *sja1105_mgmt_tree_get(struct dsa_switch *ds) +{ + struct sja1105_mgmt_tree *mgmt_tree = sja1105_mgmt_tree_find(ds); + + if (mgmt_tree) { + refcount_inc(&mgmt_tree->refcount); + return mgmt_tree; + } + + mgmt_tree = kzalloc(sizeof(*mgmt_tree), GFP_KERNEL); + if (!mgmt_tree) + return NULL; + + INIT_LIST_HEAD(&mgmt_tree->routes); + refcount_set(&mgmt_tree->refcount, 1); + mutex_init(&mgmt_tree->lock); + + return mgmt_tree; +} + +static void sja1105_mgmt_tree_put(struct sja1105_mgmt_tree *mgmt_tree) +{ + if (!refcount_dec_and_test(&mgmt_tree->refcount)) + return; + + WARN_ON(!list_empty(&mgmt_tree->routes)); + kfree(mgmt_tree); +} + +static void sja1105_mgmt_route_destroy(struct sja1105_mgmt_route *mgmt_route) +{ + struct sja1105_mgmt_route_port *mgmt_route_port, *next; + + list_for_each_entry_safe(mgmt_route_port, next, &mgmt_route->ports, + list) { + list_del(&mgmt_route_port->list); + kfree(mgmt_route_port); + } + + kfree(mgmt_route); +} + +static int sja1105_mgmt_route_create(struct dsa_port *dp) +{ + struct sja1105_mgmt_route_port *mgmt_route_port; + struct sja1105_mgmt_route *mgmt_route; + struct dsa_switch *ds = dp->ds; + struct sja1105_private *priv; + struct dsa_port *upstream_dp; + int upstream, rc; + + priv = ds->priv; + + mgmt_route = kzalloc(sizeof(*mgmt_route), GFP_KERNEL); + if (!mgmt_route) + return -ENOMEM; + + INIT_LIST_HEAD(&mgmt_route->ports); + + priv->mgmt_routes[dp->index] = mgmt_route; + + while (dp) { + mgmt_route_port = kzalloc(sizeof(*mgmt_route_port), GFP_KERNEL); + if (!mgmt_route_port) { + rc = -ENOMEM; + goto err_free_route; + } + + mgmt_route_port->dp = dp; + list_add(&mgmt_route_port->list, &mgmt_route->ports); + + upstream = dsa_upstream_port(dp->ds, dp->index); + upstream_dp = dsa_to_port(dp->ds, upstream); + if (dsa_port_is_cpu(upstream_dp)) + break; + + /* upstream_dp is a cascade port. Jump hop by hop towards the + * CPU port using the dp->link_dp adjacency information. + */ + dp = upstream_dp->link_dp; + } + + list_add_tail(&mgmt_route->list, &priv->mgmt_tree->routes); + + return 0; + +err_free_route: + sja1105_mgmt_route_destroy(mgmt_route); + + return rc; +} + +static int sja1105_mgmt_setup(struct dsa_switch *ds) +{ + struct sja1105_private *priv = ds->priv; + struct dsa_port *dp; + int rc; + + if (priv->info->tag_proto != DSA_TAG_PROTO_SJA1105) + return 0; + + priv->mgmt_tree = sja1105_mgmt_tree_get(ds); + if (!priv->mgmt_tree) + return -ENOMEM; + + priv->mgmt_routes = kcalloc(ds->num_ports, sizeof(*priv->mgmt_routes), + GFP_KERNEL); + if (!priv->mgmt_routes) { + rc = -ENOMEM; + goto err_put_tree; + } + + dsa_switch_for_each_user_port(dp, ds) { + rc = sja1105_mgmt_route_create(dp); + if (rc) + goto err_destroy_routes; + } + + return 0; + +err_destroy_routes: + dsa_switch_for_each_user_port_continue_reverse(dp, ds) + sja1105_mgmt_route_destroy(priv->mgmt_routes[dp->index]); +err_put_tree: + sja1105_mgmt_tree_put(priv->mgmt_tree); + + return rc; +} + +static void sja1105_mgmt_teardown(struct dsa_switch *ds) +{ + struct sja1105_private *priv = ds->priv; + struct dsa_port *dp; + + if (priv->info->tag_proto != DSA_TAG_PROTO_SJA1105) + return; + + dsa_switch_for_each_user_port(dp, ds) + sja1105_mgmt_route_destroy(priv->mgmt_routes[dp->index]); + + kfree(priv->mgmt_routes); + sja1105_mgmt_tree_put(priv->mgmt_tree); +} + /* The programming model for the SJA1105 switch is "all-at-once" via static * configuration tables. Some of these can be dynamically modified at runtime, * but not the xMII mode parameters table. @@ -3095,13 +3284,17 @@ static int sja1105_setup(struct dsa_switch *ds) struct sja1105_private *priv = ds->priv; int rc; + rc = sja1105_mgmt_setup(ds); + if (rc) + return rc; + if (priv->info->disable_microcontroller) { rc = priv->info->disable_microcontroller(priv); if (rc < 0) { dev_err(ds->dev, "Failed to disable microcontroller: %pe\n", ERR_PTR(rc)); - return rc; + goto out_mgmt_teardown; } } @@ -3109,7 +3302,7 @@ static int sja1105_setup(struct dsa_switch *ds) rc = sja1105_static_config_load(priv); if (rc < 0) { dev_err(ds->dev, "Failed to load static config: %d\n", rc); - return rc; + goto out_mgmt_teardown; } /* Configure the CGU (PHY link modes and speeds) */ @@ -3181,6 +3374,8 @@ static int sja1105_setup(struct dsa_switch *ds) sja1105_tas_teardown(ds); out_static_config_free: sja1105_static_config_free(&priv->static_config); +out_mgmt_teardown: + sja1105_mgmt_teardown(ds); return rc; } @@ -3199,6 +3394,7 @@ static void sja1105_teardown(struct dsa_switch *ds) sja1105_flower_teardown(ds); sja1105_tas_teardown(ds); sja1105_static_config_free(&priv->static_config); + sja1105_mgmt_teardown(ds); } static const struct phylink_mac_ops sja1105_phylink_mac_ops = { @@ -3388,7 +3584,6 @@ static int sja1105_probe(struct spi_device *spi) mutex_init(&priv->ptp_data.lock); mutex_init(&priv->dynamic_config_lock); - mutex_init(&priv->mgmt_lock); mutex_init(&priv->fdb_lock); spin_lock_init(&priv->ts_id_lock);