Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753512AbcDOCvH (ORCPT ); Thu, 14 Apr 2016 22:51:07 -0400 Received: from mail-am1on0091.outbound.protection.outlook.com ([157.56.112.91]:32265 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751875AbcDOCvE convert rfc822-to-8bit (ORCPT ); Thu, 14 Apr 2016 22:51:04 -0400 X-Greylist: delayed 768 seconds by postgrey-1.27 at vger.kernel.org; Thu, 14 Apr 2016 22:51:03 EDT From: Fugang Duan To: Philippe Reynes , "davem@davemloft.net" , "decot@googlers.com" , "f.fainelli@gmail.com" CC: "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" Subject: RE: [PATCH 2/3] phy: add generic function to support ksetting support Thread-Topic: [PATCH 2/3] phy: add generic function to support ksetting support Thread-Index: AQHRlp3psWgGPA3N8UKRr6WzfLD0cp+KVBTA Date: Fri, 15 Apr 2016 02:50:59 +0000 Message-ID: References: <1460673301-10599-1-git-send-email-tremyfr@gmail.com> <1460673301-10599-3-git-send-email-tremyfr@gmail.com> In-Reply-To: <1460673301-10599-3-git-send-email-tremyfr@gmail.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [199.59.226.141] x-ms-office365-filtering-correlation-id: c071ef05-736a-42f0-4330-08d364d8c685 x-microsoft-exchange-diagnostics: 1;VI1PR0401MB1853;5:qJglqj0WJ82pN1JDUeXY1bjNftwwL0x1jS3D0twIIDLvVpkDjD+00OKmU70qFRt7UyThapHnCYvnusSxBFmyEdJODPjKp/Gw1vv0LgK/DyzVmuuBcTtgi13mwnlol1LdtA/O/YnMySQz+OnEifAzFg==;24:sgaa7QtfgA4h5s00fxXFcZRy3qgZNF3HsX0bYqwhmxZuHV+a2Z8AO/cQaUPJAG252bLO+nkXo0dBtaRboDhg6qjhAwL7xDfZYugvFOpLa6w= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0401MB1853; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026);SRVR:VI1PR0401MB1853;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0401MB1853; x-forefront-prvs: 0913EA1D60 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(377454003)(2501003)(106116001)(10400500002)(86362001)(81166005)(76176999)(2201001)(9686002)(5003600100002)(122556002)(50986999)(54356999)(4326007)(92566002)(87936001)(5002640100001)(74316001)(1220700001)(3846002)(6116002)(102836003)(2950100001)(33656002)(5001770100001)(189998001)(66066001)(1096002)(2900100001)(76576001)(2906002)(77096005)(5008740100001)(3900700001)(586003)(19580395003)(19580405001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB1853;H:VI1PR0401MB1855.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Apr 2016 02:50:59.3520 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB1853 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4885 Lines: 140 From: Philippe Reynes Sent: Friday, April 15, 2016 6:35 AM > To: davem@davemloft.net; decot@googlers.com; f.fainelli@gmail.com; Fugang > Duan > Cc: linux-kernel@vger.kernel.org; netdev@vger.kernel.org; Philippe Reynes > > Subject: [PATCH 2/3] phy: add generic function to support ksetting support > > The old ethtool api (get_setting and set_setting) has generic phy functions > phy_ethtool_sset and phy_ethtool_gset. > To supprt the new ethtool api (get_link_ksettings and set_link_ksettings), we > add generic phy function phy_ethtool_ksettings_get and > phy_ethtool_ksettings_set. > > Signed-off-by: Philippe Reynes > --- > drivers/net/phy/phy.c | 81 > +++++++++++++++++++++++++++++++++++++++++++++++++ > include/linux/phy.h | 4 ++ > 2 files changed, 85 insertions(+), 0 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index > 5590b9c..6f221c8 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -362,6 +362,60 @@ int phy_ethtool_sset(struct phy_device *phydev, > struct ethtool_cmd *cmd) } EXPORT_SYMBOL(phy_ethtool_sset); > > +int phy_ethtool_ksettings_set(struct phy_device *phydev, > + const struct ethtool_link_ksettings *cmd) { > + u8 autoneg = cmd->base.autoneg; > + u8 duplex = cmd->base.duplex; > + u32 speed = cmd->base.speed; > + u32 advertising; > + > + if (cmd->base.phy_address != phydev->mdio.addr) > + return -EINVAL; > + > + ethtool_convert_link_mode_to_legacy_u32(&advertising, > + cmd->link_modes.advertising); > + > + /* We make sure that we don't pass unsupported values in to the PHY */ > + advertising &= phydev->supported; > + > + /* Verify the settings we care about. */ > + if (autoneg != AUTONEG_ENABLE && autoneg != AUTONEG_DISABLE) > + return -EINVAL; > + > + if (autoneg == AUTONEG_ENABLE && advertising == 0) > + return -EINVAL; > + > + if (autoneg == AUTONEG_DISABLE && > + ((speed != SPEED_1000 && > + speed != SPEED_100 && > + speed != SPEED_10) || > + (duplex != DUPLEX_HALF && > + duplex != DUPLEX_FULL))) > + return -EINVAL; > + > + phydev->autoneg = autoneg; > + > + phydev->speed = speed; > + > + phydev->advertising = advertising; > + > + if (autoneg == AUTONEG_ENABLE) > + phydev->advertising |= ADVERTISED_Autoneg; > + else > + phydev->advertising &= ~ADVERTISED_Autoneg; > + > + phydev->duplex = duplex; > + > + phydev->mdix = cmd->base.eth_tp_mdix_ctrl; > + > + /* Restart the PHY */ > + phy_start_aneg(phydev); > + > + return 0; > +} > +EXPORT_SYMBOL(phy_ethtool_ksettings_set); > + > int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd) { > cmd->supported = phydev->supported; > @@ -385,6 +439,33 @@ int phy_ethtool_gset(struct phy_device *phydev, > struct ethtool_cmd *cmd) } EXPORT_SYMBOL(phy_ethtool_gset); > > +int phy_ethtool_ksettings_get(struct phy_device *phydev, > + struct ethtool_link_ksettings *cmd) { > + ethtool_convert_legacy_u32_to_link_mode(cmd- > >link_modes.supported, > + phydev->supported); > + > + ethtool_convert_legacy_u32_to_link_mode(cmd- > >link_modes.advertising, > + phydev->advertising); > + > + ethtool_convert_legacy_u32_to_link_mode(cmd- > >link_modes.lp_advertising, > + phydev->lp_advertising); > + > + cmd->base.speed = phydev->speed; > + cmd->base.duplex = phydev->duplex; > + if (phydev->interface == PHY_INTERFACE_MODE_MOCA) > + cmd->base.port = PORT_BNC; > + else > + cmd->base.port = PORT_MII; > + > + cmd->base.phy_address = phydev->mdio.addr; > + cmd->base.autoneg = phydev->autoneg; > + cmd->base.eth_tp_mdix_ctrl = phydev->mdix; > + > + return 0; > +} > +EXPORT_SYMBOL(phy_ethtool_ksettings_get); > + > /** > * phy_mii_ioctl - generic PHY MII ioctl interface > * @phydev: the phy_device struct > diff --git a/include/linux/phy.h b/include/linux/phy.h index 2abd791..be3f83b > 100644 > --- a/include/linux/phy.h > +++ b/include/linux/phy.h > @@ -805,6 +805,10 @@ void phy_start_machine(struct phy_device *phydev); > void phy_stop_machine(struct phy_device *phydev); int > phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd); int > phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd); > +int phy_ethtool_ksettings_get(struct phy_device *phydev, > + struct ethtool_link_ksettings *cmd); int > +phy_ethtool_ksettings_set(struct phy_device *phydev, > + const struct ethtool_link_ksettings *cmd); > int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd); int > phy_start_interrupts(struct phy_device *phydev); void phy_print_status(struct > phy_device *phydev); > -- > 1.7.4.4 It seems fine. There have many drivers need to update .set_settings/. get_settings, not only fsl fec driver. And whether there still need to keep the old interface in phy.c driver ? Regards, Andy