OSDN Git Service

Add rtl8821ce driver version 5.5.2
[android-x86/external-kernel-drivers.git] / rtl8821ce / core / mesh / rtw_mesh.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef __RTW_MESH_H_
16 #define __RTW_MESH_H_
17
18 #ifndef CONFIG_AP_MODE
19         #error "CONFIG_RTW_MESH can't be enabled when CONFIG_AP_MODE is not defined\n"
20 #endif
21
22 #define RTW_MESH_TTL                            31
23 #define RTW_MESH_PERR_MIN_INT                   100
24 #define RTW_MESH_DEFAULT_ELEMENT_TTL            31
25 #define RTW_MESH_RANN_INTERVAL                  5000
26 #define RTW_MESH_PATH_TO_ROOT_TIMEOUT           6000
27 #define RTW_MESH_DIAM_TRAVERSAL_TIME            50
28 #define RTW_MESH_PATH_TIMEOUT                   5000
29 #define RTW_MESH_PREQ_MIN_INT                   10
30 #define RTW_MESH_MAX_PREQ_RETRIES               4
31 #define RTW_MESH_MIN_DISCOVERY_TIMEOUT          (2 * RTW_MESH_DIAM_TRAVERSAL_TIME)
32 #define RTW_MESH_ROOT_CONFIRMATION_INTERVAL     2000
33 #define RTW_MESH_PATH_REFRESH_TIME              1000
34 #define RTW_MESH_ROOT_INTERVAL                  5000
35
36 #define RTW_MESH_SANE_METRIC_DELTA              100
37 #define RTW_MESH_MAX_ROOT_ADD_CHK_CNT           2
38
39 #define RTW_MESH_PLINK_UNKNOWN  0
40 #define RTW_MESH_PLINK_LISTEN   1
41 #define RTW_MESH_PLINK_OPN_SNT  2
42 #define RTW_MESH_PLINK_OPN_RCVD 3
43 #define RTW_MESH_PLINK_CNF_RCVD 4
44 #define RTW_MESH_PLINK_ESTAB    5
45 #define RTW_MESH_PLINK_HOLDING  6
46 #define RTW_MESH_PLINK_BLOCKED  7
47
48 extern const char *_rtw_mesh_plink_str[];
49 #define rtw_mesh_plink_str(s) ((s <= RTW_MESH_PLINK_BLOCKED) ? _rtw_mesh_plink_str[s] : _rtw_mesh_plink_str[RTW_MESH_PLINK_UNKNOWN])
50
51 #define RTW_MESH_PS_UNKNOWN 0
52 #define RTW_MESH_PS_ACTIVE 1
53 #define RTW_MESH_PS_LSLEEP 2
54 #define RTW_MESH_PS_DSLEEP 3
55
56 extern const char *_rtw_mesh_ps_str[];
57 #define rtw_mesh_ps_str(mps) ((mps <= RTW_MESH_PS_DSLEEP) ? _rtw_mesh_ps_str[mps] : _rtw_mesh_ps_str[RTW_MESH_PS_UNKNOWN])
58
59 #define GET_MESH_CONF_ELE_PATH_SEL_PROTO_ID(_iec)               LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 0, 0, 8)
60 #define GET_MESH_CONF_ELE_PATH_SEL_METRIC_ID(_iec)              LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 1, 0, 8)
61 #define GET_MESH_CONF_ELE_CONGEST_CTRL_MODE_ID(_iec)    LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 2, 0, 8)
62 #define GET_MESH_CONF_ELE_SYNC_METHOD_ID(_iec)                  LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 3, 0, 8)
63 #define GET_MESH_CONF_ELE_AUTH_PROTO_ID(_iec)                   LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 4, 0, 8)
64
65 #define GET_MESH_CONF_ELE_MESH_FORMATION(_iec)                  LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 0, 8)
66 #define GET_MESH_CONF_ELE_CTO_MGATE(_iec)                               LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 0, 1)
67 #define GET_MESH_CONF_ELE_NUM_OF_PEERINGS(_iec)                 LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 1, 6)
68 #define GET_MESH_CONF_ELE_CTO_AS(_iec)                                  LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 7, 1)
69
70 #define GET_MESH_CONF_ELE_MESH_CAP(_iec)                                LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 0, 8)
71 #define GET_MESH_CONF_ELE_ACCEPT_PEERINGS(_iec)                 LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 0, 1)
72 #define GET_MESH_CONF_ELE_MCCA_SUP(_iec)                                LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 1, 1)
73 #define GET_MESH_CONF_ELE_MCCA_EN(_iec)                                 LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 2, 1)
74 #define GET_MESH_CONF_ELE_FORWARDING(_iec)                              LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 3, 1)
75 #define GET_MESH_CONF_ELE_MBCA_EN(_iec)                                 LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 4, 1)
76 #define GET_MESH_CONF_ELE_TBTT_ADJ(_iec)                                LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 5, 1)
77 #define GET_MESH_CONF_ELE_PS_LEVEL(_iec)                                LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 6, 1)
78
79 #define SET_MESH_CONF_ELE_PATH_SEL_PROTO_ID(_iec, _val)         SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 0, 0, 8, _val)
80 #define SET_MESH_CONF_ELE_PATH_SEL_METRIC_ID(_iec, _val)        SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 1, 0, 8, _val)
81 #define SET_MESH_CONF_ELE_CONGEST_CTRL_MODE_ID(_iec, _val)      SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 2, 0, 8, _val)
82 #define SET_MESH_CONF_ELE_SYNC_METHOD_ID(_iec, _val)            SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 3, 0, 8, _val)
83 #define SET_MESH_CONF_ELE_AUTH_PROTO_ID(_iec, _val)                     SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 4, 0, 8, _val)
84
85 #define SET_MESH_CONF_ELE_CTO_MGATE(_iec, _val)                         SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 5, 0, 1, _val)
86 #define SET_MESH_CONF_ELE_NUM_OF_PEERINGS(_iec, _val)           SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 5, 1, 6, _val)
87 #define SET_MESH_CONF_ELE_CTO_AS(_iec, _val)                            SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 5, 7, 1, _val)
88
89 #define SET_MESH_CONF_ELE_ACCEPT_PEERINGS(_iec, _val)           SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 0, 1, _val)
90 #define SET_MESH_CONF_ELE_MCCA_SUP(_iec, _val)                          SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 1, 1, _val)
91 #define SET_MESH_CONF_ELE_MCCA_EN(_iec, _val)                           SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 2, 1, _val)
92 #define SET_MESH_CONF_ELE_FORWARDING(_iec, _val)                        SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 3, 1, _val)
93 #define SET_MESH_CONF_ELE_MBCA_EN(_iec, _val)                           SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 4, 1, _val)
94 #define SET_MESH_CONF_ELE_TBTT_ADJ(_iec, _val)                          SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 5, 1, _val)
95 #define SET_MESH_CONF_ELE_PS_LEVEL(_iec, _val)                          SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 6, 1, _val)
96
97 /* Mesh flags */
98 #define MESH_FLAGS_AE           0x3 /* mask */
99 #define MESH_FLAGS_AE_A4        0x1
100 #define MESH_FLAGS_AE_A5_A6     0x2
101
102 /* Max number of paths */
103 #define RTW_MESH_MAX_PATHS 1024
104
105 #define RTW_PREQ_Q_F_START      0x1
106 #define RTW_PREQ_Q_F_REFRESH    0x2
107 #define RTW_PREQ_Q_F_CHK        0x4
108 #define RTW_PREQ_Q_F_PEER_AKA   0x8
109 struct rtw_mesh_preq_queue {
110         _list list;
111         u8 dst[ETH_ALEN];
112         u8 flags;
113 };
114
115 extern const u8 ae_to_mesh_ctrl_len[];
116
117 enum mesh_frame_type {
118         MESH_UCAST_DATA         = 0x0,
119         MESH_BMCAST_DATA        = 0x1,
120         MESH_UCAST_PX_DATA      = 0x2,
121         MESH_BMCAST_PX_DATA     = 0x3,
122         MESH_MHOP_UCAST_ACT     = 0x4,
123         MESH_MHOP_BMCAST_ACT    = 0x5,
124 };
125
126 enum mpath_sel_frame_type {
127         MPATH_PREQ = 0,
128         MPATH_PREP,
129         MPATH_PERR,
130         MPATH_RANN
131 };
132
133 /**
134  * enum rtw_mesh_deferred_task_flags - mesh deferred tasks
135  *
136  *
137  *
138  * @RTW_MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
139  * @RTW_MESH_WORK_ROOT: the mesh root station needs to send a frame
140  * @RTW_MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other
141  * mesh nodes
142  * @RTW_MESH_WORK_MBSS_CHANGED: rebuild beacon and notify driver of BSS changes
143  */
144 enum rtw_mesh_deferred_task_flags {
145         RTW_MESH_WORK_HOUSEKEEPING,
146         RTW_MESH_WORK_ROOT,
147         RTW_MESH_WORK_DRIFT_ADJUST,
148         RTW_MESH_WORK_MBSS_CHANGED,
149 };
150
151 #define RTW_MESH_MAX_PEER_CANDIDATES 15 /* aid consideration */
152 #define RTW_MESH_MAX_PEER_LINKS 8
153 #define RTW_MESH_PEER_LINK_TIMEOUT 20
154
155 #define RTW_MESH_PEER_CONF_DISABLED 0 /* special time value means no confirmation ongoing */
156 #if CONFIG_RTW_MESH_PEER_BLACKLIST
157 #define IS_PEER_CONF_DISABLED(plink) ((plink)->peer_conf_end_time == RTW_MESH_PEER_CONF_DISABLED)
158 #define IS_PEER_CONF_TIMEOUT(plink)(!IS_PEER_CONF_DISABLED(plink) && rtw_time_after(rtw_get_current_time(), (plink)->peer_conf_end_time))
159 #define SET_PEER_CONF_DISABLED(plink) (plink)->peer_conf_end_time = RTW_MESH_PEER_CONF_DISABLED
160 #define SET_PEER_CONF_END_TIME(plink, timeout_ms) \
161         do { \
162                 (plink)->peer_conf_end_time = rtw_get_current_time() + rtw_ms_to_systime(timeout_ms); \
163                 if ((plink)->peer_conf_end_time == RTW_MESH_PEER_CONF_DISABLED) \
164                         (plink)->peer_conf_end_time++; \
165         } while (0)
166 #else
167 #define IS_PEER_CONF_DISABLED(plink) 1
168 #define IS_PEER_CONF_TIMEOUT(plink) 0
169 #define SET_PEER_CONF_DISABLED(plink) do {} while (0)
170 #define SET_PEER_CONF_END_TIME(plink, timeout_ms) do {} while (0)
171 #endif /* CONFIG_RTW_MESH_PEER_BLACKLIST */
172
173 #define RTW_MESH_CTO_MGATE_CONF_DISABLED 0 /* special time value means no confirmation ongoing */
174 #if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
175 #define IS_CTO_MGATE_CONF_DISABLED(plink) ((plink)->cto_mgate_conf_end_time == RTW_MESH_CTO_MGATE_CONF_DISABLED)
176 #define IS_CTO_MGATE_CONF_TIMEOUT(plink)(!IS_CTO_MGATE_CONF_DISABLED(plink) && rtw_time_after(rtw_get_current_time(), (plink)->cto_mgate_conf_end_time))
177 #define SET_CTO_MGATE_CONF_DISABLED(plink) (plink)->cto_mgate_conf_end_time = RTW_MESH_CTO_MGATE_CONF_DISABLED
178 #define SET_CTO_MGATE_CONF_END_TIME(plink, timeout_ms) \
179         do { \
180                 (plink)->cto_mgate_conf_end_time = rtw_get_current_time() + rtw_ms_to_systime(timeout_ms); \
181                 if ((plink)->cto_mgate_conf_end_time == RTW_MESH_CTO_MGATE_CONF_DISABLED) \
182                         (plink)->cto_mgate_conf_end_time++; \
183         } while (0)
184 #else
185 #define IS_CTO_MGATE_CONF_DISABLED(plink) 1
186 #define IS_CTO_MGATE_CONF_TIMEOUT(plink) 0
187 #define SET_CTO_MGATE_CONF_DISABLED(plink) do {} while (0)
188 #define SET_CTO_MGATE_CONF_END_TIME(plink, timeout_ms) do {} while (0)
189 #endif /* CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST */
190
191 struct mesh_plink_ent {
192         u8 valid;
193         u8 addr[ETH_ALEN];
194         u8 plink_state;
195
196 #ifdef CONFIG_RTW_MESH_AEK
197         u8 aek_valid;
198         u8 aek[32];
199 #endif
200
201         u16 llid;
202         u16 plid;
203 #ifndef CONFIG_RTW_MESH_DRIVER_AID
204         u16 aid; /* aid assigned from upper layer */
205 #endif
206         u16 peer_aid; /* aid assigned from peer */
207
208         u8 chosen_pmk[16];
209
210 #ifdef CONFIG_RTW_MESH_AEK
211         u8 sel_pcs[4];
212         u8 l_nonce[32];
213         u8 p_nonce[32];
214 #endif
215
216 #ifdef CONFIG_RTW_MESH_DRIVER_AID
217         u8 *tx_conf_ies;
218         u16 tx_conf_ies_len;
219 #endif
220         u8 *rx_conf_ies;
221         u16 rx_conf_ies_len;
222
223         struct wlan_network *scanned;
224
225 #if CONFIG_RTW_MESH_PEER_BLACKLIST
226         systime peer_conf_end_time;
227 #endif
228 #if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
229         systime cto_mgate_conf_end_time;
230 #endif
231 };
232
233 #ifdef CONFIG_RTW_MESH_AEK
234 #define MESH_PLINK_AEK_VALID(ent) ent->aek_valid
235 #else
236 #define MESH_PLINK_AEK_VALID(ent) 0
237 #endif
238
239 struct mesh_plink_pool {
240         _lock lock;
241         u8 num; /* current ent being used */
242         struct mesh_plink_ent ent[RTW_MESH_MAX_PEER_CANDIDATES];
243
244 #if CONFIG_RTW_MESH_ACNODE_PREVENT
245         u8 acnode_rsvd;
246 #endif
247
248 #if CONFIG_RTW_MESH_PEER_BLACKLIST
249         _queue peer_blacklist;
250 #endif
251 #if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
252         _queue cto_mgate_blacklist;
253 #endif
254 };
255
256 struct mesh_peer_sel_policy {
257         u32 scanr_exp_ms;
258
259 #if CONFIG_RTW_MESH_ACNODE_PREVENT
260         u8 acnode_prevent;
261         u32 acnode_conf_timeout_ms;
262         u32 acnode_notify_timeout_ms;
263 #endif
264
265 #if CONFIG_RTW_MESH_OFFCH_CAND
266         u8 offch_cand;
267         u32 offch_find_int_ms; /* 0 means no offch find triggerred by driver self*/
268 #endif
269
270 #if CONFIG_RTW_MESH_PEER_BLACKLIST
271         u32 peer_conf_timeout_ms;
272         u32 peer_blacklist_timeout_ms;
273 #endif
274
275 #if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
276         u8 cto_mgate_require;
277         u32 cto_mgate_conf_timeout_ms;
278         u32 cto_mgate_blacklist_timeout_ms;
279 #endif
280 };
281
282 /* b2u flags */
283 #define RTW_MESH_B2U_ALL                BIT0
284 #define RTW_MESH_B2U_GA_UCAST   BIT1 /* Group addressed unicast frame, forward only */
285 #define RTW_MESH_B2U_BCAST              BIT2
286 #define RTW_MESH_B2U_IP_MCAST   BIT3
287
288 #define rtw_msrc_b2u_policy_chk(flags, mda) ( \
289         (flags & RTW_MESH_B2U_ALL) \
290         || ((flags & RTW_MESH_B2U_BCAST) && is_broadcast_mac_addr(mda)) \
291         || ((flags & RTW_MESH_B2U_IP_MCAST) && (IP_MCAST_MAC(mda) || ICMPV6_MCAST_MAC(mda))) \
292         )
293
294 #define rtw_mfwd_b2u_policy_chk(flags, mda, ucst) ( \
295         (flags & RTW_MESH_B2U_ALL) \
296         || ((flags & RTW_MESH_B2U_GA_UCAST) && ucst) \
297         || ((flags & RTW_MESH_B2U_BCAST) && is_broadcast_mac_addr(mda)) \
298         || ((flags & RTW_MESH_B2U_IP_MCAST) && (IP_MCAST_MAC(mda) || ICMPV6_MCAST_MAC(mda))) \
299         )
300
301 /**
302  * @sane_metric_delta: Controlling if trigger additional path check mechanism
303  * @max_root_add_chk_cnt: The retry cnt to send additional root confirmation
304  *      PREQ through old(last) path
305  */
306 struct rtw_mesh_cfg {
307         u8 max_peer_links; /* peering limit */
308         u32 plink_timeout; /* seconds */
309
310         u8 dot11MeshTTL;
311         u8 element_ttl;
312         u32 path_refresh_time;
313         u16 dot11MeshHWMPpreqMinInterval;
314         u16 dot11MeshHWMPnetDiameterTraversalTime;
315         u32 dot11MeshHWMPactivePathTimeout;
316         u8 dot11MeshHWMPmaxPREQretries;
317         u16 min_discovery_timeout;
318         u16 dot11MeshHWMPconfirmationInterval;
319         u16 dot11MeshHWMPperrMinInterval;
320         u8 dot11MeshHWMPRootMode;
321         BOOLEAN dot11MeshForwarding;
322         s32 rssi_threshold; /* in dBm, 0: no specified */
323         u16 dot11MeshHWMPRannInterval;
324         BOOLEAN dot11MeshGateAnnouncementProtocol;
325         u32 dot11MeshHWMPactivePathToRootTimeout;
326         u16 dot11MeshHWMProotInterval;
327         u8 path_gate_timeout_factor;
328 #ifdef CONFIG_RTW_MESH_ADD_ROOT_CHK
329         u16 sane_metric_delta;
330         u8 max_root_add_chk_cnt;
331 #endif
332
333         struct mesh_peer_sel_policy peer_sel_policy;
334
335 #if CONFIG_RTW_MESH_DATA_BMC_TO_UC
336         u8 b2u_flags_msrc;
337         u8 b2u_flags_mfwd;
338 #endif
339 };
340
341 struct rtw_mesh_stats {
342         u32 fwded_mcast;                /* Mesh forwarded multicast frames */
343         u32 fwded_unicast;              /* Mesh forwarded unicast frames */
344         u32 fwded_frames;               /* Mesh total forwarded frames */
345         u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
346         u32 dropped_frames_no_route;    /* Not transmitted, no route found */
347         u32 dropped_frames_congestion;/* Not forwarded due to congestion */
348         u32 dropped_frames_duplicate;
349
350         u32 mrc_del_qlen; /* MRC entry deleted cause by queue length limit */
351 };
352
353 struct rtw_mrc;
354
355 struct rtw_mesh_info {
356         u8 mesh_id[NDIS_802_11_LENGTH_SSID];
357         size_t mesh_id_len;
358         /* Active Path Selection Protocol Identifier */
359         u8 mesh_pp_id;
360         /* Active Path Selection Metric Identifier */
361         u8 mesh_pm_id;
362         /* Congestion Control Mode Identifier */
363         u8 mesh_cc_id;
364         /* Synchronization Protocol Identifier */
365         u8 mesh_sp_id;
366         /* Authentication Protocol Identifier */
367         u8 mesh_auth_id;
368
369         struct mesh_plink_pool plink_ctl;
370
371         u32 mesh_seqnum;
372         /* MSTA's own hwmp sequence number */
373         u32 sn;
374         systime last_preq;
375         systime last_sn_update;
376         systime next_perr;
377         /* Last used Path Discovery ID */
378         u32 preq_id;
379
380         ATOMIC_T mpaths;
381         struct rtw_mesh_table *mesh_paths;
382         struct rtw_mesh_table *mpp_paths;
383         int mesh_paths_generation;
384         int mpp_paths_generation;
385
386         int num_gates;
387         struct rtw_mesh_path *max_addr_gate;
388         bool max_addr_gate_is_larger_than_self;
389
390         struct rtw_mesh_stats mshstats;
391
392         _queue mpath_tx_queue;
393         u32 mpath_tx_queue_len;
394         struct tasklet_struct mpath_tx_tasklet;
395
396         struct rtw_mrc *mrc;
397
398         _lock mesh_preq_queue_lock;
399         struct rtw_mesh_preq_queue preq_queue;
400         int preq_queue_len;
401 };
402
403 extern const char *_action_self_protected_str[];
404 #define action_self_protected_str(action) ((action < RTW_ACT_SELF_PROTECTED_NUM) ? _action_self_protected_str[action] : _action_self_protected_str[0])
405
406 u8 *rtw_set_ie_mesh_id(u8 *buf, u32 *buf_len, const char *mesh_id, u8 id_len);
407 u8 *rtw_set_ie_mesh_config(u8 *buf, u32 *buf_len
408         , u8 path_sel_proto, u8 path_sel_metric, u8 congest_ctl_mode, u8 sync_method, u8 auth_proto
409         , u8 num_of_peerings, bool cto_mgate, bool cto_as
410         , bool accept_peerings, bool mcca_sup, bool mcca_en, bool forwarding
411         , bool mbca_en, bool tbtt_adj, bool ps_level);
412
413 int rtw_bss_is_same_mbss(WLAN_BSSID_EX *a, WLAN_BSSID_EX *b);
414 int rtw_bss_is_candidate_mesh_peer(WLAN_BSSID_EX *self, WLAN_BSSID_EX *target, u8 ch, u8 add_peer);
415
416 void rtw_chk_candidate_peer_notify(_adapter *adapter, struct wlan_network *scanned);
417
418 void rtw_mesh_peer_status_chk(_adapter *adapter);
419
420 #if CONFIG_RTW_MESH_ACNODE_PREVENT
421 void rtw_mesh_update_scanned_acnode_status(_adapter *adapter, struct wlan_network *scanned);
422 bool rtw_mesh_scanned_is_acnode_confirmed(_adapter *adapter, struct wlan_network *scanned);
423 bool rtw_mesh_acnode_prevent_allow_sacrifice(_adapter *adapter);
424 struct sta_info *rtw_mesh_acnode_prevent_pick_sacrifice(_adapter *adapter);
425 void dump_mesh_acnode_prevent_settings(void *sel, _adapter *adapter);
426 #endif
427
428 #if CONFIG_RTW_MESH_OFFCH_CAND
429 u8 rtw_mesh_offch_candidate_accepted(_adapter *adapter);
430 u8 rtw_mesh_select_operating_ch(_adapter *adapter);
431 void dump_mesh_offch_cand_settings(void *sel, _adapter *adapter);
432 #endif
433
434 #if CONFIG_RTW_MESH_PEER_BLACKLIST
435 int rtw_mesh_peer_blacklist_add(_adapter *adapter, const u8 *addr);
436 int rtw_mesh_peer_blacklist_del(_adapter *adapter, const u8 *addr);
437 int rtw_mesh_peer_blacklist_search(_adapter *adapter, const u8 *addr);
438 void rtw_mesh_peer_blacklist_flush(_adapter *adapter);
439 void dump_mesh_peer_blacklist(void *sel, _adapter *adapter);
440 void dump_mesh_peer_blacklist_settings(void *sel, _adapter *adapter);
441 #endif
442 #if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
443 u8 rtw_mesh_cto_mgate_required(_adapter *adapter);
444 u8 rtw_mesh_cto_mgate_network_filter(_adapter *adapter, struct wlan_network *scanned);
445 int rtw_mesh_cto_mgate_blacklist_add(_adapter *adapter, const u8 *addr);
446 int rtw_mesh_cto_mgate_blacklist_del(_adapter *adapter, const u8 *addr);
447 int rtw_mesh_cto_mgate_blacklist_search(_adapter *adapter, const u8 *addr);
448 void rtw_mesh_cto_mgate_blacklist_flush(_adapter *adapter);
449 void dump_mesh_cto_mgate_blacklist(void *sel, _adapter *adapter);
450 void dump_mesh_cto_mgate_blacklist_settings(void *sel, _adapter *adapter);
451 #endif
452 void dump_mesh_peer_sel_policy(void *sel, _adapter *adapter);
453 void dump_mesh_networks(void *sel, _adapter *adapter);
454
455 void rtw_mesh_adjust_chbw(u8 req_ch, u8 *req_bw, u8 *req_offset);
456
457 int rtw_sae_check_frames(_adapter *adapter, const u8 *buf, u32 len, u8 tx);
458 int rtw_mesh_check_frames_tx(_adapter *adapter, const u8 **buf, size_t *len);
459 int rtw_mesh_check_frames_rx(_adapter *adapter, const u8 *buf, size_t len);
460
461 int rtw_mesh_on_auth(_adapter *adapter, union recv_frame *rframe);
462 unsigned int on_action_self_protected(_adapter *adapter, union recv_frame *rframe);
463
464 bool rtw_mesh_update_bss_peering_status(_adapter *adapter, WLAN_BSSID_EX *bss);
465 bool rtw_mesh_update_bss_formation_info(_adapter *adapter, WLAN_BSSID_EX *bss);
466 bool rtw_mesh_update_bss_forwarding_state(_adapter *adapter, WLAN_BSSID_EX *bss);
467
468 struct mesh_plink_ent *_rtw_mesh_plink_get(_adapter *adapter, const u8 *hwaddr);
469 struct mesh_plink_ent *rtw_mesh_plink_get(_adapter *adapter, const u8 *hwaddr);
470 struct mesh_plink_ent *rtw_mesh_plink_get_no_estab_by_idx(_adapter *adapter, u8 idx);
471 int _rtw_mesh_plink_add(_adapter *adapter, const u8 *hwaddr);
472 int rtw_mesh_plink_add(_adapter *adapter, const u8 *hwaddr);
473 int rtw_mesh_plink_set_state(_adapter *adapter, const u8 *hwaddr, u8 state);
474 #ifdef CONFIG_RTW_MESH_AEK
475 int rtw_mesh_plink_set_aek(_adapter *adapter, const u8 *hwaddr, const u8 *aek);
476 #endif
477 #if CONFIG_RTW_MESH_PEER_BLACKLIST
478 int rtw_mesh_plink_set_peer_conf_timeout(_adapter *adapter, const u8 *hwaddr);
479 #endif
480 void _rtw_mesh_plink_del_ent(_adapter *adapter, struct mesh_plink_ent *ent);
481 int rtw_mesh_plink_del(_adapter *adapter, const u8 *hwaddr);
482 void rtw_mesh_plink_ctl_init(_adapter *adapter);
483 void rtw_mesh_plink_ctl_deinit(_adapter *adapter);
484 void dump_mesh_plink_ctl(void *sel, _adapter *adapter);
485
486 int rtw_mesh_peer_establish(_adapter *adapter, struct mesh_plink_ent *plink, struct sta_info *sta);
487 void _rtw_mesh_expire_peer_ent(_adapter *adapter, struct mesh_plink_ent *plink);
488 void rtw_mesh_expire_peer(_adapter *adapter, const u8 *peer_addr);
489 u8 rtw_mesh_ps_annc(_adapter *adapter, u8 ps);
490
491 unsigned int on_action_mesh(_adapter *adapter, union recv_frame *rframe);
492
493 void rtw_mesh_cfg_init(_adapter *adapter);
494 void rtw_mesh_cfg_init_max_peer_links(_adapter *adapter, u8 stack_conf);
495 void rtw_mesh_cfg_init_plink_timeout(_adapter *adapter, u32 stack_conf);
496 void rtw_mesh_init_mesh_info(_adapter *adapter);
497 void rtw_mesh_deinit_mesh_info(_adapter *adapter);
498
499 #if CONFIG_RTW_MESH_DATA_BMC_TO_UC
500 void dump_mesh_b2u_flags(void *sel, _adapter *adapter);
501 #endif
502
503 int rtw_mesh_addr_resolve(_adapter *adapter, struct xmit_frame *xframe, _pkt *pkt, _list *b2u_list);
504
505 s8 rtw_mesh_tx_set_whdr_mctrl_len(u8 mesh_frame_mode, struct pkt_attrib *attrib);
506 void rtw_mesh_tx_build_mctrl(_adapter *adapter, struct pkt_attrib *attrib, u8 *buf);
507 u8 rtw_mesh_tx_build_whdr(_adapter *adapter, struct pkt_attrib *attrib
508         , u16 *fctrl, struct rtw_ieee80211_hdr *whdr);
509
510 int rtw_mesh_rx_data_validate_hdr(_adapter *adapter, union recv_frame *rframe, struct sta_info **sta);
511 int rtw_mesh_rx_data_validate_mctrl(_adapter *adapter, union recv_frame *rframe
512         , const struct rtw_ieee80211s_hdr *mctrl, const u8 *mda, const u8 *msa
513         , u8 *mctrl_len, const u8 **da, const u8 **sa);
514 int rtw_mesh_rx_validate_mctrl_non_amsdu(_adapter *adapter, union recv_frame *rframe);
515
516 int rtw_mesh_rx_msdu_act_check(union recv_frame *rframe
517         , const u8 *mda, const u8 *msa
518         , const u8 *da, const u8 *sa
519         , struct rtw_ieee80211s_hdr *mctrl
520         , struct xmit_frame **fwd_frame, _list *b2u_list);
521
522 void dump_mesh_stats(void *sel, _adapter *adapter);
523
524 #if defined(PLATFORM_LINUX) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32))
525 #define rtw_lockdep_assert_held(l) lockdep_assert_held(l)
526 #define rtw_lockdep_is_held(l) lockdep_is_held(l)
527 #else
528 #error "TBD\n"
529 #endif
530
531 #include "rtw_mesh_pathtbl.h"
532 #include "rtw_mesh_hwmp.h"
533 #endif /* __RTW_MESH_H_ */