br_private_mrp.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _BR_PRIVATE_MRP_H_
  3. #define _BR_PRIVATE_MRP_H_
  4. #include "br_private.h"
  5. #include <uapi/linux/mrp_bridge.h>
  6. #define MRP_OPT_PADDING 0x2
  7. struct br_mrp {
  8. /* list of mrp instances */
  9. struct hlist_node list;
  10. struct net_bridge_port __rcu *p_port;
  11. struct net_bridge_port __rcu *s_port;
  12. struct net_bridge_port __rcu *i_port;
  13. u32 ring_id;
  14. u16 in_id;
  15. u16 prio;
  16. enum br_mrp_ring_role_type ring_role;
  17. u8 ring_role_offloaded;
  18. enum br_mrp_ring_state_type ring_state;
  19. u32 ring_transitions;
  20. enum br_mrp_in_role_type in_role;
  21. u8 in_role_offloaded;
  22. enum br_mrp_in_state_type in_state;
  23. u32 in_transitions;
  24. struct delayed_work test_work;
  25. u32 test_interval;
  26. unsigned long test_end;
  27. u32 test_count_miss;
  28. u32 test_max_miss;
  29. bool test_monitor;
  30. struct delayed_work in_test_work;
  31. u32 in_test_interval;
  32. unsigned long in_test_end;
  33. u32 in_test_count_miss;
  34. u32 in_test_max_miss;
  35. u32 seq_id;
  36. struct rcu_head rcu;
  37. };
  38. /* This type is returned by br_mrp_switchdev functions that allow to have a SW
  39. * backup in case the HW can't implement completely the protocol.
  40. * BR_MRP_NONE - means the HW can't run at all the protocol, so the SW stops
  41. * configuring the node anymore.
  42. * BR_MRP_SW - the HW can help the SW to run the protocol, by redirecting MRP
  43. * frames to CPU.
  44. * BR_MRP_HW - the HW can implement completely the protocol.
  45. */
  46. enum br_mrp_hw_support {
  47. BR_MRP_NONE,
  48. BR_MRP_SW,
  49. BR_MRP_HW,
  50. };
  51. /* br_mrp.c */
  52. int br_mrp_add(struct net_bridge *br, struct br_mrp_instance *instance);
  53. int br_mrp_del(struct net_bridge *br, struct br_mrp_instance *instance);
  54. int br_mrp_set_port_state(struct net_bridge_port *p,
  55. enum br_mrp_port_state_type state);
  56. int br_mrp_set_port_role(struct net_bridge_port *p,
  57. enum br_mrp_port_role_type role);
  58. int br_mrp_set_ring_state(struct net_bridge *br,
  59. struct br_mrp_ring_state *state);
  60. int br_mrp_set_ring_role(struct net_bridge *br, struct br_mrp_ring_role *role);
  61. int br_mrp_start_test(struct net_bridge *br, struct br_mrp_start_test *test);
  62. int br_mrp_set_in_state(struct net_bridge *br, struct br_mrp_in_state *state);
  63. int br_mrp_set_in_role(struct net_bridge *br, struct br_mrp_in_role *role);
  64. int br_mrp_start_in_test(struct net_bridge *br,
  65. struct br_mrp_start_in_test *test);
  66. /* br_mrp_switchdev.c */
  67. int br_mrp_switchdev_add(struct net_bridge *br, struct br_mrp *mrp);
  68. int br_mrp_switchdev_del(struct net_bridge *br, struct br_mrp *mrp);
  69. enum br_mrp_hw_support
  70. br_mrp_switchdev_set_ring_role(struct net_bridge *br, struct br_mrp *mrp,
  71. enum br_mrp_ring_role_type role);
  72. int br_mrp_switchdev_set_ring_state(struct net_bridge *br, struct br_mrp *mrp,
  73. enum br_mrp_ring_state_type state);
  74. enum br_mrp_hw_support
  75. br_mrp_switchdev_send_ring_test(struct net_bridge *br, struct br_mrp *mrp,
  76. u32 interval, u8 max_miss, u32 period,
  77. bool monitor);
  78. int br_mrp_port_switchdev_set_state(struct net_bridge_port *p, u32 state);
  79. int br_mrp_port_switchdev_set_role(struct net_bridge_port *p,
  80. enum br_mrp_port_role_type role);
  81. enum br_mrp_hw_support
  82. br_mrp_switchdev_set_in_role(struct net_bridge *br, struct br_mrp *mrp,
  83. u16 in_id, u32 ring_id,
  84. enum br_mrp_in_role_type role);
  85. int br_mrp_switchdev_set_in_state(struct net_bridge *br, struct br_mrp *mrp,
  86. enum br_mrp_in_state_type state);
  87. enum br_mrp_hw_support
  88. br_mrp_switchdev_send_in_test(struct net_bridge *br, struct br_mrp *mrp,
  89. u32 interval, u8 max_miss, u32 period);
  90. /* br_mrp_netlink.c */
  91. int br_mrp_ring_port_open(struct net_device *dev, u8 loc);
  92. int br_mrp_in_port_open(struct net_device *dev, u8 loc);
  93. /* MRP protocol data units */
  94. struct br_mrp_tlv_hdr {
  95. __u8 type;
  96. __u8 length;
  97. };
  98. struct br_mrp_common_hdr {
  99. __be16 seq_id;
  100. __u8 domain[MRP_DOMAIN_UUID_LENGTH];
  101. };
  102. struct br_mrp_ring_test_hdr {
  103. __be16 prio;
  104. __u8 sa[ETH_ALEN];
  105. __be16 port_role;
  106. __be16 state;
  107. __be16 transitions;
  108. __be32 timestamp;
  109. } __attribute__((__packed__));
  110. struct br_mrp_in_test_hdr {
  111. __be16 id;
  112. __u8 sa[ETH_ALEN];
  113. __be16 port_role;
  114. __be16 state;
  115. __be16 transitions;
  116. __be32 timestamp;
  117. } __attribute__((__packed__));
  118. struct br_mrp_oui_hdr {
  119. __u8 oui[MRP_OUI_LENGTH];
  120. };
  121. struct br_mrp_sub_option1_hdr {
  122. __u8 type;
  123. __u8 data[MRP_MANUFACTURE_DATA_LENGTH];
  124. };
  125. #endif /* _BR_PRIVATE_MRP_H */