netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: kuba@kernel.org
Cc: andrew@lunn.ch, olteanv@gmail.com, netdev@vger.kernel.org,
	"Steffen Bätz" <steffen@innosonix.de>,
	"Fabio Estevam" <festevam@denx.de>
Subject: [PATCH net-next] net: dsa: mv88e6xxx: Allow hwstamping on the master port
Date: Thu, 10 Nov 2022 09:43:45 -0300	[thread overview]
Message-ID: <20221110124345.3901389-1-festevam@gmail.com> (raw)

From: Steffen Bätz <steffen@innosonix.de>

Currently, it is not possible to run SIOCGHWTSTAMP or SIOCSHWTSTAMP
ioctls on the dsa master interface if the port_hwtstamp_set/get()
hooks are present, as implemented in net/dsa/master.c:

static int dsa_master_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
...
	case SIOCGHWTSTAMP:
	case SIOCSHWTSTAMP:
		/* Deny PTP operations on master if there is at least one
		 * switch in the tree that is PTP capable.
		 */
		list_for_each_entry(dp, &dst->ports, list)
			if (dp->ds->ops->port_hwtstamp_get ||
			    dp->ds->ops->port_hwtstamp_set)
				return -EBUSY;
		break;
	}

Even if the hwtstamping functionality is disabled in the mv88e6xxx driver
by not setting CONFIG_NET_DSA_MV88E6XXX_PTP, the functions port_hwtstamp_set()
port_hwtstamp_get() are still present due to their stub declarations.

Fix this problem, by removing the stub declarations and guarding these
functions wih CONFIG_NET_DSA_MV88E6XXX_PTP.

Without this change:

 # hwstamp_ctl -i eth0
SIOCGHWTSTAMP failed: Device or resource busy

With the change applied, it is possible to set and get the timestamping
options:

 # hwstamp_ctl -i eth0
current settings:
tx_type 0
rx_filter 0

 # hwstamp_ctl -i eth0 -r 1 -t 1
current settings:
tx_type 0
rx_filter 0
new settings:
tx_type 1
rx_filter 1

Tested on a custom i.MX8MN board with a 88E6320 switch.

Signed-off-by: Steffen Bätz <steffen@innosonix.de>
Signed-off-by: Fabio Estevam <festevam@denx.de>
---
 drivers/net/dsa/mv88e6xxx/chip.c     |  2 ++
 drivers/net/dsa/mv88e6xxx/hwtstamp.h | 12 ------------
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index bf34c942db99..cfa0168cab03 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -6925,8 +6925,10 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
 	.port_mirror_del	= mv88e6xxx_port_mirror_del,
 	.crosschip_bridge_join	= mv88e6xxx_crosschip_bridge_join,
 	.crosschip_bridge_leave	= mv88e6xxx_crosschip_bridge_leave,
+#ifdef CONFIG_NET_DSA_MV88E6XXX_PTP
 	.port_hwtstamp_set	= mv88e6xxx_port_hwtstamp_set,
 	.port_hwtstamp_get	= mv88e6xxx_port_hwtstamp_get,
+#endif
 	.port_txtstamp		= mv88e6xxx_port_txtstamp,
 	.port_rxtstamp		= mv88e6xxx_port_rxtstamp,
 	.get_ts_info		= mv88e6xxx_get_ts_info,
diff --git a/drivers/net/dsa/mv88e6xxx/hwtstamp.h b/drivers/net/dsa/mv88e6xxx/hwtstamp.h
index cf7fb6d660b1..86c6213c2ae8 100644
--- a/drivers/net/dsa/mv88e6xxx/hwtstamp.h
+++ b/drivers/net/dsa/mv88e6xxx/hwtstamp.h
@@ -132,18 +132,6 @@ int mv88e6165_global_disable(struct mv88e6xxx_chip *chip);
 
 #else /* !CONFIG_NET_DSA_MV88E6XXX_PTP */
 
-static inline int mv88e6xxx_port_hwtstamp_set(struct dsa_switch *ds,
-					      int port, struct ifreq *ifr)
-{
-	return -EOPNOTSUPP;
-}
-
-static inline int mv88e6xxx_port_hwtstamp_get(struct dsa_switch *ds,
-					      int port, struct ifreq *ifr)
-{
-	return -EOPNOTSUPP;
-}
-
 static inline bool mv88e6xxx_port_rxtstamp(struct dsa_switch *ds, int port,
 					   struct sk_buff *clone,
 					   unsigned int type)
-- 
2.25.1


             reply	other threads:[~2022-11-10 12:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 12:43 Fabio Estevam [this message]
2022-11-10 12:53 ` [PATCH net-next] net: dsa: mv88e6xxx: Allow hwstamping on the master port Vladimir Oltean
2022-11-11 11:13   ` Fabio Estevam
2022-11-11 21:41     ` Vladimir Oltean
2022-11-12  0:06       ` Fabio Estevam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221110124345.3901389-1-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=festevam@denx.de \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=steffen@innosonix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).