Skip to content

Commit aea3dee

Browse files
committed
Merge branch 'Peer-to-Peer-One-Step-time-stamping'
Richard Cochran says: ==================== 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 phy_device methods for existing time stamping fields. - Patches 2-5 convert the stack and drivers to the new methods. - Patch 6 moves code around the dp83640 driver. - Patches 7-10 add support for MII time stamping in non-PHY devices. - Patch 11 adds the new P2P 1-step option. - Patch 12 adds a driver implementing the new option. Thanks, Richard Changed in v9: ~~~~~~~~~~~~~~ - Fix two more drivers' switch/case blocks WRT the new HWTSTAMP ioctl. - Picked up two more review tags from Andrew. Changed in v8: ~~~~~~~~~~~~~~ - Avoided adding forward functional declarations in the dp83640 driver. - Picked up Florian's new review tags and another one from Andrew. Changed in v7: ~~~~~~~~~~~~~~ - Converted pr_debug|err to dev_ variants in new driver. - Fixed device tree documentation per Rob's v6 review. - Picked up Andrew's and Rob's review tags. - Silenced sparse warnings in new driver. Changed in v6: ~~~~~~~~~~~~~~ - Added methods for accessing the phy_device time stamping fields. - Adjust the device tree documentation per Rob's v5 review. - Fixed the build failures due to missing exports. Changed in v5: ~~~~~~~~~~~~~~ - Fixed build failure in macvlan. - Fixed latent bug with its gcc warning in the driver. 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. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 9f6cff9 + bad1eaa commit aea3dee

25 files changed

Lines changed: 1437 additions & 154 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ZHAW InES PTP time stamping IP core
2+
3+
The IP core needs two different kinds of nodes. The control node
4+
lives somewhere in the memory map and specifies the address of the
5+
control registers. There can be up to three port handles placed as
6+
attributes of PHY nodes. These associate a particular MII bus with a
7+
port index within the IP core.
8+
9+
Required properties of the control node:
10+
11+
- compatible: "ines,ptp-ctrl"
12+
- reg: physical address and size of the register bank
13+
14+
Required format of the port handle within the PHY node:
15+
16+
- timestamper: provides control node reference and
17+
the port channel within the IP core
18+
19+
Example:
20+
21+
tstamper: timestamper@60000000 {
22+
compatible = "ines,ptp-ctrl";
23+
reg = <0x60000000 0x80>;
24+
};
25+
26+
ethernet@80000000 {
27+
...
28+
mdio {
29+
...
30+
ethernet-phy@3 {
31+
...
32+
timestamper = <&tstamper 0>;
33+
};
34+
};
35+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Time stamps from MII bus snooping devices
2+
3+
This binding supports non-PHY devices that snoop the MII bus and
4+
provide time stamps. In contrast to PHY time stamping drivers (which
5+
can simply attach their interface directly to the PHY instance), stand
6+
alone MII time stamping drivers use this binding to specify the
7+
connection between the snooping device and a given network interface.
8+
9+
Non-PHY MII time stamping drivers typically talk to the control
10+
interface over another bus like I2C, SPI, UART, or via a memory mapped
11+
peripheral. This controller device is associated with one or more
12+
time stamping channels, each of which snoops on a MII bus.
13+
14+
The "timestamper" property lives in a phy node and links a time
15+
stamping channel from the controller device to that phy's MII bus.
16+
17+
Example:
18+
19+
tstamper: timestamper@10000000 {
20+
compatible = "ines,ptp-ctrl";
21+
reg = <0x10000000 0x80>;
22+
};
23+
24+
ethernet@20000000 {
25+
mdio {
26+
ethernet-phy@1 {
27+
timestamper = <&tstamper 0>;
28+
};
29+
};
30+
};
31+
32+
ethernet@30000000 {
33+
mdio {
34+
ethernet-phy@2 {
35+
timestamper = <&tstamper 1>;
36+
};
37+
};
38+
};
39+
40+
In this example, time stamps from the MII bus attached to phy@1 will
41+
appear on time stamp channel 0 (zero), and those from phy@2 appear on
42+
channel 1.

‎drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15410,6 +15410,7 @@ int bnx2x_configure_ptp_filters(struct bnx2x *bp)
1541015410
REG_WR(bp, rule, BNX2X_PTP_TX_ON_RULE_MASK);
1541115411
break;
1541215412
case HWTSTAMP_TX_ONESTEP_SYNC:
15413+
case HWTSTAMP_TX_ONESTEP_P2P:
1541315414
BNX2X_ERR("One-step timestamping is not supported\n");
1541415415
return -ERANGE;
1541515416
}

‎drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ static int mlxsw_sp_ptp_get_message_types(const struct hwtstamp_config *config,
920920
egr_types = 0xff;
921921
break;
922922
case HWTSTAMP_TX_ONESTEP_SYNC:
923+
case HWTSTAMP_TX_ONESTEP_P2P:
923924
return -ERANGE;
924925
}
925926

‎drivers/net/ethernet/microchip/lan743x_ptp.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,9 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
12651265

12661266
lan743x_ptp_set_sync_ts_insert(adapter, true);
12671267
break;
1268+
case HWTSTAMP_TX_ONESTEP_P2P:
1269+
ret = -ERANGE;
1270+
break;
12681271
default:
12691272
netif_warn(adapter, drv, adapter->netdev,
12701273
" tx_type = %d, UNKNOWN\n", config.tx_type);

‎drivers/net/ethernet/qlogic/qede/qede_ptp.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ static int qede_ptp_cfg_filters(struct qede_dev *edev)
247247
break;
248248

249249
case HWTSTAMP_TX_ONESTEP_SYNC:
250+
case HWTSTAMP_TX_ONESTEP_P2P:
250251
DP_ERR(edev, "One-step timestamping is not supported\n");
251252
return -ERANGE;
252253
}

‎drivers/net/ethernet/ti/netcp_ethss.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,8 +2533,6 @@ static int gbe_del_vid(void *intf_priv, int vid)
25332533
}
25342534

25352535
#if IS_ENABLED(CONFIG_TI_CPTS)
2536-
#define HAS_PHY_TXTSTAMP(p) ((p)->drv && (p)->drv->txtstamp)
2537-
#define HAS_PHY_RXTSTAMP(p) ((p)->drv && (p)->drv->rxtstamp)
25382536

25392537
static void gbe_txtstamp(void *context, struct sk_buff *skb)
25402538
{
@@ -2566,7 +2564,7 @@ static int gbe_txtstamp_mark_pkt(struct gbe_intf *gbe_intf,
25662564
* We mark it here because skb_tx_timestamp() is called
25672565
* after all the txhooks are called.
25682566
*/
2569-
if (phydev && HAS_PHY_TXTSTAMP(phydev)) {
2567+
if (phy_has_txtstamp(phydev)) {
25702568
skb_shinfo(p_info->skb)->tx_flags |= SKBTX_IN_PROGRESS;
25712569
return 0;
25722570
}
@@ -2588,7 +2586,7 @@ static int gbe_rxtstamp(struct gbe_intf *gbe_intf, struct netcp_packet *p_info)
25882586
if (p_info->rxtstamp_complete)
25892587
return 0;
25902588

2591-
if (phydev && HAS_PHY_RXTSTAMP(phydev)) {
2589+
if (phy_has_rxtstamp(phydev)) {
25922590
p_info->rxtstamp_complete = true;
25932591
return 0;
25942592
}
@@ -2830,7 +2828,7 @@ static int gbe_ioctl(void *intf_priv, struct ifreq *req, int cmd)
28302828
struct gbe_intf *gbe_intf = intf_priv;
28312829
struct phy_device *phy = gbe_intf->slave->phy;
28322830

2833-
if (!phy || !phy->drv->hwtstamp) {
2831+
if (!phy_has_hwtstamp(phy)) {
28342832
switch (cmd) {
28352833
case SIOCGHWTSTAMP:
28362834
return gbe_hwtstamp_get(gbe_intf, req);

‎drivers/net/macvlan.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,8 @@ static int macvlan_ethtool_get_ts_info(struct net_device *dev,
10361036
const struct ethtool_ops *ops = real_dev->ethtool_ops;
10371037
struct phy_device *phydev = real_dev->phydev;
10381038

1039-
if (phydev && phydev->drv && phydev->drv->ts_info) {
1040-
return phydev->drv->ts_info(phydev, info);
1039+
if (phy_has_tsinfo(phydev)) {
1040+
return phy_ts_info(phydev, info);
10411041
} else if (ops->get_ts_info) {
10421042
return ops->get_ts_info(real_dev, info);
10431043
} else {

‎drivers/net/phy/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ obj-$(CONFIG_MDIO_SUN4I) += mdio-sun4i.o
4343
obj-$(CONFIG_MDIO_THUNDER) += mdio-thunder.o
4444
obj-$(CONFIG_MDIO_XGENE) += mdio-xgene.o
4545

46+
obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += mii_timestamper.o
47+
4648
obj-$(CONFIG_SFP) += sfp.o
4749
sfp-obj-$(CONFIG_SFP) += sfp-bus.o
4850
obj-y += $(sfp-obj-y) $(sfp-obj-m)

0 commit comments

Comments
 (0)