^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2008, 2009 open80211s Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Authors: Luis Carlos Cobo <luisca@cozybit.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Javier Cardona <javier@cozybit.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef IEEE80211S_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define IEEE80211S_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/jhash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "ieee80211_i.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /* Data structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * enum mesh_path_flags - mac80211 mesh path flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * @MESH_PATH_ACTIVE: the mesh path can be used for forwarding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * @MESH_PATH_RESOLVING: the discovery process is running for this mesh path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * @MESH_PATH_SN_VALID: the mesh path contains a valid destination sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * @MESH_PATH_FIXED: the mesh path has been manually set and should not be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * @MESH_PATH_RESOLVED: the mesh path can has been resolved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * already queued up, waiting for the discovery process to start.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * @MESH_PATH_DELETED: the mesh path has been deleted and should no longer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * MESH_PATH_RESOLVED is used by the mesh path timer to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * decide when to stop or cancel the mesh path discovery.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) enum mesh_path_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) MESH_PATH_ACTIVE = BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) MESH_PATH_RESOLVING = BIT(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) MESH_PATH_SN_VALID = BIT(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) MESH_PATH_FIXED = BIT(3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) MESH_PATH_RESOLVED = BIT(4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) MESH_PATH_REQ_QUEUED = BIT(5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) MESH_PATH_DELETED = BIT(6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * enum mesh_deferred_task_flags - mac80211 mesh deferred tasks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * @MESH_WORK_ROOT: the mesh root station needs to send a frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * @MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * mesh nodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * @MESH_WORK_MBSS_CHANGED: rebuild beacon and notify driver of BSS changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) enum mesh_deferred_task_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) MESH_WORK_HOUSEKEEPING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) MESH_WORK_ROOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) MESH_WORK_DRIFT_ADJUST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) MESH_WORK_MBSS_CHANGED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * struct mesh_path - mac80211 mesh path structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * @dst: mesh path destination mac address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * @mpp: mesh proxy mac address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * @rhash: rhashtable list pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * @walk_list: linked list containing all mesh_path objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * @gate_list: list pointer for known gates list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * @sdata: mesh subif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * @next_hop: mesh neighbor to which frames for this destination will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * forwarded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @timer: mesh path discovery timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * @frame_queue: pending queue for frames sent to this destination while the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * path is unresolved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * @rcu: rcu head for freeing mesh path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * @sn: target sequence number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * @metric: current metric to this destination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * @hop_count: hops to destination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * @exp_time: in jiffies, when the path will expire or when it expired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * retry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * @discovery_retries: number of discovery retries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * @flags: mesh path flags, as specified on &enum mesh_path_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * @state_lock: mesh path state lock used to protect changes to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * mpath itself. No need to take this lock when adding or removing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * an mpath to a hash bucket on a path table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * @rann_snd_addr: the RANN sender address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * @rann_metric: the aggregated path metric towards the root node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * @last_preq_to_root: Timestamp of last PREQ sent to root
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * @is_root: the destination station of this path is a root node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * @is_gate: the destination station of this path is a mesh gate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * @path_change_count: the number of path changes to destination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * The dst address is unique in the mesh path table. Since the mesh_path is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * protected by RCU, deleting the next_hop STA must remove / substitute the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * mesh_path structure and wait until that is no longer reachable before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * destroying the STA completely.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct mesh_path {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) u8 dst[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) u8 mpp[ETH_ALEN]; /* used for MPP or MAP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct rhash_head rhash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct hlist_node walk_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct hlist_node gate_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct ieee80211_sub_if_data *sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct sta_info __rcu *next_hop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct sk_buff_head frame_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) u32 sn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) u32 metric;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) u8 hop_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) unsigned long exp_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) u32 discovery_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) u8 discovery_retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) enum mesh_path_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) spinlock_t state_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) u8 rann_snd_addr[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) u32 rann_metric;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) unsigned long last_preq_to_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) bool is_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) bool is_gate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) u32 path_change_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * struct mesh_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * @known_gates: list of known mesh gates and their mpaths by the station. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * gate's mpath may or may not be resolved and active.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * @gates_lock: protects updates to known_gates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * @rhead: the rhashtable containing struct mesh_paths, keyed by dest addr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * @walk_head: linked list containging all mesh_path objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * @walk_lock: lock protecting walk_head
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * @entries: number of entries in the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct mesh_table {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct hlist_head known_gates;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) spinlock_t gates_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct rhashtable rhead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct hlist_head walk_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) spinlock_t walk_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) atomic_t entries; /* Up to MAX_MESH_NEIGHBOURS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /* Recent multicast cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* RMC_BUCKETS must be a power of 2, maximum 256 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define RMC_BUCKETS 256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #define RMC_QUEUE_MAX_LEN 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #define RMC_TIMEOUT (3 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * struct rmc_entry - entry in the Recent Multicast Cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * @seqnum: mesh sequence number of the frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * @exp_time: expiration time of the entry, in jiffies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * @sa: source address of the frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * @list: hashtable list pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * The Recent Multicast Cache keeps track of the latest multicast frames that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * have been received by a mesh interface and discards received multicast frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * that are found in the cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct rmc_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct hlist_node list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) unsigned long exp_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) u32 seqnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) u8 sa[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct mesh_rmc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) struct hlist_head bucket[RMC_BUCKETS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) u32 idx_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #define MESH_PATH_EXPIRE (600 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /* Default maximum number of plinks per interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) #define MESH_MAX_PLINKS 256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /* Maximum number of paths per interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #define MESH_MAX_MPATHS 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /* Number of frames buffered per destination for unresolved destinations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #define MESH_FRAME_QUEUE_LEN 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /* Public interfaces */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /* Various */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) const u8 *da, const u8 *sa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) unsigned int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct ieee80211s_hdr *meshhdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) const char *addr4or5, const char *addr6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) int mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) const u8 *addr, struct ieee80211s_hdr *mesh_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct ieee802_11_elems *ie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) int mesh_add_meshid_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) int mesh_add_vht_cap_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int mesh_add_vht_oper_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) int mesh_add_he_cap_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct sk_buff *skb, u8 ie_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) int mesh_add_he_oper_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) int mesh_add_he_6ghz_cap_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) void ieee80211s_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) void ieee80211s_update_metric(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) struct ieee80211_tx_status *st);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) void ieee80211_mesh_teardown_sdata(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) /* wrapper for ieee80211_bss_info_change_notify() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) void ieee80211_mbss_info_change_notify(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) u32 changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) /* mesh power save */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) u32 ieee80211_mps_local_status_update(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) u32 ieee80211_mps_set_sta_local_pm(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) enum nl80211_mesh_power_mode pm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) void ieee80211_mps_set_frame_flags(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct ieee80211_hdr *hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) void ieee80211_mps_sta_status_update(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) void ieee80211_mps_rx_h_sta_process(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) struct ieee80211_hdr *hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) void ieee80211_mpsp_trigger_process(u8 *qc, struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) bool tx, bool acked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) void ieee80211_mps_frame_release(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) struct ieee802_11_elems *elems);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* Mesh paths */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct mesh_path *mesh_path_lookup(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) const u8 *dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) struct mesh_path *mpp_path_lookup(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) const u8 *dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) int mpp_path_add(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) const u8 *dst, const u8 *mpp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct mesh_path *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) mesh_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) struct mesh_path *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) mpp_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) struct ieee80211_mgmt *mgmt, size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) struct mesh_path *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) int mesh_path_add_gate(struct mesh_path *mpath);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) int mesh_path_send_to_gates(struct mesh_path *mpath);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) int mesh_gate_num(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) u32 airtime_link_metric_get(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) /* Mesh plinks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) u8 *hw_addr, struct ieee802_11_elems *ie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct ieee80211_rx_status *rx_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) void mesh_plink_timer(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) void mesh_plink_broken(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) u32 mesh_plink_deactivate(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) u32 mesh_plink_open(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) u32 mesh_plink_block(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) struct ieee80211_mgmt *mgmt, size_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) struct ieee80211_rx_status *rx_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) void mesh_sta_cleanup(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) /* Private interfaces */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /* Mesh paths */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) u8 ttl, const u8 *target, u32 target_sn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) u16 target_rcode, const u8 *ra);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) void mesh_path_flush_pending(struct mesh_path *mpath);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) void mesh_path_tx_pending(struct mesh_path *mpath);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) void mesh_path_timer(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) void mesh_path_flush_by_nexthop(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) #ifdef CONFIG_MAC80211_MESH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) u32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) atomic_inc(&sdata->u.mesh.estab_plinks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) return mesh_accept_plinks_update(sdata) | BSS_CHANGED_BEACON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) u32 mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) atomic_dec(&sdata->u.mesh.estab_plinks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) return mesh_accept_plinks_update(sdata) | BSS_CHANGED_BEACON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) atomic_read(&sdata->u.mesh.estab_plinks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) return (min_t(long, mesh_plink_free_count(sdata),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) static inline void mesh_path_activate(struct mesh_path *mpath)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) void mesh_sync_adjust_tsf(struct ieee80211_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) void ieee80211s_stop(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) { return false; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) static inline void ieee80211s_stop(void) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) #endif /* IEEE80211S_H */