Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752208AbdI1RZk (ORCPT ); Thu, 28 Sep 2017 13:25:40 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:34663 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751945AbdI1RZi (ORCPT ); Thu, 28 Sep 2017 13:25:38 -0400 X-Google-Smtp-Source: AOwi7QCy6pSq5aVRQKOMhrK6Sb+iGlhYBe8ZCK+Tm/MuqpyVDalLL/mI9nJF8jsKrukzy1xYHHs5xg== Subject: Re: [PATCH net-next RFC 5/9] net: dsa: forward hardware timestamping ioctls to switch driver To: Brandon Streiff , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Andrew Lunn , Vivien Didelot , Richard Cochran , Erik Hons References: <1506612341-18061-1-git-send-email-brandon.streiff@ni.com> <1506612341-18061-6-git-send-email-brandon.streiff@ni.com> From: Florian Fainelli Message-ID: Date: Thu, 28 Sep 2017 10:25:34 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1506612341-18061-6-git-send-email-brandon.streiff@ni.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1598 Lines: 52 On 09/28/2017 08:25 AM, Brandon Streiff wrote: > This patch adds support to the dsa slave network device so that > switch drivers can implement the SIOC[GS]HWTSTAMP ioctls and the > ethtool timestamp-info interface. > > Signed-off-by: Brandon Streiff > --- > struct dsa_switch_driver { > diff --git a/net/dsa/slave.c b/net/dsa/slave.c > index bf8800d..2cf6a83 100644 > --- a/net/dsa/slave.c > +++ b/net/dsa/slave.c > @@ -264,10 +264,34 @@ dsa_slave_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, > > static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) > { > + struct dsa_slave_priv *p = netdev_priv(dev); > + struct dsa_switch *ds = p->dp->ds; > + int port = p->dp->index; > + > if (!dev->phydev) > return -ENODEV; > > - return phy_mii_ioctl(dev->phydev, ifr, cmd); > + switch (cmd) { > + case SIOCGMIIPHY: > + case SIOCGMIIREG: > + case SIOCSMIIREG: > + if (dev->phydev) > + return phy_mii_ioctl(dev->phydev, ifr, cmd); > + else > + return -EOPNOTSUPP; > + case SIOCGHWTSTAMP: > + if (ds->ops->port_hwtstamp_get) > + return ds->ops->port_hwtstamp_get(ds, port, ifr); > + else > + return -EOPNOTSUPP; > + case SIOCSHWTSTAMP: > + if (ds->ops->port_hwtstamp_set) > + return ds->ops->port_hwtstamp_set(ds, port, ifr); > + else > + return -EOPNOTSUPP; > + default: > + return -EOPNOTSUPP; > + } This echoes back to Andrew's comments in patch 2, but we may have to prefer PHY timestamping over MAC timestamping if both are available? Richard, is that usually how the preference should be made? -- Florian