Received: by 10.213.65.68 with SMTP id h4csp918135imn; Wed, 28 Mar 2018 15:46:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx48iL+23srBRTvrtZRAcB7DXgZScXR1nQJxaNsXKZtX4i6FpYn+qhngqKVB+lpSZ8meaj28w X-Received: by 2002:a17:902:744b:: with SMTP id e11-v6mr267245plt.351.1522277168524; Wed, 28 Mar 2018 15:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522277168; cv=none; d=google.com; s=arc-20160816; b=mrnSE0RYfX7pWGL8baHRk7qSSjV4ra3b9T+jxMO2P+Boy0u7uR84DHTbuZ6u5puIYp rAhEWaqWJA8ueV+2t/ynAaYJEGHIu/N3GOe+tJgBD1dEZiorzGnYwv808YrqjqCGjF4O TKebljUvLNOhBReRFTSzzYselSn+y+UNeT8BS50k4BhHZTPsS3yYcRoUonSHUF7SAYnk HifMQinmR+UTIR3EQjFkRiJKX/kvDBW+AUqxDpOPpN41l7Qd4juzUmhgOr/dvHgdb6+I abnQdpMNfE+cNihyCx8IJfdTGXIJwyyy3Froa7/XLXUyzTUsd8jvXInnEE2F7G/FiJCj 7tVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=YgD5YqAOuc8utbpA64ZxOuM/8EB5Qe/gsje8VPST1ZU=; b=Wc62D869LTywwQi1zFCbOZd6Lq8bAt5jBcLTtmV95FI+pEGbVaebsBf4tU6GGy0KNa mi8xgAbwZ2RIiIAL2J4iXj7XXizKy4IPEYWOF5bcnebCFiXNTavuHICriyLHimhl25UK PnEgfwOG/dXlfEWEESPvudoyDlIpX6/qMP9eGgntbzF7t6q7KQM4Ts8eyugrxOCHhZ/Q XUrPlYfcqnbv6qL373sPNz5pZkdm3LIxGarKMrBSNTo8Ki80mgzZXRHYP8eko5EGBUxo kPKjtLJgvrgp0vHmF9+PafYd6y4Nx8m+IQqUvGjChQRgaxUexOehJUq33w5Jh1aMe3vD 0TBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U0wbqI1Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10si3115642pgp.45.2018.03.28.15.45.54; Wed, 28 Mar 2018 15:46:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U0wbqI1Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753998AbeC1Wo3 (ORCPT + 99 others); Wed, 28 Mar 2018 18:44:29 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:39544 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753973AbeC1WoZ (ORCPT ); Wed, 28 Mar 2018 18:44:25 -0400 Received: by mail-pg0-f67.google.com with SMTP id b9so1755483pgf.6; Wed, 28 Mar 2018 15:44:25 -0700 (PDT) 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; bh=YgD5YqAOuc8utbpA64ZxOuM/8EB5Qe/gsje8VPST1ZU=; b=U0wbqI1ZdVWpppPGtFvIiTU3cXjqCSRpTbMNV/8rW2Rw0zjiSCrWMZ1Ukypob1NoHH QgMe8gMwmgEXV0KTNv0lZEYfl0FqbF8WCV7gCahZiEpVvyB70KY/3p2eOlOnsG53D6pB cAD+/XjbI2WXnjxzBcsmKufzZ0RXRB5hGZbAaXPFJC8vppu+hDCCXsF1s1Tazj3aIQ1Z U/pW26f6oTWPEIz1UH0qOokntwr6MXW2hHn4DN1W5tvsA6Jchymv7SNZIN8I/euA3WRy KfTX2KZnRsbc6fBwUm6vENkmg3zd7ESdFTZA3iOQAuO+PozNqT7fpUr7fBALrOSyAO6s Tk0A== 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; bh=YgD5YqAOuc8utbpA64ZxOuM/8EB5Qe/gsje8VPST1ZU=; b=khjepXSGK08cQ6NMdo8ni5C3mscCoq/KvcS2mCijP5CvJPSuKUIfhPVwG1HDse978H /6//PnZ7YYwmkKTO0zdgUCvON43vrY9GNUXNyeQGJOrOgm3H4XTOR+/kTtKpGV/Hq4hI jVBbm5YXGRpd5I4Zg5j6ojKn4XwhtYV35OKhkyCKObe7pmXRwg76ByYtMpclULSChpav uEPtW2jzAfxVp2wp62RNwEpHHHUwWFFVPPXpADMN29TEy1BKFkc85PsnVf4s7ysvLCUi /6wnOgOffW43Er4WiTneAomzwgCX0U8aJucwZCIRGaCSjwuaDckwZmIZqzkeHUct12Lf KUow== X-Gm-Message-State: AElRT7HNKuBCYkoUp2iSicRQmiW/MeKhdj6TXD1KI3mHhF4gX2Ph9Y2n gn8e1M4H/ZIToiz5oiZDw0VA4MfM X-Received: by 2002:a17:902:bd94:: with SMTP id q20-v6mr5633489pls.364.1522277064385; Wed, 28 Mar 2018 15:44:24 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id s4sm8056472pgp.29.2018.03.28.15.44.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Mar 2018 15:44:23 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Russell King , Florian Fainelli , Thomas Petazzoni , Andrew Lunn , "David S. Miller" , linux-kernel@vger.kernel.org (open list), Antoine Tenart , Yan Markman , Stefan Chulski , Maxime Chevallier , Miquel Raynal , Marcin Wojtas Subject: [PATCH net-next v2 2/2] sfp/phylink: move module EEPROM ethtool access into netdev core ethtool Date: Wed, 28 Mar 2018 15:44:16 -0700 Message-Id: <20180328224416.6981-3-f.fainelli@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180328224416.6981-1-f.fainelli@gmail.com> References: <20180328224416.6981-1-f.fainelli@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Russell King Provide a pointer to the SFP bus in struct net_device, so that the ethtool module EEPROM methods can access the SFP directly, rather than needing every user to provide a hook for it. Reviewed-by: Andrew Lunn Signed-off-by: Russell King Signed-off-by: Florian Fainelli --- drivers/net/ethernet/marvell/mvneta.c | 18 ------------------ drivers/net/phy/phylink.c | 28 ---------------------------- drivers/net/phy/sfp-bus.c | 6 ++---- include/linux/netdevice.h | 3 +++ include/linux/phylink.h | 3 --- net/core/ethtool.c | 7 +++++++ 6 files changed, 12 insertions(+), 53 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index cd09bde55596..25ced96750bf 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -4075,22 +4075,6 @@ static int mvneta_ethtool_set_wol(struct net_device *dev, return ret; } -static int mvneta_ethtool_get_module_info(struct net_device *dev, - struct ethtool_modinfo *modinfo) -{ - struct mvneta_port *pp = netdev_priv(dev); - - return phylink_ethtool_get_module_info(pp->phylink, modinfo); -} - -static int mvneta_ethtool_get_module_eeprom(struct net_device *dev, - struct ethtool_eeprom *ee, u8 *buf) -{ - struct mvneta_port *pp = netdev_priv(dev); - - return phylink_ethtool_get_module_eeprom(pp->phylink, ee, buf); -} - static int mvneta_ethtool_get_eee(struct net_device *dev, struct ethtool_eee *eee) { @@ -4165,8 +4149,6 @@ static const struct ethtool_ops mvneta_eth_tool_ops = { .set_link_ksettings = mvneta_ethtool_set_link_ksettings, .get_wol = mvneta_ethtool_get_wol, .set_wol = mvneta_ethtool_set_wol, - .get_module_info = mvneta_ethtool_get_module_info, - .get_module_eeprom = mvneta_ethtool_get_module_eeprom, .get_eee = mvneta_ethtool_get_eee, .set_eee = mvneta_ethtool_set_eee, }; diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 9b1e4721ea3a..c582b2d7546c 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1250,34 +1250,6 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, } EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam); -int phylink_ethtool_get_module_info(struct phylink *pl, - struct ethtool_modinfo *modinfo) -{ - int ret = -EOPNOTSUPP; - - WARN_ON(!lockdep_rtnl_is_held()); - - if (pl->sfp_bus) - ret = sfp_get_module_info(pl->sfp_bus, modinfo); - - return ret; -} -EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_info); - -int phylink_ethtool_get_module_eeprom(struct phylink *pl, - struct ethtool_eeprom *ee, u8 *buf) -{ - int ret = -EOPNOTSUPP; - - WARN_ON(!lockdep_rtnl_is_held()); - - if (pl->sfp_bus) - ret = sfp_get_module_eeprom(pl->sfp_bus, ee, buf); - - return ret; -} -EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_eeprom); - /** * phylink_ethtool_get_eee_err() - read the energy efficient ethernet error * counter diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index 3d4ff5d0d2a6..0381da78d228 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c @@ -342,6 +342,7 @@ static int sfp_register_bus(struct sfp_bus *bus) } if (bus->started) bus->socket_ops->start(bus->sfp); + bus->netdev->sfp_bus = bus; bus->registered = true; return 0; } @@ -356,6 +357,7 @@ static void sfp_unregister_bus(struct sfp_bus *bus) if (bus->phydev && ops && ops->disconnect_phy) ops->disconnect_phy(bus->upstream); } + bus->netdev->sfp_bus = NULL; bus->registered = false; } @@ -371,8 +373,6 @@ static void sfp_unregister_bus(struct sfp_bus *bus) */ int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) { - if (!bus->registered) - return -ENOIOCTLCMD; return bus->socket_ops->module_info(bus->sfp, modinfo); } EXPORT_SYMBOL_GPL(sfp_get_module_info); @@ -391,8 +391,6 @@ EXPORT_SYMBOL_GPL(sfp_get_module_info); int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, u8 *data) { - if (!bus->registered) - return -ENOIOCTLCMD; return bus->socket_ops->module_eeprom(bus->sfp, ee, data); } EXPORT_SYMBOL_GPL(sfp_get_module_eeprom); diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 2a2d9cf50aa2..53f0cd64676b 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -58,6 +58,7 @@ struct device; struct phy_device; struct dsa_port; +struct sfp_bus; /* 802.11 specific */ struct wireless_dev; /* 802.15.4 specific */ @@ -1662,6 +1663,7 @@ enum netdev_priv_flags { * @priomap: XXX: need comments on this one * @phydev: Physical device may attach itself * for hardware timestamping + * @sfp_bus: attached &struct sfp_bus structure. * * @qdisc_tx_busylock: lockdep class annotating Qdisc->busylock spinlock * @qdisc_running_key: lockdep class annotating Qdisc->running seqcount @@ -1945,6 +1947,7 @@ struct net_device { struct netprio_map __rcu *priomap; #endif struct phy_device *phydev; + struct sfp_bus *sfp_bus; struct lock_class_key *qdisc_tx_busylock; struct lock_class_key *qdisc_running_key; bool proto_down; diff --git a/include/linux/phylink.h b/include/linux/phylink.h index e95cc12030fa..50eeae025f1e 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -219,9 +219,6 @@ void phylink_ethtool_get_pauseparam(struct phylink *, struct ethtool_pauseparam *); int phylink_ethtool_set_pauseparam(struct phylink *, struct ethtool_pauseparam *); -int phylink_ethtool_get_module_info(struct phylink *, struct ethtool_modinfo *); -int phylink_ethtool_get_module_eeprom(struct phylink *, - struct ethtool_eeprom *, u8 *); int phylink_get_eee_err(struct phylink *); int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *); int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *); diff --git a/net/core/ethtool.c b/net/core/ethtool.c index bb6e498c6e3d..eb55252ca1fb 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -2245,6 +2246,9 @@ static int __ethtool_get_module_info(struct net_device *dev, const struct ethtool_ops *ops = dev->ethtool_ops; struct phy_device *phydev = dev->phydev; + if (dev->sfp_bus) + return sfp_get_module_info(dev->sfp_bus, modinfo); + if (phydev && phydev->drv && phydev->drv->module_info) return phydev->drv->module_info(phydev, modinfo); @@ -2279,6 +2283,9 @@ static int __ethtool_get_module_eeprom(struct net_device *dev, const struct ethtool_ops *ops = dev->ethtool_ops; struct phy_device *phydev = dev->phydev; + if (dev->sfp_bus) + return sfp_get_module_eeprom(dev->sfp_bus, ee, data); + if (phydev && phydev->drv && phydev->drv->module_eeprom) return phydev->drv->module_eeprom(phydev, ee, data); -- 2.14.1