blob: 1c308c034e1a6835cd9e4cf9b2f4069a58060a04 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
David Wardfebf0182013-02-08 17:17:06 +00002#ifndef _NET_MRP_H
3#define _NET_MRP_H
4
5#define MRP_END_MARK 0x0
6
7struct mrp_pdu_hdr {
8 u8 version;
9};
10
11struct mrp_msg_hdr {
12 u8 attrtype;
13 u8 attrlen;
14};
15
16struct 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)
21};
22
23enum 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
31};
32
33struct mrp_skb_cb {
34 struct mrp_msg_hdr *mh;
35 struct mrp_vecattr_hdr *vah;
36 unsigned char attrvalue[];
37};
38
39static inline struct mrp_skb_cb *mrp_cb(struct sk_buff *skb)
40{
41 BUILD_BUG_ON(sizeof(struct mrp_skb_cb) >
Pankaj Bharadiyac5936422019-12-09 10:31:43 -080042 sizeof_field(struct sk_buff, cb));
David Wardfebf0182013-02-08 17:17:06 +000043 return (struct mrp_skb_cb *)skb->cb;
44}
45
46enum 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
60};
61#define MRP_APPLICANT_MAX (__MRP_APPLICANT_MAX - 1)
62
63enum 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
78};
79#define MRP_EVENT_MAX (__MRP_EVENT_MAX - 1)
80
81enum 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,
88};
89
90struct mrp_attr {
91 struct rb_node node;
92 enum mrp_applicant_state state;
93 u8 type;
94 u8 len;
95 unsigned char value[];
96};
97
98enum mrp_applications {
99 MRP_APPLICATION_MVRP,
100 __MRP_APPLICATION_MAX
101};
102#define MRP_APPLICATION_MAX (__MRP_APPLICATION_MAX - 1)
103
104struct 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;
110};
111
112struct mrp_applicant {
113 struct mrp_application *app;
114 struct net_device *dev;
115 struct timer_list join_timer;
Noel Burton-Krahn9fe34f52013-09-18 12:24:40 -0700116 struct timer_list periodic_timer;
David Wardfebf0182013-02-08 17:17:06 +0000117
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;
123};
124
125struct mrp_port {
126 struct mrp_applicant __rcu *applicants[MRP_APPLICATION_MAX + 1];
127 struct rcu_head rcu;
128};
129
Joe Perchesa5be1eb2013-09-21 10:22:46 -0700130int mrp_register_application(struct mrp_application *app);
131void mrp_unregister_application(struct mrp_application *app);
David Wardfebf0182013-02-08 17:17:06 +0000132
Joe Perchesa5be1eb2013-09-21 10:22:46 -0700133int mrp_init_applicant(struct net_device *dev, struct mrp_application *app);
134void mrp_uninit_applicant(struct net_device *dev, struct mrp_application *app);
David Wardfebf0182013-02-08 17:17:06 +0000135
Joe Perchesa5be1eb2013-09-21 10:22:46 -0700136int mrp_request_join(const struct net_device *dev,
137 const struct mrp_application *app,
138 const void *value, u8 len, u8 type);
139void mrp_request_leave(const struct net_device *dev,
140 const struct mrp_application *app,
141 const void *value, u8 len, u8 type);
David Wardfebf0182013-02-08 17:17:06 +0000142
143#endif /* _NET_MRP_H */