Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 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 | |
Horatiu Vultur | f745893 | 2021-06-26 22:18:04 +0200 | [diff] [blame] | 9 | #define MRP_OPT_PADDING 0x2 |
| 10 | |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 11 | struct br_mrp { |
| 12 | /* list of mrp instances */ |
Horatiu Vultur | 0169b82 | 2020-11-06 22:50:49 +0100 | [diff] [blame] | 13 | struct hlist_node list; |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 14 | |
| 15 | struct net_bridge_port __rcu *p_port; |
| 16 | struct net_bridge_port __rcu *s_port; |
Horatiu Vultur | 78c1b4f | 2020-07-14 09:34:50 +0200 | [diff] [blame] | 17 | struct net_bridge_port __rcu *i_port; |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 18 | |
| 19 | u32 ring_id; |
Horatiu Vultur | 78c1b4f | 2020-07-14 09:34:50 +0200 | [diff] [blame] | 20 | u16 in_id; |
Horatiu Vultur | 4b3a61b | 2020-05-30 18:09:47 +0000 | [diff] [blame] | 21 | u16 prio; |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 22 | |
| 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 Vultur | 78c1b4f | 2020-07-14 09:34:50 +0200 | [diff] [blame] | 28 | 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 Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 33 | 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 Vultur | c6676e7 | 2020-05-30 18:09:48 +0000 | [diff] [blame] | 38 | bool test_monitor; |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 39 | |
Horatiu Vultur | 78c1b4f | 2020-07-14 09:34:50 +0200 | [diff] [blame] | 40 | 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 Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 46 | u32 seq_id; |
| 47 | |
| 48 | struct rcu_head rcu; |
| 49 | }; |
| 50 | |
Horatiu Vultur | e1bd99d | 2021-02-16 22:42:00 +0100 | [diff] [blame] | 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 |
| 56 | * frames to CPU. |
| 57 | * BR_MRP_HW - the HW can implement completely the protocol. |
| 58 | */ |
| 59 | enum br_mrp_hw_support { |
| 60 | BR_MRP_NONE, |
| 61 | BR_MRP_SW, |
| 62 | BR_MRP_HW, |
| 63 | }; |
| 64 | |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 65 | /* br_mrp.c */ |
| 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, |
Horatiu Vultur | 20f6a05 | 2020-05-27 12:34:30 +0000 | [diff] [blame] | 71 | enum br_mrp_port_role_type role); |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 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); |
Horatiu Vultur | 537ed56 | 2020-07-14 09:34:54 +0200 | [diff] [blame] | 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); |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 80 | |
| 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); |
Horatiu Vultur | 1a3ddb0 | 2021-02-16 22:42:01 +0100 | [diff] [blame] | 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); |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 87 | int br_mrp_switchdev_set_ring_state(struct net_bridge *br, struct br_mrp *mrp, |
| 88 | enum br_mrp_ring_state_type state); |
Horatiu Vultur | 1a3ddb0 | 2021-02-16 22:42:01 +0100 | [diff] [blame] | 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, |
| 92 | bool monitor); |
Horatiu Vultur | b2bdba1 | 2021-02-06 22:47:33 +0100 | [diff] [blame] | 93 | int br_mrp_port_switchdev_set_state(struct net_bridge_port *p, u32 state); |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 94 | int br_mrp_port_switchdev_set_role(struct net_bridge_port *p, |
| 95 | enum br_mrp_port_role_type role); |
Horatiu Vultur | 1a3ddb0 | 2021-02-16 22:42:01 +0100 | [diff] [blame] | 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); |
Horatiu Vultur | f23f0db | 2020-07-14 09:34:53 +0200 | [diff] [blame] | 100 | int br_mrp_switchdev_set_in_state(struct net_bridge *br, struct br_mrp *mrp, |
| 101 | enum br_mrp_in_state_type state); |
Horatiu Vultur | 1a3ddb0 | 2021-02-16 22:42:01 +0100 | [diff] [blame] | 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); |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 105 | |
| 106 | /* br_mrp_netlink.c */ |
Horatiu Vultur | 4cc625c | 2020-07-14 09:34:51 +0200 | [diff] [blame] | 107 | int br_mrp_ring_port_open(struct net_device *dev, u8 loc); |
Horatiu Vultur | 4139d4b | 2020-07-14 09:34:52 +0200 | [diff] [blame] | 108 | int br_mrp_in_port_open(struct net_device *dev, u8 loc); |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 109 | |
Rasmus Villemoes | 6781939 | 2021-01-21 21:40:37 +0100 | [diff] [blame] | 110 | /* MRP protocol data units */ |
| 111 | struct br_mrp_tlv_hdr { |
| 112 | __u8 type; |
| 113 | __u8 length; |
| 114 | }; |
| 115 | |
| 116 | struct br_mrp_common_hdr { |
| 117 | __be16 seq_id; |
| 118 | __u8 domain[MRP_DOMAIN_UUID_LENGTH]; |
| 119 | }; |
| 120 | |
| 121 | struct 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 | |
| 130 | struct 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 Vultur | f745893 | 2021-06-26 22:18:04 +0200 | [diff] [blame] | 139 | struct br_mrp_oui_hdr { |
| 140 | __u8 oui[MRP_OUI_LENGTH]; |
| 141 | }; |
| 142 | |
| 143 | struct br_mrp_sub_option1_hdr { |
| 144 | __u8 type; |
| 145 | __u8 data[MRP_MANUFACTURE_DATA_LENGTH]; |
| 146 | }; |
| 147 | |
Horatiu Vultur | 2f1a11a | 2020-04-26 15:22:02 +0200 | [diff] [blame] | 148 | #endif /* _BR_PRIVATE_MRP_H */ |