From patchwork Fri Feb 5 22:02:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 377954 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 E2CC5C433E9 for ; Sat, 6 Feb 2021 03:15:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C33F464FD4 for ; Sat, 6 Feb 2021 03:15:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231680AbhBFDO5 (ORCPT ); Fri, 5 Feb 2021 22:14:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbhBFCzS (ORCPT ); Fri, 5 Feb 2021 21:55:18 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0737C06121E for ; Fri, 5 Feb 2021 14:03:12 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id q2so7558977eds.11 for ; Fri, 05 Feb 2021 14:03:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=33tPkKQOYyma2ofwMWOEyRy7yLPx/4Fcn7KgmHqtobE=; b=mx3krhsdXsiKM1HoO1VhgYZNYY+/oZdtogTmLJZwpZDw0wX5hEth+8x7sktwU7rYI6 B2C6/NcJoxhNx6EHCKUwA0uWuU64WephrO7iVndFwgAy2LsEPzoWbQZlIujVm0DeNesZ Zdog3hdb0mku/C7tuEf6oDCUMeIGzIsYXY40Eh2aYImNJZ+dwI2um4eeQy5rHZqm468r 9zyZ0jOYDxaNTL11Ae6i6gjmo6YCNLO/03i+PXpphwm18MxX0lqshfbQWPZ+FdnrVTsP vw3zf/Lr5lvRIiKIHZ9//8wGcavAefziR3yMmRohD7feQpwt9gDXdaOnS6ab7FWSB4Fp s8kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=33tPkKQOYyma2ofwMWOEyRy7yLPx/4Fcn7KgmHqtobE=; b=PV7bXAv+8BVWOnsz/Ai/Jc2MPBAZYdJi5Rzeb0Vh/OY1IpMNy9lJfWhtH8Q4nwrCTY v3r2Wr+3oSMp5e9bcVJe3TB6e1jBAjKOD+dcGw4Sec/ogS+GR8PMarBxOCWCDSolnu/h kQUCp8KktgvLYmIjmT3D5uArhozg9H76PLk+ySIIb+N2xnBuGzfTEv2fXop1rtmltkJi PQjUorgb5+fEGTE/8GG/Yad68225cp7tZxCkEyPtbjpUuXVaiOKIUY3jCEpl4TJp7M1A Pd1iCUy79WuyWMJFvNavArTf3MIakKDsYFOnXgt7fZ07O/m92ebD0eE5RWzvBExTF2zX JzPg== X-Gm-Message-State: AOAM532lhpBwk/dkv43CMXNfac/VuQUuBFZtGJ7HgsFyPBRyiZsPUP2G f6Ept0ny29e5WVOkVPyRXh0ChowPuKQ= X-Google-Smtp-Source: ABdhPJydUOBQgiLZTK7hUUpOrV3ZDTCYsJT4qI56ActtPk3c7Jm4mY3QOUPOpHw6qX9bjORir9OwvQ== X-Received: by 2002:a50:fe18:: with SMTP id f24mr5542422edt.276.1612562591720; Fri, 05 Feb 2021 14:03:11 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:11 -0800 (PST) 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 RESEND v3 net-next 01/12] net: mscc: ocelot: rename ocelot_netdevice_port_event to ocelot_netdevice_changeupper Date: Sat, 6 Feb 2021 00:02:10 +0200 Message-Id: <20210205220221.255646-2-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 378408 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 F2260C4332D for ; Sat, 6 Feb 2021 02:43:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB8EF64FE4 for ; Sat, 6 Feb 2021 02:43:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230055AbhBFCmq (ORCPT ); Fri, 5 Feb 2021 21:42:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231378AbhBFCid (ORCPT ); Fri, 5 Feb 2021 21:38:33 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C09CC06121F for ; Fri, 5 Feb 2021 14:03:14 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id l12so10720216edt.3 for ; Fri, 05 Feb 2021 14:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e65FdPPpPqsFXEIrgbCwnULwizGY4EY0nzN9rQzDB7o=; b=A142HV9ssaJZupirkDrITJqg0p7RaBikisEXHSAW8wEe8vSkgJzwuPfbdU8c9TCPtM TvDbowcuS1eqRR2y/4dB77ylRtTBc8xaeD05YDXUOoayG8KThtDhrNI3PqG4H52gr+D0 Fjj/fRPO4pJx1Vt6y4V44gTOiigXPxyqOk7gb/UBrfI3gecXW51bBTQKwhWz2U1K57my 8xk55v0jrUaXAyAtoko1MZLGmFL0k5tPFBdOjMQ8ntzkE7Q554REvkMDMjJ2fCzMqyql q7Xd2AlrxTipPUvboPWnSFo/Vf6a3iHUB7fzgVz/tMloITN6bxshDQoSNVNWW+UWvVWR FNMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e65FdPPpPqsFXEIrgbCwnULwizGY4EY0nzN9rQzDB7o=; b=UmRAPQXtlOdDCzhOuALCFCxnlBxuAahpY9uNMIvlsQ05lbkEvxv7VCGBat7RU5B25C mxidukplFodNbvMX+f+CsgzBUPQFfGEUIR+RBSR0oVxaBYgIodzwLMQjgsXjhdicsmN2 dpWobigZbykCvYnulwtMqWTOTLMMe7c5ecqwmPEWUu85W1AXZGg9RUMRtQzZnVKof5Ep kEQo6v2+qgCl+uI8EWYwHYJjPTraAsetJcLCt9jr/Do/YZHE2k6GPh99YWx95Ln55yND l8U60sq8ML43NeTtUn9NonnB3PfRL3QFpvrKPFrFjRTwj5KEChWVcM5x6tGdhQ/YsWBl kW+A== X-Gm-Message-State: AOAM530vwjfWFLg04NBvVAUAm0EsKHQM8EKKJUCvQkUclyUhjb+cEbuX jCpkPrpT1u1vr+ekc30N/h0= X-Google-Smtp-Source: ABdhPJzPkrIoxAlHZn+ESmKg2TCsAsUEscKAS5uzXk3W8Z9W+F5smNCf5ya0SgyOPoUVwKOhAmEBdA== X-Received: by 2002:aa7:d149:: with SMTP id r9mr3856361edo.38.1612562593039; Fri, 05 Feb 2021 14:03:13 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:12 -0800 (PST) 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 RESEND v3 net-next 02/12] net: mscc: ocelot: use a switch-case statement in ocelot_netdevice_event Date: Sat, 6 Feb 2021 00:02:11 +0200 Message-Id: <20210205220221.255646-3-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 378396 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 432F4C433E0 for ; Sat, 6 Feb 2021 03:13:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D1CA64DF2 for ; Sat, 6 Feb 2021 03:13:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230421AbhBFDMz (ORCPT ); Fri, 5 Feb 2021 22:12:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231614AbhBFCpo (ORCPT ); Fri, 5 Feb 2021 21:45:44 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C4B9C061221 for ; Fri, 5 Feb 2021 14:03:15 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id q2so10713184edi.4 for ; Fri, 05 Feb 2021 14:03:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w6Xc58ToC8+ijxTxPbxGmb5r50nmvZ4Yn9iItw/4NHA=; b=ffCP1X2ParYu/ejogj+4GSu4qx1CAKARusYm7PwK1YJI2y7BFlTkH0imucZVdeNYI6 /cA8kp3EH78Qs5I8Huuv4NBg9WXuU41AkLM8XXVqH6sf6Dh8Ya1tS36worrHQZQZazhA F/eIwKoDsEE7hHFBIx6P9sNRUcDblW7Obf8JkGg7FeLxj7xQKsjWSZZgteqh2TNlpad7 hQe1vf9MVhegMne6YZhhJklL3IehoNZyF9uVWxAJfkGeiBt+YPg8avVeID4//L/q8q0F zgnxAnYjBa+TmSBIfxKzK6/SivXr/GMIf4CHWa6JlEW9y06+3IYh8LvK2i4WRSYa7YpK b+qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w6Xc58ToC8+ijxTxPbxGmb5r50nmvZ4Yn9iItw/4NHA=; b=W9ZKTm1Yu9asKHPEASv1+x6sNXedFMBAg9G9JWe9HnWc7lCT27x0ft4bYVjGI5Tvrh ro5gspOlySdze5oWaCVb74R85Vx1vHfQ4pSbaza2eD0qyMSkCEi5XynHdcJUoxqGr6Fx cZ+BsOSGjFgsE5Ugi2C5XWmgwz/4wqEWcvNRCffJCBpCMoTX3aP6em6O7O4gNKnetJei GrPrV/ntOEr+js1fIQerItOZw/qkdI8Gb12hJSUszP4BYqMy98Z2tVhj3gTw/0S2OvWB Eyisgz9Vu0IZhIHmdzF9LruH5MGBCJFyuZCTQihXWspxujS1dDBSwSZjTFO1mgyuplXW f3wQ== X-Gm-Message-State: AOAM531on99GQjFPldXYy+QP2S77GXiZl86xPd8fvQtCy9iKO935Prp/ /iWeiq0SQ+5uGa49IA8Tbsg= X-Google-Smtp-Source: ABdhPJwbg8Rb0pDYrEZuxrZduVdiYzEtnXgDq4m53vKtl7scvkfxUkyuBPLE2uzadL0uxeuLas0K+Q== X-Received: by 2002:aa7:c9cf:: with SMTP id i15mr5577178edt.296.1612562594250; Fri, 05 Feb 2021 14:03:14 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:13 -0800 (PST) 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 RESEND v3 net-next 03/12] net: mscc: ocelot: don't refuse bonding interfaces we can't offload Date: Sat, 6 Feb 2021 00:02:12 +0200 Message-Id: <20210205220221.255646-4-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 377949 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 A4BFFC433DB for ; Sat, 6 Feb 2021 03:26:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5675B64E26 for ; Sat, 6 Feb 2021 03:26:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232555AbhBFD0N (ORCPT ); Fri, 5 Feb 2021 22:26:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbhBFCbc (ORCPT ); Fri, 5 Feb 2021 21:31:32 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8642FC061222 for ; Fri, 5 Feb 2021 14:03:17 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id p20so14443390ejb.6 for ; Fri, 05 Feb 2021 14:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q4n4FGiLY5qYF4qlcv5Fy3UvQcNQkdKb8FPZmbU0xEw=; b=AQDktQuEuUFrzVhSCwa/k3BJsOCKcsx1w/OWCQsIX9TPo8KMKn04nypL5Qeavs6XPK fEC4xNpEAtuyyegJB1HC2MnpTIWJzSTk+7tCB2ZDIIcFY02yB1t+NAZI2OkSeJacDKRx esUjIwm+98wyouQDFlSYitk7h2vjSIAOWV9pAKoTkueCNWI1m+Q8FLJYftywyPfC1BB3 MEnZUPbo9rdFnN0caFOeUqLHJsALPCqGFnRYDNt/T5nZ5Ox6Vz6pqUhmynAM1uriqyS+ FNb29Q7PSgkCgouKgKYHQrowkMAbE68QcaY5ti5M3uAuEEQ/p37hr/hmfc1sRs1icB9h wp2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q4n4FGiLY5qYF4qlcv5Fy3UvQcNQkdKb8FPZmbU0xEw=; b=RxRVzBg2V7g9HFi+SBzRwZQeIDcKOKH0+3UZ0Vkzc6Q+rBfRSG3BSr6Woj1O0Wu6aD N8xpPxS3rPihjlLT8vtsEFHuYQXjkaekfy92HY9IK8cmgqsz94kzM6VyydbIwG3tbR+r t7NZnx6k8PayQ7tpjcMKhzTzTvhXazdKfkavn+QMtvG9yIa6ek1JwTcGv2u+EvnR0SRf yPeCEtUeEfrlRvrPOysHbSGlEaVxw+eym3hLZtxBeDafsldXxY09N++4aNWRddQncePt ZXArNs63+TiXTqQX8+wGKO12T/7c3PNHhrLOygeRun2jnkBeTgJGewlow89vMnkiT2LK 1ZFw== X-Gm-Message-State: AOAM533ISJuXy/IkMx4B68i5hIGDibi/B6wv9ZPOVBNGcW3cs/y2LgvX f84y0Wo0a7L3K369XhEqT6o= X-Google-Smtp-Source: ABdhPJwoqhRPCSgNF6mgW/xzBAvRrTh/pg187PTu+4Jgo0PlIWIqois2I0Z+FnVEe7y3n6RenDwOkA== X-Received: by 2002:a17:906:d922:: with SMTP id rn2mr6233726ejb.414.1612562595395; Fri, 05 Feb 2021 14:03:15 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:14 -0800 (PST) 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 RESEND v3 net-next 04/12] net: mscc: ocelot: use ipv6 in the aggregation code Date: Sat, 6 Feb 2021 00:02:13 +0200 Message-Id: <20210205220221.255646-5-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 377970 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 1D221C433DB for ; Sat, 6 Feb 2021 02:38:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E55BF65010 for ; Sat, 6 Feb 2021 02:38:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231357AbhBFCiR (ORCPT ); Fri, 5 Feb 2021 21:38:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbhBFCfU (ORCPT ); Fri, 5 Feb 2021 21:35:20 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEF34C061223 for ; Fri, 5 Feb 2021 14:03:17 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id i8so14410410ejc.7 for ; Fri, 05 Feb 2021 14:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MsV1sQIBZpuksx4sPdCdGrBtzsa4qZpu9FzXyF9RiLU=; b=bzktRBIakRgngCW4fmg1eSKERCtBOnq0/KK9ohDllwkjw5dY3PdVk4VNfAFUl2lcjl 7v7aOBdqfJDoOdLFGiBVOLrG7q2iJLOsZvrXAkJsqWwjrPzNmE5DY1XVDDCARzzejLLj Pd0ivEnI/fnKIQlHw50yZ30CH+zaAwOPr4K6KLoz/16gF0KWsrue7Adp3LN5LMb76Za8 8is7WZVQkgdsoVHXm0orTBK81lj11EShfPmBw76cGPgI0pgvGBdypcz9C7G+7i9g94uv yaoRc3ivD98atDP/DYUL5oJuZ0S/qJ7vJzEQS7zXJrzoQ4gAT6pUaKA1fr6eGBziszUc dIrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MsV1sQIBZpuksx4sPdCdGrBtzsa4qZpu9FzXyF9RiLU=; b=YcRX0MAgTClAfLUA+2ow7NSzPHlNxDVsHiAE7zMhhumb4vWtGMnzGj5AzuFnrL3v/v dTR/+5MI1WrBl0xls7olZkTf3PyVF8hH7WXa1t3Pi3FTJeev+/46xJswztzWa0VzESaj 3TYZQ0bXgtW67huFbqmZjLxnDTbp1RNIm33Fs5wG7DA6AjAZC6MPPOK9hMpgTabjggQM yI5xN9a8/dNlBkdV+mmclJ1FIqCSj1TgkbTuJgBLv6hQSHfpkZC6dTAis9O2w40vFoQ6 t7aIj9fydHCiiQwLuBMIa/ITtaBUgY2QqjEO253zae0GLGeRl/l+iV2MIV8u3P3hixDk /2tg== X-Gm-Message-State: AOAM532cYJctR5xnkp8oIxZp80V8mcMXOaHVtl5UlPRtBlnre+xz85Do GlrQcqEey490U+qiGF3UZAsqsAmQbIA= X-Google-Smtp-Source: ABdhPJykkP6n9YNLjQRzRxIS6rjykzpvoxQlOgR24NF06MjiFBMSeloYcO/qJ5y4nG+XVCPYmPV4gQ== X-Received: by 2002:a17:906:84d7:: with SMTP id f23mr6268570ejy.87.1612562596584; Fri, 05 Feb 2021 14:03:16 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:16 -0800 (PST) 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 RESEND v3 net-next 05/12] net: mscc: ocelot: set up the bonding mask in a way that avoids a net_device Date: Sat, 6 Feb 2021 00:02:14 +0200 Message-Id: <20210205220221.255646-6-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 378397 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 46EC3C433E0 for ; Sat, 6 Feb 2021 03:01:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15C0964F51 for ; Sat, 6 Feb 2021 03:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232446AbhBFDBJ (ORCPT ); Fri, 5 Feb 2021 22:01:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232123AbhBFCvY (ORCPT ); Fri, 5 Feb 2021 21:51:24 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18DB3C061224 for ; Fri, 5 Feb 2021 14:03:19 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id r12so14406432ejb.9 for ; Fri, 05 Feb 2021 14:03:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qg0FNg0PtL0XgjN5bkLtn3U5F0iKT5oU5G6kbieF+Bw=; b=Ie/ekkLswFrNQ16FSp+vPmx4iWNp3rXHFCXzCgaOhJ0SosGXwtbxjrZLNyDcI08g/B xGxraOVxCkIgvwvYTS7/EwWT9W03rByXIsQpVDm2Ddyg2qTds3pGSUuHW5Iu8uD56wiN WGBsinwQrSb/2KmhqO5v1+Af0h8DjooynAL/B1jmXqX13WfSNngElE3Y3C7wpDCz57I5 G5Kt4p0HSgLE6cbLjThvfJREEOUbwoISPA9RFSJGWcENeUMk2ZPxpN2mG095kH1BCTSM qQZhKUmb6yFdUkwSrhCJUNGeVq1mLurEiR9Aw6lEDDABdESBAzR3P1g/IK5R01coXfVm AY6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qg0FNg0PtL0XgjN5bkLtn3U5F0iKT5oU5G6kbieF+Bw=; b=ljkljDiLQODk7cZ2jLVt6Tyz0vlbu/RV2XNwWDNIMydyGNxBTOrXEwIdqbDQhaysQW BU3w/AOcj+9EnbCkGsVPQghzeoVUYPv/s6JUNldBT0S1qFKak0ccCJl3vyAKOtINwjU4 sXZ0wjYiML32i2/wSuP4xb9L4JmeDvTU/GjTa6/e/b9MV4t2MAtXSltgC8U5EGHH4uf0 6pjftwDxqCV973/g0BX4QjUnHVSqKMs9r3CQB8c+WEmr5Q16p5VYvyb3bnjCFa5UoFS6 OLie5Cci1Wf7d1NdSGFDfQu1tLhPACAGrhL+0kxR78yJGOOUPq9la+2RXP42xr8NmQRm aKrw== X-Gm-Message-State: AOAM532ACcannZJUOTuLpi2xEhysJd1yCUDxtKmRdBdlDgyiT21Wg0DI cJfBMPPUiHcb2lHbacgKMyQ= X-Google-Smtp-Source: ABdhPJxPLozTEMF9GVMIesQDPUrdpGdL/nKMyhH6C/BFCz+fK+u3sKQC5mAauJGi8vj6PGziK7PqUQ== X-Received: by 2002:a17:906:c010:: with SMTP id e16mr5829996ejz.91.1612562597737; Fri, 05 Feb 2021 14:03:17 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:17 -0800 (PST) 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 RESEND v3 net-next 06/12] net: mscc: ocelot: avoid unneeded "lp" variable in LAG join Date: Sat, 6 Feb 2021 00:02:15 +0200 Message-Id: <20210205220221.255646-7-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 378403 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 10613C433E6 for ; Sat, 6 Feb 2021 02:51:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C58CD64F06 for ; Sat, 6 Feb 2021 02:51:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232168AbhBFCvm (ORCPT ); Fri, 5 Feb 2021 21:51:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231325AbhBFCmr (ORCPT ); Fri, 5 Feb 2021 21:42:47 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3310CC061225 for ; Fri, 5 Feb 2021 14:03:20 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id w1so14373016ejf.11 for ; Fri, 05 Feb 2021 14:03:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QS13JTR37VVKTmmDq1xl6ePKRk/6k5ELZv5cGdZhKOs=; b=shYm/sM8+sl/nHdExgz2IvOl6LL0o37qTZckhZ3ACb65I+jBSvgX4LFRO2vQiH8KoG 8WeLuWjs8OmgdIxkZH7DWWzZeJFPg1jVQmR3JUN56JSCaIoDi7B7HKLfExjVbEfJhfVP 35cbzC2/3e5Xzg1apwkx+DIsPmG/KYmQzi23s/GXgj1/k4MnekCDsBOJ4yF6L2NftqQC HGEz+p0X208dgGN99iaAmmRMpk1V0gqfks3xPkiCSrU/debWqzy9Dv17KbxYDsLA6Alc +RFBoo9RHRq/YUgn3aeiQ6nQKNS6Ufjv+jfQ+M9GpN5vstPThDTKoiGQgtDUSN4YbqDX 79Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QS13JTR37VVKTmmDq1xl6ePKRk/6k5ELZv5cGdZhKOs=; b=GY3TuQMJqObwwQ0mOvdMkw9bU7Zxw4zBY04R3dWaiDv6QHzRAKkIdSCmGFc4Bj++cs uJvaXYM0mlMjXbZcESdvoctXM3zPRiWnYaS0V41eBycmTaWrP6aQKjRontO8ptXNHTQ/ yz9U7/YWTMYJbyOnQSsz6ZSYaNyS3C6zvZYHZS//Rdx35bfy34oxv6absMl6XLM6SLtN PHvOvNreegKuZJq9Obzqqi4k2oDtO9rUnAP4XixHsnYbOxar7KRocya9Bi+XCbTThlIA TPt3lHKumeVHXj1hpi6AoaSBGiMP4qzJwBlligXrMsHNjQxjj/7RVG3nSInuKxL/UfWM A80w== X-Gm-Message-State: AOAM533JeSg9Nfs24F7I/+tJwAQxt20cu6w3oCcss22Mc7z0uSnYjMMb S7K2PuK9itWAcK3ljpMfdzU= X-Google-Smtp-Source: ABdhPJyCTLdiR1SaI0md1QKXwHZXit///NQPUbGkH9Xa/3NbX2Oa2/los6JiUMoFTQYfx/+DBkfprg== X-Received: by 2002:a17:906:eb88:: with SMTP id mh8mr5913704ejb.150.1612562598887; Fri, 05 Feb 2021 14:03:18 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:18 -0800 (PST) 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 RESEND v3 net-next 07/12] net: mscc: ocelot: set up logical port IDs centrally Date: Sat, 6 Feb 2021 00:02:16 +0200 Message-Id: <20210205220221.255646-8-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 378399 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 72828C43333 for ; Sat, 6 Feb 2021 02:57:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5248B64F51 for ; Sat, 6 Feb 2021 02:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232348AbhBFC4h (ORCPT ); Fri, 5 Feb 2021 21:56:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231772AbhBFCse (ORCPT ); Fri, 5 Feb 2021 21:48:34 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F678C061226 for ; Fri, 5 Feb 2021 14:03:21 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id q2so10713669edi.4 for ; Fri, 05 Feb 2021 14:03:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TczSOMJlcVuD/G6cNnSP+M29wppGj2lvswI8JvvFkjA=; b=pRyLWofMRJqw31Vlq/77gy0SwhL2dAprmWNZeGOGIMd5+f8ajU3yCAGm0MjiS5neSc Mb0DL9fVnZVpFCo9q1Ip/PFq+JMzFH9yN3ZVQlSl1mh+4qVJZQjcgAs3C8cT8xXVtKYF hxMZ3VHOm3vLgtZt+W/ntp1msvnIqnrl3YFuC/v94NKLLuHCjQT+TxB5W7ZEOMnb61ch 50Wdf339MiyKmKualseK6OUNy3HlrwJOzDC/BI7WmEz67ln5+cvJOEVrDqnhb0Uruf7Y UtpYa/VKKSBv1H7RVJL06C11ezUc6QkoxoXdz8B/XzHq+Ez94TQ2fsZRGrKsPPT2fzbG oB5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TczSOMJlcVuD/G6cNnSP+M29wppGj2lvswI8JvvFkjA=; b=RNRabVjcplxyI4CF76jdgRvbAOso7JcjXhCE2ciqJffdG09jdqT9pdCVVA1TjYCLcc Axk2r1XapY/3lWap6LLPV5qjzHdrCBcHEIJYniubwt7Y0RYbShjYQDzYYOGzTrgkXWxI kqHMrd8YDDJbfOP/mehZ0cJ4tKsGRkEGecsSpKQ4zKIpFEdm4fYhZfU6MdyNFLXzUAs2 2HsEwOVy6FML26SEt5TTMEohsDkvnsvCZt1djYyXrQjh4zgz/gxhWbP+mM9HDgnP5J0s 6Epi4+4P4Kye/p/Rf+mGNQ1jwCzhFRAC7xdG6c5i/mlHTxUfyhTn7dfC2z9vO+0+Mm5H zVng== X-Gm-Message-State: AOAM532IbBIXP60KvVcaxhcDc6KB3oMI3fKeKLFgtJyLRYbN1K4sby4m awI+9lhfe+FTUID79uqGr2g= X-Google-Smtp-Source: ABdhPJxOSmF3cmaQ0/YP3DVOn0iYWRvF6dHxmPgwdG/r5PY4IVfP2uJO+gLNj1ute6u3U/umxDnj9g== X-Received: by 2002:aa7:d2d2:: with SMTP id k18mr5747596edr.222.1612562600086; Fri, 05 Feb 2021 14:03:20 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:19 -0800 (PST) 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 RESEND v3 net-next 08/12] net: mscc: ocelot: drop the use of the "lags" array Date: Sat, 6 Feb 2021 00:02:17 +0200 Message-Id: <20210205220221.255646-9-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 378407 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 38337C4332E for ; Sat, 6 Feb 2021 02:47:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 129CF65033 for ; Sat, 6 Feb 2021 02:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbhBFCb4 (ORCPT ); Fri, 5 Feb 2021 21:31:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbhBFCbr (ORCPT ); Fri, 5 Feb 2021 21:31:47 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CD67C0611C0 for ; Fri, 5 Feb 2021 14:03:22 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id s11so10698116edd.5 for ; Fri, 05 Feb 2021 14:03:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I/8G4m2IjEP9kJnVijcaplzNh0G1BLcnZbgghwOkNlo=; b=L1zgQWPs79z2BFkG34ftURrJ7s3qJ9no02C0GEhCFGZGoZBnHmCwRXrvotSfg1ZcdH nRdv/YFuFMI42Q3bDoWNyusWWerBEniHCo2EtyuwhY8qdM8EL//2FDhtcdSMnNdpLbsp jyV582ZQJIhWYFw5w0qauzX55sg62AbD+anQ/+0rTlwe9VpxOJdUDK1T3T93Qf3tJNpW TB6Epx6WYB36Cn4lV+h/NiaxBCf/wXHctmic9NGnMfuSWgSMMJAQWTgD945zYKqgA1TY aWEUYDXVEMyIhWxOY6kuqKuWBMQ0WrH4pc0LR9a1ZE2BG1I0dOgUKZ5FXGNolM2hMwut kd8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I/8G4m2IjEP9kJnVijcaplzNh0G1BLcnZbgghwOkNlo=; b=BZTtO1Pouvt50wm6Qb6UBHXGvYkzG8v5eRLHeXbVQMgsGxdbELJS7XyQV1cgIPrIba UPaexiTkpVhVgVp78x2deLHcJ9GWLG2VWFTLeOeyzNWd1IjvFm+VIa1mWIme8Nbdi/8e kxSlsJwpFm3Q5IY0hRMYS9JlRJqu/AV6YTgc1x075j9DAtacy4QbDD2B2sNhaVcFu+C6 llJ/stbDBYrdLlmZL77S5/qXW2M7v9vK+ve3m+bJfrPuaBFnMzlvpHjoZO+j7oIan0Ch oZ6j/JXwdQnnkB2eVvAjlUs+tLHnY0TMginEm2FyxpJy1+iOtVTTIQdkEe8+ShbqaUVj Rmxg== X-Gm-Message-State: AOAM5328zxSYXLH/UZmbzsaAKIJSZ5OEbROlY3qFQ9nT3ZkNHRpGz3Ky /polk4tkd3MxaF3zgQBCVdY= X-Google-Smtp-Source: ABdhPJwypNrsHe8vP+DeAmwW7co8gqveBAwaylsemB+y6aRw/VTXfwQfRdeX/B/QFVQuCVtbryzEcQ== X-Received: by 2002:a05:6402:2694:: with SMTP id w20mr5640138edd.200.1612562601205; Fri, 05 Feb 2021 14:03:21 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:20 -0800 (PST) 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 RESEND v3 net-next 09/12] net: mscc: ocelot: rename aggr_count to num_ports_in_lag Date: Sat, 6 Feb 2021 00:02:18 +0200 Message-Id: <20210205220221.255646-10-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 378413 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 3DDF5C433DB for ; Sat, 6 Feb 2021 02:33:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B84965011 for ; Sat, 6 Feb 2021 02:33:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbhBFCcK (ORCPT ); Fri, 5 Feb 2021 21:32:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbhBFCcF (ORCPT ); Fri, 5 Feb 2021 21:32:05 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B43DC0611C1 for ; Fri, 5 Feb 2021 14:03:23 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id a9so14473394ejr.2 for ; Fri, 05 Feb 2021 14:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EdEKlddiPMEq5s0RcOpO54B9BUtWLJWqLn2v/XNUweQ=; b=HUbl68u/gvpoj2CR692ce3RGaxzOFESByu6wbzQ/pQDwyQ16cLd5GGsQElbn/jpL2C /0K6jodfZpAIFhgtMeddBfGwfupJa48PL/wYqn5FI7hojnITa2T71CX9vpUmx9IdMow4 BwR3hFyA/pHxWE8iX5j3oDhgtPzHRzwZLQUr42W69CJp0gyUbKyXjaQzAcGq7caEKrcj yLO0b+KRMEdVP4HkcXAWHj6xgVUqCHLYTWN735UTfQKovb5l6FVWzzn3ubp09XvGR9YA 4c1kjDloBneZSUamOkTYQ9msHaSbhjzaCEbwKBXeq3QtyGKVwwku2EaUX49zqV7Bl6lI Xlaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EdEKlddiPMEq5s0RcOpO54B9BUtWLJWqLn2v/XNUweQ=; b=V6Kb3NwQOh5RGL2hraJ1UaPV4/S0Sf+5ilw8lPtVF5o02fh+Hxwl6lmA8MHLwxG3GW LNADifXVwrYr/l2qYii/Q9sPldmI+msEBvTtJi3ZVB+LUOzTxp097FTrDidWpdbv78dU v6diq3Wtyii7vh5o1H+UKozBR1mIetu9wu8DjwYwqbD/HukriwoLBmTe+Qr5lmSxBBP/ sgth0dHeATHi2SuqQ7QyUjJYpJiOvEYLpJBe0akNbSVh+gvkL0cwtHejWct4Pt7Yiu8d cx8c38DH/O0grbObXmldpO4VD3biHIJVsInq1pfH8U8GN4azaf6ULWUyd0Cjgj12MmzX J7Zg== X-Gm-Message-State: AOAM531vNs/ApebS650xgrCyfLpP6dtcQJSv89d8GxIXC5M8VUm+ZOdJ xI2+TFLMPMpgK58o+M1D+hE= X-Google-Smtp-Source: ABdhPJwm5Vqvj9gmkQZlLZyfEoFWIa/e4H/8z/Z+AW+0iAxJttqYHcFnURL3OeicK8yd8Yg1Q9+XWQ== X-Received: by 2002:a17:906:2e0c:: with SMTP id n12mr6033617eji.312.1612562602376; Fri, 05 Feb 2021 14:03:22 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:21 -0800 (PST) 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 RESEND v3 net-next 10/12] net: mscc: ocelot: rebalance LAGs on link up/down events Date: Sat, 6 Feb 2021 00:02:19 +0200 Message-Id: <20210205220221.255646-11-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 378394 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 7C782C43381 for ; Sat, 6 Feb 2021 03:17:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FBA764EEC for ; Sat, 6 Feb 2021 03:17:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231846AbhBFDPe (ORCPT ); Fri, 5 Feb 2021 22:15:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232197AbhBFCzT (ORCPT ); Fri, 5 Feb 2021 21:55:19 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB0E9C0611C2 for ; Fri, 5 Feb 2021 14:03:24 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id sa23so14511834ejb.0 for ; Fri, 05 Feb 2021 14:03:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I0fStImX6Rzxzw2BiXqbA+G9P9WGsBPjitXdFpg5VKs=; b=TtCgMGVoMfaFxGBxixcDxuZNF5n0uhmyaXAKmOvNrl+V5sWknbKeZb3VoYSxDrlb2O 4jrHlRs8nebAoOk3aHoVMs+JBs2sQcwnTwyU19bcIyCxPLwXyqtzVbldX6kPG2JF/dgh 13nz8QnKjQS8NXUp9/CIWzbjdhEnOaJWCCPgj0o7ti/nmMU14kCYH/x/LaMHTy7DrAiT IyEz07jEtYFGEjIAQAYBeEDrbv/FjoduzEk6JkrDHYFSU2/dLMoc2QTb4Rv2WhWtPHfW Uz9ronE1Z+8ebpG/IT4pWiV1FwrVHISHDjG4akOuD55LhocjkkHmHWTTGrowKzPpFx5l tp2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I0fStImX6Rzxzw2BiXqbA+G9P9WGsBPjitXdFpg5VKs=; b=uCABQjqep19t1OEMsiuHMSHinUzdAEmpF8p7SXWYw0VrtkfTVXAlFlF3ss/JJ1cjm5 LQVeEMNIvimch2wgbgbvSPf6uzogoow1r18dMK+/LMiQOR7ut2zpfUeMmFcD8SVLGTix POZ+jrRq6v5t/OA6Ki0a18Qe9B9yeRwI0U7Kg50fjW47QCNJvCOMVp7FWc09xJJcorDL bwbhnNW7rRggLIL/lRQD3bu9Sj0QGQ0+VcoF/f7F8RT6cPrimRZoMl0WotZZZfI07a+6 CSBJuLm8yHnJdJOiNKBtMa/squFRPFTG2cLW6m7O6SBIzxn4HjIrPsskYhEiXlKrY9n4 Uj9w== X-Gm-Message-State: AOAM5314NiwBL/FTFEz/J89JCfzd7oBsDItGSZQ/ht2ODVOTZwKt1iHu iDwnjMQyccSUh50DunC+WTc= X-Google-Smtp-Source: ABdhPJzFXAbssa1fzqoxTdaxe5AToXzhIC6LVw4DI+bweplOc+Uopo4rsH5j6iAvvMB2UaNgJUPTng== X-Received: by 2002:a17:907:7347:: with SMTP id dq7mr6128879ejc.385.1612562603449; Fri, 05 Feb 2021 14:03:23 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:22 -0800 (PST) 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 RESEND v3 net-next 11/12] net: dsa: make assisted_learning_on_cpu_port bypass offloaded LAG interfaces Date: Sat, 6 Feb 2021 00:02:20 +0200 Message-Id: <20210205220221.255646-12-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 22:02:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 377971 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 70864C433DB for ; Sat, 6 Feb 2021 02:37:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 162CE65010 for ; Sat, 6 Feb 2021 02:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231312AbhBFCgy (ORCPT ); Fri, 5 Feb 2021 21:36:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230379AbhBFCdp (ORCPT ); Fri, 5 Feb 2021 21:33:45 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02176C0611C3 for ; Fri, 5 Feb 2021 14:03:26 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id p20so14444543ejb.6 for ; Fri, 05 Feb 2021 14:03:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QKpdkMelmR9vRcUe1LgJJjZ28BK97tyoDUjRYm59MYc=; b=K941JhIqBaRbKKn1ghP4M3PUJOZP6SNub3Ka8tXVNuBm8Tyl9nrfNVPBZdVyPtJqC3 XOY+01Iewa/quotq0I4Ac4RVUjZepY4FQTsT4SG2s1hMR8ebCSVGuokmgDOg7IwzXivg porbQjTTurkrqwh0TmhAGNyvW9WTb2uo9CySRyYfqqaGQiGvdOmwBKmap1+VlfCuF+jT 71I/BArfQSqMmaMbEb/2isjJprjsQCESP1uF/QNIq3rPvEg3/X8ekQ4k8ST13etJHoiZ vG4732WEFomGJDgmLaONLIlIHwSMLgHctG4HcWMn5Nik25dHjGFeEKQ5Kk5TldsNTAky 2vrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QKpdkMelmR9vRcUe1LgJJjZ28BK97tyoDUjRYm59MYc=; b=nhBxkfpt8Q/1sNdVkoAZ38izdpjZR6AyvbYhcAlcoeeNUJKWfU2G6qO0xcfuiFeYU1 m/kLQRmzfRkW3E8zt1hbiQhNYmyh6ScumXcm4z6mR7haAVG/6fT9cA8A177oUZLQc49z nuvjUilHNk1roZcWf9UG2I5HpIdJUCx4ni2YqWakm+RwjsAUxRFb05fGV/tllKJWfmkn dN8qGRj7b4tI+Lmh+QVbAMJEM4rNPutuVl/IFCDKZUD3NRcEnO+JV+JWJEpQO00vRYl7 3KAqRctGBmNKEtHMRm8tRUIF8ihyeVHoicd9axHXgrfKFzF9ZK6yfCc7FNe4nnZ3OfDI OJuA== X-Gm-Message-State: AOAM530AafkRP8POq9L+VJ+5UXs3PXrmTJ3BL6/rfCXhksidab0s1HwG sGsZN5OgvRWxuBIRPSQLxRU= X-Google-Smtp-Source: ABdhPJwg2+NLU42ofgvgY2mrH0+hJHaA8xZ8frtW79VHEnn5G8Rm4IwQCPWlngPnqbmuJ4aN4H0GcQ== X-Received: by 2002:a17:906:dff1:: with SMTP id lc17mr5803338ejc.198.1612562604576; Fri, 05 Feb 2021 14:03:24 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id t16sm4969909edi.60.2021.02.05.14.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:03:24 -0800 (PST) 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 RESEND v3 net-next 12/12] net: dsa: felix: propagate the LAG offload ops towards the ocelot lib Date: Sat, 6 Feb 2021 00:02:21 +0200 Message-Id: <20210205220221.255646-13-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205220221.255646-1-olteanv@gmail.com> References: <20210205220221.255646-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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);