mesh_ps.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright 2012-2013, Marco Porsch <marco.porsch@s2005.tu-chemnitz.de>
  4. * Copyright 2012-2013, cozybit Inc.
  5. * Copyright (C) 2021 Intel Corporation
  6. */
  7. #include "mesh.h"
  8. #include "wme.h"
  9. /* mesh PS management */
  10. /**
  11. * mps_qos_null_get - create pre-addressed QoS Null frame for mesh powersave
  12. * @sta: the station to get the frame for
  13. */
  14. static struct sk_buff *mps_qos_null_get(struct sta_info *sta)
  15. {
  16. struct ieee80211_sub_if_data *sdata = sta->sdata;
  17. struct ieee80211_local *local = sdata->local;
  18. struct ieee80211_hdr *nullfunc; /* use 4addr header */
  19. struct sk_buff *skb;
  20. int size = sizeof(*nullfunc);
  21. __le16 fc;
  22. skb = dev_alloc_skb(local->hw.extra_tx_headroom + size + 2);
  23. if (!skb)
  24. return NULL;
  25. skb_reserve(skb, local->hw.extra_tx_headroom);
  26. nullfunc = skb_put(skb, size);
  27. fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
  28. ieee80211_fill_mesh_addresses(nullfunc, &fc, sta->sta.addr,
  29. sdata->vif.addr);
  30. nullfunc->frame_control = fc;
  31. nullfunc->duration_id = 0;
  32. nullfunc->seq_ctrl = 0;
  33. /* no address resolution for this frame -> set addr 1 immediately */
  34. memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
  35. skb_put_zero(skb, 2); /* append QoS control field */
  36. ieee80211_mps_set_frame_flags(sdata, sta, nullfunc);
  37. return skb;
  38. }
  39. /**
  40. * mps_qos_null_tx - send a QoS Null to indicate link-specific power mode
  41. * @sta: the station to send to
  42. */
  43. static void mps_qos_null_tx(struct sta_info *sta)
  44. {
  45. struct sk_buff *skb;
  46. skb = mps_qos_null_get(sta);
  47. if (!skb)
  48. return;
  49. mps_dbg(sta->sdata, "announcing peer-specific power mode to %pM\n",
  50. sta->sta.addr);
  51. /* don't unintentionally start a MPSP */
  52. if (!test_sta_flag(sta, WLAN_STA_PS_STA)) {
  53. u8 *qc = ieee80211_get_qos_ctl((void *) skb->data);
  54. qc[0] |= IEEE80211_QOS_CTL_EOSP;
  55. }
  56. ieee80211_tx_skb(sta->sdata, skb);
  57. }
  58. /**
  59. * ieee80211_mps_local_status_update - track status of local link-specific PMs
  60. *
  61. * @sdata: local mesh subif
  62. *
  63. * sets the non-peer power mode and triggers the driver PS (re-)configuration
  64. * Return BSS_CHANGED_BEACON if a beacon update is necessary.
  65. */
  66. u32 ieee80211_mps_local_status_update(struct ieee80211_sub_if_data *sdata)
  67. {
  68. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  69. struct sta_info *sta;
  70. bool peering = false;
  71. int light_sleep_cnt = 0;
  72. int deep_sleep_cnt = 0;
  73. u32 changed = 0;
  74. enum nl80211_mesh_power_mode nonpeer_pm;
  75. rcu_read_lock();
  76. list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
  77. if (sdata != sta->sdata)
  78. continue;
  79. switch (sta->mesh->plink_state) {
  80. case NL80211_PLINK_OPN_SNT:
  81. case NL80211_PLINK_OPN_RCVD:
  82. case NL80211_PLINK_CNF_RCVD:
  83. peering = true;
  84. break;
  85. case NL80211_PLINK_ESTAB:
  86. if (sta->mesh->local_pm == NL80211_MESH_POWER_LIGHT_SLEEP)
  87. light_sleep_cnt++;
  88. else if (sta->mesh->local_pm == NL80211_MESH_POWER_DEEP_SLEEP)
  89. deep_sleep_cnt++;
  90. break;
  91. default:
  92. break;
  93. }
  94. }
  95. rcu_read_unlock();
  96. /*
  97. * Set non-peer mode to active during peering/scanning/authentication
  98. * (see IEEE802.11-2012 13.14.8.3). The non-peer mesh power mode is
  99. * deep sleep if the local STA is in light or deep sleep towards at
  100. * least one mesh peer (see 13.14.3.1). Otherwise, set it to the
  101. * user-configured default value.
  102. */
  103. if (peering) {
  104. mps_dbg(sdata, "setting non-peer PM to active for peering\n");
  105. nonpeer_pm = NL80211_MESH_POWER_ACTIVE;
  106. } else if (light_sleep_cnt || deep_sleep_cnt) {
  107. mps_dbg(sdata, "setting non-peer PM to deep sleep\n");
  108. nonpeer_pm = NL80211_MESH_POWER_DEEP_SLEEP;
  109. } else {
  110. mps_dbg(sdata, "setting non-peer PM to user value\n");
  111. nonpeer_pm = ifmsh->mshcfg.power_mode;
  112. }
  113. /* need update if sleep counts move between 0 and non-zero */
  114. if (ifmsh->nonpeer_pm != nonpeer_pm ||
  115. !ifmsh->ps_peers_light_sleep != !light_sleep_cnt ||
  116. !ifmsh->ps_peers_deep_sleep != !deep_sleep_cnt)
  117. changed = BSS_CHANGED_BEACON;
  118. ifmsh->nonpeer_pm = nonpeer_pm;
  119. ifmsh->ps_peers_light_sleep = light_sleep_cnt;
  120. ifmsh->ps_peers_deep_sleep = deep_sleep_cnt;
  121. return changed;
  122. }
  123. /**
  124. * ieee80211_mps_set_sta_local_pm - set local PM towards a mesh STA
  125. *
  126. * @sta: mesh STA
  127. * @pm: the power mode to set
  128. * Return BSS_CHANGED_BEACON if a beacon update is in order.
  129. */
  130. u32 ieee80211_mps_set_sta_local_pm(struct sta_info *sta,
  131. enum nl80211_mesh_power_mode pm)
  132. {
  133. struct ieee80211_sub_if_data *sdata = sta->sdata;
  134. if (sta->mesh->local_pm == pm)
  135. return 0;
  136. mps_dbg(sdata, "local STA operates in mode %d with %pM\n",
  137. pm, sta->sta.addr);
  138. sta->mesh->local_pm = pm;
  139. /*
  140. * announce peer-specific power mode transition
  141. * (see IEEE802.11-2012 13.14.3.2 and 13.14.3.3)
  142. */
  143. if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
  144. mps_qos_null_tx(sta);
  145. return ieee80211_mps_local_status_update(sdata);
  146. }
  147. /**
  148. * ieee80211_mps_set_frame_flags - set mesh PS flags in FC (and QoS Control)
  149. *
  150. * @sdata: local mesh subif
  151. * @sta: mesh STA
  152. * @hdr: 802.11 frame header
  153. *
  154. * see IEEE802.11-2012 8.2.4.1.7 and 8.2.4.5.11
  155. *
  156. * NOTE: sta must be given when an individually-addressed QoS frame header
  157. * is handled, for group-addressed and management frames it is not used
  158. */
  159. void ieee80211_mps_set_frame_flags(struct ieee80211_sub_if_data *sdata,
  160. struct sta_info *sta,
  161. struct ieee80211_hdr *hdr)
  162. {
  163. enum nl80211_mesh_power_mode pm;
  164. u8 *qc;
  165. if (WARN_ON(is_unicast_ether_addr(hdr->addr1) &&
  166. ieee80211_is_data_qos(hdr->frame_control) &&
  167. !sta))
  168. return;
  169. if (is_unicast_ether_addr(hdr->addr1) &&
  170. ieee80211_is_data_qos(hdr->frame_control) &&
  171. sta->mesh->plink_state == NL80211_PLINK_ESTAB)
  172. pm = sta->mesh->local_pm;
  173. else
  174. pm = sdata->u.mesh.nonpeer_pm;
  175. if (pm == NL80211_MESH_POWER_ACTIVE)
  176. hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_PM);
  177. else
  178. hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
  179. if (!ieee80211_is_data_qos(hdr->frame_control))
  180. return;
  181. qc = ieee80211_get_qos_ctl(hdr);
  182. if ((is_unicast_ether_addr(hdr->addr1) &&
  183. pm == NL80211_MESH_POWER_DEEP_SLEEP) ||
  184. (is_multicast_ether_addr(hdr->addr1) &&
  185. sdata->u.mesh.ps_peers_deep_sleep > 0))
  186. qc[1] |= (IEEE80211_QOS_CTL_MESH_PS_LEVEL >> 8);
  187. else
  188. qc[1] &= ~(IEEE80211_QOS_CTL_MESH_PS_LEVEL >> 8);
  189. }
  190. /**
  191. * ieee80211_mps_sta_status_update - update buffering status of neighbor STA
  192. *
  193. * @sta: mesh STA
  194. *
  195. * called after change of peering status or non-peer/peer-specific power mode
  196. */
  197. void ieee80211_mps_sta_status_update(struct sta_info *sta)
  198. {
  199. enum nl80211_mesh_power_mode pm;
  200. bool do_buffer;
  201. /* For non-assoc STA, prevent buffering or frame transmission */
  202. if (sta->sta_state < IEEE80211_STA_ASSOC)
  203. return;
  204. /*
  205. * use peer-specific power mode if peering is established and the
  206. * peer's power mode is known
  207. */
  208. if (sta->mesh->plink_state == NL80211_PLINK_ESTAB &&
  209. sta->mesh->peer_pm != NL80211_MESH_POWER_UNKNOWN)
  210. pm = sta->mesh->peer_pm;
  211. else
  212. pm = sta->mesh->nonpeer_pm;
  213. do_buffer = (pm != NL80211_MESH_POWER_ACTIVE);
  214. /* clear the MPSP flags for non-peers or active STA */
  215. if (sta->mesh->plink_state != NL80211_PLINK_ESTAB) {
  216. clear_sta_flag(sta, WLAN_STA_MPSP_OWNER);
  217. clear_sta_flag(sta, WLAN_STA_MPSP_RECIPIENT);
  218. } else if (!do_buffer) {
  219. clear_sta_flag(sta, WLAN_STA_MPSP_OWNER);
  220. }
  221. /* Don't let the same PS state be set twice */
  222. if (test_sta_flag(sta, WLAN_STA_PS_STA) == do_buffer)
  223. return;
  224. if (do_buffer) {
  225. set_sta_flag(sta, WLAN_STA_PS_STA);
  226. atomic_inc(&sta->sdata->u.mesh.ps.num_sta_ps);
  227. mps_dbg(sta->sdata, "start PS buffering frames towards %pM\n",
  228. sta->sta.addr);
  229. } else {
  230. ieee80211_sta_ps_deliver_wakeup(sta);
  231. }
  232. }
  233. static void mps_set_sta_peer_pm(struct sta_info *sta,
  234. struct ieee80211_hdr *hdr)
  235. {
  236. enum nl80211_mesh_power_mode pm;
  237. u8 *qc = ieee80211_get_qos_ctl(hdr);
  238. /*
  239. * Test Power Management field of frame control (PW) and
  240. * mesh power save level subfield of QoS control field (PSL)
  241. *
  242. * | PM | PSL| Mesh PM |
  243. * +----+----+---------+
  244. * | 0 |Rsrv| Active |
  245. * | 1 | 0 | Light |
  246. * | 1 | 1 | Deep |
  247. */
  248. if (ieee80211_has_pm(hdr->frame_control)) {
  249. if (qc[1] & (IEEE80211_QOS_CTL_MESH_PS_LEVEL >> 8))
  250. pm = NL80211_MESH_POWER_DEEP_SLEEP;
  251. else
  252. pm = NL80211_MESH_POWER_LIGHT_SLEEP;
  253. } else {
  254. pm = NL80211_MESH_POWER_ACTIVE;
  255. }
  256. if (sta->mesh->peer_pm == pm)
  257. return;
  258. mps_dbg(sta->sdata, "STA %pM enters mode %d\n",
  259. sta->sta.addr, pm);
  260. sta->mesh->peer_pm = pm;
  261. ieee80211_mps_sta_status_update(sta);
  262. }
  263. static void mps_set_sta_nonpeer_pm(struct sta_info *sta,
  264. struct ieee80211_hdr *hdr)
  265. {
  266. enum nl80211_mesh_power_mode pm;
  267. if (ieee80211_has_pm(hdr->frame_control))
  268. pm = NL80211_MESH_POWER_DEEP_SLEEP;
  269. else
  270. pm = NL80211_MESH_POWER_ACTIVE;
  271. if (sta->mesh->nonpeer_pm == pm)
  272. return;
  273. mps_dbg(sta->sdata, "STA %pM sets non-peer mode to %d\n",
  274. sta->sta.addr, pm);
  275. sta->mesh->nonpeer_pm = pm;
  276. ieee80211_mps_sta_status_update(sta);
  277. }
  278. /**
  279. * ieee80211_mps_rx_h_sta_process - frame receive handler for mesh powersave
  280. *
  281. * @sta: STA info that transmitted the frame
  282. * @hdr: IEEE 802.11 (QoS) Header
  283. */
  284. void ieee80211_mps_rx_h_sta_process(struct sta_info *sta,
  285. struct ieee80211_hdr *hdr)
  286. {
  287. if (is_unicast_ether_addr(hdr->addr1) &&
  288. ieee80211_is_data_qos(hdr->frame_control)) {
  289. /*
  290. * individually addressed QoS Data/Null frames contain
  291. * peer link-specific PS mode towards the local STA
  292. */
  293. mps_set_sta_peer_pm(sta, hdr);
  294. /* check for mesh Peer Service Period trigger frames */
  295. ieee80211_mpsp_trigger_process(ieee80211_get_qos_ctl(hdr),
  296. sta, false, false);
  297. } else {
  298. /*
  299. * can only determine non-peer PS mode
  300. * (see IEEE802.11-2012 8.2.4.1.7)
  301. */
  302. mps_set_sta_nonpeer_pm(sta, hdr);
  303. }
  304. }
  305. /* mesh PS frame release */
  306. static void mpsp_trigger_send(struct sta_info *sta, bool rspi, bool eosp)
  307. {
  308. struct ieee80211_sub_if_data *sdata = sta->sdata;
  309. struct sk_buff *skb;
  310. struct ieee80211_hdr *nullfunc;
  311. struct ieee80211_tx_info *info;
  312. u8 *qc;
  313. skb = mps_qos_null_get(sta);
  314. if (!skb)
  315. return;
  316. nullfunc = (struct ieee80211_hdr *) skb->data;
  317. if (!eosp)
  318. nullfunc->frame_control |=
  319. cpu_to_le16(IEEE80211_FCTL_MOREDATA);
  320. /*
  321. * | RSPI | EOSP | MPSP triggering |
  322. * +------+------+--------------------+
  323. * | 0 | 0 | local STA is owner |
  324. * | 0 | 1 | no MPSP (MPSP end) |
  325. * | 1 | 0 | both STA are owner |
  326. * | 1 | 1 | peer STA is owner | see IEEE802.11-2012 13.14.9.2
  327. */
  328. qc = ieee80211_get_qos_ctl(nullfunc);
  329. if (rspi)
  330. qc[1] |= (IEEE80211_QOS_CTL_RSPI >> 8);
  331. if (eosp)
  332. qc[0] |= IEEE80211_QOS_CTL_EOSP;
  333. info = IEEE80211_SKB_CB(skb);
  334. info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER |
  335. IEEE80211_TX_CTL_REQ_TX_STATUS;
  336. mps_dbg(sdata, "sending MPSP trigger%s%s to %pM\n",
  337. rspi ? " RSPI" : "", eosp ? " EOSP" : "", sta->sta.addr);
  338. ieee80211_tx_skb(sdata, skb);
  339. }
  340. /**
  341. * mpsp_qos_null_append - append QoS Null frame to MPSP skb queue if needed
  342. * @sta: the station to handle
  343. * @frames: the frame list to append to
  344. *
  345. * To properly end a mesh MPSP the last transmitted frame has to set the EOSP
  346. * flag in the QoS Control field. In case the current tailing frame is not a
  347. * QoS Data frame, append a QoS Null to carry the flag.
  348. */
  349. static void mpsp_qos_null_append(struct sta_info *sta,
  350. struct sk_buff_head *frames)
  351. {
  352. struct ieee80211_sub_if_data *sdata = sta->sdata;
  353. struct sk_buff *new_skb, *skb = skb_peek_tail(frames);
  354. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  355. struct ieee80211_tx_info *info;
  356. if (ieee80211_is_data_qos(hdr->frame_control))
  357. return;
  358. new_skb = mps_qos_null_get(sta);
  359. if (!new_skb)
  360. return;
  361. mps_dbg(sdata, "appending QoS Null in MPSP towards %pM\n",
  362. sta->sta.addr);
  363. /*
  364. * This frame has to be transmitted last. Assign lowest priority to
  365. * make sure it cannot pass other frames when releasing multiple ACs.
  366. */
  367. new_skb->priority = 1;
  368. skb_set_queue_mapping(new_skb, IEEE80211_AC_BK);
  369. ieee80211_set_qos_hdr(sdata, new_skb);
  370. info = IEEE80211_SKB_CB(new_skb);
  371. info->control.vif = &sdata->vif;
  372. info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING;
  373. __skb_queue_tail(frames, new_skb);
  374. }
  375. /**
  376. * mps_frame_deliver - transmit frames during mesh powersave
  377. *
  378. * @sta: STA info to transmit to
  379. * @n_frames: number of frames to transmit. -1 for all
  380. */
  381. static void mps_frame_deliver(struct sta_info *sta, int n_frames)
  382. {
  383. struct ieee80211_local *local = sta->sdata->local;
  384. int ac;
  385. struct sk_buff_head frames;
  386. struct sk_buff *skb;
  387. bool more_data = false;
  388. skb_queue_head_init(&frames);
  389. /* collect frame(s) from buffers */
  390. for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
  391. while (n_frames != 0) {
  392. skb = skb_dequeue(&sta->tx_filtered[ac]);
  393. if (!skb) {
  394. skb = skb_dequeue(
  395. &sta->ps_tx_buf[ac]);
  396. if (skb)
  397. local->total_ps_buffered--;
  398. }
  399. if (!skb)
  400. break;
  401. n_frames--;
  402. __skb_queue_tail(&frames, skb);
  403. }
  404. if (!skb_queue_empty(&sta->tx_filtered[ac]) ||
  405. !skb_queue_empty(&sta->ps_tx_buf[ac]))
  406. more_data = true;
  407. }
  408. /* nothing to send? -> EOSP */
  409. if (skb_queue_empty(&frames)) {
  410. mpsp_trigger_send(sta, false, true);
  411. return;
  412. }
  413. /* in a MPSP make sure the last skb is a QoS Data frame */
  414. if (test_sta_flag(sta, WLAN_STA_MPSP_OWNER))
  415. mpsp_qos_null_append(sta, &frames);
  416. mps_dbg(sta->sdata, "sending %d frames to PS STA %pM\n",
  417. skb_queue_len(&frames), sta->sta.addr);
  418. /* prepare collected frames for transmission */
  419. skb_queue_walk(&frames, skb) {
  420. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  421. struct ieee80211_hdr *hdr = (void *) skb->data;
  422. /*
  423. * Tell TX path to send this frame even though the
  424. * STA may still remain is PS mode after this frame
  425. * exchange.
  426. */
  427. info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
  428. if (more_data || !skb_queue_is_last(&frames, skb))
  429. hdr->frame_control |=
  430. cpu_to_le16(IEEE80211_FCTL_MOREDATA);
  431. else
  432. hdr->frame_control &=
  433. cpu_to_le16(~IEEE80211_FCTL_MOREDATA);
  434. if (skb_queue_is_last(&frames, skb) &&
  435. ieee80211_is_data_qos(hdr->frame_control)) {
  436. u8 *qoshdr = ieee80211_get_qos_ctl(hdr);
  437. /* MPSP trigger frame ends service period */
  438. *qoshdr |= IEEE80211_QOS_CTL_EOSP;
  439. info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
  440. }
  441. }
  442. ieee80211_add_pending_skbs(local, &frames);
  443. sta_info_recalc_tim(sta);
  444. }
  445. /**
  446. * ieee80211_mpsp_trigger_process - track status of mesh Peer Service Periods
  447. *
  448. * @qc: QoS Control field
  449. * @sta: peer to start a MPSP with
  450. * @tx: frame was transmitted by the local STA
  451. * @acked: frame has been transmitted successfully
  452. *
  453. * NOTE: active mode STA may only serve as MPSP owner
  454. */
  455. void ieee80211_mpsp_trigger_process(u8 *qc, struct sta_info *sta,
  456. bool tx, bool acked)
  457. {
  458. u8 rspi = qc[1] & (IEEE80211_QOS_CTL_RSPI >> 8);
  459. u8 eosp = qc[0] & IEEE80211_QOS_CTL_EOSP;
  460. if (tx) {
  461. if (rspi && acked)
  462. set_sta_flag(sta, WLAN_STA_MPSP_RECIPIENT);
  463. if (eosp)
  464. clear_sta_flag(sta, WLAN_STA_MPSP_OWNER);
  465. else if (acked &&
  466. test_sta_flag(sta, WLAN_STA_PS_STA) &&
  467. !test_and_set_sta_flag(sta, WLAN_STA_MPSP_OWNER))
  468. mps_frame_deliver(sta, -1);
  469. } else {
  470. if (eosp)
  471. clear_sta_flag(sta, WLAN_STA_MPSP_RECIPIENT);
  472. else if (sta->mesh->local_pm != NL80211_MESH_POWER_ACTIVE)
  473. set_sta_flag(sta, WLAN_STA_MPSP_RECIPIENT);
  474. if (rspi && !test_and_set_sta_flag(sta, WLAN_STA_MPSP_OWNER))
  475. mps_frame_deliver(sta, -1);
  476. }
  477. }
  478. /**
  479. * ieee80211_mps_frame_release - release frames buffered due to mesh power save
  480. *
  481. * @sta: mesh STA
  482. * @elems: IEs of beacon or probe response
  483. *
  484. * For peers if we have individually-addressed frames buffered or the peer
  485. * indicates buffered frames, send a corresponding MPSP trigger frame. Since
  486. * we do not evaluate the awake window duration, QoS Nulls are used as MPSP
  487. * trigger frames. If the neighbour STA is not a peer, only send single frames.
  488. */
  489. void ieee80211_mps_frame_release(struct sta_info *sta,
  490. struct ieee802_11_elems *elems)
  491. {
  492. int ac, buffer_local = 0;
  493. bool has_buffered = false;
  494. if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
  495. has_buffered = ieee80211_check_tim(elems->tim, elems->tim_len,
  496. sta->mesh->aid);
  497. if (has_buffered)
  498. mps_dbg(sta->sdata, "%pM indicates buffered frames\n",
  499. sta->sta.addr);
  500. /* only transmit to PS STA with announced, non-zero awake window */
  501. if (test_sta_flag(sta, WLAN_STA_PS_STA) &&
  502. (!elems->awake_window || !get_unaligned_le16(elems->awake_window)))
  503. return;
  504. if (!test_sta_flag(sta, WLAN_STA_MPSP_OWNER))
  505. for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
  506. buffer_local += skb_queue_len(&sta->ps_tx_buf[ac]) +
  507. skb_queue_len(&sta->tx_filtered[ac]);
  508. if (!has_buffered && !buffer_local)
  509. return;
  510. if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
  511. mpsp_trigger_send(sta, has_buffered, !buffer_local);
  512. else
  513. mps_frame_deliver(sta, 1);
  514. }