1 From 67ca04147efac6cac3f7490c61c817a84daada57 Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Thu, 28 Nov 2019 14:42:44 +0800
4 Subject: [PATCH] LF-368 net: mscc: ocelot: add VCAP IS2 rule to trap PTP
7 All the PTP messages over Ethernet have etype 0x88f7 on them.
8 Use etype as the key to trap PTP messages.
10 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
12 drivers/net/ethernet/mscc/ocelot.c | 23 +++++++++++++++++++++++
13 1 file changed, 23 insertions(+)
15 --- a/drivers/net/ethernet/mscc/ocelot.c
16 +++ b/drivers/net/ethernet/mscc/ocelot.c
17 @@ -2337,6 +2337,20 @@ void ocelot_set_cpu_port(struct ocelot *
19 EXPORT_SYMBOL(ocelot_set_cpu_port);
21 +/* Entry for PTP over Ethernet (etype 0x88f7)
22 + * Action: trap to CPU port
24 +static struct ocelot_ace_rule ptp_rule = {
26 + .type = OCELOT_ACE_TYPE_ETYPE,
27 + .dmac_mc = OCELOT_VCAP_BIT_1,
28 + .action = OCELOT_ACL_ACTION_TRAP,
29 + .frame.etype.etype.value[0] = 0x88,
30 + .frame.etype.etype.value[1] = 0xf7,
31 + .frame.etype.etype.mask[0] = 0xff,
32 + .frame.etype.etype.mask[1] = 0xff,
35 int ocelot_init(struct ocelot *ocelot)
38 @@ -2474,6 +2488,13 @@ int ocelot_init(struct ocelot *ocelot)
39 "Timestamp initialization failed\n");
43 + /* Available on all ingress port except CPU port */
44 + ptp_rule.ocelot = ocelot;
45 + ptp_rule.ingress_port_mask =
46 + GENMASK(ocelot->num_phys_ports - 1, 0);
47 + ptp_rule.ingress_port_mask &= ~BIT(ocelot->cpu);
48 + ocelot_ace_rule_offload_add(&ptp_rule);
52 @@ -2488,6 +2509,8 @@ void ocelot_deinit(struct ocelot *ocelot
53 cancel_delayed_work(&ocelot->stats_work);
54 destroy_workqueue(ocelot->stats_queue);
55 mutex_destroy(&ocelot->stats_lock);
57 + ocelot_ace_rule_offload_del(&ptp_rule);
59 if (ocelot->ptp_clock)
60 ptp_clock_unregister(ocelot->ptp_clock);