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>
9 #define MRP_OPT_PADDING 0x2
12 /* list of mrp instances */
13 struct hlist_node list;
15 struct net_bridge_port __rcu *p_port;
16 struct net_bridge_port __rcu *s_port;
17 struct net_bridge_port __rcu *i_port;
23 enum br_mrp_ring_role_type ring_role;
24 u8 ring_role_offloaded;
25 enum br_mrp_ring_state_type ring_state;
28 enum br_mrp_in_role_type in_role;
30 enum br_mrp_in_state_type in_state;
33 struct delayed_work test_work;
35 unsigned long test_end;
40 struct delayed_work in_test_work;
42 unsigned long in_test_end;
43 u32 in_test_count_miss;
51 /* This type is returned by br_mrp_switchdev functions that allow to have a SW
52 * backup in case the HW can't implement completely the protocol.
53 * BR_MRP_NONE - means the HW can't run at all the protocol, so the SW stops
54 * configuring the node anymore.
55 * BR_MRP_SW - the HW can help the SW to run the protocol, by redirecting MRP
57 * BR_MRP_HW - the HW can implement completely the protocol.
59 enum br_mrp_hw_support {
66 int br_mrp_add(struct net_bridge *br, struct br_mrp_instance *instance);
67 int br_mrp_del(struct net_bridge *br, struct br_mrp_instance *instance);
68 int br_mrp_set_port_state(struct net_bridge_port *p,
69 enum br_mrp_port_state_type state);
70 int br_mrp_set_port_role(struct net_bridge_port *p,
71 enum br_mrp_port_role_type role);
72 int br_mrp_set_ring_state(struct net_bridge *br,
73 struct br_mrp_ring_state *state);
74 int br_mrp_set_ring_role(struct net_bridge *br, struct br_mrp_ring_role *role);
75 int br_mrp_start_test(struct net_bridge *br, struct br_mrp_start_test *test);
76 int br_mrp_set_in_state(struct net_bridge *br, struct br_mrp_in_state *state);
77 int br_mrp_set_in_role(struct net_bridge *br, struct br_mrp_in_role *role);
78 int br_mrp_start_in_test(struct net_bridge *br,
79 struct br_mrp_start_in_test *test);
81 /* br_mrp_switchdev.c */
82 int br_mrp_switchdev_add(struct net_bridge *br, struct br_mrp *mrp);
83 int br_mrp_switchdev_del(struct net_bridge *br, struct br_mrp *mrp);
84 enum br_mrp_hw_support
85 br_mrp_switchdev_set_ring_role(struct net_bridge *br, struct br_mrp *mrp,
86 enum br_mrp_ring_role_type role);
87 int br_mrp_switchdev_set_ring_state(struct net_bridge *br, struct br_mrp *mrp,
88 enum br_mrp_ring_state_type state);
89 enum br_mrp_hw_support
90 br_mrp_switchdev_send_ring_test(struct net_bridge *br, struct br_mrp *mrp,
91 u32 interval, u8 max_miss, u32 period,
93 int br_mrp_port_switchdev_set_state(struct net_bridge_port *p, u32 state);
94 int br_mrp_port_switchdev_set_role(struct net_bridge_port *p,
95 enum br_mrp_port_role_type role);
96 enum br_mrp_hw_support
97 br_mrp_switchdev_set_in_role(struct net_bridge *br, struct br_mrp *mrp,
98 u16 in_id, u32 ring_id,
99 enum br_mrp_in_role_type role);
100 int br_mrp_switchdev_set_in_state(struct net_bridge *br, struct br_mrp *mrp,
101 enum br_mrp_in_state_type state);
102 enum br_mrp_hw_support
103 br_mrp_switchdev_send_in_test(struct net_bridge *br, struct br_mrp *mrp,
104 u32 interval, u8 max_miss, u32 period);
106 /* br_mrp_netlink.c */
107 int br_mrp_ring_port_open(struct net_device *dev, u8 loc);
108 int br_mrp_in_port_open(struct net_device *dev, u8 loc);
110 /* MRP protocol data units */
111 struct br_mrp_tlv_hdr {
116 struct br_mrp_common_hdr {
118 __u8 domain[MRP_DOMAIN_UUID_LENGTH];
121 struct br_mrp_ring_test_hdr {
128 } __attribute__((__packed__));
130 struct br_mrp_in_test_hdr {
137 } __attribute__((__packed__));
139 struct br_mrp_oui_hdr {
140 __u8 oui[MRP_OUI_LENGTH];
143 struct br_mrp_sub_option1_hdr {
145 __u8 data[MRP_MANUFACTURE_DATA_LENGTH];
148 #endif /* _BR_PRIVATE_MRP_H */