1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _NET_MRP_H 2 #ifndef _NET_MRP_H 3 #define _NET_MRP_H 3 #define _NET_MRP_H 4 4 5 #include <linux/netdevice.h> << 6 #include <linux/skbuff.h> << 7 #include <linux/types.h> << 8 << 9 #define MRP_END_MARK 0x0 5 #define MRP_END_MARK 0x0 10 6 11 struct mrp_pdu_hdr { 7 struct mrp_pdu_hdr { 12 u8 version; 8 u8 version; 13 }; 9 }; 14 10 15 struct mrp_msg_hdr { 11 struct mrp_msg_hdr { 16 u8 attrtype; 12 u8 attrtype; 17 u8 attrlen; 13 u8 attrlen; 18 }; 14 }; 19 15 20 struct mrp_vecattr_hdr { 16 struct mrp_vecattr_hdr { 21 __be16 lenflags; 17 __be16 lenflags; 22 unsigned char firstattrvalue[]; 18 unsigned char firstattrvalue[]; 23 #define MRP_VECATTR_HDR_LEN_MASK cpu_to_be16(0 19 #define MRP_VECATTR_HDR_LEN_MASK cpu_to_be16(0x1FFF) 24 #define MRP_VECATTR_HDR_FLAG_LA cpu_to_be16(0x 20 #define MRP_VECATTR_HDR_FLAG_LA cpu_to_be16(0x2000) 25 }; 21 }; 26 22 27 enum mrp_vecattr_event { 23 enum mrp_vecattr_event { 28 MRP_VECATTR_EVENT_NEW, 24 MRP_VECATTR_EVENT_NEW, 29 MRP_VECATTR_EVENT_JOIN_IN, 25 MRP_VECATTR_EVENT_JOIN_IN, 30 MRP_VECATTR_EVENT_IN, 26 MRP_VECATTR_EVENT_IN, 31 MRP_VECATTR_EVENT_JOIN_MT, 27 MRP_VECATTR_EVENT_JOIN_MT, 32 MRP_VECATTR_EVENT_MT, 28 MRP_VECATTR_EVENT_MT, 33 MRP_VECATTR_EVENT_LV, 29 MRP_VECATTR_EVENT_LV, 34 __MRP_VECATTR_EVENT_MAX 30 __MRP_VECATTR_EVENT_MAX 35 }; 31 }; 36 32 37 struct mrp_skb_cb { 33 struct mrp_skb_cb { 38 struct mrp_msg_hdr *mh; 34 struct mrp_msg_hdr *mh; 39 struct mrp_vecattr_hdr *vah; 35 struct mrp_vecattr_hdr *vah; 40 unsigned char attrvalue[]; 36 unsigned char attrvalue[]; 41 }; 37 }; 42 38 43 static inline struct mrp_skb_cb *mrp_cb(struct 39 static inline struct mrp_skb_cb *mrp_cb(struct sk_buff *skb) 44 { 40 { 45 BUILD_BUG_ON(sizeof(struct mrp_skb_cb) 41 BUILD_BUG_ON(sizeof(struct mrp_skb_cb) > 46 sizeof_field(struct sk_bu !! 42 FIELD_SIZEOF(struct sk_buff, cb)); 47 return (struct mrp_skb_cb *)skb->cb; 43 return (struct mrp_skb_cb *)skb->cb; 48 } 44 } 49 45 50 enum mrp_applicant_state { 46 enum mrp_applicant_state { 51 MRP_APPLICANT_INVALID, 47 MRP_APPLICANT_INVALID, 52 MRP_APPLICANT_VO, 48 MRP_APPLICANT_VO, 53 MRP_APPLICANT_VP, 49 MRP_APPLICANT_VP, 54 MRP_APPLICANT_VN, 50 MRP_APPLICANT_VN, 55 MRP_APPLICANT_AN, 51 MRP_APPLICANT_AN, 56 MRP_APPLICANT_AA, 52 MRP_APPLICANT_AA, 57 MRP_APPLICANT_QA, 53 MRP_APPLICANT_QA, 58 MRP_APPLICANT_LA, 54 MRP_APPLICANT_LA, 59 MRP_APPLICANT_AO, 55 MRP_APPLICANT_AO, 60 MRP_APPLICANT_QO, 56 MRP_APPLICANT_QO, 61 MRP_APPLICANT_AP, 57 MRP_APPLICANT_AP, 62 MRP_APPLICANT_QP, 58 MRP_APPLICANT_QP, 63 __MRP_APPLICANT_MAX 59 __MRP_APPLICANT_MAX 64 }; 60 }; 65 #define MRP_APPLICANT_MAX (__MRP_APPLICA 61 #define MRP_APPLICANT_MAX (__MRP_APPLICANT_MAX - 1) 66 62 67 enum mrp_event { 63 enum mrp_event { 68 MRP_EVENT_NEW, 64 MRP_EVENT_NEW, 69 MRP_EVENT_JOIN, 65 MRP_EVENT_JOIN, 70 MRP_EVENT_LV, 66 MRP_EVENT_LV, 71 MRP_EVENT_TX, 67 MRP_EVENT_TX, 72 MRP_EVENT_R_NEW, 68 MRP_EVENT_R_NEW, 73 MRP_EVENT_R_JOIN_IN, 69 MRP_EVENT_R_JOIN_IN, 74 MRP_EVENT_R_IN, 70 MRP_EVENT_R_IN, 75 MRP_EVENT_R_JOIN_MT, 71 MRP_EVENT_R_JOIN_MT, 76 MRP_EVENT_R_MT, 72 MRP_EVENT_R_MT, 77 MRP_EVENT_R_LV, 73 MRP_EVENT_R_LV, 78 MRP_EVENT_R_LA, 74 MRP_EVENT_R_LA, 79 MRP_EVENT_REDECLARE, 75 MRP_EVENT_REDECLARE, 80 MRP_EVENT_PERIODIC, 76 MRP_EVENT_PERIODIC, 81 __MRP_EVENT_MAX 77 __MRP_EVENT_MAX 82 }; 78 }; 83 #define MRP_EVENT_MAX (__MRP_EVENT_M 79 #define MRP_EVENT_MAX (__MRP_EVENT_MAX - 1) 84 80 85 enum mrp_tx_action { 81 enum mrp_tx_action { 86 MRP_TX_ACTION_NONE, 82 MRP_TX_ACTION_NONE, 87 MRP_TX_ACTION_S_NEW, 83 MRP_TX_ACTION_S_NEW, 88 MRP_TX_ACTION_S_JOIN_IN, 84 MRP_TX_ACTION_S_JOIN_IN, 89 MRP_TX_ACTION_S_JOIN_IN_OPTIONAL, 85 MRP_TX_ACTION_S_JOIN_IN_OPTIONAL, 90 MRP_TX_ACTION_S_IN_OPTIONAL, 86 MRP_TX_ACTION_S_IN_OPTIONAL, 91 MRP_TX_ACTION_S_LV, 87 MRP_TX_ACTION_S_LV, 92 }; 88 }; 93 89 94 struct mrp_attr { 90 struct mrp_attr { 95 struct rb_node node; 91 struct rb_node node; 96 enum mrp_applicant_state state; 92 enum mrp_applicant_state state; 97 u8 type; 93 u8 type; 98 u8 len; 94 u8 len; 99 unsigned char value[ 95 unsigned char value[]; 100 }; 96 }; 101 97 102 enum mrp_applications { 98 enum mrp_applications { 103 MRP_APPLICATION_MVRP, 99 MRP_APPLICATION_MVRP, 104 __MRP_APPLICATION_MAX 100 __MRP_APPLICATION_MAX 105 }; 101 }; 106 #define MRP_APPLICATION_MAX (__MRP_APPLICA 102 #define MRP_APPLICATION_MAX (__MRP_APPLICATION_MAX - 1) 107 103 108 struct mrp_application { 104 struct mrp_application { 109 enum mrp_applications type; 105 enum mrp_applications type; 110 unsigned int maxattr; 106 unsigned int maxattr; 111 struct packet_type pkttype; 107 struct packet_type pkttype; 112 unsigned char group_address[ 108 unsigned char group_address[ETH_ALEN]; 113 u8 version; 109 u8 version; 114 }; 110 }; 115 111 116 struct mrp_applicant { 112 struct mrp_applicant { 117 struct mrp_application *app; 113 struct mrp_application *app; 118 struct net_device *dev; 114 struct net_device *dev; 119 struct timer_list join_timer; 115 struct timer_list join_timer; 120 struct timer_list periodic_timer 116 struct timer_list periodic_timer; 121 117 122 spinlock_t lock; 118 spinlock_t lock; 123 struct sk_buff_head queue; 119 struct sk_buff_head queue; 124 struct sk_buff *pdu; 120 struct sk_buff *pdu; 125 struct rb_root mad; 121 struct rb_root mad; 126 struct rcu_head rcu; 122 struct rcu_head rcu; 127 bool active; 123 bool active; 128 }; 124 }; 129 125 130 struct mrp_port { 126 struct mrp_port { 131 struct mrp_applicant __rcu *appli 127 struct mrp_applicant __rcu *applicants[MRP_APPLICATION_MAX + 1]; 132 struct rcu_head rcu; 128 struct rcu_head rcu; 133 }; 129 }; 134 130 135 int mrp_register_application(struct mrp_applic 131 int mrp_register_application(struct mrp_application *app); 136 void mrp_unregister_application(struct mrp_app 132 void mrp_unregister_application(struct mrp_application *app); 137 133 138 int mrp_init_applicant(struct net_device *dev, 134 int mrp_init_applicant(struct net_device *dev, struct mrp_application *app); 139 void mrp_uninit_applicant(struct net_device *d 135 void mrp_uninit_applicant(struct net_device *dev, struct mrp_application *app); 140 136 141 int mrp_request_join(const struct net_device * 137 int mrp_request_join(const struct net_device *dev, 142 const struct mrp_applicat 138 const struct mrp_application *app, 143 const void *value, u8 len 139 const void *value, u8 len, u8 type); 144 void mrp_request_leave(const struct net_device 140 void mrp_request_leave(const struct net_device *dev, 145 const struct mrp_applic 141 const struct mrp_application *app, 146 const void *value, u8 l 142 const void *value, u8 len, u8 type); 147 143 148 #endif /* _NET_MRP_H */ 144 #endif /* _NET_MRP_H */ 149 145
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.