18754172a57bf0c308febaee856679d8b7e72364
[openwrt/staging/hauke.git] /
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
5 Ethernet frames
6
7 All the PTP messages over Ethernet have etype 0x88f7 on them.
8 Use etype as the key to trap PTP messages.
9
10 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
11 ---
12 drivers/net/ethernet/mscc/ocelot.c | 23 +++++++++++++++++++++++
13 1 file changed, 23 insertions(+)
14
15 --- a/drivers/net/ethernet/mscc/ocelot.c
16 +++ b/drivers/net/ethernet/mscc/ocelot.c
17 @@ -2340,6 +2340,20 @@ void ocelot_set_cpu_port(struct ocelot *
18 }
19 EXPORT_SYMBOL(ocelot_set_cpu_port);
20
21 +/* Entry for PTP over Ethernet (etype 0x88f7)
22 + * Action: trap to CPU port
23 + */
24 +static struct ocelot_ace_rule ptp_rule = {
25 + .prio = 1,
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,
33 +};
34 +
35 int ocelot_init(struct ocelot *ocelot)
36 {
37 char queue_name[32];
38 @@ -2477,6 +2491,13 @@ int ocelot_init(struct ocelot *ocelot)
39 "Timestamp initialization failed\n");
40 return ret;
41 }
42 +
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);
49 }
50
51 return 0;
52 @@ -2491,6 +2512,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);
56 + if (ocelot->ptp)
57 + ocelot_ace_rule_offload_del(&ptp_rule);
58 ocelot_ace_deinit();
59 if (ocelot->ptp_clock)
60 ptp_clock_unregister(ocelot->ptp_clock);