rtw_mesh_pathtbl.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  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. #define _RTW_MESH_PATHTBL_C_
  16. #ifdef CONFIG_RTW_MESH
  17. #include <drv_types.h>
  18. #include <linux/jhash.h>
  19. #ifdef PLATFORM_LINUX
  20. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
  21. static void rtw_mpath_free_rcu(struct rtw_mesh_path *mpath)
  22. {
  23. kfree_rcu(mpath, rcu);
  24. rtw_mstat_update(MSTAT_TYPE_PHY, MSTAT_FREE, sizeof(struct rtw_mesh_path));
  25. }
  26. #else
  27. static void rtw_mpath_free_rcu_callback(rtw_rcu_head *head)
  28. {
  29. struct rtw_mesh_path *mpath;
  30. mpath = container_of(head, struct rtw_mesh_path, rcu);
  31. rtw_mfree(mpath, sizeof(struct rtw_mesh_path));
  32. }
  33. static void rtw_mpath_free_rcu(struct rtw_mesh_path *mpath)
  34. {
  35. call_rcu(&mpath->rcu, rtw_mpath_free_rcu_callback);
  36. }
  37. #endif
  38. #endif /* PLATFORM_LINUX */
  39. static void rtw_mesh_path_free_rcu(struct rtw_mesh_table *tbl, struct rtw_mesh_path *mpath);
  40. static u32 rtw_mesh_table_hash(const void *addr, u32 len, u32 seed)
  41. {
  42. /* Use last four bytes of hw addr as hash index */
  43. return jhash_1word(*(u32 *)(addr+2), seed);
  44. }
  45. static const rtw_rhashtable_params rtw_mesh_rht_params = {
  46. .nelem_hint = 2,
  47. .automatic_shrinking = true,
  48. .key_len = ETH_ALEN,
  49. .key_offset = offsetof(struct rtw_mesh_path, dst),
  50. .head_offset = offsetof(struct rtw_mesh_path, rhash),
  51. .hashfn = rtw_mesh_table_hash,
  52. };
  53. static inline bool rtw_mpath_expired(struct rtw_mesh_path *mpath)
  54. {
  55. return (mpath->flags & RTW_MESH_PATH_ACTIVE) &&
  56. rtw_time_after(rtw_get_current_time(), mpath->exp_time) &&
  57. !(mpath->flags & RTW_MESH_PATH_FIXED);
  58. }
  59. static void rtw_mesh_path_rht_free(void *ptr, void *tblptr)
  60. {
  61. struct rtw_mesh_path *mpath = ptr;
  62. struct rtw_mesh_table *tbl = tblptr;
  63. rtw_mesh_path_free_rcu(tbl, mpath);
  64. }
  65. static struct rtw_mesh_table *rtw_mesh_table_alloc(void)
  66. {
  67. struct rtw_mesh_table *newtbl;
  68. newtbl = rtw_malloc(sizeof(struct rtw_mesh_table));
  69. if (!newtbl)
  70. return NULL;
  71. rtw_hlist_head_init(&newtbl->known_gates);
  72. ATOMIC_SET(&newtbl->entries, 0);
  73. _rtw_spinlock_init(&newtbl->gates_lock);
  74. return newtbl;
  75. }
  76. static void rtw_mesh_table_free(struct rtw_mesh_table *tbl)
  77. {
  78. rtw_rhashtable_free_and_destroy(&tbl->rhead,
  79. rtw_mesh_path_rht_free, tbl);
  80. rtw_mfree(tbl, sizeof(struct rtw_mesh_table));
  81. }
  82. /**
  83. *
  84. * rtw_mesh_path_assign_nexthop - update mesh path next hop
  85. *
  86. * @mpath: mesh path to update
  87. * @sta: next hop to assign
  88. *
  89. * Locking: mpath->state_lock must be held when calling this function
  90. */
  91. void rtw_mesh_path_assign_nexthop(struct rtw_mesh_path *mpath, struct sta_info *sta)
  92. {
  93. struct xmit_frame *xframe;
  94. _list *list, *head;
  95. rtw_rcu_assign_pointer(mpath->next_hop, sta);
  96. enter_critical_bh(&mpath->frame_queue.lock);
  97. head = &mpath->frame_queue.queue;
  98. list = get_next(head);
  99. while (rtw_end_of_queue_search(head, list) == _FALSE) {
  100. xframe = LIST_CONTAINOR(list, struct xmit_frame, list);
  101. list = get_next(list);
  102. _rtw_memcpy(xframe->attrib.ra, sta->cmn.mac_addr, ETH_ALEN);
  103. }
  104. exit_critical_bh(&mpath->frame_queue.lock);
  105. }
  106. static void rtw_prepare_for_gate(struct xmit_frame *xframe, char *dst_addr,
  107. struct rtw_mesh_path *gate_mpath)
  108. {
  109. struct pkt_attrib *attrib = &xframe->attrib;
  110. char *next_hop;
  111. if (attrib->mesh_frame_mode == MESH_UCAST_DATA)
  112. attrib->mesh_frame_mode = MESH_UCAST_PX_DATA;
  113. /* update next hop */
  114. rtw_rcu_read_lock();
  115. next_hop = rtw_rcu_dereference(gate_mpath->next_hop)->cmn.mac_addr;
  116. _rtw_memcpy(attrib->ra, next_hop, ETH_ALEN);
  117. rtw_rcu_read_unlock();
  118. _rtw_memcpy(attrib->mda, dst_addr, ETH_ALEN);
  119. }
  120. /**
  121. *
  122. * rtw_mesh_path_move_to_queue - Move or copy frames from one mpath queue to another
  123. *
  124. * This function is used to transfer or copy frames from an unresolved mpath to
  125. * a gate mpath. The function also adds the Address Extension field and
  126. * updates the next hop.
  127. *
  128. * If a frame already has an Address Extension field, only the next hop and
  129. * destination addresses are updated.
  130. *
  131. * The gate mpath must be an active mpath with a valid mpath->next_hop.
  132. *
  133. * @mpath: An active mpath the frames will be sent to (i.e. the gate)
  134. * @from_mpath: The failed mpath
  135. * @copy: When true, copy all the frames to the new mpath queue. When false,
  136. * move them.
  137. */
  138. static void rtw_mesh_path_move_to_queue(struct rtw_mesh_path *gate_mpath,
  139. struct rtw_mesh_path *from_mpath,
  140. bool copy)
  141. {
  142. struct xmit_frame *fskb;
  143. _list *list, *head;
  144. _list failq;
  145. u32 failq_len;
  146. _irqL flags;
  147. if (rtw_warn_on(gate_mpath == from_mpath))
  148. return;
  149. if (rtw_warn_on(!gate_mpath->next_hop))
  150. return;
  151. _rtw_init_listhead(&failq);
  152. _enter_critical_bh(&from_mpath->frame_queue.lock, &flags);
  153. rtw_list_splice_init(&from_mpath->frame_queue.queue, &failq);
  154. failq_len = from_mpath->frame_queue_len;
  155. from_mpath->frame_queue_len = 0;
  156. _exit_critical_bh(&from_mpath->frame_queue.lock, &flags);
  157. head = &failq;
  158. list = get_next(head);
  159. while (rtw_end_of_queue_search(head, list) == _FALSE) {
  160. if (gate_mpath->frame_queue_len >= RTW_MESH_FRAME_QUEUE_LEN) {
  161. RTW_MPATH_DBG(FUNC_ADPT_FMT" mpath queue for gate %pM is full!\n"
  162. , FUNC_ADPT_ARG(gate_mpath->adapter), gate_mpath->dst);
  163. break;
  164. }
  165. fskb = LIST_CONTAINOR(list, struct xmit_frame, list);
  166. list = get_next(list);
  167. rtw_list_delete(&fskb->list);
  168. failq_len--;
  169. rtw_prepare_for_gate(fskb, gate_mpath->dst, gate_mpath);
  170. _enter_critical_bh(&gate_mpath->frame_queue.lock, &flags);
  171. rtw_list_insert_tail(&fskb->list, get_list_head(&gate_mpath->frame_queue));
  172. gate_mpath->frame_queue_len++;
  173. _exit_critical_bh(&gate_mpath->frame_queue.lock, &flags);
  174. #if 0 /* TODO: copy */
  175. skb = rtw_skb_copy(fskb);
  176. if (rtw_warn_on(!skb))
  177. break;
  178. rtw_prepare_for_gate(skb, gate_mpath->dst, gate_mpath);
  179. skb_queue_tail(&gate_mpath->frame_queue, skb);
  180. if (copy)
  181. continue;
  182. __skb_unlink(fskb, &failq);
  183. rtw_skb_free(fskb);
  184. #endif
  185. }
  186. RTW_MPATH_DBG(FUNC_ADPT_FMT" mpath queue for gate %pM has %d frames\n"
  187. , FUNC_ADPT_ARG(gate_mpath->adapter), gate_mpath->dst, gate_mpath->frame_queue_len);
  188. if (!copy)
  189. return;
  190. _enter_critical_bh(&from_mpath->frame_queue.lock, &flags);
  191. rtw_list_splice(&failq, &from_mpath->frame_queue.queue);
  192. from_mpath->frame_queue_len += failq_len;
  193. _exit_critical_bh(&from_mpath->frame_queue.lock, &flags);
  194. }
  195. static struct rtw_mesh_path *rtw_mpath_lookup(struct rtw_mesh_table *tbl, const u8 *dst)
  196. {
  197. struct rtw_mesh_path *mpath;
  198. if (!tbl)
  199. return NULL;
  200. mpath = rtw_rhashtable_lookup_fast(&tbl->rhead, dst, rtw_mesh_rht_params);
  201. if (mpath && rtw_mpath_expired(mpath)) {
  202. enter_critical_bh(&mpath->state_lock);
  203. mpath->flags &= ~RTW_MESH_PATH_ACTIVE;
  204. exit_critical_bh(&mpath->state_lock);
  205. }
  206. return mpath;
  207. }
  208. /**
  209. * rtw_mesh_path_lookup - look up a path in the mesh path table
  210. * @sdata: local subif
  211. * @dst: hardware address (ETH_ALEN length) of destination
  212. *
  213. * Returns: pointer to the mesh path structure, or NULL if not found
  214. *
  215. * Locking: must be called within a read rcu section.
  216. */
  217. struct rtw_mesh_path *
  218. rtw_mesh_path_lookup(_adapter *adapter, const u8 *dst)
  219. {
  220. return rtw_mpath_lookup(adapter->mesh_info.mesh_paths, dst);
  221. }
  222. struct rtw_mesh_path *
  223. rtw_mpp_path_lookup(_adapter *adapter, const u8 *dst)
  224. {
  225. return rtw_mpath_lookup(adapter->mesh_info.mpp_paths, dst);
  226. }
  227. static struct rtw_mesh_path *
  228. __rtw_mesh_path_lookup_by_idx(struct rtw_mesh_table *tbl, int idx)
  229. {
  230. int i = 0, ret;
  231. struct rtw_mesh_path *mpath = NULL;
  232. rtw_rhashtable_iter iter;
  233. if (!tbl)
  234. return NULL;
  235. ret = rtw_rhashtable_walk_enter(&tbl->rhead, &iter);
  236. if (ret)
  237. return NULL;
  238. ret = rtw_rhashtable_walk_start(&iter);
  239. if (ret && ret != -EAGAIN)
  240. goto err;
  241. while ((mpath = rtw_rhashtable_walk_next(&iter))) {
  242. if (IS_ERR(mpath) && PTR_ERR(mpath) == -EAGAIN)
  243. continue;
  244. if (IS_ERR(mpath))
  245. break;
  246. if (i++ == idx)
  247. break;
  248. }
  249. err:
  250. rtw_rhashtable_walk_stop(&iter);
  251. rtw_rhashtable_walk_exit(&iter);
  252. if (IS_ERR(mpath) || !mpath)
  253. return NULL;
  254. if (rtw_mpath_expired(mpath)) {
  255. enter_critical_bh(&mpath->state_lock);
  256. mpath->flags &= ~RTW_MESH_PATH_ACTIVE;
  257. exit_critical_bh(&mpath->state_lock);
  258. }
  259. return mpath;
  260. }
  261. /**
  262. * rtw_mesh_path_lookup_by_idx - look up a path in the mesh path table by its index
  263. * @idx: index
  264. * @sdata: local subif, or NULL for all entries
  265. *
  266. * Returns: pointer to the mesh path structure, or NULL if not found.
  267. *
  268. * Locking: must be called within a read rcu section.
  269. */
  270. struct rtw_mesh_path *
  271. rtw_mesh_path_lookup_by_idx(_adapter *adapter, int idx)
  272. {
  273. return __rtw_mesh_path_lookup_by_idx(adapter->mesh_info.mesh_paths, idx);
  274. }
  275. /**
  276. * rtw_mpp_path_lookup_by_idx - look up a path in the proxy path table by its index
  277. * @idx: index
  278. * @sdata: local subif, or NULL for all entries
  279. *
  280. * Returns: pointer to the proxy path structure, or NULL if not found.
  281. *
  282. * Locking: must be called within a read rcu section.
  283. */
  284. struct rtw_mesh_path *
  285. rtw_mpp_path_lookup_by_idx(_adapter *adapter, int idx)
  286. {
  287. return __rtw_mesh_path_lookup_by_idx(adapter->mesh_info.mpp_paths, idx);
  288. }
  289. /**
  290. * rtw_mesh_path_add_gate - add the given mpath to a mesh gate to our path table
  291. * @mpath: gate path to add to table
  292. */
  293. int rtw_mesh_path_add_gate(struct rtw_mesh_path *mpath)
  294. {
  295. struct rtw_mesh_cfg *mcfg;
  296. struct rtw_mesh_info *minfo;
  297. struct rtw_mesh_table *tbl;
  298. int err, ori_num_gates;
  299. rtw_rcu_read_lock();
  300. tbl = mpath->adapter->mesh_info.mesh_paths;
  301. if (!tbl) {
  302. err = -ENOENT;
  303. goto err_rcu;
  304. }
  305. enter_critical_bh(&mpath->state_lock);
  306. mcfg = &mpath->adapter->mesh_cfg;
  307. mpath->gate_timeout = rtw_get_current_time() +
  308. rtw_ms_to_systime(mcfg->path_gate_timeout_factor *
  309. mpath->gate_ann_int);
  310. if (mpath->is_gate) {
  311. err = -EEXIST;
  312. exit_critical_bh(&mpath->state_lock);
  313. goto err_rcu;
  314. }
  315. minfo = &mpath->adapter->mesh_info;
  316. mpath->is_gate = true;
  317. _rtw_spinlock(&tbl->gates_lock);
  318. ori_num_gates = minfo->num_gates;
  319. minfo->num_gates++;
  320. rtw_hlist_add_head_rcu(&mpath->gate_list, &tbl->known_gates);
  321. if (ori_num_gates == 0
  322. || rtw_macaddr_is_larger(mpath->dst, minfo->max_addr_gate->dst)
  323. ) {
  324. minfo->max_addr_gate = mpath;
  325. minfo->max_addr_gate_is_larger_than_self =
  326. rtw_macaddr_is_larger(mpath->dst, adapter_mac_addr(mpath->adapter));
  327. }
  328. _rtw_spinunlock(&tbl->gates_lock);
  329. exit_critical_bh(&mpath->state_lock);
  330. if (ori_num_gates == 0) {
  331. update_beacon(mpath->adapter, WLAN_EID_MESH_CONFIG, NULL, _TRUE);
  332. #if CONFIG_RTW_MESH_CTO_MGATE_CARRIER
  333. if (!rtw_mesh_cto_mgate_required(mpath->adapter))
  334. rtw_netif_carrier_on(mpath->adapter->pnetdev);
  335. #endif
  336. }
  337. RTW_MPATH_DBG(
  338. FUNC_ADPT_FMT" Mesh path: Recorded new gate: %pM. %d known gates\n",
  339. FUNC_ADPT_ARG(mpath->adapter),
  340. mpath->dst, mpath->adapter->mesh_info.num_gates);
  341. err = 0;
  342. err_rcu:
  343. rtw_rcu_read_unlock();
  344. return err;
  345. }
  346. /**
  347. * rtw_mesh_gate_del - remove a mesh gate from the list of known gates
  348. * @tbl: table which holds our list of known gates
  349. * @mpath: gate mpath
  350. */
  351. void rtw_mesh_gate_del(struct rtw_mesh_table *tbl, struct rtw_mesh_path *mpath)
  352. {
  353. struct rtw_mesh_cfg *mcfg;
  354. struct rtw_mesh_info *minfo;
  355. int ori_num_gates;
  356. rtw_lockdep_assert_held(&mpath->state_lock);
  357. if (!mpath->is_gate)
  358. return;
  359. mcfg = &mpath->adapter->mesh_cfg;
  360. minfo = &mpath->adapter->mesh_info;
  361. mpath->is_gate = false;
  362. enter_critical_bh(&tbl->gates_lock);
  363. rtw_hlist_del_rcu(&mpath->gate_list);
  364. ori_num_gates = minfo->num_gates;
  365. minfo->num_gates--;
  366. if (ori_num_gates == 1) {
  367. minfo->max_addr_gate = NULL;
  368. minfo->max_addr_gate_is_larger_than_self = 0;
  369. } else if (minfo->max_addr_gate == mpath) {
  370. struct rtw_mesh_path *gate, *max_addr_gate = NULL;
  371. rtw_hlist_node *node;
  372. rtw_hlist_for_each_entry_rcu(gate, node, &tbl->known_gates, gate_list) {
  373. if (!max_addr_gate || rtw_macaddr_is_larger(gate->dst, max_addr_gate->dst))
  374. max_addr_gate = gate;
  375. }
  376. minfo->max_addr_gate = max_addr_gate;
  377. minfo->max_addr_gate_is_larger_than_self =
  378. rtw_macaddr_is_larger(max_addr_gate->dst, adapter_mac_addr(mpath->adapter));
  379. }
  380. exit_critical_bh(&tbl->gates_lock);
  381. if (ori_num_gates == 1) {
  382. update_beacon(mpath->adapter, WLAN_EID_MESH_CONFIG, NULL, _TRUE);
  383. #if CONFIG_RTW_MESH_CTO_MGATE_CARRIER
  384. if (rtw_mesh_cto_mgate_required(mpath->adapter))
  385. rtw_netif_carrier_off(mpath->adapter->pnetdev);
  386. #endif
  387. }
  388. RTW_MPATH_DBG(
  389. FUNC_ADPT_FMT" Mesh path: Deleted gate: %pM. %d known gates\n",
  390. FUNC_ADPT_ARG(mpath->adapter),
  391. mpath->dst, mpath->adapter->mesh_info.num_gates);
  392. }
  393. /**
  394. * rtw_mesh_gate_search - search a mesh gate from the list of known gates
  395. * @tbl: table which holds our list of known gates
  396. * @addr: address of gate
  397. */
  398. bool rtw_mesh_gate_search(struct rtw_mesh_table *tbl, const u8 *addr)
  399. {
  400. struct rtw_mesh_path *gate;
  401. rtw_hlist_node *node;
  402. bool exist = 0;
  403. rtw_rcu_read_lock();
  404. rtw_hlist_for_each_entry_rcu(gate, node, &tbl->known_gates, gate_list) {
  405. if (_rtw_memcmp(gate->dst, addr, ETH_ALEN) == _TRUE) {
  406. exist = 1;
  407. break;
  408. }
  409. }
  410. rtw_rcu_read_unlock();
  411. return exist;
  412. }
  413. /**
  414. * rtw_mesh_gate_num - number of gates known to this interface
  415. * @sdata: subif data
  416. */
  417. int rtw_mesh_gate_num(_adapter *adapter)
  418. {
  419. return adapter->mesh_info.num_gates;
  420. }
  421. bool rtw_mesh_is_primary_gate(_adapter *adapter)
  422. {
  423. struct rtw_mesh_cfg *mcfg = &adapter->mesh_cfg;
  424. struct rtw_mesh_info *minfo = &adapter->mesh_info;
  425. return mcfg->dot11MeshGateAnnouncementProtocol
  426. && !minfo->max_addr_gate_is_larger_than_self;
  427. }
  428. void dump_known_gates(void *sel, _adapter *adapter)
  429. {
  430. struct rtw_mesh_info *minfo = &adapter->mesh_info;
  431. struct rtw_mesh_table *tbl;
  432. struct rtw_mesh_path *gate;
  433. rtw_hlist_node *node;
  434. if (!rtw_mesh_gate_num(adapter))
  435. goto exit;
  436. rtw_rcu_read_lock();
  437. tbl = minfo->mesh_paths;
  438. if (!tbl)
  439. goto unlock;
  440. RTW_PRINT_SEL(sel, "num:%d\n", rtw_mesh_gate_num(adapter));
  441. rtw_hlist_for_each_entry_rcu(gate, node, &tbl->known_gates, gate_list) {
  442. RTW_PRINT_SEL(sel, "%c"MAC_FMT"\n"
  443. , gate == minfo->max_addr_gate ? '*' : ' '
  444. , MAC_ARG(gate->dst));
  445. }
  446. unlock:
  447. rtw_rcu_read_unlock();
  448. exit:
  449. return;
  450. }
  451. static
  452. struct rtw_mesh_path *rtw_mesh_path_new(_adapter *adapter,
  453. const u8 *dst)
  454. {
  455. struct rtw_mesh_path *new_mpath;
  456. new_mpath = rtw_zmalloc(sizeof(struct rtw_mesh_path));
  457. if (!new_mpath)
  458. return NULL;
  459. _rtw_memcpy(new_mpath->dst, dst, ETH_ALEN);
  460. _rtw_memset(new_mpath->rann_snd_addr, 0xFF, ETH_ALEN);
  461. new_mpath->is_root = false;
  462. new_mpath->adapter = adapter;
  463. new_mpath->flags = 0;
  464. new_mpath->gate_asked = false;
  465. _rtw_init_queue(&new_mpath->frame_queue);
  466. new_mpath->frame_queue_len = 0;
  467. new_mpath->exp_time = rtw_get_current_time();
  468. _rtw_spinlock_init(&new_mpath->state_lock);
  469. rtw_init_timer(&new_mpath->timer, adapter, rtw_mesh_path_timer, new_mpath);
  470. return new_mpath;
  471. }
  472. /**
  473. * rtw_mesh_path_add - allocate and add a new path to the mesh path table
  474. * @dst: destination address of the path (ETH_ALEN length)
  475. * @sdata: local subif
  476. *
  477. * Returns: 0 on success
  478. *
  479. * State: the initial state of the new path is set to 0
  480. */
  481. struct rtw_mesh_path *rtw_mesh_path_add(_adapter *adapter,
  482. const u8 *dst)
  483. {
  484. struct rtw_mesh_table *tbl = adapter->mesh_info.mesh_paths;
  485. struct rtw_mesh_path *mpath, *new_mpath;
  486. int ret;
  487. if (!tbl)
  488. return ERR_PTR(-ENOTSUPP);
  489. if (_rtw_memcmp(dst, adapter_mac_addr(adapter), ETH_ALEN) == _TRUE)
  490. /* never add ourselves as neighbours */
  491. return ERR_PTR(-ENOTSUPP);
  492. if (is_multicast_mac_addr(dst))
  493. return ERR_PTR(-ENOTSUPP);
  494. if (ATOMIC_INC_UNLESS(&adapter->mesh_info.mpaths, RTW_MESH_MAX_MPATHS) == 0)
  495. return ERR_PTR(-ENOSPC);
  496. new_mpath = rtw_mesh_path_new(adapter, dst);
  497. if (!new_mpath)
  498. return ERR_PTR(-ENOMEM);
  499. do {
  500. ret = rtw_rhashtable_lookup_insert_fast(&tbl->rhead,
  501. &new_mpath->rhash,
  502. rtw_mesh_rht_params);
  503. if (ret == -EEXIST)
  504. mpath = rtw_rhashtable_lookup_fast(&tbl->rhead,
  505. dst,
  506. rtw_mesh_rht_params);
  507. } while (unlikely(ret == -EEXIST && !mpath));
  508. if (ret && ret != -EEXIST)
  509. return ERR_PTR(ret);
  510. /* At this point either new_mpath was added, or we found a
  511. * matching entry already in the table; in the latter case
  512. * free the unnecessary new entry.
  513. */
  514. if (ret == -EEXIST) {
  515. rtw_mfree(new_mpath, sizeof(struct rtw_mesh_path));
  516. new_mpath = mpath;
  517. }
  518. adapter->mesh_info.mesh_paths_generation++;
  519. return new_mpath;
  520. }
  521. int rtw_mpp_path_add(_adapter *adapter,
  522. const u8 *dst, const u8 *mpp)
  523. {
  524. struct rtw_mesh_table *tbl = adapter->mesh_info.mpp_paths;
  525. struct rtw_mesh_path *new_mpath;
  526. int ret;
  527. if (!tbl)
  528. return -ENOTSUPP;
  529. if (_rtw_memcmp(dst, adapter_mac_addr(adapter), ETH_ALEN) == _TRUE)
  530. /* never add ourselves as neighbours */
  531. return -ENOTSUPP;
  532. if (is_multicast_mac_addr(dst))
  533. return -ENOTSUPP;
  534. new_mpath = rtw_mesh_path_new(adapter, dst);
  535. if (!new_mpath)
  536. return -ENOMEM;
  537. _rtw_memcpy(new_mpath->mpp, mpp, ETH_ALEN);
  538. ret = rtw_rhashtable_lookup_insert_fast(&tbl->rhead,
  539. &new_mpath->rhash,
  540. rtw_mesh_rht_params);
  541. adapter->mesh_info.mpp_paths_generation++;
  542. return ret;
  543. }
  544. void dump_mpp(void *sel, _adapter *adapter)
  545. {
  546. struct rtw_mesh_path *mpath;
  547. int idx = 0;
  548. char dst[ETH_ALEN];
  549. char mpp[ETH_ALEN];
  550. RTW_PRINT_SEL(sel, "%-17s %-17s\n", "dst", "mpp");
  551. do {
  552. rtw_rcu_read_lock();
  553. mpath = rtw_mpp_path_lookup_by_idx(adapter, idx);
  554. if (mpath) {
  555. _rtw_memcpy(dst, mpath->dst, ETH_ALEN);
  556. _rtw_memcpy(mpp, mpath->mpp, ETH_ALEN);
  557. }
  558. rtw_rcu_read_unlock();
  559. if (mpath) {
  560. RTW_PRINT_SEL(sel, MAC_FMT" "MAC_FMT"\n"
  561. , MAC_ARG(dst), MAC_ARG(mpp));
  562. }
  563. idx++;
  564. } while (mpath);
  565. }
  566. /**
  567. * rtw_mesh_plink_broken - deactivates paths and sends perr when a link breaks
  568. *
  569. * @sta: broken peer link
  570. *
  571. * This function must be called from the rate control algorithm if enough
  572. * delivery errors suggest that a peer link is no longer usable.
  573. */
  574. void rtw_mesh_plink_broken(struct sta_info *sta)
  575. {
  576. _adapter *adapter = sta->padapter;
  577. struct rtw_mesh_table *tbl = adapter->mesh_info.mesh_paths;
  578. static const u8 bcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  579. struct rtw_mesh_path *mpath;
  580. rtw_rhashtable_iter iter;
  581. int ret;
  582. if (!tbl)
  583. return;
  584. ret = rtw_rhashtable_walk_enter(&tbl->rhead, &iter);
  585. if (ret)
  586. return;
  587. ret = rtw_rhashtable_walk_start(&iter);
  588. if (ret && ret != -EAGAIN)
  589. goto out;
  590. while ((mpath = rtw_rhashtable_walk_next(&iter))) {
  591. if (IS_ERR(mpath) && PTR_ERR(mpath) == -EAGAIN)
  592. continue;
  593. if (IS_ERR(mpath))
  594. break;
  595. if (rtw_rcu_access_pointer(mpath->next_hop) == sta &&
  596. mpath->flags & RTW_MESH_PATH_ACTIVE &&
  597. !(mpath->flags & RTW_MESH_PATH_FIXED)) {
  598. enter_critical_bh(&mpath->state_lock);
  599. mpath->flags &= ~RTW_MESH_PATH_ACTIVE;
  600. ++mpath->sn;
  601. exit_critical_bh(&mpath->state_lock);
  602. rtw_mesh_path_error_tx(adapter,
  603. adapter->mesh_cfg.element_ttl,
  604. mpath->dst, mpath->sn,
  605. WLAN_REASON_MESH_PATH_DEST_UNREACHABLE, bcast);
  606. }
  607. }
  608. out:
  609. rtw_rhashtable_walk_stop(&iter);
  610. rtw_rhashtable_walk_exit(&iter);
  611. }
  612. static void rtw_mesh_path_free_rcu(struct rtw_mesh_table *tbl,
  613. struct rtw_mesh_path *mpath)
  614. {
  615. _adapter *adapter = mpath->adapter;
  616. enter_critical_bh(&mpath->state_lock);
  617. mpath->flags |= RTW_MESH_PATH_RESOLVING | RTW_MESH_PATH_DELETED;
  618. rtw_mesh_gate_del(tbl, mpath);
  619. exit_critical_bh(&mpath->state_lock);
  620. _cancel_timer_ex(&mpath->timer);
  621. ATOMIC_DEC(&adapter->mesh_info.mpaths);
  622. ATOMIC_DEC(&tbl->entries);
  623. _rtw_spinlock_free(&mpath->state_lock);
  624. rtw_mesh_path_flush_pending(mpath);
  625. rtw_mpath_free_rcu(mpath);
  626. }
  627. static void __rtw_mesh_path_del(struct rtw_mesh_table *tbl, struct rtw_mesh_path *mpath)
  628. {
  629. rtw_rhashtable_remove_fast(&tbl->rhead, &mpath->rhash, rtw_mesh_rht_params);
  630. rtw_mesh_path_free_rcu(tbl, mpath);
  631. }
  632. /**
  633. * rtw_mesh_path_flush_by_nexthop - Deletes mesh paths if their next hop matches
  634. *
  635. * @sta: mesh peer to match
  636. *
  637. * RCU notes: this function is called when a mesh plink transitions from
  638. * PLINK_ESTAB to any other state, since PLINK_ESTAB state is the only one that
  639. * allows path creation. This will happen before the sta can be freed (because
  640. * sta_info_destroy() calls this) so any reader in a rcu read block will be
  641. * protected against the plink disappearing.
  642. */
  643. void rtw_mesh_path_flush_by_nexthop(struct sta_info *sta)
  644. {
  645. _adapter *adapter = sta->padapter;
  646. struct rtw_mesh_table *tbl = adapter->mesh_info.mesh_paths;
  647. struct rtw_mesh_path *mpath;
  648. rtw_rhashtable_iter iter;
  649. int ret;
  650. if (!tbl)
  651. return;
  652. ret = rtw_rhashtable_walk_enter(&tbl->rhead, &iter);
  653. if (ret)
  654. return;
  655. ret = rtw_rhashtable_walk_start(&iter);
  656. if (ret && ret != -EAGAIN)
  657. goto out;
  658. while ((mpath = rtw_rhashtable_walk_next(&iter))) {
  659. if (IS_ERR(mpath) && PTR_ERR(mpath) == -EAGAIN)
  660. continue;
  661. if (IS_ERR(mpath))
  662. break;
  663. if (rtw_rcu_access_pointer(mpath->next_hop) == sta)
  664. __rtw_mesh_path_del(tbl, mpath);
  665. }
  666. out:
  667. rtw_rhashtable_walk_stop(&iter);
  668. rtw_rhashtable_walk_exit(&iter);
  669. }
  670. static void rtw_mpp_flush_by_proxy(_adapter *adapter,
  671. const u8 *proxy)
  672. {
  673. struct rtw_mesh_table *tbl = adapter->mesh_info.mpp_paths;
  674. struct rtw_mesh_path *mpath;
  675. rtw_rhashtable_iter iter;
  676. int ret;
  677. if (!tbl)
  678. return;
  679. ret = rtw_rhashtable_walk_enter(&tbl->rhead, &iter);
  680. if (ret)
  681. return;
  682. ret = rtw_rhashtable_walk_start(&iter);
  683. if (ret && ret != -EAGAIN)
  684. goto out;
  685. while ((mpath = rtw_rhashtable_walk_next(&iter))) {
  686. if (IS_ERR(mpath) && PTR_ERR(mpath) == -EAGAIN)
  687. continue;
  688. if (IS_ERR(mpath))
  689. break;
  690. if (_rtw_memcmp(mpath->mpp, proxy, ETH_ALEN) == _TRUE)
  691. __rtw_mesh_path_del(tbl, mpath);
  692. }
  693. out:
  694. rtw_rhashtable_walk_stop(&iter);
  695. rtw_rhashtable_walk_exit(&iter);
  696. }
  697. static void rtw_table_flush_by_iface(struct rtw_mesh_table *tbl)
  698. {
  699. struct rtw_mesh_path *mpath;
  700. rtw_rhashtable_iter iter;
  701. int ret;
  702. if (!tbl)
  703. return;
  704. ret = rtw_rhashtable_walk_enter(&tbl->rhead, &iter);
  705. if (ret)
  706. return;
  707. ret = rtw_rhashtable_walk_start(&iter);
  708. if (ret && ret != -EAGAIN)
  709. goto out;
  710. while ((mpath = rtw_rhashtable_walk_next(&iter))) {
  711. if (IS_ERR(mpath) && PTR_ERR(mpath) == -EAGAIN)
  712. continue;
  713. if (IS_ERR(mpath))
  714. break;
  715. __rtw_mesh_path_del(tbl, mpath);
  716. }
  717. out:
  718. rtw_rhashtable_walk_stop(&iter);
  719. rtw_rhashtable_walk_exit(&iter);
  720. }
  721. /**
  722. * rtw_mesh_path_flush_by_iface - Deletes all mesh paths associated with a given iface
  723. *
  724. * This function deletes both mesh paths as well as mesh portal paths.
  725. *
  726. * @sdata: interface data to match
  727. *
  728. */
  729. void rtw_mesh_path_flush_by_iface(_adapter *adapter)
  730. {
  731. rtw_table_flush_by_iface(adapter->mesh_info.mesh_paths);
  732. rtw_table_flush_by_iface(adapter->mesh_info.mpp_paths);
  733. }
  734. /**
  735. * rtw_table_path_del - delete a path from the mesh or mpp table
  736. *
  737. * @tbl: mesh or mpp path table
  738. * @sdata: local subif
  739. * @addr: dst address (ETH_ALEN length)
  740. *
  741. * Returns: 0 if successful
  742. */
  743. static int rtw_table_path_del(struct rtw_mesh_table *tbl,
  744. const u8 *addr)
  745. {
  746. struct rtw_mesh_path *mpath;
  747. if (!tbl)
  748. return -ENXIO;
  749. rtw_rcu_read_lock();
  750. mpath = rtw_rhashtable_lookup_fast(&tbl->rhead, addr, rtw_mesh_rht_params);
  751. if (!mpath) {
  752. rtw_rcu_read_unlock();
  753. return -ENXIO;
  754. }
  755. __rtw_mesh_path_del(tbl, mpath);
  756. rtw_rcu_read_unlock();
  757. return 0;
  758. }
  759. /**
  760. * rtw_mesh_path_del - delete a mesh path from the table
  761. *
  762. * @addr: dst address (ETH_ALEN length)
  763. * @sdata: local subif
  764. *
  765. * Returns: 0 if successful
  766. */
  767. int rtw_mesh_path_del(_adapter *adapter, const u8 *addr)
  768. {
  769. int err;
  770. /* flush relevant mpp entries first */
  771. rtw_mpp_flush_by_proxy(adapter, addr);
  772. err = rtw_table_path_del(adapter->mesh_info.mesh_paths, addr);
  773. adapter->mesh_info.mesh_paths_generation++;
  774. return err;
  775. }
  776. /**
  777. * rtw_mesh_path_tx_pending - sends pending frames in a mesh path queue
  778. *
  779. * @mpath: mesh path to activate
  780. *
  781. * Locking: the state_lock of the mpath structure must NOT be held when calling
  782. * this function.
  783. */
  784. void rtw_mesh_path_tx_pending(struct rtw_mesh_path *mpath)
  785. {
  786. if (mpath->flags & RTW_MESH_PATH_ACTIVE) {
  787. struct rtw_mesh_info *minfo = &mpath->adapter->mesh_info;
  788. _list q;
  789. u32 q_len = 0;
  790. _rtw_init_listhead(&q);
  791. /* move to local queue */
  792. enter_critical_bh(&mpath->frame_queue.lock);
  793. if (mpath->frame_queue_len) {
  794. rtw_list_splice_init(&mpath->frame_queue.queue, &q);
  795. q_len = mpath->frame_queue_len;
  796. mpath->frame_queue_len = 0;
  797. }
  798. exit_critical_bh(&mpath->frame_queue.lock);
  799. if (q_len) {
  800. /* move to mpath_tx_queue */
  801. enter_critical_bh(&minfo->mpath_tx_queue.lock);
  802. rtw_list_splice_tail(&q, &minfo->mpath_tx_queue.queue);
  803. minfo->mpath_tx_queue_len += q_len;
  804. exit_critical_bh(&minfo->mpath_tx_queue.lock);
  805. /* schedule mpath_tx_tasklet */
  806. tasklet_hi_schedule(&minfo->mpath_tx_tasklet);
  807. }
  808. }
  809. }
  810. /**
  811. * rtw_mesh_path_send_to_gates - sends pending frames to all known mesh gates
  812. *
  813. * @mpath: mesh path whose queue will be emptied
  814. *
  815. * If there is only one gate, the frames are transferred from the failed mpath
  816. * queue to that gate's queue. If there are more than one gates, the frames
  817. * are copied from each gate to the next. After frames are copied, the
  818. * mpath queues are emptied onto the transmission queue.
  819. */
  820. int rtw_mesh_path_send_to_gates(struct rtw_mesh_path *mpath)
  821. {
  822. _adapter *adapter = mpath->adapter;
  823. struct rtw_mesh_table *tbl;
  824. struct rtw_mesh_path *from_mpath = mpath;
  825. struct rtw_mesh_path *gate;
  826. bool copy = false;
  827. rtw_hlist_node *node;
  828. tbl = adapter->mesh_info.mesh_paths;
  829. if (!tbl)
  830. return 0;
  831. rtw_rcu_read_lock();
  832. rtw_hlist_for_each_entry_rcu(gate, node, &tbl->known_gates, gate_list) {
  833. if (gate->flags & RTW_MESH_PATH_ACTIVE) {
  834. RTW_MPATH_DBG(FUNC_ADPT_FMT" Forwarding to %pM\n",
  835. FUNC_ADPT_ARG(adapter), gate->dst);
  836. rtw_mesh_path_move_to_queue(gate, from_mpath, copy);
  837. from_mpath = gate;
  838. copy = true;
  839. } else {
  840. RTW_MPATH_DBG(
  841. FUNC_ADPT_FMT" Not forwarding to %pM (flags %#x)\n",
  842. FUNC_ADPT_ARG(adapter), gate->dst, gate->flags);
  843. }
  844. }
  845. rtw_hlist_for_each_entry_rcu(gate, node, &tbl->known_gates, gate_list) {
  846. RTW_MPATH_DBG(FUNC_ADPT_FMT" Sending to %pM\n",
  847. FUNC_ADPT_ARG(adapter), gate->dst);
  848. rtw_mesh_path_tx_pending(gate);
  849. }
  850. rtw_rcu_read_unlock();
  851. return (from_mpath == mpath) ? -EHOSTUNREACH : 0;
  852. }
  853. /**
  854. * rtw_mesh_path_discard_frame - discard a frame whose path could not be resolved
  855. *
  856. * @skb: frame to discard
  857. * @sdata: network subif the frame was to be sent through
  858. *
  859. * Locking: the function must me called within a rcu_read_lock region
  860. */
  861. void rtw_mesh_path_discard_frame(_adapter *adapter,
  862. struct xmit_frame *xframe)
  863. {
  864. rtw_free_xmitframe(&adapter->xmitpriv, xframe);
  865. adapter->mesh_info.mshstats.dropped_frames_no_route++;
  866. }
  867. /**
  868. * rtw_mesh_path_flush_pending - free the pending queue of a mesh path
  869. *
  870. * @mpath: mesh path whose queue has to be freed
  871. *
  872. * Locking: the function must me called within a rcu_read_lock region
  873. */
  874. void rtw_mesh_path_flush_pending(struct rtw_mesh_path *mpath)
  875. {
  876. struct xmit_frame *xframe;
  877. _list *list, *head;
  878. _list tmp;
  879. _rtw_init_listhead(&tmp);
  880. enter_critical_bh(&mpath->frame_queue.lock);
  881. rtw_list_splice_init(&mpath->frame_queue.queue, &tmp);
  882. mpath->frame_queue_len = 0;
  883. exit_critical_bh(&mpath->frame_queue.lock);
  884. head = &tmp;
  885. list = get_next(head);
  886. while (rtw_end_of_queue_search(head, list) == _FALSE) {
  887. xframe = LIST_CONTAINOR(list, struct xmit_frame, list);
  888. list = get_next(list);
  889. rtw_list_delete(&xframe->list);
  890. rtw_mesh_path_discard_frame(mpath->adapter, xframe);
  891. }
  892. }
  893. /**
  894. * rtw_mesh_path_fix_nexthop - force a specific next hop for a mesh path
  895. *
  896. * @mpath: the mesh path to modify
  897. * @next_hop: the next hop to force
  898. *
  899. * Locking: this function must be called holding mpath->state_lock
  900. */
  901. void rtw_mesh_path_fix_nexthop(struct rtw_mesh_path *mpath, struct sta_info *next_hop)
  902. {
  903. enter_critical_bh(&mpath->state_lock);
  904. rtw_mesh_path_assign_nexthop(mpath, next_hop);
  905. mpath->sn = 0xffff;
  906. mpath->metric = 0;
  907. mpath->hop_count = 0;
  908. mpath->exp_time = 0;
  909. mpath->flags = RTW_MESH_PATH_FIXED | RTW_MESH_PATH_SN_VALID;
  910. rtw_mesh_path_activate(mpath);
  911. exit_critical_bh(&mpath->state_lock);
  912. rtw_ewma_err_rate_init(&next_hop->metrics.err_rate);
  913. /* init it at a low value - 0 start is tricky */
  914. rtw_ewma_err_rate_add(&next_hop->metrics.err_rate, 1);
  915. rtw_mesh_path_tx_pending(mpath);
  916. }
  917. int rtw_mesh_pathtbl_init(_adapter *adapter)
  918. {
  919. struct rtw_mesh_table *tbl_path, *tbl_mpp;
  920. int ret;
  921. tbl_path = rtw_mesh_table_alloc();
  922. if (!tbl_path)
  923. return -ENOMEM;
  924. tbl_mpp = rtw_mesh_table_alloc();
  925. if (!tbl_mpp) {
  926. ret = -ENOMEM;
  927. goto free_path;
  928. }
  929. rtw_rhashtable_init(&tbl_path->rhead, &rtw_mesh_rht_params);
  930. rtw_rhashtable_init(&tbl_mpp->rhead, &rtw_mesh_rht_params);
  931. adapter->mesh_info.mesh_paths = tbl_path;
  932. adapter->mesh_info.mpp_paths = tbl_mpp;
  933. return 0;
  934. free_path:
  935. rtw_mesh_table_free(tbl_path);
  936. return ret;
  937. }
  938. static
  939. void rtw_mesh_path_tbl_expire(_adapter *adapter,
  940. struct rtw_mesh_table *tbl)
  941. {
  942. struct rtw_mesh_path *mpath;
  943. rtw_rhashtable_iter iter;
  944. int ret;
  945. if (!tbl)
  946. return;
  947. ret = rtw_rhashtable_walk_enter(&tbl->rhead, &iter);
  948. if (ret)
  949. return;
  950. ret = rtw_rhashtable_walk_start(&iter);
  951. if (ret && ret != -EAGAIN)
  952. goto out;
  953. while ((mpath = rtw_rhashtable_walk_next(&iter))) {
  954. if (IS_ERR(mpath) && PTR_ERR(mpath) == -EAGAIN)
  955. continue;
  956. if (IS_ERR(mpath))
  957. break;
  958. if ((!(mpath->flags & RTW_MESH_PATH_RESOLVING)) &&
  959. (!(mpath->flags & RTW_MESH_PATH_FIXED)) &&
  960. rtw_time_after(rtw_get_current_time(), mpath->exp_time + RTW_MESH_PATH_EXPIRE))
  961. __rtw_mesh_path_del(tbl, mpath);
  962. if (mpath->is_gate && /* need not to deal with non-gate case */
  963. rtw_time_after(rtw_get_current_time(), mpath->gate_timeout)) {
  964. RTW_MPATH_DBG(FUNC_ADPT_FMT"mpath [%pM] expired systime is %lu systime is %lu\n",
  965. FUNC_ADPT_ARG(adapter), mpath->dst,
  966. mpath->gate_timeout, rtw_get_current_time());
  967. enter_critical_bh(&mpath->state_lock);
  968. if (mpath->gate_asked) { /* asked gate before */
  969. rtw_mesh_gate_del(tbl, mpath);
  970. exit_critical_bh(&mpath->state_lock);
  971. } else {
  972. mpath->gate_asked = true;
  973. mpath->gate_timeout = rtw_get_current_time() + rtw_ms_to_systime(mpath->gate_ann_int);
  974. exit_critical_bh(&mpath->state_lock);
  975. rtw_mesh_queue_preq(mpath, RTW_PREQ_Q_F_START | RTW_PREQ_Q_F_REFRESH);
  976. RTW_MPATH_DBG(FUNC_ADPT_FMT"mpath [%pM] ask mesh gate existence (is_root=%d)\n",
  977. FUNC_ADPT_ARG(adapter), mpath->dst, mpath->is_root);
  978. }
  979. }
  980. }
  981. out:
  982. rtw_rhashtable_walk_stop(&iter);
  983. rtw_rhashtable_walk_exit(&iter);
  984. }
  985. void rtw_mesh_path_expire(_adapter *adapter)
  986. {
  987. rtw_mesh_path_tbl_expire(adapter, adapter->mesh_info.mesh_paths);
  988. rtw_mesh_path_tbl_expire(adapter, adapter->mesh_info.mpp_paths);
  989. }
  990. void rtw_mesh_pathtbl_unregister(_adapter *adapter)
  991. {
  992. if (adapter->mesh_info.mesh_paths) {
  993. rtw_mesh_table_free(adapter->mesh_info.mesh_paths);
  994. adapter->mesh_info.mesh_paths = NULL;
  995. }
  996. if (adapter->mesh_info.mpp_paths) {
  997. rtw_mesh_table_free(adapter->mesh_info.mpp_paths);
  998. adapter->mesh_info.mpp_paths = NULL;
  999. }
  1000. }
  1001. #endif /* CONFIG_RTW_MESH */