sja1105.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0
  2. * Copyright (c) 2019, Vladimir Oltean <[email protected]>
  3. */
  4. /* Included by drivers/net/dsa/sja1105/sja1105.h and net/dsa/tag_sja1105.c */
  5. #ifndef _NET_DSA_SJA1105_H
  6. #define _NET_DSA_SJA1105_H
  7. #include <linux/skbuff.h>
  8. #include <linux/etherdevice.h>
  9. #include <linux/dsa/8021q.h>
  10. #include <net/dsa.h>
  11. #define ETH_P_SJA1105 ETH_P_DSA_8021Q
  12. #define ETH_P_SJA1105_META 0x0008
  13. #define ETH_P_SJA1110 0xdadc
  14. #define SJA1105_DEFAULT_VLAN (VLAN_N_VID - 1)
  15. /* IEEE 802.3 Annex 57A: Slow Protocols PDUs (01:80:C2:xx:xx:xx) */
  16. #define SJA1105_LINKLOCAL_FILTER_A 0x0180C2000000ull
  17. #define SJA1105_LINKLOCAL_FILTER_A_MASK 0xFFFFFF000000ull
  18. /* IEEE 1588 Annex F: Transport of PTP over Ethernet (01:1B:19:xx:xx:xx) */
  19. #define SJA1105_LINKLOCAL_FILTER_B 0x011B19000000ull
  20. #define SJA1105_LINKLOCAL_FILTER_B_MASK 0xFFFFFF000000ull
  21. /* Source and Destination MAC of follow-up meta frames.
  22. * Whereas the choice of SMAC only affects the unique identification of the
  23. * switch as sender of meta frames, the DMAC must be an address that is present
  24. * in the DSA master port's multicast MAC filter.
  25. * 01-80-C2-00-00-0E is a good choice for this, as all profiles of IEEE 1588
  26. * over L2 use this address for some purpose already.
  27. */
  28. #define SJA1105_META_SMAC 0x222222222222ull
  29. #define SJA1105_META_DMAC 0x0180C200000Eull
  30. enum sja1110_meta_tstamp {
  31. SJA1110_META_TSTAMP_TX = 0,
  32. SJA1110_META_TSTAMP_RX = 1,
  33. };
  34. struct sja1105_deferred_xmit_work {
  35. struct dsa_port *dp;
  36. struct sk_buff *skb;
  37. struct kthread_work work;
  38. };
  39. /* Global tagger data */
  40. struct sja1105_tagger_data {
  41. void (*xmit_work_fn)(struct kthread_work *work);
  42. void (*meta_tstamp_handler)(struct dsa_switch *ds, int port, u8 ts_id,
  43. enum sja1110_meta_tstamp dir, u64 tstamp);
  44. };
  45. struct sja1105_skb_cb {
  46. struct sk_buff *clone;
  47. u64 tstamp;
  48. /* Only valid for packets cloned for 2-step TX timestamping */
  49. u8 ts_id;
  50. };
  51. #define SJA1105_SKB_CB(skb) \
  52. ((struct sja1105_skb_cb *)((skb)->cb))
  53. static inline struct sja1105_tagger_data *
  54. sja1105_tagger_data(struct dsa_switch *ds)
  55. {
  56. BUG_ON(ds->dst->tag_ops->proto != DSA_TAG_PROTO_SJA1105 &&
  57. ds->dst->tag_ops->proto != DSA_TAG_PROTO_SJA1110);
  58. return ds->tagger_data;
  59. }
  60. #endif /* _NET_DSA_SJA1105_H */