Skip to contentSkip to conversation

Peer to Peer One-Step time stamping

PATCH Superseded Richard Cochran 3 participants 15 messages May 29, 2019 – May 31, 2019

Subsystems (8)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Richard Cochran

author maintainer
#0 lore raw

v4 cover Peer to Peer One-Step time stamping

This series adds support for PTP (IEEE 1588) P2P one-step time stamping along with a driver for a hardware device that supports this.

If the hardware supports p2p one-step, it subtracts the ingress time stamp value from the Pdelay_Request correction field. The user space software stack then simply copies the correction field into the Pdelay_Response, and on transmission the hardware adds the egress time stamp into the correction field.

This new functionality extends CONFIG_NETWORK_PHY_TIMESTAMPING to cover MII snooping devices, but it still depends on phylib, just as that option does. Expanding beyond phylib is not within the scope of the this series.

User space support is available in the current linuxptp master branch.

- Patch 1 adds the new option.
- Patches 2-5 add support for MII time stamping in non-PHY devices.
- Patch 6 adds a driver implementing the new option.

Thanks,
Richard

Changed in v4:
~~~~~~~~~~~~~~

- Correct error paths and PTR_ERR return values in the framework.
- Expanded KernelDoc comments WRT PHY locking.
- Pick up Andrew's review tag.

Changed in v3:
~~~~~~~~~~~~~~

- Simplify the device tree binding and document the time stamping phandle by itself.

Changed in v2:
~~~~~~~~~~~~~~

- Per the v1 review, changed the modeling of MII time stamping devices. They are no longer a kind of mdio device.

Richard Cochran (6):
net: Introduce peer to peer one step PTP time stamping.
net: Introduce a new MII time stamping interface.
net: Add a layer for non-PHY MII time stamping drivers.
dt-bindings: ptp: Introduce MII time stamping devices.
net: mdio: of: Register discovered MII time stampers.
ptp: Add a driver for InES time stamping IP core.

 Documentation/devicetree/bindings/ptp/ptp-ines.txt |  35 +
 .../devicetree/bindings/ptp/timestamper.txt        |  41 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |   1 +
 drivers/net/phy/Makefile                           |   2 +
 drivers/net/phy/dp83640.c                          |  47 +-
 drivers/net/phy/mii_timestamper.c                  | 121 +++
 drivers/net/phy/phy.c                              |   4 +-
 drivers/net/phy/phy_device.c                       |   5 +
 drivers/of/of_mdio.c                               |  30 +-
 drivers/ptp/Kconfig                                |  10 +
 drivers/ptp/Makefile                               |   1 +
 drivers/ptp/ptp_ines.c                             | 859 +++++++++++++++++++++
 include/linux/mii_timestamper.h                    | 120 +++
 include/linux/phy.h                                |  25 +-
 include/uapi/linux/net_tstamp.h                    |   8 +
 net/8021q/vlan_dev.c                               |   4 +-
 net/Kconfig                                        |   7 +-
 net/core/dev_ioctl.c                               |   1 +
 net/core/ethtool.c                                 |   4 +-
 net/core/timestamping.c                            |  20 +-
 20 files changed, 1287 insertions(+), 58 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ptp/ptp-ines.txt
 create mode 100644 Documentation/devicetree/bindings/ptp/timestamper.txt
 create mode 100644 drivers/net/phy/mii_timestamper.c
 create mode 100644 drivers/ptp/ptp_ines.c
 create mode 100644 include/linux/mii_timestamper.h
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH v4 1/6 net: Introduce peer to peer one step PTP time stamping.

The 1588 standard defines one step operation for both Sync and PDelay_Resp messages. Up until now, hardware with P2P one step has been rare, and kernel support was lacking. This patch adds support of the mode in anticipation of new hardware developments.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 1 +
 include/uapi/linux/net_tstamp.h                  | 8 ++++++++
 net/core/dev_ioctl.c                             | 1 +
 3 files changed, 10 insertions(+)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1 -0
index 03ac10b1cd1e..44a378f26bbd 100644
@@ -15380,6 +15380,7 @@ int bnx2x_configure_ptp_filters(struct bnx2x *bp)
 		REG_WR(bp, rule, BNX2X_PTP_TX_ON_RULE_MASK);
 		break;
 	case HWTSTAMP_TX_ONESTEP_SYNC:
+	case HWTSTAMP_TX_ONESTEP_P2P:
 		BNX2X_ERR("One-step timestamping is not supported\n");
 		return -ERANGE;
 	}
include/uapi/linux/net_tstamp.h +8 -0
index e5b39721c6e4..f96e650d0af9 100644
@@ -90,6 +90,14 @@ enum hwtstamp_tx_types {
 	 * queue.
 	 */
 	HWTSTAMP_TX_ONESTEP_SYNC,
+
+	/*
+	 * Same as HWTSTAMP_TX_ONESTEP_SYNC, but also enables time
+	 * stamp insertion directly into PDelay_Resp packets. In this
+	 * case, neither transmitted Sync nor PDelay_Resp packets will
+	 * receive a time stamp via the socket error queue.
+	 */
+	HWTSTAMP_TX_ONESTEP_P2P,
 };
 
 /* possible values for hwtstamp_config->rx_filter */
net/core/dev_ioctl.c +1 -0
index 5163d900bb4f..dbaebbe573f0 100644
@@ -187,6 +187,7 @@ static int net_hwtstamp_validate(struct ifreq *ifr)
 	case HWTSTAMP_TX_OFF:
 	case HWTSTAMP_TX_ON:
 	case HWTSTAMP_TX_ONESTEP_SYNC:
+	case HWTSTAMP_TX_ONESTEP_P2P:
 		tx_type_valid = 1;
 		break;
 	}
Signature · 1 line
2.11.0
author maintainer
#2 lore raw

PATCH v4 2/6 net: Introduce a new MII time stamping interface.

In reply to Richard Cochran

Currently the stack supports time stamping in PHY devices. However, there are newer, non-PHY devices that can snoop an MII bus and provide time stamps. In order to support such devices, this patch introduces a new interface to be used by both PHY and non-PHY devices.

In addition, the one and only user of the old PHY time stamping API is converted to the new interface.

---
 drivers/net/phy/dp83640.c       | 47 +++++++++++++++++++++++-----------
 drivers/net/phy/phy.c           |  4 +--
 drivers/net/phy/phy_device.c    |  2 ++
 include/linux/mii_timestamper.h | 56 +++++++++++++++++++++++++++++++++++++++++
 include/linux/phy.h             | 25 ++----------------
 net/8021q/vlan_dev.c            |  4 +--
 net/core/ethtool.c              |  4 +--
 net/core/timestamping.c         | 20 +++++++--------
 8 files changed, 108 insertions(+), 54 deletions(-)
 create mode 100644 include/linux/mii_timestamper.h
drivers/net/phy/dp83640.c +32 -15
index 6580094161a9..a87a72818e89 100644
@@ -98,6 +98,7 @@ struct dp83640_private {
 	struct list_head list;
 	struct dp83640_clock *clock;
 	struct phy_device *phydev;
+	struct mii_timestamper mii_ts;
 	struct delayed_work ts_work;
 	int hwts_tx_en;
 	int hwts_rx_en;
@@ -201,6 +202,14 @@ static void dp83640_gpio_defaults(struct ptp_pin_desc *pd)
 static LIST_HEAD(phyter_clocks);
 static DEFINE_MUTEX(phyter_clocks_lock);
 
+static int dp83640_hwtstamp(struct mii_timestamper *mii_ts,
+			    struct ifreq *ifr);
+static int dp83640_ts_info(struct mii_timestamper *mii_ts,
+			   struct ethtool_ts_info *info);
+static bool dp83640_rxtstamp(struct mii_timestamper *mii_ts,
+			     struct sk_buff *skb, int type);
+static void dp83640_txtstamp(struct mii_timestamper *mii_ts,
+			     struct sk_buff *skb, int type);
 static void rx_timestamp_work(struct work_struct *work);
 
 /* extended register access functions */
@@ -1133,13 +1142,18 @@ static int dp83640_probe(struct phy_device *phydev)
 		goto no_memory;
 
 	dp83640->phydev = phydev;
-	INIT_DELAYED_WORK(&dp83640->ts_work, rx_timestamp_work);
+	dp83640->mii_ts.rxtstamp = dp83640_rxtstamp;
+	dp83640->mii_ts.txtstamp = dp83640_txtstamp;
+	dp83640->mii_ts.hwtstamp = dp83640_hwtstamp;
+	dp83640->mii_ts.ts_info  = dp83640_ts_info;
 
+	INIT_DELAYED_WORK(&dp83640->ts_work, rx_timestamp_work);
 	INIT_LIST_HEAD(&dp83640->rxts);
 	INIT_LIST_HEAD(&dp83640->rxpool);
 	for (i = 0; i < MAX_RXTS; i++)
 		list_add(&dp83640->rx_pool_data[i].list, &dp83640->rxpool);
 
+	phydev->mii_ts = &dp83640->mii_ts;
 	phydev->priv = dp83640;
 
 	spin_lock_init(&dp83640->rx_lock);
@@ -1180,6 +1194,8 @@ static void dp83640_remove(struct phy_device *phydev)
 	if (phydev->mdio.addr == BROADCAST_ADDR)
 		return;
 
+	phydev->mii_ts = NULL;
+
 	enable_status_frames(phydev, false);
 	cancel_delayed_work_sync(&dp83640->ts_work);
 
@@ -1303,9 +1319,10 @@ static int dp83640_config_intr(struct phy_device *phydev)
 	}
 }
 
-static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
+static int dp83640_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr)
 {
-	struct dp83640_private *dp83640 = phydev->priv;
+	struct dp83640_private *dp83640 =
+		container_of(mii_ts, struct dp83640_private, mii_ts);
 	struct hwtstamp_config cfg;
 	u16 txcfg0, rxcfg0;
 
@@ -1381,8 +1398,8 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
 
 	mutex_lock(&dp83640->clock->extreg_lock);
 
-	ext_write(0, phydev, PAGE5, PTP_TXCFG0, txcfg0);
-	ext_write(0, phydev, PAGE5, PTP_RXCFG0, rxcfg0);
+	ext_write(0, dp83640->phydev, PAGE5, PTP_TXCFG0, txcfg0);
+	ext_write(0, dp83640->phydev, PAGE5, PTP_RXCFG0, rxcfg0);
 
 	mutex_unlock(&dp83640->clock->extreg_lock);
 
@@ -1412,10 +1429,11 @@ static void rx_timestamp_work(struct work_struct *work)
 		schedule_delayed_work(&dp83640->ts_work, SKB_TIMESTAMP_TIMEOUT);
 }
 
-static bool dp83640_rxtstamp(struct phy_device *phydev,
+static bool dp83640_rxtstamp(struct mii_timestamper *mii_ts,
 			     struct sk_buff *skb, int type)
 {
-	struct dp83640_private *dp83640 = phydev->priv;
+	struct dp83640_private *dp83640 =
+		container_of(mii_ts, struct dp83640_private, mii_ts);
 	struct dp83640_skb_info *skb_info = (struct dp83640_skb_info *)skb->cb;
 	struct list_head *this, *next;
 	struct rxts *rxts;
@@ -1461,11 +1479,12 @@ static bool dp83640_rxtstamp(struct phy_device *phydev,
 	return true;
 }
 
-static void dp83640_txtstamp(struct phy_device *phydev,
+static void dp83640_txtstamp(struct mii_timestamper *mii_ts,
 			     struct sk_buff *skb, int type)
 {
 	struct dp83640_skb_info *skb_info = (struct dp83640_skb_info *)skb->cb;
-	struct dp83640_private *dp83640 = phydev->priv;
+	struct dp83640_private *dp83640 =
+		container_of(mii_ts, struct dp83640_private, mii_ts);
 
 	switch (dp83640->hwts_tx_en) {
 
@@ -1488,9 +1507,11 @@ static void dp83640_txtstamp(struct phy_device *phydev,
 	}
 }
 
-static int dp83640_ts_info(struct phy_device *dev, struct ethtool_ts_info *info)
+static int dp83640_ts_info(struct mii_timestamper *mii_ts,
+			   struct ethtool_ts_info *info)
 {
-	struct dp83640_private *dp83640 = dev->priv;
+	struct dp83640_private *dp83640 =
+		container_of(mii_ts, struct dp83640_private, mii_ts);
 
 	info->so_timestamping =
 		SOF_TIMESTAMPING_TX_HARDWARE |
@@ -1521,10 +1542,6 @@ static struct phy_driver dp83640_driver = {
 	.config_init	= dp83640_config_init,
 	.ack_interrupt  = dp83640_ack_interrupt,
 	.config_intr    = dp83640_config_intr,
-	.ts_info	= dp83640_ts_info,
-	.hwtstamp	= dp83640_hwtstamp,
-	.rxtstamp	= dp83640_rxtstamp,
-	.txtstamp	= dp83640_txtstamp,
 };
 
 static int __init dp83640_init(void)
drivers/net/phy/phy.c +2 -2
index e8885429293a..36a96234f08e 100644
@@ -468,8 +468,8 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
 		return 0;
 
 	case SIOCSHWTSTAMP:
-		if (phydev->drv && phydev->drv->hwtstamp)
-			return phydev->drv->hwtstamp(phydev, ifr);
+		if (phydev->mii_ts && phydev->mii_ts->hwtstamp)
+			return phydev->mii_ts->hwtstamp(phydev->mii_ts, ifr);
 		/* fall through */
 
 	default:
drivers/net/phy/phy_device.c +2 -0
index 5d288da9a3b0..5e5ab359f6ed 100644
@@ -915,6 +915,8 @@ static void phy_link_change(struct phy_device *phydev, bool up, bool do_carrier)
 			netif_carrier_off(netdev);
 	}
 	phydev->adjust_link(netdev);
+	if (phydev->mii_ts && phydev->mii_ts->link_state)
+		phydev->mii_ts->link_state(phydev->mii_ts, phydev);
 }
 
 /**
include/linux/mii_timestamper.h new file +56 -0

56 lines not on this page · raw message

include/linux/phy.h +2 -23
index 7180b1d1e5e3..2d0f8c09e3da 100644
@@ -22,6 +22,7 @@
 #include <linux/linkmode.h>
 #include <linux/mdio.h>
 #include <linux/mii.h>
+#include <linux/mii_timestamper.h>
 #include <linux/module.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
@@ -444,6 +445,7 @@ struct phy_device {
 
 	struct phylink *phylink;
 	struct net_device *attached_dev;
+	struct mii_timestamper *mii_ts;
 
 	u8 mdix;
 	u8 mdix_ctrl;
@@ -546,29 +548,6 @@ struct phy_driver {
 	 */
 	int (*match_phy_device)(struct phy_device *phydev);
 
-	/* Handles ethtool queries for hardware time stamping. */
-	int (*ts_info)(struct phy_device *phydev, struct ethtool_ts_info *ti);
-
-	/* Handles SIOCSHWTSTAMP ioctl for hardware time stamping. */
-	int  (*hwtstamp)(struct phy_device *phydev, struct ifreq *ifr);
-
-	/*
-	 * Requests a Rx timestamp for 'skb'. If the skb is accepted,
-	 * the phy driver promises to deliver it using netif_rx() as
-	 * soon as a timestamp becomes available. One of the
-	 * PTP_CLASS_ values is passed in 'type'. The function must
-	 * return true if the skb is accepted for delivery.
-	 */
-	bool (*rxtstamp)(struct phy_device *dev, struct sk_buff *skb, int type);
-
-	/*
-	 * Requests a Tx timestamp for 'skb'. The phy driver promises
-	 * to deliver it using skb_complete_tx_timestamp() as soon as a
-	 * timestamp becomes available. One of the PTP_CLASS_ values
-	 * is passed in 'type'.
-	 */
-	void (*txtstamp)(struct phy_device *dev, struct sk_buff *skb, int type);
-
 	/* Some devices (e.g. qnap TS-119P II) require PHY register changes to
 	 * enable Wake on LAN, so set_wol is provided to be called in the
 	 * ethernet driver's set_wol function. */
net/8021q/vlan_dev.c +2 -2
index c546c4228075..12b832d32c59 100644
@@ -682,8 +682,8 @@ static int vlan_ethtool_get_ts_info(struct net_device *dev,
 	const struct ethtool_ops *ops = vlan->real_dev->ethtool_ops;
 	struct phy_device *phydev = vlan->real_dev->phydev;
 
-	if (phydev && phydev->drv && phydev->drv->ts_info) {
-		 return phydev->drv->ts_info(phydev, info);
+	if (phydev && phydev->mii_ts && phydev->mii_ts->ts_info) {
+		return phydev->mii_ts->ts_info(phydev->mii_ts, info);
 	} else if (ops->get_ts_info) {
 		return ops->get_ts_info(vlan->real_dev, info);
 	} else {
net/core/ethtool.c +2 -2
index 4a593853cbf2..e6cb3c987677 100644
@@ -2168,8 +2168,8 @@ static int ethtool_get_ts_info(struct net_device *dev, void __user *useraddr)
 	memset(&info, 0, sizeof(info));
 	info.cmd = ETHTOOL_GET_TS_INFO;
 
-	if (phydev && phydev->drv && phydev->drv->ts_info) {
-		err = phydev->drv->ts_info(phydev, &info);
+	if (phydev && phydev->mii_ts && phydev->mii_ts->ts_info) {
+		err = phydev->mii_ts->ts_info(phydev->mii_ts, &info);
 	} else if (ops->get_ts_info) {
 		err = ops->get_ts_info(dev, &info);
 	} else {
net/core/timestamping.c +10 -10
index 42689d5c468c..95c45c4dc0f9 100644
@@ -26,7 +26,7 @@
 static unsigned int classify(const struct sk_buff *skb)
 {
 	if (likely(skb->dev && skb->dev->phydev &&
-		   skb->dev->phydev->drv))
+		   skb->dev->phydev->mii_ts))
 		return ptp_classify_raw(skb);
 	else
 		return PTP_CLASS_NONE;
@@ -34,7 +34,7 @@ static unsigned int classify(const struct sk_buff *skb)
 
 void skb_clone_tx_timestamp(struct sk_buff *skb)
 {
-	struct phy_device *phydev;
+	struct mii_timestamper *mii_ts;
 	struct sk_buff *clone;
 	unsigned int type;
 
@@ -45,22 +45,22 @@ void skb_clone_tx_timestamp(struct sk_buff *skb)
 	if (type == PTP_CLASS_NONE)
 		return;
 
-	phydev = skb->dev->phydev;
-	if (likely(phydev->drv->txtstamp)) {
+	mii_ts = skb->dev->phydev->mii_ts;
+	if (likely(mii_ts->txtstamp)) {
 		clone = skb_clone_sk(skb);
 		if (!clone)
 			return;
-		phydev->drv->txtstamp(phydev, clone, type);
+		mii_ts->txtstamp(mii_ts, clone, type);
 	}
 }
 EXPORT_SYMBOL_GPL(skb_clone_tx_timestamp);
 
 bool skb_defer_rx_timestamp(struct sk_buff *skb)
 {
-	struct phy_device *phydev;
+	struct mii_timestamper *mii_ts;
 	unsigned int type;
 
-	if (!skb->dev || !skb->dev->phydev || !skb->dev->phydev->drv)
+	if (!skb->dev || !skb->dev->phydev || !skb->dev->phydev->mii_ts)
 		return false;
 
 	if (skb_headroom(skb) < ETH_HLEN)
@@ -75,9 +75,9 @@ bool skb_defer_rx_timestamp(struct sk_buff *skb)
 	if (type == PTP_CLASS_NONE)
 		return false;
 
-	phydev = skb->dev->phydev;
-	if (likely(phydev->drv->rxtstamp))
-		return phydev->drv->rxtstamp(phydev, skb, type);
+	mii_ts = skb->dev->phydev->mii_ts;
+	if (likely(mii_ts->rxtstamp))
+		return mii_ts->rxtstamp(mii_ts, skb, type);
 
 	return false;
 }
Signature · 1 line
2.11.0
#3 lore raw

Re: [PATCH V4 net-next 2/6] net: Introduce a new MII time stamping interface.

I love your patch! Yet something to improve:

Hi Richard,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url: https://github.com/0day-ci/linux/commits/Richard-Cochran/Peer-to-Peer-One-Step-time-stamping/20190531-213601
config: s390-debug_defconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=s390

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

drivers/net/macvlan.c: In function 'macvlan_ethtool_get_ts_info':

>> drivers/net/macvlan.c:1059:42: error: 'struct phy_driver' has no member named 'ts_info'
     if (phydev && phydev->drv && phydev->drv->ts_info) {
                                             ^~
   drivers/net/macvlan.c:1060:22: error: 'struct phy_driver' has no member named 'ts_info'
       return phydev->drv->ts_info(phydev, info);
                         ^~

vim +1059 drivers/net/macvlan.c

9edb8bb6 Stephen Hemminger 2008-10-29  1051  
254c0a2b Hangbin Liu       2019-03-20  1052  static int macvlan_ethtool_get_ts_info(struct net_device *dev,
254c0a2b Hangbin Liu       2019-03-20  1053  				       struct ethtool_ts_info *info)
254c0a2b Hangbin Liu       2019-03-20  1054  {
254c0a2b Hangbin Liu       2019-03-20  1055  	struct net_device *real_dev = macvlan_dev_real_dev(dev);
254c0a2b Hangbin Liu       2019-03-20  1056  	const struct ethtool_ops *ops = real_dev->ethtool_ops;
254c0a2b Hangbin Liu       2019-03-20  1057  	struct phy_device *phydev = real_dev->phydev;
254c0a2b Hangbin Liu       2019-03-20  1058  
254c0a2b Hangbin Liu       2019-03-20 @1059  	if (phydev && phydev->drv && phydev->drv->ts_info) {
254c0a2b Hangbin Liu       2019-03-20  1060  		 return phydev->drv->ts_info(phydev, info);
254c0a2b Hangbin Liu       2019-03-20  1061  	} else if (ops->get_ts_info) {
254c0a2b Hangbin Liu       2019-03-20  1062  		return ops->get_ts_info(real_dev, info);
254c0a2b Hangbin Liu       2019-03-20  1063  	} else {
254c0a2b Hangbin Liu       2019-03-20  1064  		info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
254c0a2b Hangbin Liu       2019-03-20  1065  			SOF_TIMESTAMPING_SOFTWARE;
254c0a2b Hangbin Liu       2019-03-20  1066  		info->phc_index = -1;
254c0a2b Hangbin Liu       2019-03-20  1067  	}
254c0a2b Hangbin Liu       2019-03-20  1068  
254c0a2b Hangbin Liu       2019-03-20  1069  	return 0;
254c0a2b Hangbin Liu       2019-03-20  1070  }
254c0a2b Hangbin Liu       2019-03-20  1071  

:::::: The code at line 1059 was first introduced by commit
:::::: 254c0a2bfedb9e1baf38bd82ca86494d4bc1e0cb macvlan: pass get_ts_info and SIOC[SG]HWTSTAMP ioctl to real device

:::::: TO: Hangbin Liu <[email protected]>
:::::: CC: David S. Miller <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#4 lore raw

Re: [PATCH V4 net-next 2/6] net: Introduce a new MII time stamping interface.

In reply to Richard Cochran
I love your patch! Yet something to improve:

Hi Richard,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url: https://github.com/0day-ci/linux/commits/Richard-Cochran/Peer-to-Peer-One-Step-time-stamping/20190531-213601
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=arm

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

drivers/net/ethernet/ti/netcp_ethss.c: In function 'gbe_txtstamp_mark_pkt':

>> drivers/net/ethernet/ti/netcp_ethss.c:2535:50: error: 'struct phy_driver' has no member named 'txtstamp'
    #define HAS_PHY_TXTSTAMP(p) ((p)->drv && (p)->drv->txtstamp)
                                                     ^
   drivers/net/ethernet/ti/netcp_ethss.c:2568:16: note: in expansion of macro 'HAS_PHY_TXTSTAMP'
     if (phydev && HAS_PHY_TXTSTAMP(phydev)) {
                   ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/ti/netcp_ethss.c: In function 'gbe_rxtstamp':
>> drivers/net/ethernet/ti/netcp_ethss.c:2536:50: error: 'struct phy_driver' has no member named 'rxtstamp'
    #define HAS_PHY_RXTSTAMP(p) ((p)->drv && (p)->drv->rxtstamp)
                                                     ^
   drivers/net/ethernet/ti/netcp_ethss.c:2590:16: note: in expansion of macro 'HAS_PHY_RXTSTAMP'
     if (phydev && HAS_PHY_RXTSTAMP(phydev)) {
                   ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/ti/netcp_ethss.c: In function 'gbe_ioctl':
>> drivers/net/ethernet/ti/netcp_ethss.c:2832:23: error: 'struct phy_driver' has no member named 'hwtstamp'
     if (!phy || !phy->drv->hwtstamp) {
                          ^~

vim +2535 drivers/net/ethernet/ti/netcp_ethss.c

6f8d3f33 Wingman Kwok 2015-01-15 2533

6246168b WingMan Kwok 2016-12-08  2534  #if IS_ENABLED(CONFIG_TI_CPTS)
6246168b WingMan Kwok 2016-12-08 @2535  #define HAS_PHY_TXTSTAMP(p) ((p)->drv && (p)->drv->txtstamp)
6246168b WingMan Kwok 2016-12-08 @2536  #define HAS_PHY_RXTSTAMP(p) ((p)->drv && (p)->drv->rxtstamp)

6246168b WingMan Kwok 2016-12-08 2537

:::::: The code at line 2535 was first introduced by commit
:::::: 6246168b4a38357b135d07370464f27d4f3a68ce net: ethernet: ti: netcp: add support of cpts

:::::: TO: WingMan Kwok <[email protected]>
:::::: CC: David S. Miller <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#5 lore raw

Re: [PATCH V4 net-next 2/6] net: Introduce a new MII time stamping interface.

In reply to Richard Cochran
I love your patch! Perhaps something to improve:

Hi Richard,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url: https://github.com/0day-ci/linux/commits/Richard-Cochran/Peer-to-Peer-One-Step-time-stamping/20190531-213601
reproduce:

        # apt-get install sparse
        # sparse version: v0.6.1-rc1-7-g2b96cd8-dirty
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag

sparse warnings: (new ones prefixed by >>)

drivers/net/macvlan.c:1059:49: sparse: sparse: no member 'ts_info' in struct phy_driver drivers/net/macvlan.c:1060:36: sparse: sparse: no member 'ts_info' in struct phy_driver

>> drivers/net/macvlan.c:1059:49: sparse: sparse: unknown expression (8 46)

vim +1059 drivers/net/macvlan.c

9edb8bb6 Stephen Hemminger 2008-10-29  1051  
254c0a2b Hangbin Liu       2019-03-20  1052  static int macvlan_ethtool_get_ts_info(struct net_device *dev,
254c0a2b Hangbin Liu       2019-03-20  1053  				       struct ethtool_ts_info *info)
254c0a2b Hangbin Liu       2019-03-20  1054  {
254c0a2b Hangbin Liu       2019-03-20  1055  	struct net_device *real_dev = macvlan_dev_real_dev(dev);
254c0a2b Hangbin Liu       2019-03-20  1056  	const struct ethtool_ops *ops = real_dev->ethtool_ops;
254c0a2b Hangbin Liu       2019-03-20  1057  	struct phy_device *phydev = real_dev->phydev;
254c0a2b Hangbin Liu       2019-03-20  1058  
254c0a2b Hangbin Liu       2019-03-20 @1059  	if (phydev && phydev->drv && phydev->drv->ts_info) {
254c0a2b Hangbin Liu       2019-03-20  1060  		 return phydev->drv->ts_info(phydev, info);
254c0a2b Hangbin Liu       2019-03-20  1061  	} else if (ops->get_ts_info) {
254c0a2b Hangbin Liu       2019-03-20  1062  		return ops->get_ts_info(real_dev, info);
254c0a2b Hangbin Liu       2019-03-20  1063  	} else {
254c0a2b Hangbin Liu       2019-03-20  1064  		info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
254c0a2b Hangbin Liu       2019-03-20  1065  			SOF_TIMESTAMPING_SOFTWARE;
254c0a2b Hangbin Liu       2019-03-20  1066  		info->phc_index = -1;
254c0a2b Hangbin Liu       2019-03-20  1067  	}
254c0a2b Hangbin Liu       2019-03-20  1068  
254c0a2b Hangbin Liu       2019-03-20  1069  	return 0;
254c0a2b Hangbin Liu       2019-03-20  1070  }
254c0a2b Hangbin Liu       2019-03-20  1071  

:::::: The code at line 1059 was first introduced by commit
:::::: 254c0a2bfedb9e1baf38bd82ca86494d4bc1e0cb macvlan: pass get_ts_info and SIOC[SG]HWTSTAMP ioctl to real device

:::::: TO: Hangbin Liu <[email protected]>
:::::: CC: David S. Miller <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author maintainer
#6 lore raw

PATCH v4 3/6 net: Add a layer for non-PHY MII time stamping drivers.

In reply to Richard Cochran

While PHY time stamping drivers can simply attach their interface directly to the PHY instance, stand alone drivers require support in order to manage their services. Non-PHY MII time stamping drivers have a control interface over another bus like I2C, SPI, UART, or via a memory mapped peripheral. The controller device will be associated with one or more time stamping channels, each of which sits snoops in on a MII bus.

This patch provides a glue layer that will enable time stamping channels to find their controlling device.

---
 drivers/net/phy/Makefile          |   2 +
 drivers/net/phy/mii_timestamper.c | 121 ++++++++++++++++++++++++++++++++++++++
 include/linux/mii_timestamper.h   |  64 ++++++++++++++++++++
 net/Kconfig                       |   7 ++-
 4 files changed, 191 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/phy/mii_timestamper.c
drivers/net/phy/Makefile +2 -0
index bac339e09042..4f7db9e23456 100644
@@ -42,6 +42,8 @@ obj-$(CONFIG_MDIO_SUN4I)	+= mdio-sun4i.o
 obj-$(CONFIG_MDIO_THUNDER)	+= mdio-thunder.o
 obj-$(CONFIG_MDIO_XGENE)	+= mdio-xgene.o
 
+obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += mii_timestamper.o
+
 obj-$(CONFIG_SFP)		+= sfp.o
 sfp-obj-$(CONFIG_SFP)		+= sfp-bus.o
 obj-y				+= $(sfp-obj-y) $(sfp-obj-m)
drivers/net/phy/mii_timestamper.c new file +121 -0

121 lines not on this page · raw message

include/linux/mii_timestamper.h +64 -0

86 lines not on this page · raw message

net/Kconfig +4 -3
index d122f53c6fa2..203e6f5dafa7 100644
@@ -110,9 +110,10 @@ config NETWORK_PHY_TIMESTAMPING
 	bool "Timestamping in PHY devices"
 	select NET_PTP_CLASSIFY
 	help
-	  This allows timestamping of network packets by PHYs with
-	  hardware timestamping capabilities. This option adds some
-	  overhead in the transmit and receive paths.
+	  This allows timestamping of network packets by PHYs (or
+	  other MII bus snooping devices) with hardware timestamping
+	  capabilities. This option adds some overhead in the transmit
+	  and receive paths.
 
 	  If you are unsure how to answer this question, answer N.
 
Signature · 1 line
2.11.0
author maintainer
#7 lore raw

PATCH v4 4/6 dt-bindings: ptp: Introduce MII time stamping devices.

In reply to Richard Cochran

This patch add a new binding that allows non-PHY MII time stamping devices to find their buses. The new documentation covers both the generic binding and one upcoming user.

---
 Documentation/devicetree/bindings/ptp/ptp-ines.txt | 35 ++++++++++++++++++
 .../devicetree/bindings/ptp/timestamper.txt        | 41 ++++++++++++++++++++++
 2 files changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ptp/ptp-ines.txt
 create mode 100644 Documentation/devicetree/bindings/ptp/timestamper.txt
Documentation/devicetree/bindings/ptp/ptp-ines.txt new file +35 -0
new file mode 100644
index 000000000000..4dee9eb89455
@@ -0,0 +1,35 @@
+ZHAW InES PTP time stamping IP core
+
+The IP core needs two different kinds of nodes.  The control node
+lives somewhere in the memory map and specifies the address of the
+control registers.  There can be up to three port handles placed as
+attributes of PHY nodes.  These associate a particular MII bus with a
+port index within the IP core.
+
+Required properties of the control node:
+
+- compatible:		"ines,ptp-ctrl"
+- reg:			physical address and size of the register bank
+
+Required format of the port handle within the PHY node:
+
+- timestamper:		provides control node reference and
+			the port channel within the IP core
+
+Example:
+
+	tstamper: timestamper@60000000 {
+		compatible = "ines,ptp-ctrl";
+		reg = <0x60000000 0x80>;
+	};
+
+	ethernet@80000000 {
+		...
+		mdio {
+			...
+			phy@3 {
+				...
+				timestamper = <&tstamper 0>;
+			};
+		};
+	};
Documentation/devicetree/bindings/ptp/timestamper.txt new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.11.0
author maintainer
#8 lore raw

PATCH v4 5/6 net: mdio: of: Register discovered MII time stampers.

In reply to Richard Cochran

When parsing a PHY node, register its time stamper, if any, and attach the instance to the PHY device.

---
 drivers/net/phy/phy_device.c |  3 +++
 drivers/of/of_mdio.c         | 30 +++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)
drivers/net/phy/phy_device.c +3 -0
index 5e5ab359f6ed..4d0bb9d25018 100644
@@ -877,6 +877,9 @@ EXPORT_SYMBOL(phy_device_register);
  */
 void phy_device_remove(struct phy_device *phydev)
 {
+	if (phydev->mii_ts)
+		unregister_mii_timestamper(phydev->mii_ts);
+
 	device_del(&phydev->mdio.dev);
 
 	/* Assert the reset signal */
drivers/of/of_mdio.c +29 -1
index fcf25e32b1ed..98f2516ec3ba 100644
@@ -43,14 +43,37 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id)
 	return -EINVAL;
 }
 
+struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
+{
+	struct of_phandle_args arg;
+	int err;
+
+	err = of_parse_phandle_with_fixed_args(node, "timestamper", 1, 0, &arg);
+
+	if (err == -ENOENT)
+		return NULL;
+	else if (err)
+		return ERR_PTR(err);
+
+	if (arg.args_count != 1)
+		return ERR_PTR(-EINVAL);
+
+	return register_mii_timestamper(arg.np, arg.args[0]);
+}
+
 static int of_mdiobus_register_phy(struct mii_bus *mdio,
 				    struct device_node *child, u32 addr)
 {
+	struct mii_timestamper *mii_ts;
 	struct phy_device *phy;
 	bool is_c45;
 	int rc;
 	u32 phy_id;
 
+	mii_ts = of_find_mii_timestamper(child);
+	if (IS_ERR(mii_ts))
+		return PTR_ERR(mii_ts);
+
 	is_c45 = of_device_is_compatible(child,
 					 "ethernet-phy-ieee802.3-c45");
 
@@ -58,11 +81,14 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
 		phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
 	else
 		phy = get_phy_device(mdio, addr, is_c45);
-	if (IS_ERR(phy))
+	if (IS_ERR(phy)) {
+		unregister_mii_timestamper(mii_ts);
 		return PTR_ERR(phy);
+	}
 
 	rc = of_irq_get(child, 0);
 	if (rc == -EPROBE_DEFER) {
+		unregister_mii_timestamper(mii_ts);
 		phy_device_free(phy);
 		return rc;
 	}
@@ -91,10 +117,12 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
 	 * register it */
 	rc = phy_device_register(phy);
 	if (rc) {
+		unregister_mii_timestamper(mii_ts);
 		phy_device_free(phy);
 		of_node_put(child);
 		return rc;
 	}
+	phy->mii_ts = mii_ts;
 
 	dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n",
 		child, addr);
Signature · 1 line
2.11.0
author maintainer
#9 lore raw

PATCH v4 6/6 ptp: Add a driver for InES time stamping IP core.

In reply to Richard Cochran

The InES at the ZHAW offers a PTP time stamping IP core. The FPGA logic recognizes and time stamps PTP frames on the MII bus. This patch adds a driver for the core along with a device tree binding to allow hooking the driver to MII buses.

---
 drivers/ptp/Kconfig    |  10 +
 drivers/ptp/Makefile   |   1 +
 drivers/ptp/ptp_ines.c | 859 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 870 insertions(+)
 create mode 100644 drivers/ptp/ptp_ines.c
drivers/ptp/Kconfig +10 -0
index 9b8fee5178e8..9824ea0467c8 100644
@@ -89,6 +89,16 @@ config DP83640_PHY
 	  In order for this to work, your MAC driver must also
 	  implement the skb_tx_timestamp() function.
 
+config PTP_1588_CLOCK_INES
+	tristate "ZHAW InES PTP time stamping IP core"
+	depends on NETWORK_PHY_TIMESTAMPING
+	depends on PHYLIB
+	depends on PTP_1588_CLOCK
+	help
+	  This driver adds support for using the ZHAW InES 1588 IP
+	  core.  This clock is only useful if the MII bus of your MAC
+	  is wired up to the core.
+
 config PTP_1588_CLOCK_PCH
 	tristate "Intel PCH EG20T as PTP clock"
 	depends on X86_32 || COMPILE_TEST
drivers/ptp/Makefile +1 -0
index 677d1d178a3e..3cdd33f93d35 100644
@@ -6,6 +6,7 @@
 ptp-y					:= ptp_clock.o ptp_chardev.o ptp_sysfs.o
 obj-$(CONFIG_PTP_1588_CLOCK)		+= ptp.o
 obj-$(CONFIG_PTP_1588_CLOCK_DTE)	+= ptp_dte.o
+obj-$(CONFIG_PTP_1588_CLOCK_INES)	+= ptp_ines.o
 obj-$(CONFIG_PTP_1588_CLOCK_IXP46X)	+= ptp_ixp46x.o
 obj-$(CONFIG_PTP_1588_CLOCK_PCH)	+= ptp_pch.o
 obj-$(CONFIG_PTP_1588_CLOCK_KVM)	+= ptp_kvm.o
drivers/ptp/ptp_ines.c new file +859 -0

859 lines not on this page · raw message

Signature · 1 line
2.11.0
#10 lore raw

Re: [PATCH V4 net-next 6/6] ptp: Add a driver for InES time stamping IP core.

I love your patch! Perhaps something to improve:

Hi Richard,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url: https://github.com/0day-ci/linux/commits/Richard-Cochran/Peer-to-Peer-One-Step-time-stamping/20190531-213601
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=m68k

If you fix the issue, kindly add following tag

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

drivers//ptp/ptp_ines.c: In function 'ines_txtstamp':

>> drivers//ptp/ptp_ines.c:674:3: warning: 'old_skb' may be used uninitialized in this function [-Wmaybe-uninitialized]
      kfree_skb(old_skb);
      ^~~~~~~~~~~~~~~~~~

vim +/old_skb +674 drivers//ptp/ptp_ines.c

651
652 static void ines_txtstamp(struct mii_timestamper *mii_ts,
653 struct sk_buff *skb, int type)
654 {
655 struct ines_port *port = container_of(mii_ts, struct ines_port, mii_ts);
656 struct sk_buff *old_skb;
657 unsigned long flags;
658
659 if (!port->txts_enabled || ines_txts_onestep(port, skb, type)) {
660 kfree_skb(skb);
661 return;
662 }
663
664 spin_lock_irqsave(&port->lock, flags);
665
666 if (port->tx_skb)
667 old_skb = port->tx_skb;
668
669 port->tx_skb = skb;
670
671 spin_unlock_irqrestore(&port->lock, flags);
672
673 if (old_skb)

 > 674			kfree_skb(old_skb);

675
676 schedule_delayed_work(&port->ts_work, 1);
677 }
678

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

maintainer
#11 lore raw
In reply to Richard Cochran

From: Richard Cochran <[email protected]>
Date: Tue, 28 May 2019 22:58:01 -0700

Quoted 14 lines

This series adds support for PTP (IEEE 1588) P2P one-step time stamping along with a driver for a hardware device that supports this.

If the hardware supports p2p one-step, it subtracts the ingress time stamp value from the Pdelay_Request correction field. The user space software stack then simply copies the correction field into the Pdelay_Response, and on transmission the hardware adds the egress time stamp into the correction field.

This new functionality extends CONFIG_NETWORK_PHY_TIMESTAMPING to cover MII snooping devices, but it still depends on phylib, just as that option does. Expanding beyond phylib is not within the scope of the this series.

Quoted 5 lines

User space support is available in the current linuxptp master branch.

- Patch 1 adds the new option.
- Patches 2-5 add support for MII time stamping in non-PHY devices.
- Patch 6 adds a driver implementing the new option.

Series applied, thanks Richard.

maintainer
#12 lore raw

From: David Miller <[email protected]>
Date: Thu, 30 May 2019 11:55:07 -0700 (PDT)

Quoted 1 line

Series applied, thanks Richard.

I had to revert, this doesn't build.

drivers/ptp/ptp_ines.c: In function ‘ines_txtstamp’:
drivers/ptp/ptp_ines.c:674:3: warning: ‘old_skb’ may be used uninitialized in this function [-Wmaybe-uninitialized]
kfree_skb(old_skb);
^~~~~~~~~~~~~~~~~~
drivers/net/macvlan.c: In function ‘macvlan_ethtool_get_ts_info’:
drivers/net/macvlan.c:1059:42: error: ‘struct phy_driver’ has no member named ‘ts_info’

  if (phydev && phydev->drv && phydev->drv->ts_info) {
                                          ^~
drivers/net/macvlan.c:1060:22: error: ‘struct phy_driver’ has no member named ‘ts_info’
    return phydev->drv->ts_info(phydev, info);
                      ^~
author maintainer
#13 lore raw
Quoted 1 line · David Miller

I had to revert, this doesn't build.

Sorry I missed macvlan, and thanks for the 'uninitialized' warning. It was a real latent bug. I wonder why my linaro 7.4 gcc didn't flag that...

Anyhow, I rebased v5 of my series to latest net-next, and I'm getting a lot of these:

In file included from net/ipv6/af_inet6.c:45:0:
./include/linux/netfilter_ipv6.h: In function ‘nf_ipv6_br_defrag’:
./include/linux/netfilter_ipv6.h:110:9: error: implicit declaration of function ‘nf_ct_frag6_gather’; did you mean ‘nf_ct_attach’? [-Werror=implicit-function-declaration]

  return nf_ct_frag6_gather(net, skb, user);
         ^~~~~~~~~~~~~~~~~~
         nf_ct_attach

Thanks,
Richard

maintainer
#14 lore raw

From: Richard Cochran <[email protected]>
Date: Thu, 30 May 2019 22:51:32 -0700

Quoted 9 lines

Anyhow, I rebased v5 of my series to latest net-next, and I'm getting a lot of these:

In file included from net/ipv6/af_inet6.c:45:0:
./include/linux/netfilter_ipv6.h: In function ‘nf_ipv6_br_defrag’:
./include/linux/netfilter_ipv6.h:110:9: error: implicit declaration of function ‘nf_ct_frag6_gather’; did you mean ‘nf_ct_attach’? [-Werror=implicit-function-declaration]

  return nf_ct_frag6_gather(net, skb, user);
         ^~~~~~~~~~~~~~~~~~
         nf_ct_attach

This should be fixed now.