1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #ifndef _BR_PRIVATE_MRP_H_
4 #define _BR_PRIVATE_MRP_H_
6 #include "br_private.h"
7 #include <uapi/linux/mrp_bridge.h>
10 /* list of mrp instances */
11 struct hlist_node list;
13 struct net_bridge_port __rcu *p_port;
14 struct net_bridge_port __rcu *s_port;
15 struct net_bridge_port __rcu *i_port;
21 enum br_mrp_ring_role_type ring_role;
22 u8 ring_role_offloaded;
23 enum br_mrp_ring_state_type ring_state;
26 enum br_mrp_in_role_type in_role;
28 enum br_mrp_in_state_type in_state;
31 struct delayed_work test_work;
33 unsigned long test_end;
38 struct delayed_work in_test_work;
40 unsigned long in_test_end;
41 u32 in_test_count_miss;
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
55 * BR_MRP_HW - the HW can implement completely the protocol.
57 enum br_mrp_hw_support {
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);
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 enum br_mrp_hw_support
83 br_mrp_switchdev_set_ring_role(struct net_bridge *br, struct br_mrp *mrp,
84 enum br_mrp_ring_role_type role);
85 int br_mrp_switchdev_set_ring_state(struct net_bridge *br, struct br_mrp *mrp,
86 enum br_mrp_ring_state_type state);
87 enum br_mrp_hw_support
88 br_mrp_switchdev_send_ring_test(struct net_bridge *br, struct br_mrp *mrp,
89 u32 interval, u8 max_miss, u32 period,
91 int br_mrp_port_switchdev_set_state(struct net_bridge_port *p, u32 state);
92 int br_mrp_port_switchdev_set_role(struct net_bridge_port *p,
93 enum br_mrp_port_role_type role);
94 enum br_mrp_hw_support
95 br_mrp_switchdev_set_in_role(struct net_bridge *br, struct br_mrp *mrp,
96 u16 in_id, u32 ring_id,
97 enum br_mrp_in_role_type role);
98 int br_mrp_switchdev_set_in_state(struct net_bridge *br, struct br_mrp *mrp,
99 enum br_mrp_in_state_type state);
100 enum br_mrp_hw_support
101 br_mrp_switchdev_send_in_test(struct net_bridge *br, struct br_mrp *mrp,
102 u32 interval, u8 max_miss, u32 period);
104 /* br_mrp_netlink.c */
105 int br_mrp_ring_port_open(struct net_device *dev, u8 loc);
106 int br_mrp_in_port_open(struct net_device *dev, u8 loc);
108 /* MRP protocol data units */
109 struct br_mrp_tlv_hdr {
114 struct br_mrp_common_hdr {
116 __u8 domain[MRP_DOMAIN_UUID_LENGTH];
119 struct br_mrp_ring_test_hdr {
126 } __attribute__((__packed__));
128 struct br_mrp_in_test_hdr {
135 } __attribute__((__packed__));
137 #endif /* _BR_PRIVATE_MRP_H */