[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 4 Apr 2022 21:28:08 +0200
From: Matej Zachar <zachar.matej@...il.com>
To: netdev@...r.kernel.org
Subject: [DSA] fallback PTP to master port when switch does not support it
Hi,
in my embedded setup I have CPU (master) port with full PTP support connected to the onboard switch (without PTP support) through DSA. As the ioctl and ts_info is passed to the switch driver I made small change to fallback to the master net_device. This however requires that the switch which does not support PTP must not implement .get_ts_info and .port_hwtstamp_get/set from dsa_switch_ops struct.
Do you think this is good approach - I’m happy to work on patch if it makes sense.
I understand that better solution would be to have PTP capable switch, but thats not the situation on this board.
Thank you,
Matej.
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 65b125bb3b8606e35e5a4a5963c04543266c6114..c78b202e86f3b12d2046de718fd5a1ddcec277cd 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -251,16 +251,25 @@ 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;
+ struct net_device *master = dsa_slave_to_master(dev);
/* Pass through to switch driver if it supports timestamping */
switch (cmd) {
case SIOCGHWTSTAMP:
if (ds->ops->port_hwtstamp_get)
return ds->ops->port_hwtstamp_get(ds, port, ifr);
+
+ if (master->netdev_ops->ndo_do_ioctl)
+ return master->netdev_ops->ndo_do_ioctl(master, ifr, cmd);
+
break;
case SIOCSHWTSTAMP:
if (ds->ops->port_hwtstamp_set)
return ds->ops->port_hwtstamp_set(ds, port, ifr);
+
+ if (master->netdev_ops->ndo_do_ioctl)
+ return master->netdev_ops->ndo_do_ioctl(master, ifr, cmd);
+
break;
}
@@ -1292,11 +1303,12 @@ static int dsa_slave_get_ts_info(struct net_device *dev,
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
+ struct net_device *master = dsa_slave_to_master(dev);
- if (!ds->ops->get_ts_info)
- return -EOPNOTSUPP;
+ if (ds->ops->get_ts_info)
+ return ds->ops->get_ts_info(ds, p->dp->index, ts);
- return ds->ops->get_ts_info(ds, p->dp->index, ts);
+ return master->ethtool_ops->get_ts_info(master, ts);
}
static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
Powered by blists - more mailing lists