[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<HE1PR04MB31480DBFDFA823EACCD399CB8834A@HE1PR04MB3148.eurprd04.prod.outlook.com>
Date: Fri, 14 Jul 2023 03:05:36 +0000
From: Wei Fang <wei.fang@....com>
To: Vladimir Oltean <vladimir.oltean@....com>, "netdev@...r.kernel.org"
<netdev@...r.kernel.org>
CC: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
<pabeni@...hat.com>, Andrew Lunn <andrew@...n.ch>, Florian Fainelli
<f.fainelli@...il.com>, Maxim Georgiev <glipus@...il.com>, Horatiu Vultur
<horatiu.vultur@...rochip.com>, Köry Maincent
<kory.maincent@...tlin.com>, Maxime Chevallier
<maxime.chevallier@...tlin.com>, Richard Cochran <richardcochran@...il.com>,
Vadim Fedorenko <vadim.fedorenko@...ux.dev>, Gerhard Engleder
<gerhard@...leder-embedded.com>, Hangbin Liu <liuhangbin@...il.com>, Russell
King <linux@...linux.org.uk>, Heiner Kallweit <hkallweit1@...il.com>, Jacob
Keller <jacob.e.keller@...el.com>, Jay Vosburgh <j.vosburgh@...il.com>, Andy
Gospodarek <andy@...yhouse.net>, Shenwei Wang <shenwei.wang@....com>, Clark
Wang <xiaoning.wang@....com>, dl-linux-imx <linux-imx@....com>,
"UNGLinuxDriver@...rochip.com" <UNGLinuxDriver@...rochip.com>, Lars Povlsen
<lars.povlsen@...rochip.com>, Steen Hegelund <Steen.Hegelund@...rochip.com>,
Daniel Machon <daniel.machon@...rochip.com>, Simon Horman
<simon.horman@...igine.com>, Casper Andersson <casper.casan@...il.com>,
Sergey Organov <sorganov@...il.com>, "linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v7 net-next 06/10] net: fec: convert to ndo_hwtstamp_get()
and ndo_hwtstamp_set()
> -----Original Message-----
> From: Vladimir Oltean <vladimir.oltean@....com>
> Sent: 2023年7月13日 20:19
> To: netdev@...r.kernel.org
> Cc: David S. Miller <davem@...emloft.net>; Eric Dumazet
> <edumazet@...gle.com>; Jakub Kicinski <kuba@...nel.org>; Paolo Abeni
> <pabeni@...hat.com>; Andrew Lunn <andrew@...n.ch>; Florian Fainelli
> <f.fainelli@...il.com>; Maxim Georgiev <glipus@...il.com>; Horatiu Vultur
> <horatiu.vultur@...rochip.com>; Köry Maincent
> <kory.maincent@...tlin.com>; Maxime Chevallier
> <maxime.chevallier@...tlin.com>; Richard Cochran
> <richardcochran@...il.com>; Vadim Fedorenko
> <vadim.fedorenko@...ux.dev>; Gerhard Engleder
> <gerhard@...leder-embedded.com>; Hangbin Liu <liuhangbin@...il.com>;
> Russell King <linux@...linux.org.uk>; Heiner Kallweit
> <hkallweit1@...il.com>; Jacob Keller <jacob.e.keller@...el.com>; Jay
> Vosburgh <j.vosburgh@...il.com>; Andy Gospodarek <andy@...yhouse.net>;
> Wei Fang <wei.fang@....com>; Shenwei Wang <shenwei.wang@....com>;
> Clark Wang <xiaoning.wang@....com>; dl-linux-imx <linux-imx@....com>;
> UNGLinuxDriver@...rochip.com; Lars Povlsen <lars.povlsen@...rochip.com>;
> Steen Hegelund <Steen.Hegelund@...rochip.com>; Daniel Machon
> <daniel.machon@...rochip.com>; Simon Horman
> <simon.horman@...igine.com>; Casper Andersson
> <casper.casan@...il.com>; Sergey Organov <sorganov@...il.com>;
> linux-arm-kernel@...ts.infradead.org; linux-kernel@...r.kernel.org
> Subject: [PATCH v7 net-next 06/10] net: fec: convert to ndo_hwtstamp_get()
> and ndo_hwtstamp_set()
>
> The hardware timestamping through ndo_eth_ioctl() is going away.
> Convert the FEC driver to the new API before that can be removed.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
> ---
> Changes in v7:
> - Patch is new
>
> drivers/net/ethernet/freescale/fec.h | 5 ++-
> drivers/net/ethernet/freescale/fec_main.c | 52 +++++++++++++++++------
> drivers/net/ethernet/freescale/fec_ptp.c | 31 +++++---------
> 3 files changed, 52 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec.h
> b/drivers/net/ethernet/freescale/fec.h
> index 9939ccafb556..d4ae0e7c0a44 100644
> --- a/drivers/net/ethernet/freescale/fec.h
> +++ b/drivers/net/ethernet/freescale/fec.h
> @@ -691,8 +691,9 @@ void fec_ptp_init(struct platform_device *pdev, int
> irq_idx); void fec_ptp_stop(struct platform_device *pdev); void
> fec_ptp_start_cyclecounter(struct net_device *ndev); void
> fec_ptp_disable_hwts(struct net_device *ndev); -int fec_ptp_set(struct
> net_device *ndev, struct ifreq *ifr); -int fec_ptp_get(struct net_device *ndev,
> struct ifreq *ifr);
> +int fec_ptp_set(struct net_device *ndev, struct kernel_hwtstamp_config
> *config,
> + struct netlink_ext_ack *extack);
> +void fec_ptp_get(struct net_device *ndev, struct kernel_hwtstamp_config
> +*config);
>
>
> /******************************************************************
> **********/
> #endif /* FEC_H */
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index 1280da699fa3..c0b68fc3ec8b 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -3196,7 +3196,6 @@ static const struct ethtool_ops
> fec_enet_ethtool_ops = {
>
> static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) {
> - struct fec_enet_private *fep = netdev_priv(ndev);
> struct phy_device *phydev = ndev->phydev;
>
> if (!netif_running(ndev))
> @@ -3205,19 +3204,6 @@ static int fec_enet_ioctl(struct net_device *ndev,
> struct ifreq *rq, int cmd)
> if (!phydev)
> return -ENODEV;
>
> - if (fep->bufdesc_ex) {
> - bool use_fec_hwts = !phy_has_hwtstamp(phydev);
> -
> - if (cmd == SIOCSHWTSTAMP) {
> - if (use_fec_hwts)
> - return fec_ptp_set(ndev, rq);
> - fec_ptp_disable_hwts(ndev);
> - } else if (cmd == SIOCGHWTSTAMP) {
> - if (use_fec_hwts)
> - return fec_ptp_get(ndev, rq);
> - }
> - }
> -
> return phy_mii_ioctl(phydev, rq, cmd); }
>
> @@ -3868,6 +3854,42 @@ static int fec_enet_xdp_xmit(struct net_device
> *dev,
> return sent_frames;
> }
>
> +static int fec_hwtstamp_get(struct net_device *ndev,
> + struct kernel_hwtstamp_config *config) {
> + struct fec_enet_private *fep = netdev_priv(ndev);
> + struct phy_device *phydev = ndev->phydev;
> +
> + if (phy_has_hwtstamp(phydev))
> + return phy_mii_ioctl(phydev, config->ifr, SIOCGHWTSTAMP);
> +
> + if (!fep->bufdesc_ex)
> + return -EOPNOTSUPP;
> +
> + fec_ptp_get(ndev, config);
> +
> + return 0;
> +}
> +
> +static int fec_hwtstamp_set(struct net_device *ndev,
> + struct kernel_hwtstamp_config *config,
> + struct netlink_ext_ack *extack)
> +{
> + struct fec_enet_private *fep = netdev_priv(ndev);
> + struct phy_device *phydev = ndev->phydev;
> +
> + if (phy_has_hwtstamp(phydev)) {
> + fec_ptp_disable_hwts(ndev);
> +
> + return phy_mii_ioctl(phydev, config->ifr, SIOCSHWTSTAMP);
> + }
> +
> + if (!fep->bufdesc_ex)
> + return -EOPNOTSUPP;
> +
> + return fec_ptp_set(ndev, config, extack); }
> +
> static const struct net_device_ops fec_netdev_ops = {
> .ndo_open = fec_enet_open,
> .ndo_stop = fec_enet_close,
> @@ -3884,6 +3906,8 @@ static const struct net_device_ops fec_netdev_ops =
> {
> .ndo_set_features = fec_set_features,
> .ndo_bpf = fec_enet_bpf,
> .ndo_xdp_xmit = fec_enet_xdp_xmit,
> + .ndo_hwtstamp_get = fec_hwtstamp_get,
> + .ndo_hwtstamp_set = fec_hwtstamp_set,
> };
>
> static const unsigned short offset_des_active_rxq[] = { diff --git
> a/drivers/net/ethernet/freescale/fec_ptp.c
> b/drivers/net/ethernet/freescale/fec_ptp.c
> index ab86bb8562ef..3f53b8ae57dd 100644
> --- a/drivers/net/ethernet/freescale/fec_ptp.c
> +++ b/drivers/net/ethernet/freescale/fec_ptp.c
> @@ -618,16 +618,12 @@ void fec_ptp_disable_hwts(struct net_device *ndev)
> fep->hwts_rx_en = 0;
> }
>
> -int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr)
> +int fec_ptp_set(struct net_device *ndev, struct kernel_hwtstamp_config
> *config,
> + struct netlink_ext_ack *extack)
> {
> struct fec_enet_private *fep = netdev_priv(ndev);
>
> - struct hwtstamp_config config;
> -
> - if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
> - return -EFAULT;
> -
> - switch (config.tx_type) {
> + switch (config->tx_type) {
> case HWTSTAMP_TX_OFF:
> fep->hwts_tx_en = 0;
> break;
> @@ -638,33 +634,28 @@ int fec_ptp_set(struct net_device *ndev, struct ifreq
> *ifr)
> return -ERANGE;
> }
>
> - switch (config.rx_filter) {
> + switch (config->rx_filter) {
> case HWTSTAMP_FILTER_NONE:
> fep->hwts_rx_en = 0;
> break;
>
> default:
> fep->hwts_rx_en = 1;
> - config.rx_filter = HWTSTAMP_FILTER_ALL;
> + config->rx_filter = HWTSTAMP_FILTER_ALL;
> break;
> }
>
> - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
> - -EFAULT : 0;
> + return 0;
> }
>
> -int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr)
> +void fec_ptp_get(struct net_device *ndev, struct kernel_hwtstamp_config
> +*config)
> {
> struct fec_enet_private *fep = netdev_priv(ndev);
> - struct hwtstamp_config config;
> -
> - config.flags = 0;
> - config.tx_type = fep->hwts_tx_en ? HWTSTAMP_TX_ON :
> HWTSTAMP_TX_OFF;
> - config.rx_filter = (fep->hwts_rx_en ?
> - HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE);
>
> - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
> - -EFAULT : 0;
> + config->flags = 0;
> + config->tx_type = fep->hwts_tx_en ? HWTSTAMP_TX_ON :
> HWTSTAMP_TX_OFF;
> + config->rx_filter = (fep->hwts_rx_en ?
> + HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE);
> }
>
> /*
> --
> 2.34.1
Thanks!
Reviewed-by: Wei Fang < wei.fang@....com >
Powered by blists - more mailing lists