Marvell PTP stuffs
Subsystems (6)
Russell King (Oracle)
reviewercover Marvell PTP stuffs
Not for merging, and, yes, it's more than 15 patches.
As the merge window is approaching, I thought I would share my current state with the Marvell PTP library. I don't consider this ready for merging yet, as I still have decisions to make on the structure for multi-port setups such as DSA. 88E6165 support is also likely broken.
You will have noticed I've pushed out some patches cleaning up stuff in the mv88e6xxx driver, and also making it easier for PTP clock drivers to clean up when unregistering.
This series contains potentially another independent patch, adding the ability to get the hwtstamp configuration from a MII timestamper, although of course, the only known user right now is the Marvell PHY PTP support (specifically 88E1510) in this series.
One of the things I don't like about the conversion for mv88e6xxx is the "drop the old code, plug in the new". The hwtstamp.c changes are split up, but they result in stuff becoming non-functional during the transition.
The only thing I can think of doing to solve that is to forward the hwtstamp_set() call to both implementations, and then convert the tx side, rx side, and remove the old.
I've been running this for about 10 days (with reboots) between two machines, one using the PHY side as the GM, and the other using DSA as the slave. All seems happy, no timeouts on getting the timestamps for the Sync or Delay_Req packets:
ptp4l[3032.775]: master offset -60 s2 freq -3984 path delay 11144 ptp4l[3033.775]: master offset -16 s2 freq -3958 path delay 11144 ptp4l[3034.775]: master offset 45 s2 freq -3901 path delay 11144 ptp4l[3035.775]: master offset 203 s2 freq -3730 path delay 11144 ptp4l[3036.775]: master offset 115 s2 freq -3757 path delay 11144 ptp4l[3037.775]: master offset -186 s2 freq -4023 path delay 11144 ptp4l[3038.775]: master offset -244 s2 freq -4137 path delay 11144 ptp4l[3039.775]: master offset -122 s2 freq -4088 path delay 11137
I've tested both L2 and L4 configurations. Whether I get these to a point that I can post some of them for real next week is uncertain, and I certainly won't post them unless I feel they are ready - especially not before I'm happy with the library.
drivers/net/dsa/mv88e6xxx/Kconfig | 1 + drivers/net/dsa/mv88e6xxx/chip.c | 10 + drivers/net/dsa/mv88e6xxx/chip.h | 63 +-- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 664 ++++++++++++------------------ drivers/net/dsa/mv88e6xxx/hwtstamp.h | 26 +- drivers/net/dsa/mv88e6xxx/ptp.c | 527 +++++++++--------------- drivers/net/dsa/mv88e6xxx/ptp.h | 30 +- drivers/net/phy/Kconfig | 13 + drivers/net/phy/Makefile | 1 + drivers/net/phy/marvell.c | 15 +- drivers/net/phy/marvell_ptp.c | 369 +++++++++++++++++ drivers/net/phy/marvell_ptp.h | 17 + drivers/net/phy/phy.c | 3 + drivers/ptp/Kconfig | 4 + drivers/ptp/Makefile | 2 + drivers/ptp/ptp_marvell_tai.c | 445 ++++++++++++++++++++ drivers/ptp/ptp_marvell_ts.c | 778 +++++++++++++++++++++++++++++++++++ include/linux/marvell_ptp.h | 159 +++++++ include/linux/mii_timestamper.h | 3 + 19 files changed, 2318 insertions(+), 812 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
RFC PATCH 1/20 ptp: marvell: add core support for Marvell PTP
Provide core support for the Marvell PTP implementations, which consist of a TAI (time application interface) and timestamping blocks. This hardware can be found in Marvell 88E151x PHYs, Armada 38x and Armada 37xx (mvneta), as well as Marvell DSA devices.
Support for both arrival timestamps is supported, we use arrival 1 for PTP peer delay messages, and arrival 0 for all other messages, which is the same as the Marvell DSA implementation.
External event capture is also supported.
PPS output and trigger generation is not supported.
This core takes inspiration from the existing Marvell 88E6xxx DSA PTP code and DP83640 drivers. Like the original 88E6xxx DSA code, we use a delayed work to keep the cycle counter updated, and a separate delayed work for event capture.
We expose the ptp clock aux work to allow users to support single and multi-port designs. A multi-port design will have a single Marvell TAI instance and one Marvell TS instance per port.
--- drivers/ptp/Kconfig | 4 + drivers/ptp/Makefile | 2 + drivers/ptp/ptp_marvell_tai.c | 445 +++++++++++++++++++ drivers/ptp/ptp_marvell_ts.c | 778 ++++++++++++++++++++++++++++++++++ include/linux/marvell_ptp.h | 159 +++++++ 5 files changed, 1388 insertions(+) create mode 100644 drivers/ptp/ptp_marvell_tai.c create mode 100644 drivers/ptp/ptp_marvell_ts.c create mode 100644 include/linux/marvell_ptp.h
drivers/ptp/Kconfig +4 -0
@@ -184,6 +184,10 @@ config PTP_1588_CLOCK_FC3W To compile this driver as a module, choose M here: the module will be called ptp_fc3. +config PTP_1588_CLOCK_MARVELL + tristate + depends on PTP_1588_CLOCK + config PTP_1588_CLOCK_MOCK tristate "Mock-up PTP clock" depends on PTP_1588_CLOCK
drivers/ptp/Makefile +2 -0
@@ -12,6 +12,8 @@ obj-$(CONFIG_PTP_1588_CLOCK_INES) += ptp_ines.o obj-$(CONFIG_PTP_1588_CLOCK_PCH) += ptp_pch.o obj-$(CONFIG_PTP_1588_CLOCK_KVM) += ptp_kvm.o obj-$(CONFIG_PTP_1588_CLOCK_VMCLOCK) += ptp_vmclock.o +obj-$(CONFIG_PTP_1588_CLOCK_MARVELL) += ptp-marvell.o +ptp-marvell-y := ptp_marvell_tai.o ptp_marvell_ts.o obj-$(CONFIG_PTP_1588_CLOCK_QORIQ) += ptp_qoriq.o obj-$(CONFIG_PTP_1588_CLOCK_IDTCM) += ptp_clockmatrix.o obj-$(CONFIG_PTP_1588_CLOCK_FC3W) += ptp_fc3.o
drivers/ptp/ptp_marvell_tai.c new file +445 -0
445 lines not on this page · raw message
drivers/ptp/ptp_marvell_ts.c new file +778 -0
778 lines not on this page · raw message
include/linux/marvell_ptp.h new file +159 -0
159 lines not on this page · raw message
Signature · 1 line
2.47.3
RFC PATCH 2/20 net: phy: add hwtstamp_get() method for mii timestampers
In reply to Russell King (Oracle)Add the missing hwtstamp_get() method for mii timestampers so PHYs can report their configuration back to userspace.
--- drivers/net/phy/phy.c | 3 +++ include/linux/mii_timestamper.h | 3 +++ 2 files changed, 6 insertions(+)
drivers/net/phy/phy.c +3 -0
@@ -476,6 +476,9 @@ int __phy_hwtstamp_get(struct phy_device *phydev,if (!phydev)return -ENODEV ; +if (phydev->mii_ts && phydev->mii_ts->hwtstamp_get) +return phydev->mii_ts->hwtstamp_get (phydev->mii_ts, config); +return -EOPNOTSUPP ; }
include/linux/mii_timestamper.h +3 -0
@@ -55,6 +55,9 @@ struct mii_timestamper {struct kernel_hwtstamp_config *kernel_config, struct netlink_ext_ack *extack); +int (*hwtstamp_get)(struct mii_timestamper *mii_ts, +struct kernel_hwtstamp_config *kernel_config); +void (*link_state)(struct mii_timestamper *mii_ts,struct phy_device *phydev);
Signature · 1 line
2.47.3
Re: [PATCH RFC net-next 02/20] net: phy: add hwtstamp_get() method for mii timestampers
Quoted 4 lines · Russell King (Oracle)
Add the missing
hwtstamp_get()method for mii timestampers so PHYs can report their configuration back to userspace.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
RFC PATCH 3/20 net: phy: marvell: add PHY PTP support
In reply to Russell King (Oracle)Add PTP basic support for Marvell 88E151x PHYs. These PHYs support timestamping the egress and ingress of packets, but does not support any packet modification, nor do we support any filtering beyond selecting packets that the hardware recognises as PTP/802.1AS.
The PHYs support hardware pins for providing an external clock for the TAI counter, and a separate pin that can be used for event capture or generation of a trigger (either a pulse or periodic). This code does not support either of these modes.
We currently use a delayed work to poll for the timestamps which is far from ideal, but we also provide a function that can be called from an interrupt handler - which would be good to tie into the main Marvell PHY driver.
The driver takes inspiration from the Marvell 88E6xxx DSA and DP83640 drivers. The hardware is very similar to the implementation found in the 88E6xxx DSA driver, but the access methods are very different, although it may be possible to create a library that both can use along with accessor functions.
--- drivers/net/phy/Kconfig | 13 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/marvell.c | 15 +- drivers/net/phy/marvell_ptp.c | 369 ++++++++++++++++++++++++++++++++++ drivers/net/phy/marvell_ptp.h | 17 ++ 5 files changed, 414 insertions(+), 1 deletion(-) create mode 100644 drivers/net/phy/marvell_ptp.c create mode 100644 drivers/net/phy/marvell_ptp.h
drivers/net/phy/Kconfig +13 -0
@@ -253,6 +253,19 @@ config MARVELL_PHY help Currently has a driver for the 88E1XXX +config MARVELL_PHY_PTP + bool "Marvell PHY PTP support" + depends on NETWORK_PHY_TIMESTAMPING + depends on (MARVELL_PHY = y && PTP_1588_CLOCK = y) || \ + (MARVELL_PHY = m && PTP_1588_CLOCK) + select PTP_1588_CLOCK_MARVELL + help + Support PHY timestamping on Marvell 88E1510, 88E1512, 88E1514 + and 88E1518 PHYs. + + N.B. In order for this to be fully functional, your MAC driver + must call the skb_tx_timestamp() function. + config MARVELL_10G_PHY tristate "Marvell Alaska 10Gbit PHYs" help
drivers/net/phy/Makefile +1 -0
@@ -64,6 +64,7 @@ obj-$(CONFIG_ICPLUS_PHY) += icplus.o obj-$(CONFIG_INTEL_XWAY_PHY) += intel-xway.o obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o obj-$(CONFIG_LXT_PHY) += lxt.o +obj-$(CONFIG_MARVELL_PHY_PTP) += marvell_ptp.o obj-$(CONFIG_MARVELL_10G_PHY) += marvell10g.o obj-$(CONFIG_MARVELL_PHY) += marvell.o obj-$(CONFIG_MARVELL_88Q2XXX_PHY) += marvell-88q2xxx.o
drivers/net/phy/marvell.c +14 -1
@@ -38,6 +38,8 @@#include <asm/irq.h> #include <linux/uaccess.h> +#include "marvell_ptp.h" +#define MII_MARVELL_PHY_PAGE 22#define MII_MARVELL_COPPER_PAGE 0x00#define MII_MARVELL_FIBER_PAGE 0x01
@@ -3684,7 +3686,7 @@ static const struct sfp_upstream_ops m88e1510_sfp_ops = { .disconnect_phy = phy_sfp_disconnect_phy, }; -static int m88e1510_probe (struct phy_device *phydev) +static int m88e15xx_probe (struct phy_device *phydev) {int err;
@@ -3695,6 +3697,17 @@ static int m88e1510_probe(struct phy_device *phydev)return phy_sfp_probe (phydev, &m88e1510_sfp_ops); } +static int m88e1510_probe (struct phy_device *phydev) +{ +int err; + + err =m88e15xx_probe (phydev); +if (err) +return err; + +return devm_marvell_phy_ptp_probe (phydev); +} +static struct phy_driver marvell_drivers[] = { { .phy_id =MARVELL_PHY_ID_88E1101 ,
drivers/net/phy/marvell_ptp.c new file +369 -0
369 lines not on this page · raw message
drivers/net/phy/marvell_ptp.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef MARVELL_PTP_H +#define MARVELL_PTP_H + +#if IS_ENABLED (CONFIG_MARVELL_PHY_PTP ) +irqreturn_t marvell_phy_ptp_irq (struct phy_device *phydev); +int devm_marvell_phy_ptp_probe (struct phy_device *phydev); +#else +static inline int marvell_phy_ptp_dummy_probe (void ) +{ +return 0 ; +} +#define devm_marvell_phy_ptp_probe(x...) marvell_phy_ptp_dummy_probe() + +#endif + +#endif
Signature · 1 line
2.47.3
Andrew Lunn
maintainerRe: [PATCH RFC net-next 03/20] net: phy: marvell: add PHY PTP support
Quoted 11 lines
drivers/net/phy/marvell_ptp.c new file +11
-0+static u64 marvell_phy_tai_clock_read (struct device *dev, +struct ptp_system_timestamp *sts) +{ +struct phy_device *phydev =to_phy_device (dev); +int err, oldpage, lo, hi; + + oldpage =phy_select_page (phydev,MARVELL_PAGE_PTP_GLOBAL ); +if (oldpage >=0 ) { +/* 88e151x says to write 0x8e0e */ +ptp_read_system_prets (sts); + err =__phy_write (phydev,PTPG_READPLUS_COMMAND ,0x8e0e );
drivers/net/phy/marvell_ptp.c line 129
Quoted 10 lines
drivers/net/phy/marvell_ptp.c new file +10
-0+ptp_read_system_postts (sts); + lo =__phy_read (phydev,PTPG_READPLUS_DATA ); + hi =__phy_read (phydev,PTPG_READPLUS_DATA ); + } + err =phy_restore_page (phydev, oldpage, err); + +if (err || lo <0 || hi <0 ) +return 0 ; + +return lo | hi <<16 ;
What happens when hi is >= 0x8000? Doesn't that result in undefined behaviour for 32 bit machines? The u64 result we are trying to return is big enough to hold the value. Does the hi need promoting to u64 before doing the shift?
Andrew
Russell King (Oracle)
reviewerRe: [PATCH RFC net-next 03/20] net: phy: marvell: add PHY PTP support
Quoted 18 lines · Andrew Lunn
Quoted 18 lines
drivers/net/phy/marvell_ptp.c new file +18
-0+static u64 marvell_phy_tai_clock_read (struct device *dev, +struct ptp_system_timestamp *sts) +{ +struct phy_device *phydev =to_phy_device (dev); +int err, oldpage, lo, hi; + + oldpage =phy_select_page (phydev,MARVELL_PAGE_PTP_GLOBAL ); +if (oldpage >=0 ) { +/* 88e151x says to write 0x8e0e */ +ptp_read_system_prets (sts); + err =__phy_write (phydev,PTPG_READPLUS_COMMAND ,0x8e0e ); +ptp_read_system_postts (sts); + lo =__phy_read (phydev,PTPG_READPLUS_DATA ); + hi =__phy_read (phydev,PTPG_READPLUS_DATA ); + } + err =phy_restore_page (phydev, oldpage, err); + +if (err || lo <0 || hi <0 )
Quoted 8 lines
drivers/net/phy/marvell_ptp.c line 129
Quoted 3 lines
drivers/net/phy/marvell_ptp.c new file +3
-0+return 0 ; + +return lo | hi <<16 ;What happens when hi is >=
0x8000? Doesn't that result in undefined behaviour for 32 bit machines? The u64 result we are trying to return is big enough to hold the value. Does the hi need promoting to u64 before doing the shift?
Good point - looking at the generated code, it gets sign-extended to a 64 bit value. So, hi=0x8000 results in 0xffffffff8000XXXX being returned.
Does it matter? There are two functions that call the cyclecounter ->read() method. timecounter_init() sets ->cycle_last from the value, and timecounter_read_delta() does this:
cycle_delta = (cycle_now - tc->cycle_last) & tc->cc->mask;
before updating ->cycle_last with the returned value. As the mask is initialised thusly:
tai->cyclecounter.mask = CYCLECOUNTER_MASK(32);
this masks off the sign-extended high 32-bits, giving us back a value of 0x8000XXXX.
So, while the sign extension is undesirable, it has no effect on the operation. Is it worth throwing casts in the code? I suspect that's a matter of personal opinion.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Andrew Lunn
maintainerRe: [PATCH RFC net-next 03/20] net: phy: marvell: add PHY PTP support
Quoted 41 lines · Russell King (Oracle)
Quoted 18 lines · Andrew Lunn
Quoted 18 lines
drivers/net/phy/marvell_ptp.c new file +18
-0+static u64 marvell_phy_tai_clock_read (struct device *dev, +struct ptp_system_timestamp *sts) +{ +struct phy_device *phydev =to_phy_device (dev); +int err, oldpage, lo, hi; + + oldpage =phy_select_page (phydev,MARVELL_PAGE_PTP_GLOBAL ); +if (oldpage >=0 ) { +/* 88e151x says to write 0x8e0e */ +ptp_read_system_prets (sts); + err =__phy_write (phydev,PTPG_READPLUS_COMMAND ,0x8e0e ); +ptp_read_system_postts (sts); + lo =__phy_read (phydev,PTPG_READPLUS_DATA ); + hi =__phy_read (phydev,PTPG_READPLUS_DATA ); + } + err =phy_restore_page (phydev, oldpage, err); + +if (err || lo <0 || hi <0 )Quoted 8 lines
drivers/net/phy/marvell_ptp.c line 129
Quoted 3 lines
drivers/net/phy/marvell_ptp.c new file +3
-0+return 0 ; + +return lo | hi <<16 ;What happens when hi is >=
0x8000? Doesn't that result in undefined behaviour for 32 bit machines? The u64 result we are trying to return is big enough to hold the value. Does the hi need promoting to u64 before doing the shift?Good point - looking at the generated code, it gets sign-extended to a 64 bit value. So, hi=0x8000 results in 0xffffffff8000XXXX being returned.
Does it matter? There are two functions that call the cyclecounter ->read() method.
timecounter_init()sets ->cycle_last from the value, andtimecounter_read_delta()does this:cycle_delta = (cycle_now - tc->cycle_last) & tc->cc->mask;before updating ->cycle_last with the returned value. As the mask is initialised thusly:
Quoted 8 lines
tai->cyclecounter.mask = CYCLECOUNTER_MASK(32);this masks off the sign-extended high 32-bits, giving us back a value of 0x8000XXXX.
So, while the sign extension is undesirable, it has no effect on the operation. Is it worth throwing casts in the code? I suspect that's a matter of personal opinion.
I doubt the static analysers can do such a detailed analysis. So at some point we are going to get patches adding a cast. You could maybe change hi to a signed 64. That would avoid adding a cast, while still being O.K. to hold a negative error code from __phy_read().
Andrew
RFC PATCH 4/20 net: dsa: mv88e6xxx: split out set_ptp_cpu_port() code
In reply to Russell King (Oracle)Split out the code which sets up the upstream CPU port for PTP. This will be required when converted to the generic Marvell PTP library.
--- drivers/net/dsa/mv88e6xxx/ptp.c | 42 ++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-)
drivers/net/dsa/mv88e6xxx/ptp.c +25 -17
@@ -444,6 +444,27 @@ const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = { (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ), }; +static int mv88e6xxx_set_ptp_cpu_port (struct mv88e6xxx_chip *chip) +{ +struct dsa_port *dp; +int upstream =0 ; +int err; + +if (!chip->info->ops->ptp_ops->set_ptp_cpu_port) +return 0 ; + +dsa_switch_for_each_user_port (dp, chip->ds) { + upstream =dsa_upstream_port (chip->ds, dp->index); +break ; + } + + err = chip->info->ops->ptp_ops->set_ptp_cpu_port (chip, upstream); +if (err) +dev_err (chip->dev,"Failed to set PTP CPU destination port!\n" ); + +return err; +} +static u64 mv88e6xxx_ptp_clock_read (struct cyclecounter *cc) {struct mv88e6xxx_chip *chip =cc_to_chip (cc);
@@ -473,7 +494,7 @@ static void mv88e6xxx_ptp_overflow_check(struct work_struct *work)int mv88e6xxx_ptp_setup (struct mv88e6xxx_chip *chip) {const struct mv88e6xxx_ptp_ops *ptp_ops = chip->info->ops->ptp_ops; -int i; +int err, i;/* Set up the cycle counter */ chip->cc_coeffs =mv88e6xxx_cc_coeff_get (chip);
@@ -524,22 +545,9 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip)PTP_FALLING_EDGE |PTP_STRICT_FLAGS ; -if (ptp_ops->set_ptp_cpu_port) { -struct dsa_port *dp; -int upstream =0 ; -int err; - -dsa_switch_for_each_user_port (dp, chip->ds) { - upstream =dsa_upstream_port (chip->ds, dp->index); -break ; - } - - err = ptp_ops->set_ptp_cpu_port (chip, upstream); -if (err) { -dev_err (chip->dev,"Failed to set PTP CPU destination port!\n" ); -return err; - } - } + err =mv88e6xxx_set_ptp_cpu_port (chip); +if (err) +return err; chip->ptp_clock =ptp_clock_register (&chip->ptp_clock_info, chip->dev);if (IS_ERR (chip->ptp_clock))
Signature · 1 line
2.47.3
Andrew Lunn
maintainerRe: [PATCH RFC net-next 04/20] net: dsa: mv88e6xxx: split out set_ptp_cpu_port() code
Quoted 19 lines · Russell King (Oracle)
Split out the code which sets up the upstream CPU port for PTP. This will be required when converted to the generic Marvell PTP library.
Signed-off-by Russell King (Oracle) <[email protected]>--- drivers/net/dsa/mv88e6xxx/ptp.c | 42 ++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-)drivers/net/dsa/mv88e6xxx/ptp.c +3
-0@@ -444,6 +444,27 @@ const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = { (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ), }; +static int mv88e6xxx_set_ptp_cpu_port (struct mv88e6xxx_chip *chip) +{ +struct dsa_port *dp;
drivers/net/dsa/mv88e6xxx/ptp.c const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = { · line 459
Quoted 10 lines
drivers/net/dsa/mv88e6xxx/ptp.c +10
-0+int upstream =0 ; +int err; + +if (!chip->info->ops->ptp_ops->set_ptp_cpu_port) +return 0 ; + +dsa_switch_for_each_user_port (dp, chip->ds) { + upstream =dsa_upstream_port (chip->ds, dp->index); +break ; + }
I think you can use dsa_switch_upstream_port(chip->ds);
It will look less odd than this loop construct.
drivers/net/dsa/mv88e6xxx/ptp.c int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip) · line 535
Quoted 9 lines
drivers/net/dsa/mv88e6xxx/ptp.c +0
-9-if (ptp_ops->set_ptp_cpu_port) { -struct dsa_port *dp; -int upstream =0 ; -int err; - -dsa_switch_for_each_user_port (dp, chip->ds) { - upstream =dsa_upstream_port (chip->ds, dp->index); -break ; - }
Although i see you copied it from here. So keep it if you want.
Andrew
RFC PATCH 5/20 net: dsa: mv88e6xxx: convert PTP clock_read() method to take chip
In reply to Russell King (Oracle)The various clock_read() method implementations do not make use of the passed struct cycle_counter except to convert to the parent struct mv88e6xxx_chip. The caller of these methods has already done this.
Pass a pointer to struct mv88e6xxx_chip instead.
--- drivers/net/dsa/mv88e6xxx/chip.h | 2 +- drivers/net/dsa/mv88e6xxx/ptp.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +1 -1
@@ -730,7 +730,7 @@ struct mv88e6xxx_avb_ops { };struct mv88e6xxx_ptp_ops { -u64 (*clock_read)(struct cyclecounter *cc); +u64 (*clock_read)(struct mv88e6xxx_chip *chip);int (*ptp_enable)(struct ptp_clock_info *ptp,struct ptp_clock_request *rq,int on); int (*ptp_verify)(struct ptp_clock_info *ptp, unsigned int pin,
drivers/net/dsa/mv88e6xxx/ptp.c +3 -5
@@ -138,9 +138,8 @@ mv88e6xxx_cc_coeff_get(struct mv88e6xxx_chip *chip) } } -static u64 mv88e6352_ptp_clock_read (struct cyclecounter *cc) +static u64 mv88e6352_ptp_clock_read (struct mv88e6xxx_chip *chip) { -struct mv88e6xxx_chip *chip =cc_to_chip (cc);u16 phc_time[2 ];int err;
@@ -152,9 +151,8 @@ static u64 mv88e6352_ptp_clock_read(struct cyclecounter *cc)return ((u32 )phc_time[1 ] <<16 ) | phc_time[0 ]; } -static u64 mv88e6165_ptp_clock_read (struct cyclecounter *cc) +static u64 mv88e6165_ptp_clock_read (struct mv88e6xxx_chip *chip) { -struct mv88e6xxx_chip *chip =cc_to_chip (cc);u16 phc_time[2 ];int err;
@@ -470,7 +468,7 @@ static u64 mv88e6xxx_ptp_clock_read(struct cyclecounter *cc)struct mv88e6xxx_chip *chip =cc_to_chip (cc);if (chip->info->ops->ptp_ops->clock_read) -return chip->info->ops->ptp_ops->clock_read (cc); +return chip->info->ops->ptp_ops->clock_read (chip);return 0 ; }
Signature · 1 line
2.47.3
Re: [PATCH RFC net-next 05/20] net: dsa: mv88e6xxx: convert PTP clock_read() method to take chip
Quoted 7 lines · Russell King (Oracle)
The various
clock_read()method implementations do not make use of the passed structcycle_counterexcept to convert to the parent structmv88e6xxx_chip. The caller of these methods has already done this.Pass a pointer to struct
mv88e6xxx_chipinstead.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
RFC PATCH 6/20 net: dsa: mv88e6xxx: convert PTP ptp_verify() method to take chip
In reply to Russell King (Oracle)Wrap the ptp_ops->ptp_verify() method and convert it to take struct mv88e6xxx_chip. This eases the transition to generic Marvell PTP.
--- drivers/net/dsa/mv88e6xxx/chip.h | 2 +- drivers/net/dsa/mv88e6xxx/ptp.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +1 -1
@@ -733,7 +733,7 @@ struct mv88e6xxx_ptp_ops {u64 (*clock_read)(struct mv88e6xxx_chip *chip);int (*ptp_enable)(struct ptp_clock_info *ptp,struct ptp_clock_request *rq,int on); -int (*ptp_verify)(struct ptp_clock_info *ptp,unsigned int pin, +int (*ptp_verify)(struct mv88e6xxx_chip *chip,unsigned int pin,enum ptp_pin_function func,unsigned int chan);void (*event_work)(struct work_struct *ugly);int (*port_enable)(struct mv88e6xxx_chip *chip,int port);
drivers/net/dsa/mv88e6xxx/ptp.c +10 -2
@@ -306,6 +306,14 @@ static int mv88e6xxx_ptp_settime(struct ptp_clock_info *ptp,return 0 ; } +static int mv88e6xxx_ptp_verify (struct ptp_clock_info *ptp,unsigned int pin, +enum ptp_pin_function func,unsigned int chan) +{ +struct mv88e6xxx_chip *chip =ptp_to_chip (ptp); + +return chip->info->ops->ptp_ops->ptp_verify (chip, pin, func, chan); +} +static int mv88e6352_ptp_enable_extts (struct mv88e6xxx_chip *chip,struct ptp_clock_request *rq,int on) {
@@ -365,7 +373,7 @@ static int mv88e6352_ptp_enable(struct ptp_clock_info *ptp, } } -static int mv88e6352_ptp_verify (struct ptp_clock_info *ptp,unsigned int pin, +static int mv88e6352_ptp_verify (struct mv88e6xxx_chip *chip,unsigned int pin,enum ptp_pin_function func,unsigned int chan) {switch (func) {
@@ -536,7 +544,7 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip) chip->ptp_clock_info.gettime64 = mv88e6xxx_ptp_gettime; chip->ptp_clock_info.settime64 = mv88e6xxx_ptp_settime; chip->ptp_clock_info.enable = ptp_ops->ptp_enable; - chip->ptp_clock_info.verify = ptp_ops->ptp_verify; + chip->ptp_clock_info.verify = mv88e6xxx_ptp_verify; chip->ptp_clock_info.do_aux_work = mv88e6xxx_hwtstamp_work; chip->ptp_clock_info.supported_extts_flags = PTP_RISING_EDGE |
Signature · 1 line
2.47.3
Re: [PATCH RFC net-next 06/20] net: dsa: mv88e6xxx: convert PTP ptp_verify() method to take chip
Quoted 5 lines · Russell King (Oracle)
Wrap the
ptp_ops->ptp_verify()method and convert it to take structmv88e6xxx_chip. This eases the transition to generic Marvell PTP.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
RFC PATCH 7/20 net: dsa: mv88e6xxx: convert PTP ptp_enable() method to take chip
In reply to Russell King (Oracle)Wrap the ptp_ops->ptp_enable() method and convert it to take struct mv88e6xxx_chip. This eases the transition to generic Marvell PTP.
--- drivers/net/dsa/mv88e6xxx/chip.h | 2 +- drivers/net/dsa/mv88e6xxx/ptp.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +1 -1
@@ -731,7 +731,7 @@ struct mv88e6xxx_avb_ops {struct mv88e6xxx_ptp_ops {u64 (*clock_read)(struct mv88e6xxx_chip *chip); -int (*ptp_enable)(struct ptp_clock_info *ptp, +int (*ptp_enable)(struct mv88e6xxx_chip *chip,struct ptp_clock_request *rq,int on);int (*ptp_verify)(struct mv88e6xxx_chip *chip,unsigned int pin,enum ptp_pin_function func,unsigned int chan);
drivers/net/dsa/mv88e6xxx/ptp.c +10 -4
@@ -306,6 +306,14 @@ static int mv88e6xxx_ptp_settime(struct ptp_clock_info *ptp,return 0 ; } +static int mv88e6xxx_ptp_enable (struct ptp_clock_info *ptp, +struct ptp_clock_request *req,int enable) +{ +struct mv88e6xxx_chip *chip =ptp_to_chip (ptp); + +return chip->info->ops->ptp_ops->ptp_enable (chip, req, enable); +} +static int mv88e6xxx_ptp_verify (struct ptp_clock_info *ptp,unsigned int pin,enum ptp_pin_function func,unsigned int chan) {
@@ -360,11 +368,9 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip,return err; } -static int mv88e6352_ptp_enable (struct ptp_clock_info *ptp, +static int mv88e6352_ptp_enable (struct mv88e6xxx_chip *chip,struct ptp_clock_request *rq,int on) { -struct mv88e6xxx_chip *chip =ptp_to_chip (ptp); -switch (rq->type) {case PTP_CLK_REQ_EXTTS :return mv88e6352_ptp_enable_extts (chip, rq, on);
@@ -543,7 +549,7 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip) chip->ptp_clock_info.adjtime = mv88e6xxx_ptp_adjtime; chip->ptp_clock_info.gettime64 = mv88e6xxx_ptp_gettime; chip->ptp_clock_info.settime64 = mv88e6xxx_ptp_settime; - chip->ptp_clock_info.enable = ptp_ops->ptp_enable; + chip->ptp_clock_info.enable = mv88e6xxx_ptp_enable; chip->ptp_clock_info.verify = mv88e6xxx_ptp_verify; chip->ptp_clock_info.do_aux_work = mv88e6xxx_hwtstamp_work;
Signature · 1 line
2.47.3
Re: [PATCH RFC net-next 07/20] net: dsa: mv88e6xxx: convert PTP ptp_enable() method to take chip
Quoted 5 lines · Russell King (Oracle)
Wrap the
ptp_ops->ptp_enable()method and convert it to take structmv88e6xxx_chip. This eases the transition to generic Marvell PTP.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
RFC PATCH 8/20 net: dsa: mv88e6xxx: convert mv88e6xxx_hwtstamp_work() to take chip
In reply to Russell King (Oracle)Instead of passing a pointer to the ptp_clock_info structure, pass a pointer to mv88e6xxx_chip instead. This allows the transition to the generic marvell PTP library easier.
--- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 3 +-- drivers/net/dsa/mv88e6xxx/hwtstamp.h | 2 +- drivers/net/dsa/mv88e6xxx/ptp.c | 7 ++++++- 3 files changed, 8 insertions(+), 4 deletions(-)
drivers/net/dsa/mv88e6xxx/hwtstamp.c +1 -2
@@ -439,9 +439,8 @@ static int mv88e6xxx_txtstamp_work(struct mv88e6xxx_chip *chip,return 0 ; } -long mv88e6xxx_hwtstamp_work (struct ptp_clock_info *ptp) +long mv88e6xxx_hwtstamp_work (struct mv88e6xxx_chip *chip) { -struct mv88e6xxx_chip *chip =ptp_to_chip (ptp);struct dsa_switch *ds = chip->ds;struct mv88e6xxx_port_hwtstamp *ps;int i, restart =0 ;
drivers/net/dsa/mv88e6xxx/hwtstamp.h +1 -1
@@ -124,7 +124,7 @@ void mv88e6xxx_port_txtstamp(struct dsa_switch *ds, int port,int mv88e6xxx_get_ts_info (struct dsa_switch *ds,int port,struct kernel_ethtool_ts_info *info); -long mv88e6xxx_hwtstamp_work (struct ptp_clock_info *ptp); +long mv88e6xxx_hwtstamp_work (struct mv88e6xxx_chip *chip);int mv88e6xxx_hwtstamp_setup (struct mv88e6xxx_chip *chip);void mv88e6xxx_hwtstamp_free (struct mv88e6xxx_chip *chip);int mv88e6352_hwtstamp_port_enable (struct mv88e6xxx_chip *chip,int port);
drivers/net/dsa/mv88e6xxx/ptp.c +6 -1
@@ -503,6 +503,11 @@ static void mv88e6xxx_ptp_overflow_check(struct work_struct *work) MV88E6XXX_TAI_OVERFLOW_PERIOD); } +static long mv88e6xxx_ptp_aux_work (struct ptp_clock_info *ptp) +{ +return mv88e6xxx_hwtstamp_work (ptp_to_chip (ptp)); +} +int mv88e6xxx_ptp_setup (struct mv88e6xxx_chip *chip) {const struct mv88e6xxx_ptp_ops *ptp_ops = chip->info->ops->ptp_ops;
@@ -551,7 +556,7 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip) chip->ptp_clock_info.settime64 = mv88e6xxx_ptp_settime; chip->ptp_clock_info.enable = mv88e6xxx_ptp_enable; chip->ptp_clock_info.verify = mv88e6xxx_ptp_verify; - chip->ptp_clock_info.do_aux_work = mv88e6xxx_hwtstamp_work; + chip->ptp_clock_info.do_aux_work = mv88e6xxx_ptp_aux_work; chip->ptp_clock_info.supported_extts_flags =PTP_RISING_EDGE | PTP_FALLING_EDGE |
Signature · 1 line
2.47.3
Re: [PATCH RFC net-next 08/20] net: dsa: mv88e6xxx: convert mv88e6xxx_hwtstamp_work() to take chip
Quoted 5 lines · Russell King (Oracle)
Instead of passing a pointer to the
ptp_clock_infostructure, pass a pointer tomv88e6xxx_chipinstead. This allows the transition to the generic marvell PTP library easier.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
RFC PATCH 9/20 net: dsa: mv88e6xxx: always verify PTP_PF_NONE
In reply to Russell King (Oracle)Setting a pin to "no function" should always be supported. Move this to mv88e6xxx_ptp_verify(). This allows mv88e6352_ptp_verify() to be simplified as the only supported PTP pin mode function is PTP_PF_EXTTS.
--- drivers/net/dsa/mv88e6xxx/ptp.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/dsa/mv88e6xxx/ptp.c +6 -7
@@ -319,6 +319,10 @@ static int mv88e6xxx_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin, {struct mv88e6xxx_chip *chip =ptp_to_chip (ptp); +/* Always allow a pin to be set to no function */ +if (func ==PTP_PF_NONE ) +return 0 ; +return chip->info->ops->ptp_ops->ptp_verify (chip, pin, func, chan); }
@@ -382,14 +386,9 @@ static int mv88e6352_ptp_enable(struct mv88e6xxx_chip *chip,static int mv88e6352_ptp_verify (struct mv88e6xxx_chip *chip,unsigned int pin,enum ptp_pin_function func,unsigned int chan) { -switch (func) { -case PTP_PF_NONE : -case PTP_PF_EXTTS : -break ; -case PTP_PF_PEROUT : -case PTP_PF_PHYSYNC : +if (func !=PTP_PF_EXTTS )return -EOPNOTSUPP ; - } +return 0 ; }
Signature · 1 line
2.47.3
Re: [PATCH RFC net-next 09/20] net: dsa: mv88e6xxx: always verify PTP_PF_NONE
Quoted 6 lines · Russell King (Oracle)
Setting a pin to "no function" should always be supported. Move this to
mv88e6xxx_ptp_verify(). This allowsmv88e6352_ptp_verify()to be simplified as the only supported PTP pin mode function isPTP_PF_EXTTS.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
RFC PATCH 10/20 net: dsa: mv88e6xxx: only support EXTTS for pins
In reply to Russell King (Oracle)The sole implementation for the PTP verify/enable methods only supports the EXTTS function. Move these checks into mv88e6xxx_ptp_verify() and mv88e6xxx_ptp_enable(), renaming the ptp_enable() method to ptp_enable_extts().
--- drivers/net/dsa/mv88e6xxx/chip.h | 4 ++-- drivers/net/dsa/mv88e6xxx/ptp.c | 26 +++++++++----------------- 2 files changed, 11 insertions(+), 19 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +2 -2
@@ -731,8 +731,8 @@ struct mv88e6xxx_avb_ops {struct mv88e6xxx_ptp_ops {u64 (*clock_read)(struct mv88e6xxx_chip *chip); -int (*ptp_enable)(struct mv88e6xxx_chip *chip, -struct ptp_clock_request *rq,int on); +int (*ptp_enable_extts)(struct mv88e6xxx_chip *chip, +struct ptp_clock_request *rq,int on);int (*ptp_verify)(struct mv88e6xxx_chip *chip,unsigned int pin,enum ptp_pin_function func,unsigned int chan);void (*event_work)(struct work_struct *ugly);
drivers/net/dsa/mv88e6xxx/ptp.c +9 -17
@@ -311,7 +311,10 @@ static int mv88e6xxx_ptp_enable(struct ptp_clock_info *ptp, {struct mv88e6xxx_chip *chip =ptp_to_chip (ptp); -return chip->info->ops->ptp_ops->ptp_enable (chip, req, enable); +if (req->type !=PTP_CLK_REQ_EXTTS ) +return -EOPNOTSUPP ; + +return chip->info->ops->ptp_ops->ptp_enable_extts (chip, req, enable); } static int mv88e6xxx_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
@@ -323,6 +326,9 @@ static int mv88e6xxx_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,if (func ==PTP_PF_NONE )return 0 ; +if (func !=PTP_PF_EXTTS ) +return -EOPNOTSUPP ; +return chip->info->ops->ptp_ops->ptp_verify (chip, pin, func, chan); }
@@ -372,23 +378,9 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip,return err; } -static int mv88e6352_ptp_enable (struct mv88e6xxx_chip *chip, -struct ptp_clock_request *rq,int on) -{ -switch (rq->type) { -case PTP_CLK_REQ_EXTTS : -return mv88e6352_ptp_enable_extts (chip, rq, on); -default : -return -EOPNOTSUPP ; - } -} -static int mv88e6352_ptp_verify (struct mv88e6xxx_chip *chip,unsigned int pin,enum ptp_pin_function func,unsigned int chan) { -if (func !=PTP_PF_EXTTS ) -return -EOPNOTSUPP ; -return 0 ; }
@@ -410,7 +402,7 @@ const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops = {const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = { .clock_read = mv88e6352_ptp_clock_read, - .ptp_enable = mv88e6352_ptp_enable, + .ptp_enable_extts = mv88e6352_ptp_enable_extts, .ptp_verify = mv88e6352_ptp_verify, .event_work = mv88e6352_tai_event_work, .port_enable = mv88e6352_hwtstamp_port_enable,
@@ -433,7 +425,7 @@ const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = {const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = { .clock_read = mv88e6352_ptp_clock_read, - .ptp_enable = mv88e6352_ptp_enable, + .ptp_enable_extts = mv88e6352_ptp_enable_extts, .ptp_verify = mv88e6352_ptp_verify, .event_work = mv88e6352_tai_event_work, .port_enable = mv88e6352_hwtstamp_port_enable,
Signature · 1 line
2.47.3
Re: [PATCH RFC net-next 10/20] net: dsa: mv88e6xxx: only support EXTTS for pins
Quoted 4 lines · Russell King (Oracle)
The sole implementation for the PTP verify/enable methods only supports the EXTTS function. Move these checks into
mv88e6xxx_ptp_verify()andmv88e6xxx_ptp_enable(), renaming theptp_enable()method toptp_enable_extts().
It would be great to add .supported_extts_flags as well to allow PTP_EXTTS_REQUEST2, take a look at changes in:
https://lore.kernel.org/netdev/20250919103928.3ab57aa2@kmaincent-XPS-13-7390/T/#m579d718f36b2368e476eb400e235fe28f0bd03ff
Russell King (Oracle)
reviewerRe: [PATCH RFC net-next 10/20] net: dsa: mv88e6xxx: only support EXTTS for pins
Quoted 9 lines · Vadim Fedorenko
Quoted 4 lines · Russell King (Oracle)
The sole implementation for the PTP verify/enable methods only supports the EXTTS function. Move these checks into
mv88e6xxx_ptp_verify()andmv88e6xxx_ptp_enable(), renaming theptp_enable()method toptp_enable_extts().It would be great to add .supported_extts_flags as well to allow
PTP_EXTTS_REQUEST2, take a look at changes in:
https://lore.kernel.org/netdev/20250919103928.3ab57aa2@kmaincent-XPS-13-7390/T/#m579d718f36b2368e476eb400e235fe28f0bd03ff
Marvell DSA already supports .supported_extts_flags, and my changes aim to do nothing to regress anything that was already supported. I consider any such regression to be a bug when doing projects like this.
Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
RFC PATCH 11/20 net: dsa: mv88e6xxx: split out EXTTS pin setup
In reply to Russell King (Oracle)Split out the EXTTS pin setup from the extts configuration.
--- drivers/net/dsa/mv88e6xxx/ptp.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-)
drivers/net/dsa/mv88e6xxx/ptp.c +19 -14
@@ -111,6 +111,20 @@ static int mv88e6352_set_gpio_func(struct mv88e6xxx_chip *chip, int pin,return chip->info->ops->gpio_ops->set_pctl (chip, pin, func); } +static int mv88e6352_ptp_pin_setup (struct mv88e6xxx_chip *chip,int pin, +enum ptp_pin_function func,int enable) +{ +if (func !=PTP_PF_EXTTS ) +return -EOPNOTSUPP ; + +if (enable) + func =MV88E6352_G2_SCRATCH_GPIO_PCTL_EVREQ ; +else + func =MV88E6352_G2_SCRATCH_GPIO_PCTL_GPIO ; + +return mv88e6352_set_gpio_func (chip, pin, func, true); +} +static const struct mv88e6xxx_cc_coeffs *mv88e6xxx_cc_coeff_get (struct mv88e6xxx_chip *chip) {
@@ -352,27 +366,18 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip,return -EBUSY ;mv88e6xxx_reg_lock (chip); + err =mv88e6352_ptp_pin_setup (chip, pin,PTP_PF_EXTTS , on); -if (on) { - func =MV88E6352_G2_SCRATCH_GPIO_PCTL_EVREQ ; - - err =mv88e6352_set_gpio_func (chip, pin, func, true); -if (err) - goto out; - +if (!on) { +/* Always cancel the work, even if an error occurs */ +cancel_delayed_work_sync (&chip->tai_event_work); + }else if (!err) {schedule_delayed_work (&chip->tai_event_work,TAI_EVENT_WORK_INTERVAL ); err =mv88e6352_config_eventcap (chip, rising); - }else { - func =MV88E6352_G2_SCRATCH_GPIO_PCTL_GPIO ; - - err =mv88e6352_set_gpio_func (chip, pin, func, true); - -cancel_delayed_work_sync (&chip->tai_event_work); } -out:mv88e6xxx_reg_unlock (chip);return err;
Signature · 1 line
2.47.3
Re: [PATCH RFC net-next 11/20] net: dsa: mv88e6xxx: split out EXTTS pin setup
Quoted 7 lines
static const struct
mv88e6xxx_cc_coeffs*mv88e6xxx_cc_coeff_get(struct mv88e6xxx_chip *chip){drivers/net/dsa/mv88e6xxx/ptp.c +0
-0@@ -352,27 +366,18 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip,return -EBUSY ;mv88e6xxx_reg_lock (chip);
drivers/net/dsa/mv88e6xxx/ptp.c static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip, · line 371
Quoted 10 lines
drivers/net/dsa/mv88e6xxx/ptp.c +2
-7+ err =mv88e6352_ptp_pin_setup (chip, pin,PTP_PF_EXTTS , on); -if (on) { - func =MV88E6352_G2_SCRATCH_GPIO_PCTL_EVREQ ; - - err =mv88e6352_set_gpio_func (chip, pin, func, true); -if (err) - goto out; - +if (!on) {
Inverting the if () makes this a little bit harder to review. But it does remove a goto. I probably would of kept the code in the same order. But:
Andrew
Russell King (Oracle)
reviewerRe: [PATCH RFC net-next 11/20] net: dsa: mv88e6xxx: split out EXTTS pin setup
Quoted 22 lines · Andrew Lunn
Quoted 7 lines
static const struct
mv88e6xxx_cc_coeffs*mv88e6xxx_cc_coeff_get(struct mv88e6xxx_chip *chip){drivers/net/dsa/mv88e6xxx/ptp.c +0
-0@@ -352,27 +366,18 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip,return -EBUSY ;mv88e6xxx_reg_lock (chip);drivers/net/dsa/mv88e6xxx/ptp.c static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip, · line 371
Quoted 10 lines
drivers/net/dsa/mv88e6xxx/ptp.c +2
-7+ err =mv88e6352_ptp_pin_setup (chip, pin,PTP_PF_EXTTS , on); -if (on) { - func =MV88E6352_G2_SCRATCH_GPIO_PCTL_EVREQ ; - - err =mv88e6352_set_gpio_func (chip, pin, func, true); -if (err) - goto out; - +if (!on) {Inverting the if () makes this a little bit harder to review. But it does remove a goto. I probably would of kept the code in the same order. But:
Quoted 1 line
Reviewed-by Andrew Lunn <[email protected]>
It's not the goto, but:
if (on && !err) {
schedule_delayed_work(&chip->tai_event_work,
TAI_EVENT_WORK_INTERVAL);
err = mv88e6352_config_eventcap(chip, rising);
} else if (!on) {
/* Always cancel the work, even if an error occurs */
cancel_delayed_work_sync(&chip->tai_event_work);
}would be the alternative, which is IMHO less readable, and more error-prone. However, there is an issue that if mv88e6352_config_eventcap() returns an error, we leave the work scheduled. So maybe:
if (on && !err) {
schedule_delayed_work(&chip->tai_event_work,
TAI_EVENT_WORK_INTERVAL);
err = mv88e6352_config_eventcap(chip, rising);
}
if (!on || err) {
/* Always cancel the work, even if an error occurs */
cancel_delayed_work_sync(&chip->tai_event_work);
}which is more difficult to get one's head around.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
RFC PATCH 12/20 net: dsa: mv88e6xxx: move EXTTS flag validation and pin lookup
In reply to Russell King (Oracle)Move the flag validation and pin lookup to mv88e6xxx_ptp_enable() mv88e6352_ptp_enable_extts().
--- drivers/net/dsa/mv88e6xxx/chip.h | 2 +- drivers/net/dsa/mv88e6xxx/ptp.c | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +1 -1
@@ -732,7 +732,7 @@ struct mv88e6xxx_avb_ops {struct mv88e6xxx_ptp_ops {u64 (*clock_read)(struct mv88e6xxx_chip *chip);int (*ptp_enable_extts)(struct mv88e6xxx_chip *chip, -struct ptp_clock_request *rq,int on); +struct ptp_clock_request *rq,int pin,int on);int (*ptp_verify)(struct mv88e6xxx_chip *chip,unsigned int pin,enum ptp_pin_function func,unsigned int chan);void (*event_work)(struct work_struct *ugly);
drivers/net/dsa/mv88e6xxx/ptp.c +15 -14
@@ -324,11 +324,23 @@ static int mv88e6xxx_ptp_enable(struct ptp_clock_info *ptp, struct ptp_clock_request *req, int enable) {struct mv88e6xxx_chip *chip =ptp_to_chip (ptp); +int pin;if (req->type !=PTP_CLK_REQ_EXTTS )return -EOPNOTSUPP ; -return chip->info->ops->ptp_ops->ptp_enable_extts (chip, req, enable); +/* Reject requests to enable time stamping on both edges. */ +if (req->extts.flags &PTP_STRICT_FLAGS && + req->extts.flags &PTP_ENABLE_FEATURE && + (req->extts.flags &PTP_EXTTS_EDGES ) ==PTP_EXTTS_EDGES ) +return -EOPNOTSUPP ; + + pin =ptp_find_pin (chip->ptp_clock,PTP_PF_EXTTS , req->extts.index); +if (pin <0 ) +return -EBUSY ; + +return chip->info->ops->ptp_ops->ptp_enable_extts (chip, req, pin, + enable); } static int mv88e6xxx_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
@@ -347,24 +359,13 @@ static int mv88e6xxx_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin, }static int mv88e6352_ptp_enable_extts (struct mv88e6xxx_chip *chip, -struct ptp_clock_request *rq,int on) +struct ptp_clock_request *rq,int pin, +int on) {int rising = (rq->extts.flags &PTP_RISING_EDGE );int func; -int pin;int err; -/* Reject requests to enable time stamping on both edges. */ -if ((rq->extts.flags &PTP_STRICT_FLAGS ) && - (rq->extts.flags &PTP_ENABLE_FEATURE ) && - (rq->extts.flags &PTP_EXTTS_EDGES ) ==PTP_EXTTS_EDGES ) -return -EOPNOTSUPP ; - - pin =ptp_find_pin (chip->ptp_clock,PTP_PF_EXTTS , rq->extts.index); - -if (pin <0 ) -return -EBUSY ; -mv88e6xxx_reg_lock (chip); err =mv88e6352_ptp_pin_setup (chip, pin,PTP_PF_EXTTS , on);
Signature · 1 line
2.47.3
RFC PATCH 13/20 net: dsa: mv88e6xxx: convert to marvell TAI
In reply to Russell King (Oracle)Convert Marvell PTP timekeeping to use the Marvell PTP library TAI implementation which is functionally identical (and was derived from the mv88e6xxx code.)
Unfortunately, there is no progressive way to switch this over.
Note that the Marvell PTP TAI library has to be initialised without the mv88e6xxx lock held, so we split the initialisation into two parts.
--- drivers/net/dsa/mv88e6xxx/Kconfig | 1 + drivers/net/dsa/mv88e6xxx/chip.c | 6 + drivers/net/dsa/mv88e6xxx/chip.h | 26 +- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 14 +- drivers/net/dsa/mv88e6xxx/ptp.c | 473 ++++++++++----------------- drivers/net/dsa/mv88e6xxx/ptp.h | 30 +- 6 files changed, 194 insertions(+), 356 deletions(-)
drivers/net/dsa/mv88e6xxx/Kconfig +1 -0
@@ -14,6 +14,7 @@ config NET_DSA_MV88E6XXX_PTP default n depends on (NET_DSA_MV88E6XXX = y && PTP_1588_CLOCK = y) || \ (NET_DSA_MV88E6XXX = m && PTP_1588_CLOCK) + select PTP_1588_CLOCK_MARVELL help Say Y to enable PTP hardware timestamping on Marvell 88E6xxx switch chips that support it.
drivers/net/dsa/mv88e6xxx/chip.c +6 -0
@@ -4109,6 +4109,12 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)if (err) goto out_hwtstamp; +if (chip->info->ptp_support) { + err =mv88e6xxx_ptp_setup_unlocked (chip); +if (err) + goto out_hwtstamp; + } +/* Have to be called without holding the register lock, since * they take the devlink lock, and we later take the locks in * the reverse order when getting/setting parameters or
drivers/net/dsa/mv88e6xxx/chip.h +12 -14
@@ -14,6 +14,7 @@#include <linux/gpio/consumer.h> #include <linux/kthread.h> #include <linux/leds.h> +#include <linux/marvell_ptp.h> #include <linux/phy.h> #include <linux/property.h> #include <linux/ptp_clock_kernel.h>
@@ -412,17 +413,8 @@ struct mv88e6xxx_chip {/* GPIO resources */ u8 gpio_data[2 ]; -/* This cyclecounter abstracts the switch PTP time. -* reg_lock must be held for any operation that read()s. -*/ -struct cyclecounter tstamp_cc; -struct timecounter tstamp_tc; -struct delayed_work overflow_work; -const struct mv88e6xxx_cc_coeffs *cc_coeffs; - -struct ptp_clock *ptp_clock; -struct ptp_clock_info ptp_clock_info; -struct delayed_work tai_event_work; +struct marvell_tai *tai; +struct ptp_pin_desc pin_config[MV88E6XXX_MAX_GPIO ];u16 enable_count;
@@ -446,6 +438,13 @@ struct mv88e6xxx_chip {DECLARE_BITMAP (fid_bitmap,MV88E6XXX_N_FID ); }; +static inline struct mv88e6xxx_chip *dev_to_chip (struct device *dev) +{ +struct dsa_switch *ds =dev_get_drvdata (dev); + +return ds->priv; +} +struct mv88e6xxx_bus_ops {int (*read)(struct mv88e6xxx_chip *chip,int addr,int reg,u16 *val);int (*write)(struct mv88e6xxx_chip *chip,int addr,int reg,u16 val);
@@ -731,11 +730,10 @@ struct mv88e6xxx_avb_ops {struct mv88e6xxx_ptp_ops {u64 (*clock_read)(struct mv88e6xxx_chip *chip); -int (*ptp_enable_extts)(struct mv88e6xxx_chip *chip, -struct ptp_clock_request *rq,int pin,int on); +int (*ptp_pin_setup)(struct mv88e6xxx_chip *chip,int pin, +enum ptp_pin_function func,int enable);int (*ptp_verify)(struct mv88e6xxx_chip *chip,unsigned int pin,enum ptp_pin_function func,unsigned int chan); -void (*event_work)(struct work_struct *ugly);int (*port_enable)(struct mv88e6xxx_chip *chip,int port);int (*port_disable)(struct mv88e6xxx_chip *chip,int port);int (*global_enable)(struct mv88e6xxx_chip *chip);
drivers/net/dsa/mv88e6xxx/hwtstamp.c +5 -9
@@ -79,7 +79,7 @@ int mv88e6xxx_get_ts_info(struct dsa_switch *ds, int port,SOF_TIMESTAMPING_TX_HARDWARE |SOF_TIMESTAMPING_RX_HARDWARE |SOF_TIMESTAMPING_RAW_HARDWARE ; - info->phc_index =ptp_clock_index (chip->ptp_clock); + info->phc_index =marvell_tai_ptp_clock_index (chip->tai); info->tx_types = (1 <<HWTSTAMP_TX_OFF ) | (1 <<HWTSTAMP_TX_ON );
@@ -289,9 +289,7 @@ static void mv88e6xxx_get_rxts(struct mv88e6xxx_chip *chip,if (mv88e6xxx_ts_valid (status) &&seq_match (skb, seq_id)) { ns = timehi <<16 | timelo; -mv88e6xxx_reg_lock (chip); - ns =timecounter_cyc2time (&chip->tstamp_tc, ns); -mv88e6xxx_reg_unlock (chip); + ns =marvell_tai_cyc2time (chip->tai, ns); shwt =skb_hwtstamps (skb);memset (shwt,0 ,sizeof (*shwt)); shwt->hwtstamp =ns_to_ktime (ns);
@@ -348,7 +346,7 @@ bool mv88e6xxx_port_rxtstamp(struct dsa_switch *ds, int port,else skb_queue_tail (&ps->rx_queue, skb); -ptp_schedule_worker (chip->ptp_clock,0 ); +marvell_tai_schedule (chip->tai,0 );return true; }
@@ -409,9 +407,7 @@ static int mv88e6xxx_txtstamp_work(struct mv88e6xxx_chip *chip,memset (&shhwtstamps,0 ,sizeof (shhwtstamps)); time_raw = ((u32 )departure_block[2 ] <<16 ) | departure_block[1 ]; -mv88e6xxx_reg_lock (chip); - ns =timecounter_cyc2time (&chip->tstamp_tc, time_raw); -mv88e6xxx_reg_unlock (chip); + ns =marvell_tai_cyc2time (chip->tai, time_raw); shhwtstamps.hwtstamp =ns_to_ktime (ns); dev_dbg(chip->dev,
@@ -490,7 +486,7 @@ void mv88e6xxx_port_txtstamp(struct dsa_switch *ds, int port, ps->tx_tstamp_start = jiffies; ps->tx_seq_id =be16_to_cpu (hdr->sequence_id); -ptp_schedule_worker (chip->ptp_clock,0 ); +marvell_tai_schedule (chip->tai,0 ); }int mv88e6165_global_disable (struct mv88e6xxx_chip *chip)
drivers/net/dsa/mv88e6xxx/ptp.c +164 -309
544 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/ptp.h +6 -24
@@ -15,39 +15,15 @@#include "chip.h" -/* Offset 0x00: TAI Global Config */ -#define MV88E6352_TAI_CFG 0x00 -#define MV88E6352_TAI_CFG_CAP_OVERWRITE 0x8000 -#define MV88E6352_TAI_CFG_CAP_CTR_START 0x4000 -#define MV88E6352_TAI_CFG_EVREQ_FALLING 0x2000 -#define MV88E6352_TAI_CFG_TRIG_ACTIVE_LO 0x1000 -#define MV88E6352_TAI_CFG_IRL_ENABLE 0x0400 -#define MV88E6352_TAI_CFG_TRIG_IRQ_EN 0x0200 -#define MV88E6352_TAI_CFG_EVREQ_IRQ_EN 0x0100 -#define MV88E6352_TAI_CFG_TRIG_LOCK 0x0080 -#define MV88E6352_TAI_CFG_BLOCK_UPDATE 0x0008 -#define MV88E6352_TAI_CFG_MULTI_PTP 0x0004 -#define MV88E6352_TAI_CFG_TRIG_MODE_ONESHOT 0x0002 -#define MV88E6352_TAI_CFG_TRIG_ENABLE 0x0001 -/* Offset 0x01: Timestamp Clock Period (ps) */ #define MV88E6XXX_TAI_CLOCK_PERIOD 0x01 -/* Offset 0x09: Event Status */ -#define MV88E6352_TAI_EVENT_STATUS 0x09 -#define MV88E6352_TAI_EVENT_STATUS_ERROR 0x0200 -#define MV88E6352_TAI_EVENT_STATUS_VALID 0x0100 -#define MV88E6352_TAI_EVENT_STATUS_CTR_MASK 0x00ff -/* Offset 0x0A/0x0B: Event Time Lo/Hi. Always read with Event Status. */ -/* Offset 0x0E/0x0F: PTP Global Time */ #define MV88E6352_TAI_TIME_LO 0x0e -#define MV88E6352_TAI_TIME_HI 0x0f/* 6165 Global Control Registers */ /* Offset 0x9/0xa: Global Time */ #define MV88E6165_PTP_GC_TIME_LO 0x09 -#define MV88E6165_PTP_GC_TIME_HI 0x0A/* 6165 Per Port Registers. The arrival and departure registers are a * common block consisting of status, two time registers and the sequence ID
@@ -67,6 +43,7 @@#ifdef CONFIG_NET_DSA_MV88E6XXX_PTP int mv88e6xxx_ptp_setup (struct mv88e6xxx_chip *chip); +int mv88e6xxx_ptp_setup_unlocked (struct mv88e6xxx_chip *chip);void mv88e6xxx_ptp_free (struct mv88e6xxx_chip *chip);#define ptp_to_chip (ptp) container_of(ptp, struct mv88e6xxx_chip, \
@@ -83,6 +60,11 @@ static inline int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip)return 0 ; } +static inline int mv88e6xxx_ptp_setup_unlocked (struct mv88e6xxx_chip *chip) +{ +return 0 ; +} +static inline void mv88e6xxx_ptp_free (struct mv88e6xxx_chip *chip) { }
Signature · 1 line
2.47.3
RFC PATCH 14/20 net: dsa: mv88e6xxx: convert mv88e6xxx_cc_coeffs to marvell_tai_param
In reply to Russell King (Oracle)Convert the coefficients to struct marvell_tai_param.
--- drivers/net/dsa/mv88e6xxx/ptp.c | 40 +++++++++++---------------------- 1 file changed, 13 insertions(+), 27 deletions(-)
drivers/net/dsa/mv88e6xxx/ptp.c +13 -27
@@ -16,13 +16,6 @@#include "hwtstamp.h" #include "ptp.h" -struct mv88e6xxx_cc_coeffs { -u32 cc_shift; -u32 cc_mult; -u32 cc_mult_num; -u32 cc_mult_dem; -}; -/* Family MV88E6250: * Raw timestamps are in units of 10-ns clock periods. *
@@ -31,11 +24,11 @@ struct mv88e6xxx_cc_coeffs {* clkadj = scaled_ppm * 2^7 / 5^5 */ #define MV88E6XXX_CC_10NS_SHIFT 28 -static const struct mv88e6xxx_cc_coeffs mv88e6xxx_cc_10ns_coeffs = { +static const struct marvell_tai_param mv88e6xxx_cc_10ns_coeffs = { .cc_shift =MV88E6XXX_CC_10NS_SHIFT , .cc_mult =10 <<MV88E6XXX_CC_10NS_SHIFT , .cc_mult_num =1 <<7 , - .cc_mult_dem =3125ULL , + .cc_mult_den =3125ULL , };/* Other families except MV88E6393X in internal clock mode:
@@ -46,11 +39,11 @@ static const struct mv88e6xxx_cc_coeffs mv88e6xxx_cc_10ns_coeffs = {* clkadj = scaled_ppm * 2^9 / 5^6 */ #define MV88E6XXX_CC_8NS_SHIFT 28 -static const struct mv88e6xxx_cc_coeffs mv88e6xxx_cc_8ns_coeffs = { +static const struct marvell_tai_param mv88e6xxx_cc_8ns_coeffs = { .cc_shift =MV88E6XXX_CC_8NS_SHIFT , .cc_mult =8 <<MV88E6XXX_CC_8NS_SHIFT , .cc_mult_num =1 <<9 , - .cc_mult_dem =15625ULL + .cc_mult_den =15625ULL };/* Family MV88E6393X using internal clock:
@@ -61,11 +54,11 @@ static const struct mv88e6xxx_cc_coeffs mv88e6xxx_cc_8ns_coeffs = {* clkadj = scaled_ppm * 2^8 / 5^6 */ #define MV88E6XXX_CC_4NS_SHIFT 28 -static const struct mv88e6xxx_cc_coeffs mv88e6xxx_cc_4ns_coeffs = { +static const struct marvell_tai_param mv88e6xxx_cc_4ns_coeffs = { .cc_shift =MV88E6XXX_CC_4NS_SHIFT , .cc_mult =4 <<MV88E6XXX_CC_4NS_SHIFT , .cc_mult_num =1 <<8 , - .cc_mult_dem =15625ULL + .cc_mult_den =15625ULL }; static int mv88e6xxx_tai_read(struct mv88e6xxx_chip *chip, int addr,
@@ -242,8 +235,8 @@ static int mv88e6352_ptp_pin_setup(struct mv88e6xxx_chip *chip, int pin,return mv88e6352_set_gpio_func (chip, pin, func, true); } -static const struct mv88e6xxx_cc_coeffs * -mv88e6xxx_cc_coeff_get (struct mv88e6xxx_chip *chip) +static const struct marvell_tai_param * +mv88e6xxx_tai_param_get (struct mv88e6xxx_chip *chip) {u16 period_ps;int err;
@@ -386,15 +379,14 @@ static int mv88e6xxx_set_ptp_cpu_port(struct mv88e6xxx_chip *chip)int mv88e6xxx_ptp_setup (struct mv88e6xxx_chip *chip) {const struct mv88e6xxx_ptp_ops *ptp_ops = chip->info->ops->ptp_ops; -const struct mv88e6xxx_cc_coeffs *cc_coeffs; -struct marvell_tai_param tai_param; +const struct marvell_tai_param *tai_param;struct marvell_tai_pins pins;int i, err;/* Set up the cycle counter */ - cc_coeffs =mv88e6xxx_cc_coeff_get (chip); -if (IS_ERR (cc_coeffs)) -return PTR_ERR (cc_coeffs); + tai_param =mv88e6xxx_tai_param_get (chip); +if (IS_ERR (tai_param)) +return PTR_ERR (tai_param); err =mv88e6xxx_set_ptp_cpu_port (chip);if (err)
@@ -402,12 +394,6 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip)mv88e6xxx_reg_unlock (chip); -memset (&tai_param,0 ,sizeof (tai_param)); - tai_param.cc_mult_num = cc_coeffs->cc_mult_num; - tai_param.cc_mult_den = cc_coeffs->cc_mult_dem; - tai_param.cc_mult = cc_coeffs->cc_mult; - tai_param.cc_shift = cc_coeffs->cc_shift; -memset (&pins,0 ,sizeof (pins)); pins.n_ext_ts = ptp_ops->n_ext_ts; pins.n_pins =mv88e6xxx_num_gpio (chip);
@@ -422,7 +408,7 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip) ppd->func =PTP_PF_NONE ; } - err =marvell_tai_probe (&chip->tai, &mv88e6xxx_tai_ops, &tai_param, + err =marvell_tai_probe (&chip->tai, &mv88e6xxx_tai_ops, tai_param, &pins,dev_name (chip->dev), chip->dev);mv88e6xxx_reg_lock (chip);
Signature · 1 line
2.47.3
RFC PATCH 15/20 net: dsa: mv88e6xxx: allow generic core to configure global regs
In reply to Russell King (Oracle)--- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/net/dsa/mv88e6xxx/hwtstamp.c +12 -2
@@ -544,6 +544,17 @@ static int mv88e6xxx_hwtstamp_port_setup(struct mv88e6xxx_chip *chip, int port)return 0 ; } +static int mv88e6xxx_ts_global_write (struct device *dev,u8 reg,u16 val) +{ +struct mv88e6xxx_chip *chip =dev_to_chip (dev); + +return chip->info->ops->avb_ops->ptp_write (chip, reg, val); +} + +static const struct marvell_ts_ops mv88e6xxx_ts_ops = { + .ts_global_write = mv88e6xxx_ts_global_write, +}; +int mv88e6xxx_hwtstamp_setup (struct mv88e6xxx_chip *chip) {const struct mv88e6xxx_ptp_ops *ptp_ops = chip->info->ops->ptp_ops;
@@ -564,8 +575,7 @@ int mv88e6xxx_hwtstamp_setup(struct mv88e6xxx_chip *chip)return err; } -/* Set the ethertype of L2 PTP messages */ - err =mv88e6xxx_ptp_write (chip,MV88E6XXX_PTP_ETHERTYPE ,ETH_P_1588 ); + err =marvell_ts_global_config (chip->dev, &mv88e6xxx_ts_ops);if (err)return err;
Signature · 1 line
2.47.3
RFC PATCH 16/20 net: dsa: mv88e6xxx: add beginnings of generic Marvell PTP ts layer
In reply to Russell King (Oracle)Initialise the generic Marvell PTP per-port timestamping layer, and use it to provide the get_ts_info() method.
--- drivers/net/dsa/mv88e6xxx/chip.c | 4 + drivers/net/dsa/mv88e6xxx/chip.h | 2 + drivers/net/dsa/mv88e6xxx/hwtstamp.c | 188 ++++++++++++++++++++++++--- drivers/net/dsa/mv88e6xxx/hwtstamp.h | 6 + 4 files changed, 182 insertions(+), 18 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +4 -0
@@ -4113,6 +4113,10 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) err =mv88e6xxx_ptp_setup_unlocked (chip);if (err) goto out_hwtstamp; + + err =mv88e6xxx_hwtstamp_setup_unlocked (chip); +if (err) + goto out_hwtstamp; }/* Have to be called without holding the register lock, since
drivers/net/dsa/mv88e6xxx/chip.h +2 -0
@@ -424,6 +424,8 @@ struct mv88e6xxx_chip {/* Per-port timestamping resources. */ struct mv88e6xxx_port_hwtstamp port_hwtstamp[DSA_MAX_PORTS ]; +struct marvell_ts ptp_ts[DSA_MAX_PORTS ]; +struct marvell_ts_caps ptp_caps;/* Array of port structures. */ struct mv88e6xxx_port ports[DSA_MAX_PORTS ];
drivers/net/dsa/mv88e6xxx/hwtstamp.c +170 -18
259 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/hwtstamp.h +6 -0
@@ -125,6 +125,7 @@ int mv88e6xxx_get_ts_info(struct dsa_switch *ds, int port, struct kernel_ethtool_ts_info *info);long mv88e6xxx_hwtstamp_work (struct mv88e6xxx_chip *chip); +int mv88e6xxx_hwtstamp_setup_unlocked (struct mv88e6xxx_chip *chip);int mv88e6xxx_hwtstamp_setup (struct mv88e6xxx_chip *chip);void mv88e6xxx_hwtstamp_free (struct mv88e6xxx_chip *chip);int mv88e6352_hwtstamp_port_enable (struct mv88e6xxx_chip *chip,int port);
@@ -172,6 +173,11 @@ static inline int mv88e6xxx_hwtstamp_setup(struct mv88e6xxx_chip *chip)return 0 ; } +static inline int mv88e6xxx_hwtstamp_setup_unlocked (struct mv88e6xxx_chip *chip) +{ +return 0 ; +} +static inline void mv88e6xxx_hwtstamp_free (struct mv88e6xxx_chip *chip) { }
Signature · 1 line
2.47.3
RFC PATCH 17/20 net: dsa: mv88e6xxx: switch tx timestamping to core
In reply to Russell King (Oracle)--- drivers/net/dsa/mv88e6xxx/chip.h | 6 -- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 116 ++------------------------- drivers/net/dsa/mv88e6xxx/hwtstamp.h | 3 - 3 files changed, 7 insertions(+), 118 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +0 -6
@@ -222,7 +222,6 @@ struct mv88e6xxx_irq {/* state flags for mv88e6xxx_port_hwtstamp::state */ enum {MV88E6XXX_HWTSTAMP_ENABLED , -MV88E6XXX_HWTSTAMP_TX_IN_PROGRESS , };struct mv88e6xxx_port_hwtstamp {
@@ -236,11 +235,6 @@ struct mv88e6xxx_port_hwtstamp {struct sk_buff_head rx_queue;struct sk_buff_head rx_queue2; -/* Resources for transmit timestamping */ -unsigned long tx_tstamp_start; -struct sk_buff *tx_skb; -u16 tx_seq_id; -/* Current timestamp configuration */ struct kernel_hwtstamp_config tstamp_config; };
drivers/net/dsa/mv88e6xxx/hwtstamp.c +7 -109
147 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/hwtstamp.h +0 -3
@@ -103,9 +103,6 @@/* Status fields for arrival and depature timestamp status registers */ #define MV88E6XXX_PTP_TS_STATUS_MASK 0x0006 -#define MV88E6XXX_PTP_TS_STATUS_NORMAL 0x0000 -#define MV88E6XXX_PTP_TS_STATUS_OVERWITTEN 0x0002 -#define MV88E6XXX_PTP_TS_STATUS_DISCARDED 0x0004#define MV88E6XXX_PTP_TS_VALID 0x0001#ifdef CONFIG_NET_DSA_MV88E6XXX_PTP
Signature · 1 line
2.47.3
RFC PATCH 18/20 net: dsa: mv88e6xxx: switch rx timestamping to core
In reply to Russell King (Oracle)--- drivers/net/dsa/mv88e6xxx/chip.h | 7 -- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 154 +-------------------------- drivers/net/dsa/mv88e6xxx/hwtstamp.h | 4 - 3 files changed, 2 insertions(+), 163 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +0 -7
@@ -225,16 +225,9 @@ enum { };struct mv88e6xxx_port_hwtstamp { -/* Port index */ -int port_id; -/* Timestamping state */ unsigned long state; -/* Resources for receive timestamping */ -struct sk_buff_head rx_queue; -struct sk_buff_head rx_queue2; -/* Current timestamp configuration */ struct kernel_hwtstamp_config tstamp_config; };
drivers/net/dsa/mv88e6xxx/hwtstamp.c +2 -152
181 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/hwtstamp.h +0 -4
@@ -101,10 +101,6 @@/* Offset 0x13: PTP Departure Sequence ID */ #define MV88E6XXX_PORT_PTP_DEP_SEQID 0x13 -/* Status fields for arrival and depature timestamp status registers */ -#define MV88E6XXX_PTP_TS_STATUS_MASK 0x0006 -#define MV88E6XXX_PTP_TS_VALID 0x0001 -#ifdef CONFIG_NET_DSA_MV88E6XXX_PTP int mv88e6xxx_port_hwtstamp_set(struct dsa_switch *ds, int port,
Signature · 1 line
2.47.3
RFC PATCH 19/20 net: dsa: mv88e6xxx: switch hwtstamp config to core XXX Fix 6165
In reply to Russell King (Oracle)--- drivers/net/dsa/mv88e6xxx/chip.h | 16 +-- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 151 +++++++-------------------- drivers/net/dsa/mv88e6xxx/hwtstamp.h | 11 -- 3 files changed, 36 insertions(+), 142 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +1 -15
@@ -219,19 +219,6 @@ struct mv88e6xxx_irq {int nirqs; }; -/* state flags for mv88e6xxx_port_hwtstamp::state */ -enum { -MV88E6XXX_HWTSTAMP_ENABLED , -}; - -struct mv88e6xxx_port_hwtstamp { -/* Timestamping state */ -unsigned long state; - -/* Current timestamp configuration */ -struct kernel_hwtstamp_config tstamp_config; -}; -enum mv88e6xxx_policy_mapping {MV88E6XXX_POLICY_MAPPING_DA ,MV88E6XXX_POLICY_MAPPING_SA ,
@@ -403,16 +390,15 @@ struct mv88e6xxx_chip {struct marvell_tai *tai;struct ptp_pin_desc pin_config[MV88E6XXX_MAX_GPIO ]; -u16 enable_count;/* Current ingress and egress monitor ports */ int egress_dest_port;int ingress_dest_port;/* Per-port timestamping resources. */ -struct mv88e6xxx_port_hwtstamp port_hwtstamp[DSA_MAX_PORTS ];struct marvell_ts ptp_ts[DSA_MAX_PORTS ];struct marvell_ts_caps ptp_caps; +u16 ptp_ts_enable_count;/* Array of port structures. */ struct mv88e6xxx_port ports[DSA_MAX_PORTS ];
drivers/net/dsa/mv88e6xxx/hwtstamp.c +35 -116
197 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/hwtstamp.h +0 -11
@@ -19,17 +19,6 @@/* Offset 0x00: PTP EtherType */ #define MV88E6XXX_PTP_ETHERTYPE 0x00 -/* Offset 0x01: Message Type Timestamp Enables */ -#define MV88E6XXX_PTP_MSGTYPE 0x01 -#define MV88E6XXX_PTP_MSGTYPE_SYNC 0x0001 -#define MV88E6XXX_PTP_MSGTYPE_DELAY_REQ 0x0002 -#define MV88E6XXX_PTP_MSGTYPE_PDLAY_REQ 0x0004 -#define MV88E6XXX_PTP_MSGTYPE_PDLAY_RES 0x0008 -#define MV88E6XXX_PTP_MSGTYPE_ALL_EVENT 0x000f - -/* Offset 0x02: Timestamp Arrival Capture Pointers */ -#define MV88E6XXX_PTP_TS_ARRIVAL_PTR 0x02 -/* Offset 0x05: PTP Global Configuration */ #define MV88E6165_PTP_CFG 0x05#define MV88E6165_PTP_CFG_TSPEC_MASK 0xf000
Signature · 1 line
2.47.3
RFC PATCH 20/20 net: dsa: mv88e6xxx: add ptp irq support
In reply to Russell King (Oracle)--- drivers/net/dsa/mv88e6xxx/chip.h | 2 + drivers/net/dsa/mv88e6xxx/hwtstamp.c | 60 +++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +2 -0
@@ -399,6 +399,8 @@ struct mv88e6xxx_chip {struct marvell_ts ptp_ts[DSA_MAX_PORTS ];struct marvell_ts_caps ptp_caps;u16 ptp_ts_enable_count; +int avb_irq; +char avb_irq_name[64 ];/* Array of port structures. */ struct mv88e6xxx_port ports[DSA_MAX_PORTS ];
drivers/net/dsa/mv88e6xxx/hwtstamp.c +58 -2
94 lines not on this page · raw message
Signature · 1 line
2.47.3