1ccf80ddfSLuis Carlos Cobo /* 2264d9b7dSRui Paulo * Copyright (c) 2008, 2009 open80211s Ltd. 3ccf80ddfSLuis Carlos Cobo * Authors: Luis Carlos Cobo <luisca@cozybit.com> 4ccf80ddfSLuis Carlos Cobo * Javier Cardona <javier@cozybit.com> 5ccf80ddfSLuis Carlos Cobo * 6ccf80ddfSLuis Carlos Cobo * This program is free software; you can redistribute it and/or modify 7ccf80ddfSLuis Carlos Cobo * it under the terms of the GNU General Public License version 2 as 8ccf80ddfSLuis Carlos Cobo * published by the Free Software Foundation. 9ccf80ddfSLuis Carlos Cobo */ 10ccf80ddfSLuis Carlos Cobo 11ccf80ddfSLuis Carlos Cobo #ifndef IEEE80211S_H 12ccf80ddfSLuis Carlos Cobo #define IEEE80211S_H 13ccf80ddfSLuis Carlos Cobo 14902acc78SJohannes Berg #include <linux/types.h> 15ccf80ddfSLuis Carlos Cobo #include <linux/jhash.h> 16902acc78SJohannes Berg #include "ieee80211_i.h" 17ccf80ddfSLuis Carlos Cobo 18ccf80ddfSLuis Carlos Cobo 19ccf80ddfSLuis Carlos Cobo /* Data structures */ 20ccf80ddfSLuis Carlos Cobo 21ccf80ddfSLuis Carlos Cobo /** 22ccf80ddfSLuis Carlos Cobo * enum mesh_path_flags - mac80211 mesh path flags 23ccf80ddfSLuis Carlos Cobo * 24ccf80ddfSLuis Carlos Cobo * 25ccf80ddfSLuis Carlos Cobo * 26eb80ed8dSRami Rosen * @MESH_PATH_ACTIVE: the mesh path can be used for forwarding 27eb80ed8dSRami Rosen * @MESH_PATH_RESOLVING: the discovery process is running for this mesh path 28d19b3bf6SRui Paulo * @MESH_PATH_SN_VALID: the mesh path contains a valid destination sequence 29ccf80ddfSLuis Carlos Cobo * number 30ccf80ddfSLuis Carlos Cobo * @MESH_PATH_FIXED: the mesh path has been manually set and should not be 31ccf80ddfSLuis Carlos Cobo * modified 32ccf80ddfSLuis Carlos Cobo * @MESH_PATH_RESOLVED: the mesh path can has been resolved 33f3011cf9SJavier Cardona * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination 34f3011cf9SJavier Cardona * already queued up, waiting for the discovery process to start. 35ccf80ddfSLuis Carlos Cobo * 36eb80ed8dSRami Rosen * MESH_PATH_RESOLVED is used by the mesh path timer to 37ccf80ddfSLuis Carlos Cobo * decide when to stop or cancel the mesh path discovery. 38ccf80ddfSLuis Carlos Cobo */ 39ccf80ddfSLuis Carlos Cobo enum mesh_path_flags { 40ccf80ddfSLuis Carlos Cobo MESH_PATH_ACTIVE = BIT(0), 41ccf80ddfSLuis Carlos Cobo MESH_PATH_RESOLVING = BIT(1), 42d19b3bf6SRui Paulo MESH_PATH_SN_VALID = BIT(2), 43ccf80ddfSLuis Carlos Cobo MESH_PATH_FIXED = BIT(3), 44ccf80ddfSLuis Carlos Cobo MESH_PATH_RESOLVED = BIT(4), 45f3011cf9SJavier Cardona MESH_PATH_REQ_QUEUED = BIT(5), 46ccf80ddfSLuis Carlos Cobo }; 47ccf80ddfSLuis Carlos Cobo 48ccf80ddfSLuis Carlos Cobo /** 4918889231SJavier Cardona * enum mesh_deferred_task_flags - mac80211 mesh deferred tasks 5018889231SJavier Cardona * 5118889231SJavier Cardona * 5218889231SJavier Cardona * 5318889231SJavier Cardona * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks 5418889231SJavier Cardona * @MESH_WORK_GROW_MPATH_TABLE: the mesh path table is full and needs 5518889231SJavier Cardona * to grow. 5618889231SJavier Cardona * @MESH_WORK_GROW_MPP_TABLE: the mesh portals table is full and needs to 5718889231SJavier Cardona * grow 58e304bfd3SRui Paulo * @MESH_WORK_ROOT: the mesh root station needs to send a frame 59dbf498fbSJavier Cardona * @MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other 60dbf498fbSJavier Cardona * mesh nodes 6118889231SJavier Cardona */ 6218889231SJavier Cardona enum mesh_deferred_task_flags { 6318889231SJavier Cardona MESH_WORK_HOUSEKEEPING, 6418889231SJavier Cardona MESH_WORK_GROW_MPATH_TABLE, 6518889231SJavier Cardona MESH_WORK_GROW_MPP_TABLE, 66e304bfd3SRui Paulo MESH_WORK_ROOT, 67dbf498fbSJavier Cardona MESH_WORK_DRIFT_ADJUST, 6818889231SJavier Cardona }; 6918889231SJavier Cardona 7018889231SJavier Cardona /** 71ccf80ddfSLuis Carlos Cobo * struct mesh_path - mac80211 mesh path structure 72ccf80ddfSLuis Carlos Cobo * 73ccf80ddfSLuis Carlos Cobo * @dst: mesh path destination mac address 74f698d856SJasper Bryant-Greene * @sdata: mesh subif 75ccf80ddfSLuis Carlos Cobo * @next_hop: mesh neighbor to which frames for this destination will be 76ccf80ddfSLuis Carlos Cobo * forwarded 77ccf80ddfSLuis Carlos Cobo * @timer: mesh path discovery timer 78ccf80ddfSLuis Carlos Cobo * @frame_queue: pending queue for frames sent to this destination while the 79ccf80ddfSLuis Carlos Cobo * path is unresolved 80d19b3bf6SRui Paulo * @sn: target sequence number 81ccf80ddfSLuis Carlos Cobo * @metric: current metric to this destination 82ccf80ddfSLuis Carlos Cobo * @hop_count: hops to destination 83ccf80ddfSLuis Carlos Cobo * @exp_time: in jiffies, when the path will expire or when it expired 84ccf80ddfSLuis Carlos Cobo * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery 85ccf80ddfSLuis Carlos Cobo * retry 86ccf80ddfSLuis Carlos Cobo * @discovery_retries: number of discovery retries 87ccf80ddfSLuis Carlos Cobo * @flags: mesh path flags, as specified on &enum mesh_path_flags 88f5e50cd0SJavier Cardona * @state_lock: mesh path state lock used to protect changes to the 89f5e50cd0SJavier Cardona * mpath itself. No need to take this lock when adding or removing 90f5e50cd0SJavier Cardona * an mpath to a hash bucket on a path table. 913d045a54SChun-Yeow Yeoh * @rann_snd_addr: the RANN sender address 92d2a079fdSChun-Yeow Yeoh * @rann_metric: the aggregated path metric towards the root node 93728b19e5SChun-Yeow Yeoh * @last_preq_to_root: Timestamp of last PREQ sent to root 943d045a54SChun-Yeow Yeoh * @is_root: the destination station of this path is a root node 955ee68e5bSJavier Cardona * @is_gate: the destination station of this path is a mesh gate 96ccf80ddfSLuis Carlos Cobo * 97ccf80ddfSLuis Carlos Cobo * 98f698d856SJasper Bryant-Greene * The combination of dst and sdata is unique in the mesh path table. Since the 99d0709a65SJohannes Berg * next_hop STA is only protected by RCU as well, deleting the STA must also 100d0709a65SJohannes Berg * remove/substitute the mesh_path structure and wait until that is no longer 101d0709a65SJohannes Berg * reachable before destroying the STA completely. 102ccf80ddfSLuis Carlos Cobo */ 103ccf80ddfSLuis Carlos Cobo struct mesh_path { 104ccf80ddfSLuis Carlos Cobo u8 dst[ETH_ALEN]; 10579617deeSYanBo u8 mpp[ETH_ALEN]; /* used for MPP or MAP */ 106f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata; 10740b275b6SJohannes Berg struct sta_info __rcu *next_hop; 108ccf80ddfSLuis Carlos Cobo struct timer_list timer; 109ccf80ddfSLuis Carlos Cobo struct sk_buff_head frame_queue; 110ccf80ddfSLuis Carlos Cobo struct rcu_head rcu; 111d19b3bf6SRui Paulo u32 sn; 112ccf80ddfSLuis Carlos Cobo u32 metric; 113ccf80ddfSLuis Carlos Cobo u8 hop_count; 114ccf80ddfSLuis Carlos Cobo unsigned long exp_time; 115ccf80ddfSLuis Carlos Cobo u32 discovery_timeout; 116ccf80ddfSLuis Carlos Cobo u8 discovery_retries; 117ccf80ddfSLuis Carlos Cobo enum mesh_path_flags flags; 118ccf80ddfSLuis Carlos Cobo spinlock_t state_lock; 1193d045a54SChun-Yeow Yeoh u8 rann_snd_addr[ETH_ALEN]; 120d2a079fdSChun-Yeow Yeoh u32 rann_metric; 121728b19e5SChun-Yeow Yeoh unsigned long last_preq_to_root; 1223d045a54SChun-Yeow Yeoh bool is_root; 1235ee68e5bSJavier Cardona bool is_gate; 124ccf80ddfSLuis Carlos Cobo }; 125ccf80ddfSLuis Carlos Cobo 126ccf80ddfSLuis Carlos Cobo /** 127ccf80ddfSLuis Carlos Cobo * struct mesh_table 128ccf80ddfSLuis Carlos Cobo * 129ccf80ddfSLuis Carlos Cobo * @hash_buckets: array of hash buckets of the table 130ccf80ddfSLuis Carlos Cobo * @hashwlock: array of locks to protect write operations, one per bucket 131ccf80ddfSLuis Carlos Cobo * @hash_mask: 2^size_order - 1, used to compute hash idx 132ccf80ddfSLuis Carlos Cobo * @hash_rnd: random value used for hash computations 133ccf80ddfSLuis Carlos Cobo * @entries: number of entries in the table 134ccf80ddfSLuis Carlos Cobo * @free_node: function to free nodes of the table 135eef35c2dSStefan Weil * @copy_node: function to copy nodes of the table 136ccf80ddfSLuis Carlos Cobo * @size_order: determines size of the table, there will be 2^size_order hash 137ccf80ddfSLuis Carlos Cobo * buckets 138ccf80ddfSLuis Carlos Cobo * @mean_chain_len: maximum average length for the hash buckets' list, if it is 139ccf80ddfSLuis Carlos Cobo * reached, the table will grow 1405ee68e5bSJavier Cardona * @known_gates: list of known mesh gates and their mpaths by the station. The 1415ee68e5bSJavier Cardona * gate's mpath may or may not be resolved and active. 1425ee68e5bSJavier Cardona * 1431928ecabSJohannes Berg * rcu_head: RCU head to free the table 144ccf80ddfSLuis Carlos Cobo */ 145ccf80ddfSLuis Carlos Cobo struct mesh_table { 146ccf80ddfSLuis Carlos Cobo /* Number of buckets will be 2^N */ 147ccf80ddfSLuis Carlos Cobo struct hlist_head *hash_buckets; 148ccf80ddfSLuis Carlos Cobo spinlock_t *hashwlock; /* One per bucket, for add/del */ 149ccf80ddfSLuis Carlos Cobo unsigned int hash_mask; /* (2^size_order) - 1 */ 150ccf80ddfSLuis Carlos Cobo __u32 hash_rnd; /* Used for hash generation */ 151ccf80ddfSLuis Carlos Cobo atomic_t entries; /* Up to MAX_MESH_NEIGHBOURS */ 152ccf80ddfSLuis Carlos Cobo void (*free_node) (struct hlist_node *p, bool free_leafs); 1534caf86c6SPavel Emelyanov int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl); 154ccf80ddfSLuis Carlos Cobo int size_order; 155ccf80ddfSLuis Carlos Cobo int mean_chain_len; 1565ee68e5bSJavier Cardona struct hlist_head *known_gates; 1575ee68e5bSJavier Cardona spinlock_t gates_lock; 1581928ecabSJohannes Berg 1591928ecabSJohannes Berg struct rcu_head rcu_head; 160ccf80ddfSLuis Carlos Cobo }; 161ccf80ddfSLuis Carlos Cobo 162ccf80ddfSLuis Carlos Cobo /* Recent multicast cache */ 163ccf80ddfSLuis Carlos Cobo /* RMC_BUCKETS must be a power of 2, maximum 256 */ 164ccf80ddfSLuis Carlos Cobo #define RMC_BUCKETS 256 165ccf80ddfSLuis Carlos Cobo #define RMC_QUEUE_MAX_LEN 4 166ccf80ddfSLuis Carlos Cobo #define RMC_TIMEOUT (3 * HZ) 167ccf80ddfSLuis Carlos Cobo 168ccf80ddfSLuis Carlos Cobo /** 169ccf80ddfSLuis Carlos Cobo * struct rmc_entry - entry in the Recent Multicast Cache 170ccf80ddfSLuis Carlos Cobo * 171ccf80ddfSLuis Carlos Cobo * @seqnum: mesh sequence number of the frame 172ccf80ddfSLuis Carlos Cobo * @exp_time: expiration time of the entry, in jiffies 173ccf80ddfSLuis Carlos Cobo * @sa: source address of the frame 174ccf80ddfSLuis Carlos Cobo * 175ccf80ddfSLuis Carlos Cobo * The Recent Multicast Cache keeps track of the latest multicast frames that 176ccf80ddfSLuis Carlos Cobo * have been received by a mesh interface and discards received multicast frames 177ccf80ddfSLuis Carlos Cobo * that are found in the cache. 178ccf80ddfSLuis Carlos Cobo */ 179ccf80ddfSLuis Carlos Cobo struct rmc_entry { 180ccf80ddfSLuis Carlos Cobo struct list_head list; 181ccf80ddfSLuis Carlos Cobo u32 seqnum; 182ccf80ddfSLuis Carlos Cobo unsigned long exp_time; 183ccf80ddfSLuis Carlos Cobo u8 sa[ETH_ALEN]; 184ccf80ddfSLuis Carlos Cobo }; 185ccf80ddfSLuis Carlos Cobo 186ccf80ddfSLuis Carlos Cobo struct mesh_rmc { 187b7cfcd11SThomas Pedersen struct list_head bucket[RMC_BUCKETS]; 18851ceddadSLuis Carlos Cobo u32 idx_mask; 189ccf80ddfSLuis Carlos Cobo }; 190ccf80ddfSLuis Carlos Cobo 19125d49e4dSThomas Pedersen #define IEEE80211_MESH_PEER_INACTIVITY_LIMIT (1800 * HZ) 19225d49e4dSThomas Pedersen #define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ) 193ccf80ddfSLuis Carlos Cobo 194ccf80ddfSLuis Carlos Cobo #define MESH_PATH_EXPIRE (600 * HZ) 195ccf80ddfSLuis Carlos Cobo 196ccf80ddfSLuis Carlos Cobo /* Default maximum number of plinks per interface */ 197ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PLINKS 256 198ccf80ddfSLuis Carlos Cobo 199ccf80ddfSLuis Carlos Cobo /* Maximum number of paths per interface */ 200ccf80ddfSLuis Carlos Cobo #define MESH_MAX_MPATHS 1024 201ccf80ddfSLuis Carlos Cobo 2024bd4c2ddSThomas Pedersen /* Number of frames buffered per destination for unresolved destinations */ 2034bd4c2ddSThomas Pedersen #define MESH_FRAME_QUEUE_LEN 10 2044bd4c2ddSThomas Pedersen 205ccf80ddfSLuis Carlos Cobo /* Public interfaces */ 206ccf80ddfSLuis Carlos Cobo /* Various */ 2073c5772a5SJavier Cardona int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc, 20815ff6365SJohannes Berg const u8 *da, const u8 *sa); 209ccf80ddfSLuis Carlos Cobo int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, 21061ad5394SJavier Cardona struct ieee80211_sub_if_data *sdata, char *addr4or5, 21161ad5394SJavier Cardona char *addr6); 212ccf80ddfSLuis Carlos Cobo int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr, 213f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 214f743ff49SThomas Pedersen bool mesh_matches_local(struct ieee80211_sub_if_data *sdata, 215f743ff49SThomas Pedersen struct ieee802_11_elems *ie); 216472dbc45SJohannes Berg void mesh_ids_set_default(struct ieee80211_if_mesh *mesh); 217f698d856SJasper Bryant-Greene void mesh_mgmt_ies_add(struct sk_buff *skb, 218f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 219082ebb0cSThomas Pedersen int mesh_add_meshconf_ie(struct sk_buff *skb, 220082ebb0cSThomas Pedersen struct ieee80211_sub_if_data *sdata); 221082ebb0cSThomas Pedersen int mesh_add_meshid_ie(struct sk_buff *skb, 222082ebb0cSThomas Pedersen struct ieee80211_sub_if_data *sdata); 223082ebb0cSThomas Pedersen int mesh_add_rsn_ie(struct sk_buff *skb, 224082ebb0cSThomas Pedersen struct ieee80211_sub_if_data *sdata); 2253f52b7e3SMarco Porsch int mesh_add_awake_window_ie(struct sk_buff *skb, 2263f52b7e3SMarco Porsch struct ieee80211_sub_if_data *sdata); 227082ebb0cSThomas Pedersen int mesh_add_vendor_ies(struct sk_buff *skb, 228082ebb0cSThomas Pedersen struct ieee80211_sub_if_data *sdata); 229082ebb0cSThomas Pedersen int mesh_add_ds_params_ie(struct sk_buff *skb, 230082ebb0cSThomas Pedersen struct ieee80211_sub_if_data *sdata); 231176f3608SThomas Pedersen int mesh_add_ht_cap_ie(struct sk_buff *skb, 232176f3608SThomas Pedersen struct ieee80211_sub_if_data *sdata); 233074d46d1SJohannes Berg int mesh_add_ht_oper_ie(struct sk_buff *skb, 234176f3608SThomas Pedersen struct ieee80211_sub_if_data *sdata); 235f698d856SJasper Bryant-Greene void mesh_rmc_free(struct ieee80211_sub_if_data *sdata); 236f698d856SJasper Bryant-Greene int mesh_rmc_init(struct ieee80211_sub_if_data *sdata); 237ccf80ddfSLuis Carlos Cobo void ieee80211s_init(void); 238bfc32e6aSJavier Cardona void ieee80211s_update_metric(struct ieee80211_local *local, 23935b3fe1cSJavier Cardona struct sta_info *sta, struct sk_buff *skb); 240ccf80ddfSLuis Carlos Cobo void ieee80211s_stop(void); 241902acc78SJohannes Berg void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata); 242472dbc45SJohannes Berg void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata); 243472dbc45SJohannes Berg void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata); 24463c5723bSRui Paulo void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh); 2458ba7acf3SJohannes Berg const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method); 246902acc78SJohannes Berg 2473f52b7e3SMarco Porsch /* mesh power save */ 2483f52b7e3SMarco Porsch void ieee80211_mps_local_status_update(struct ieee80211_sub_if_data *sdata); 2493f52b7e3SMarco Porsch void ieee80211_mps_set_sta_local_pm(struct sta_info *sta, 2503f52b7e3SMarco Porsch enum nl80211_mesh_power_mode pm); 2513f52b7e3SMarco Porsch void ieee80211_mps_set_frame_flags(struct ieee80211_sub_if_data *sdata, 2523f52b7e3SMarco Porsch struct sta_info *sta, 2533f52b7e3SMarco Porsch struct ieee80211_hdr *hdr); 2543f52b7e3SMarco Porsch void ieee80211_mps_sta_status_update(struct sta_info *sta); 2553f52b7e3SMarco Porsch void ieee80211_mps_rx_h_sta_process(struct sta_info *sta, 2563f52b7e3SMarco Porsch struct ieee80211_hdr *hdr); 2573f52b7e3SMarco Porsch void ieee80211_mpsp_trigger_process(u8 *qc, struct sta_info *sta, 2583f52b7e3SMarco Porsch bool tx, bool acked); 2593f52b7e3SMarco Porsch void ieee80211_mps_frame_release(struct sta_info *sta, 2603f52b7e3SMarco Porsch struct ieee802_11_elems *elems); 2613f52b7e3SMarco Porsch 262ccf80ddfSLuis Carlos Cobo /* Mesh paths */ 263f698d856SJasper Bryant-Greene int mesh_nexthop_lookup(struct sk_buff *skb, 264f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 2650cfda851SThomas Pedersen int mesh_nexthop_resolve(struct sk_buff *skb, 2660cfda851SThomas Pedersen struct ieee80211_sub_if_data *sdata); 267f698d856SJasper Bryant-Greene void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata); 268f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup(u8 *dst, 269f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 27079617deeSYanBo struct mesh_path *mpp_path_lookup(u8 *dst, 27179617deeSYanBo struct ieee80211_sub_if_data *sdata); 27279617deeSYanBo int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata); 273f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup_by_idx(int idx, 274f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 275ccf80ddfSLuis Carlos Cobo void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop); 276f698d856SJasper Bryant-Greene void mesh_path_expire(struct ieee80211_sub_if_data *sdata); 277f698d856SJasper Bryant-Greene void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, 278f698d856SJasper Bryant-Greene struct ieee80211_mgmt *mgmt, size_t len); 279f698d856SJasper Bryant-Greene int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata); 2805ee68e5bSJavier Cardona 2815ee68e5bSJavier Cardona int mesh_path_add_gate(struct mesh_path *mpath); 2825ee68e5bSJavier Cardona int mesh_path_send_to_gates(struct mesh_path *mpath); 2835ee68e5bSJavier Cardona int mesh_gate_num(struct ieee80211_sub_if_data *sdata); 284ccf80ddfSLuis Carlos Cobo /* Mesh plinks */ 285f743ff49SThomas Pedersen void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata, 286f743ff49SThomas Pedersen u8 *hw_addr, 2871570ca59SJavier Cardona struct ieee802_11_elems *ie); 288f698d856SJasper Bryant-Greene bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie); 289df323818SMarco Porsch u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata); 290ccf80ddfSLuis Carlos Cobo void mesh_plink_broken(struct sta_info *sta); 291*45b5028eSThomas Pedersen u32 mesh_plink_deactivate(struct sta_info *sta); 292ccf80ddfSLuis Carlos Cobo int mesh_plink_open(struct sta_info *sta); 293ccf80ddfSLuis Carlos Cobo void mesh_plink_block(struct sta_info *sta); 294f698d856SJasper Bryant-Greene void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, 295f698d856SJasper Bryant-Greene struct ieee80211_mgmt *mgmt, size_t len, 296f698d856SJasper Bryant-Greene struct ieee80211_rx_status *rx_status); 297*45b5028eSThomas Pedersen void mesh_sta_cleanup(struct sta_info *sta); 298ccf80ddfSLuis Carlos Cobo 299ccf80ddfSLuis Carlos Cobo /* Private interfaces */ 300ccf80ddfSLuis Carlos Cobo /* Mesh tables */ 30118889231SJavier Cardona void mesh_mpath_table_grow(void); 30218889231SJavier Cardona void mesh_mpp_table_grow(void); 303ccf80ddfSLuis Carlos Cobo /* Mesh paths */ 304d19b3bf6SRui Paulo int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, __le16 target_rcode, 30515ff6365SJohannes Berg const u8 *ra, struct ieee80211_sub_if_data *sdata); 306ccf80ddfSLuis Carlos Cobo void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta); 307ccf80ddfSLuis Carlos Cobo void mesh_path_flush_pending(struct mesh_path *mpath); 308ccf80ddfSLuis Carlos Cobo void mesh_path_tx_pending(struct mesh_path *mpath); 309ccf80ddfSLuis Carlos Cobo int mesh_pathtbl_init(void); 310ccf80ddfSLuis Carlos Cobo void mesh_pathtbl_unregister(void); 311f698d856SJasper Bryant-Greene int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata); 312ccf80ddfSLuis Carlos Cobo void mesh_path_timer(unsigned long data); 313ccf80ddfSLuis Carlos Cobo void mesh_path_flush_by_nexthop(struct sta_info *sta); 314f698d856SJasper Bryant-Greene void mesh_path_discard_frame(struct sk_buff *skb, 315f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 3165bb644a0SJohannes Berg void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata); 3175bb644a0SJohannes Berg void mesh_path_restart(struct ieee80211_sub_if_data *sdata); 318e304bfd3SRui Paulo void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata); 319ccf80ddfSLuis Carlos Cobo 32025d49e4dSThomas Pedersen bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt); 321f5ea9120SJohannes Berg extern int mesh_paths_generation; 322f5ea9120SJohannes Berg 323902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 324902acc78SJohannes Berg extern int mesh_allocated; 325902acc78SJohannes Berg 3261617bab8SMarco Porsch static inline 3271617bab8SMarco Porsch u32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata) 3281617bab8SMarco Porsch { 3291617bab8SMarco Porsch atomic_inc(&sdata->u.mesh.estab_plinks); 3301617bab8SMarco Porsch return mesh_accept_plinks_update(sdata); 3311617bab8SMarco Porsch } 3321617bab8SMarco Porsch 3331617bab8SMarco Porsch static inline 3341617bab8SMarco Porsch u32 mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata) 3351617bab8SMarco Porsch { 3361617bab8SMarco Porsch atomic_dec(&sdata->u.mesh.estab_plinks); 3371617bab8SMarco Porsch return mesh_accept_plinks_update(sdata); 3381617bab8SMarco Porsch } 3391617bab8SMarco Porsch 340ccf80ddfSLuis Carlos Cobo static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata) 341ccf80ddfSLuis Carlos Cobo { 342472dbc45SJohannes Berg return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks - 3431258d976SAshok Nagarajan atomic_read(&sdata->u.mesh.estab_plinks); 344ccf80ddfSLuis Carlos Cobo } 345ccf80ddfSLuis Carlos Cobo 346ccf80ddfSLuis Carlos Cobo static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata) 347ccf80ddfSLuis Carlos Cobo { 348d0709a65SJohannes Berg return (min_t(long, mesh_plink_free_count(sdata), 349ccf80ddfSLuis Carlos Cobo MESH_MAX_PLINKS - sdata->local->num_sta)) > 0; 350ccf80ddfSLuis Carlos Cobo } 351ccf80ddfSLuis Carlos Cobo 352ccf80ddfSLuis Carlos Cobo static inline void mesh_path_activate(struct mesh_path *mpath) 353ccf80ddfSLuis Carlos Cobo { 354ccf80ddfSLuis Carlos Cobo mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED; 355ccf80ddfSLuis Carlos Cobo } 356ccf80ddfSLuis Carlos Cobo 357c7108a71SJavier Cardona static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata) 358c7108a71SJavier Cardona { 359c7108a71SJavier Cardona return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP; 360c7108a71SJavier Cardona } 361c7108a71SJavier Cardona 362472dbc45SJohannes Berg void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local); 363472dbc45SJohannes Berg 3645bb644a0SJohannes Berg void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata); 3655bb644a0SJohannes Berg void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata); 3665bb644a0SJohannes Berg void mesh_plink_quiesce(struct sta_info *sta); 3675bb644a0SJohannes Berg void mesh_plink_restart(struct sta_info *sta); 36894c514feSAndrei Emeltchenko void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata); 369dbf498fbSJavier Cardona void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata); 370902acc78SJohannes Berg #else 371902acc78SJohannes Berg #define mesh_allocated 0 372472dbc45SJohannes Berg static inline void 373472dbc45SJohannes Berg ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {} 3745bb644a0SJohannes Berg static inline void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata) 3755bb644a0SJohannes Berg {} 3765bb644a0SJohannes Berg static inline void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) 3775bb644a0SJohannes Berg {} 3785bb644a0SJohannes Berg static inline void mesh_plink_quiesce(struct sta_info *sta) {} 3795bb644a0SJohannes Berg static inline void mesh_plink_restart(struct sta_info *sta) {} 380c7108a71SJavier Cardona static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata) 381c7108a71SJavier Cardona { return false; } 38294c514feSAndrei Emeltchenko static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata) 38394c514feSAndrei Emeltchenko {} 384902acc78SJohannes Berg #endif 385902acc78SJohannes Berg 386ccf80ddfSLuis Carlos Cobo #endif /* IEEE80211S_H */ 387