blob: bda8e18967125b34825cf3f19d76ec02f962d9c9 [file] [log] [blame]
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +02001/* 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
Horatiu Vulturf7458932021-06-26 22:18:04 +02009#define MRP_OPT_PADDING 0x2
10
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020011struct br_mrp {
12 /* list of mrp instances */
Horatiu Vultur0169b822020-11-06 22:50:49 +010013 struct hlist_node list;
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020014
15 struct net_bridge_port __rcu *p_port;
16 struct net_bridge_port __rcu *s_port;
Horatiu Vultur78c1b4f2020-07-14 09:34:50 +020017 struct net_bridge_port __rcu *i_port;
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020018
19 u32 ring_id;
Horatiu Vultur78c1b4f2020-07-14 09:34:50 +020020 u16 in_id;
Horatiu Vultur4b3a61b2020-05-30 18:09:47 +000021 u16 prio;
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020022
23 enum br_mrp_ring_role_type ring_role;
24 u8 ring_role_offloaded;
25 enum br_mrp_ring_state_type ring_state;
26 u32 ring_transitions;
27
Horatiu Vultur78c1b4f2020-07-14 09:34:50 +020028 enum br_mrp_in_role_type in_role;
29 u8 in_role_offloaded;
30 enum br_mrp_in_state_type in_state;
31 u32 in_transitions;
32
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020033 struct delayed_work test_work;
34 u32 test_interval;
35 unsigned long test_end;
36 u32 test_count_miss;
37 u32 test_max_miss;
Horatiu Vulturc6676e72020-05-30 18:09:48 +000038 bool test_monitor;
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020039
Horatiu Vultur78c1b4f2020-07-14 09:34:50 +020040 struct delayed_work in_test_work;
41 u32 in_test_interval;
42 unsigned long in_test_end;
43 u32 in_test_count_miss;
44 u32 in_test_max_miss;
45
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020046 u32 seq_id;
47
48 struct rcu_head rcu;
49};
50
Horatiu Vulture1bd99d2021-02-16 22:42:00 +010051/* 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
56 * frames to CPU.
57 * BR_MRP_HW - the HW can implement completely the protocol.
58 */
59enum br_mrp_hw_support {
60 BR_MRP_NONE,
61 BR_MRP_SW,
62 BR_MRP_HW,
63};
64
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020065/* br_mrp.c */
66int br_mrp_add(struct net_bridge *br, struct br_mrp_instance *instance);
67int br_mrp_del(struct net_bridge *br, struct br_mrp_instance *instance);
68int br_mrp_set_port_state(struct net_bridge_port *p,
69 enum br_mrp_port_state_type state);
70int br_mrp_set_port_role(struct net_bridge_port *p,
Horatiu Vultur20f6a052020-05-27 12:34:30 +000071 enum br_mrp_port_role_type role);
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020072int br_mrp_set_ring_state(struct net_bridge *br,
73 struct br_mrp_ring_state *state);
74int br_mrp_set_ring_role(struct net_bridge *br, struct br_mrp_ring_role *role);
75int br_mrp_start_test(struct net_bridge *br, struct br_mrp_start_test *test);
Horatiu Vultur537ed562020-07-14 09:34:54 +020076int br_mrp_set_in_state(struct net_bridge *br, struct br_mrp_in_state *state);
77int br_mrp_set_in_role(struct net_bridge *br, struct br_mrp_in_role *role);
78int br_mrp_start_in_test(struct net_bridge *br,
79 struct br_mrp_start_in_test *test);
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020080
81/* br_mrp_switchdev.c */
82int br_mrp_switchdev_add(struct net_bridge *br, struct br_mrp *mrp);
83int br_mrp_switchdev_del(struct net_bridge *br, struct br_mrp *mrp);
Horatiu Vultur1a3ddb02021-02-16 22:42:01 +010084enum br_mrp_hw_support
85br_mrp_switchdev_set_ring_role(struct net_bridge *br, struct br_mrp *mrp,
86 enum br_mrp_ring_role_type role);
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020087int br_mrp_switchdev_set_ring_state(struct net_bridge *br, struct br_mrp *mrp,
88 enum br_mrp_ring_state_type state);
Horatiu Vultur1a3ddb02021-02-16 22:42:01 +010089enum br_mrp_hw_support
90br_mrp_switchdev_send_ring_test(struct net_bridge *br, struct br_mrp *mrp,
91 u32 interval, u8 max_miss, u32 period,
92 bool monitor);
Horatiu Vulturb2bdba12021-02-06 22:47:33 +010093int br_mrp_port_switchdev_set_state(struct net_bridge_port *p, u32 state);
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +020094int br_mrp_port_switchdev_set_role(struct net_bridge_port *p,
95 enum br_mrp_port_role_type role);
Horatiu Vultur1a3ddb02021-02-16 22:42:01 +010096enum br_mrp_hw_support
97br_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);
Horatiu Vulturf23f0db2020-07-14 09:34:53 +0200100int br_mrp_switchdev_set_in_state(struct net_bridge *br, struct br_mrp *mrp,
101 enum br_mrp_in_state_type state);
Horatiu Vultur1a3ddb02021-02-16 22:42:01 +0100102enum br_mrp_hw_support
103br_mrp_switchdev_send_in_test(struct net_bridge *br, struct br_mrp *mrp,
104 u32 interval, u8 max_miss, u32 period);
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +0200105
106/* br_mrp_netlink.c */
Horatiu Vultur4cc625c2020-07-14 09:34:51 +0200107int br_mrp_ring_port_open(struct net_device *dev, u8 loc);
Horatiu Vultur4139d4b2020-07-14 09:34:52 +0200108int br_mrp_in_port_open(struct net_device *dev, u8 loc);
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +0200109
Rasmus Villemoes67819392021-01-21 21:40:37 +0100110/* MRP protocol data units */
111struct br_mrp_tlv_hdr {
112 __u8 type;
113 __u8 length;
114};
115
116struct br_mrp_common_hdr {
117 __be16 seq_id;
118 __u8 domain[MRP_DOMAIN_UUID_LENGTH];
119};
120
121struct br_mrp_ring_test_hdr {
122 __be16 prio;
123 __u8 sa[ETH_ALEN];
124 __be16 port_role;
125 __be16 state;
126 __be16 transitions;
127 __be32 timestamp;
128} __attribute__((__packed__));
129
130struct br_mrp_in_test_hdr {
131 __be16 id;
132 __u8 sa[ETH_ALEN];
133 __be16 port_role;
134 __be16 state;
135 __be16 transitions;
136 __be32 timestamp;
137} __attribute__((__packed__));
138
Horatiu Vulturf7458932021-06-26 22:18:04 +0200139struct br_mrp_oui_hdr {
140 __u8 oui[MRP_OUI_LENGTH];
141};
142
143struct br_mrp_sub_option1_hdr {
144 __u8 type;
145 __u8 data[MRP_MANUFACTURE_DATA_LENGTH];
146};
147
Horatiu Vultur2f1a11a2020-04-26 15:22:02 +0200148#endif /* _BR_PRIVATE_MRP_H */