netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] vlan: also check phy_driver ts_info for vlan's real device
@ 2018-03-30  1:44 Hangbin Liu
  2018-03-30 15:02 ` Andrew Lunn
  2018-04-02  0:56 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Hangbin Liu @ 2018-03-30  1:44 UTC (permalink / raw)
  To: netdev; +Cc: Richard Cochran, David S. Miller, Hangbin Liu

Just like function ethtool_get_ts_info(), we should also consider the
phy_driver ts_info call back. For example, driver dp83640.

Fixes: 37dd9255b2f6 ("vlan: Pass ethtool get_ts_info queries to real device.")
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 net/8021q/vlan_dev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index f7e83f6..236452e 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -29,6 +29,7 @@
 #include <linux/net_tstamp.h>
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
+#include <linux/phy.h>
 #include <net/arp.h>
 #include <net/switchdev.h>
 
@@ -665,8 +666,11 @@ static int vlan_ethtool_get_ts_info(struct net_device *dev,
 {
 	const struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
 	const struct ethtool_ops *ops = vlan->real_dev->ethtool_ops;
+	struct phy_device *phydev = vlan->real_dev->phydev;
 
-	if (ops->get_ts_info) {
+	if (phydev && phydev->drv && phydev->drv->ts_info) {
+		 return phydev->drv->ts_info(phydev, info);
+	} else if (ops->get_ts_info) {
 		return ops->get_ts_info(vlan->real_dev, info);
 	} else {
 		info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] vlan: also check phy_driver ts_info for vlan's real device
  2018-03-30  1:44 [PATCH net] vlan: also check phy_driver ts_info for vlan's real device Hangbin Liu
@ 2018-03-30 15:02 ` Andrew Lunn
  2018-03-30 15:21   ` Richard Cochran
  2018-04-02  0:56 ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2018-03-30 15:02 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, Richard Cochran, David S. Miller

On Fri, Mar 30, 2018 at 09:44:00AM +0800, Hangbin Liu wrote:
> Just like function ethtool_get_ts_info(), we should also consider the
> phy_driver ts_info call back. For example, driver dp83640.

Hi Hangbin

Would it not be better to just call ethtool_get_ts_info() on the real
device? That would then also deal with the case that the 'real' device
is another virtual device stacked on top of a real device.

   Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] vlan: also check phy_driver ts_info for vlan's real device
  2018-03-30 15:02 ` Andrew Lunn
@ 2018-03-30 15:21   ` Richard Cochran
  2018-03-30 15:36     ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Cochran @ 2018-03-30 15:21 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Hangbin Liu, netdev, David S. Miller

On Fri, Mar 30, 2018 at 05:02:14PM +0200, Andrew Lunn wrote:
> Would it not be better to just call ethtool_get_ts_info() on the real
> device? That would then also deal with the case that the 'real' device
> is another virtual device stacked on top of a real device.

That won't work.

The returned 'ethtool_ts_info' is on the stack of
ethtool_get_ts_info().  Both the top level and the inner call to
will call copy_to_user(), but the top level will clobber the correct
result with zeros.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] vlan: also check phy_driver ts_info for vlan's real device
  2018-03-30 15:21   ` Richard Cochran
@ 2018-03-30 15:36     ` Andrew Lunn
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2018-03-30 15:36 UTC (permalink / raw)
  To: Richard Cochran; +Cc: Hangbin Liu, netdev, David S. Miller

On Fri, Mar 30, 2018 at 08:21:21AM -0700, Richard Cochran wrote:
> On Fri, Mar 30, 2018 at 05:02:14PM +0200, Andrew Lunn wrote:
> > Would it not be better to just call ethtool_get_ts_info() on the real
> > device? That would then also deal with the case that the 'real' device
> > is another virtual device stacked on top of a real device.
> 
> That won't work.
> 
> The returned 'ethtool_ts_info' is on the stack of
> ethtool_get_ts_info().  Both the top level and the inner call to
> will call copy_to_user(), but the top level will clobber the correct
> result with zeros.

Ah, O.K.

But it still seems like there should be one central place to handle a
device. Maybe factor out the part which deals with getting the
information from the device, from the part that copies it to
userspace?

	Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] vlan: also check phy_driver ts_info for vlan's real device
  2018-03-30  1:44 [PATCH net] vlan: also check phy_driver ts_info for vlan's real device Hangbin Liu
  2018-03-30 15:02 ` Andrew Lunn
@ 2018-04-02  0:56 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2018-04-02  0:56 UTC (permalink / raw)
  To: liuhangbin; +Cc: netdev, richardcochran

From: Hangbin Liu <liuhangbin@gmail.com>
Date: Fri, 30 Mar 2018 09:44:00 +0800

> Just like function ethtool_get_ts_info(), we should also consider the
> phy_driver ts_info call back. For example, driver dp83640.
> 
> Fixes: 37dd9255b2f6 ("vlan: Pass ethtool get_ts_info queries to real device.")
> Acked-by: Richard Cochran <richardcochran@gmail.com>
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-02  0:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-30  1:44 [PATCH net] vlan: also check phy_driver ts_info for vlan's real device Hangbin Liu
2018-03-30 15:02 ` Andrew Lunn
2018-03-30 15:21   ` Richard Cochran
2018-03-30 15:36     ` Andrew Lunn
2018-04-02  0:56 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).