Merge tag 'for-net-next-2021-06-28' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / net / bridge / br_private_mrp.h
CommitLineData
2f1a11ae
HV
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
9struct br_mrp {
10 /* list of mrp instances */
0169b820 11 struct hlist_node list;
2f1a11ae
HV
12
13 struct net_bridge_port __rcu *p_port;
14 struct net_bridge_port __rcu *s_port;
78c1b4fb 15 struct net_bridge_port __rcu *i_port;
2f1a11ae
HV
16
17 u32 ring_id;
78c1b4fb 18 u16 in_id;
4b3a61b0 19 u16 prio;
2f1a11ae
HV
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
78c1b4fb
HV
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
2f1a11ae
HV
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;
c6676e7d 36 bool test_monitor;
2f1a11ae 37
78c1b4fb
HV
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
2f1a11ae
HV
44 u32 seq_id;
45
46 struct rcu_head rcu;
47};
48
e1bd99d0
HV
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 */
57enum br_mrp_hw_support {
58 BR_MRP_NONE,
59 BR_MRP_SW,
60 BR_MRP_HW,
61};
62
2f1a11ae
HV
63/* br_mrp.c */
64int br_mrp_add(struct net_bridge *br, struct br_mrp_instance *instance);
65int br_mrp_del(struct net_bridge *br, struct br_mrp_instance *instance);
66int br_mrp_set_port_state(struct net_bridge_port *p,
67 enum br_mrp_port_state_type state);
68int br_mrp_set_port_role(struct net_bridge_port *p,
20f6a05e 69 enum br_mrp_port_role_type role);
2f1a11ae
HV
70int br_mrp_set_ring_state(struct net_bridge *br,
71 struct br_mrp_ring_state *state);
72int br_mrp_set_ring_role(struct net_bridge *br, struct br_mrp_ring_role *role);
73int br_mrp_start_test(struct net_bridge *br, struct br_mrp_start_test *test);
537ed567
HV
74int br_mrp_set_in_state(struct net_bridge *br, struct br_mrp_in_state *state);
75int br_mrp_set_in_role(struct net_bridge *br, struct br_mrp_in_role *role);
76int br_mrp_start_in_test(struct net_bridge *br,
77 struct br_mrp_start_in_test *test);
2f1a11ae
HV
78
79/* br_mrp_switchdev.c */
80int br_mrp_switchdev_add(struct net_bridge *br, struct br_mrp *mrp);
81int br_mrp_switchdev_del(struct net_bridge *br, struct br_mrp *mrp);
1a3ddb0b
HV
82enum br_mrp_hw_support
83br_mrp_switchdev_set_ring_role(struct net_bridge *br, struct br_mrp *mrp,
84 enum br_mrp_ring_role_type role);
2f1a11ae
HV
85int br_mrp_switchdev_set_ring_state(struct net_bridge *br, struct br_mrp *mrp,
86 enum br_mrp_ring_state_type state);
1a3ddb0b
HV
87enum br_mrp_hw_support
88br_mrp_switchdev_send_ring_test(struct net_bridge *br, struct br_mrp *mrp,
89 u32 interval, u8 max_miss, u32 period,
90 bool monitor);
b2bdba1c 91int br_mrp_port_switchdev_set_state(struct net_bridge_port *p, u32 state);
2f1a11ae
HV
92int br_mrp_port_switchdev_set_role(struct net_bridge_port *p,
93 enum br_mrp_port_role_type role);
1a3ddb0b
HV
94enum br_mrp_hw_support
95br_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);
f23f0db3
HV
98int br_mrp_switchdev_set_in_state(struct net_bridge *br, struct br_mrp *mrp,
99 enum br_mrp_in_state_type state);
1a3ddb0b
HV
100enum br_mrp_hw_support
101br_mrp_switchdev_send_in_test(struct net_bridge *br, struct br_mrp *mrp,
102 u32 interval, u8 max_miss, u32 period);
2f1a11ae
HV
103
104/* br_mrp_netlink.c */
4cc625c6 105int br_mrp_ring_port_open(struct net_device *dev, u8 loc);
4139d4b5 106int br_mrp_in_port_open(struct net_device *dev, u8 loc);
2f1a11ae 107
67819390
RV
108/* MRP protocol data units */
109struct br_mrp_tlv_hdr {
110 __u8 type;
111 __u8 length;
112};
113
114struct br_mrp_common_hdr {
115 __be16 seq_id;
116 __u8 domain[MRP_DOMAIN_UUID_LENGTH];
117};
118
119struct br_mrp_ring_test_hdr {
120 __be16 prio;
121 __u8 sa[ETH_ALEN];
122 __be16 port_role;
123 __be16 state;
124 __be16 transitions;
125 __be32 timestamp;
126} __attribute__((__packed__));
127
128struct br_mrp_in_test_hdr {
129 __be16 id;
130 __u8 sa[ETH_ALEN];
131 __be16 port_role;
132 __be16 state;
133 __be16 transitions;
134 __be32 timestamp;
135} __attribute__((__packed__));
136
2f1a11ae 137#endif /* _BR_PRIVATE_MRP_H */