linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: mscc: allow forwarding ioctl operations to attached PHYs
@ 2020-05-26 15:01 Antoine Tenart
  2020-05-26 15:01 ` [PATCH net-next 1/2] net: mscc: use the PHY MII ioctl interface when possible Antoine Tenart
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Antoine Tenart @ 2020-05-26 15:01 UTC (permalink / raw)
  To: davem, andrew, f.fainelli, hkallweit1
  Cc: Antoine Tenart, netdev, linux-kernel, alexandre.belloni,
	thomas.petazzoni, allan.nielsen, vladimir.oltean

Hello,

These two patches allow forwarding ioctl to the PHY MII implementation,
and support is added for offloading timestamping operations to
compatible attached PHYs.

Thanks,
Antoine

Antoine Tenart (2):
  net: mscc: use the PHY MII ioctl interface when possible
  net: mscc: allow offloading timestamping operations to the PHY

 drivers/net/ethernet/mscc/ocelot.c       | 23 ++++++++++++-----------
 drivers/net/ethernet/mscc/ocelot_board.c |  3 ++-
 2 files changed, 14 insertions(+), 12 deletions(-)

-- 
2.26.2


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

* [PATCH net-next 1/2] net: mscc: use the PHY MII ioctl interface when possible
  2020-05-26 15:01 [PATCH net-next 0/2] net: mscc: allow forwarding ioctl operations to attached PHYs Antoine Tenart
@ 2020-05-26 15:01 ` Antoine Tenart
  2020-05-27 14:11   ` Andrew Lunn
  2020-05-26 15:01 ` [PATCH net-next 2/2] net: mscc: allow offloading timestamping operations to the PHY Antoine Tenart
  2020-05-27 21:54 ` [PATCH net-next 0/2] net: mscc: allow forwarding ioctl operations to attached PHYs David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Antoine Tenart @ 2020-05-26 15:01 UTC (permalink / raw)
  To: davem, andrew, f.fainelli, hkallweit1
  Cc: Antoine Tenart, netdev, linux-kernel, alexandre.belloni,
	thomas.petazzoni, allan.nielsen, vladimir.oltean

Allow ioctl to be implemented by the PHY, when a PHY is attached to the
Ocelot switch. In case the ioctl is a request to set or get the hardware
timestamp, use the Ocelot switch implementation for now.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
---
 drivers/net/ethernet/mscc/ocelot.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index e621c4c3ee86..2151c08a57c7 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -1204,18 +1204,16 @@ static int ocelot_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 	struct ocelot *ocelot = priv->port.ocelot;
 	int port = priv->chip_port;
 
-	/* The function is only used for PTP operations for now */
-	if (!ocelot->ptp)
-		return -EOPNOTSUPP;
-
-	switch (cmd) {
-	case SIOCSHWTSTAMP:
-		return ocelot_hwstamp_set(ocelot, port, ifr);
-	case SIOCGHWTSTAMP:
-		return ocelot_hwstamp_get(ocelot, port, ifr);
-	default:
-		return -EOPNOTSUPP;
+	if (ocelot->ptp) {
+		switch (cmd) {
+		case SIOCSHWTSTAMP:
+			return ocelot_hwstamp_set(ocelot, port, ifr);
+		case SIOCGHWTSTAMP:
+			return ocelot_hwstamp_get(ocelot, port, ifr);
+		}
 	}
+
+	return phy_mii_ioctl(dev->phydev, ifr, cmd);
 }
 
 static const struct net_device_ops ocelot_port_netdev_ops = {
-- 
2.26.2


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

* [PATCH net-next 2/2] net: mscc: allow offloading timestamping operations to the PHY
  2020-05-26 15:01 [PATCH net-next 0/2] net: mscc: allow forwarding ioctl operations to attached PHYs Antoine Tenart
  2020-05-26 15:01 ` [PATCH net-next 1/2] net: mscc: use the PHY MII ioctl interface when possible Antoine Tenart
@ 2020-05-26 15:01 ` Antoine Tenart
  2020-05-27 14:11   ` Andrew Lunn
  2020-05-27 21:54 ` [PATCH net-next 0/2] net: mscc: allow forwarding ioctl operations to attached PHYs David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Antoine Tenart @ 2020-05-26 15:01 UTC (permalink / raw)
  To: davem, andrew, f.fainelli, hkallweit1
  Cc: Antoine Tenart, netdev, linux-kernel, alexandre.belloni,
	thomas.petazzoni, allan.nielsen, vladimir.oltean

This patch adds support for offloading timestamping operations not only
to the Ocelot switch (as already supported) but to compatible PHYs.
When both the PHY and the Ocelot switch support timestamping operations,
the PHY implementation is chosen as the timestamp will happen closer to
the medium.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
---
 drivers/net/ethernet/mscc/ocelot.c       | 5 ++++-
 drivers/net/ethernet/mscc/ocelot_board.c | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index 2151c08a57c7..9cfe1fd98c30 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -1204,7 +1204,10 @@ static int ocelot_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 	struct ocelot *ocelot = priv->port.ocelot;
 	int port = priv->chip_port;
 
-	if (ocelot->ptp) {
+	/* If the attached PHY device isn't capable of timestamping operations,
+	 * use our own (when possible).
+	 */
+	if (!phy_has_hwtstamp(dev->phydev) && ocelot->ptp) {
 		switch (cmd) {
 		case SIOCSHWTSTAMP:
 			return ocelot_hwstamp_set(ocelot, port, ifr);
diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
index 67a8d61c926a..4a15d2ff8b70 100644
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -189,7 +189,8 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
 			skb->offload_fwd_mark = 1;
 
 		skb->protocol = eth_type_trans(skb, dev);
-		netif_rx(skb);
+		if (!skb_defer_rx_timestamp(skb))
+			netif_rx(skb);
 		dev->stats.rx_bytes += len;
 		dev->stats.rx_packets++;
 	} while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp));
-- 
2.26.2


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

* Re: [PATCH net-next 1/2] net: mscc: use the PHY MII ioctl interface when possible
  2020-05-26 15:01 ` [PATCH net-next 1/2] net: mscc: use the PHY MII ioctl interface when possible Antoine Tenart
@ 2020-05-27 14:11   ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2020-05-27 14:11 UTC (permalink / raw)
  To: Antoine Tenart
  Cc: davem, f.fainelli, hkallweit1, netdev, linux-kernel,
	alexandre.belloni, thomas.petazzoni, allan.nielsen,
	vladimir.oltean

On Tue, May 26, 2020 at 05:01:48PM +0200, Antoine Tenart wrote:
> Allow ioctl to be implemented by the PHY, when a PHY is attached to the
> Ocelot switch. In case the ioctl is a request to set or get the hardware
> timestamp, use the Ocelot switch implementation for now.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 2/2] net: mscc: allow offloading timestamping operations to the PHY
  2020-05-26 15:01 ` [PATCH net-next 2/2] net: mscc: allow offloading timestamping operations to the PHY Antoine Tenart
@ 2020-05-27 14:11   ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2020-05-27 14:11 UTC (permalink / raw)
  To: Antoine Tenart
  Cc: davem, f.fainelli, hkallweit1, netdev, linux-kernel,
	alexandre.belloni, thomas.petazzoni, allan.nielsen,
	vladimir.oltean

On Tue, May 26, 2020 at 05:01:49PM +0200, Antoine Tenart wrote:
> This patch adds support for offloading timestamping operations not only
> to the Ocelot switch (as already supported) but to compatible PHYs.
> When both the PHY and the Ocelot switch support timestamping operations,
> the PHY implementation is chosen as the timestamp will happen closer to
> the medium.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 0/2] net: mscc: allow forwarding ioctl operations to attached PHYs
  2020-05-26 15:01 [PATCH net-next 0/2] net: mscc: allow forwarding ioctl operations to attached PHYs Antoine Tenart
  2020-05-26 15:01 ` [PATCH net-next 1/2] net: mscc: use the PHY MII ioctl interface when possible Antoine Tenart
  2020-05-26 15:01 ` [PATCH net-next 2/2] net: mscc: allow offloading timestamping operations to the PHY Antoine Tenart
@ 2020-05-27 21:54 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2020-05-27 21:54 UTC (permalink / raw)
  To: antoine.tenart
  Cc: andrew, f.fainelli, hkallweit1, netdev, linux-kernel,
	alexandre.belloni, thomas.petazzoni, allan.nielsen,
	vladimir.oltean

From: Antoine Tenart <antoine.tenart@bootlin.com>
Date: Tue, 26 May 2020 17:01:47 +0200

> These two patches allow forwarding ioctl to the PHY MII implementation,
> and support is added for offloading timestamping operations to
> compatible attached PHYs.

Series applied, thanks.

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

end of thread, other threads:[~2020-05-27 21:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-26 15:01 [PATCH net-next 0/2] net: mscc: allow forwarding ioctl operations to attached PHYs Antoine Tenart
2020-05-26 15:01 ` [PATCH net-next 1/2] net: mscc: use the PHY MII ioctl interface when possible Antoine Tenart
2020-05-27 14:11   ` Andrew Lunn
2020-05-26 15:01 ` [PATCH net-next 2/2] net: mscc: allow offloading timestamping operations to the PHY Antoine Tenart
2020-05-27 14:11   ` Andrew Lunn
2020-05-27 21:54 ` [PATCH net-next 0/2] net: mscc: allow forwarding ioctl operations to attached PHYs 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).