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