David Ward | febf018 | 2013-02-08 17:17:06 +0000 | [diff] [blame] | 1 | #ifndef _NET_MRP_H |
| 2 | #define _NET_MRP_H |
| 3 | |
| 4 | #define MRP_END_MARK 0x0 |
| 5 | |
| 6 | struct mrp_pdu_hdr { |
| 7 | u8 version; |
| 8 | }; |
| 9 | |
| 10 | struct mrp_msg_hdr { |
| 11 | u8 attrtype; |
| 12 | u8 attrlen; |
| 13 | }; |
| 14 | |
| 15 | struct mrp_vecattr_hdr { |
| 16 | __be16 lenflags; |
| 17 | unsigned char firstattrvalue[]; |
| 18 | #define MRP_VECATTR_HDR_LEN_MASK cpu_to_be16(0x1FFF) |
| 19 | #define MRP_VECATTR_HDR_FLAG_LA cpu_to_be16(0x2000) |
| 20 | }; |
| 21 | |
| 22 | enum mrp_vecattr_event { |
| 23 | MRP_VECATTR_EVENT_NEW, |
| 24 | MRP_VECATTR_EVENT_JOIN_IN, |
| 25 | MRP_VECATTR_EVENT_IN, |
| 26 | MRP_VECATTR_EVENT_JOIN_MT, |
| 27 | MRP_VECATTR_EVENT_MT, |
| 28 | MRP_VECATTR_EVENT_LV, |
| 29 | __MRP_VECATTR_EVENT_MAX |
| 30 | }; |
| 31 | |
| 32 | struct mrp_skb_cb { |
| 33 | struct mrp_msg_hdr *mh; |
| 34 | struct mrp_vecattr_hdr *vah; |
| 35 | unsigned char attrvalue[]; |
| 36 | }; |
| 37 | |
| 38 | static inline struct mrp_skb_cb *mrp_cb(struct sk_buff *skb) |
| 39 | { |
| 40 | BUILD_BUG_ON(sizeof(struct mrp_skb_cb) > |
| 41 | FIELD_SIZEOF(struct sk_buff, cb)); |
| 42 | return (struct mrp_skb_cb *)skb->cb; |
| 43 | } |
| 44 | |
| 45 | enum mrp_applicant_state { |
| 46 | MRP_APPLICANT_INVALID, |
| 47 | MRP_APPLICANT_VO, |
| 48 | MRP_APPLICANT_VP, |
| 49 | MRP_APPLICANT_VN, |
| 50 | MRP_APPLICANT_AN, |
| 51 | MRP_APPLICANT_AA, |
| 52 | MRP_APPLICANT_QA, |
| 53 | MRP_APPLICANT_LA, |
| 54 | MRP_APPLICANT_AO, |
| 55 | MRP_APPLICANT_QO, |
| 56 | MRP_APPLICANT_AP, |
| 57 | MRP_APPLICANT_QP, |
| 58 | __MRP_APPLICANT_MAX |
| 59 | }; |
| 60 | #define MRP_APPLICANT_MAX (__MRP_APPLICANT_MAX - 1) |
| 61 | |
| 62 | enum mrp_event { |
| 63 | MRP_EVENT_NEW, |
| 64 | MRP_EVENT_JOIN, |
| 65 | MRP_EVENT_LV, |
| 66 | MRP_EVENT_TX, |
| 67 | MRP_EVENT_R_NEW, |
| 68 | MRP_EVENT_R_JOIN_IN, |
| 69 | MRP_EVENT_R_IN, |
| 70 | MRP_EVENT_R_JOIN_MT, |
| 71 | MRP_EVENT_R_MT, |
| 72 | MRP_EVENT_R_LV, |
| 73 | MRP_EVENT_R_LA, |
| 74 | MRP_EVENT_REDECLARE, |
| 75 | MRP_EVENT_PERIODIC, |
| 76 | __MRP_EVENT_MAX |
| 77 | }; |
| 78 | #define MRP_EVENT_MAX (__MRP_EVENT_MAX - 1) |
| 79 | |
| 80 | enum mrp_tx_action { |
| 81 | MRP_TX_ACTION_NONE, |
| 82 | MRP_TX_ACTION_S_NEW, |
| 83 | MRP_TX_ACTION_S_JOIN_IN, |
| 84 | MRP_TX_ACTION_S_JOIN_IN_OPTIONAL, |
| 85 | MRP_TX_ACTION_S_IN_OPTIONAL, |
| 86 | MRP_TX_ACTION_S_LV, |
| 87 | }; |
| 88 | |
| 89 | struct mrp_attr { |
| 90 | struct rb_node node; |
| 91 | enum mrp_applicant_state state; |
| 92 | u8 type; |
| 93 | u8 len; |
| 94 | unsigned char value[]; |
| 95 | }; |
| 96 | |
| 97 | enum mrp_applications { |
| 98 | MRP_APPLICATION_MVRP, |
| 99 | __MRP_APPLICATION_MAX |
| 100 | }; |
| 101 | #define MRP_APPLICATION_MAX (__MRP_APPLICATION_MAX - 1) |
| 102 | |
| 103 | struct mrp_application { |
| 104 | enum mrp_applications type; |
| 105 | unsigned int maxattr; |
| 106 | struct packet_type pkttype; |
| 107 | unsigned char group_address[ETH_ALEN]; |
| 108 | u8 version; |
| 109 | }; |
| 110 | |
| 111 | struct mrp_applicant { |
| 112 | struct mrp_application *app; |
| 113 | struct net_device *dev; |
| 114 | struct timer_list join_timer; |
Noel Burton-Krahn | 9fe34f5 | 2013-09-18 12:24:40 -0700 | [diff] [blame] | 115 | struct timer_list periodic_timer; |
David Ward | febf018 | 2013-02-08 17:17:06 +0000 | [diff] [blame] | 116 | |
| 117 | spinlock_t lock; |
| 118 | struct sk_buff_head queue; |
| 119 | struct sk_buff *pdu; |
| 120 | struct rb_root mad; |
| 121 | struct rcu_head rcu; |
| 122 | }; |
| 123 | |
| 124 | struct mrp_port { |
| 125 | struct mrp_applicant __rcu *applicants[MRP_APPLICATION_MAX + 1]; |
| 126 | struct rcu_head rcu; |
| 127 | }; |
| 128 | |
Joe Perches | a5be1eb | 2013-09-21 10:22:46 -0700 | [diff] [blame] | 129 | int mrp_register_application(struct mrp_application *app); |
| 130 | void mrp_unregister_application(struct mrp_application *app); |
David Ward | febf018 | 2013-02-08 17:17:06 +0000 | [diff] [blame] | 131 | |
Joe Perches | a5be1eb | 2013-09-21 10:22:46 -0700 | [diff] [blame] | 132 | int mrp_init_applicant(struct net_device *dev, struct mrp_application *app); |
| 133 | void mrp_uninit_applicant(struct net_device *dev, struct mrp_application *app); |
David Ward | febf018 | 2013-02-08 17:17:06 +0000 | [diff] [blame] | 134 | |
Joe Perches | a5be1eb | 2013-09-21 10:22:46 -0700 | [diff] [blame] | 135 | int mrp_request_join(const struct net_device *dev, |
| 136 | const struct mrp_application *app, |
| 137 | const void *value, u8 len, u8 type); |
| 138 | void mrp_request_leave(const struct net_device *dev, |
| 139 | const struct mrp_application *app, |
| 140 | const void *value, u8 len, u8 type); |
David Ward | febf018 | 2013-02-08 17:17:06 +0000 | [diff] [blame] | 141 | |
| 142 | #endif /* _NET_MRP_H */ |