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