br_private_cfm.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _BR_PRIVATE_CFM_H_
  3. #define _BR_PRIVATE_CFM_H_
  4. #include "br_private.h"
  5. #include <uapi/linux/cfm_bridge.h>
  6. struct br_cfm_mep_create {
  7. enum br_cfm_domain domain; /* Domain for this MEP */
  8. enum br_cfm_mep_direction direction; /* Up or Down MEP direction */
  9. u32 ifindex; /* Residence port */
  10. };
  11. int br_cfm_mep_create(struct net_bridge *br,
  12. const u32 instance,
  13. struct br_cfm_mep_create *const create,
  14. struct netlink_ext_ack *extack);
  15. int br_cfm_mep_delete(struct net_bridge *br,
  16. const u32 instance,
  17. struct netlink_ext_ack *extack);
  18. struct br_cfm_mep_config {
  19. u32 mdlevel;
  20. u32 mepid; /* MEPID for this MEP */
  21. struct mac_addr unicast_mac; /* The MEP unicast MAC */
  22. };
  23. int br_cfm_mep_config_set(struct net_bridge *br,
  24. const u32 instance,
  25. const struct br_cfm_mep_config *const config,
  26. struct netlink_ext_ack *extack);
  27. struct br_cfm_maid {
  28. u8 data[CFM_MAID_LENGTH];
  29. };
  30. struct br_cfm_cc_config {
  31. /* Expected received CCM PDU MAID. */
  32. struct br_cfm_maid exp_maid;
  33. /* Expected received CCM PDU interval. */
  34. /* Transmitting CCM PDU interval when CCM tx is enabled. */
  35. enum br_cfm_ccm_interval exp_interval;
  36. bool enable; /* Enable/disable CCM PDU handling */
  37. };
  38. int br_cfm_cc_config_set(struct net_bridge *br,
  39. const u32 instance,
  40. const struct br_cfm_cc_config *const config,
  41. struct netlink_ext_ack *extack);
  42. int br_cfm_cc_peer_mep_add(struct net_bridge *br, const u32 instance,
  43. u32 peer_mep_id,
  44. struct netlink_ext_ack *extack);
  45. int br_cfm_cc_peer_mep_remove(struct net_bridge *br, const u32 instance,
  46. u32 peer_mep_id,
  47. struct netlink_ext_ack *extack);
  48. /* Transmitted CCM Remote Defect Indication status set.
  49. * This RDI is inserted in transmitted CCM PDUs if CCM transmission is enabled.
  50. * See br_cfm_cc_ccm_tx() with interval != BR_CFM_CCM_INTERVAL_NONE
  51. */
  52. int br_cfm_cc_rdi_set(struct net_bridge *br, const u32 instance,
  53. const bool rdi, struct netlink_ext_ack *extack);
  54. /* OAM PDU Tx information */
  55. struct br_cfm_cc_ccm_tx_info {
  56. struct mac_addr dmac;
  57. /* The CCM will be transmitted for this period in seconds.
  58. * Call br_cfm_cc_ccm_tx before timeout to keep transmission alive.
  59. * When period is zero any ongoing transmission will be stopped.
  60. */
  61. u32 period;
  62. bool seq_no_update; /* Update Tx CCM sequence number */
  63. bool if_tlv; /* Insert Interface Status TLV */
  64. u8 if_tlv_value; /* Interface Status TLV value */
  65. bool port_tlv; /* Insert Port Status TLV */
  66. u8 port_tlv_value; /* Port Status TLV value */
  67. /* Sender ID TLV ??
  68. * Organization-Specific TLV ??
  69. */
  70. };
  71. int br_cfm_cc_ccm_tx(struct net_bridge *br, const u32 instance,
  72. const struct br_cfm_cc_ccm_tx_info *const tx_info,
  73. struct netlink_ext_ack *extack);
  74. struct br_cfm_mep_status {
  75. /* Indications that an OAM PDU has been seen. */
  76. bool opcode_unexp_seen; /* RX of OAM PDU with unexpected opcode */
  77. bool version_unexp_seen; /* RX of OAM PDU with unexpected version */
  78. bool rx_level_low_seen; /* Rx of OAM PDU with level low */
  79. };
  80. struct br_cfm_cc_peer_status {
  81. /* This CCM related status is based on the latest received CCM PDU. */
  82. u8 port_tlv_value; /* Port Status TLV value */
  83. u8 if_tlv_value; /* Interface Status TLV value */
  84. /* CCM has not been received for 3.25 intervals */
  85. u8 ccm_defect:1;
  86. /* (RDI == 1) for last received CCM PDU */
  87. u8 rdi:1;
  88. /* Indications that a CCM PDU has been seen. */
  89. u8 seen:1; /* CCM PDU received */
  90. u8 tlv_seen:1; /* CCM PDU with TLV received */
  91. /* CCM PDU with unexpected sequence number received */
  92. u8 seq_unexp_seen:1;
  93. };
  94. struct br_cfm_mep {
  95. /* list header of MEP instances */
  96. struct hlist_node head;
  97. u32 instance;
  98. struct br_cfm_mep_create create;
  99. struct br_cfm_mep_config config;
  100. struct br_cfm_cc_config cc_config;
  101. struct br_cfm_cc_ccm_tx_info cc_ccm_tx_info;
  102. /* List of multiple peer MEPs */
  103. struct hlist_head peer_mep_list;
  104. struct net_bridge_port __rcu *b_port;
  105. unsigned long ccm_tx_end;
  106. struct delayed_work ccm_tx_dwork;
  107. u32 ccm_tx_snumber;
  108. u32 ccm_rx_snumber;
  109. struct br_cfm_mep_status status;
  110. bool rdi;
  111. struct rcu_head rcu;
  112. };
  113. struct br_cfm_peer_mep {
  114. struct hlist_node head;
  115. struct br_cfm_mep *mep;
  116. struct delayed_work ccm_rx_dwork;
  117. u32 mepid;
  118. struct br_cfm_cc_peer_status cc_status;
  119. u32 ccm_rx_count_miss;
  120. struct rcu_head rcu;
  121. };
  122. #endif /* _BR_PRIVATE_CFM_H_ */