Skip to content

Commit f745893

Browse files
HoratiuVulturdavem330
authored andcommitted
net: bridge: mrp: Update the Test frames for MRA
According to the standard IEC 62439-2, in case the node behaves as MRA and needs to send Test frames on ring ports, then these Test frames need to have an Option TLV and a Sub-Option TLV which has the type AUTO_MGR. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f0305e7 commit f745893

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

net/bridge/br_mrp.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,33 @@ static struct sk_buff *br_mrp_alloc_test_skb(struct br_mrp *mrp,
204204
hdr->timestamp = cpu_to_be32(jiffies_to_msecs(jiffies));
205205

206206
br_mrp_skb_common(skb, mrp);
207+
208+
/* In case the node behaves as MRA then the Test frame needs to have
209+
* an Option TLV which includes eventually a sub-option TLV that has
210+
* the type AUTO_MGR
211+
*/
212+
if (mrp->ring_role == BR_MRP_RING_ROLE_MRA) {
213+
struct br_mrp_sub_option1_hdr *sub_opt = NULL;
214+
struct br_mrp_tlv_hdr *sub_tlv = NULL;
215+
struct br_mrp_oui_hdr *oui = NULL;
216+
u8 length;
217+
218+
length = sizeof(*sub_opt) + sizeof(*sub_tlv) + sizeof(oui) +
219+
MRP_OPT_PADDING;
220+
br_mrp_skb_tlv(skb, BR_MRP_TLV_HEADER_OPTION, length);
221+
222+
oui = skb_put(skb, sizeof(*oui));
223+
memset(oui, 0x0, sizeof(*oui));
224+
sub_opt = skb_put(skb, sizeof(*sub_opt));
225+
memset(sub_opt, 0x0, sizeof(*sub_opt));
226+
227+
sub_tlv = skb_put(skb, sizeof(*sub_tlv));
228+
sub_tlv->type = BR_MRP_SUB_TLV_HEADER_TEST_AUTO_MGR;
229+
230+
/* 32 bit alligment shall be ensured therefore add 2 bytes */
231+
skb_put(skb, MRP_OPT_PADDING);
232+
}
233+
207234
br_mrp_skb_tlv(skb, BR_MRP_TLV_HEADER_END, 0x0);
208235

209236
return skb;

net/bridge/br_private_mrp.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "br_private.h"
77
#include <uapi/linux/mrp_bridge.h>
88

9+
#define MRP_OPT_PADDING 0x2
10+
911
struct br_mrp {
1012
/* list of mrp instances */
1113
struct hlist_node list;
@@ -134,4 +136,13 @@ struct br_mrp_in_test_hdr {
134136
__be32 timestamp;
135137
} __attribute__((__packed__));
136138

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+
137148
#endif /* _BR_PRIVATE_MRP_H */

0 commit comments

Comments
 (0)