701-net-0341-LF-368-net-mscc-ocelot-add-VCAP-IS2-rule-to-trap-PTP.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From 67ca04147efac6cac3f7490c61c817a84daada57 Mon Sep 17 00:00:00 2001
  2. From: Yangbo Lu <[email protected]>
  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. All the PTP messages over Ethernet have etype 0x88f7 on them.
  7. Use etype as the key to trap PTP messages.
  8. Signed-off-by: Yangbo Lu <[email protected]>
  9. ---
  10. drivers/net/ethernet/mscc/ocelot.c | 23 +++++++++++++++++++++++
  11. 1 file changed, 23 insertions(+)
  12. --- a/drivers/net/ethernet/mscc/ocelot.c
  13. +++ b/drivers/net/ethernet/mscc/ocelot.c
  14. @@ -2340,6 +2340,20 @@ void ocelot_set_cpu_port(struct ocelot *
  15. }
  16. EXPORT_SYMBOL(ocelot_set_cpu_port);
  17. +/* Entry for PTP over Ethernet (etype 0x88f7)
  18. + * Action: trap to CPU port
  19. + */
  20. +static struct ocelot_ace_rule ptp_rule = {
  21. + .prio = 1,
  22. + .type = OCELOT_ACE_TYPE_ETYPE,
  23. + .dmac_mc = OCELOT_VCAP_BIT_1,
  24. + .action = OCELOT_ACL_ACTION_TRAP,
  25. + .frame.etype.etype.value[0] = 0x88,
  26. + .frame.etype.etype.value[1] = 0xf7,
  27. + .frame.etype.etype.mask[0] = 0xff,
  28. + .frame.etype.etype.mask[1] = 0xff,
  29. +};
  30. +
  31. int ocelot_init(struct ocelot *ocelot)
  32. {
  33. char queue_name[32];
  34. @@ -2477,6 +2491,13 @@ int ocelot_init(struct ocelot *ocelot)
  35. "Timestamp initialization failed\n");
  36. return ret;
  37. }
  38. +
  39. + /* Available on all ingress port except CPU port */
  40. + ptp_rule.ocelot = ocelot;
  41. + ptp_rule.ingress_port_mask =
  42. + GENMASK(ocelot->num_phys_ports - 1, 0);
  43. + ptp_rule.ingress_port_mask &= ~BIT(ocelot->cpu);
  44. + ocelot_ace_rule_offload_add(&ptp_rule);
  45. }
  46. return 0;
  47. @@ -2491,6 +2512,8 @@ void ocelot_deinit(struct ocelot *ocelot
  48. cancel_delayed_work(&ocelot->stats_work);
  49. destroy_workqueue(ocelot->stats_queue);
  50. mutex_destroy(&ocelot->stats_lock);
  51. + if (ocelot->ptp)
  52. + ocelot_ace_rule_offload_del(&ptp_rule);
  53. ocelot_ace_deinit();
  54. if (ocelot->ptp_clock)
  55. ptp_clock_unregister(ocelot->ptp_clock);