ENETC: support hardware timestamping
Subsystems (6)
Y.b. Lu
maintainerv2 cover ENETC: support hardware timestamping
This patch-set is to support hardware timestamping for ENETC and also to add ENETC 1588 timer device tree node for ls1028a.
Because the ENETC RX BD ring dynamic allocation has not been supported and it is too expensive to use extended RX BDs if timestamping is not used, a Kconfig option is used to enable extended RX BDs in order to support hardware timestamping. This option will be removed once RX BD ring dynamic allocation is implemented.
Yangbo Lu (4):
enetc: add hardware timestamping support
enetc: add get_ts_info interface for ethtool
dt-binding: ptp_qoriq: support ENETC PTP compatible
arm64: dts: fsl: ls1028a: add ENETC 1588 timer node
.../devicetree/bindings/ptp/ptp-qoriq.txt | 1 + .../arm64/boot/dts/freescale/fsl-ls1028a.dtsi | 6 + drivers/net/ethernet/freescale/enetc/Kconfig | 10 ++ drivers/net/ethernet/freescale/enetc/enetc.c | 158 +++++++++++++++++- drivers/net/ethernet/freescale/enetc/enetc.h | 15 +- .../ethernet/freescale/enetc/enetc_ethtool.c | 31 ++++ .../net/ethernet/freescale/enetc/enetc_hw.h | 13 ++ .../net/ethernet/freescale/enetc/enetc_pf.c | 1 + .../net/ethernet/freescale/enetc/enetc_ptp.c | 5 + .../net/ethernet/freescale/enetc/enetc_vf.c | 1 + 10 files changed, 235 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.1
Y.b. Lu
maintainerPATCH v2 1/4 enetc: add hardware timestamping support
This patch is to add hardware timestamping support for ENETC. On Rx, timestamping is enabled for all frames. On Tx, we only instruct the hardware to timestamp the frames marked accordingly by the stack.
Because the RX BD ring dynamic allocation has not been supported and it is too expensive to use extended RX BDs if timestamping is not used, a Kconfig option is used to enable extended RX BDs in order to support hardware timestamping. This option will be removed once RX BD ring dynamic allocation is implemented.
---
Changes for v2:
- Rephrased Kconfig help message.
- Reverse Christmas tree order for variable definitions.
- Dropped goto in enetc_clean_tx_ring().
- Used name enetc_active_offloads instead of enetc_hw_features.
- Fixed up rx tstamp implementation.
- Rephrased commit message and added Claudiu.
--- drivers/net/ethernet/freescale/enetc/Kconfig | 10 ++ drivers/net/ethernet/freescale/enetc/enetc.c | 158 +++++++++++++++++- drivers/net/ethernet/freescale/enetc/enetc.h | 12 +- .../net/ethernet/freescale/enetc/enetc_hw.h | 13 ++ .../net/ethernet/freescale/enetc/enetc_pf.c | 1 + .../net/ethernet/freescale/enetc/enetc_vf.c | 1 + 6 files changed, 189 insertions(+), 6 deletions(-)
drivers/net/ethernet/freescale/enetc/Kconfig +10 -0
@@ -29,3 +29,13 @@ config FSL_ENETC_PTP_CLOCK packets using the SO_TIMESTAMPING API. If compiled as module (M), the module name is fsl-enetc-ptp. + +config FSL_ENETC_HW_TIMESTAMPING + bool "ENETC hardware timestamping support" + depends on FSL_ENETC || FSL_ENETC_VF + help + Enable hardware timestamping support on the Ethernet packets + using the SO_TIMESTAMPING API. Because the RX BD ring dynamic + allocation has not been supported and it is too expensive to use + extended RX BDs if timestamping is not used, this option enables + extended RX BDs in order to support hardware timestamping.
drivers/net/ethernet/freescale/enetc/enetc.c +153 -5
233 lines not on this page · raw message
drivers/net/ethernet/freescale/enetc/enetc.h +11 -1
@@ -21,7 +21,9 @@ struct enetc_tx_swbd {struct sk_buff *skb;dma_addr_t dma;u16 len; -u16 is_dma_page; + u8 is_dma_page:1; + u8 check_wb:1; + u8 do_tstamp:1; };#define ENETC_RX_MAXFRM_SIZE ENETC_MAC_MAXFRM_SIZE
@@ -167,6 +169,12 @@ struct enetc_cls_rule {#define ENETC_MAX_BDR_INT 2/* fixed to max # of available cpus */ +/* TODO: more hardware offloads */ +enum enetc_active_offloads { +ENETC_F_RX_TSTAMP =BIT (0 ), +ENETC_F_TX_TSTAMP =BIT (1 ), +}; +struct enetc_ndev_priv {struct net_device *ndev;struct device *dev;/* dma-mapping device */
@@ -178,6 +186,7 @@ struct enetc_ndev_priv {u16 rx_bd_count, tx_bd_count;u16 msg_enable; +int active_offloads;struct enetc_bdr *tx_ring[16 ];struct enetc_bdr *rx_ring[16 ];
@@ -216,6 +225,7 @@ netdev_tx_t enetc_xmit(struct sk_buff *skb, struct net_device *ndev);struct net_device_stats *enetc_get_stats (struct net_device *ndev);int enetc_set_features (struct net_device *ndev,netdev_features_t features); +int enetc_ioctl (struct net_device *ndev,struct ifreq *rq,int cmd);/* ethtool */ void enetc_set_ethtool_ops (struct net_device *ndev);
drivers/net/ethernet/freescale/enetc/enetc_hw.h +13 -0
@@ -361,6 +361,12 @@ union enetc_tx_bd {u8 e_flags;u8 flags; } ext;/* Tx BD extension */ +struct { +__le32 tstamp; +u8 reserved[10 ]; +u8 status; +u8 flags; + } wb;/* writeback descriptor */ };#define ENETC_TXBD_FLAGS_L4CS BIT(0)
@@ -399,6 +405,9 @@ union enetc_rx_bd {struct {__le64 addr;u8 reserved[8 ]; +#ifdef CONFIG_FSL_ENETC_HW_TIMESTAMPING +u8 reserved1[16 ]; +#endif } w;struct {__le16 inet_csum;
@@ -413,6 +422,10 @@ union enetc_rx_bd { };__le32 lstatus; }; +#ifdef CONFIG_FSL_ENETC_HW_TIMESTAMPING +__le32 tstamp; +u8 reserved[12 ]; +#endif } r; };
drivers/net/ethernet/freescale/enetc/enetc_pf.c +1 -0
@@ -702,6 +702,7 @@ static const struct net_device_ops enetc_ndev_ops = { .ndo_set_vf_vlan = enetc_pf_set_vf_vlan, .ndo_set_vf_spoofchk = enetc_pf_set_vf_spoofchk, .ndo_set_features = enetc_pf_set_features, + .ndo_do_ioctl = enetc_ioctl, }; static void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
drivers/net/ethernet/freescale/enetc/enetc_vf.c +1 -0
@@ -111,6 +111,7 @@ static const struct net_device_ops enetc_ndev_ops = { .ndo_get_stats = enetc_get_stats, .ndo_set_mac_address = enetc_vf_set_mac_addr, .ndo_set_features = enetc_vf_set_features, + .ndo_do_ioctl = enetc_ioctl, }; static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
Signature · 1 line
2.17.1
Y.b. Lu
maintainerPATCH v2 2/4 enetc: add get_ts_info interface for ethtool
In reply to Y.b. LuThis patch is to add get_ts_info interface for ethtool to support getting timestamping capability.
---
Changes for v2:
- None.
--- drivers/net/ethernet/freescale/enetc/enetc.h | 3 ++ .../ethernet/freescale/enetc/enetc_ethtool.c | 31 +++++++++++++++++++ .../net/ethernet/freescale/enetc/enetc_ptp.c | 5 +++ 3 files changed, 39 insertions(+)
drivers/net/ethernet/freescale/enetc/enetc.h +3 -0
@@ -209,6 +209,9 @@ struct enetc_msg_cmd_set_primary_mac {#define ENETC_CBDR_TIMEOUT 1000/* usecs */ +/* PTP driver exports */ +extern int enetc_phc_index; +/* SI common */ int enetc_pci_probe (struct pci_dev *pdev,const char *name,int sizeof_priv);void enetc_pci_remove (struct pci_dev *pdev);
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +31 -0
@@ -555,6 +555,35 @@ static void enetc_get_ringparam(struct net_device *ndev, } } +static int enetc_get_ts_info (struct net_device *ndev, +struct ethtool_ts_info *info) +{ +int *phc_idx; + + phc_idx =symbol_get (enetc_phc_index); +if (phc_idx) { + info->phc_index = *phc_idx; +symbol_put (enetc_phc_index); + }else { + info->phc_index =-1 ; + } + +#ifdef CONFIG_FSL_ENETC_HW_TIMESTAMPING + info->so_timestamping =SOF_TIMESTAMPING_TX_HARDWARE | +SOF_TIMESTAMPING_RX_HARDWARE | +SOF_TIMESTAMPING_RAW_HARDWARE ; + + info->tx_types = (1 <<HWTSTAMP_TX_OFF ) | + (1 <<HWTSTAMP_TX_ON ); + info->rx_filters = (1 <<HWTSTAMP_FILTER_NONE ) | + (1 <<HWTSTAMP_FILTER_ALL ); +#else + info->so_timestamping =SOF_TIMESTAMPING_RX_SOFTWARE | +SOF_TIMESTAMPING_SOFTWARE ; +#endif +return 0 ; +} +static const struct ethtool_ops enetc_pf_ethtool_ops = { .get_regs_len = enetc_get_reglen, .get_regs = enetc_get_regs,
@@ -571,6 +600,7 @@ static const struct ethtool_ops enetc_pf_ethtool_ops = { .get_link_ksettings = phy_ethtool_get_link_ksettings, .set_link_ksettings = phy_ethtool_set_link_ksettings, .get_link = ethtool_op_get_link, + .get_ts_info = enetc_get_ts_info, };static const struct ethtool_ops enetc_vf_ethtool_ops = {
@@ -586,6 +616,7 @@ static const struct ethtool_ops enetc_vf_ethtool_ops = { .set_rxfh = enetc_set_rxfh, .get_ringparam = enetc_get_ringparam, .get_link = ethtool_op_get_link, + .get_ts_info = enetc_get_ts_info, };void enetc_set_ethtool_ops (struct net_device *ndev)
drivers/net/ethernet/freescale/enetc/enetc_ptp.c +5 -0
@@ -7,6 +7,9 @@#include "enetc.h" +int enetc_phc_index =-1 ; +EXPORT_SYMBOL (enetc_phc_index); +static struct ptp_clock_info enetc_ptp_caps = { .owner =THIS_MODULE , .name ="ENETC PTP clock" ,
@@ -96,6 +99,7 @@ static int enetc_ptp_probe(struct pci_dev *pdev,if (err) goto err_no_clock; + enetc_phc_index = ptp_qoriq->phc_index;pci_set_drvdata (pdev, ptp_qoriq);return 0 ;
@@ -119,6 +123,7 @@ static void enetc_ptp_remove(struct pci_dev *pdev) {struct ptp_qoriq *ptp_qoriq =pci_get_drvdata (pdev); + enetc_phc_index =-1 ;ptp_qoriq_free (ptp_qoriq);kfree (ptp_qoriq);
Signature · 1 line
2.17.1
Y.b. Lu
maintainerPATCH v2 3/4 dt-binding: ptp_qoriq: support ENETC PTP compatible
In reply to Y.b. LuAdd a new compatible for ENETC PTP.
---
Changes for v2:
- Added this patch.
--- Documentation/devicetree/bindings/ptp/ptp-qoriq.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/ptp/ptp-qoriq.txt +1 -0
@@ -4,6 +4,7 @@ General Properties: - compatible Should be "fsl,etsec-ptp" for eTSEC Should be "fsl,fman-ptp-timer" for DPAA FMan + Should be "fsl,enetc-ptp" for ENETC - reg Offset and length of the register set for the device - interrupts There should be at least two interrupts. Some devices have as many as four PTP related interrupts.
Signature · 1 line
2.17.1
Y.b. Lu
maintainerPATCH v2 4/4 arm64: dts: fsl: ls1028a: add ENETC 1588 timer node
In reply to Y.b. LuAdd ENETC 1588 timer node which is ENETC PF 4 (Physiscal Function 4).
---
Changes for v2:
- Added compatible.
--- arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +6 -0
@@ -431,6 +431,12 @@ compatible = "fsl,enetc"; reg = <0x000100 0 0 0 0>; }; + ethernet@0,4 { + compatible = "fsl,enetc-ptp"; + reg = <0x000400 0 0 0 0>; + clocks = <&clockgen 4 0>; + little-endian; + }; }; }; };
Signature · 1 line
2.17.1
Quoted 2 lines · Y.b. Lu
This patch-set is to support hardware timestamping for ENETC and also to add ENETC 1588 timer device tree node for ls1028a.
Please, in the future, summarize the changes from the last series in the cover letter. It helps the reviewers to focus.
Thanks,
Richard
Y.b. Lu
maintainerQuoted 11 lines
-----Original Message-----
From: Richard Cochran <[email protected]>
Sent: Thursday, May 23, 2019 9:49 PM
To: Y.b. Lu <[email protected]>
Cc: [email protected]; David Miller <[email protected]>; Claudiu Manoil <[email protected]>; Shawn Guo <[email protected]>; Rob Herring <[email protected]>; Alexandru Marginean <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net-next v2, 0/4] ENETC: support hardware timestamping
Quoted 6 lines
Quoted 2 lines · Y.b. Lu
This patch-set is to support hardware timestamping for ENETC and also to add ENETC 1588 timer device tree node for ls1028a.
Please, in the future, summarize the changes from the last series in the cover letter. It helps the reviewers to focus.
[Y.b. Lu] Sorry Richard. Will summarize all changes in cover letter in the future, besides change notes on each patch. Thanks.
Quoted 3 lines
Thanks,
Richard
David Miller
maintainerFrom: "Y.b. Lu" <[email protected]>
Date: Thu, 23 May 2019 02:33:24 +0000
Quoted 9 lines
This patch-set is to support hardware timestamping for ENETC and also to add ENETC 1588 timer device tree node for ls1028a.
Because the ENETC RX BD ring dynamic allocation has not been supported and it is too expensive to use extended RX BDs if timestamping is not used, a
Kconfigoption is used to enable extended RX BDs in order to support hardware timestamping. This option will be removed once RX BD ring dynamic allocation is implemented.
Series applied.