0001
0002
0003
0004
0005
0006
0007
0008 #ifndef IEEE80211S_H
0009 #define IEEE80211S_H
0010
0011 #include <linux/types.h>
0012 #include <linux/jhash.h>
0013 #include "ieee80211_i.h"
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 enum mesh_path_flags {
0037 MESH_PATH_ACTIVE = BIT(0),
0038 MESH_PATH_RESOLVING = BIT(1),
0039 MESH_PATH_SN_VALID = BIT(2),
0040 MESH_PATH_FIXED = BIT(3),
0041 MESH_PATH_RESOLVED = BIT(4),
0042 MESH_PATH_REQ_QUEUED = BIT(5),
0043 MESH_PATH_DELETED = BIT(6),
0044 };
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 enum mesh_deferred_task_flags {
0058 MESH_WORK_HOUSEKEEPING,
0059 MESH_WORK_ROOT,
0060 MESH_WORK_DRIFT_ADJUST,
0061 MESH_WORK_MBSS_CHANGED,
0062 };
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103 struct mesh_path {
0104 u8 dst[ETH_ALEN];
0105 u8 mpp[ETH_ALEN];
0106 struct rhash_head rhash;
0107 struct hlist_node walk_list;
0108 struct hlist_node gate_list;
0109 struct ieee80211_sub_if_data *sdata;
0110 struct sta_info __rcu *next_hop;
0111 struct timer_list timer;
0112 struct sk_buff_head frame_queue;
0113 struct rcu_head rcu;
0114 u32 sn;
0115 u32 metric;
0116 u8 hop_count;
0117 unsigned long exp_time;
0118 u32 discovery_timeout;
0119 u8 discovery_retries;
0120 enum mesh_path_flags flags;
0121 spinlock_t state_lock;
0122 u8 rann_snd_addr[ETH_ALEN];
0123 u32 rann_metric;
0124 unsigned long last_preq_to_root;
0125 bool is_root;
0126 bool is_gate;
0127 u32 path_change_count;
0128 };
0129
0130
0131
0132 #define RMC_BUCKETS 256
0133 #define RMC_QUEUE_MAX_LEN 4
0134 #define RMC_TIMEOUT (3 * HZ)
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148 struct rmc_entry {
0149 struct hlist_node list;
0150 unsigned long exp_time;
0151 u32 seqnum;
0152 u8 sa[ETH_ALEN];
0153 };
0154
0155 struct mesh_rmc {
0156 struct hlist_head bucket[RMC_BUCKETS];
0157 u32 idx_mask;
0158 };
0159
0160 #define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
0161
0162 #define MESH_PATH_EXPIRE (600 * HZ)
0163
0164
0165 #define MESH_MAX_PLINKS 256
0166
0167
0168 #define MESH_MAX_MPATHS 1024
0169
0170
0171 #define MESH_FRAME_QUEUE_LEN 10
0172
0173
0174
0175 int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
0176 const u8 *da, const u8 *sa);
0177 unsigned int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata,
0178 struct ieee80211s_hdr *meshhdr,
0179 const char *addr4or5, const char *addr6);
0180 int mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
0181 const u8 *addr, struct ieee80211s_hdr *mesh_hdr);
0182 bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
0183 struct ieee802_11_elems *ie);
0184 void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
0185 int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
0186 struct sk_buff *skb);
0187 int mesh_add_meshid_ie(struct ieee80211_sub_if_data *sdata,
0188 struct sk_buff *skb);
0189 int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata,
0190 struct sk_buff *skb);
0191 int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,
0192 struct sk_buff *skb);
0193 int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata,
0194 struct sk_buff *skb);
0195 int mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata,
0196 struct sk_buff *skb);
0197 int mesh_add_vht_cap_ie(struct ieee80211_sub_if_data *sdata,
0198 struct sk_buff *skb);
0199 int mesh_add_vht_oper_ie(struct ieee80211_sub_if_data *sdata,
0200 struct sk_buff *skb);
0201 int mesh_add_he_cap_ie(struct ieee80211_sub_if_data *sdata,
0202 struct sk_buff *skb, u8 ie_len);
0203 int mesh_add_he_oper_ie(struct ieee80211_sub_if_data *sdata,
0204 struct sk_buff *skb);
0205 int mesh_add_he_6ghz_cap_ie(struct ieee80211_sub_if_data *sdata,
0206 struct sk_buff *skb);
0207 void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
0208 int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
0209 void ieee80211s_init(void);
0210 void ieee80211s_update_metric(struct ieee80211_local *local,
0211 struct sta_info *sta,
0212 struct ieee80211_tx_status *st);
0213 void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
0214 void ieee80211_mesh_teardown_sdata(struct ieee80211_sub_if_data *sdata);
0215 int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
0216 void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
0217 void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
0218 const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method);
0219
0220 void ieee80211_mbss_info_change_notify(struct ieee80211_sub_if_data *sdata,
0221 u32 changed);
0222
0223
0224 u32 ieee80211_mps_local_status_update(struct ieee80211_sub_if_data *sdata);
0225 u32 ieee80211_mps_set_sta_local_pm(struct sta_info *sta,
0226 enum nl80211_mesh_power_mode pm);
0227 void ieee80211_mps_set_frame_flags(struct ieee80211_sub_if_data *sdata,
0228 struct sta_info *sta,
0229 struct ieee80211_hdr *hdr);
0230 void ieee80211_mps_sta_status_update(struct sta_info *sta);
0231 void ieee80211_mps_rx_h_sta_process(struct sta_info *sta,
0232 struct ieee80211_hdr *hdr);
0233 void ieee80211_mpsp_trigger_process(u8 *qc, struct sta_info *sta,
0234 bool tx, bool acked);
0235 void ieee80211_mps_frame_release(struct sta_info *sta,
0236 struct ieee802_11_elems *elems);
0237
0238
0239 int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata,
0240 struct sk_buff *skb);
0241 int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata,
0242 struct sk_buff *skb);
0243 void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
0244 struct mesh_path *mesh_path_lookup(struct ieee80211_sub_if_data *sdata,
0245 const u8 *dst);
0246 struct mesh_path *mpp_path_lookup(struct ieee80211_sub_if_data *sdata,
0247 const u8 *dst);
0248 int mpp_path_add(struct ieee80211_sub_if_data *sdata,
0249 const u8 *dst, const u8 *mpp);
0250 struct mesh_path *
0251 mesh_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx);
0252 struct mesh_path *
0253 mpp_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx);
0254 void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
0255 void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
0256 void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
0257 struct ieee80211_mgmt *mgmt, size_t len);
0258 struct mesh_path *
0259 mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst);
0260
0261 int mesh_path_add_gate(struct mesh_path *mpath);
0262 int mesh_path_send_to_gates(struct mesh_path *mpath);
0263 int mesh_gate_num(struct ieee80211_sub_if_data *sdata);
0264 u32 airtime_link_metric_get(struct ieee80211_local *local,
0265 struct sta_info *sta);
0266
0267
0268 void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
0269 u8 *hw_addr, struct ieee802_11_elems *ie,
0270 struct ieee80211_rx_status *rx_status);
0271 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
0272 u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
0273 void mesh_plink_timer(struct timer_list *t);
0274 void mesh_plink_broken(struct sta_info *sta);
0275 u32 mesh_plink_deactivate(struct sta_info *sta);
0276 u32 mesh_plink_open(struct sta_info *sta);
0277 u32 mesh_plink_block(struct sta_info *sta);
0278 void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
0279 struct ieee80211_mgmt *mgmt, size_t len,
0280 struct ieee80211_rx_status *rx_status);
0281 void mesh_sta_cleanup(struct sta_info *sta);
0282
0283
0284
0285 int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
0286 u8 ttl, const u8 *target, u32 target_sn,
0287 u16 target_rcode, const u8 *ra);
0288 void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
0289 void mesh_path_flush_pending(struct mesh_path *mpath);
0290 void mesh_path_tx_pending(struct mesh_path *mpath);
0291 void mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata);
0292 void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata);
0293 int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr);
0294 void mesh_path_timer(struct timer_list *t);
0295 void mesh_path_flush_by_nexthop(struct sta_info *sta);
0296 void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
0297 struct sk_buff *skb);
0298 void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
0299
0300 bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
0301
0302 #ifdef CONFIG_MAC80211_MESH
0303 static inline
0304 u32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata)
0305 {
0306 atomic_inc(&sdata->u.mesh.estab_plinks);
0307 return mesh_accept_plinks_update(sdata) | BSS_CHANGED_BEACON;
0308 }
0309
0310 static inline
0311 u32 mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata)
0312 {
0313 atomic_dec(&sdata->u.mesh.estab_plinks);
0314 return mesh_accept_plinks_update(sdata) | BSS_CHANGED_BEACON;
0315 }
0316
0317 static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
0318 {
0319 return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
0320 atomic_read(&sdata->u.mesh.estab_plinks);
0321 }
0322
0323 static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
0324 {
0325 return (min_t(long, mesh_plink_free_count(sdata),
0326 MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
0327 }
0328
0329 static inline void mesh_path_activate(struct mesh_path *mpath)
0330 {
0331 mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
0332 }
0333
0334 static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
0335 {
0336 return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
0337 }
0338
0339 void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
0340 void mesh_sync_adjust_tsf(struct ieee80211_sub_if_data *sdata);
0341 void ieee80211s_stop(void);
0342 #else
0343 static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
0344 { return false; }
0345 static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
0346 {}
0347 static inline void ieee80211s_stop(void) {}
0348 #endif
0349
0350 #endif