netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [DSA] fallback PTP to master port when switch does not support it
@ 2022-04-04 19:28 Matej Zachar
  2022-04-04 22:04 ` Andrew Lunn
  0 siblings, 1 reply; 10+ messages in thread
From: Matej Zachar @ 2022-04-04 19:28 UTC (permalink / raw)
  To: netdev

 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,

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

end of thread, other threads:[~2022-05-26 12:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 19:28 [DSA] fallback PTP to master port when switch does not support it Matej Zachar
2022-04-04 22:04 ` Andrew Lunn
2022-04-05 14:21   ` Matej Zachar
2022-04-05 19:48   ` Jakub Kicinski
2022-04-07  9:44     ` Vladimir Oltean
2022-05-25 15:00       ` Rodolfo Giometti
2022-05-25 15:55         ` Vladimir Oltean
2022-05-26  7:45           ` Rodolfo Giometti
2022-05-26 12:31             ` Vladimir Oltean
2022-05-25 18:18         ` Andrew Lunn

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).