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: 377426 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 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: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: 377450 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 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: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: 377427 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 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: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: 377428 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 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: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: 377429 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 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)