From patchwork Fri Jan 8 09:07:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12006097 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,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 90D45C433E6 for ; Fri, 8 Jan 2021 09:08:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D32C2226A for ; Fri, 8 Jan 2021 09:08:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbhAHJIT (ORCPT ); Fri, 8 Jan 2021 04:08:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727570AbhAHJIS (ORCPT ); Fri, 8 Jan 2021 04:08:18 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BDD1C0612F5 for ; Fri, 8 Jan 2021 01:07:37 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id c7so10462820edv.6 for ; Fri, 08 Jan 2021 01:07:37 -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=MvWdbpHlmPhq6FtvIjCBXNgOECoVYIRRCLQ4z1WPNPc=; b=kd7LANf/oA97u7XVqbRkgPXRRJPWH9TWhIT+a1aIvi9lMFbVzlMP7xN5rmA8zb5DXo wOeaRmPOpg8+GZdpLDwNJpKsNkdFD2rsZlUXRmX4EgHOnzJRKn4LMO84/paDzrXQZCtQ 5H17Q3MgGINfZaSgh687ftOwhNh78Y/kC5ngTwXAA56qsTvkRpZMC1S4uwDDmEOfLnfF 3sbOq8zcUZCak5K1caZhXLhbSgE7LL86fZ3IZmIVq/NLh1aQZn9vYbwTPZB3cXO/LuaB CuDB10BI6Bf3CRZldgKKQyrS/9G6hbiHiNmk6fPKWbtWKHFsqFylTdi3f3b4SeptC3Zl pw9w== 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=MvWdbpHlmPhq6FtvIjCBXNgOECoVYIRRCLQ4z1WPNPc=; b=Y/nsoK7HEnqhuFT69YhyqYzbziXJ8XBryx8rCV6xxhbUGLSz75dFL70e0jR+LCgJRD jdzBr1T2dfJB14fmxvQKQqSjmVK2Y2s4mOjpdvpr6mYis9jZ+Vk/mim/crBNY9r5+5CB 6XwaRkYBcu6/tCQUJ3vZHkvssjFzwrcq7MdMGd4mQNa7odEGvPDvV8AHTegiQIxHL3Nm wG4WJWSrlsQlMBxEzsskV1si7mkvaW5bnP2C2RWt+Pb2tCO8zxqkCRB76Uk2AVFdtnru QqWI6kuEcxdLteCCY6eZgZ0J7IL/V8TSSyzVZ8VyOLSmuCpLN2Vo1EKwhZ7BExMjlSFa Djzw== X-Gm-Message-State: AOAM531pVV57CVf5CVrdvDckso0pVwWPmgYKCDG2UXtCLu9K+YLSjk6/ b1W4xrSifEiXVDGumWYuttc= X-Google-Smtp-Source: ABdhPJxq6SnUYyZMpV49M87jT6W/AaiR45bC/HnaROT8LIKb0AD2Yvd9GuCD4sWDTcH9xkEBqJShmA== X-Received: by 2002:a05:6402:1d9a:: with SMTP id dk26mr4580714edb.283.1610096856260; Fri, 08 Jan 2021 01:07:36 -0800 (PST) Received: from yoga-910.localhost (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id k16sm3307132ejd.78.2021.01.08.01.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 01:07:35 -0800 (PST) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: laurentiu.tudor@nxp.com, Ioana Ciornei Subject: [PATCH net-next v2 1/6] dpaa2-mac: split up initializing the MAC object from connecting to it Date: Fri, 8 Jan 2021 11:07:22 +0200 Message-Id: <20210108090727.866283-2-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210108090727.866283-1-ciorneiioana@gmail.com> References: <20210108090727.866283-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei Split up the initialization phase of the dpmac object from actually configuring the phylink instance, connecting to it and configuring the MAC. This is done so that even though the dpni object is connected to a dpmac which has link management handled by the firmware we are still able to export the MAC counters. Signed-off-by: Ioana Ciornei --- Changes in v2: - none .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 14 +++- .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 69 +++++++++++-------- .../net/ethernet/freescale/dpaa2/dpaa2-mac.h | 5 ++ 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index fb0bcd18ec0c..61385894e8c7 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -4056,15 +4056,24 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv) mac->mc_io = priv->mc_io; mac->net_dev = priv->net_dev; + err = dpaa2_mac_open(mac); + if (err) + goto err_free_mac; + err = dpaa2_mac_connect(mac); if (err) { netdev_err(priv->net_dev, "Error connecting to the MAC endpoint\n"); - kfree(mac); - return err; + goto err_close_mac; } priv->mac = mac; return 0; + +err_close_mac: + dpaa2_mac_close(mac); +err_free_mac: + kfree(mac); + return err; } static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv) @@ -4073,6 +4082,7 @@ static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv) return; dpaa2_mac_disconnect(priv->mac); + dpaa2_mac_close(priv->mac); kfree(priv->mac); priv->mac = NULL; } diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 828c177df03d..50dd302abcf4 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -302,36 +302,20 @@ static void dpaa2_pcs_destroy(struct dpaa2_mac *mac) int dpaa2_mac_connect(struct dpaa2_mac *mac) { - struct fsl_mc_device *dpmac_dev = mac->mc_dev; struct net_device *net_dev = mac->net_dev; struct device_node *dpmac_node; struct phylink *phylink; - struct dpmac_attr attr; int err; - err = dpmac_open(mac->mc_io, 0, dpmac_dev->obj_desc.id, - &dpmac_dev->mc_handle); - if (err || !dpmac_dev->mc_handle) { - netdev_err(net_dev, "dpmac_open() = %d\n", err); - return -ENODEV; - } - - err = dpmac_get_attributes(mac->mc_io, 0, dpmac_dev->mc_handle, &attr); - if (err) { - netdev_err(net_dev, "dpmac_get_attributes() = %d\n", err); - goto err_close_dpmac; - } - - mac->if_link_type = attr.link_type; + mac->if_link_type = mac->attr.link_type; - dpmac_node = dpaa2_mac_get_node(attr.id); + dpmac_node = dpaa2_mac_get_node(mac->attr.id); if (!dpmac_node) { - netdev_err(net_dev, "No dpmac@%d node found.\n", attr.id); - err = -ENODEV; - goto err_close_dpmac; + netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id); + return -ENODEV; } - err = dpaa2_mac_get_if_mode(dpmac_node, attr); + err = dpaa2_mac_get_if_mode(dpmac_node, mac->attr); if (err < 0) { err = -EINVAL; goto err_put_node; @@ -351,9 +335,9 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) goto err_put_node; } - if (attr.link_type == DPMAC_LINK_TYPE_PHY && - attr.eth_if != DPMAC_ETH_IF_RGMII) { - err = dpaa2_pcs_create(mac, dpmac_node, attr.id); + if (mac->attr.link_type == DPMAC_LINK_TYPE_PHY && + mac->attr.eth_if != DPMAC_ETH_IF_RGMII) { + err = dpaa2_pcs_create(mac, dpmac_node, mac->attr.id); if (err) goto err_put_node; } @@ -389,8 +373,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) dpaa2_pcs_destroy(mac); err_put_node: of_node_put(dpmac_node); -err_close_dpmac: - dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); + return err; } @@ -402,8 +385,40 @@ void dpaa2_mac_disconnect(struct dpaa2_mac *mac) phylink_disconnect_phy(mac->phylink); phylink_destroy(mac->phylink); dpaa2_pcs_destroy(mac); +} + +int dpaa2_mac_open(struct dpaa2_mac *mac) +{ + struct fsl_mc_device *dpmac_dev = mac->mc_dev; + struct net_device *net_dev = mac->net_dev; + int err; + + err = dpmac_open(mac->mc_io, 0, dpmac_dev->obj_desc.id, + &dpmac_dev->mc_handle); + if (err || !dpmac_dev->mc_handle) { + netdev_err(net_dev, "dpmac_open() = %d\n", err); + return -ENODEV; + } + + err = dpmac_get_attributes(mac->mc_io, 0, dpmac_dev->mc_handle, + &mac->attr); + if (err) { + netdev_err(net_dev, "dpmac_get_attributes() = %d\n", err); + goto err_close_dpmac; + } + + return 0; + +err_close_dpmac: + dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); + return err; +} + +void dpaa2_mac_close(struct dpaa2_mac *mac) +{ + struct fsl_mc_device *dpmac_dev = mac->mc_dev; - dpmac_close(mac->mc_io, 0, mac->mc_dev->mc_handle); + dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); } static char dpaa2_mac_ethtool_stats[][ETH_GSTRING_LEN] = { diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h index 955a52856210..13d42dd58ec9 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h @@ -17,6 +17,7 @@ struct dpaa2_mac { struct dpmac_link_state state; struct net_device *net_dev; struct fsl_mc_io *mc_io; + struct dpmac_attr attr; struct phylink_config phylink_config; struct phylink *phylink; @@ -28,6 +29,10 @@ struct dpaa2_mac { bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev, struct fsl_mc_io *mc_io); +int dpaa2_mac_open(struct dpaa2_mac *mac); + +void dpaa2_mac_close(struct dpaa2_mac *mac); + int dpaa2_mac_connect(struct dpaa2_mac *mac); void dpaa2_mac_disconnect(struct dpaa2_mac *mac); From patchwork Fri Jan 8 09:07:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12006101 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,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 49850C433E6 for ; Fri, 8 Jan 2021 09:08:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 113BE2226A for ; Fri, 8 Jan 2021 09:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728022AbhAHJIV (ORCPT ); Fri, 8 Jan 2021 04:08:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727984AbhAHJIT (ORCPT ); Fri, 8 Jan 2021 04:08:19 -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 9C4CBC0612F6 for ; Fri, 8 Jan 2021 01:07:38 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id u19so10518152edx.2 for ; Fri, 08 Jan 2021 01:07:38 -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=XpEoQbxWtWJsFfdB5Doiub4VSWo7EKLolsqR3ejOC/s=; b=jEtQ0eWyIrhRj+KY1EZPEcTYFyKdJ+X9eqmFMOs6Q3y4VW1Ppbs4OQPOjmg7TieZAW /OITp8ee3EX2/2QQV7Cr0H2wJrMoQFChjZOAJVjlH5gKaDvUdoiYRdJ2/H8kEPO9/N55 GuLPo2FbjVD3ShjPOePTaLea/nh9LxN9UfyRCVNxyJSrN3HspnlY1jmBgpRWxSoKDTAH X0+EoahwRL3WphJNZH4IumTdb3UU7jnaPNjboIBYg6nCSShxJM0RYtwlgLkgkbPfIlUY f+JOFUBZiQtiSUTXng8rdnE3gPa4FGt4RiHCr90nPwDpGbqdNXFwhcfw9f9NcybhWAW4 T68Q== 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=XpEoQbxWtWJsFfdB5Doiub4VSWo7EKLolsqR3ejOC/s=; b=IDHcmF4deZZxvfrDpyPUQb3wcKrDo0gIaP8SgEYSYs31C+t6Lxz2RltA6yKNF2Hh+1 QHsXzk3GSGpdayxvoodEbiN4FEzMTcuTxDbcwAUx/cuHt8jTlWnLJmOZt+BEPI4h1pdO M+a4oKeCMWtCTFflwEunCjB1XpG8HPSrKhQoV0VSfebQBwe4tBVaAwYEj/VzQiJvJIfy zkUSIL+0L6h2zecJnZz/RMk9qhmPy0PGjwBszTyGzP7tU7ifYSJDafyMZlFOLkbVIg3y lkc4Hw0ePiHNpynM+t9Px3On8Q8b0mpiUZnhglpyt0ySlJ9rluiL2KIddFE6JQ0Ntt2W /suw== X-Gm-Message-State: AOAM532THwqjUM5zFKhts/dinlfzqfFifQ7Wa6fqryAnlVcjC61LjPbY ID7pKdHxNPW9L+p8qD1na6s= X-Google-Smtp-Source: ABdhPJwqTLq+d03HTlc9Vq4mfmAeO+oBPKY1M7oaHuupERPdj/ZfABnmI9iuo9IIj7rG/YQp7spcGQ== X-Received: by 2002:a05:6402:229b:: with SMTP id cw27mr4536785edb.23.1610096857331; Fri, 08 Jan 2021 01:07:37 -0800 (PST) Received: from yoga-910.localhost (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id k16sm3307132ejd.78.2021.01.08.01.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 01:07:36 -0800 (PST) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: laurentiu.tudor@nxp.com, Ioana Ciornei Subject: [PATCH net-next v2 2/6] dpaa2-mac: export MAC counters even when in TYPE_FIXED Date: Fri, 8 Jan 2021 11:07:23 +0200 Message-Id: <20210108090727.866283-3-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210108090727.866283-1-ciorneiioana@gmail.com> References: <20210108090727.866283-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei If the network interface object is connected to a MAC of TYPE_FIXED, the link status management is handled exclusively by the firmware. This does not mean that the driver cannot access the MAC counters and export them in ethtool. For this to happen, we open the attached dpmac device and keep a pointer to it in priv->mac. Because of this, all the checks in the driver of the following form 'if (priv->mac)' have to be updated to actually check the dpmac attribute and not rely on the presence of a non-NULL value. Signed-off-by: Ioana Ciornei --- Changes in v2: - none .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 37 +++++++++---------- .../net/ethernet/freescale/dpaa2/dpaa2-eth.h | 13 +++++++ .../ethernet/freescale/dpaa2/dpaa2-ethtool.c | 16 ++++---- .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 26 ------------- 4 files changed, 39 insertions(+), 53 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 61385894e8c7..f3f53e36aa00 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -1691,7 +1691,7 @@ static int dpaa2_eth_link_state_update(struct dpaa2_eth_priv *priv) /* When we manage the MAC/PHY using phylink there is no need * to manually update the netif_carrier. */ - if (priv->mac) + if (dpaa2_eth_is_type_phy(priv)) goto out; /* Chech link state; speed / duplex changes are not treated yet */ @@ -1730,7 +1730,7 @@ static int dpaa2_eth_open(struct net_device *net_dev) priv->dpbp_dev->obj_desc.id, priv->bpid); } - if (!priv->mac) { + if (!dpaa2_eth_is_type_phy(priv)) { /* We'll only start the txqs when the link is actually ready; * make sure we don't race against the link up notification, * which may come immediately after dpni_enable(); @@ -1752,7 +1752,7 @@ static int dpaa2_eth_open(struct net_device *net_dev) goto enable_err; } - if (priv->mac) + if (dpaa2_eth_is_type_phy(priv)) phylink_start(priv->mac->phylink); return 0; @@ -1826,11 +1826,11 @@ static int dpaa2_eth_stop(struct net_device *net_dev) int dpni_enabled = 0; int retries = 10; - if (!priv->mac) { + if (dpaa2_eth_is_type_phy(priv)) { + phylink_stop(priv->mac->phylink); + } else { netif_tx_stop_all_queues(net_dev); netif_carrier_off(net_dev); - } else { - phylink_stop(priv->mac->phylink); } /* On dpni_disable(), the MC firmware will: @@ -2115,7 +2115,7 @@ static int dpaa2_eth_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) if (cmd == SIOCSHWTSTAMP) return dpaa2_eth_ts_ioctl(dev, rq, cmd); - if (priv->mac) + if (dpaa2_eth_is_type_phy(priv)) return phylink_mii_ioctl(priv->mac->phylink, rq, cmd); return -EOPNOTSUPP; @@ -4045,9 +4045,6 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv) if (IS_ERR_OR_NULL(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type) return 0; - if (dpaa2_mac_is_type_fixed(dpmac_dev, priv->mc_io)) - return 0; - mac = kzalloc(sizeof(struct dpaa2_mac), GFP_KERNEL); if (!mac) return -ENOMEM; @@ -4059,18 +4056,21 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv) err = dpaa2_mac_open(mac); if (err) goto err_free_mac; + priv->mac = mac; - err = dpaa2_mac_connect(mac); - if (err) { - netdev_err(priv->net_dev, "Error connecting to the MAC endpoint\n"); - goto err_close_mac; + if (dpaa2_eth_is_type_phy(priv)) { + err = dpaa2_mac_connect(mac); + if (err) { + netdev_err(priv->net_dev, "Error connecting to the MAC endpoint\n"); + goto err_close_mac; + } } - priv->mac = mac; return 0; err_close_mac: dpaa2_mac_close(mac); + priv->mac = NULL; err_free_mac: kfree(mac); return err; @@ -4078,10 +4078,9 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv) static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv) { - if (!priv->mac) - return; + if (dpaa2_eth_is_type_phy(priv)) + dpaa2_mac_disconnect(priv->mac); - dpaa2_mac_disconnect(priv->mac); dpaa2_mac_close(priv->mac); kfree(priv->mac); priv->mac = NULL; @@ -4111,7 +4110,7 @@ static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg) dpaa2_eth_update_tx_fqids(priv); rtnl_lock(); - if (priv->mac) + if (dpaa2_eth_has_mac(priv)) dpaa2_eth_disconnect_mac(priv); else dpaa2_eth_connect_mac(priv); diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index d236b8695c39..c3d456c45102 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -693,6 +693,19 @@ static inline unsigned int dpaa2_eth_rx_head_room(struct dpaa2_eth_priv *priv) return priv->tx_data_offset - DPAA2_ETH_RX_HWA_SIZE; } +static inline bool dpaa2_eth_is_type_phy(struct dpaa2_eth_priv *priv) +{ + if (priv->mac && priv->mac->attr.link_type == DPMAC_LINK_TYPE_PHY) + return true; + + return false; +} + +static inline bool dpaa2_eth_has_mac(struct dpaa2_eth_priv *priv) +{ + return priv->mac ? true : false; +} + int dpaa2_eth_set_hash(struct net_device *net_dev, u64 flags); int dpaa2_eth_set_cls(struct net_device *net_dev, u64 key); int dpaa2_eth_cls_key_size(u64 key); diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c index f981a523e13a..bf59708b869e 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c @@ -85,7 +85,7 @@ static int dpaa2_eth_nway_reset(struct net_device *net_dev) { struct dpaa2_eth_priv *priv = netdev_priv(net_dev); - if (priv->mac) + if (dpaa2_eth_is_type_phy(priv)) return phylink_ethtool_nway_reset(priv->mac->phylink); return -EOPNOTSUPP; @@ -97,7 +97,7 @@ dpaa2_eth_get_link_ksettings(struct net_device *net_dev, { struct dpaa2_eth_priv *priv = netdev_priv(net_dev); - if (priv->mac) + if (dpaa2_eth_is_type_phy(priv)) return phylink_ethtool_ksettings_get(priv->mac->phylink, link_settings); @@ -115,7 +115,7 @@ dpaa2_eth_set_link_ksettings(struct net_device *net_dev, { struct dpaa2_eth_priv *priv = netdev_priv(net_dev); - if (!priv->mac) + if (!dpaa2_eth_is_type_phy(priv)) return -ENOTSUPP; return phylink_ethtool_ksettings_set(priv->mac->phylink, link_settings); @@ -127,7 +127,7 @@ static void dpaa2_eth_get_pauseparam(struct net_device *net_dev, struct dpaa2_eth_priv *priv = netdev_priv(net_dev); u64 link_options = priv->link_state.options; - if (priv->mac) { + if (dpaa2_eth_is_type_phy(priv)) { phylink_ethtool_get_pauseparam(priv->mac->phylink, pause); return; } @@ -150,7 +150,7 @@ static int dpaa2_eth_set_pauseparam(struct net_device *net_dev, return -EOPNOTSUPP; } - if (priv->mac) + if (dpaa2_eth_is_type_phy(priv)) return phylink_ethtool_set_pauseparam(priv->mac->phylink, pause); if (pause->autoneg) @@ -198,7 +198,7 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset, strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN); p += ETH_GSTRING_LEN; } - if (priv->mac) + if (dpaa2_eth_has_mac(priv)) dpaa2_mac_get_strings(p); break; } @@ -211,7 +211,7 @@ static int dpaa2_eth_get_sset_count(struct net_device *net_dev, int sset) switch (sset) { case ETH_SS_STATS: /* ethtool_get_stats(), ethtool_get_drvinfo() */ - if (priv->mac) + if (dpaa2_eth_has_mac(priv)) num_ss_stats += dpaa2_mac_get_sset_count(); return num_ss_stats; default: @@ -313,7 +313,7 @@ static void dpaa2_eth_get_ethtool_stats(struct net_device *net_dev, } *(data + i++) = buf_cnt; - if (priv->mac) + if (dpaa2_eth_has_mac(priv)) dpaa2_mac_get_ethtool_stats(priv->mac, data + i); } diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 50dd302abcf4..81b2822a7dc9 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -228,32 +228,6 @@ static const struct phylink_mac_ops dpaa2_mac_phylink_ops = { .mac_link_down = dpaa2_mac_link_down, }; -bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev, - struct fsl_mc_io *mc_io) -{ - struct dpmac_attr attr; - bool fixed = false; - u16 mc_handle = 0; - int err; - - err = dpmac_open(mc_io, 0, dpmac_dev->obj_desc.id, - &mc_handle); - if (err || !mc_handle) - return false; - - err = dpmac_get_attributes(mc_io, 0, mc_handle, &attr); - if (err) - goto out; - - if (attr.link_type == DPMAC_LINK_TYPE_FIXED) - fixed = true; - -out: - dpmac_close(mc_io, 0, mc_handle); - - return fixed; -} - static int dpaa2_pcs_create(struct dpaa2_mac *mac, struct device_node *dpmac_node, int id) { From patchwork Fri Jan 8 09:07:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12006099 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,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 E3CFDC433E0 for ; Fri, 8 Jan 2021 09:08:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E5F42226A for ; Fri, 8 Jan 2021 09:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728010AbhAHJIV (ORCPT ); Fri, 8 Jan 2021 04:08:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727570AbhAHJIU (ORCPT ); Fri, 8 Jan 2021 04:08:20 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7F84C0612F8 for ; Fri, 8 Jan 2021 01:07:39 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id qw4so13489012ejb.12 for ; Fri, 08 Jan 2021 01:07:39 -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=foCgk8zcUSolWnGxsnJiriBVrT56FQaSbBo6WHS7LCw=; b=HroOrmY3Acwa5HIFn61YCfsrNcpM7hj1RMck/n1wZC5u9n/EVSv1Gy/45iWWemfSrQ yl36txrj76vJcaRjLyVQw8TRK6xqFp5QIrkMcdNCttNIfqICsD1Jk2k271mCekWABoIX Jro7DtOnNJxbY3jt0earQZZh64ATjVCqawheoDC0/dn+PPto/g4U5H4YaifknTYua8fh lGDEi6Z8qrp8P5UH7LmL91gbdjoVI+f1hcTIo1UzJea+59djUbnx+0hUmPCZsJg72fNM 3l/eBwLTpJW7ng6D9LdFC/1IRwhTUJ21MLMwNyici6Qp9stlJ3clc0qqyei8+xZAJhWm xmnQ== 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=foCgk8zcUSolWnGxsnJiriBVrT56FQaSbBo6WHS7LCw=; b=OAjXLQozv2IlH5CeseYkZJo3GRmMqvhL2meR9nFLSYSrxMNBe95V6DTLB+SPzlYk6T oEG85uOQU0iEO7AaBXjyB3UYIZBG5axO3zVCscYE/zIJiO34l1hy0l4IcCxGGSiD3DNS 458HHSY5fgCjU4MfsFmKgJ+PAD3QP/HwBo84o7lQx7X5aDNVJbxhPm4heaZvUb+GEoUP fqc5mKUDpukYbebEkHzmAuEEBaH6ZyPnIYXAo8dvBFa+Q5hf6QTN3W1aRpgNduYPqGLP I/tY6qzdgqSse+bbwfaD/Qsxt/S4xcJPiSGrCt1oz3DzET8ep2rZ8feTsjp14rtZeaUN wf8A== X-Gm-Message-State: AOAM530knSmlTN8zTuYYkgp3PbGjJVjiNqaj1UTBrPnNxa/KkIv7+tDc CsYwPmqzQHfQ4j30HAKooOQ= X-Google-Smtp-Source: ABdhPJyoQyazh5u50dbULCea8yZ9GZQ4WzO4ZuUUhJwKJlPRmYxcQeJSYi2+JssXdfAmlqN3v+zvMw== X-Received: by 2002:a17:906:8051:: with SMTP id x17mr1941552ejw.430.1610096858574; Fri, 08 Jan 2021 01:07:38 -0800 (PST) Received: from yoga-910.localhost (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id k16sm3307132ejd.78.2021.01.08.01.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 01:07:38 -0800 (PST) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: laurentiu.tudor@nxp.com, Ioana Ciornei Subject: [PATCH net-next v2 3/6] bus: fsl-mc: return -EPROBE_DEFER when a device is not yet discovered Date: Fri, 8 Jan 2021 11:07:24 +0200 Message-Id: <20210108090727.866283-4-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210108090727.866283-1-ciorneiioana@gmail.com> References: <20210108090727.866283-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei The fsl_mc_get_endpoint() should return a pointer to the connected fsl_mc device, if there is one. By interrogating the MC firmware, we know if there is an endpoint or not so when the endpoint device is actually searched on the fsl-mc bus and not found we are hitting the case in which the device has not been yet discovered by the bus. Return -EPROBE_DEFER so that callers can differentiate this case. Signed-off-by: Ioana Ciornei Acked-by: Laurentiu Tudor Reviewed-by: Andrew Lunn --- Changes in v2: - none drivers/bus/fsl-mc/fsl-mc-bus.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index 34811db074b7..28d5da1c011c 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -936,6 +936,15 @@ struct fsl_mc_device *fsl_mc_get_endpoint(struct fsl_mc_device *mc_dev) endpoint_desc.id = endpoint2.id; endpoint = fsl_mc_device_lookup(&endpoint_desc, mc_bus_dev); + /* + * We know that the device has an endpoint because we verified by + * interrogating the firmware. This is the case when the device was not + * yet discovered by the fsl-mc bus, thus the lookup returned NULL. + * Differentiate this case by returning EPROBE_DEFER. + */ + if (!endpoint) + return ERR_PTR(-EPROBE_DEFER); + return endpoint; } EXPORT_SYMBOL_GPL(fsl_mc_get_endpoint); From patchwork Fri Jan 8 09:07:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12006103 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,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 F3C8BC433E0 for ; Fri, 8 Jan 2021 09:08:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7AEE2226A for ; Fri, 8 Jan 2021 09:08:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728033AbhAHJIY (ORCPT ); Fri, 8 Jan 2021 04:08:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728014AbhAHJIV (ORCPT ); Fri, 8 Jan 2021 04:08:21 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F133BC0612F9 for ; Fri, 8 Jan 2021 01:07:40 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id b9so13686878ejy.0 for ; Fri, 08 Jan 2021 01:07:40 -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=Z5d4Wq24eFSaaginkRNTjN0txnMxYO4bJxyMlTjODSA=; b=HEdHUPC2kQpJGQ0oYz5P+m2vPJx8FfDFps3HLZ80SaXbiupUm5XG11lwttdgfKKAV0 1w2DPNhEeTornca95ODdVIgqlYCs3Kwo4eWQu3bq0LeE2KHm1EioGI5N703wjdFcryrc jQTHs/4hh8zbQ3F46c/G4WAeD8MKVgYmQJB4Rish1i6gFmMMVDRc3u6xePibMfTUCSne 01GfD8aMncjfVOTfS42NYwRFePa/4D9FQfKdR/ty13RyAcvids+Rg/e0bDD4FCEbmzmu WHhAP5mb5vYIarPWIzASzuS/RSLNJewl6UZzmixIcyCkM0YAKUPkNqLIjh+4BghMTanP bLQg== 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=Z5d4Wq24eFSaaginkRNTjN0txnMxYO4bJxyMlTjODSA=; b=H7qUEC6herizmFxIqJLuzhnG3cxAwMaZuZIQ2pcpc3YOBLnfdSAWEkYFl36lpmn/oX f/6GcPijz/2PS0zMlbr2GPetC9pwecxO86u8BCzAHvsrb1X87P1iFXIPGXDXLNtQwuzT bHFEZ2rOmolHQGAqGfB0cFEfV54/N4JpP01G4/QlgQ+pUcW1xDRi8I3k78uR0bqsG9dD OW05n7rwQGlUDkgCWUAh50dZcf/xYPdC6tDGvJpkf7egUXbfrV2HbovzT74d9VvbgjlL lFUWCPzAns6rSVE8ShRsVSvkp69ocYKqopDuP23JmPYXnmDMFWkyT4mqAX8w5CTLjNhY A5BA== X-Gm-Message-State: AOAM531SPwxesM2NjtKBOKh7EZyAKHo7H5UoggQLUrH1mi1POqn1tXxe VSQfogdMFDp2LGzvStCJqUU= X-Google-Smtp-Source: ABdhPJytTItuIDHASTqWfaysKULFaAqgJSw2+7+OleYMh5yf/Z78K8L5dOfMb3muDBTKfakdcRtnzg== X-Received: by 2002:a17:907:435c:: with SMTP id oc20mr2130001ejb.286.1610096859700; Fri, 08 Jan 2021 01:07:39 -0800 (PST) Received: from yoga-910.localhost (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id k16sm3307132ejd.78.2021.01.08.01.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 01:07:39 -0800 (PST) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: laurentiu.tudor@nxp.com, Ioana Ciornei Subject: [PATCH net-next v2 4/6] dpaa2-eth: retry the probe when the MAC is not yet discovered on the bus Date: Fri, 8 Jan 2021 11:07:25 +0200 Message-Id: <20210108090727.866283-5-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210108090727.866283-1-ciorneiioana@gmail.com> References: <20210108090727.866283-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei The fsl_mc_get_endpoint() function now returns -EPROBE_DEFER when the dpmac device was not yet discovered by the fsl-mc bus. When this happens, pass the error code up so that we can retry the probe at a later time. Signed-off-by: Ioana Ciornei Reviewed-by: Andrew Lunn --- Changes in v2: - replaced IS_ERR_OR_NULL() by IS_ERR() drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index f3f53e36aa00..a8c98869e484 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -4042,7 +4042,11 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv) dpni_dev = to_fsl_mc_device(priv->net_dev->dev.parent); dpmac_dev = fsl_mc_get_endpoint(dpni_dev); - if (IS_ERR_OR_NULL(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type) + + if (PTR_ERR(dpmac_dev) == -EPROBE_DEFER) + return PTR_ERR(dpmac_dev); + + if (IS_ERR(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type) return 0; mac = kzalloc(sizeof(struct dpaa2_mac), GFP_KERNEL); From patchwork Fri Jan 8 09:07:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12006105 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,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 DD8F9C433E0 for ; Fri, 8 Jan 2021 09:08:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 904AD2226A for ; Fri, 8 Jan 2021 09:08:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727919AbhAHJI6 (ORCPT ); Fri, 8 Jan 2021 04:08:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727885AbhAHJI5 (ORCPT ); Fri, 8 Jan 2021 04:08:57 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3977C0612FA for ; Fri, 8 Jan 2021 01:07:41 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id ga15so13610807ejb.4 for ; Fri, 08 Jan 2021 01:07:41 -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=hR6oOKRaEb4xU9lNIaadoNIwqR0Ic8ORY/DFIm1kfxI=; b=dBSDn9DcrhL4zzx1oPMe8HqJHNEBiVoHHA+DDM1D5rukRiH00zLOYLgjHwAFUtmcxB iFPc/ksHQYOaTOi+Q9OJvYNepfqkRFCdDSydkFKIRGbFd32M11e7zfjgyroVVIDkphfL QCY6psec3j3BDr/E4N+ZYHjZfc3F1AWKs8Bhb9gtV6+8QWLHJUCjzRALGkaU9av37CEg Qn9VlMRTLiPHM6Gnys6rAuNCthiSxFOQ/rrx20f5ZfXX2mV5UwRC+xiiTHvGBiQtKozY SGvC/N2g2o7fGzlaYJ2jf3Exd9HnEDLl1sVf1KeXY/bWdyA3nfAPbpk38U4WLciV37QU R/NQ== 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=hR6oOKRaEb4xU9lNIaadoNIwqR0Ic8ORY/DFIm1kfxI=; b=jv67ph0wW3P/M756UxP7Xcz3GAzVAzSOuR1L29H37TfKSaf6ntTyNwJjcsjkvQ95CI OCn5nnPeEGru99g0stO5OW/sx6x65ZyWoGVGWIk3/dm710GJxfUFks8LINIGGdwMd6kN mrFQdTZvd/FNo0DmSMwwVkAeQfINXJijG07eugKYp5BlN7F1c4lfZt4xdjw4wHwBJ3SY t7bTU0MDvvIzr8d42YVeT8a8lklDIV5CUhOO/1P0jQjpAG92NLcRf/WDT8UlXSgbRXGe 0c9nO7mLnerI5U/nj8e+TcPENjWXyU90BzjG+wmJvEUzc36SAys9rn1mF8mtFx2qwNy5 b7RA== X-Gm-Message-State: AOAM532BGiAn1NZereU0qRHgaqypAngepiH3MNn9gwvqtaklptMC9RXD 7tT+2HsXaEn5PSJud5DV/nU= X-Google-Smtp-Source: ABdhPJyIBC7obYhylvbAd56r42e9SZzLFLW2/McZelmFBbTmsQs07L56vpZpsvNMC7urSrvlfQx2tQ== X-Received: by 2002:a17:907:961d:: with SMTP id gb29mr2072781ejc.460.1610096860674; Fri, 08 Jan 2021 01:07:40 -0800 (PST) Received: from yoga-910.localhost (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id k16sm3307132ejd.78.2021.01.08.01.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 01:07:40 -0800 (PST) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: laurentiu.tudor@nxp.com, Ioana Ciornei Subject: [PATCH net-next v2 5/6] dpaa2-mac: remove an unnecessary check Date: Fri, 8 Jan 2021 11:07:26 +0200 Message-Id: <20210108090727.866283-6-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210108090727.866283-1-ciorneiioana@gmail.com> References: <20210108090727.866283-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei The dpaa2-eth driver has phylink integration only if the connected dpmac object is in TYPE_PHY (aka the PCS/PHY etc link status is managed by Linux instead of the firmware). The check is thus unnecessary because the code path that reaches the .mac_link_up() callback is only with TYPE_PHY dpmac objects. Signed-off-by: Ioana Ciornei --- Changes in v2: - none .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 81b2822a7dc9..3869c38f3979 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -174,30 +174,25 @@ static void dpaa2_mac_link_up(struct phylink_config *config, dpmac_state->up = 1; - if (mac->if_link_type == DPMAC_LINK_TYPE_PHY) { - /* If the DPMAC is configured for PHY mode, we need - * to pass the link parameters to the MC firmware. - */ - dpmac_state->rate = speed; - - if (duplex == DUPLEX_HALF) - dpmac_state->options |= DPMAC_LINK_OPT_HALF_DUPLEX; - else if (duplex == DUPLEX_FULL) - dpmac_state->options &= ~DPMAC_LINK_OPT_HALF_DUPLEX; - - /* This is lossy; the firmware really should take the pause - * enablement status rather than pause/asym pause status. - */ - if (rx_pause) - dpmac_state->options |= DPMAC_LINK_OPT_PAUSE; - else - dpmac_state->options &= ~DPMAC_LINK_OPT_PAUSE; - - if (rx_pause ^ tx_pause) - dpmac_state->options |= DPMAC_LINK_OPT_ASYM_PAUSE; - else - dpmac_state->options &= ~DPMAC_LINK_OPT_ASYM_PAUSE; - } + dpmac_state->rate = speed; + + if (duplex == DUPLEX_HALF) + dpmac_state->options |= DPMAC_LINK_OPT_HALF_DUPLEX; + else if (duplex == DUPLEX_FULL) + dpmac_state->options &= ~DPMAC_LINK_OPT_HALF_DUPLEX; + + /* This is lossy; the firmware really should take the pause + * enablement status rather than pause/asym pause status. + */ + if (rx_pause) + dpmac_state->options |= DPMAC_LINK_OPT_PAUSE; + else + dpmac_state->options &= ~DPMAC_LINK_OPT_PAUSE; + + if (rx_pause ^ tx_pause) + dpmac_state->options |= DPMAC_LINK_OPT_ASYM_PAUSE; + else + dpmac_state->options &= ~DPMAC_LINK_OPT_ASYM_PAUSE; err = dpmac_set_link_state(mac->mc_io, 0, mac->mc_dev->mc_handle, dpmac_state); From patchwork Fri Jan 8 09:07:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12006107 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,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 1EBFAC433E6 for ; Fri, 8 Jan 2021 09:09:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3C0722248 for ; Fri, 8 Jan 2021 09:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727961AbhAHJI7 (ORCPT ); Fri, 8 Jan 2021 04:08:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727895AbhAHJI5 (ORCPT ); Fri, 8 Jan 2021 04:08:57 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 251F1C0612FB for ; Fri, 8 Jan 2021 01:07:43 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id d17so13542486ejy.9 for ; Fri, 08 Jan 2021 01:07:43 -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=OehcWf/fqpAy2S0ELS38TYxWj45yJVZV6WoKp4s+Or0=; b=jSDoGoJccePoHjoAtZZZF1UWp57GGYFLbNDO1NAUYlopIs4lZV7z2gMojkSLAjsV7Z NRvxZObFQExNDWzVaQjVALBxvan4XnAf3AYWULy/9KphOt2saoWUXS5R3RiP9ybQ1Vyw wjYBvkf0tM5oZpcWQ11KdJZOiEKxiTpCbKoopJuxubnKDfaBjCJq39AjSklyWG+TVDUM IISR9zGlRnithYS2N7+Q91tnOfWbUApxO/Ps7l5+JSbtxeaMpHezgJ4wNRJz+9TNIXVI EW0oFmfLze0R7sC1JTAcK9aluBWtejbpp+Md0V/EKJCETRXZ0Q3mB1xZEN8WfhBpdAl3 R4vg== 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=OehcWf/fqpAy2S0ELS38TYxWj45yJVZV6WoKp4s+Or0=; b=U8hs2tDSuqNls0aYDGvsLqW5HYva2ofKPNDNlZdR/ckMTNxXf5WDpaqKo0Bw7Kp5qK ONgqh8YkE0Ej4EfEdryB65wYGk7XyJ1vJrkdID3SJmcq0u1kXAwdiE5JJKPWZ36p+bEj yPNpLGuPFHJn9CpYrsqaZW/TI4FYrpqXSY1Zy7GfLTHIdDwtM4tGn5KiGIFgaxhrWjy4 x0Ehwwdes2/ytRBQwxBY67Oz1kghA81shVlnb+TYTgRJvVjQ5KZq8hW5oa8a1e2NLfYK 443fiI6S98ROG587coMDX8sj7Vi9w6Faa09UwmbWZhiyBfvVGoxnze3SNznq4sxhuujM KRDA== X-Gm-Message-State: AOAM532Da+tjlJi7ugziV3Y/D/MkmWiJXIs9dtI5kqzW1kFwxw9p6pVG NhIOM91w8foZwhB6wTCfnxg= X-Google-Smtp-Source: ABdhPJwGBfxQBm08VyOiTpKrb9Gr8FZWzf95bhaslDVYEFN9juxip5HdnmpmVNjwvH/KE1T/+vyQqA== X-Received: by 2002:a17:907:98ec:: with SMTP id ke12mr1962549ejc.554.1610096861854; Fri, 08 Jan 2021 01:07:41 -0800 (PST) Received: from yoga-910.localhost (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id k16sm3307132ejd.78.2021.01.08.01.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 01:07:41 -0800 (PST) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: laurentiu.tudor@nxp.com, Ioana Ciornei Subject: [PATCH net-next v2 6/6] dpaa2-mac: remove a comment regarding pause settings Date: Fri, 8 Jan 2021 11:07:27 +0200 Message-Id: <20210108090727.866283-7-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210108090727.866283-1-ciorneiioana@gmail.com> References: <20210108090727.866283-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei The MC firmware takes these PAUSE/ASYM_PAUSE flags provided by the driver, transforms them back into rx/tx pause enablement status and applies them to hardware. We are not losing information by this transformation, thus remove the comment. Signed-off-by: Ioana Ciornei --- Changes in v2: - reworded the commit message drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 3869c38f3979..69ad869446cf 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -181,9 +181,6 @@ static void dpaa2_mac_link_up(struct phylink_config *config, else if (duplex == DUPLEX_FULL) dpmac_state->options &= ~DPMAC_LINK_OPT_HALF_DUPLEX; - /* This is lossy; the firmware really should take the pause - * enablement status rather than pause/asym pause status. - */ if (rx_pause) dpmac_state->options |= DPMAC_LINK_OPT_PAUSE; else