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