Support DPAA PTP clock and timestamping
Subsystems (10)
Yangbo Lu
maintainercover Support DPAA PTP clock and timestamping
This patchset is to support DPAA FMAN PTP clock and HW timestamping.
- The patch #1 to patch #5 are to support DPAA FMAN 1588 timer in ptp_qoriq driver.
- The patch #6 to patch #10 are to add HW timestamping support in DPAA ethernet driver.
Yangbo Lu (10):
fsl/fman: share the event interrupt
ptp: support DPAA FMan 1588 timer in ptp_qoriq
dt-binding: ptp_qoriq: add DPAA FMan support powerpc/mpc85xx: move ptp timer out of fman in dts
arm64: dts: fsl: move ptp timer out of fman fsl/fman: add set_tstamp interface fsl/fman_port: support getting timestamp field fsl/fman: define frame description command UPD
dpaa_eth: add support for hardware timestamping
dpaa_eth: add the get_ts_info interface for ethtool
Documentation/devicetree/bindings/net/fsl-fman.txt | 25 +---- .../devicetree/bindings/ptp/ptp-qoriq.txt | 15 ++- arch/arm64/boot/dts/freescale/qoriq-fman3-0.dtsi | 14 ++- arch/powerpc/boot/dts/fsl/qoriq-fman-0.dtsi | 14 ++- arch/powerpc/boot/dts/fsl/qoriq-fman-1.dtsi | 14 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0.dtsi | 14 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-1.dtsi | 14 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3l-0.dtsi | 14 ++- drivers/net/ethernet/freescale/dpaa/Kconfig | 12 ++ drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 119 +++++++++++++++++++- drivers/net/ethernet/freescale/dpaa/dpaa_eth.h | 5 + drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 44 +++++++ drivers/net/ethernet/freescale/fman/fman.c | 3 +- drivers/net/ethernet/freescale/fman/fman.h | 1 + drivers/net/ethernet/freescale/fman/fman_dtsec.c | 27 +++++ drivers/net/ethernet/freescale/fman/fman_dtsec.h | 1 + drivers/net/ethernet/freescale/fman/fman_memac.c | 5 + drivers/net/ethernet/freescale/fman/fman_memac.h | 1 + drivers/net/ethernet/freescale/fman/fman_port.c | 12 ++ drivers/net/ethernet/freescale/fman/fman_port.h | 3 + drivers/net/ethernet/freescale/fman/fman_tgec.c | 21 ++++ drivers/net/ethernet/freescale/fman/fman_tgec.h | 1 + drivers/net/ethernet/freescale/fman/mac.c | 3 + drivers/net/ethernet/freescale/fman/mac.h | 1 + drivers/ptp/Kconfig | 2 +- drivers/ptp/ptp_qoriq.c | 104 +++++++++++------ include/linux/fsl/ptp_qoriq.h | 38 +++++- 27 files changed, 414 insertions(+), 113 deletions(-)
Yangbo Lu
maintainerPATCH 1/10 fsl/fman: share the event interrupt
This patch is to share fman event interrupt because the 1588 timer driver will also use this interrupt.
--- drivers/net/ethernet/freescale/fman/fman.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/ethernet/freescale/fman/fman.c +2 -1
@@ -2801,7 +2801,8 @@ static irqreturn_t fman_irq(int irq, void *handle)of_node_put (muram_node);of_node_put (fm_node); - err =devm_request_irq (&of_dev->dev, irq, fman_irq,0 ,"fman" , fman); + err =devm_request_irq (&of_dev->dev, irq, fman_irq,IRQF_SHARED , +"fman" , fman);if (err <0 ) {dev_err (&of_dev->dev,"%s: irq %d allocation failed (error = %d)\n" , __func__, irq, err);
Signature · 1 line
1.7.1
Yangbo Lu
maintainerPATCH 2/10 ptp: support DPAA FMan 1588 timer in ptp_qoriq
In reply to Yangbo LuThis patch is to support DPAA (Data Path Acceleration Architecture) 1588 timer by adding "fsl,fman-ptp-timer" compatible, sharing interrupt with FMan, adding FSL_DPAA_ETH dependency, and fixing up register offset.
--- drivers/ptp/Kconfig | 2 +- drivers/ptp/ptp_qoriq.c | 104 ++++++++++++++++++++++++++--------------- include/linux/fsl/ptp_qoriq.h | 38 ++++++++++++--- 3 files changed, 98 insertions(+), 46 deletions(-)
drivers/ptp/Kconfig +1 -1
@@ -43,7 +43,7 @@ config PTP_1588_CLOCK_DTE config PTP_1588_CLOCK_QORIQ tristate "Freescale QorIQ 1588 timer as PTP clock" - depends on GIANFAR + depends on GIANFAR || FSL_DPAA_ETH depends on PTP_1588_CLOCK default y help
drivers/ptp/ptp_qoriq.c +66 -38
265 lines not on this page · raw message
include/linux/fsl/ptp_qoriq.h +31 -7
@@ -11,9 +11,8 @@/* * qoriq ptp registers -* Generated by regen.tcl on Thu May 13 01:38:57 PM CEST 2010 */ -struct qoriq_ptp_registers { +struct ctrl_regs {u32 tmr_ctrl;/* Timer control register */ u32 tmr_tevent;/* Timestamp event register */ u32 tmr_temask;/* Timer event mask register */
@@ -28,22 +27,47 @@ struct qoriq_ptp_registers {u8 res1[4 ];u32 tmroff_h;/* Timer offset high */ u32 tmroff_l;/* Timer offset low */ -u8 res2[8 ]; +}; + +struct alarm_regs {u32 tmr_alarm1_h;/* Timer alarm 1 high register */ u32 tmr_alarm1_l;/* Timer alarm 1 high register */ u32 tmr_alarm2_h;/* Timer alarm 2 high register */ u32 tmr_alarm2_l;/* Timer alarm 2 high register */ -u8 res3[48 ]; +}; + +struct fiper_regs {u32 tmr_fiper1;/* Timer fixed period interval */ u32 tmr_fiper2;/* Timer fixed period interval */ u32 tmr_fiper3;/* Timer fixed period interval */ -u8 res4[20 ]; +}; + +struct etts_regs {u32 tmr_etts1_h;/* Timestamp of general purpose external trigger */ u32 tmr_etts1_l;/* Timestamp of general purpose external trigger */ u32 tmr_etts2_h;/* Timestamp of general purpose external trigger */ u32 tmr_etts2_l;/* Timestamp of general purpose external trigger */ }; +struct qoriq_ptp_registers { +struct ctrl_regs __iomem *ctrl_regs; +struct alarm_regs __iomem *alarm_regs; +struct fiper_regs __iomem *fiper_regs; +struct etts_regs __iomem *etts_regs; +}; + +/* Offset definitions for the four register groups */ +#define CTRL_REGS_OFFSET 0x0 +#define ALARM_REGS_OFFSET 0x40 +#define FIPER_REGS_OFFSET 0x80 +#define ETTS_REGS_OFFSET 0xa0 + +#define FMAN_CTRL_REGS_OFFSET 0x80 +#define FMAN_ALARM_REGS_OFFSET 0xb8 +#define FMAN_FIPER_REGS_OFFSET 0xd0 +#define FMAN_ETTS_REGS_OFFSET 0xe0 + +/* Bit definitions for the TMR_CTRL register */ #define ALM1P (1<<31)/* Alarm1 output polarity */ #define ALM2P (1<<30)/* Alarm2 output polarity */
@@ -105,10 +129,10 @@ struct qoriq_ptp_registers {#define DRIVER "ptp_qoriq"#define DEFAULT_CKSEL 1#define N_EXT_TS 2 -#define REG_SIZE sizeof(struct qoriq_ptp_registers)struct qoriq_ptp { -struct qoriq_ptp_registers __iomem *regs; +void __iomem *base; +struct qoriq_ptp_registers regs;spinlock_t lock;/* protects regs */ struct ptp_clock *clock;struct ptp_clock_info caps;
Signature · 1 line
1.7.1
Yangbo Lu
maintainerPATCH 3/10 dt-binding: ptp_qoriq: add DPAA FMan support
In reply to Yangbo LuThis patch is to add bindings description for DPAA FMan 1588 timer, and also remove its description in fsl-fman dt-bindings document.
--- Documentation/devicetree/bindings/net/fsl-fman.txt | 25 +------------------- .../devicetree/bindings/ptp/ptp-qoriq.txt | 15 +++++++++-- 2 files changed, 13 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/net/fsl-fman.txt +1 -24
@@ -356,30 +356,7 @@ ethernet at e0000 { ============================================================================ FMan IEEE 1588 Node -DESCRIPTION - -The FMan interface to support IEEE 1588 - - -PROPERTIES - -- compatible - Usage: required - Value type: <stringlist> - Definition: A standard property. - Must include "fsl,fman-ptp-timer". - -- reg - Usage: required - Value type: <prop-encoded-array> - Definition: A standard property. - -EXAMPLE - -ptp-timer at fe000 { - compatible = "fsl,fman-ptp-timer"; - reg = <0xfe000 0x1000>; -}; +Refer to Documentation/devicetree/bindings/ptp/ptp-qoriq.txt ============================================================================= FMan MDIO Node
Documentation/devicetree/bindings/ptp/ptp-qoriq.txt +12 -3
@@ -2,7 +2,8 @@ General Properties: - - compatible Should be "fsl,etsec-ptp" + - compatible Should be "fsl,etsec-ptp" for eTSEC + Should be "fsl,fman-ptp-timer" for DPAA FMan - 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.
@@ -43,14 +44,22 @@ Clock Properties: value, which will be directly written in those bits, that is why, according to reference manual, the next clock sources can be used: + For eTSEC, <0> - external high precision timer reference clock (TSEC_TMR_CLK input is used for this purpose); <1> - eTSEC system clock; <2> - eTSEC1 transmit clock; <3> - RTC clock input. - When this attribute is not used, eTSEC system clock will serve as - IEEE 1588 timer reference clock. + For DPAA FMan, + <0> - external high precision timer reference clock (TMR_1588_CLK) + <1> - MAC system clock (1/2 FMan clock) + <2> - reserved + <3> - RTC clock oscillator + + When this attribute is not used, the IEEE 1588 timer reference clock + will use the eTSEC system clock (for Gianfar) or the MAC system + clock (for DPAA). Example:
Signature · 1 line
1.7.1
Yangbo Lu
maintainerPATCH 4/10 powerpc/mpc85xx: move ptp timer out of fman in dts
In reply to Yangbo LuThis patch is to move ptp timer node out of fman. Because ptp timer will be probed by ptp_qoriq driver, it should be an independent device in case of conflict memory mapping.
--- arch/powerpc/boot/dts/fsl/qoriq-fman-0.dtsi | 14 ++++++++------ arch/powerpc/boot/dts/fsl/qoriq-fman-1.dtsi | 14 ++++++++------ arch/powerpc/boot/dts/fsl/qoriq-fman3-0.dtsi | 14 ++++++++------ arch/powerpc/boot/dts/fsl/qoriq-fman3-1.dtsi | 14 ++++++++------ arch/powerpc/boot/dts/fsl/qoriq-fman3l-0.dtsi | 14 ++++++++------ 5 files changed, 40 insertions(+), 30 deletions(-)
arch/powerpc/boot/dts/fsl/qoriq-fman-0.dtsi +8 -6
@@ -37,12 +37,13 @@ fman0: fman at 400000 { #size-cells = <1>; cell-index = <0>; compatible = "fsl,fman"; - ranges = <0 0x400000 0x100000>; - reg = <0x400000 0x100000>; + ranges = <0 0x400000 0xfe000>; + reg = <0x400000 0xfe000>; interrupts = <96 2 0 0>, <16 2 1 1>; clocks = <&clockgen 3 0>; clock-names = "fmanclk"; fsl,qman-channel-range = <0x40 0xc>; + ptimer-handle = <&ptp_timer0>; muram at 0 { compatible = "fsl,fman-muram";
@@ -93,9 +94,10 @@ fman0: fman at 400000 { reg = <0x87000 0x1000>; status = "disabled"; }; +}; - ptp_timer0: ptp-timer at fe000 { - compatible = "fsl,fman-ptp-timer"; - reg = <0xfe000 0x1000>; - }; +ptp_timer0: ptp-timer at 4fe000 { + compatible = "fsl,fman-ptp-timer"; + reg = <0x4fe000 0x1000>; + interrupts = <96 2 0 0>; };
arch/powerpc/boot/dts/fsl/qoriq-fman-1.dtsi +8 -6
@@ -37,12 +37,13 @@ fman1: fman at 500000 { #size-cells = <1>; cell-index = <1>; compatible = "fsl,fman"; - ranges = <0 0x500000 0x100000>; - reg = <0x500000 0x100000>; + ranges = <0 0x500000 0xfe000>; + reg = <0x500000 0xfe000>; interrupts = <97 2 0 0>, <16 2 1 0>; clocks = <&clockgen 3 1>; clock-names = "fmanclk"; fsl,qman-channel-range = <0x60 0xc>; + ptimer-handle = <&ptp_timer1>; muram at 0 { compatible = "fsl,fman-muram";
@@ -93,9 +94,10 @@ fman1: fman at 500000 { reg = <0x87000 0x1000>; status = "disabled"; }; +}; - ptp_timer1: ptp-timer at fe000 { - compatible = "fsl,fman-ptp-timer"; - reg = <0xfe000 0x1000>; - }; +ptp_timer1: ptp-timer at 5fe000 { + compatible = "fsl,fman-ptp-timer"; + reg = <0x5fe000 0x1000>; + interrupts = <97 2 0 0>; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0.dtsi +8 -6
@@ -37,12 +37,13 @@ fman0: fman at 400000 { #size-cells = <1>; cell-index = <0>; compatible = "fsl,fman"; - ranges = <0 0x400000 0x100000>; - reg = <0x400000 0x100000>; + ranges = <0 0x400000 0xfe000>; + reg = <0x400000 0xfe000>; interrupts = <96 2 0 0>, <16 2 1 1>; clocks = <&clockgen 3 0>; clock-names = "fmanclk"; fsl,qman-channel-range = <0x800 0x10>; + ptimer-handle = <&ptp_timer0>; muram at 0 { compatible = "fsl,fman-muram";
@@ -98,9 +99,10 @@ fman0: fman at 400000 { compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; reg = <0xfd000 0x1000>; }; +}; - ptp_timer0: ptp-timer at fe000 { - compatible = "fsl,fman-ptp-timer"; - reg = <0xfe000 0x1000>; - }; +ptp_timer0: ptp-timer at 4fe000 { + compatible = "fsl,fman-ptp-timer"; + reg = <0x4fe000 0x1000>; + interrupts = <96 2 0 0>; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-1.dtsi +8 -6
@@ -37,12 +37,13 @@ fman1: fman at 500000 { #size-cells = <1>; cell-index = <1>; compatible = "fsl,fman"; - ranges = <0 0x500000 0x100000>; - reg = <0x500000 0x100000>; + ranges = <0 0x500000 0xfe000>; + reg = <0x500000 0xfe000>; interrupts = <97 2 0 0>, <16 2 1 0>; clocks = <&clockgen 3 1>; clock-names = "fmanclk"; fsl,qman-channel-range = <0x820 0x10>; + ptimer-handle = <&ptp_timer1>; muram at 0 { compatible = "fsl,fman-muram";
@@ -98,9 +99,10 @@ fman1: fman at 500000 { compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; reg = <0xfd000 0x1000>; }; +}; - ptp_timer1: ptp-timer at fe000 { - compatible = "fsl,fman-ptp-timer"; - reg = <0xfe000 0x1000>; - }; +ptp_timer1: ptp-timer at 5fe000 { + compatible = "fsl,fman-ptp-timer"; + reg = <0x5fe000 0x1000>; + interrupts = <97 2 0 0>; };
arch/powerpc/boot/dts/fsl/qoriq-fman3l-0.dtsi +8 -6
@@ -37,12 +37,13 @@ fman0: fman at 400000 { #size-cells = <1>; cell-index = <0>; compatible = "fsl,fman"; - ranges = <0 0x400000 0x100000>; - reg = <0x400000 0x100000>; + ranges = <0 0x400000 0xfe000>; + reg = <0x400000 0xfe000>; interrupts = <96 2 0 0>, <16 2 1 1>; clocks = <&clockgen 3 0>; clock-names = "fmanclk"; fsl,qman-channel-range = <0x800 0x10>; + ptimer-handle = <&ptp_timer0>; muram at 0 { compatible = "fsl,fman-muram";
@@ -86,9 +87,10 @@ fman0: fman at 400000 { compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; reg = <0xfd000 0x1000>; }; +}; - ptp_timer0: ptp-timer at fe000 { - compatible = "fsl,fman-ptp-timer"; - reg = <0xfe000 0x1000>; - }; +ptp_timer0: ptp-timer at 4fe000 { + compatible = "fsl,fman-ptp-timer"; + reg = <0x4fe000 0x1000>; + interrupts = <96 2 0 0>; };
Signature · 1 line
1.7.1
Yangbo Lu
maintainerPATCH 5/10 arm64: dts: fsl: move ptp timer out of fman
In reply to Yangbo LuThis patch is to move ptp timer node out of fman. Because ptp timer will be probed by ptp_qoriq driver, it should be an independent device in case of conflict memory mapping.
--- arch/arm64/boot/dts/freescale/qoriq-fman3-0.dtsi | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/freescale/qoriq-fman3-0.dtsi +8 -6
@@ -11,13 +11,14 @@ fman0: fman at 1a00000 { #size-cells = <1>; cell-index = <0>; compatible = "fsl,fman"; - ranges = <0x0 0x0 0x1a00000 0x100000>; - reg = <0x0 0x1a00000 0x0 0x100000>; + ranges = <0x0 0x0 0x1a00000 0xfe000>; + reg = <0x0 0x1a00000 0x0 0xfe000>; interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clockgen 3 0>; clock-names = "fmanclk"; fsl,qman-channel-range = <0x800 0x10>; + ptimer-handle = <&ptp_timer0>; muram at 0 { compatible = "fsl,fman-muram";
@@ -73,9 +74,10 @@ fman0: fman at 1a00000 { compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; reg = <0xfd000 0x1000>; }; +}; - ptp_timer0: ptp-timer at fe000 { - compatible = "fsl,fman-ptp-timer"; - reg = <0xfe000 0x1000>; - }; +ptp_timer0: ptp-timer at 1afe000 { + compatible = "fsl,fman-ptp-timer"; + reg = <0x1afe000 0x1000>; + interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>; };
Signature · 1 line
1.7.1
Yangbo Lu
maintainerPATCH 6/10 fsl/fman: add set_tstamp interface
In reply to Yangbo LuThis patch is to add set_tstamp interface for memac, dtsec, and 10GEC controllers to configure HW timestamping.
--- drivers/net/ethernet/freescale/fman/fman_dtsec.c | 27 ++++++++++++++++++++++ drivers/net/ethernet/freescale/fman/fman_dtsec.h | 1 + drivers/net/ethernet/freescale/fman/fman_memac.c | 5 ++++ drivers/net/ethernet/freescale/fman/fman_memac.h | 1 + drivers/net/ethernet/freescale/fman/fman_tgec.c | 21 +++++++++++++++++ drivers/net/ethernet/freescale/fman/fman_tgec.h | 1 + drivers/net/ethernet/freescale/fman/mac.c | 3 ++ drivers/net/ethernet/freescale/fman/mac.h | 1 + 8 files changed, 60 insertions(+), 0 deletions(-)
drivers/net/ethernet/freescale/fman/fman_dtsec.c +27 -0
@@ -123,11 +123,13 @@#define DTSEC_ECNTRL_R100M 0x00000008#define DTSEC_ECNTRL_QSGMIIM 0x00000001 +#define TCTRL_TTSE 0x00000040#define TCTRL_GTS 0x00000020#define RCTRL_PAL_MASK 0x001f0000#define RCTRL_PAL_SHIFT 16#define RCTRL_GHTX 0x00000400 +#define RCTRL_RTSE 0x00000040#define RCTRL_GRS 0x00000020#define RCTRL_MPROM 0x00000008#define RCTRL_RSF 0x00000004
@@ -1136,6 +1138,31 @@ int dtsec_set_allmulti(struct fman_mac *dtsec, bool enable)return 0 ; } +int dtsec_set_tstamp (struct fman_mac *dtsec,bool enable) +{ +struct dtsec_regs __iomem *regs = dtsec->regs; +u32 rctrl, tctrl; + +if (!is_init_done (dtsec->dtsec_drv_param)) +return -EINVAL ; + + rctrl =ioread32be (®s->rctrl); + tctrl =ioread32be (®s->tctrl); + +if (enable) { + rctrl |=RCTRL_RTSE ; + tctrl |=TCTRL_TTSE ; + }else { + rctrl &= ~RCTRL_RTSE ; + tctrl &= ~TCTRL_TTSE ; + } + +iowrite32be (rctrl, ®s->rctrl); +iowrite32be (tctrl, ®s->tctrl); + +return 0 ; +} +int dtsec_del_hash_mac_address (struct fman_mac *dtsec,enet_addr_t *eth_addr) {struct dtsec_regs __iomem *regs = dtsec->regs;
drivers/net/ethernet/freescale/fman/fman_dtsec.h +1 -0
@@ -56,5 +56,6 @@ int dtsec_set_exception(struct fman_mac *dtsec,int dtsec_del_hash_mac_address (struct fman_mac *dtsec,enet_addr_t *eth_addr);int dtsec_get_version (struct fman_mac *dtsec,u32 *mac_version);int dtsec_set_allmulti (struct fman_mac *dtsec,bool enable); +int dtsec_set_tstamp (struct fman_mac *dtsec,bool enable);#endif /* __DTSEC_H */
drivers/net/ethernet/freescale/fman/fman_memac.c +5 -0
@@ -964,6 +964,11 @@ int memac_set_allmulti(struct fman_mac *memac, bool enable)return 0 ; } +int memac_set_tstamp (struct fman_mac *memac,bool enable) +{ +return 0 ;/* Always enabled. */ +} +int memac_del_hash_mac_address (struct fman_mac *memac,enet_addr_t *eth_addr) {struct memac_regs __iomem *regs = memac->regs;
drivers/net/ethernet/freescale/fman/fman_memac.h +1 -0
@@ -58,5 +58,6 @@ int memac_set_exception(struct fman_mac *memac,int memac_add_hash_mac_address (struct fman_mac *memac,enet_addr_t *eth_addr);int memac_del_hash_mac_address (struct fman_mac *memac,enet_addr_t *eth_addr);int memac_set_allmulti (struct fman_mac *memac,bool enable); +int memac_set_tstamp (struct fman_mac *memac,bool enable);#endif /* __MEMAC_H */
drivers/net/ethernet/freescale/fman/fman_tgec.c +21 -0
@@ -44,6 +44,7 @@#define TGEC_TX_IPG_LENGTH_MASK 0x000003ff/* Command and Configuration Register (COMMAND_CONFIG) */ +#define CMD_CFG_EN_TIMESTAMP 0x00100000#define CMD_CFG_NO_LEN_CHK 0x00020000#define CMD_CFG_PAUSE_IGNORE 0x00000100#define CMF_CFG_CRC_FWD 0x00000040
@@ -588,6 +589,26 @@ int tgec_set_allmulti(struct fman_mac *tgec, bool enable)return 0 ; } +int tgec_set_tstamp (struct fman_mac *tgec,bool enable) +{ +struct tgec_regs __iomem *regs = tgec->regs; +u32 tmp; + +if (!is_init_done (tgec->cfg)) +return -EINVAL ; + + tmp =ioread32be (®s->command_config); + +if (enable) + tmp |=CMD_CFG_EN_TIMESTAMP ; +else + tmp &= ~CMD_CFG_EN_TIMESTAMP ; + +iowrite32be (tmp, ®s->command_config); + +return 0 ; +} +int tgec_del_hash_mac_address (struct fman_mac *tgec,enet_addr_t *eth_addr) {struct tgec_regs __iomem *regs = tgec->regs;
drivers/net/ethernet/freescale/fman/fman_tgec.h +1 -0
@@ -52,5 +52,6 @@ int tgec_set_exception(struct fman_mac *tgec,int tgec_del_hash_mac_address (struct fman_mac *tgec,enet_addr_t *eth_addr);int tgec_get_version (struct fman_mac *tgec,u32 *mac_version);int tgec_set_allmulti (struct fman_mac *tgec,bool enable); +int tgec_set_tstamp (struct fman_mac *tgec,bool enable);#endif /* __TGEC_H */
drivers/net/ethernet/freescale/fman/mac.c +3 -0
@@ -471,6 +471,7 @@ static void setup_dtsec(struct mac_device *mac_dev) mac_dev->set_rx_pause = dtsec_accept_rx_pause_frames; mac_dev->set_exception = dtsec_set_exception; mac_dev->set_allmulti = dtsec_set_allmulti; + mac_dev->set_tstamp = dtsec_set_tstamp; mac_dev->set_multi = set_multi; mac_dev->start = start; mac_dev->stop = stop;
@@ -490,6 +491,7 @@ static void setup_tgec(struct mac_device *mac_dev) mac_dev->set_rx_pause = tgec_accept_rx_pause_frames; mac_dev->set_exception = tgec_set_exception; mac_dev->set_allmulti = tgec_set_allmulti; + mac_dev->set_tstamp = tgec_set_tstamp; mac_dev->set_multi = set_multi; mac_dev->start = start; mac_dev->stop = stop;
@@ -509,6 +511,7 @@ static void setup_memac(struct mac_device *mac_dev) mac_dev->set_rx_pause = memac_accept_rx_pause_frames; mac_dev->set_exception = memac_set_exception; mac_dev->set_allmulti = memac_set_allmulti; + mac_dev->set_tstamp = memac_set_tstamp; mac_dev->set_multi = set_multi; mac_dev->start = start; mac_dev->stop = stop;
drivers/net/ethernet/freescale/fman/mac.h +1 -0
@@ -68,6 +68,7 @@ struct mac_device {int (*set_promisc)(struct fman_mac *mac_dev,bool enable);int (*change_addr)(struct fman_mac *mac_dev,enet_addr_t *enet_addr);int (*set_allmulti)(struct fman_mac *mac_dev,bool enable); +int (*set_tstamp)(struct fman_mac *mac_dev,bool enable);int (*set_multi)(struct net_device *net_dev,struct mac_device *mac_dev);int (*set_rx_pause)(struct fman_mac *mac_dev,bool en);
Signature · 1 line
1.7.1
Yangbo Lu
maintainerPATCH 7/10 fsl/fman_port: support getting timestamp field
In reply to Yangbo LuThis patch is to add fman_port_get_tstamp_field() interface to get timestamp field data.
--- drivers/net/ethernet/freescale/fman/fman_port.c | 12 ++++++++++++ drivers/net/ethernet/freescale/fman/fman_port.h | 3 +++ 2 files changed, 15 insertions(+), 0 deletions(-)
drivers/net/ethernet/freescale/fman/fman_port.c +12 -0
@@ -1731,6 +1731,18 @@ int fman_port_get_hash_result_offset(struct fman_port *port, u32 *offset) }EXPORT_SYMBOL (fman_port_get_hash_result_offset); +int fman_port_get_tstamp_field (struct fman_port *port,const void *data, +u64 *tstamp) +{ +if (port->buffer_offsets.time_stamp_offset ==ILLEGAL_BASE ) +return -EINVAL ; + + *tstamp = *(u64 *)(data + port->buffer_offsets.time_stamp_offset); + +return 0 ; +} +EXPORT_SYMBOL (fman_port_get_tstamp_field); +static int fman_port_probe (struct platform_device *of_dev) {struct fman_port *port;
drivers/net/ethernet/freescale/fman/fman_port.h +3 -0
@@ -153,6 +153,9 @@ int fman_port_cfg_buf_prefix_content(struct fman_port *port,int fman_port_get_hash_result_offset (struct fman_port *port,u32 *offset); +int fman_port_get_tstamp_field (struct fman_port *port,const void *data, +u64 *tstamp); +struct fman_port *fman_port_bind (struct device *dev);#endif /* __FMAN_PORT_H */
Signature · 1 line
1.7.1
Yangbo Lu
maintainerPATCH 8/10 fsl/fman: define frame description command UPD
In reply to Yangbo LuDefined frame description command FM_FD_CMD_UPD for prepended data updating.
--- drivers/net/ethernet/freescale/fman/fman.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/ethernet/freescale/fman/fman.h +1 -0
@@ -41,6 +41,7 @@/* Frame queue Context Override */ #define FM_FD_CMD_FCO 0x80000000#define FM_FD_CMD_RPD 0x40000000/* Read Prepended Data */ +#define FM_FD_CMD_UPD 0x20000000/* Update Prepended Data */ #define FM_FD_CMD_DTC 0x10000000/* Do L4 Checksum */ /* TX-Port: Unsupported Format */
Signature · 1 line
1.7.1
Yangbo Lu
maintainerPATCH 9/10 dpaa_eth: add support for hardware timestamping
In reply to Yangbo LuThis patch is to add hardware timestamping support for dpaa_eth. On Rx, timestamping is enabled for all frames. On Tx, we only instruct the hardware to timestamp the frames marked accordingly by the stack.
--- drivers/net/ethernet/freescale/dpaa/Kconfig | 12 +++ drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 119 +++++++++++++++++++++++- drivers/net/ethernet/freescale/dpaa/dpaa_eth.h | 5 + 3 files changed, 133 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/dpaa/Kconfig +12 -0
@@ -8,3 +8,15 @@ menuconfig FSL_DPAA_ETH supporting the Freescale QorIQ chips. Depends on Freescale Buffer Manager and Queue Manager driver and Frame Manager Driver. + +if FSL_DPAA_ETH +config FSL_DPAA_ETH_TS + bool "DPAA hardware timestamping support" + select PTP_1588_CLOCK_QORIQ + default n + help + Enable DPAA hardware timestamping support. + This option is useful for applications to get + hardware time stamps on the Ethernet packets + using the SO_TIMESTAMPING API. +endif
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +116 -3
165 lines not on this page · raw message
drivers/net/ethernet/freescale/dpaa/dpaa_eth.h +5 -0
@@ -182,6 +182,11 @@ struct dpaa_priv {struct dpaa_buffer_layout buf_layout[2 ];u16 rx_headroom; + +#ifdef CONFIG_FSL_DPAA_ETH_TS +bool tx_tstamp;/* Tx timestamping enabled */ +bool rx_tstamp;/* Rx timestamping enabled */ +#endif };/* from dpaa_ethtool.c */
Signature · 1 line
1.7.1
Richard Cochran
maintainerRe: [PATCH 09/10] dpaa_eth: add support for hardware timestamping
drivers/net/ethernet/freescale/dpaa/Kconfig menuconfig FSL_DPAA_ETH · line 22
Quoted 11 lines · Yangbo Lu
drivers/net/ethernet/freescale/dpaa/Kconfig +11
-0+if FSL_DPAA_ETH +config FSL_DPAA_ETH_TS + bool "DPAA hardware timestamping support" + select PTP_1588_CLOCK_QORIQ + default n + help + Enable DPAA hardware timestamping support. + This option is useful for applications to get + hardware time stamps on the Ethernet packets + using the SO_TIMESTAMPING API. +endif
You should drop this #ifdef. In general, if a MAC supports time stamping and PHC, then the driver support should simply be compiled in.
[ When time stamping incurs a large run time performance penalty to
non-PTP users, then it might make sense to have a Kconfig option to disable it, but that doesn't appear to be the case here. ]
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c static int dpaa_eth_refill_bpools(struct dpaa_priv *priv) · line 1640
Quoted 7 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +3
-0@@ -1615,6 +1635,24 @@ static int dpaa_eth_refill_bpools(struct dpaa_priv *priv) skbh = (struct sk_buff **)phys_to_virt (addr); skb = *skbh; +#ifdef CONFIG_FSL_DPAA_ETH_TS +if (priv->tx_tstamp && +skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) {
This condition fits on one line easily.
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c static int dpaa_eth_refill_bpools(struct dpaa_priv *priv) · line 1642
Quoted 2 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +2
-0+struct skb_shared_hwtstamps shhwtstamps; +u64 ns;
Local variables belong at the top of the function.
Quoted 16 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +12
-0+memset (&shhwtstamps,0 ,sizeof (shhwtstamps)); + +if (!dpaa_get_tstamp_ns (priv->net_dev, &ns, + priv->mac_dev->port[TX ], + (void *)skbh)) { + shhwtstamps.hwtstamp =ns_to_ktime (ns); +skb_tstamp_tx (skb, &shhwtstamps); + }else { +dev_warn (dev,"dpaa_get_tstamp_ns failed!\n" ); + } + } +#endif if (unlikely (qm_fd_get_format (fd) == qm_fd_sg)) { nr_frags =skb_shinfo (skb)->nr_frags; dma_unmap_single(dev, addr, qm_fd_get_offset(fd) +
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c static int dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev) · line 2129
Quoted 6 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +3
-0@@ -2086,6 +2124,14 @@ static int dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev)if (unlikely (err <0 )) goto skb_to_fd_failed; +#ifdef CONFIG_FSL_DPAA_ETH_TS +if (priv->tx_tstamp && +skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) {
One line please.
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c static int dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev) · line 2137
Quoted 8 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +5
-0+ fd.cmd |=FM_FD_CMD_UPD ; + skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; + } +#endif +if (likely (dpaa_xmit (priv, percpu_stats, queue_mapping, &fd) ==0 ))return NETDEV_TX_OK ;
Thanks,
Richard
Y.b. Lu
maintainerRE: [PATCH 09/10] dpaa_eth: add support for hardware timestamping
Hi Richard,
Quoted 28 lines
-----Original Message-----
From: Richard Cochran [mailto:richardcochran at gmail.com]
Sent: Monday, June 4, 2018 9:49 PM
To: Y.b. Lu <[email protected]>
Cc: netdev at vger.kernel.org; Madalin-cristian Bucur <[email protected]>; Rob Herring <[email protected]>; Shawn Guo <[email protected]>; David S . Miller <[email protected]>; devicetree at vger.kernel.org; linuxppc-dev at lists.ozlabs.org; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org
Subject: Re: [PATCH 09/10]dpaa_eth: add support for hardware timestampingdrivers/net/ethernet/freescale/dpaa/Kconfig menuconfig FSL_DPAA_ETH · line 22
Quoted 11 lines · Yangbo Lu
drivers/net/ethernet/freescale/dpaa/Kconfig +11
-0+if FSL_DPAA_ETH +config FSL_DPAA_ETH_TS + bool "DPAA hardware timestamping support" + select PTP_1588_CLOCK_QORIQ + default n + help + Enable DPAA hardware timestamping support. + This option is useful for applications to get + hardware time stamps on the Ethernet packets + using the SO_TIMESTAMPING API. +endifYou should drop this #ifdef. In general, if a MAC supports time stamping and PHC, then the driver support should simply be compiled in.
Quoted 3 lines
[ When time stamping incurs a large run time performance penalty to
non-PTP users, then it might make sense to have aKconfigoption to disable it, but that doesn't appear to be the case here. ]
[Y.b. Lu] Actually these timestamping codes affected DPAA networking performance in our previous performance test. That's why we used ifdef for it.
Quoted 11 lines
Review static int dpaa_eth_refill_bpools(struct
Quoted 2 lines
(quoted diff) +0
-0@@ -1615,6 +1635,24 @@ static int dpaa_eth_refill_bpools(struct
dpaa_priv*priv)drivers/net/ethernet/freescale/dpaa/dpaa_eth.c static int dpaa_eth_refill_bpools(struct dpaa_priv *priv) · line 1640
Quoted 6 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +3
-0skbh = (struct sk_buff **)phys_to_virt (addr); skb = *skbh; +#ifdef CONFIG_FSL_DPAA_ETH_TS +if (priv->tx_tstamp && +skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) {This condition fits on one line easily.
[Y.b. Lu] Right. I will use one line in next version.
Quoted 5 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c static int dpaa_eth_refill_bpools(struct dpaa_priv *priv) · line 1642
Quoted 3 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +2
-0+struct skb_shared_hwtstamps shhwtstamps; +u64 ns;Local variables belong at the top of the function.
[Y.b. Lu] Ok, will move them to the top in next verison.
Quoted 18 lines
Quoted 7 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +6
-0+memset (&shhwtstamps,0 ,sizeof (shhwtstamps)); + +if (!dpaa_get_tstamp_ns (priv->net_dev, &ns, + priv->mac_dev->port[TX ], + (void *)skbh)) { + shhwtstamps.hwtstamp =ns_to_ktime (ns);drivers/net/ethernet/freescale/dpaa/dpaa_eth.c static int dpaa_eth_refill_bpools(struct dpaa_priv *priv)
Quoted 10 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +7
-0+ skb_tstamp_tx(skb, &shhwtstamps); + }else { +dev_warn (dev,"dpaa_get_tstamp_ns failed!\n" ); + } + } +#endif if (unlikely (qm_fd_get_format (fd) == qm_fd_sg)) { nr_frags =skb_shinfo (skb)->nr_frags; dma_unmap_single(dev, addr, qm_fd_get_offset(fd) + @@ -2086,6 +2124,14 @@ static int dpaa_start_xmit(struct sk_buff *skb, struct
net_device*net_dev)
Quoted 8 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c static int dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev) · line 2129
Quoted 6 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +3
-0if (unlikely (err <0 )) goto skb_to_fd_failed; +#ifdef CONFIG_FSL_DPAA_ETH_TS +if (priv->tx_tstamp && +skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) {One line please.
[Y.b. Lu] No problem.
Quoted 12 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c static int dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev) · line 2136
Quoted 9 lines
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +5
-0+ fd.cmd |=FM_FD_CMD_UPD ; + skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; + } +#endif +if (likely (dpaa_xmit (priv, percpu_stats, queue_mapping, &fd) ==0 ))return NETDEV_TX_OK ;Thanks,
Richard
Richard Cochran
maintainerRe: [PATCH 09/10] dpaa_eth: add support for hardware timestamping
Quoted 2 lines · Y.b. Lu
[Y.b. Lu] Actually these timestamping codes affected DPAA networking performance in our previous performance test. That's why we used ifdef for it.
How much does time stamping hurt performance?
If the time stamping is compiled in but not enabled at run time, does it still affect performace?
Thanks,
Richard
Y.b. Lu
maintainerRE: [PATCH 09/10] dpaa_eth: add support for hardware timestamping
Hi Richard,
Quoted 12 lines
-----Original Message-----
From: Richard Cochran [mailto:richardcochran at gmail.com]
Sent: Tuesday, June 5, 2018 9:58 PM
To: Y.b. Lu <[email protected]>
Cc: netdev at vger.kernel.org; Madalin-cristian Bucur <[email protected]>; Rob Herring <[email protected]>; Shawn Guo <[email protected]>; David S . Miller <[email protected]>; devicetree at vger.kernel.org; linuxppc-dev at lists.ozlabs.org; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org
Subject: Re: [PATCH 09/10]dpaa_eth: add support for hardware timestampingOn Tue, Jun 05, 2018 at 03:35:28AM +0000, Y.b. Lu wrote:
Quoted 8 lines
Quoted 1 line
[Y.b. Lu] Actually these timestamping codes affected DPAA networking
performance in our previous performance test.
Quoted 1 line
That's why we used ifdef for it.
How much does time stamping hurt performance?
If the time stamping is compiled in but not enabled at run time, does it still affect performace?
[Y.b. Lu] I can't remember and find the old data since it had been a long time.
I just did the iperf test today between two 10G ports. I didn?t see any performance changes with timestamping code ? So, let's me remove the ifdef in next version.
Thanks a lot.
Quoted 3 lines
Thanks,
Richard
Yangbo Lu
maintainerPATCH 10/10 dpaa_eth: add the get_ts_info interface for ethtool
In reply to Yangbo LuAdded the get_ts_info interface for ethtool to check the timestamping capability.
--- drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 44 ++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)
drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c +44 -0
@@ -32,6 +32,9 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/string.h> +#include <linux/of_platform.h> +#include <linux/net_tstamp.h> +#include <linux/fsl/ptp_qoriq.h> #include "dpaa_eth.h" #include "mac.h"
@@ -515,6 +518,46 @@ static int dpaa_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)return ret; } +static int dpaa_get_ts_info (struct net_device *net_dev, +struct ethtool_ts_info *info) +{ +struct device *dev = net_dev->dev.parent; +struct device_node *mac_node = dev->of_node; +struct device_node *fman_node =NULL , *ptp_node =NULL ; +struct platform_device *ptp_dev =NULL ; +struct qoriq_ptp *ptp =NULL ; + + fman_node =of_get_parent (mac_node); +if (fman_node) + ptp_node =of_parse_phandle (fman_node,"ptimer-handle" ,0 ); + +if (ptp_node) + ptp_dev =of_find_device_by_node (ptp_node); + +if (ptp_dev) + ptp =platform_get_drvdata (ptp_dev); + +if (ptp) { + info->phc_index = ptp->phc_index; +#ifdef CONFIG_FSL_DPAA_ETH_TS + 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 ); +return 0 ; +#endif + }else { + info->phc_index =-1 ; + } + + info->so_timestamping =SOF_TIMESTAMPING_RX_SOFTWARE | +SOF_TIMESTAMPING_SOFTWARE ; +return 0 ; +} +const struct ethtool_ops dpaa_ethtool_ops = { .get_drvinfo = dpaa_get_drvinfo, .get_msglevel = dpaa_get_msglevel,
@@ -530,4 +573,5 @@ static int dpaa_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) .set_link_ksettings = dpaa_set_link_ksettings, .get_rxnfc = dpaa_get_rxnfc, .set_rxnfc = dpaa_set_rxnfc, + .get_ts_info = dpaa_get_ts_info, };
Signature · 1 line
1.7.1