From patchwork Fri Feb 5 13:02:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12071253 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50E61C433E0 for ; Fri, 5 Feb 2021 22:47:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C4EE64FD6 for ; Fri, 5 Feb 2021 22:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231328AbhBEWr2 (ORCPT ); Fri, 5 Feb 2021 17:47:28 -0500 Received: from mail-eopbgr50056.outbound.protection.outlook.com ([40.107.5.56]:25949 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232435AbhBEND4 (ORCPT ); Fri, 5 Feb 2021 08:03:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a/L8XfAKlAA7/LtDGv5cklJ+QVF6HxKuU1iwR8rCDHB+Y3QK+Nsza73sgb9KlX+lCADjhNtPQ8jrypihv7N4A3D33bauyLgCsF3MM5DxKd456tXBtvvHSgfJG3/cXO82VXDb6e5arwJ2GxUBsk7e625d3yLgbVJGLCgqZ+EFTx/1xGncUi1OM80UIIkqpWW8YNCZWipRQ2IXBJoT9Hm66fFv7tD2HSYvjbr2kY8u1++u0i2q1+u27nzdV0gfr2npfiY9iKb6DF1JQ0pooy+evQvh36idfiNEjet4Y67mx8uLi+sz4VC+/oeWhrYKywjstaZgjzB2paNe7CGE2iVyAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Sd2qH3cXEC0nns1qm0IfyyAfe/mCopRCedrtK9XDYZU=; b=SibgqWAaMJmEZw8KilgJWOUdX4RxOSpfW70XeB8dhkNK6nXgogHE8R7/xc1Xe68oHo2E9wUufzEZtdnyaM5YkgBsEiQM/F5EFpWTIUfFj0UBFNymHm7gYgslJCxeewbbL8gw2yea4AvJCWg/nbUvAnw17fzHhZltFXCXCYYFjDoPUGfXboboBSf3yxmD/3R/bokGjhKQE4xtq4CcSLStv+AVkR3FHJmOijuJMcqYcPvP9iVmy3mPJk4u3XhaAL/N86ganqUaI6nNZoxcMhLqwt/euphF7rsOI1b1PAH1CYP2jNnqVDhajSIkTy0jRYNMfJa/4x6HEPChAuI5dGNYcw== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Sd2qH3cXEC0nns1qm0IfyyAfe/mCopRCedrtK9XDYZU=; b=I9yu6elV8ZeCDXyun/fxJoWO54hC1Ec2nbGv21SwZuj6DJBdiDUI/6D41jqSNTOCnzsyE7IBQT/3NVK4u9yeSSTb/97H2dl3vs6IagxPVc4LPNqo15U/3dYK/gaDwKOYwpvJT23tzDJEWRPVXVwsGZGpLCzGcI2PqYeC5sfoQxw= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:02:59 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:02:59 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 01/12] net: mscc: ocelot: rename ocelot_netdevice_port_event to ocelot_netdevice_changeupper Date: Fri, 5 Feb 2021 15:02:29 +0200 Message-Id: <20210205130240.4072854-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:02:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 181a0af9-77cc-430a-a2aa-08d8c9d65ca5 X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SBPXWXr9kI9oZwbmAtQOrdr7x10BqvetX5vUyKDozFyfbmaXFAHZ4lXu6UJBDnIG1lIwyrCP79zopauZ87sBoRX7H2xliyzjXlaADRSMHHAkk4Iu88bX8KO21TMzv7EQaTuhQNQWofqHfxlYVXozfDCP8ch/tmJTOLG5DZbv3V0K1xsl3wYXPXd62TR5tyt6muVlqBOaliruVAWINgJ7n3XD29dm+Qdk2WE2CyyCwE7608BTAWvKgyHSJIQz+quY2mtlZ0WuVS3xFtrXj4F7atjaRotIUnw47D1u3X0A/qpnLyNjqaO6nAqxvKjBhqgjPv2ZIlcEMvbFa7OnwVh/s2wb2I4zmcipbQLHYKJvZFeKXJT473dXws1AxqD+2vJdwGnpKOvNMdoNMBvtPrvWHlQw9HNStgKSwkeA89eEJJJy2ksPxZFTZtMW9yNhdid8ZMnWzBLI/yKORXlQpOgrA0B7hG9F5vUMe8W26MNqwTxxjS2+jioIXbYqVUbbeqCiBSmSCqhHIk+w16vRR6d1G6bCdKP1jKPOSLPureksIkdkYKPlFWHRqA2bfBKwMcNL+nF3lkPNz17UyapOU1veCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: TiCPPg2GC/2DL1TmIdaY6J13zzUafT0x7MviYgtk4Lc+zsDx2iSAGHHdrG2kfqi5mGXn1fCEpMMyDup5ALphIc4zP5RiaqmjrcLT4e8dsfJve83+W+6OXHI2YJp+r/3uTq5/wJezn9Y0G71ZRvGEVE0AixjRbxDcg8AkxmN4hfSs9hfshsjTealS6E6Ay65xZYdQaPVHY1kaUz3DHbSwCZyYd8jQSF+0lnvBgjQ0gc6jZkqcAwyKwc67gO0Ac3iDmLhPAkJLaCk7mkKOW2Jj2C8Un9ApolgkyfwADCq8VfRwauC5ziKOXW01TQIN6FQwLwqRFwi7j+k3X8QfJ7p9BAKGBUamvZ7egUx+wVrxYc6aPkScUz4UofUgjk7sKghVNCp5WH9NpaP8VEFH0H7pkSE7oVWvsjycJHVbgYAW6kE6aQeuJ2sZ9xbd/hcjbgND/N4RbhnQXkYs3jZSvXBWVMHrHbirjGqcIAAVJq5/NLGS5xjTrYGYxhIH6aIc4z+qtnLQePx/eo5fncSCU2HdV72rUvrpnSZDFJy8iWaSDL1W6SDPdQoyGgOHweXIW1+qSHUkDTBjwV4NBdc3JYgqEfiTSr7t7K3FvuiyNODnxvVfT+qbw121CQGjEzlc6LRsnRnjbEs7odg8j+nPlSylHAYC2I3w0YX9E/OhwOOmFFb0rp7w8VTrISwCJ3rPcMhsiOK/5mq5TE3kmhHrxIfy+Wgs5PGWG848jM7lNb6UjSl/WYhu+ZS+fiWux2VrvtlnDwzcGRJGs1fHQkXonuO0ipog5dCicaoGCK2fxqbpGOdFk5eHEqmftB/N4u1yrkbn07kqKQC6RXvy0hnB9ATVwfy/ohjKR8UTOKTjx2G6Q0FyCJBFwPw3FDMQFCVEhaHcRnA7IUKk0HgiZWr4RRhPnBmE5o8WZu3xEz+9sD0MMGTc3swUdky5h1Aba+uQTWezurpwH+vvmZjofxZHxugKoXRFW1DktDiWKhPWuFkHyJddHk8WjI9V4VJya6ErwLVQFgf0MMET9a9RwwaLyhdRHNCecz5iFZQEKElxADR+8dV48UusDKG4yy47zujUcFDLsw/XSiZnDvIAqQxIou4Bj6kNAsxaavV7QNmZP0ov7I6ZEvxq4foQnhI2+PsC8z7kMEIsrsMjSKZkUxnFoxhmX+QTwlsHI7X5gKCUh09fLvlm0RONDQ/P0Rxy4sJOsn9JQc5wd2YrENDdsZ+fon0M3WjGigbpc1p3RLwHd9oR/c3QQ/14T9JwhVYf1+AIZDRxraYyE1lfIR7mG7MJP1LVz/Ai3DJ2r8stnElwz483AZkrS870Fnzp5mOft3/JJta/ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 181a0af9-77cc-430a-a2aa-08d8c9d65ca5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:02:59.0436 (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: O1U84zgbkLPrTqGY+IHC7c+2HY4Fi6yp5pVDveP2K6vW8brNGhtmh9AlJ9ZLN/InPXaAB+AVjs+tFNNa0jWAOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org ocelot_netdevice_port_event treats a single event, NETDEV_CHANGEUPPER. So we can remove the check for the type of event, and rename the function to be more suggestive, since there already is a function with a very similar name of ocelot_netdevice_event. Signed-off-by: Vladimir Oltean --- Changes in v3: None. Changes in v2: Fixed build by removing the "event" argument of ocelot_netdevice_changeupper. drivers/net/ethernet/mscc/ocelot_net.c | 59 ++++++++++++-------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index e6b33d9df184..c8106124f134 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1110,9 +1110,8 @@ static int ocelot_port_obj_del(struct net_device *dev, return ret; } -static int ocelot_netdevice_port_event(struct net_device *dev, - unsigned long event, - struct netdev_notifier_changeupper_info *info) +static int ocelot_netdevice_changeupper(struct net_device *dev, + struct netdev_notifier_changeupper_info *info) { struct ocelot_port_private *priv = netdev_priv(dev); struct ocelot_port *ocelot_port = &priv->port; @@ -1120,28 +1119,22 @@ static int ocelot_netdevice_port_event(struct net_device *dev, int port = priv->chip_port; int err = 0; - switch (event) { - case NETDEV_CHANGEUPPER: - if (netif_is_bridge_master(info->upper_dev)) { - if (info->linking) { - err = ocelot_port_bridge_join(ocelot, port, - info->upper_dev); - } else { - err = ocelot_port_bridge_leave(ocelot, port, - info->upper_dev); - } - } - if (netif_is_lag_master(info->upper_dev)) { - if (info->linking) - err = ocelot_port_lag_join(ocelot, port, - info->upper_dev); - else - ocelot_port_lag_leave(ocelot, port, + if (netif_is_bridge_master(info->upper_dev)) { + if (info->linking) { + err = ocelot_port_bridge_join(ocelot, port, info->upper_dev); + } else { + err = ocelot_port_bridge_leave(ocelot, port, + info->upper_dev); } - break; - default: - break; + } + if (netif_is_lag_master(info->upper_dev)) { + if (info->linking) + err = ocelot_port_lag_join(ocelot, port, + info->upper_dev); + else + ocelot_port_lag_leave(ocelot, port, + info->upper_dev); } return err; @@ -1170,17 +1163,19 @@ static int ocelot_netdevice_event(struct notifier_block *unused, } } - if (netif_is_lag_master(dev)) { - struct net_device *slave; - struct list_head *iter; + if (event == NETDEV_CHANGEUPPER) { + if (netif_is_lag_master(dev)) { + struct net_device *slave; + struct list_head *iter; - netdev_for_each_lower_dev(dev, slave, iter) { - ret = ocelot_netdevice_port_event(slave, event, info); - if (ret) - goto notify; + netdev_for_each_lower_dev(dev, slave, iter) { + ret = ocelot_netdevice_changeupper(slave, info); + if (ret) + goto notify; + } + } else { + ret = ocelot_netdevice_changeupper(dev, info); } - } else { - ret = ocelot_netdevice_port_event(dev, event, info); } notify: From patchwork Fri Feb 5 13:02:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12071251 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64FE3C433E9 for ; Fri, 5 Feb 2021 22:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23C8864FD6 for ; Fri, 5 Feb 2021 22:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233015AbhBEWqr (ORCPT ); Fri, 5 Feb 2021 17:46:47 -0500 Received: from mail-eopbgr50071.outbound.protection.outlook.com ([40.107.5.71]:21318 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232466AbhBENEB (ORCPT ); Fri, 5 Feb 2021 08:04:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VQSz+CJQ0bgbgzjumd23Pr+NjYndTwIPGi9nml2lFY4PfHxceqLJoGzU7bl1q/c0y1zc/k2/TftjfVVAokWL2Hzi7eFXyj60qXFnqLfPCTacqFn71q4tQmbySBuBnaCi2BLD27a1Vr+np2GG18tAN2lNnfL0uyYWhwVtifOQ0JuPFILSsLVMji+lkKh2Up7OkqJrCCBndBb/M0auOxwsOZD8z22g9oN2J0fVX8igm3/N+UlAIT+flK1G31p2tFqZg24DABm167MVIiL4d9bSGxZRwA8DR/NPOqkdLDXosXblG6V1VFLks9P42g+ExLotLzqkoNibwZrGgHaP0C1TRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lp+AGvLsLN6tC9hk0uH+apufGoxmvGjlqq9D0ZDxIFY=; b=g/x55z+iGW/KVO7FpTFbykPcPUVDy2bSG7O1xVFj3kMMtpk90HkIk3VPcwWWZGbzxKt7EL1GISv3QKwVe0ZxgOTso9lcEtO2pp71/k1FbhvS+nuEft7JPI7LysLHNSsVvPXiluELVCtUI3j94vH1i2tvfgZH78PgIZxLZkp25g7Gfd6K4wr+5YRcDH4V5KCdQmfKeDES6vnWbGM/Dx2FqvifCikC9IAtPiYETDu3x7pBOR9c3DlNlIGeNRMV65tIAvRuDAdUcwKL60lqS8HXuwo5znZeaWb8f1vMJDKD3mWEViD6YlGXzhXUopCr2vtUBO7xPp97RXchZCBDML842A== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lp+AGvLsLN6tC9hk0uH+apufGoxmvGjlqq9D0ZDxIFY=; b=NvV8sal47NcGRL0nrqtTSwIUHuoqe7QcqFSXXQgUtP7Bhpwg6E6374IPKhbjppdnKU3fKfd5S/FUHeBnonwAUJ9+U8ZtixP7tVzf3nAXAXju+cAyJt1ObeKJ71QvZb4Yt2v1V4WCnW285vuCoQQFHlZVRnVK3xZo3k2FmHPKhXs= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:02:59 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:02:59 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 02/12] net: mscc: ocelot: use a switch-case statement in ocelot_netdevice_event Date: Fri, 5 Feb 2021 15:02:30 +0200 Message-Id: <20210205130240.4072854-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:02:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f1d57f0a-4f06-438c-1880-08d8c9d65d17 X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TgFurUlPAj3pL34FFLic0OLa/Yt/k0QlbwggKh2Z0ngcNpKv8QhjduONGfS+B4NCCXJp4+mel+xC/ILkMyprk2I4xfHTpGkmU6EU6snxvIhSyzODT3pEBCiXizXZtwiM1mTKN55GmJs2hZlXTZfd88/2sCSsoiOSbctYMNJMEGlLduy4ExU4ve38i14Dl1dVqre1y8udwMQ4KhCmicxMIO+slKiMMT0qIu1Zyt9op6O7mC1IKXQ3RapoYem1Y/rMNyRTfNNW9yfquIshhEqo126YjsMKW7UfRK0ZZhYLR3FXI+0KCtXhHhGWxAzEqm/Z/d8tQgQEVfGq+38+GIEb+IB3WFN6jUViIKCZ1Be+zdEQ+Tf1SATnXl5/XfQbKov9aHKL2sd00BXh9AXFa34gkTv1QR3YRemdMXhV0LXVnwRbWnYd2NTIc/UE+1P4yjKMOebCb3rQaMLh3Um61VlnXKXJWObd+WvcuuMmSOd8g95YcncuyFYdfi0ezXI0NyQpnCWpeiZMQu+boe99lcTRL+iKEaQ9HfGxK6tKzmOf2yorL4/4Vem95WX6BP52Z0U2fftOjqlusXlyhFB2fmlUAw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 6YPYZn06XCTuEV/K68RP2ScFFvGWCF4A00F0hwCiDukYW71bxq2OF591eIsNOtRidFcv7ySjAH7nBpbLWjN05MDQvDhcmVb3YycmhImfQjMyFVt2Nkn+ohG2agSd31hKpXZJxoC70xYL86P4nArreFupEjTS75yx5SfFt8hVGf+wYRjN6XY+RgrQdmRr58feaqk+t4n/lVyjSAxQ5Qk6NlHtjfNG7ZZ8o7xaOo3R+RK0DAAjCN7OsO3Py8eqc/6RUhymtco24JsmMMupggfKKtTojQ8lIE3XTGGrYwE+PQHBGHq01Fwq8RSeUzFa3BQIDGfgjhdQ6FYM/6OHGKlgbZD6Fpb7zOU8bjQBI6AkplEuzAkML+WGcXAJr2Hv5fNOZXVnislfhjlMfkdQ1ZgNThNhmU8ZWVFt+4ndBVCRcitFXG0U+2DQZiGVTqdQURk2Trk9kUuf7w7o6fyJF8HcHbj4/+Wg0L8Xbvi1qIhL0YG+hikRM3wb3K6dPGQzkH+zFPCTWsLROevN/xDRUrI/r3ssa3ZGrmrlrcgJPq40/3ivkPSaRuCrsJW0me9NSUq6qkV50Qj9AVzs+uzmUaciUZ6to4fMaH9ZD/uJS42XEz5fFNusVUAuM+aVOWqB0X2M9dpv4Cq8EcwJvvFbrlk+5tey5pa+FbGzCUlLSciJXkGTwl5I41VzjS+LVm81BxyuD5XK66FFds9wrAs2Ok0JJuAq28FwDZay1Ip4/BH9oj/fVbu691mnl0g9Um88vyX8/LsoGi5eU95ExtCQXcrJVTlh8lQq00KmwmAIIC/CeTuRwGz5/+41DMr+PY9PSYWw/25eVDU5VuW+BInLi33Y8A9fvs/Q99+NNL8qruC8kBbAmkHFEKsb98ygXZQi/TwvQgeFiNCgbVzvE+maysy47lhLhPDJbyxVTp1LLJ7fcMpb5W4RbURvQQ6bNLkpz8tU88wCAkIn46OyB7cNQuN89YvcTSo5tGEYcxwtt5DIDfKgfWg81D8OvViCCDjF2zmo5ayXvRul0FSPG6qkelHz6Dmow9k++Y282zOBdqTo4QARgORt3e/vTB5pei4HiN2d7ZV3kNrhkuZ/T9PVVvTj3D4FP3THyHyKC3Gu+cMCrl7ZqRBbw6i3r4MGmmMwHpPeoHYBCfw3JGbPnoqUPBO73W4IDesssObVet0m8LB+3shEvmhl3SP7d6uiwmxbGUJ6uEPUi/V5nk/uTvMZq/g8oikK8hsMbJfPhw7IwzI9CiP1/0Xp8aFCGBKncu2uPmJorAnjrIO3TLp183y3UB4LfrrwUfabwegdlQndjLbYyYD00Hc6sLlWqKrHMMusS8W5 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1d57f0a-4f06-438c-1880-08d8c9d65d17 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:02:59.7812 (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: oOG/lyv6mFZTqPM86JIQDzcuODHbZ1IpwK9vgH2B3uyINfNvMHE1lvL0JmQOQQTAVl9AckdKVXZiEUZti8A0Rg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Make ocelot's net device event handler more streamlined by structuring it in a similar way with others. The inspiration here was dsa_slave_netdevice_event. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot_net.c | 68 +++++++++++++++++--------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index c8106124f134..ec68cf644522 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1137,49 +1137,71 @@ static int ocelot_netdevice_changeupper(struct net_device *dev, info->upper_dev); } - return err; + return notifier_from_errno(err); +} + +static int +ocelot_netdevice_lag_changeupper(struct net_device *dev, + struct netdev_notifier_changeupper_info *info) +{ + struct net_device *lower; + struct list_head *iter; + int err = NOTIFY_DONE; + + netdev_for_each_lower_dev(dev, lower, iter) { + err = ocelot_netdevice_changeupper(lower, info); + if (err) + return notifier_from_errno(err); + } + + return NOTIFY_DONE; } static int ocelot_netdevice_event(struct notifier_block *unused, unsigned long event, void *ptr) { - struct netdev_notifier_changeupper_info *info = ptr; struct net_device *dev = netdev_notifier_info_to_dev(ptr); - int ret = 0; - if (event == NETDEV_PRECHANGEUPPER && - ocelot_netdevice_dev_check(dev) && - netif_is_lag_master(info->upper_dev)) { - struct netdev_lag_upper_info *lag_upper_info = info->upper_info; + switch (event) { + case NETDEV_PRECHANGEUPPER: { + struct netdev_notifier_changeupper_info *info = ptr; + struct netdev_lag_upper_info *lag_upper_info; struct netlink_ext_ack *extack; + if (!ocelot_netdevice_dev_check(dev)) + break; + + if (!netif_is_lag_master(info->upper_dev)) + break; + + lag_upper_info = info->upper_info; + if (lag_upper_info && lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { extack = netdev_notifier_info_to_extack(&info->info); NL_SET_ERR_MSG_MOD(extack, "LAG device using unsupported Tx type"); - ret = -EINVAL; - goto notify; + return notifier_from_errno(-EINVAL); } + + break; } + case NETDEV_CHANGEUPPER: { + struct netdev_notifier_changeupper_info *info = ptr; - if (event == NETDEV_CHANGEUPPER) { - if (netif_is_lag_master(dev)) { - struct net_device *slave; - struct list_head *iter; + if (ocelot_netdevice_dev_check(dev)) + return ocelot_netdevice_changeupper(dev, info); - netdev_for_each_lower_dev(dev, slave, iter) { - ret = ocelot_netdevice_changeupper(slave, info); - if (ret) - goto notify; - } - } else { - ret = ocelot_netdevice_changeupper(dev, info); - } + if (netif_is_lag_master(dev)) + return ocelot_netdevice_lag_changeupper(dev, info); + + break; + } + default: + break; } -notify: - return notifier_from_errno(ret); + return NOTIFY_DONE; } struct notifier_block ocelot_netdevice_nb __read_mostly = { From patchwork Fri Feb 5 13:02:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12071241 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94C5BC433E0 for ; Fri, 5 Feb 2021 22:46:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BF5D64FD6 for ; Fri, 5 Feb 2021 22:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233129AbhBEWpu (ORCPT ); Fri, 5 Feb 2021 17:45:50 -0500 Received: from mail-eopbgr50086.outbound.protection.outlook.com ([40.107.5.86]:61168 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232468AbhBENFP (ORCPT ); Fri, 5 Feb 2021 08:05:15 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mLaEidR2l2abGoE6xaIXBdpqI26NnXQLukwdmoVwSLWQp+z3Ieev9M0b2fql5XtiCFvI6WlpdNg7Gv3rFtwnMwuAc15boNqFEPSY0H2w4EPYE9pW6JT49sFFvRdvevRIQnXyRowwcBumACUVRZJaFV1EFkj8FmAPd/NEDlpj6l/WNYWYuGY/mbodZYTlaBfIBmi3vi0TC3FCD7ecxlmQ6horC2oP+sdnOVRud7SvLYl92wptYL/1UzAE+QFX1WuZyy0vj16w6RuhzlGvEMtPe8QMM+rCXgc7rwVf/6Re1utnAURfDmWVeemoP3/hUsP3SZwtFDVC7GCM/2225h5h6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/Jt+k4VIz/Okps95xWshPAH4d7l0kk+BjIgs6DRTXoA=; b=Fmk4wvOvF7IdtcJfUvmI9mpqVYiT/gGjykD0ggxfD1bnOJEKPq5PBP1nVaZsfU/HMCS125FP26Rb6MhaQjTPHQI1RUfLtZ7O/BCgSQKAifvMaSDwqVxEdtcJ4ztT64ni2Y77dH2KcM5hbheg8AoQo0ygw+sARkbYQ+l03bowgcQADgL5d68A/OviZikoByiI1mUaHI53P7vCsIXsEaJvf8UWnD2f82EWzEH6o1d7uZjesQEWy5NsmUe9SJvlc4yxlHnYdYu+y9bap/Wpkbi0rJxwrx42kUZ1AtKMlfl+3T3Pj5lZABS5gxdJnQIcBqbjM0uEezFK5tWXg7nrGHlsTg== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/Jt+k4VIz/Okps95xWshPAH4d7l0kk+BjIgs6DRTXoA=; b=ozxsCdx6c8cF75CglG7W9yhHix9onVUcNbRfLZlyhmmhNCIrkdFA0Qxpuz7zjSP7EDAdNjFIIURi8JMz7EEvpDRGjQveY2X+Mu7NiqxWxfxDyKohVzSd5VoOqNjqPomIeQ0rRS+pFeUcW0KyDqe6eT2XAzrLHFbfwzto6iEZzRI= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:03:00 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:03:00 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 03/12] net: mscc: ocelot: don't refuse bonding interfaces we can't offload Date: Fri, 5 Feb 2021 15:02:31 +0200 Message-Id: <20210205130240.4072854-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:03:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9afc0e3c-74d1-4568-39d4-08d8c9d65da5 X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i682uDElnpVfz+i9HQTNqyb8X99IqpICgGVDMnpFGbu6OjJUFFN3uEr7ac+Ms5Tt+NY2JLr9hIeKXgU4ITgAXy6x9NEh/BPl993NkAl9O0pp3bB51AAHFRSiFhf6GZolq6CvwiiHyQ9LGOK3c8tVSaRpz4SQdSB4kzqNxmEFZUL/smKTnfkASNnBMMnLYDU3xDoyuiGiYRW6xlv0ydOqL/6i+3d9gb/r/8gGgER2IEELwAKhO3uVr1wPlNtTyxsbSIsQj9u00CN5Wo2i4mMxmjcE8ToSF5bLhIXFoT7FrEPSVQbmqQmaFIx8NlATRrteov9M5M8dhFOydWVYyaE+BP82X92MHEJ5uquwU5TBRmWVFzEzqAnHtC6T5fLcu/yvvmgVvNtfP2cULCi41yiyTZJtT9zYc5xxu0F1PaFyA9Vs4n8y2LJsvg/4OzZ+JviIZnlSAlgYPA6SmoI25tgQ/i8CpeRhZbfRCLepsjR7qlZxO/UFiSUSa+tezedqgE0S9EUXmYCNchXVA1xiZRTPLNzjmOv46gcMQarurTgj6dPS3mfEXK/dF753DU4OSrN8IXcXsvBJwmQHjSwkzNkFyA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Qp1wIuT1uTYp7q4k8UmQKlQ7OJk/0QwTQw5uw10A9J4Tlcr2TodrvQG7tWuWcYAbJwuSalMH1ShdK3rqGSLwc5KYYU998NpsEfLR1OFwrpvSogD1734bTqx7DiPmSagKAL1+mLbMnxhcD91Yzv4sMPJTLiyHHd6eTGDF7Bp7s9YBRR2Vn8e+8lD4Ghx5itVEKJIlPfeawaHaIyhrglw4PBKA8L9Z/+i8zLcYUmN68aZ28qynvVDnRe3GfUDkqEVfvIoyajTkLZZsGrFWrvTXZommwBqRR7FakibD3g0mNqQL2T+q7DV/mI71mtqafUUU15zRJGSfc7DOn0o8vhpYX+XjMmARAar9oO/xLB4H50MvjO2iHtRL52gWaK5uSZyxfPJrSU9oBspD4T2b6lKpObFLSKwLJwvsojshgb72jtaf+EP8mTe1vRweDvt9S3D3/0uKGoMDacHU5jCupL/HyyUt20WzScsIgNKu7Tat2UJsexERsVDIiEsQ/MdvOQBpJTMc8lFVtSxqrgQc3XIEwPQrhcIIdwo8EqCYohtJrFFbk382vgUluBk3uOQjvuxDTmNq9GuACYyIhk+yrLAJH7gT699D73QNgD2Tt3AmGGvWJNz7ufeTtegJsuDR1Q3eOtTjrhhRwJAGHFixx7oGNH1RemgLPSaE8DFFwwe0KOLbwna8gf8fugTYF+6ln2azQnMN6OucReVidkOCgYHZB8iAb2Rb1V+z4eor7rpZGwVphsHBRcy45PK+7/8Md4566ZCzaVvtXifBikTr1MPO0LpJ2fpCi7GTL8tk/xSXPa7z1m/BVw7r8sWwlq9r+uqeyPNvj1D9UK7T+KguQ0Y8/HwRLV6khdwsn7s9yoqFewAAR2TSCmhbtvoJjqRmtzaJ4uPXRH4xNBfkNUJlej1jUX/qmC6D/bUbTrmKsTobm+wqULh5vo9A4+B45iRW8Nv7RsLEyMFHLFs1AuYi3NanvPtq3PUSinypYj1nWfXwdQ5ZbsCKpNWvw1DD4aNXK1DAr5l154Nbhj43olS/nUkL+U3VjglZnqScZG3qNfQxUXxvYb0d8hzj3R2vlI7sNhoWKTtzQqPNOglbqo1EFIGexNI+K61FMj2UxvMU/sMsDYrpWXplM/386IYlg+N21dscCZFfub44J0UO3uLqZ6iVcg5ETDEKI3EF7fvoM024naRrhvnZaUpsLmeOZ80BdNBNGgczQ7xkss9bS0MgLABIPaiOSOMlvI9eHW6NBy96qDCb8LWU2l0pmGHo1Xo53irsPYJ3L4R3hYcd4a3xIkermKX4RO3dkePNIQfEejoraSvq4W3XbGWT6Ptp8GMz11sT X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9afc0e3c-74d1-4568-39d4-08d8c9d65da5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:03:00.6217 (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: kYIE3dJOl241JKjuoGrM9TYKk14vcuFoQNtsSQifZhfoTT1H/TENZsHXX3acitlCVozrMmh6evBVWk2Ev6GVWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since switchdev/DSA exposes network interfaces that fulfill many of the same user space expectations that dedicated NICs do, it makes sense to not deny bonding interfaces with a bonding policy that we cannot offload, but instead allow the bonding driver to select the egress interface in software. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- Changes in v3: None. Changes in v2: Addressed Alex's feedback: > This changes the return value in case of error, I'm not sure how > important this is. by keeping the return code of notifier_from_errno(-EINVAL) drivers/net/ethernet/mscc/ocelot.c | 6 ++++- drivers/net/ethernet/mscc/ocelot.h | 3 ++- drivers/net/ethernet/mscc/ocelot_net.c | 36 +++++++------------------- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 5f21799ad85b..33274d4fc5af 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1316,12 +1316,16 @@ static void ocelot_setup_lag(struct ocelot *ocelot, int lag) } int ocelot_port_lag_join(struct ocelot *ocelot, int port, - struct net_device *bond) + struct net_device *bond, + struct netdev_lag_upper_info *info) { struct net_device *ndev; u32 bond_mask = 0; int lag, lp; + if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH) + return -EOPNOTSUPP; + rcu_read_lock(); for_each_netdev_in_bond_rcu(bond, ndev) { struct ocelot_port_private *priv = netdev_priv(ndev); diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index 76b8d8ce3b48..12dc74453076 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -110,7 +110,8 @@ int ocelot_mact_learn(struct ocelot *ocelot, int port, int ocelot_mact_forget(struct ocelot *ocelot, const unsigned char mac[ETH_ALEN], unsigned int vid); int ocelot_port_lag_join(struct ocelot *ocelot, int port, - struct net_device *bond); + struct net_device *bond, + struct netdev_lag_upper_info *info); void ocelot_port_lag_leave(struct ocelot *ocelot, int port, struct net_device *bond); struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port); diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index ec68cf644522..0a4de949f4d9 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1129,12 +1129,19 @@ static int ocelot_netdevice_changeupper(struct net_device *dev, } } if (netif_is_lag_master(info->upper_dev)) { - if (info->linking) + if (info->linking) { err = ocelot_port_lag_join(ocelot, port, - info->upper_dev); - else + info->upper_dev, + info->upper_info); + if (err == -EOPNOTSUPP) { + NL_SET_ERR_MSG_MOD(info->info.extack, + "Offloading not supported"); + err = 0; + } + } else { ocelot_port_lag_leave(ocelot, port, info->upper_dev); + } } return notifier_from_errno(err); @@ -1163,29 +1170,6 @@ static int ocelot_netdevice_event(struct notifier_block *unused, struct net_device *dev = netdev_notifier_info_to_dev(ptr); switch (event) { - case NETDEV_PRECHANGEUPPER: { - struct netdev_notifier_changeupper_info *info = ptr; - struct netdev_lag_upper_info *lag_upper_info; - struct netlink_ext_ack *extack; - - if (!ocelot_netdevice_dev_check(dev)) - break; - - if (!netif_is_lag_master(info->upper_dev)) - break; - - lag_upper_info = info->upper_info; - - if (lag_upper_info && - lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { - extack = netdev_notifier_info_to_extack(&info->info); - NL_SET_ERR_MSG_MOD(extack, "LAG device using unsupported Tx type"); - - return notifier_from_errno(-EINVAL); - } - - break; - } case NETDEV_CHANGEUPPER: { struct netdev_notifier_changeupper_info *info = ptr; From patchwork Fri Feb 5 13:02:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12070089 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDCF0C433DB for ; Fri, 5 Feb 2021 13:08:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DEA964F3A for ; Fri, 5 Feb 2021 13:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbhBENIV (ORCPT ); Fri, 5 Feb 2021 08:08:21 -0500 Received: from mail-eopbgr50065.outbound.protection.outlook.com ([40.107.5.65]:47758 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232250AbhBENFP (ORCPT ); Fri, 5 Feb 2021 08:05:15 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KnzTdPjJTxODIpzBf4aBZThXNCSJDLhfi+Tn8DhcP8ByMKNEGwLpGDpo1fkeUYMyx+5lZPaMdTzPrdGEKuPEaAbuc+Rf9x4pvGbxHGWalTXwN3AKM8m5JFXvnHpJuMIG1GYgXQibSqV/MaLu7xOsxUf6FnHEb0xyOs2x3F2NSv6q67A0rR0BY5NNzRakjGmk6hPLePS1wwZ2kkgliLk+sZcShxsCDPD+5yJeTJFOPcM65g+Y5XAgPX8GVS9dQ3xc6UvWkY+uewr3q+cEATK/QfuarofbgB0zRg+JYh5d2tDGhJGbpFlM0dUAQGfUuWPrPJSEfk4Uh2x+a0poR+lYxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yDCG90MMChzWmWulHNdfSxFF9fCb078nXp5zBwRuJwI=; b=LvykAnhHO1gCuKh6RfYj/b6zv/gnaTsRMhBhhpSm7EH351zC62xyi9+37Mz7JRrYUYefRCGO0J5V4F4kHF2VVq+DkLZSRfAZiPVbx6NY5KupcdrYoUJ43qOWvGMrFzTl/V2qGamCqT4RHnG5IW1dX0pIZGAQK1B2XA47D5RjD1QqPC9ywi2jIZHoX/BcPHQ1s8vNKZ+dVC3Xu2Fyl3s78fuQtCXLTqD38b6WRzX8963juT8T6BCzH2KTPBIXRZsMCXH9FRBkthOtq84cuD88gvx8wIGE7gqPAw/aI1fnrqBPGWAqeATXfpTacCAYiYpjqgn6KTTQvwAWvyWoh0VLKg== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yDCG90MMChzWmWulHNdfSxFF9fCb078nXp5zBwRuJwI=; b=m+ToxpsLRW4nMSU6VByuhLsQmaeem5dqJNagYcMbxEl0j56Kr85Y4+uMsnpEEeuGFlzCL41gMnnh+KMBLDxvTKfhyssKHLr1r3G8EY+dVqLVmTRr1Dq0JJi7rOG+nbrC6sIBgg4lOU/65WTn0oQfqvfBC79wZxedfw0srg+e+RQ= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:03:01 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:03:01 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 04/12] net: mscc: ocelot: use ipv6 in the aggregation code Date: Fri, 5 Feb 2021 15:02:32 +0200 Message-Id: <20210205130240.4072854-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:03:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 81b9d497-b79e-490c-6f01-08d8c9d65e10 X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T1RExAc4xAjfVTYoVCXneyvfnzTUaHQEMf3ego1Sc27ApdV/0NZR2DXb8oiodfTu/DOI5OQZRJDIvPVIAPKugfoVNjo2QgU7RSzoaa2V0ra4Z5OVaT9eZejnFatKfqCg06WwrQWHahUqKrml/sKpfMAiw1Abu1BKTLc0qXVDX5d/hr4XzM0H9DhX1cai5gEwDIIanQQ4JaSZc8kiQwvxmJC/Y9FZ65m3wskCFmr9qgy5KNDczs5QtKvcY/5gJ+NrvOWtRiYwHz6iKWQPjM4ekyKv+JqgOelqXZOvahKyfGyXFZbmxIxMkBg9Ii2ohHuhlWOvYITo3OMI/RKzq5Y+k6GdptCXIN8wTTHIxzSV4CF/jdvdYXoTnITqP6iXtVcYnUyDIrlPQSr3+hMLNNsJ9uWh6E4VHGN+j06J8/7mp6nhWnHq90BePbyPH1bo5wSiCzBwrT8aPt6Yno2zd9fmWJcE2Lvs7rF4GyEtistL/Wr+5cGWl0C5w4GzUTcAltulPUL29Rn+K+WxxqlZQZHqrTSKM8isfIVh/KfxGdnkt5enu0hvABmaNyfm/VumYlSCZIZhzO5ZrM4I+w80qBnPJg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: c3EvPnT639tWn2g2PW45/2XMNuI/CjZ2oWgVfM3YmEK9cGlVef8byhEjGMa9rYiRlrOAZC66o3WufUKc9bNlQwz25sWyYMGHSYQDa++pivIMv1Iy0cfVs2Jr4LmMs8RzJD1zV8X1ZiADvldWdC9nYRFHLtBDOXEPtffmtJcYQgZ7DGFiULZmLb1mlYE7A8q4MJ8bveSRrmFkP1TUwPrXvJeYcWNandyxyl83a6FarCVlyytFVO/qFbTxsj6uiGCs6TUZGxk4SX4QUXTmkXUpjRkZAOcrR+zpwMVJm6CpSijxYgCaEnnI8GecdCb79nnhR9yvJxfC9TITxG5vr4PQC04rwc32nUP2FnIdTml4cSvkHSW7U50LVxZ8E+LUh3gP3JCsmO+MKmSOXs1MUOrzAC7N+FAn2dkAGd9HoTWK8c0Uzhn2+0KVHT5P/Yrtx+vpzqGg3zHtb/wG03DH/1iMEvGeoW7Z84XO/YZSzVFjiQN6h83r+V79wkhxF6Iq/18qhyajc7shC7mU8LdD23+TP4ZTXey/Fwmmznv7P/osMdxJtrsnny0RMLT4OwvxWNocicNWoRTCMz78X00z/V/MW4C9J+s98m5hIDvHOYUiR31EDv6tQ/FxVfCM8K0ERHbvByk5gU2EYi4PkrlMKpt6Jhqse0sRYs2TEuJhOkE75eiwJezYtEDPttzssJh/Th4/wR7UWrrfhKDdAW2dNgj2EnwhwlSnYCUnBN9eXSWT0YQ0mB3lB2cuH2oolg2RdfcwgXlpGLu7wMiG8haW/TLOmnUFWXbMxRbqZh118gTLVWjdZDrYTyLeOOmRCmdgmR9cTn8jBnnecZ7jtrKmGU6e/JRScNsd0I2B3n3zgApix5jN0WHo7KudJG6jgWeRWAAbncGJ6mCtV4A4MR/4toEJAcuvkzuv1i/6LcxvJHxSiRizP2HboiwzRJzheIPWgKOvDpdBPX9LqlYNibVTb/Ko1Oe/lZpFLYlIjq1rA2CBHW92YW/AywBTdDZInAWkHKPfE5UW3JIY9f7QxAwy3HI1xTL4ioHot+HmchwYoJNLDBFL4CtV2auWYDN/qLS075EPxQdHPxOeTYZmEeMsvHKw+hlGmP1mg2FzYg/bnN/yw47rnJL2Xj4F0e+ZNGzV964JkJVVZdjTPokzqDKU8iZ4q8dfAmrY+n8CvSStgPWTA3QHm7ERgVHvhlISbub8Pk/bvoKf/2U2qoVfXRVrV8cwNNhR9QXnqFaoTKK1rNBdEBqzbtmDNSNNpSZfogQaZYWR0KbQjrOpWD7hGBCLio45O+q5IhNgxyaz/4NbTA3gCV4BbYGlrWlmmQoBm4Zk/KWO X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81b9d497-b79e-490c-6f01-08d8c9d65e10 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:03:01.3193 (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: I7vidqnx2v85RL3+9NVov3g5JGu1IPIivADXi/MAqvuu/WKw1wnj/A8OUZkhoSh1ALNzwAfJgLfdynmZnQ4qoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org IPv6 header information is not currently part of the entropy source for the 4-bit aggregation code used for LAG offload, even though it could be. The hardware reference manual says about these fields: ANA::AGGR_CFG.AC_IP6_TCPUDP_PORT_ENA Use IPv6 TCP/UDP port when calculating aggregation code. Configure identically for all ports. Recommended value is 1. ANA::AGGR_CFG.AC_IP6_FLOW_LBL_ENA Use IPv6 flow label when calculating AC. Configure identically for all ports. Recommended value is 1. Integration with the xmit_hash_policy of the bonding interface is TBD. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- Changes in v3: None. Changes in v2: None. drivers/net/ethernet/mscc/ocelot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 33274d4fc5af..ef3f10f1e54f 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1615,7 +1615,10 @@ int ocelot_init(struct ocelot *ocelot) ocelot_write(ocelot, ANA_AGGR_CFG_AC_SMAC_ENA | ANA_AGGR_CFG_AC_DMAC_ENA | ANA_AGGR_CFG_AC_IP4_SIPDIP_ENA | - ANA_AGGR_CFG_AC_IP4_TCPUDP_ENA, ANA_AGGR_CFG); + ANA_AGGR_CFG_AC_IP4_TCPUDP_ENA | + ANA_AGGR_CFG_AC_IP6_FLOW_LBL_ENA | + ANA_AGGR_CFG_AC_IP6_TCPUDP_ENA, + ANA_AGGR_CFG); /* Set MAC age time to default value. The entry is aged after * 2*AGE_PERIOD From patchwork Fri Feb 5 13:02:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12071231 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98945C433DB for ; Fri, 5 Feb 2021 22:43:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64B7464FEB for ; Fri, 5 Feb 2021 22:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232108AbhBEWnN (ORCPT ); Fri, 5 Feb 2021 17:43:13 -0500 Received: from mail-eopbgr50062.outbound.protection.outlook.com ([40.107.5.62]:3953 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232470AbhBENGJ (ORCPT ); Fri, 5 Feb 2021 08:06:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jS7mcMYjs48DJUubfHa9eoqoOcfm0pgbJvDOUqgSowiPbUqPqzYaseJJZrc86gm69LiQUVD1bk9Hk0mVFAysKTR+zU+aCGLHPcqynd94CIgNI15GL4IIzUMDhSgVnusy8rNAmSXbGEtqLJ8Spj5BGX/+hY8sweXnoO0ktJJvJawmH86ZX9PSNBOvaxFDQHjTozMmYM733mgM7NjmC++VXJqW1LNEekLPxQX955jwyYZHuXgg0G9YeA8X4uWzog5wlz/plGAh31ZSb7VjxcyTN5tV/lskiOaqoEIYPdBE8+TM0LgLMdN4ge4J4LUVQkgzw2qj6xXvzRNTT3SU5RFhZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Pe6McAGWClnSbrANbFnBwZDrpMnUa0RZD/lgH2I/Fw=; b=UHwsEC0IlI9thV7tuvU7AfYxR3ov2k17JtznzIb+23ddT1d5avVUKIQLpD/g9BpxH4ovsYwxdKM+ihHJZMiR4VO2CY5s7mSTpDTmSEDqIlPG8R5j35H2kzwF/Uj9fJP+0K9MMSIeuCDcR29Yz2cXjTOgWMU5IxOAJCeMXHvXK3+QUVqExYekN51jtcO7nFnjx/vcpa35JfABp4S8hDMNC7GTPN9SYzda6MAQ4+ZRvQMzaYghZUmUXGnUXHTzhUO7c6NkEcMCoUt23LWw5/B+KSMwYuNH5gu9BbwE1/jrq8GvqljgoSHM7T/8kdVCdnbqr/Q6UOE82B7g77NahX96jw== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Pe6McAGWClnSbrANbFnBwZDrpMnUa0RZD/lgH2I/Fw=; b=PhyuxVaKnYwT6STpELcsmySzwv/MTg6plP1f6aUWG79wiUAoHhArVNuWd2bNokgGIs28YsEUZvAedRac5bY5YiniF5Y8acvzeATzRLgUWm/ZmmwkTjWAdB/WQ4fPq4Kb3hScwn8bNxMdB8bLSAc/7OOKUBN9VECPjPVquhXvfN0= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:03:02 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:03:02 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 05/12] net: mscc: ocelot: set up the bonding mask in a way that avoids a net_device Date: Fri, 5 Feb 2021 15:02:33 +0200 Message-Id: <20210205130240.4072854-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:03:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1dd3285d-9029-4703-cbd4-08d8c9d65e72 X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yvIePtd9g8IDne87+tk3sWKaIEcNKBUfcJaduSFj8x3MM7YWw0c2dbzofeTu2WCfqFFETOZQqOr+X2rMQH02Fx2u2YINIOqQJQyIk1Pe4D1liBreD3wgvcLF+h4TA2qa850j+fZqo3IFB2ftLbj/U4aHsXMelLP0nQk0m3kw9XD9tymIErTDlTGZo7bKUvpmw53+DSEoQf7cGaIZL8eVZJ6oNwKLYbf4Jrp58r6KnTb11ExXBWICipR7RyYwB7IONQ6Ukq9fz5AdHdXcsG4kPWqvx/ttcUsDjfu/jBXzzaENRSRhq8PTKOMaPDssXk0sZ431VM9ONDa9KtoARWEBbsze26N/II3R+HpYGJCOLjDQSQ5yT8bGoRIzSvdw/GQB2dhQqiA4o0i+4woPQrTi07i5pPeWG2lCeXF5hFWyRIX0XT93+IWAPE+I5Lb+DxtviEwKGwp3/H7eTk5WftiemLnAhfBJzjhTxF7sghVERuCmw15A8sC1++TvbECbgRU7Q4dsEB6YU/5tmosBVRqC9AKBF+a/uFKHtag1EYYDJS1rbc2QvsSO/13oxvaUJ1H2bPybGuFbrCLqMEEeX910NA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: a1k72+NENy4Zm7ePTZ6kVB8HgEt2Epk00Ro021Aa5iuUeHU62x/z1A9YW6LbdAB4HtI2TCW21xBcDGYJz/eyJI1PO5OOn1Xh65JX0elz10RhmJugHyMK/jxo5xGYllGyf3YDkzI9SX+1Us1XKsTnYtKhhMJ48keAZXIQkGPRcoW1hpe/O+duKEQN2R4/QzsIy+KqfSPjHGE0mmHRAx7XYXpLWUZsb33FsgCiGFfcQ05WAiOZV+D/GgIszn7wuV1kHgcqC+RE5QRO53/drV1XL0/v0iwgfSZfxIQaFi3vTLah+r3PeAxVXdr9meSnnbitmrYpEiwOCHQH4J92xRtUh5IU9GOMYgClQyhpgjd5wWGZYT1+2sPm6D6I1IPe3xY6E7eF2Wt3eEJOuAP/g8VTc9PVMBjQC57YhDnSbq0kZWxJyCzmp+3J+NYcVwcIEq1iYW00qxZF7kcei79hdx6CKOVWJkgBtTE33T724SgtGaeWwTeOBRMkUg6Y1Kz7vyn7iSjPwKgTjCx/yzWw/kLQ5hUZhxiv0BPpRqqiEPHu1OenHwBSnrtVnAPzr81uiFxNFFL2KnQz5e4Q82tVn2HJyAvZs7Qb0Tc7fW65vKQqFTgxF7kJXN6aus85y1MLjthzHfZXdEXDn/GFOtr3JkKUNpIErm/rMmFU48TB6ePpXiYLlTT9VewPVXajdH3Lqm+GqNYuajbe8q9R59t1OYraFRNxcxI7Fz9mr+GxiFRib7KfYPIlCJqrEsfhA6DTQoBVD0kIisaW4n7MnrG6McbKxyljtLJa+qjYSfJnqCfpyKpV+RMWtuf4tTw5fQimeoQX2CNS7Nr2gBrAJIBj9sx9pPAn/2mNboCZ0EnTGCEEazYXdGr75npO1+fQkV2XxOAWNAmBTArtETUeDR0j8tQmNSDYYWJhWyqHLu4Q/NXy2Elw6vU6KZWZSnttFCRdpSAy8j4LcvYqGrT3Nii4JZ7pCkOnP2iYI3gOfp0Lb/PZDdA8xl2i1pe5drQEMkJb5O0b4CwpkP7FQEwHYnV/fIRyewQfo/0nkd4eKhyWTggJVGMyBKGoaYQfWs4aRVGFR6zLaJXA8HDR7YSY7se+te3ZV/lNcCb0Mq+4gbQ4dnzk/VyHsxN+U95zgnFKkdqiXee+SeT++Kpjd5oZme5Lplxb7joy66Jftd5X81zTQwasUf5Kqkj6dE4AloN+UrUbxsWMTBTzXC6VJq3Z3OqOMtJhcEbClzBWqRepG8lKS5tS9GCKHIaS7is5Ufk1UyhyUq68hCwyoD/Pt2LP/bVLhFIorA5h4BGp4BY4mSdTzIR8znERjPePGtPo/oaZ0V6regEL X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1dd3285d-9029-4703-cbd4-08d8c9d65e72 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:03:01.9809 (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: f7arKT2k/E4A4MLU5pwVYQ9MIqBWuIESgwOkkr0q5roDZTnOR8FfZOx+F/W6GYdiCYm0I8hDVbTslMoqFc//KQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since this code should be called from pure switchdev as well as from DSA, we must find a way to determine the bonding mask not by looking directly at the net_device lowers of the bonding interface, since those could have different private structures. We keep a pointer to the bonding upper interface, if present, in struct ocelot_port. Then the bonding mask becomes the bitwise OR of all ports that have the same bonding upper interface. This adds a duplication of functionality with the current "lags" array, but the duplication will be short-lived, since further patches will remove the latter completely. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- Changes in v3: None. Changes in v2: Adapted to the merged version of the DSA API for LAG offload (i.e. rejecting a bonding interface due to tx_type now done within the .port_lag_join callback, caller is supposed to handle -EOPNOTSUPP). drivers/net/ethernet/mscc/ocelot.c | 29 ++++++++++++++++++++++------- include/soc/mscc/ocelot.h | 2 ++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index ef3f10f1e54f..127beedcccde 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -889,6 +889,24 @@ int ocelot_get_ts_info(struct ocelot *ocelot, int port, } EXPORT_SYMBOL(ocelot_get_ts_info); +static u32 ocelot_get_bond_mask(struct ocelot *ocelot, struct net_device *bond) +{ + u32 mask = 0; + int port; + + for (port = 0; port < ocelot->num_phys_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + if (!ocelot_port) + continue; + + if (ocelot_port->bond == bond) + mask |= BIT(port); + } + + return mask; +} + static u32 ocelot_get_dsa_8021q_cpu_mask(struct ocelot *ocelot) { u32 mask = 0; @@ -1319,20 +1337,15 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port, struct net_device *bond, struct netdev_lag_upper_info *info) { - struct net_device *ndev; u32 bond_mask = 0; int lag, lp; if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH) return -EOPNOTSUPP; - rcu_read_lock(); - for_each_netdev_in_bond_rcu(bond, ndev) { - struct ocelot_port_private *priv = netdev_priv(ndev); + ocelot->ports[port]->bond = bond; - bond_mask |= BIT(priv->chip_port); - } - rcu_read_unlock(); + bond_mask = ocelot_get_bond_mask(ocelot, bond); lp = __ffs(bond_mask); @@ -1366,6 +1379,8 @@ void ocelot_port_lag_leave(struct ocelot *ocelot, int port, u32 port_cfg; int i; + ocelot->ports[port]->bond = NULL; + /* Remove port from any lag */ for (i = 0; i < ocelot->num_phys_ports; i++) ocelot->lags[i] &= ~BIT(port); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 6a61c499a30d..e36a1ed29c01 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -611,6 +611,8 @@ struct ocelot_port { u8 *xmit_template; bool is_dsa_8021q_cpu; + + struct net_device *bond; }; struct ocelot { From patchwork Fri Feb 5 13:02:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12071239 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E70EC433DB for ; Fri, 5 Feb 2021 22:46:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3263B64E0F for ; Fri, 5 Feb 2021 22:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232870AbhBEWpf (ORCPT ); Fri, 5 Feb 2021 17:45:35 -0500 Received: from mail-eopbgr50056.outbound.protection.outlook.com ([40.107.5.56]:62982 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232479AbhBENGJ (ORCPT ); Fri, 5 Feb 2021 08:06:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EZXHvNcrEOYV0D5ocjKYSNodeIjx7OD7dGCOnd85OiCNvh0qO2NfkOdRTUkRfbWnOXOaTehPmVu2bywhOiD1IQ/JD6Bz3FVTGGys5xG3obLCBWmy6CcBFwbDEUN9Rv6rOt/dzw2KM84MrkapzAlAC8wFfztTdZ+6wEK2qLEHdkiC6DgPE53YWVJq4exZC5T11/ZZl1Ps/Uzo9pQfHRd8xv8srmeMIu99GWNNWTa8Gm/67M5/GlX2MLS9xsjTaxu9U2whrloNJyzHYAVYfQ57HTAm8rDmBvIzvIX4k1Nkl6Ca0e7zAkYrUD9nTr19h7F1OVNHZGW+uC1Zud+ZuBZBRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a/xkEsjhw4O+AZC+W/j/4Jo6Rqste4fXU5SIsP9OU2c=; b=kkl7YYBotYm3GuSF+cp4+PdovBxGyT1jP0doW31Pnnu9TrMaHGJaS0tAuzBFjxByk6dNa0qMFzkt0+oC+UvCUAnMFcZG8QptCOOV9MbyJvxiUbOMoIVWPOO1sr4LW6/hwOZ9/EIrEqDrWJwIniMxSVNsev1kPCEUKa5pBc122ooGN4DP1oyGEXN/Rpe2UZbTpkZJinBonuAtC5aIi7pcNVLaHkEGGTk9M00R9ATm9EMzOJF3duWbxFi8Ttg4Z1JWiE6L/ujqYLm74+hCrRj+YnTNyw3D465XLu6aUQN9hLWgscU9dL8LTpYTwBWLlDnBKNWkxZGUaDwiVIqmiMiRyQ== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a/xkEsjhw4O+AZC+W/j/4Jo6Rqste4fXU5SIsP9OU2c=; b=TZ+dWNy0NoKA3Yk4/sFERre0Y46q6k4Y+wYlf1Y8CKwXRAvlPHvgSJlgW/xCpn+cmPkERgXhvDpxlLOnQtarAWTr9gQ56vx8w/L8z+NlARsMrqRPV93cDn1jBcPF7ih87iD53zy09iOE7NFgCuD+fRzXcC+vsVr6D43ogcIZ3Dw= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:03:02 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:03:02 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 06/12] net: mscc: ocelot: avoid unneeded "lp" variable in LAG join Date: Fri, 5 Feb 2021 15:02:34 +0200 Message-Id: <20210205130240.4072854-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:03:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 422c3cf6-de22-48b7-79f6-08d8c9d65ee5 X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Gv0LD1k8at1GTGMI4HzXVumg4jx441qOudywccJOYlCotEGKGMTUcpGo0l/TK3u23es/Gy5OCZiPjMLAnJEO+TAl1Sd7JGsKQIL+CSh8TQVtGqNnoLEDYAbNcsOVAfesyjBBBNMIts1HShwdZozYTeqPgjKhW7MspD+nVyoDkvrUTeAgOsDeZcEMdBf0lwAj79Aa8Phamzg3A+3crfc0nT3heVeDCHxggJo5X+n4+TYr2Fx/ltNcVUXHfSxWnlEgu9TJVnUCyFsWeHmBKnBw/JR6BreL4/1wHxaYXyTeInwzHkpawDIIDN1Aca/fsDYmrbOu7hq0OF4I9vETJMJbMWDAm0X5QdYadK6CA+TXY6QvFNNLpXG0Juyr6ADUHapUyOdUj7VJarwFGDSAcmarIkZXhL75kr4OH/x5x9Q8iDKv2Z+MXgI6V9c8kIB76seonQQuJgQHXFaeNo/jis2R6g82f33U8djyDP/rppnNyfDTnGb6sq8kXfN9OFAY6nUwOsHhitzMNvMmO2bn6KRDPVdaGCOGAv/yXTM8TSNfnszKMCQfjiSChyYk+KBeC5GBbn0aIJlpIa79pYBgXANog== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: UnPS7Or/+KiQwSBIfgjOhpi47nzoe8sbUObe83zYd+x+N8WfEH/ebE9AwyHiUlewpd2N/vi4yTcvzBUBY/u/YiVafq150G5Pk5iPznvOBz9IObrSDTaW6i8KZrJUownJAvk2Xeo3nj7z7FyjFPuYeYlZpXgfneHjv5Lhev6MvmKHyvxrrGyYdKJ6q26y+EGy7z6+Ke9xv7XVnaobt0bmDdIrkYo67NeGXe0RQZknRvyZ9ya3mpBMp3yWi4hF0SkFr2IDDia0X+ZZ1xdXVNGFSSeOzIXNWZG8qG/8v6016H/tp0ouBiEKD8kWXPRlUlz3Gc/zXJY8b85NvzDxiMXSrVv0eFLgl+KlPQkJOACWBXffbXmun+SVlzD5kNgauXyYMougcCGyg/JLw/8pBCmbzHOgCUQxX3nt+apbUNKSHVmtIiGlWUSxSmaWbqntGZRmoAx+v4am52i3XkaPixpArCuiSr64CCDcSbBhTyfGKgqK5h6kYtPnMM9DrdNi1qgKrRu3JIgfDX75ad6fGIX10tqeDVheYauV76AwE3Z3aVEpuWGhfeSlWhFV7kEpj1dt4lrqFRJRQ+wx3ZuQWPeA+SU/mhXqMD5V4CbNrsGH0m44LyyHs/zABvf5ggD5l1SfeyKYFhwlm+/+wsgv2WeZhHF9Wc/1EQHNU8poV0KZWw++HYOcsO914tWFm2ICklGY+5izH+wt0AdazDExmnIOTf5bmOKHdn8nZtXyO5JnZW8UDmtKWZ+qz7o3RxRk+61jXieuzrqEXmI5t+cWQVpxct3YiPyOEslBJWFAx2q9VC8QHrpKOpbMC3Mabye6Q/DyQoGiNn2Gm9AjII1l3mWhucwU/wLfh2S51Oqt25VFaLTqlAUFN/4P4ZWv9nmfAp4dUXs0iy28BH15LdX57y9Qh9Lbik7Se+fPVzVfGlNgxtHzfxQFmPSnz2bUKfHwE4Vo2oOj+peizsrdPwauT0KldGAEmHi/DovZKhlLzHqGLd+qG0TYWkUIgTbp2sX4+UpW+pwGALmlC0MLKdGiElEGfTERdDwe1ophxvmUGMT9hn2bT2JMAQOSzVOxqOjIUdtVfbpfyCSbffvyUUtKT2vTp/DYzUU7iGMfktFT2WTxMt164lGsGrEcc2LUlWJkzQYyCl1G9UOmZg6869dhzBHirn9FfBO5e+ChKFVfjNbDLWnGvMfUZ1TT9lnwVZZVTmSoJWHJrv1sJPF4uxQLFQLFldKG1gnlaDHocrYvk3TiYlcXStylshU5XWp3hz3zrHrwFJK0wncTGkUTVLCsKETjA1x83AbaufqPIBZX+IOfBpJPQ9qPIHHAgzQhu4oeNElX X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 422c3cf6-de22-48b7-79f6-08d8c9d65ee5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:03:02.6715 (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: x3QMXSW2/qxg4x8NOOgC+2BQMPMjo1gKYCKJvUie3VT6otWprWV0xWqgNHbZbQpbcjJB/OL4har85R2lsIAMtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The index of the LAG is equal to the logical port ID that all the physical port members have, which is further equal to the index of the first physical port that is a member of the LAG. The code gets a bit carried away with logic like this: if (a == b) c = a; else c = b; which can be simplified, of course, into: c = b; (with a being port, b being lp, c being lag) This further makes the "lp" variable redundant, since we can use "lag" everywhere where "lp" (logical port) was used. So instead of a "c = b" assignment, we can do a complete deletion of b. Only one comment here: if (bond_mask) { lp = __ffs(bond_mask); ocelot->lags[lp] = 0; } lp was clobbered before, because it was used as a temporary variable to hold the new smallest port ID from the bond. Now that we don't have "lp" any longer, we'll just avoid the temporary variable and zeroize the bonding mask directly. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- Changes in v3: None. Changes in v2: None. drivers/net/ethernet/mscc/ocelot.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 127beedcccde..7f6fb872f588 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1338,7 +1338,7 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port, struct netdev_lag_upper_info *info) { u32 bond_mask = 0; - int lag, lp; + int lag; if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH) return -EOPNOTSUPP; @@ -1347,22 +1347,18 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port, bond_mask = ocelot_get_bond_mask(ocelot, bond); - lp = __ffs(bond_mask); + lag = __ffs(bond_mask); /* If the new port is the lowest one, use it as the logical port from * now on */ - if (port == lp) { - lag = port; + if (port == lag) { ocelot->lags[port] = bond_mask; bond_mask &= ~BIT(port); - if (bond_mask) { - lp = __ffs(bond_mask); - ocelot->lags[lp] = 0; - } + if (bond_mask) + ocelot->lags[__ffs(bond_mask)] = 0; } else { - lag = lp; - ocelot->lags[lp] |= BIT(port); + ocelot->lags[lag] |= BIT(port); } ocelot_setup_lag(ocelot, lag); From patchwork Fri Feb 5 13:02:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12071237 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB0F0C433E0 for ; Fri, 5 Feb 2021 22:46:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 918DF64FAB for ; Fri, 5 Feb 2021 22:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232760AbhBEWo5 (ORCPT ); Fri, 5 Feb 2021 17:44:57 -0500 Received: from mail-eopbgr50070.outbound.protection.outlook.com ([40.107.5.70]:49991 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231215AbhBENGa (ORCPT ); Fri, 5 Feb 2021 08:06:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z/f9VFKE8/fMOueeWDwKQvTfYB0xEVLjAXnByfzxRy32b8KNuoAps09WRjUYlchR2sYjhUdzcBHfFtNFSQ0unkDCQb4XQCQFCDEnX5lESi/XWfYja6kMUT8wLgMG7ePYR7/odZQr4BleVKbEvgJGFwr+qK5yNKHQwlHYyfuOYQpzvSXkM5HJF2NTkHHK2alaQwtBXihl0trwupNC2l1ILPxSQXwE7wJKygZmOfdpv4omHXy6nyEFvtAdZRpjEM4Yl2oGOdXQ3YO9PYAtD2CvwV6latOqtTIF/BwTDhDbORaZ9zNZP2M4D3FUQzCUiEuw+/5iSL45FsUPaKs1oFrI3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XEw+5hJeZoW8KHz+cU5PVXKNkRn9X3J5TU4/p+7Ce7g=; b=G48ptRz9Xp1HZquzpj+SOtbks6kJiOjLUxcLsmWQcXpI4RBKdF8UUOSt1qiXtApTCDuE3lobdxFepCfBUeuuTdgVg1eGwOBsLkb7pOx2fDtFqXmFJAp62V4S38lBkbCI2NB2e1dhY/0Q9C9VqiiR5gPfDsqDvZiTc0Bhmouv1HG0x1PjIKC1NhQDF7wgQIFReIKusmzLvi3Dryp032zXmF3x03rXFtk9sa6o/X6iQvBHzfAgCbmD+h3pO/P5ctbtMj9T7/F4vdamsYLn1znLTz+dBaqiRaP4tsGcoalKS0DS3kmSE5t6sf1a4f8lmkhJjTLJPPVNbM09t/xj3uHuGA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XEw+5hJeZoW8KHz+cU5PVXKNkRn9X3J5TU4/p+7Ce7g=; b=p4KRWsrPJ7JL7HeDoDiPvmTaa5OFzeiCCCjs/FSZafTEPRMZZwZQR1zgUEszKU9HFh30taVFjfMKdYxhbf94AgUeWU1gEHIJoXoPJUDcfqEWwA1Wqtm1R6OOpCHGqWsVxC1uzo2ir1bLNWbgiE9xIar2Bwfc3djj6vy9s6wQ5tU= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:03:03 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:03:03 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 07/12] net: mscc: ocelot: set up logical port IDs centrally Date: Fri, 5 Feb 2021 15:02:35 +0200 Message-Id: <20210205130240.4072854-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:03:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a501e28f-55d3-4d12-d6cc-08d8c9d65f47 X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sy0dmh06Rrb2oys46cYQ+7nXvWJKHBHReWgGewy1mPyqXKu/CyUI4+yfdMZmHExh+C2zMMdiIYI0tR+LXbnsoWjFnDzFKRnqsC5LvG1Wbd61WTB/GymxnkBmquymK05asZjpVpLFr6hVntlqhCxrwxMO2qD6xTnLg1GXEie03PlXqisCAyGuVdxR8pjRcZwdyh7VrLdcoHV3qRpPTNv5nyFGWy/FQtkXo0SlcEd2CAA+l8mREdmms0bPf2ADAu4rAfKsI1ATfTnO0e4tj32au7wNU1t8LiMgCE2LPa5LYw8yRmBXbhV4pDbLjE8JZXf83bnxLlwMr6HUNMd5V2sh31Nh6iDooybesAea7MJ8gIUHyH/T7of3wJ43go++qiWtUqCPSL4uIGdJ7h0GYYX327cUh7WRoLjTz7p5nshmap3T3+o7U3lSoyrZ3NC7TB6s6NlV8uBirBA/F7ob98O4HLIfnkuk4ojkY0bcEL3b01x/67IJLp3Gy1Kf0W6iuI/W5nhjyznQo+D/kInmCMCxvMFRPAm6C95uT+dy3/5iFhoA/RAbNVLycGVYtj+BHAwOnEcRd+wOYw4V8o6oojif6w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5IoeWtrOVtVsUwRsBTwzJt/0rN1Nm0zb9FJG7+jlyTetprNkd88QGSBGRu2C+ETX3kkOUFSEaUl/+bbT0ln53Vyxoa6dNHwBV3TNixnaW4R0EKNOrfnhua+a9gwA+ZJD1+9gXo6wOsFcFJf3x3vAaAm7Sm3KDE0OCEgbf0TVZmtIvCeZlySNo/ERhrQVEHET9wEhcO9KUT6FAEgmFLs38LRA67HoTx7tLBL0sGOQZWqrStnteNmLn8Mn+7czBWvQDwzDSv6AOMQbgH0wcwaAQMS0TsIuEeVVTiRbLDTglI6hTKkTXisFBpQJKI8LVdDSJJxmXkcGJgjGragWzihsgJuR8g2Dv2jR6HiPzFPZ869ive4Ueyjx/dplxCs1LPUL+LmOWEMOlVO5zqg3/5vicairOA/LUabnzexYRNEuSBwJ5FXxQxqWMaLYiX1TDpV0fPzN+voTihpjTPJ1lipLvC03LyrngfjNDVJZWyuzkitqOj63t/2IFVEK0+rSXFMqdqgGFwi9NPbpqMYhOlHHcwihsXbKRgnRqsDarDl+kFnsAPBbC4eKVED7fLraQxSOypFe6/TEVj+RMVwSZ9KWA++Hg43e1KKJthOZZqY8rizP9tSRx9+o2TrdDisJfa0nSFnKUcyWD6zClMTlsflbOycJRQJZUEVIdGAfv3+EzMPCp97fmJFjVI08YFHAqKubHTqkHA5vXXJlhOVJesiGSdrIX/nmzzK3kmyPyKWh/YBLhYok9QzWy3BEWq2qIYNHLrv72t2qV7QUw4Dmvq8VbVSnzTjYRA5N6dMuFIWpF7T1Qbf88hKSZu7MyMnT5/NjXQORP6L2mgxPq0ikZIrUk/77Bkq+mj/MyiLnZfvRp8+hunGzZUaWdQdt8qGizDwfHWZ2kz2HwbcsrUFq5m7wUGoN0Bnqu/9tnAgUsuSZRnwLe9dZXYCcMijVqoLsyeHNv/tUp2N83D/8iJXzsKlO2Fy4eB1uurMuDnb8GbbMDMgh7NjirFZeMi2VNwGX0+y/BoJSHW9eFJ+pEUhgG7d6AGqnOx2d0gPXhpms1pZ4rdjVmY52JHN2DPoopmD2+7oh+vTKaLyrVf3KKqloFYkNY6LpP1/G5YsV2+AXmzTSpvqLWm884RFGlf9NWXbjyge003Q1gFWPZsNA8I7OsiZcup5APqvCZFfAaVpENo3b2Mubj0F3MPp9Blns38tqqvN3O1RiWZ9wCC7rFTHAykbEiVBqu1YXPMVsZSfORYizM24B1+oWokqSu7nbVUr+sFt/dVMtNi8cutJ6ru/aio79g2b84+hruBQounhKUW2Dy7zuNty0+t75Q9cNibP1DSRb X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a501e28f-55d3-4d12-d6cc-08d8c9d65f47 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:03:03.3591 (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: 2zRgVZ83JOAow+igPunsFxBO4BUJktiz46MwaBPLGsch92wII89DALdr+EsYEmSeytHRC/9YfpMhXmntDWEJ/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The setup of logical port IDs is done in two places: from the inconclusively named ocelot_setup_lag and from ocelot_port_lag_leave, a function that also calls ocelot_setup_lag (which apparently does an incomplete setup of the LAG). To improve this situation, we can rename ocelot_setup_lag into ocelot_setup_logical_port_ids, and drop the "lag" argument. It will now set up the logical port IDs of all switch ports, which may be just slightly more inefficient but more maintainable. Signed-off-by: Vladimir Oltean --- Changes in v3: None. Changes in v2: None. drivers/net/ethernet/mscc/ocelot.c | 47 ++++++++++++++++++------------ 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 7f6fb872f588..5d765245c6d3 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1316,20 +1316,36 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) } } -static void ocelot_setup_lag(struct ocelot *ocelot, int lag) +/* When offloading a bonding interface, the switch ports configured under the + * same bond must have the same logical port ID, equal to the physical port ID + * of the lowest numbered physical port in that bond. Otherwise, in standalone/ + * bridged mode, each port has a logical port ID equal to its physical port ID. + */ +static void ocelot_setup_logical_port_ids(struct ocelot *ocelot) { - unsigned long bond_mask = ocelot->lags[lag]; - unsigned int p; + int port; - for_each_set_bit(p, &bond_mask, ocelot->num_phys_ports) { - u32 port_cfg = ocelot_read_gix(ocelot, ANA_PORT_PORT_CFG, p); + for (port = 0; port < ocelot->num_phys_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct net_device *bond; + + if (!ocelot_port) + continue; - port_cfg &= ~ANA_PORT_PORT_CFG_PORTID_VAL_M; + bond = ocelot_port->bond; + if (bond) { + int lag = __ffs(ocelot_get_bond_mask(ocelot, bond)); - /* Use lag port as logical port for port i */ - ocelot_write_gix(ocelot, port_cfg | - ANA_PORT_PORT_CFG_PORTID_VAL(lag), - ANA_PORT_PORT_CFG, p); + ocelot_rmw_gix(ocelot, + ANA_PORT_PORT_CFG_PORTID_VAL(lag), + ANA_PORT_PORT_CFG_PORTID_VAL_M, + ANA_PORT_PORT_CFG, port); + } else { + ocelot_rmw_gix(ocelot, + ANA_PORT_PORT_CFG_PORTID_VAL(port), + ANA_PORT_PORT_CFG_PORTID_VAL_M, + ANA_PORT_PORT_CFG, port); + } } } @@ -1361,7 +1377,7 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port, ocelot->lags[lag] |= BIT(port); } - ocelot_setup_lag(ocelot, lag); + ocelot_setup_logical_port_ids(ocelot); ocelot_apply_bridge_fwd_mask(ocelot); ocelot_set_aggr_pgids(ocelot); @@ -1372,7 +1388,6 @@ EXPORT_SYMBOL(ocelot_port_lag_join); void ocelot_port_lag_leave(struct ocelot *ocelot, int port, struct net_device *bond) { - u32 port_cfg; int i; ocelot->ports[port]->bond = NULL; @@ -1389,15 +1404,9 @@ void ocelot_port_lag_leave(struct ocelot *ocelot, int port, ocelot->lags[n] = ocelot->lags[port]; ocelot->lags[port] = 0; - - ocelot_setup_lag(ocelot, n); } - port_cfg = ocelot_read_gix(ocelot, ANA_PORT_PORT_CFG, port); - port_cfg &= ~ANA_PORT_PORT_CFG_PORTID_VAL_M; - ocelot_write_gix(ocelot, port_cfg | ANA_PORT_PORT_CFG_PORTID_VAL(port), - ANA_PORT_PORT_CFG, port); - + ocelot_setup_logical_port_ids(ocelot); ocelot_apply_bridge_fwd_mask(ocelot); ocelot_set_aggr_pgids(ocelot); } From patchwork Fri Feb 5 13:02:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12070091 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 533F9C433DB for ; Fri, 5 Feb 2021 13:09:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E572564F38 for ; Fri, 5 Feb 2021 13:09:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230399AbhBENIw (ORCPT ); Fri, 5 Feb 2021 08:08:52 -0500 Received: from mail-eopbgr50056.outbound.protection.outlook.com ([40.107.5.56]:25949 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231421AbhBENGT (ORCPT ); Fri, 5 Feb 2021 08:06:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XqjDYZqeQmxmOe8baAw7LmNEbkVnDEEq3XLEM4+9MqHdu1Q9jbDgY+aPXplpkCkaKTq/B3pTxOe5QQP7+MIZXMoVf3mB5xND9YR74KsQMCmDiu86t+jYsH/Bx7nPXQppxotcctcHk6yXTd9XArsMCw5nsmvT0eJA4CnHmbXcCyGxMhPwuJsNaeFBfVqTug+b8neYWIGf9D2y4lhbpyWmpEhOrZVWDaVqoOkl2muEsAy+LUXbGFuyxrj44lxJ5aabcwsK8sG/oCXAmO8MVRQQEdrV9FlpQnxNPDKW3YHOPLux0+9XAd27qk79HNftwxwcm12rv/04SSPAwR0DjTrsaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JkN+qjpUyhOHdEpjPVMthMuHol0+A0u+g9wleCPXRrI=; b=Mn1SxsnVklRH93SFheY3L1Qmfz4BZYIBTxX3fYhjm7/QlZzRSGIn7bb+o3UO/wvy79RXf5yX4MGl7av1lMVh4PY+R93mB4Wy7jfR1uEiPp9lW/E3VrCLeUG4AOLSB/uCrfiz7xT5rq9o5ptr5o4PPCX3bZfxEKu0BjVkSOWOuHfgvkFdFAtEUpzS8JNBK68YAnpsblOvTZ5QSc9qRtoakqanBoCT1nIILJNYy9L08QRhyLiJXcswp5zdjFcGWydl6w6SJT8Y64v/YAR8R1yIEGMlloNwGstc66jordenNE6wnSQ1yOPtR1AydrFsrprmWaRBA3ZJDT0kzO/LqNpnOQ== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JkN+qjpUyhOHdEpjPVMthMuHol0+A0u+g9wleCPXRrI=; b=hHKxAGld3zIDBF5qnpSi+Z22RXvsIvQBEzAFLkrT0zUygS8KVUG4bopkzYpGc5Rz1AIhSK80FF7HTgKtupu2Py7Vza2yqoyWLC81fnrjkN0XhuoYfEz8r/ClZPeT9QjNYb0n4HDj6ts0ri5zO96yXu3qGBdMesSDIINYdMtpPu0= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:03:04 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:03:04 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 08/12] net: mscc: ocelot: drop the use of the "lags" array Date: Fri, 5 Feb 2021 15:02:36 +0200 Message-Id: <20210205130240.4072854-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:03:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 119075f3-804a-4bf2-f6d9-08d8c9d65faa X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f/8nYfzOKnd79JU4F89i0OYjShkWJPngMN5WpolnSAdPqK03Bk0NICt2P0COuhkaRqp7jGdBZD1wBtRcdhJNKIDaYOHHFf+Zw6FaJKXq37n+l/nPTCop67k634ZJCga4Qh3YHyYuwwRUBLu4EWqPhe3FoQQmVxWAXczNCtMmaeqs5o7e3G7fwzTs7ZNXgk2XkxUR6EvRMyR0DKf0mt58ylydvitW/m1osJKo1F1f/3GrQLaMvMz/9xfLSURsuFx68/671hlwumvk0tLugKy7cos5AgKxnCBGNCA90bOM84LMivkwNc+eIHgrd8L4D1Su6ct93ggS71bABZOMAThVsCaSRqU9GD4vHAZM4Qzv/HeOa2xmh7gGbCth+QDauNy9p7eSHkaBgGzLANYWQlSaCu0DC8BJXOTgqTvQWma9/Q/3U/bZNLOmu9btzL+Te0AC7rS9b/uO+nwcezfnQP1N1CQJVbepzjofDNtY5uAyFG4NQ1MSiz2/lhaUMh+AGm9qVs7wKLVm0dwTQ0qqbteVlWZ619G6/UsOpzxqzskn8kwVb6NEB8UPuSdNnbH8bXv8sYEfNKofSADpJXrdKQeFiw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: FLF484Z6lXGgukSTvveOhA0LgNnFz086jOjOL1pKsByUxp1CgUQ3JOvIkE3lchgP6Qprv8OwC+nQXX0IacsqpPB7v8I2x90/Da2/EtK6o2e2PCFXCDsikQiQIHj7RyqfCSTNN7z18BquWvK5tq1B7uWFp0I8kwgXQkm2pymupYEyGZUFKol6izAeYnWvtm+34PeFjSj0n41DtGzYuNgeg1AQy/5RJIuRAxeMnfUGmG5cuZjzpCJZPNw5nE6cmqAfpwkJCYvipFZdyxH409C3o9cUOXy4b56CJGCA6b+LsmqyGNTbn5m5SsFsCyJCeCoUQytpPy0yiUmaz4HRLHYaE+tCC1MgJUDzFHtAfCdaA1Va4UVnR0DECuOLjS4G53eYcjIt1SajEKhzPybl56PcYorlgQzUJ/qHmNdq6nXQhQiv4KLIHDHTYc6Di0F3wqTOmiaVxGOMomiWbvhDJymZsY2wgdESLqNmpTYWgfcenkNQBrU+zjHZ+krz/tNTD4/jGNr7+nTuqvW8Feel94I+7AGvSTBlRNA66dLEROvzi4TidrCOhGlFi908KNEAh41yx0uKhZu1XkMsdes61T44xFmLopF0qcB7vsVQ5XgW/+KFGRpXFB1W7nzSQnQiAFGmsT5pQqxJEM7WO5/Hlhb2ORp/3aQLixgGbWNgQee2rOJ0r3ebbP2ZnhmWP6lzC9HxwLwoDNp7G/9WaAEQc49Fdhdb4azrlf0FNNWP4yfJTknGsopFQnlh4QzZq4rUnjPjHnK9a/Ze8VgNvYr2B7v2Dn6YuDq+jJKWoIUIRYnmUUMoeSH9SnEfsXPHiiuLtEOGvgqhit+HkRP5LdgOqQhsr6eT+vBb9sI1c6UA8Ds5BgfK7IvB4iLQVemA2xbgV4G/b4sTBJ1v6QybgiUMmJztzB0g/cHrST44VJW5O6lytxMwrMrUigfoxED0MyHlqLMwkzS0ngEZkK2TOtAVCzjlb117ckhHMSuiGmcOLSlYGSKVz1baLpiuFsZpJmFYbCEZuZ3lURBbSnU2c9C6ax9fA6gfDMDrup2cVwGV9jSzqXqfBKF/uxRgYbnWiJl01JS3v6th+sZqN+MFPxwBcssCO+FZEsJPYT+/vxtegebP2KXW5YFqt2guNCIwCem1B4ogncP6O8AVf2YubVKDoP87KwSZbPfbri1GS+63l78NzJfpzZbLTSgvxBrc8WYOHTLk4RfUMKW4NyHgoS6mljYHG6/V/nhSNVj876t2RQw6Oxc7zaWbMpyqOd3nQdZ8CdCj3f5f1smYDQepAB+M+d0nbkxmRRhM+KqEtAmDEycHbfEc08PdIq2Xow5tj7wcMGLj X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 119075f3-804a-4bf2-f6d9-08d8c9d65faa X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:03:03.9778 (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: DJ+5HAkSlsfDrrlvvQKLMCwcwTTJrdivW7sJW7piKeLQF47+pIOfLPat/SrYsEpV88n3YKvBKIWUtNWaL2s2pA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We can now simplify the implementation by always using ocelot_get_bond_mask to look up the other ports that are offloading the same bonding interface as us. In ocelot_set_aggr_pgids, the code had a way to uniquely iterate through LAGs. We need to achieve the same behavior by marking each LAG as visited, which we do now by using a temporary 32-bit "visited" bitmask. This is ok and we do not need dynamic memory allocation, because we know that this switch architecture will not have more than 32 ports (the PGID port masks are 32-bit anyway). Signed-off-by: Vladimir Oltean --- Changes in v3: Using a "visited" bit mask to avoid memory allocation. Changes in v2: Context looks a bit different. drivers/net/ethernet/mscc/ocelot.c | 95 ++++++++++++------------------ include/soc/mscc/ocelot.h | 2 - 2 files changed, 39 insertions(+), 58 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 5d765245c6d3..c906c449d2dd 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -957,21 +957,11 @@ void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot) mask = GENMASK(ocelot->num_phys_ports - 1, 0); mask &= ~cpu_fwd_mask; } else if (ocelot->bridge_fwd_mask & BIT(port)) { - int lag; + struct net_device *bond = ocelot_port->bond; mask = ocelot->bridge_fwd_mask & ~BIT(port); - - for (lag = 0; lag < ocelot->num_phys_ports; lag++) { - unsigned long bond_mask = ocelot->lags[lag]; - - if (!bond_mask) - continue; - - if (bond_mask & BIT(port)) { - mask &= ~bond_mask; - break; - } - } + if (bond) + mask &= ~ocelot_get_bond_mask(ocelot, bond); } else { /* Standalone ports forward only to DSA tag_8021q CPU * ports (if those exist), or to the hardware CPU port @@ -1277,6 +1267,7 @@ EXPORT_SYMBOL(ocelot_port_bridge_leave); static void ocelot_set_aggr_pgids(struct ocelot *ocelot) { + unsigned long visited = GENMASK(ocelot->num_phys_ports - 1, 0); int i, port, lag; /* Reset destination and aggregation PGIDS */ @@ -1287,16 +1278,35 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) ocelot_write_rix(ocelot, GENMASK(ocelot->num_phys_ports - 1, 0), ANA_PGID_PGID, i); - /* Now, set PGIDs for each LAG */ + /* The visited ports bitmask holds the list of ports offloading any + * bonding interface. Initially we mark all these ports as unvisited, + * then every time we visit a port in this bitmask, we know that it is + * the lowest numbered port, i.e. the one whose logical ID == physical + * port ID == LAG ID. So we mark as visited all further ports in the + * bitmask that are offloading the same bonding interface. This way, + * we set up the aggregation PGIDs only once per bonding interface. + */ + for (port = 0; port < ocelot->num_phys_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + if (!ocelot_port || !ocelot_port->bond) + continue; + + visited &= ~BIT(port); + } + + /* Now, set PGIDs for each active LAG */ for (lag = 0; lag < ocelot->num_phys_ports; lag++) { + struct net_device *bond = ocelot->ports[lag]->bond; unsigned long bond_mask; int aggr_count = 0; u8 aggr_idx[16]; - bond_mask = ocelot->lags[lag]; - if (!bond_mask) + if (!bond || (visited & BIT(lag))) continue; + bond_mask = ocelot_get_bond_mask(ocelot, bond); + for_each_set_bit(port, &bond_mask, ocelot->num_phys_ports) { // Destination mask ocelot_write_rix(ocelot, bond_mask, @@ -1313,6 +1323,19 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) ac |= BIT(aggr_idx[i % aggr_count]); ocelot_write_rix(ocelot, ac, ANA_PGID_PGID, i); } + + /* Mark all ports in the same LAG as visited to avoid applying + * the same config again. + */ + for (port = lag; port < ocelot->num_phys_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + if (!ocelot_port) + continue; + + if (ocelot_port->bond == bond) + visited |= BIT(port); + } } } @@ -1353,30 +1376,11 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port, struct net_device *bond, struct netdev_lag_upper_info *info) { - u32 bond_mask = 0; - int lag; - if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH) return -EOPNOTSUPP; ocelot->ports[port]->bond = bond; - bond_mask = ocelot_get_bond_mask(ocelot, bond); - - lag = __ffs(bond_mask); - - /* If the new port is the lowest one, use it as the logical port from - * now on - */ - if (port == lag) { - ocelot->lags[port] = bond_mask; - bond_mask &= ~BIT(port); - if (bond_mask) - ocelot->lags[__ffs(bond_mask)] = 0; - } else { - ocelot->lags[lag] |= BIT(port); - } - ocelot_setup_logical_port_ids(ocelot); ocelot_apply_bridge_fwd_mask(ocelot); ocelot_set_aggr_pgids(ocelot); @@ -1388,24 +1392,8 @@ EXPORT_SYMBOL(ocelot_port_lag_join); void ocelot_port_lag_leave(struct ocelot *ocelot, int port, struct net_device *bond) { - int i; - ocelot->ports[port]->bond = NULL; - /* Remove port from any lag */ - for (i = 0; i < ocelot->num_phys_ports; i++) - ocelot->lags[i] &= ~BIT(port); - - /* if it was the logical port of the lag, move the lag config to the - * next port - */ - if (ocelot->lags[port]) { - int n = __ffs(ocelot->lags[port]); - - ocelot->lags[n] = ocelot->lags[port]; - ocelot->lags[port] = 0; - } - ocelot_setup_logical_port_ids(ocelot); ocelot_apply_bridge_fwd_mask(ocelot); ocelot_set_aggr_pgids(ocelot); @@ -1587,11 +1575,6 @@ int ocelot_init(struct ocelot *ocelot) } } - ocelot->lags = devm_kcalloc(ocelot->dev, ocelot->num_phys_ports, - sizeof(u32), GFP_KERNEL); - if (!ocelot->lags) - return -ENOMEM; - ocelot->stats = devm_kcalloc(ocelot->dev, ocelot->num_phys_ports * ocelot->num_stats, sizeof(u64), GFP_KERNEL); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index e36a1ed29c01..089e552719e0 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -657,8 +657,6 @@ struct ocelot { enum ocelot_tag_prefix npi_inj_prefix; enum ocelot_tag_prefix npi_xtr_prefix; - u32 *lags; - struct list_head multicast; struct list_head pgids; From patchwork Fri Feb 5 13:02:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12071233 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8FA3C433DB for ; Fri, 5 Feb 2021 22:44:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77CEE64FF8 for ; Fri, 5 Feb 2021 22:44:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232513AbhBEWni (ORCPT ); Fri, 5 Feb 2021 17:43:38 -0500 Received: from mail-eopbgr50071.outbound.protection.outlook.com ([40.107.5.71]:21318 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230259AbhBENGY (ORCPT ); Fri, 5 Feb 2021 08:06:24 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f/bhbdIzSVYJvaSHGaI2LlnbhTCYXOLTs4jODxfCY6jmsQYtDKugrOda49wLHHy4rn/5uwQkyV5vBJ51EmaSfgcUDEKM+hkVLDuVd9ELhk/FKL6Zy5zUSIWFdIaTO+FM06GG5lIncBi6NP1SQNCwSze8Cc5J3vjnASDv3aLrBEykBr6y4PiX5noz2dwcnQ8FIrZEaCXOvYf9XTYnguhuiCx/mP1gAg+XVBG5EzaT+Cdp5WCsKQx0Rinxg5sJlYQ80iZfpYy1MN5xdcJ5sidfa+mFvbT+/KjGeCqhEDLRxlj9N6qh9XE4I1Iaq8K6ukOA36ayJc2TQmklcbc6do7YoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8jAIPQ5E3ivqoM71TxoK/YFQZDNwL+v2ItpwkdDO5mY=; b=NDiUqiANkVjeSPPMkF4fXuS5R9KrsF+nSocetCAsaBNwN3XiDzxeVJpPIsc1eVo7wDXSGdBPsXBtuIIyrE6DyusMMxvfNxpCjnyoDKkUyaYNpp7DrPz+gWFbAEv9sD5LoLxQiYdbutaBQuPW73IXC2uT2rRsENwcukHWTsUIeOZ6J/DC94vMakB5vf8YLwRAGYnwZsmYPfL/wvDDy5c3AWxlrBpjMiS75j9KEvHT46YHFbESbCwIf/NkyHK7smOQbPuGqJxJTGnO8HBdXCbBqegUmhipRh3AktBawzssk0nRpPaJe4TI+FV1JFl+QvqtGELZXj3jiekcgsX4jTs3Vg== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8jAIPQ5E3ivqoM71TxoK/YFQZDNwL+v2ItpwkdDO5mY=; b=LMhBn3+nXxazmPU23k8G5GHpEP0Wr2n17wjKuBajm22Klpb3Yj/oqjfiyHCWRYrW2+etzhm28SQaBy2VZZTer7sfAdD5bghn1Njk2DlMNq+cY3j+FhzFdHa5fsEJ3rWkyOxu180zundwn4h2ViOX4i6lfp7OPD9EYEtLtm3DTVs= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:03:05 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:03:05 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 09/12] net: mscc: ocelot: rename aggr_count to num_ports_in_lag Date: Fri, 5 Feb 2021 15:02:37 +0200 Message-Id: <20210205130240.4072854-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:03:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3feceb77-2f3d-42cf-af34-08d8c9d66007 X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rgyPWRrPwTe1H/M2jk33VBAlDcJFP9FP2fYpenU7n+3Gp6w10Fbv84axK52FvNgmsZmrKV736AYsH1jeetfDmhS0qualdmpFNAYOCob692BAKI2PyZCSncDNVgtKlPDm1MTZngBmkhCrOblbGzII6bnkJFKdBqgHrI2KS+c89WxTr4zkMwBDuzTwGmpWN0/xPY4pgmZDOYYaS6f/OpYHZZpcFPdgQL+0w59mc8ezaAoC1QF4xvcE3lo5zV0+Sqm5WkkyYRUGf8fG/gEBqeh41hL4EM6YsvEBkbC6ixbbINmgxQfeoJI08WQh38xehMwhUIxfNF1dZ7XeQuMze9aJDVxPpECJ9/JRMQbQ3VS14xmZWeKAvmGjNju0mcBsIpdp3VedWd1kL8GXQHgdmQvp6SRDtXRDyNhgoP3SSsA6uckrvD2S10nMCyQPJE8Y3mYqe5c4AakfdqwEaaIxkkDTZm4sU2PtoKUfv299Oje7AkG6rMJphtKGUIh+2lbWGA7EfAIeUL3gT6P1cw4S6righaAG59fl9MDsBuLTT/6f0M37wBZqEBDyjHeqzjIuqXLCiQKQ8HKTAwLP7KJXZYCZMw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: unL7A7qojVCZIoLRSI4nJfg4bbv/k/hIG3IJIvWVPusvMuEqaJtGZ6+/hRgn2CKEaEBkNPAJ7DXCN/u1f2VmEwVUmJ0gE8L0Y+b0JANGMFcJXMd+guOj7WZkwxRaGNNOLRO/bcKPItA7e9Z2E6hnBYKxf20ScN8oDj3czi/pU2zZmviBHvheklAFLENBUuhRHqXx4lElks/qPU5E4witOIx+56A8JglowsnOykvMv0Oln9y9PMDEktdKmsvExxZvx71lBkHHUSZs3suasW+uUj/wlp/Jplb9P2FkZUcvy1ocC8N9PJzueQFrOhWsmgBbH2hXfRJrTVmqo/ZJgHdcZxnMTYIE5EMHEXRA8NFWWiW/D+hUd+nTgyqfZ55Hh8fEr/nIjakkB2mvDlsGAuBEJOIfRjdTdb5OcI9/Qr/G4xAIALoD9seq/nQHGgU+GlyH0Iy9AQ7fQbiwGBq+UATDc/GQqpWIH4IpQFP1cNtuSe9YUuRoOJ/nIaXa/Zs4sTG7cVFhwo8yzUY6lc2n5JY39h8fBW1u0W/k1g1QGfto0KPHw8ppQdNaiFf3ZoqwsCLU6zMLx+Wf6Y1Vj7U8r9lC6SIDGOQYU1GTMlFFjQ32xhOw4qrpqG4Da3JcfCR1LnXOPnxZ9idk7Rz5LSebx4jYxNSDGq6rWQJ5noWcnWpiPHYUbiy9klcvN7Od0mkSZkTEmPEbkN2xjYydQ6iejCw032PlQ39LhfDyP+U9LNFunyy4ZaerYVij/czSpWX5BanSFPRednP8BS62icQcJUrgXu4q/X6A1p4eRAEBTmLBN41MUhHOP1Kt3re2KLlVJbrqP/uFkmRpuNXz35sbmbcnaLSX9qfFwlF+qhitY9MZNLI+znf4gzYLFCiH0yxiXmXLLScSHuoAXGpAe7tlF/InvsjYvZEXq0N6sW96/I+p8BmPoHuZxH9isb5reU11ahCCxLHhyOesam9xSPfCvQwf7CzvJt26VQkUbqSLEohxuW7n7IWvR9ShHUvAmSUoEKMoq7HEP6k5gDwVXOLCpyVWZoMhYr0sY7cuGMhBPNdWB+KmaOTfvmGDUzzwB9Oqz/Gn0Q+CBbVtGFmtZnHztOZ3misf9+E42h+TFBfd7Uz83pPMuots90crB6oiP0kKv3SFo2eW0aGqPWBCb2qxgfB+UOe3FJXXdunMZhOJYR0MuQTQUlYQdjo2RXpsB+idEi6vYrqeincua5SRdgL3TKFc7CeqDpwm8GdaZaqD37xOl6Hp9MOClkaxnCKRGQBZ99vVODOg5ph0xbmC8z55NFd8/dVEBgSK7IHQZyHzAsoIgBBREGE3uc6Zgw8qHXNDfZia X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3feceb77-2f3d-42cf-af34-08d8c9d66007 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:03:04.9972 (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: zQE4ZpzRMZ/vUkGUO+WrK4GrRtEokmvJROzKJPhnxzObp0KPTCBKQMuo+c/6keEgJxfzg/WV6nzwU4g67o+xyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org It makes it a bit easier to read and understand the code that deals with balancing the 16 aggregation codes among the ports in a certain LAG. Signed-off-by: Vladimir Oltean --- Changes in v3: None. Changes in v2: None. drivers/net/ethernet/mscc/ocelot.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index c906c449d2dd..380a5a661702 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1298,8 +1298,8 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) /* Now, set PGIDs for each active LAG */ for (lag = 0; lag < ocelot->num_phys_ports; lag++) { struct net_device *bond = ocelot->ports[lag]->bond; + int num_ports_in_lag = 0; unsigned long bond_mask; - int aggr_count = 0; u8 aggr_idx[16]; if (!bond || (visited & BIT(lag))) @@ -1311,8 +1311,7 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) // Destination mask ocelot_write_rix(ocelot, bond_mask, ANA_PGID_PGID, port); - aggr_idx[aggr_count] = port; - aggr_count++; + aggr_idx[num_ports_in_lag++] = port; } for_each_aggr_pgid(ocelot, i) { @@ -1320,7 +1319,7 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) ac = ocelot_read_rix(ocelot, ANA_PGID_PGID, i); ac &= ~bond_mask; - ac |= BIT(aggr_idx[i % aggr_count]); + ac |= BIT(aggr_idx[i % num_ports_in_lag]); ocelot_write_rix(ocelot, ac, ANA_PGID_PGID, i); } From patchwork Fri Feb 5 13:02:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12071235 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19D7FC433E0 for ; Fri, 5 Feb 2021 22:44:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9C1965007 for ; Fri, 5 Feb 2021 22:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232617AbhBEWoU (ORCPT ); Fri, 5 Feb 2021 17:44:20 -0500 Received: from mail-eopbgr50082.outbound.protection.outlook.com ([40.107.5.82]:30318 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230153AbhBENGa (ORCPT ); Fri, 5 Feb 2021 08:06:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D1qAEryDhrCq5GyxJFZLZ7+sWvvZFi/xZEou6sqh6EBjRxOGFqZ3qVY8NfJDS2ycLOOxn9N1rUbQir/rBpW9PDxbXc4MNXyK9LatKICJ5EON3SfeFBa8XUfOpLEZ1svY0D5F1CDvYLFsferPdtYeSSFeyyL5hy2a2f56OkL+q378lrnY25yIrmFmbkDr4O4KQBJxcrfhbBRddytB5L24C7C64gMIR/O/U8235eElTl3mL+ayOi098WU4UXiRBWTuLv4jVmNmAy9FVATPsT8E+k6kmF4y50daQu8tffLHqYQ+cQEwxHgsQ9FbiqxFguT4GAPUBTVft388StT95IlL/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4wQLnD2xdS5p7rfBRmHeekvQgNTu0JrJ9oQdMDGZ5js=; b=DSf5QLyemHqf6TV00ZiQkcXLUBa6OCuo2N8GqSpbINBL+/rMU4YQBjduyihIoZmZOky7GbWeZPpk8SS5qVoVpIW1qXhhu7EdWhqaW7q1cbUzKTBXFC0jqc9VNOB8zWrjXaiJAXk4MZCqw88yuZQowVV3qhZ6pVTX/UgVvXVQIXl6EYQ3SSwudPVTCe6sj5qzFaFmS8oyEvcj547sgpQ7lqhAXT9i6ckLyA5F6dxQvb89DCAFVq94u93VQvSqnBY3tkCJK4VTRjG1VRZVIvZ23yvBvPlmkCHdpTR835Zh3D5xi/BRE70ALOcc0M5joiJJMyCX1+Azsb2E2seleHdV0w== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4wQLnD2xdS5p7rfBRmHeekvQgNTu0JrJ9oQdMDGZ5js=; b=lj36Qh2LjUHx4hNj0i+RMJS+zEczdBkhS/TC6uZ1xXYVfJD67Ee1Osmp9RI8eVTvPV777lIOdTqPinRGD2bbG3aQ3Bf4CYU7qlU6UP0YTm/g3SlBq/vkAZSqF8p+jFcmV1mnLda+iOuGrUWwBxB0hblxrbe+MOg6e+xn0H7N85Y= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:03:05 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:03:05 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 10/12] net: mscc: ocelot: rebalance LAGs on link up/down events Date: Fri, 5 Feb 2021 15:02:38 +0200 Message-Id: <20210205130240.4072854-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:03:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5cb3bee1-f073-4c7a-bd5a-08d8c9d660af X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pKdDgfW6GnP+oF3bkPGLtJeHmBRhavCMrU8qmC7e939JobkS/3cbAARYZ3qEZWPEzukpz1kSQ4xl8o302Qu8DKb41gAg2bZbkufT2c37qBOzaSv/LLgKLLtwc09KHubTzj/CHinRlY4Wk7F6UVQDFC+/2Fp5k/lj2YeNkCGn0w5h0zoVVAm41hB7Xy1kpKE/KV+5WViLaBmMzkjc5Nm3lbWyGsXVOeFSoeX27BkwvyadA1Hcnt6BP8v1Gf3QDRqS+L9NII9+kULfnYofmBJH1eEmbfWIAY4Q865rESLXOwoCMUFwCpZY0flGj7gpB7ixHbsK0mmm5baLqA/+CtaqiI+P3RoLWGm96EWZIyzmyN8ExrblDiPYMcl2HQ7MAsl101fuW3fvqSHS8xQN34eXi4FT6yOC07hl8BJ1MkA+dnE5wUeXy/u4e5qSDTVRJ2BgfvkTJYUL/W0uq0a2izj5peb6yUp079pR7ivJGSTb9CIMjGIaWLKG1CtxOIljJdHfX6WsUURp9eASq3hjAebndwnMCu8NymKl3Nv8B9bq6P9gie6XQhhf/W7qeQpcK8veWwhQgBCausLeOXSO2PTlPg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ZP3DoWyAPaNMIRQL/SZU1DftP0oiyDPs9qjQJ0ogWFZwtjeXShkz3mLrDrgZIzpg7pKBmISRvlpue3r4J1N+UHCSHI/WHG+eBn1yw9Z8pg9ItDpGiyZD5xpodF4LbwxjoDFJTo6Uvswi0X4ojwtzJzlkw/2TjrXFskirEN8wl4anM9uDfZITlmUHEXt+G60elUYCtMkzGZjlcqWuQKpvKYrZoRHEXg1TH/cHQipA1PxZr653V/3JnXb26DQa1wT1p6YuoEU7Uk97alnrHMJE4QHYpD7/FiNG9CKNS37RRyX//2sUMxoQtUz1wgGwQi76KrOg4v9fQOdJF+SM+6qA5gKvn4Yu4jp1SFzrufTQUsjiQjzQb2DO0guLoPWdmzZ432UTxXV+CSdBv4GAOlgzDrBSs91xMK74XU6MzaRlLICJrgy3wo2smftrWImdPRyqdicdTXsiSzsgGtbuGHqePPSWHyW2fX4bfiUkW8eiXGwOUKgbKmV3HiF4+pDz3wEtIcent7ELB+HKCmS6QU/4i53Tq8qBG/EjP7lI/H141kyo/WZHwSzKRoprl5zYn84Ez+8qNTExhAg+TrrQkYB90yehkopjSFZVCHekGj4s8jyewYTRfn1DsKD2CxuL40oNnm56K8gqvue2S6b/PtHZjNMhmNa0r4Omrtljji+jbuR7RU/PiLIuiUunoPz/ekChXqILLtUwyClEHwAXwuGHxNsi2QTsAvQ/bRtfVPUKeiXSuA1Nj6tofmI3f9imp6iBQv6dXF3QPnL62HjGKopRk2+G1i20KSj9D0PCEZopn57yLhAgRUkPXJZocsv5oNKTzTcqSZ+2iHb79nR9lM5QuISIFBJCBUGX+/3Z/hiHM3tiPRdSlESfCcn8N/nKNZQmyrUpwF/kjMt4+fUZDp8NIipTP1BUBfGvlHriSEA72EGO6T7VXAHbO7VdjVVazKwWtpGhuIFyOhEnq5ByAQ1QrUZCaRuDo8xbXyd3WU0pjOBKI91t908jH47xqMoupSdsIWpnizn3xvyqmi8jizTsbx2JXdZMZ5KiNzKIzN2P+DPGngty7PQrTMp8hYqi+9kg3ym9PAqaBeBgbIAmQo/sj7yUh6pxhWqySKe2QTMmAy/Sy6gZUz/Asrzo/dfAuUQQm0wzt6J7Fh7cum71OJJABwjhSndmSop4qPcUkeK+BDcMDyxD75i1s7x/kla/d/ZmDvul4Q3dhmBuJPtZY0I54ke4vS+rfseyDLSHCkcIlkEyjzi0KptpE9KCuAgYjp5MSpCIqQylHDgy6aqm+qaZW3+zVsjNxMzH5t2oZzZIdqrDi7XdyOjyooXdTO7Q4ynV X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5cb3bee1-f073-4c7a-bd5a-08d8c9d660af X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:03:05.7028 (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: gOJz4RAgvrhq8WSHLW4GWWjpyVESX5hzja78YYcdELleLYtcgpK5nFu68+lNyoC4FtgeLryHrgY7CSuGCltHNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org At present there is an issue when ocelot is offloading a bonding interface, but one of the links of the physical ports goes down. Traffic keeps being hashed towards that destination, and of course gets dropped on egress. Monitor the netdev notifier events emitted by the bonding driver for changes in the physical state of lower interfaces, to determine which ports are active and which ones are no longer. Then extend ocelot_get_bond_mask to return either the configured bonding interfaces, or the active ones, depending on a boolean argument. The code that does rebalancing only needs to do so among the active ports, whereas the bridge forwarding mask and the logical port IDs still need to look at the permanently bonded ports. Signed-off-by: Vladimir Oltean --- Changes in v3: - Return a proper notifier error code in ocelot_netdevice_changelowerstate. - Export ocelot_port_lag_change. - Adapt to changes in ocelot_apply_bridge_fwd_mask. Changes in v2: - Adapt to the merged version of the DSA API, which now passes just a bool lag_tx_active in .port_lag_change instead of the full struct netdev_lag_lower_state_info *info. - Renamed "just_active_ports" -> "only_active_ports" drivers/net/ethernet/mscc/ocelot.c | 41 ++++++++++++++++++++------ drivers/net/ethernet/mscc/ocelot.h | 1 + drivers/net/ethernet/mscc/ocelot_net.c | 30 +++++++++++++++++++ include/soc/mscc/ocelot.h | 1 + 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 380a5a661702..f8b85ab8be5d 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -889,7 +889,8 @@ int ocelot_get_ts_info(struct ocelot *ocelot, int port, } EXPORT_SYMBOL(ocelot_get_ts_info); -static u32 ocelot_get_bond_mask(struct ocelot *ocelot, struct net_device *bond) +static u32 ocelot_get_bond_mask(struct ocelot *ocelot, struct net_device *bond, + bool only_active_ports) { u32 mask = 0; int port; @@ -900,8 +901,12 @@ static u32 ocelot_get_bond_mask(struct ocelot *ocelot, struct net_device *bond) if (!ocelot_port) continue; - if (ocelot_port->bond == bond) + if (ocelot_port->bond == bond) { + if (only_active_ports && !ocelot_port->lag_tx_active) + continue; + mask |= BIT(port); + } } return mask; @@ -960,8 +965,10 @@ void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot) struct net_device *bond = ocelot_port->bond; mask = ocelot->bridge_fwd_mask & ~BIT(port); - if (bond) - mask &= ~ocelot_get_bond_mask(ocelot, bond); + if (bond) { + mask &= ~ocelot_get_bond_mask(ocelot, bond, + false); + } } else { /* Standalone ports forward only to DSA tag_8021q CPU * ports (if those exist), or to the hardware CPU port @@ -1298,20 +1305,20 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) /* Now, set PGIDs for each active LAG */ for (lag = 0; lag < ocelot->num_phys_ports; lag++) { struct net_device *bond = ocelot->ports[lag]->bond; - int num_ports_in_lag = 0; + int num_active_ports = 0; unsigned long bond_mask; u8 aggr_idx[16]; if (!bond || (visited & BIT(lag))) continue; - bond_mask = ocelot_get_bond_mask(ocelot, bond); + bond_mask = ocelot_get_bond_mask(ocelot, bond, true); for_each_set_bit(port, &bond_mask, ocelot->num_phys_ports) { // Destination mask ocelot_write_rix(ocelot, bond_mask, ANA_PGID_PGID, port); - aggr_idx[num_ports_in_lag++] = port; + aggr_idx[num_active_ports++] = port; } for_each_aggr_pgid(ocelot, i) { @@ -1319,7 +1326,11 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) ac = ocelot_read_rix(ocelot, ANA_PGID_PGID, i); ac &= ~bond_mask; - ac |= BIT(aggr_idx[i % num_ports_in_lag]); + /* Don't do division by zero if there was no active + * port. Just make all aggregation codes zero. + */ + if (num_active_ports) + ac |= BIT(aggr_idx[i % num_active_ports]); ocelot_write_rix(ocelot, ac, ANA_PGID_PGID, i); } @@ -1356,7 +1367,8 @@ static void ocelot_setup_logical_port_ids(struct ocelot *ocelot) bond = ocelot_port->bond; if (bond) { - int lag = __ffs(ocelot_get_bond_mask(ocelot, bond)); + int lag = __ffs(ocelot_get_bond_mask(ocelot, bond, + false)); ocelot_rmw_gix(ocelot, ANA_PORT_PORT_CFG_PORTID_VAL(lag), @@ -1399,6 +1411,17 @@ void ocelot_port_lag_leave(struct ocelot *ocelot, int port, } EXPORT_SYMBOL(ocelot_port_lag_leave); +void ocelot_port_lag_change(struct ocelot *ocelot, int port, bool lag_tx_active) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + ocelot_port->lag_tx_active = lag_tx_active; + + /* Rebalance the LAGs */ + ocelot_set_aggr_pgids(ocelot); +} +EXPORT_SYMBOL(ocelot_port_lag_change); + /* Configure the maximum SDU (L2 payload) on RX to the value specified in @sdu. * The length of VLAN tags is accounted for automatically via DEV_MAC_TAGS_CFG. * In the special case that it's the NPI port that we're configuring, the diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index 12dc74453076..b18f6644726a 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -114,6 +114,7 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port, struct netdev_lag_upper_info *info); void ocelot_port_lag_leave(struct ocelot *ocelot, int port, struct net_device *bond); +void ocelot_port_lag_change(struct ocelot *ocelot, int port, bool lag_tx_active); struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port); int ocelot_netdev_to_port(struct net_device *dev); diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 0a4de949f4d9..8f12fa45b1b5 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1164,6 +1164,27 @@ ocelot_netdevice_lag_changeupper(struct net_device *dev, return NOTIFY_DONE; } +static int +ocelot_netdevice_changelowerstate(struct net_device *dev, + struct netdev_lag_lower_state_info *info) +{ + struct ocelot_port_private *priv = netdev_priv(dev); + bool is_active = info->link_up && info->tx_enabled; + struct ocelot_port *ocelot_port = &priv->port; + struct ocelot *ocelot = ocelot_port->ocelot; + int port = priv->chip_port; + + if (!ocelot_port->bond) + return NOTIFY_DONE; + + if (ocelot_port->lag_tx_active == is_active) + return NOTIFY_DONE; + + ocelot_port_lag_change(ocelot, port, is_active); + + return NOTIFY_OK; +} + static int ocelot_netdevice_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -1181,6 +1202,15 @@ static int ocelot_netdevice_event(struct notifier_block *unused, break; } + case NETDEV_CHANGELOWERSTATE: { + struct netdev_notifier_changelowerstate_info *info = ptr; + + if (!ocelot_netdevice_dev_check(dev)) + break; + + return ocelot_netdevice_changelowerstate(dev, + info->lower_state_info); + } default: break; } diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 089e552719e0..6e806872cd24 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -613,6 +613,7 @@ struct ocelot_port { bool is_dsa_8021q_cpu; struct net_device *bond; + bool lag_tx_active; }; struct ocelot { From patchwork Fri Feb 5 13:02:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12071229 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4D17C433DB for ; Fri, 5 Feb 2021 22:43:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B93B64FEB for ; Fri, 5 Feb 2021 22:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231307AbhBEWmk (ORCPT ); Fri, 5 Feb 2021 17:42:40 -0500 Received: from mail-eopbgr50055.outbound.protection.outlook.com ([40.107.5.55]:48454 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230373AbhBENH0 (ORCPT ); Fri, 5 Feb 2021 08:07:26 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SrjMqKcpufZAvkrOmG6cxcSE6WzGmeqDirJHDyABkKawxsdK1XCS0Vq1z7uWu6GFRedYP1cEYLMoh8+61PtHHqw+EAyHDXU5UKwjI1Cxl+4ycfu/f1mMs2/KNuaSZt097wSBwYdl7l7GbXqiU7BUa3NyeNZUbwAEa809Z+Qoh4cpIoZC4hYP3dD8ThDsZvvhyhcZWpwEK/Su3UBFCpVrgDmHt0u1GgjA9JGGZs/0FR8x6Q06pcq/cdYziI0BKRv0WXEEqFNyZVJp+P0AKh7UFZKAQq9tiNcPL2iSxdsY+QeWuNkMQhzK2RCVHiNKG2UeaUTU+eMSKC+isGcg+JfXVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nEsuV7KHvJazsixLqMGHAuT7jOzle/sdox0jiM/nJRA=; b=gxyBahjYpc0pvGkK+aMA1cJrLOzcnsvtveTB7ug6nBarpt5Hrn0Mps8P7+bdGQUhJtisSk0ymZsBh8RCnwjJIbE0CR50va+O0HjBGMFSLlWX9Xh8Z6expo8kqmR6BNNxDsGAl81NgJC8Q24Pe0/gpwslAnwVW26M/L99GqSLdTabTLV1oLhHNBH17ghXVOzuhDipO9w6ac70ZYs7i9xEHBitwvmTPOYe2laV5b3fu9ncqSSB+N2jUryQziuY4GxSna5wNZ5sMk0Pkv4V7Ooz67E14oq713lyqO5GHIp5Dzx7y4KvcrYfSwnf2CESoea4jFzHqrQmWRJY2Q9cI6swiw== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nEsuV7KHvJazsixLqMGHAuT7jOzle/sdox0jiM/nJRA=; b=WWo2OEnQtYzriRwAFf0nSRqwnWTGgTcRXoZTbSsW8Rqv9WRTmv53hgwd32ZCur7Xb5BgNX9FjpCjLO2mdzgoyVLeL4NCoUzOXlO+1SYrLpp3LevYiwiGGDDcBp0Q3GnEKsF8IZAjz2o0fQ8g8bSNjrYJZ9rfFnUZl/d3lFd7Lr0= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:03:06 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:03:06 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 11/12] net: dsa: make assisted_learning_on_cpu_port bypass offloaded LAG interfaces Date: Fri, 5 Feb 2021 15:02:39 +0200 Message-Id: <20210205130240.4072854-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:03:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8542b12e-4efb-43f7-2ff7-08d8c9d66111 X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0pEegyLf+otkv6S6H0Z3IZryzSFxHGvZwYSHdvXF18ieInfV67Jlx85pbGYaTHkgW926ee63f7xsXIewJkzPG1saHKOlC1tduM+9bvJdXOv6HnJuS3y7pSb/HZjf5hRwGuXPnBSxUfKQUK7Dk8yBGONXn/P3KVXuk8ppYc5LXWoo9BdbIx8wl8zJStfAUpF4x7ArXnHLpHRHjPCsZtHifzTViUBjef837nZuBKLqQRtFha3wmhflGSftBEBnXDBvVBBzlKb4uTCfxBqmO9wky+YR1KRgOByGgD8cmNftQYmD3ezYVIPocfTZcQ1z6xbt3g370mklLsm6nGunAH2iTpU/tJrPSUmP0pDnjiZtYe6iJVPZACs2Hs0Iu0KBA9njxpscc++rr5fxaXbZE0s+/W6YmaSrV8OgiEUT+U7nmAKoEGt2aNUNfN6VJDewbysjuMzC9aEMLwfN2uozUZaeq4xBCYKfoNagem+Y6LJbClobKRmKDhc92mNtHHEzlKfKC6UlA7JaNdMjtf0EEnk0cDTKJf94PW2UVGcEaPC5e/+Duq5eKidvs6nWeK9CqurtO9PnbfsoVnabf+5fTI2nLQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Shv6YkFSgKOroS3wSfDVplDB1jkViJgEZ6gBUldko8jQie0GkkTCFXIGmHIDo6/F1sY+04UZGPa9zonUio44ybBthI/1sr94s+i7w9in86wlqNLjHt4X0/oIwFEp9st03m1GiAYcCrgyhIpyARRAMeUNiycD4Yum33CNICmHp1PMbjxM/sxjJBhT9/8jjl5BLkcrGDikoMHGo/au9TCwBo7fA/a3VW2eRoBRXFc7bd2GHm/yKFN955kPB1zgumQ26CznTAyrkx2Z9YoN9TMrqUnrJmQDFUfVFTO76zkk0QHdxWpj7SRLiM+4GAhKJ21tzQ5WIy3BH6e3goFWf+blxGxdlf6HxxcVTFaDxGTaU/THxGbA3F2ASWpduTQeEouuClnmw84cnKVdncfwjjzCBPuCwgFCtqO/m35J3LMnKpH1Yex0ABzl9/e5n0B0ALTX1HughLMycJOO78Q/gyFzUgwauY5M0xMe1vj46t23hhAe9Ja4eJQIJ73woonlJQI1R/NUZxaj7DOVaL86EW1hsP6T1TcyB1j83sNP3mLEmpNPZ5id1pJuWKctXaGt8jkqnIwwJEjfZsvv0YohnjbbI5PBTQ7FY0yZRXSBkXCB1nS4qAFSs70WJ0v9ezKlcogxDhmqtWYD+6CkFWchUcDljHZt+DiUnVedAf/Z68sfVsldlHa6qRPv00VggkuBctLDJytjmXWB4UJtMY2TidysEJyjHlPsn/tXLmZKRsoOS0gZt6MP8a2lTxyXin59UnM9pPnF0ka3/gK8Q3ITvxiLGaOSKoWqahcQQiH0CNprfl1HsHzHhUoRupVxiT790wjowXmcABQNK27W9Uo9i/P7IrDavZi91Pp6n0CJMhZfDTU2enH+/dhnR9cmU/Y7pWonEq8ML37QRsjSGc2Ua4KO015c/wN04gHtApcVsAGomqBH1fGpraYqY2rhq+iuQef5E4AQ9/jCCvOEvllqZ88qGVi/zzTI8nhQXsFl19ONh6JBhbqmBmTFC8GgCr4lzj3vc9ApZLf5jsMVlb3JfFUPFGX+6p5Vs2KgEjEgUwGyWwjrGPWvtgHz6wh3cL6YotJ9rQORoY5ybyxj4U6WbMXT9xaMjx0s2LaXIvd9wWqigJvwWRdcImUI61SOdDq53jx26MungEJgg64TOq3kV6A1TrNN3u6YUnfTpVibU41MsCiH2boySz3ffYMHbtZPWt7i5wMjM9xQc/xV/C3htvdKvBJFXozL8G8jMBStpw1t59+79mhXZ/mrlgo4jWTXKCqSpT2vIzp5JdzyaiTl4ad02ethppewr12Z2gjmKXCRiULGJhtI5waCT2ChSjsFNtpT X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8542b12e-4efb-43f7-2ff7-08d8c9d66111 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:03:06.5183 (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: qfdp/Ax9mC/k3Wm8dYTpCiZ+/6nU4C2dwx4aNLg0xKKiRMrGzIu5DxfPKHRR6qkrSUon0MmbGXV9J6TWUPp2yQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Given the following topology, and focusing only on Box A: Box A +----------------------------------+ | Board 1 br0 | | +---------+ | | / \ | | | | | | | bond0 | | | +-----+ | |192.168.1.1 | / \ | | eno0 swp0 swp1 swp2 | +---|--------|-------|-------|-----+ | | | | +--------+ | | Cable | | Cable| |Cable Cable | | +--------+ | | | | | | +---|--------|-------|-------|-----+ | eno0 swp0 swp1 swp2 | |192.168.1.2 | \ / | | | +-----+ | | | bond0 | | | | | | \ / | | +---------+ | | Board 2 br0 | +----------------------------------+ Box B The assisted_learning_on_cpu_port logic will see that swp0 is bridged with a "foreign interface" (bond0) and will therefore install all addresses learnt by the software bridge towards bond0 (including the address of eno0 on Box B) as static addresses towards the CPU port. But that's not what we want - bond0 is not really a "foreign interface" but one we can offload including L2 forwarding from/towards it. So we need to refine our logic for assisted learning such that, whenever we see an address learnt on a non-DSA interface, we search through the tree for any port that offloads that non-DSA interface. Some confusion might arise as to why we search through the whole tree instead of just the local switch returned by dsa_slave_dev_lower_find. Or a different angle of the same confusion: why does dsa_slave_dev_lower_find(br_dev) return a single dp that's under br_dev instead of the whole list of bridged DSA ports? To answer the second question, it should be enough to install the static FDB entry on the CPU port of a single switch in the tree, because dsa_port_fdb_add uses DSA_NOTIFIER_FDB_ADD which ensures that all other switches in the tree get notified of that address, and add the entry themselves using dsa_towards_port(). This should help understand the answer to the first question: the port returned by dsa_slave_dev_lower_find may not be on the same switch as the ports that offload the LAG. Nonetheless, if the driver implements .crosschip_lag_join and .crosschip_bridge_join as mv88e6xxx does, there still isn't any reason for trapping addresses learnt on the remote LAG towards the CPU, and we should prevent that. Signed-off-by: Vladimir Oltean --- Changes in v3: Patch is new and necessary due to the recent introduction of assisted learning on the CPU port. net/dsa/dsa_priv.h | 13 +++++++++++++ net/dsa/slave.c | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 263593ce94a8..8a1bcb2b4208 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -209,6 +209,19 @@ static inline bool dsa_port_offloads_netdev(struct dsa_port *dp, return false; } +/* Returns true if any port of this tree offloads the given net_device */ +static inline bool dsa_tree_offloads_netdev(struct dsa_switch_tree *dst, + struct net_device *dev) +{ + struct dsa_port *dp; + + list_for_each_entry(dp, &dst->ports, list) + if (dsa_port_offloads_netdev(dp, dev)) + return true; + + return false; +} + /* slave.c */ extern const struct dsa_device_ops notag_netdev_ops; void dsa_slave_mii_bus_init(struct dsa_switch *ds); diff --git a/net/dsa/slave.c b/net/dsa/slave.c index b0571ab4e5a7..e5c227e19b4a 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2215,6 +2215,14 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused, if (!dp->ds->assisted_learning_on_cpu_port) return NOTIFY_DONE; + + /* When the bridge learns an address on an offloaded + * LAG we don't want to send traffic to the CPU, the + * other ports bridged with the LAG should be able to + * autonomously forward towards it. + */ + if (dsa_tree_offloads_netdev(dp->ds->dst, dev)) + return NOTIFY_DONE; } if (!dp->ds->ops->port_fdb_add || !dp->ds->ops->port_fdb_del) From patchwork Fri Feb 5 13:02:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12071227 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 088B9C433E0 for ; Fri, 5 Feb 2021 22:42:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE66664FEB for ; Fri, 5 Feb 2021 22:42:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229989AbhBEWly (ORCPT ); Fri, 5 Feb 2021 17:41:54 -0500 Received: from mail-eopbgr50040.outbound.protection.outlook.com ([40.107.5.40]:14756 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229756AbhBENH6 (ORCPT ); Fri, 5 Feb 2021 08:07:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eJivCSoDgg9MwWy2MaoocjIUzfuHtgbQdsOWIUa1NXLi+piVMezHkipLJYLC6MFTKndg2WfQvJ8JjMQy0aj6yRKTky9QfFmghEXtTooGHnKNmQpUv/bbgosno0XYEktEOX6qR8aEMN5+oqV09tFnslA+6yFVatx7vFu6Qqhl2bYpr26nx9CUjiU4qDwxF/VCO869C37lmKMboDNju6vdKjxRVaclEXC7G/s9OPuWm5HnzRXeoDUBflRj12JwAgTqmMlB+WdT3YG3YY4PRpm94RADoE61bGxXIZ9Lr8lzeFA6O27opdbiNbfhQ3ruR8s3p4Cqvv8JKXGOA2Yz6eAQSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jNbqQ0SyjV1HMiL7P/ktuVpv7oBHJaR8LoGaRVhhS6I=; b=F6JYWdI8iGKRUru6kZEqU738wQSRdLExkkdPxt8Md4pnc+nb9fuswnxethrrUtLQKZOmxloYkyJhDFfSlHbOX5Gmp/FziCewIcdEe5EJwJbM0pMX42pohGkJokKl97Cx/VSoZCW0OglSCkLKZppVIZxmT8zkNAgS5HwSR7hDzeJAQUZEkAfQuSYkI8U+ucPkZglrztPethkZceHF6D4ekwCn/LKkvkIqi967KjQax9t3r0ULegb/cOzCLx4fjUtVwj/v0uRuNqjleS5dBJYlpFnilaKYPsCNymGsOzvuZaylGSPXP3u+Y9rBIOdsV/VRD1jga93s/vI8OYgrtPnivw== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jNbqQ0SyjV1HMiL7P/ktuVpv7oBHJaR8LoGaRVhhS6I=; b=ZuMz6G9FaUqh1+47sWG+vDRzLLh3Htehu8jQIYbIj8omUx8cl7dtoYeHOPomJXBMIweIN+yCVjIKHupUkHWkgLGjmxP7VimKhW8Hyou9v8MIJArBr0ck9OCL1M+jdZ6S2kxZQUFTt84St2ABXlR2okqP/olwx2MX4jxUnWjnlog= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Fri, 5 Feb 2021 13:03:07 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3df3:2eba:51bb:58d7%7]) with mapi id 15.20.3825.020; Fri, 5 Feb 2021 13:03:07 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev , Microchip Linux Driver Support , Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [PATCH v3 net-next 12/12] net: dsa: felix: propagate the LAG offload ops towards the ocelot lib Date: Fri, 5 Feb 2021 15:02:40 +0200 Message-Id: <20210205130240.4072854-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205130240.4072854-1-vladimir.oltean@nxp.com> References: <20210205130240.4072854-1-vladimir.oltean@nxp.com> X-Originating-IP: [5.12.227.87] X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (5.12.227.87) by VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Fri, 5 Feb 2021 13:03:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5f99ba21-a240-43f9-a9a0-08d8c9d66189 X-MS-TrafficTypeDiagnostic: VI1PR0402MB2863: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: maONwAOqY2g1kdGZ0XsyS9HjglZ8JiVoSDBS19qVbD3FBl71W5eJ/bWf6sbiXXGZGrDxRil6fGEF+MecCW3JK3bchSVG5H945/3Ycxj/hsnAx2xckR4EXbegAZKlR1p8+pNzsgZ9EYd+xEdvm7OzSVSF9FmDZ3lu5Z/Mx4kPDKg5EPBZIO65ySs7OLRHyCxeQHnNC6BAO7LTQ/5xsm4mgF85Do4Kn/xd639PifeShULd4E4l1CWNHOLKstIRMOb4tdjPYOI3d7v6G7cL2LG8sCi50993lwmDYgFNNMnHhw2PXDltQpKkqbeOrBpDAOJ9JD2OlvITN3S1364yL1nTjjALW4+QUPVPla8kJNvwm1L4/D1ZaxIwrMgqZd2Y3eBj+tOT34sLCLI3gYYP9CtEWHAkwgL6BDdCmBh0xsJfFziw0P5aDOv3pdFmQN77gZAF1vHhJaOEqnOkkDK7Z2kenFi42jWk55T/0WhEaBbUv6j6o2HJPlttSdZP6YMA2s+AJPEZQlYFw/YYAnGY5cpCGWaYk5KQJRbUu2frfIUryi8/EN/q8/LUiJtiqzUsNK0MG5ne7/8i6HvRu0bOgpC/nA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(136003)(346002)(39850400004)(376002)(66946007)(316002)(26005)(86362001)(6486002)(83380400001)(186003)(16526019)(6506007)(69590400011)(2906002)(5660300002)(44832011)(478600001)(8936002)(6512007)(4326008)(52116002)(54906003)(2616005)(110136005)(956004)(6666004)(8676002)(66476007)(1076003)(66556008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: dYKKsCLTTart7WlvoDIW1p8GQ0WsBzi3SxVNZi66baCN9L/CEk0DiU15agui61bpYRIuKkb+DdUS486IBNJe4irmtYILHsQzqxmxUF4xSllFR18kVDzD+8jq7lc0HOPB9F/MXl0coa7rVJ3Hw4qjWIMJ5MNtqeyLteqlQ5BG6GHRssGWEl35nRd8C7IVxoG4NExJjbyvN8uCI3zfgNIa8xwAMAlQW7AaImYRMOsLFGc9wKHQoMiIb7o10NUhF+Oq0+ica5ACA6lu8sC6icVV1R+PzU2WdkvBo+0cKMtkP5RwZRMiBCcWMS0IMUW30eda3RmBWkbrci9iuS0whuEAd2rJDxEJbgeJsOafFX0MTQcDiYw6bXhFhPia+A0jrewaVROzFHaUeEmua4Zs9iHo8pEEEkpyl42iJ+n7eNMLlTLI/ViCzOuJb8iTXp8YoI22jn9zqeuIrWBnToGBn29Fg8EpWC+ovjPxwGcEyiJhnMyf700/PbB+XDG4fkf1hm977yDibIlOSuiDFfqG6N1d99npgrVqZCwsqZjx2T3pVZOeSWmiA16HIdtBVkrLQSdwrfYzqc0wrV7mvz5/wx2lGMB8yf3pNzGFi0fuBschSu+NX7nfbl2oQQNTLL4T17ZvxE1ZA5aDC5vL2eQV6RGMF19A3uxj2j38RbicFaTA+vYF8F46jnMehnuJF+D4hwhhHXIO/0h7iK2xHPb1w4u/Z+aC0eHcburASZpAlWmFakk+y6IaFezymrhtBmXLVOMwTLZLj2Y+JBXPbqZTu3Ju/08x3vRyfYoW3yLcN91GC26Sm4jdy6RZvHYFbvka5DsySZt2jCk6MSO5Dq+ibdxnOVjNmNcBfltrMAx8H/tS2SjgE2jBp+x8cGn+U+6+xx9LCrrgW/69zE+xtFNQWt3BREH9IbokrxFTF+aDj9zVSJnGWr5xCENBru1LW89tD5zW1hxzNGpJpMrvbRmJKxny0Y6lEFJ7ix/LV4COGPqtmZ3L/04Sa2rXBVqkUWXccjQ9K7pGqOgBfCUUp2N1KwS8+ww3TNp9Q1kO5YtBKLejrw18lmplKzZ0gWcRPn0EqH4aSISwl2v+RN0FJEBR2zmWN43O6JBti6staM3UpF8yRfsD9bREmDL62PUewWaEPShRihBWckuIWGseyNaYTI6oymn39GDMhyEUjn3g2hWf++CkKBNwlmrBA3FyvLBP37oMNxfkJxwYBntIeokJpybmZ1AVSQd5P4eTXdQv+fG0SZHEf54tlB/TrcKBTVBjpwmi897QK/iX/lmgdsj7FSWt7XyqP1nJBXlm7akjpjgy5gL7ewGptuVu1PwAnW3jK6oM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f99ba21-a240-43f9-a9a0-08d8c9d66189 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2021 13:03:07.1640 (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: Xo4j+7nNDYwItOhf3KffOQioB3y1SUTSu6bw6nOMGPXNLqD5j3W7WM0ubVI0Nskjj29YNHrkGCoGn/dJ3lBE2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The ocelot switch has been supporting LAG offload since its initial commit, however felix could not make use of that, due to lack of a LAG abstraction in DSA. Now that we have that, let's forward DSA's calls towards the ocelot library, who will deal with setting up the bonding. Signed-off-by: Vladimir Oltean --- Changes in v3: lag_leave and lag_change now return void. Changes in v2: s/lag_dev/bond/g drivers/net/dsa/ocelot/felix.c | 32 ++++++++++++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot.h | 6 ------ include/soc/mscc/ocelot.h | 6 ++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index c3200dfcb83b..a9840e80bd1f 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -569,6 +569,35 @@ static void felix_bridge_leave(struct dsa_switch *ds, int port, ocelot_port_bridge_leave(ocelot, port, br); } +static int felix_lag_join(struct dsa_switch *ds, int port, + struct net_device *bond, + struct netdev_lag_upper_info *info) +{ + struct ocelot *ocelot = ds->priv; + + return ocelot_port_lag_join(ocelot, port, bond, info); +} + +static int felix_lag_leave(struct dsa_switch *ds, int port, + struct net_device *bond) +{ + struct ocelot *ocelot = ds->priv; + + ocelot_port_lag_leave(ocelot, port, bond); + + return 0; +} + +static int felix_lag_change(struct dsa_switch *ds, int port) +{ + struct dsa_port *dp = dsa_to_port(ds, port); + struct ocelot *ocelot = ds->priv; + + ocelot_port_lag_change(ocelot, port, dp->lag_tx_enabled); + + return 0; +} + static int felix_vlan_prepare(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) { @@ -1341,6 +1370,9 @@ const struct dsa_switch_ops felix_switch_ops = { .port_mdb_del = felix_mdb_del, .port_bridge_join = felix_bridge_join, .port_bridge_leave = felix_bridge_leave, + .port_lag_join = felix_lag_join, + .port_lag_leave = felix_lag_leave, + .port_lag_change = felix_lag_change, .port_stp_state_set = felix_bridge_stp_state_set, .port_vlan_filtering = felix_vlan_filtering, .port_vlan_add = felix_vlan_add, diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index b18f6644726a..c485795c606b 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -109,12 +109,6 @@ int ocelot_mact_learn(struct ocelot *ocelot, int port, unsigned int vid, enum macaccess_entry_type type); int ocelot_mact_forget(struct ocelot *ocelot, const unsigned char mac[ETH_ALEN], unsigned int vid); -int ocelot_port_lag_join(struct ocelot *ocelot, int port, - struct net_device *bond, - struct netdev_lag_upper_info *info); -void ocelot_port_lag_leave(struct ocelot *ocelot, int port, - struct net_device *bond); -void ocelot_port_lag_change(struct ocelot *ocelot, int port, bool lag_tx_active); struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port); int ocelot_netdev_to_port(struct net_device *dev); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 6e806872cd24..d0d48e9620fb 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -798,6 +798,12 @@ int ocelot_port_mdb_add(struct ocelot *ocelot, int port, const struct switchdev_obj_port_mdb *mdb); int ocelot_port_mdb_del(struct ocelot *ocelot, int port, const struct switchdev_obj_port_mdb *mdb); +int ocelot_port_lag_join(struct ocelot *ocelot, int port, + struct net_device *bond, + struct netdev_lag_upper_info *info); +void ocelot_port_lag_leave(struct ocelot *ocelot, int port, + struct net_device *bond); +void ocelot_port_lag_change(struct ocelot *ocelot, int port, bool lag_tx_active); int ocelot_devlink_sb_register(struct ocelot *ocelot); void ocelot_devlink_sb_unregister(struct ocelot *ocelot);