18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2008, 2009 open80211s Ltd.
48c2ecf20Sopenharmony_ci * Authors:    Luis Carlos Cobo <luisca@cozybit.com>
58c2ecf20Sopenharmony_ci *             Javier Cardona <javier@cozybit.com>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef IEEE80211S_H
98c2ecf20Sopenharmony_ci#define IEEE80211S_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/types.h>
128c2ecf20Sopenharmony_ci#include <linux/jhash.h>
138c2ecf20Sopenharmony_ci#include "ieee80211_i.h"
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/* Data structures */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/**
198c2ecf20Sopenharmony_ci * enum mesh_path_flags - mac80211 mesh path flags
208c2ecf20Sopenharmony_ci *
218c2ecf20Sopenharmony_ci * @MESH_PATH_ACTIVE: the mesh path can be used for forwarding
228c2ecf20Sopenharmony_ci * @MESH_PATH_RESOLVING: the discovery process is running for this mesh path
238c2ecf20Sopenharmony_ci * @MESH_PATH_SN_VALID: the mesh path contains a valid destination sequence
248c2ecf20Sopenharmony_ci *	number
258c2ecf20Sopenharmony_ci * @MESH_PATH_FIXED: the mesh path has been manually set and should not be
268c2ecf20Sopenharmony_ci *	modified
278c2ecf20Sopenharmony_ci * @MESH_PATH_RESOLVED: the mesh path can has been resolved
288c2ecf20Sopenharmony_ci * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination
298c2ecf20Sopenharmony_ci *	already queued up, waiting for the discovery process to start.
308c2ecf20Sopenharmony_ci * @MESH_PATH_DELETED: the mesh path has been deleted and should no longer
318c2ecf20Sopenharmony_ci *	be used
328c2ecf20Sopenharmony_ci *
338c2ecf20Sopenharmony_ci * MESH_PATH_RESOLVED is used by the mesh path timer to
348c2ecf20Sopenharmony_ci * decide when to stop or cancel the mesh path discovery.
358c2ecf20Sopenharmony_ci */
368c2ecf20Sopenharmony_cienum mesh_path_flags {
378c2ecf20Sopenharmony_ci	MESH_PATH_ACTIVE =	BIT(0),
388c2ecf20Sopenharmony_ci	MESH_PATH_RESOLVING =	BIT(1),
398c2ecf20Sopenharmony_ci	MESH_PATH_SN_VALID =	BIT(2),
408c2ecf20Sopenharmony_ci	MESH_PATH_FIXED	=	BIT(3),
418c2ecf20Sopenharmony_ci	MESH_PATH_RESOLVED =	BIT(4),
428c2ecf20Sopenharmony_ci	MESH_PATH_REQ_QUEUED =	BIT(5),
438c2ecf20Sopenharmony_ci	MESH_PATH_DELETED =	BIT(6),
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/**
478c2ecf20Sopenharmony_ci * enum mesh_deferred_task_flags - mac80211 mesh deferred tasks
488c2ecf20Sopenharmony_ci *
498c2ecf20Sopenharmony_ci *
508c2ecf20Sopenharmony_ci *
518c2ecf20Sopenharmony_ci * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
528c2ecf20Sopenharmony_ci * @MESH_WORK_ROOT: the mesh root station needs to send a frame
538c2ecf20Sopenharmony_ci * @MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other
548c2ecf20Sopenharmony_ci * mesh nodes
558c2ecf20Sopenharmony_ci * @MESH_WORK_MBSS_CHANGED: rebuild beacon and notify driver of BSS changes
568c2ecf20Sopenharmony_ci */
578c2ecf20Sopenharmony_cienum mesh_deferred_task_flags {
588c2ecf20Sopenharmony_ci	MESH_WORK_HOUSEKEEPING,
598c2ecf20Sopenharmony_ci	MESH_WORK_ROOT,
608c2ecf20Sopenharmony_ci	MESH_WORK_DRIFT_ADJUST,
618c2ecf20Sopenharmony_ci	MESH_WORK_MBSS_CHANGED,
628c2ecf20Sopenharmony_ci};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/**
658c2ecf20Sopenharmony_ci * struct mesh_path - mac80211 mesh path structure
668c2ecf20Sopenharmony_ci *
678c2ecf20Sopenharmony_ci * @dst: mesh path destination mac address
688c2ecf20Sopenharmony_ci * @mpp: mesh proxy mac address
698c2ecf20Sopenharmony_ci * @rhash: rhashtable list pointer
708c2ecf20Sopenharmony_ci * @walk_list: linked list containing all mesh_path objects.
718c2ecf20Sopenharmony_ci * @gate_list: list pointer for known gates list
728c2ecf20Sopenharmony_ci * @sdata: mesh subif
738c2ecf20Sopenharmony_ci * @next_hop: mesh neighbor to which frames for this destination will be
748c2ecf20Sopenharmony_ci *	forwarded
758c2ecf20Sopenharmony_ci * @timer: mesh path discovery timer
768c2ecf20Sopenharmony_ci * @frame_queue: pending queue for frames sent to this destination while the
778c2ecf20Sopenharmony_ci *	path is unresolved
788c2ecf20Sopenharmony_ci * @rcu: rcu head for freeing mesh path
798c2ecf20Sopenharmony_ci * @sn: target sequence number
808c2ecf20Sopenharmony_ci * @metric: current metric to this destination
818c2ecf20Sopenharmony_ci * @hop_count: hops to destination
828c2ecf20Sopenharmony_ci * @exp_time: in jiffies, when the path will expire or when it expired
838c2ecf20Sopenharmony_ci * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery
848c2ecf20Sopenharmony_ci *	retry
858c2ecf20Sopenharmony_ci * @discovery_retries: number of discovery retries
868c2ecf20Sopenharmony_ci * @flags: mesh path flags, as specified on &enum mesh_path_flags
878c2ecf20Sopenharmony_ci * @state_lock: mesh path state lock used to protect changes to the
888c2ecf20Sopenharmony_ci * mpath itself.  No need to take this lock when adding or removing
898c2ecf20Sopenharmony_ci * an mpath to a hash bucket on a path table.
908c2ecf20Sopenharmony_ci * @rann_snd_addr: the RANN sender address
918c2ecf20Sopenharmony_ci * @rann_metric: the aggregated path metric towards the root node
928c2ecf20Sopenharmony_ci * @last_preq_to_root: Timestamp of last PREQ sent to root
938c2ecf20Sopenharmony_ci * @is_root: the destination station of this path is a root node
948c2ecf20Sopenharmony_ci * @is_gate: the destination station of this path is a mesh gate
958c2ecf20Sopenharmony_ci * @path_change_count: the number of path changes to destination
968c2ecf20Sopenharmony_ci *
978c2ecf20Sopenharmony_ci *
988c2ecf20Sopenharmony_ci * The dst address is unique in the mesh path table. Since the mesh_path is
998c2ecf20Sopenharmony_ci * protected by RCU, deleting the next_hop STA must remove / substitute the
1008c2ecf20Sopenharmony_ci * mesh_path structure and wait until that is no longer reachable before
1018c2ecf20Sopenharmony_ci * destroying the STA completely.
1028c2ecf20Sopenharmony_ci */
1038c2ecf20Sopenharmony_cistruct mesh_path {
1048c2ecf20Sopenharmony_ci	u8 dst[ETH_ALEN];
1058c2ecf20Sopenharmony_ci	u8 mpp[ETH_ALEN];	/* used for MPP or MAP */
1068c2ecf20Sopenharmony_ci	struct rhash_head rhash;
1078c2ecf20Sopenharmony_ci	struct hlist_node walk_list;
1088c2ecf20Sopenharmony_ci	struct hlist_node gate_list;
1098c2ecf20Sopenharmony_ci	struct ieee80211_sub_if_data *sdata;
1108c2ecf20Sopenharmony_ci	struct sta_info __rcu *next_hop;
1118c2ecf20Sopenharmony_ci	struct timer_list timer;
1128c2ecf20Sopenharmony_ci	struct sk_buff_head frame_queue;
1138c2ecf20Sopenharmony_ci	struct rcu_head rcu;
1148c2ecf20Sopenharmony_ci	u32 sn;
1158c2ecf20Sopenharmony_ci	u32 metric;
1168c2ecf20Sopenharmony_ci	u8 hop_count;
1178c2ecf20Sopenharmony_ci	unsigned long exp_time;
1188c2ecf20Sopenharmony_ci	u32 discovery_timeout;
1198c2ecf20Sopenharmony_ci	u8 discovery_retries;
1208c2ecf20Sopenharmony_ci	enum mesh_path_flags flags;
1218c2ecf20Sopenharmony_ci	spinlock_t state_lock;
1228c2ecf20Sopenharmony_ci	u8 rann_snd_addr[ETH_ALEN];
1238c2ecf20Sopenharmony_ci	u32 rann_metric;
1248c2ecf20Sopenharmony_ci	unsigned long last_preq_to_root;
1258c2ecf20Sopenharmony_ci	bool is_root;
1268c2ecf20Sopenharmony_ci	bool is_gate;
1278c2ecf20Sopenharmony_ci	u32 path_change_count;
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci/* Recent multicast cache */
1318c2ecf20Sopenharmony_ci/* RMC_BUCKETS must be a power of 2, maximum 256 */
1328c2ecf20Sopenharmony_ci#define RMC_BUCKETS		256
1338c2ecf20Sopenharmony_ci#define RMC_QUEUE_MAX_LEN	4
1348c2ecf20Sopenharmony_ci#define RMC_TIMEOUT		(3 * HZ)
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci/**
1378c2ecf20Sopenharmony_ci * struct rmc_entry - entry in the Recent Multicast Cache
1388c2ecf20Sopenharmony_ci *
1398c2ecf20Sopenharmony_ci * @seqnum: mesh sequence number of the frame
1408c2ecf20Sopenharmony_ci * @exp_time: expiration time of the entry, in jiffies
1418c2ecf20Sopenharmony_ci * @sa: source address of the frame
1428c2ecf20Sopenharmony_ci * @list: hashtable list pointer
1438c2ecf20Sopenharmony_ci *
1448c2ecf20Sopenharmony_ci * The Recent Multicast Cache keeps track of the latest multicast frames that
1458c2ecf20Sopenharmony_ci * have been received by a mesh interface and discards received multicast frames
1468c2ecf20Sopenharmony_ci * that are found in the cache.
1478c2ecf20Sopenharmony_ci */
1488c2ecf20Sopenharmony_cistruct rmc_entry {
1498c2ecf20Sopenharmony_ci	struct hlist_node list;
1508c2ecf20Sopenharmony_ci	unsigned long exp_time;
1518c2ecf20Sopenharmony_ci	u32 seqnum;
1528c2ecf20Sopenharmony_ci	u8 sa[ETH_ALEN];
1538c2ecf20Sopenharmony_ci};
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_cistruct mesh_rmc {
1568c2ecf20Sopenharmony_ci	struct hlist_head bucket[RMC_BUCKETS];
1578c2ecf20Sopenharmony_ci	u32 idx_mask;
1588c2ecf20Sopenharmony_ci};
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci#define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#define MESH_PATH_EXPIRE (600 * HZ)
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci/* Default maximum number of plinks per interface */
1658c2ecf20Sopenharmony_ci#define MESH_MAX_PLINKS		256
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci/* Maximum number of paths per interface */
1688c2ecf20Sopenharmony_ci#define MESH_MAX_MPATHS		1024
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci/* Number of frames buffered per destination for unresolved destinations */
1718c2ecf20Sopenharmony_ci#define MESH_FRAME_QUEUE_LEN	10
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci/* Public interfaces */
1748c2ecf20Sopenharmony_ci/* Various */
1758c2ecf20Sopenharmony_ciint ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
1768c2ecf20Sopenharmony_ci				  const u8 *da, const u8 *sa);
1778c2ecf20Sopenharmony_ciunsigned int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata,
1788c2ecf20Sopenharmony_ci				       struct ieee80211s_hdr *meshhdr,
1798c2ecf20Sopenharmony_ci				       const char *addr4or5, const char *addr6);
1808c2ecf20Sopenharmony_ciint mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
1818c2ecf20Sopenharmony_ci		   const u8 *addr, struct ieee80211s_hdr *mesh_hdr);
1828c2ecf20Sopenharmony_cibool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
1838c2ecf20Sopenharmony_ci			struct ieee802_11_elems *ie);
1848c2ecf20Sopenharmony_civoid mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
1858c2ecf20Sopenharmony_ciint mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
1868c2ecf20Sopenharmony_ci			 struct sk_buff *skb);
1878c2ecf20Sopenharmony_ciint mesh_add_meshid_ie(struct ieee80211_sub_if_data *sdata,
1888c2ecf20Sopenharmony_ci		       struct sk_buff *skb);
1898c2ecf20Sopenharmony_ciint mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata,
1908c2ecf20Sopenharmony_ci		    struct sk_buff *skb);
1918c2ecf20Sopenharmony_ciint mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,
1928c2ecf20Sopenharmony_ci			struct sk_buff *skb);
1938c2ecf20Sopenharmony_ciint mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata,
1948c2ecf20Sopenharmony_ci		       struct sk_buff *skb);
1958c2ecf20Sopenharmony_ciint mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata,
1968c2ecf20Sopenharmony_ci			struct sk_buff *skb);
1978c2ecf20Sopenharmony_ciint mesh_add_vht_cap_ie(struct ieee80211_sub_if_data *sdata,
1988c2ecf20Sopenharmony_ci			struct sk_buff *skb);
1998c2ecf20Sopenharmony_ciint mesh_add_vht_oper_ie(struct ieee80211_sub_if_data *sdata,
2008c2ecf20Sopenharmony_ci			 struct sk_buff *skb);
2018c2ecf20Sopenharmony_ciint mesh_add_he_cap_ie(struct ieee80211_sub_if_data *sdata,
2028c2ecf20Sopenharmony_ci		       struct sk_buff *skb, u8 ie_len);
2038c2ecf20Sopenharmony_ciint mesh_add_he_oper_ie(struct ieee80211_sub_if_data *sdata,
2048c2ecf20Sopenharmony_ci			struct sk_buff *skb);
2058c2ecf20Sopenharmony_ciint mesh_add_he_6ghz_cap_ie(struct ieee80211_sub_if_data *sdata,
2068c2ecf20Sopenharmony_ci			    struct sk_buff *skb);
2078c2ecf20Sopenharmony_civoid mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
2088c2ecf20Sopenharmony_ciint mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
2098c2ecf20Sopenharmony_civoid ieee80211s_init(void);
2108c2ecf20Sopenharmony_civoid ieee80211s_update_metric(struct ieee80211_local *local,
2118c2ecf20Sopenharmony_ci			      struct sta_info *sta,
2128c2ecf20Sopenharmony_ci			      struct ieee80211_tx_status *st);
2138c2ecf20Sopenharmony_civoid ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
2148c2ecf20Sopenharmony_civoid ieee80211_mesh_teardown_sdata(struct ieee80211_sub_if_data *sdata);
2158c2ecf20Sopenharmony_ciint ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
2168c2ecf20Sopenharmony_civoid ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
2178c2ecf20Sopenharmony_civoid ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
2188c2ecf20Sopenharmony_ciconst struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method);
2198c2ecf20Sopenharmony_ci/* wrapper for ieee80211_bss_info_change_notify() */
2208c2ecf20Sopenharmony_civoid ieee80211_mbss_info_change_notify(struct ieee80211_sub_if_data *sdata,
2218c2ecf20Sopenharmony_ci				       u32 changed);
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci/* mesh power save */
2248c2ecf20Sopenharmony_ciu32 ieee80211_mps_local_status_update(struct ieee80211_sub_if_data *sdata);
2258c2ecf20Sopenharmony_ciu32 ieee80211_mps_set_sta_local_pm(struct sta_info *sta,
2268c2ecf20Sopenharmony_ci				   enum nl80211_mesh_power_mode pm);
2278c2ecf20Sopenharmony_civoid ieee80211_mps_set_frame_flags(struct ieee80211_sub_if_data *sdata,
2288c2ecf20Sopenharmony_ci				   struct sta_info *sta,
2298c2ecf20Sopenharmony_ci				   struct ieee80211_hdr *hdr);
2308c2ecf20Sopenharmony_civoid ieee80211_mps_sta_status_update(struct sta_info *sta);
2318c2ecf20Sopenharmony_civoid ieee80211_mps_rx_h_sta_process(struct sta_info *sta,
2328c2ecf20Sopenharmony_ci				    struct ieee80211_hdr *hdr);
2338c2ecf20Sopenharmony_civoid ieee80211_mpsp_trigger_process(u8 *qc, struct sta_info *sta,
2348c2ecf20Sopenharmony_ci				    bool tx, bool acked);
2358c2ecf20Sopenharmony_civoid ieee80211_mps_frame_release(struct sta_info *sta,
2368c2ecf20Sopenharmony_ci				 struct ieee802_11_elems *elems);
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci/* Mesh paths */
2398c2ecf20Sopenharmony_ciint mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata,
2408c2ecf20Sopenharmony_ci			struct sk_buff *skb);
2418c2ecf20Sopenharmony_ciint mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata,
2428c2ecf20Sopenharmony_ci			 struct sk_buff *skb);
2438c2ecf20Sopenharmony_civoid mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
2448c2ecf20Sopenharmony_cistruct mesh_path *mesh_path_lookup(struct ieee80211_sub_if_data *sdata,
2458c2ecf20Sopenharmony_ci				   const u8 *dst);
2468c2ecf20Sopenharmony_cistruct mesh_path *mpp_path_lookup(struct ieee80211_sub_if_data *sdata,
2478c2ecf20Sopenharmony_ci				  const u8 *dst);
2488c2ecf20Sopenharmony_ciint mpp_path_add(struct ieee80211_sub_if_data *sdata,
2498c2ecf20Sopenharmony_ci		 const u8 *dst, const u8 *mpp);
2508c2ecf20Sopenharmony_cistruct mesh_path *
2518c2ecf20Sopenharmony_cimesh_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx);
2528c2ecf20Sopenharmony_cistruct mesh_path *
2538c2ecf20Sopenharmony_cimpp_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx);
2548c2ecf20Sopenharmony_civoid mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
2558c2ecf20Sopenharmony_civoid mesh_path_expire(struct ieee80211_sub_if_data *sdata);
2568c2ecf20Sopenharmony_civoid mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
2578c2ecf20Sopenharmony_ci			    struct ieee80211_mgmt *mgmt, size_t len);
2588c2ecf20Sopenharmony_cistruct mesh_path *
2598c2ecf20Sopenharmony_cimesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst);
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ciint mesh_path_add_gate(struct mesh_path *mpath);
2628c2ecf20Sopenharmony_ciint mesh_path_send_to_gates(struct mesh_path *mpath);
2638c2ecf20Sopenharmony_ciint mesh_gate_num(struct ieee80211_sub_if_data *sdata);
2648c2ecf20Sopenharmony_ciu32 airtime_link_metric_get(struct ieee80211_local *local,
2658c2ecf20Sopenharmony_ci			    struct sta_info *sta);
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci/* Mesh plinks */
2688c2ecf20Sopenharmony_civoid mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
2698c2ecf20Sopenharmony_ci			   u8 *hw_addr, struct ieee802_11_elems *ie,
2708c2ecf20Sopenharmony_ci			   struct ieee80211_rx_status *rx_status);
2718c2ecf20Sopenharmony_cibool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
2728c2ecf20Sopenharmony_ciu32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
2738c2ecf20Sopenharmony_civoid mesh_plink_timer(struct timer_list *t);
2748c2ecf20Sopenharmony_civoid mesh_plink_broken(struct sta_info *sta);
2758c2ecf20Sopenharmony_ciu32 mesh_plink_deactivate(struct sta_info *sta);
2768c2ecf20Sopenharmony_ciu32 mesh_plink_open(struct sta_info *sta);
2778c2ecf20Sopenharmony_ciu32 mesh_plink_block(struct sta_info *sta);
2788c2ecf20Sopenharmony_civoid mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
2798c2ecf20Sopenharmony_ci			 struct ieee80211_mgmt *mgmt, size_t len,
2808c2ecf20Sopenharmony_ci			 struct ieee80211_rx_status *rx_status);
2818c2ecf20Sopenharmony_civoid mesh_sta_cleanup(struct sta_info *sta);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci/* Private interfaces */
2848c2ecf20Sopenharmony_ci/* Mesh paths */
2858c2ecf20Sopenharmony_ciint mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
2868c2ecf20Sopenharmony_ci		       u8 ttl, const u8 *target, u32 target_sn,
2878c2ecf20Sopenharmony_ci		       u16 target_rcode, const u8 *ra);
2888c2ecf20Sopenharmony_civoid mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
2898c2ecf20Sopenharmony_civoid mesh_path_flush_pending(struct mesh_path *mpath);
2908c2ecf20Sopenharmony_civoid mesh_path_tx_pending(struct mesh_path *mpath);
2918c2ecf20Sopenharmony_civoid mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata);
2928c2ecf20Sopenharmony_civoid mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata);
2938c2ecf20Sopenharmony_ciint mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr);
2948c2ecf20Sopenharmony_civoid mesh_path_timer(struct timer_list *t);
2958c2ecf20Sopenharmony_civoid mesh_path_flush_by_nexthop(struct sta_info *sta);
2968c2ecf20Sopenharmony_civoid mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
2978c2ecf20Sopenharmony_ci			     struct sk_buff *skb);
2988c2ecf20Sopenharmony_civoid mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_cibool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci#ifdef CONFIG_MAC80211_MESH
3038c2ecf20Sopenharmony_cistatic inline
3048c2ecf20Sopenharmony_ciu32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata)
3058c2ecf20Sopenharmony_ci{
3068c2ecf20Sopenharmony_ci	atomic_inc(&sdata->u.mesh.estab_plinks);
3078c2ecf20Sopenharmony_ci	return mesh_accept_plinks_update(sdata) | BSS_CHANGED_BEACON;
3088c2ecf20Sopenharmony_ci}
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_cistatic inline
3118c2ecf20Sopenharmony_ciu32 mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata)
3128c2ecf20Sopenharmony_ci{
3138c2ecf20Sopenharmony_ci	atomic_dec(&sdata->u.mesh.estab_plinks);
3148c2ecf20Sopenharmony_ci	return mesh_accept_plinks_update(sdata) | BSS_CHANGED_BEACON;
3158c2ecf20Sopenharmony_ci}
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_cistatic inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
3188c2ecf20Sopenharmony_ci{
3198c2ecf20Sopenharmony_ci	return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
3208c2ecf20Sopenharmony_ci	       atomic_read(&sdata->u.mesh.estab_plinks);
3218c2ecf20Sopenharmony_ci}
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_cistatic inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
3248c2ecf20Sopenharmony_ci{
3258c2ecf20Sopenharmony_ci	return (min_t(long, mesh_plink_free_count(sdata),
3268c2ecf20Sopenharmony_ci		   MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
3278c2ecf20Sopenharmony_ci}
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_cistatic inline void mesh_path_activate(struct mesh_path *mpath)
3308c2ecf20Sopenharmony_ci{
3318c2ecf20Sopenharmony_ci	mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
3328c2ecf20Sopenharmony_ci}
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_cistatic inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
3358c2ecf20Sopenharmony_ci{
3368c2ecf20Sopenharmony_ci	return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
3378c2ecf20Sopenharmony_ci}
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_civoid mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
3408c2ecf20Sopenharmony_civoid mesh_sync_adjust_tsf(struct ieee80211_sub_if_data *sdata);
3418c2ecf20Sopenharmony_civoid ieee80211s_stop(void);
3428c2ecf20Sopenharmony_ci#else
3438c2ecf20Sopenharmony_cistatic inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
3448c2ecf20Sopenharmony_ci{ return false; }
3458c2ecf20Sopenharmony_cistatic inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
3468c2ecf20Sopenharmony_ci{}
3478c2ecf20Sopenharmony_cistatic inline void ieee80211s_stop(void) {}
3488c2ecf20Sopenharmony_ci#endif
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci#endif /* IEEE80211S_H */
351