Merge tag 'for-linus-20190706' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / include / net / mrp.h
blobef58b4a071900777170685221cb6d3f261cf709c
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _NET_MRP_H
3 #define _NET_MRP_H
5 #define MRP_END_MARK 0x0
7 struct mrp_pdu_hdr {
8 u8 version;
9 };
11 struct mrp_msg_hdr {
12 u8 attrtype;
13 u8 attrlen;
16 struct mrp_vecattr_hdr {
17 __be16 lenflags;
18 unsigned char firstattrvalue[];
19 #define MRP_VECATTR_HDR_LEN_MASK cpu_to_be16(0x1FFF)
20 #define MRP_VECATTR_HDR_FLAG_LA cpu_to_be16(0x2000)
23 enum mrp_vecattr_event {
24 MRP_VECATTR_EVENT_NEW,
25 MRP_VECATTR_EVENT_JOIN_IN,
26 MRP_VECATTR_EVENT_IN,
27 MRP_VECATTR_EVENT_JOIN_MT,
28 MRP_VECATTR_EVENT_MT,
29 MRP_VECATTR_EVENT_LV,
30 __MRP_VECATTR_EVENT_MAX
33 struct mrp_skb_cb {
34 struct mrp_msg_hdr *mh;
35 struct mrp_vecattr_hdr *vah;
36 unsigned char attrvalue[];
39 static inline struct mrp_skb_cb *mrp_cb(struct sk_buff *skb)
41 BUILD_BUG_ON(sizeof(struct mrp_skb_cb) >
42 FIELD_SIZEOF(struct sk_buff, cb));
43 return (struct mrp_skb_cb *)skb->cb;
46 enum mrp_applicant_state {
47 MRP_APPLICANT_INVALID,
48 MRP_APPLICANT_VO,
49 MRP_APPLICANT_VP,
50 MRP_APPLICANT_VN,
51 MRP_APPLICANT_AN,
52 MRP_APPLICANT_AA,
53 MRP_APPLICANT_QA,
54 MRP_APPLICANT_LA,
55 MRP_APPLICANT_AO,
56 MRP_APPLICANT_QO,
57 MRP_APPLICANT_AP,
58 MRP_APPLICANT_QP,
59 __MRP_APPLICANT_MAX
61 #define MRP_APPLICANT_MAX (__MRP_APPLICANT_MAX - 1)
63 enum mrp_event {
64 MRP_EVENT_NEW,
65 MRP_EVENT_JOIN,
66 MRP_EVENT_LV,
67 MRP_EVENT_TX,
68 MRP_EVENT_R_NEW,
69 MRP_EVENT_R_JOIN_IN,
70 MRP_EVENT_R_IN,
71 MRP_EVENT_R_JOIN_MT,
72 MRP_EVENT_R_MT,
73 MRP_EVENT_R_LV,
74 MRP_EVENT_R_LA,
75 MRP_EVENT_REDECLARE,
76 MRP_EVENT_PERIODIC,
77 __MRP_EVENT_MAX
79 #define MRP_EVENT_MAX (__MRP_EVENT_MAX - 1)
81 enum mrp_tx_action {
82 MRP_TX_ACTION_NONE,
83 MRP_TX_ACTION_S_NEW,
84 MRP_TX_ACTION_S_JOIN_IN,
85 MRP_TX_ACTION_S_JOIN_IN_OPTIONAL,
86 MRP_TX_ACTION_S_IN_OPTIONAL,
87 MRP_TX_ACTION_S_LV,
90 struct mrp_attr {
91 struct rb_node node;
92 enum mrp_applicant_state state;
93 u8 type;
94 u8 len;
95 unsigned char value[];
98 enum mrp_applications {
99 MRP_APPLICATION_MVRP,
100 __MRP_APPLICATION_MAX
102 #define MRP_APPLICATION_MAX (__MRP_APPLICATION_MAX - 1)
104 struct mrp_application {
105 enum mrp_applications type;
106 unsigned int maxattr;
107 struct packet_type pkttype;
108 unsigned char group_address[ETH_ALEN];
109 u8 version;
112 struct mrp_applicant {
113 struct mrp_application *app;
114 struct net_device *dev;
115 struct timer_list join_timer;
116 struct timer_list periodic_timer;
118 spinlock_t lock;
119 struct sk_buff_head queue;
120 struct sk_buff *pdu;
121 struct rb_root mad;
122 struct rcu_head rcu;
125 struct mrp_port {
126 struct mrp_applicant __rcu *applicants[MRP_APPLICATION_MAX + 1];
127 struct rcu_head rcu;
130 int mrp_register_application(struct mrp_application *app);
131 void mrp_unregister_application(struct mrp_application *app);
133 int mrp_init_applicant(struct net_device *dev, struct mrp_application *app);
134 void mrp_uninit_applicant(struct net_device *dev, struct mrp_application *app);
136 int mrp_request_join(const struct net_device *dev,
137 const struct mrp_application *app,
138 const void *value, u8 len, u8 type);
139 void mrp_request_leave(const struct net_device *dev,
140 const struct mrp_application *app,
141 const void *value, u8 len, u8 type);
143 #endif /* _NET_MRP_H */