mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
net: dsa: mv88e6xxx: Enable PTP receive for mv88e6390
The switch receives management traffic such as STP and LLDP. However, PTP messages are not received, only transmitted. Ideally, the switch would trap all PTP messages to the management CPU. This particular switch has a PTP block which identifies PTP messages and traps them to a dedicated port. There is a register to program this destination. This is not used at the moment. Therefore, program it to the same port as the MGMT traffic is trapped to. This allows to receive PTP messages as soon as timestamping is enabled. In addition, the datasheet mentions that this register is not valid e.g., for 6190 variants. So, add a new PTP operation which is added for the 6390 and 6290 devices. Tested simply like this on Marvell 88E6390, revision 1: |/ # ptp4l -2 -i lan4 --tx_timestamp_timeout=40 -m |[...] |ptp4l[147.450]: master offset 56 s2 freq +1262 path delay 413 |ptp4l[148.450]: master offset 22 s2 freq +1244 path delay 434 |ptp4l[149.450]: master offset 5 s2 freq +1234 path delay 446 |ptp4l[150.451]: master offset 3 s2 freq +1233 path delay 451 |ptp4l[151.451]: master offset 1 s2 freq +1232 path delay 451 |ptp4l[152.451]: master offset -3 s2 freq +1229 path delay 451 |ptp4l[153.451]: master offset 9 s2 freq +1240 path delay 451 Link: https://lore.kernel.org/r/CAFSKS=PJBpvtRJxrR4sG1hyxpnUnQpiHg4SrUNzAhkWnyt9ivg@mail.gmail.com Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Tested-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
71dc9ec9ac
commit
9627c981ac
@ -5082,7 +5082,7 @@ static const struct mv88e6xxx_ops mv88e6290_ops = {
|
||||
.serdes_get_regs = mv88e6390_serdes_get_regs,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
.avb_ops = &mv88e6390_avb_ops,
|
||||
.ptp_ops = &mv88e6352_ptp_ops,
|
||||
.ptp_ops = &mv88e6390_ptp_ops,
|
||||
.phylink_get_caps = mv88e6390_phylink_get_caps,
|
||||
};
|
||||
|
||||
@ -5470,7 +5470,7 @@ static const struct mv88e6xxx_ops mv88e6390_ops = {
|
||||
.serdes_irq_status = mv88e6390_serdes_irq_status,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
.avb_ops = &mv88e6390_avb_ops,
|
||||
.ptp_ops = &mv88e6352_ptp_ops,
|
||||
.ptp_ops = &mv88e6390_ptp_ops,
|
||||
.serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
|
||||
.serdes_get_strings = mv88e6390_serdes_get_strings,
|
||||
.serdes_get_stats = mv88e6390_serdes_get_stats,
|
||||
@ -5543,7 +5543,7 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = {
|
||||
.serdes_get_regs = mv88e6390_serdes_get_regs,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
.avb_ops = &mv88e6390_avb_ops,
|
||||
.ptp_ops = &mv88e6352_ptp_ops,
|
||||
.ptp_ops = &mv88e6390_ptp_ops,
|
||||
.phylink_get_caps = mv88e6390x_phylink_get_caps,
|
||||
};
|
||||
|
||||
|
@ -715,6 +715,7 @@ struct mv88e6xxx_ptp_ops {
|
||||
int (*port_disable)(struct mv88e6xxx_chip *chip, int port);
|
||||
int (*global_enable)(struct mv88e6xxx_chip *chip);
|
||||
int (*global_disable)(struct mv88e6xxx_chip *chip);
|
||||
int (*set_ptp_cpu_port)(struct mv88e6xxx_chip *chip, int port);
|
||||
int n_ext_ts;
|
||||
int arr0_sts_reg;
|
||||
int arr1_sts_reg;
|
||||
|
@ -403,6 +403,18 @@ int mv88e6390_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port)
|
||||
return mv88e6390_g1_monitor_write(chip, ptr, port);
|
||||
}
|
||||
|
||||
int mv88e6390_g1_set_ptp_cpu_port(struct mv88e6xxx_chip *chip, int port)
|
||||
{
|
||||
u16 ptr = MV88E6390_G1_MONITOR_MGMT_CTL_PTR_PTP_CPU_DEST;
|
||||
|
||||
/* Use the default high priority for PTP frames sent to
|
||||
* the CPU.
|
||||
*/
|
||||
port |= MV88E6390_G1_MONITOR_MGMT_CTL_PTR_CPU_DEST_MGMTPRI;
|
||||
|
||||
return mv88e6390_g1_monitor_write(chip, ptr, port);
|
||||
}
|
||||
|
||||
int mv88e6390_g1_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip)
|
||||
{
|
||||
u16 ptr;
|
||||
|
@ -214,6 +214,7 @@
|
||||
#define MV88E6390_G1_MONITOR_MGMT_CTL_PTR_INGRESS_DEST 0x2000
|
||||
#define MV88E6390_G1_MONITOR_MGMT_CTL_PTR_EGRESS_DEST 0x2100
|
||||
#define MV88E6390_G1_MONITOR_MGMT_CTL_PTR_CPU_DEST 0x3000
|
||||
#define MV88E6390_G1_MONITOR_MGMT_CTL_PTR_PTP_CPU_DEST 0x3200
|
||||
#define MV88E6390_G1_MONITOR_MGMT_CTL_PTR_CPU_DEST_MGMTPRI 0x00e0
|
||||
#define MV88E6390_G1_MONITOR_MGMT_CTL_DATA_MASK 0x00ff
|
||||
|
||||
@ -303,6 +304,7 @@ int mv88e6390_g1_set_egress_port(struct mv88e6xxx_chip *chip,
|
||||
int port);
|
||||
int mv88e6095_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port);
|
||||
int mv88e6390_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port);
|
||||
int mv88e6390_g1_set_ptp_cpu_port(struct mv88e6xxx_chip *chip, int port);
|
||||
int mv88e6390_g1_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip);
|
||||
|
||||
int mv88e6085_g1_ip_pri_map(struct mv88e6xxx_chip *chip);
|
||||
|
@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#include "chip.h"
|
||||
#include "global1.h"
|
||||
#include "global2.h"
|
||||
#include "hwtstamp.h"
|
||||
#include "ptp.h"
|
||||
@ -419,6 +420,34 @@ const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = {
|
||||
.cc_mult_dem = MV88E6XXX_CC_MULT_DEM,
|
||||
};
|
||||
|
||||
const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = {
|
||||
.clock_read = mv88e6352_ptp_clock_read,
|
||||
.ptp_enable = mv88e6352_ptp_enable,
|
||||
.ptp_verify = mv88e6352_ptp_verify,
|
||||
.event_work = mv88e6352_tai_event_work,
|
||||
.port_enable = mv88e6352_hwtstamp_port_enable,
|
||||
.port_disable = mv88e6352_hwtstamp_port_disable,
|
||||
.set_ptp_cpu_port = mv88e6390_g1_set_ptp_cpu_port,
|
||||
.n_ext_ts = 1,
|
||||
.arr0_sts_reg = MV88E6XXX_PORT_PTP_ARR0_STS,
|
||||
.arr1_sts_reg = MV88E6XXX_PORT_PTP_ARR1_STS,
|
||||
.dep_sts_reg = MV88E6XXX_PORT_PTP_DEP_STS,
|
||||
.rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ),
|
||||
.cc_shift = MV88E6XXX_CC_SHIFT,
|
||||
.cc_mult = MV88E6XXX_CC_MULT,
|
||||
.cc_mult_num = MV88E6XXX_CC_MULT_NUM,
|
||||
.cc_mult_dem = MV88E6XXX_CC_MULT_DEM,
|
||||
};
|
||||
|
||||
static u64 mv88e6xxx_ptp_clock_read(const struct cyclecounter *cc)
|
||||
{
|
||||
struct mv88e6xxx_chip *chip = cc_to_chip(cc);
|
||||
@ -491,6 +520,23 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip)
|
||||
chip->ptp_clock_info.verify = ptp_ops->ptp_verify;
|
||||
chip->ptp_clock_info.do_aux_work = mv88e6xxx_hwtstamp_work;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
chip->ptp_clock = ptp_clock_register(&chip->ptp_clock_info, chip->dev);
|
||||
if (IS_ERR(chip->ptp_clock))
|
||||
return PTR_ERR(chip->ptp_clock);
|
||||
|
@ -151,6 +151,7 @@ void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip);
|
||||
extern const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops;
|
||||
extern const struct mv88e6xxx_ptp_ops mv88e6250_ptp_ops;
|
||||
extern const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops;
|
||||
extern const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops;
|
||||
|
||||
#else /* !CONFIG_NET_DSA_MV88E6XXX_PTP */
|
||||
|
||||
@ -171,6 +172,7 @@ static inline void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip)
|
||||
static const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops = {};
|
||||
static const struct mv88e6xxx_ptp_ops mv88e6250_ptp_ops = {};
|
||||
static const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = {};
|
||||
static const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = {};
|
||||
|
||||
#endif /* CONFIG_NET_DSA_MV88E6XXX_PTP */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user