driver-ops.h 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Portions of this file
  4. * Copyright(c) 2016 Intel Deutschland GmbH
  5. */
  6. #ifndef __MAC80211_DRIVER_OPS
  7. #define __MAC80211_DRIVER_OPS
  8. #include <net/mac80211.h>
  9. #include "ieee80211_i.h"
  10. #include "trace.h"
  11. static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
  12. {
  13. return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
  14. "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
  15. sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
  16. }
  17. static inline struct ieee80211_sub_if_data *
  18. get_bss_sdata(struct ieee80211_sub_if_data *sdata)
  19. {
  20. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  21. sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
  22. u.ap);
  23. return sdata;
  24. }
  25. static inline void drv_tx(struct ieee80211_local *local,
  26. struct ieee80211_tx_control *control,
  27. struct sk_buff *skb)
  28. {
  29. local->ops->tx(&local->hw, control, skb);
  30. }
  31. static inline void drv_sync_rx_queues(struct ieee80211_local *local,
  32. struct sta_info *sta)
  33. {
  34. if (local->ops->sync_rx_queues) {
  35. trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
  36. local->ops->sync_rx_queues(&local->hw);
  37. trace_drv_return_void(local);
  38. }
  39. }
  40. static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
  41. u32 sset, u8 *data)
  42. {
  43. struct ieee80211_local *local = sdata->local;
  44. if (local->ops->get_et_strings) {
  45. trace_drv_get_et_strings(local, sset);
  46. local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
  47. trace_drv_return_void(local);
  48. }
  49. }
  50. static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
  51. struct ethtool_stats *stats,
  52. u64 *data)
  53. {
  54. struct ieee80211_local *local = sdata->local;
  55. if (local->ops->get_et_stats) {
  56. trace_drv_get_et_stats(local);
  57. local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
  58. trace_drv_return_void(local);
  59. }
  60. }
  61. static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
  62. int sset)
  63. {
  64. struct ieee80211_local *local = sdata->local;
  65. int rv = 0;
  66. if (local->ops->get_et_sset_count) {
  67. trace_drv_get_et_sset_count(local, sset);
  68. rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
  69. sset);
  70. trace_drv_return_int(local, rv);
  71. }
  72. return rv;
  73. }
  74. int drv_start(struct ieee80211_local *local);
  75. void drv_stop(struct ieee80211_local *local);
  76. #ifdef CONFIG_PM
  77. static inline int drv_suspend(struct ieee80211_local *local,
  78. struct cfg80211_wowlan *wowlan)
  79. {
  80. int ret;
  81. might_sleep();
  82. trace_drv_suspend(local);
  83. ret = local->ops->suspend(&local->hw, wowlan);
  84. trace_drv_return_int(local, ret);
  85. return ret;
  86. }
  87. static inline int drv_resume(struct ieee80211_local *local)
  88. {
  89. int ret;
  90. might_sleep();
  91. trace_drv_resume(local);
  92. ret = local->ops->resume(&local->hw);
  93. trace_drv_return_int(local, ret);
  94. return ret;
  95. }
  96. static inline void drv_set_wakeup(struct ieee80211_local *local,
  97. bool enabled)
  98. {
  99. might_sleep();
  100. if (!local->ops->set_wakeup)
  101. return;
  102. trace_drv_set_wakeup(local, enabled);
  103. local->ops->set_wakeup(&local->hw, enabled);
  104. trace_drv_return_void(local);
  105. }
  106. #endif
  107. int drv_add_interface(struct ieee80211_local *local,
  108. struct ieee80211_sub_if_data *sdata);
  109. int drv_change_interface(struct ieee80211_local *local,
  110. struct ieee80211_sub_if_data *sdata,
  111. enum nl80211_iftype type, bool p2p);
  112. void drv_remove_interface(struct ieee80211_local *local,
  113. struct ieee80211_sub_if_data *sdata);
  114. static inline int drv_config(struct ieee80211_local *local, u32 changed)
  115. {
  116. int ret;
  117. might_sleep();
  118. trace_drv_config(local, changed);
  119. ret = local->ops->config(&local->hw, changed);
  120. trace_drv_return_int(local, ret);
  121. return ret;
  122. }
  123. static inline void drv_bss_info_changed(struct ieee80211_local *local,
  124. struct ieee80211_sub_if_data *sdata,
  125. struct ieee80211_bss_conf *info,
  126. u32 changed)
  127. {
  128. might_sleep();
  129. if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
  130. BSS_CHANGED_BEACON_ENABLED) &&
  131. sdata->vif.type != NL80211_IFTYPE_AP &&
  132. sdata->vif.type != NL80211_IFTYPE_ADHOC &&
  133. sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
  134. sdata->vif.type != NL80211_IFTYPE_OCB))
  135. return;
  136. if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
  137. sdata->vif.type == NL80211_IFTYPE_NAN ||
  138. (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
  139. !sdata->vif.mu_mimo_owner)))
  140. return;
  141. if (!check_sdata_in_driver(sdata))
  142. return;
  143. trace_drv_bss_info_changed(local, sdata, info, changed);
  144. if (local->ops->bss_info_changed)
  145. local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
  146. trace_drv_return_void(local);
  147. }
  148. static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
  149. struct netdev_hw_addr_list *mc_list)
  150. {
  151. u64 ret = 0;
  152. trace_drv_prepare_multicast(local, mc_list->count);
  153. if (local->ops->prepare_multicast)
  154. ret = local->ops->prepare_multicast(&local->hw, mc_list);
  155. trace_drv_return_u64(local, ret);
  156. return ret;
  157. }
  158. static inline void drv_configure_filter(struct ieee80211_local *local,
  159. unsigned int changed_flags,
  160. unsigned int *total_flags,
  161. u64 multicast)
  162. {
  163. might_sleep();
  164. trace_drv_configure_filter(local, changed_flags, total_flags,
  165. multicast);
  166. local->ops->configure_filter(&local->hw, changed_flags, total_flags,
  167. multicast);
  168. trace_drv_return_void(local);
  169. }
  170. static inline void drv_config_iface_filter(struct ieee80211_local *local,
  171. struct ieee80211_sub_if_data *sdata,
  172. unsigned int filter_flags,
  173. unsigned int changed_flags)
  174. {
  175. might_sleep();
  176. trace_drv_config_iface_filter(local, sdata, filter_flags,
  177. changed_flags);
  178. if (local->ops->config_iface_filter)
  179. local->ops->config_iface_filter(&local->hw, &sdata->vif,
  180. filter_flags,
  181. changed_flags);
  182. trace_drv_return_void(local);
  183. }
  184. static inline int drv_set_tim(struct ieee80211_local *local,
  185. struct ieee80211_sta *sta, bool set)
  186. {
  187. int ret = 0;
  188. trace_drv_set_tim(local, sta, set);
  189. if (local->ops->set_tim)
  190. ret = local->ops->set_tim(&local->hw, sta, set);
  191. trace_drv_return_int(local, ret);
  192. return ret;
  193. }
  194. static inline int drv_set_key(struct ieee80211_local *local,
  195. enum set_key_cmd cmd,
  196. struct ieee80211_sub_if_data *sdata,
  197. struct ieee80211_sta *sta,
  198. struct ieee80211_key_conf *key)
  199. {
  200. int ret;
  201. might_sleep();
  202. sdata = get_bss_sdata(sdata);
  203. if (!check_sdata_in_driver(sdata))
  204. return -EIO;
  205. trace_drv_set_key(local, cmd, sdata, sta, key);
  206. ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
  207. trace_drv_return_int(local, ret);
  208. return ret;
  209. }
  210. static inline void drv_update_tkip_key(struct ieee80211_local *local,
  211. struct ieee80211_sub_if_data *sdata,
  212. struct ieee80211_key_conf *conf,
  213. struct sta_info *sta, u32 iv32,
  214. u16 *phase1key)
  215. {
  216. struct ieee80211_sta *ista = NULL;
  217. if (sta)
  218. ista = &sta->sta;
  219. sdata = get_bss_sdata(sdata);
  220. if (!check_sdata_in_driver(sdata))
  221. return;
  222. trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
  223. if (local->ops->update_tkip_key)
  224. local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
  225. ista, iv32, phase1key);
  226. trace_drv_return_void(local);
  227. }
  228. static inline int drv_hw_scan(struct ieee80211_local *local,
  229. struct ieee80211_sub_if_data *sdata,
  230. struct ieee80211_scan_request *req)
  231. {
  232. int ret;
  233. might_sleep();
  234. if (!check_sdata_in_driver(sdata))
  235. return -EIO;
  236. trace_drv_hw_scan(local, sdata);
  237. ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
  238. trace_drv_return_int(local, ret);
  239. return ret;
  240. }
  241. static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
  242. struct ieee80211_sub_if_data *sdata)
  243. {
  244. might_sleep();
  245. if (!check_sdata_in_driver(sdata))
  246. return;
  247. trace_drv_cancel_hw_scan(local, sdata);
  248. local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
  249. trace_drv_return_void(local);
  250. }
  251. static inline int
  252. drv_sched_scan_start(struct ieee80211_local *local,
  253. struct ieee80211_sub_if_data *sdata,
  254. struct cfg80211_sched_scan_request *req,
  255. struct ieee80211_scan_ies *ies)
  256. {
  257. int ret;
  258. might_sleep();
  259. if (!check_sdata_in_driver(sdata))
  260. return -EIO;
  261. trace_drv_sched_scan_start(local, sdata);
  262. ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
  263. req, ies);
  264. trace_drv_return_int(local, ret);
  265. return ret;
  266. }
  267. static inline int drv_sched_scan_stop(struct ieee80211_local *local,
  268. struct ieee80211_sub_if_data *sdata)
  269. {
  270. int ret;
  271. might_sleep();
  272. if (!check_sdata_in_driver(sdata))
  273. return -EIO;
  274. trace_drv_sched_scan_stop(local, sdata);
  275. ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
  276. trace_drv_return_int(local, ret);
  277. return ret;
  278. }
  279. static inline void drv_sw_scan_start(struct ieee80211_local *local,
  280. struct ieee80211_sub_if_data *sdata,
  281. const u8 *mac_addr)
  282. {
  283. might_sleep();
  284. trace_drv_sw_scan_start(local, sdata, mac_addr);
  285. if (local->ops->sw_scan_start)
  286. local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
  287. trace_drv_return_void(local);
  288. }
  289. static inline void drv_sw_scan_complete(struct ieee80211_local *local,
  290. struct ieee80211_sub_if_data *sdata)
  291. {
  292. might_sleep();
  293. trace_drv_sw_scan_complete(local, sdata);
  294. if (local->ops->sw_scan_complete)
  295. local->ops->sw_scan_complete(&local->hw, &sdata->vif);
  296. trace_drv_return_void(local);
  297. }
  298. static inline int drv_get_stats(struct ieee80211_local *local,
  299. struct ieee80211_low_level_stats *stats)
  300. {
  301. int ret = -EOPNOTSUPP;
  302. might_sleep();
  303. if (local->ops->get_stats)
  304. ret = local->ops->get_stats(&local->hw, stats);
  305. trace_drv_get_stats(local, stats, ret);
  306. return ret;
  307. }
  308. static inline void drv_get_key_seq(struct ieee80211_local *local,
  309. struct ieee80211_key *key,
  310. struct ieee80211_key_seq *seq)
  311. {
  312. if (local->ops->get_key_seq)
  313. local->ops->get_key_seq(&local->hw, &key->conf, seq);
  314. trace_drv_get_key_seq(local, &key->conf);
  315. }
  316. static inline int drv_set_frag_threshold(struct ieee80211_local *local,
  317. u32 value)
  318. {
  319. int ret = 0;
  320. might_sleep();
  321. trace_drv_set_frag_threshold(local, value);
  322. if (local->ops->set_frag_threshold)
  323. ret = local->ops->set_frag_threshold(&local->hw, value);
  324. trace_drv_return_int(local, ret);
  325. return ret;
  326. }
  327. static inline int drv_set_rts_threshold(struct ieee80211_local *local,
  328. u32 value)
  329. {
  330. int ret = 0;
  331. might_sleep();
  332. trace_drv_set_rts_threshold(local, value);
  333. if (local->ops->set_rts_threshold)
  334. ret = local->ops->set_rts_threshold(&local->hw, value);
  335. trace_drv_return_int(local, ret);
  336. return ret;
  337. }
  338. static inline int drv_set_coverage_class(struct ieee80211_local *local,
  339. s16 value)
  340. {
  341. int ret = 0;
  342. might_sleep();
  343. trace_drv_set_coverage_class(local, value);
  344. if (local->ops->set_coverage_class)
  345. local->ops->set_coverage_class(&local->hw, value);
  346. else
  347. ret = -EOPNOTSUPP;
  348. trace_drv_return_int(local, ret);
  349. return ret;
  350. }
  351. static inline void drv_sta_notify(struct ieee80211_local *local,
  352. struct ieee80211_sub_if_data *sdata,
  353. enum sta_notify_cmd cmd,
  354. struct ieee80211_sta *sta)
  355. {
  356. sdata = get_bss_sdata(sdata);
  357. if (!check_sdata_in_driver(sdata))
  358. return;
  359. trace_drv_sta_notify(local, sdata, cmd, sta);
  360. if (local->ops->sta_notify)
  361. local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
  362. trace_drv_return_void(local);
  363. }
  364. static inline int drv_sta_add(struct ieee80211_local *local,
  365. struct ieee80211_sub_if_data *sdata,
  366. struct ieee80211_sta *sta)
  367. {
  368. int ret = 0;
  369. might_sleep();
  370. sdata = get_bss_sdata(sdata);
  371. if (!check_sdata_in_driver(sdata))
  372. return -EIO;
  373. trace_drv_sta_add(local, sdata, sta);
  374. if (local->ops->sta_add)
  375. ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
  376. trace_drv_return_int(local, ret);
  377. return ret;
  378. }
  379. static inline void drv_sta_remove(struct ieee80211_local *local,
  380. struct ieee80211_sub_if_data *sdata,
  381. struct ieee80211_sta *sta)
  382. {
  383. might_sleep();
  384. sdata = get_bss_sdata(sdata);
  385. if (!check_sdata_in_driver(sdata))
  386. return;
  387. trace_drv_sta_remove(local, sdata, sta);
  388. if (local->ops->sta_remove)
  389. local->ops->sta_remove(&local->hw, &sdata->vif, sta);
  390. trace_drv_return_void(local);
  391. }
  392. #ifdef CONFIG_MAC80211_DEBUGFS
  393. static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
  394. struct ieee80211_sub_if_data *sdata,
  395. struct ieee80211_sta *sta,
  396. struct dentry *dir)
  397. {
  398. might_sleep();
  399. sdata = get_bss_sdata(sdata);
  400. if (!check_sdata_in_driver(sdata))
  401. return;
  402. if (local->ops->sta_add_debugfs)
  403. local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
  404. sta, dir);
  405. }
  406. #endif
  407. static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
  408. struct ieee80211_sub_if_data *sdata,
  409. struct sta_info *sta)
  410. {
  411. might_sleep();
  412. sdata = get_bss_sdata(sdata);
  413. if (!check_sdata_in_driver(sdata))
  414. return;
  415. trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
  416. if (local->ops->sta_pre_rcu_remove)
  417. local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
  418. &sta->sta);
  419. trace_drv_return_void(local);
  420. }
  421. __must_check
  422. int drv_sta_state(struct ieee80211_local *local,
  423. struct ieee80211_sub_if_data *sdata,
  424. struct sta_info *sta,
  425. enum ieee80211_sta_state old_state,
  426. enum ieee80211_sta_state new_state);
  427. void drv_sta_rc_update(struct ieee80211_local *local,
  428. struct ieee80211_sub_if_data *sdata,
  429. struct ieee80211_sta *sta, u32 changed);
  430. static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
  431. struct ieee80211_sub_if_data *sdata,
  432. struct ieee80211_sta *sta)
  433. {
  434. sdata = get_bss_sdata(sdata);
  435. if (!check_sdata_in_driver(sdata))
  436. return;
  437. trace_drv_sta_rate_tbl_update(local, sdata, sta);
  438. if (local->ops->sta_rate_tbl_update)
  439. local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
  440. trace_drv_return_void(local);
  441. }
  442. static inline void drv_sta_statistics(struct ieee80211_local *local,
  443. struct ieee80211_sub_if_data *sdata,
  444. struct ieee80211_sta *sta,
  445. struct station_info *sinfo)
  446. {
  447. sdata = get_bss_sdata(sdata);
  448. if (!check_sdata_in_driver(sdata))
  449. return;
  450. trace_drv_sta_statistics(local, sdata, sta);
  451. if (local->ops->sta_statistics)
  452. local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
  453. trace_drv_return_void(local);
  454. }
  455. int drv_conf_tx(struct ieee80211_local *local,
  456. struct ieee80211_sub_if_data *sdata, u16 ac,
  457. const struct ieee80211_tx_queue_params *params);
  458. u64 drv_get_tsf(struct ieee80211_local *local,
  459. struct ieee80211_sub_if_data *sdata);
  460. void drv_set_tsf(struct ieee80211_local *local,
  461. struct ieee80211_sub_if_data *sdata,
  462. u64 tsf);
  463. void drv_offset_tsf(struct ieee80211_local *local,
  464. struct ieee80211_sub_if_data *sdata,
  465. s64 offset);
  466. void drv_reset_tsf(struct ieee80211_local *local,
  467. struct ieee80211_sub_if_data *sdata);
  468. static inline int drv_tx_last_beacon(struct ieee80211_local *local)
  469. {
  470. int ret = 0; /* default unsupported op for less congestion */
  471. might_sleep();
  472. trace_drv_tx_last_beacon(local);
  473. if (local->ops->tx_last_beacon)
  474. ret = local->ops->tx_last_beacon(&local->hw);
  475. trace_drv_return_int(local, ret);
  476. return ret;
  477. }
  478. int drv_ampdu_action(struct ieee80211_local *local,
  479. struct ieee80211_sub_if_data *sdata,
  480. struct ieee80211_ampdu_params *params);
  481. static inline int drv_get_survey(struct ieee80211_local *local, int idx,
  482. struct survey_info *survey)
  483. {
  484. int ret = -EOPNOTSUPP;
  485. trace_drv_get_survey(local, idx, survey);
  486. if (local->ops->get_survey)
  487. ret = local->ops->get_survey(&local->hw, idx, survey);
  488. trace_drv_return_int(local, ret);
  489. return ret;
  490. }
  491. static inline void drv_rfkill_poll(struct ieee80211_local *local)
  492. {
  493. might_sleep();
  494. if (local->ops->rfkill_poll)
  495. local->ops->rfkill_poll(&local->hw);
  496. }
  497. static inline void drv_flush(struct ieee80211_local *local,
  498. struct ieee80211_sub_if_data *sdata,
  499. u32 queues, bool drop)
  500. {
  501. struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
  502. might_sleep();
  503. if (sdata && !check_sdata_in_driver(sdata))
  504. return;
  505. trace_drv_flush(local, queues, drop);
  506. if (local->ops->flush)
  507. local->ops->flush(&local->hw, vif, queues, drop);
  508. trace_drv_return_void(local);
  509. }
  510. static inline void drv_channel_switch(struct ieee80211_local *local,
  511. struct ieee80211_sub_if_data *sdata,
  512. struct ieee80211_channel_switch *ch_switch)
  513. {
  514. might_sleep();
  515. trace_drv_channel_switch(local, sdata, ch_switch);
  516. local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
  517. trace_drv_return_void(local);
  518. }
  519. static inline int drv_set_antenna(struct ieee80211_local *local,
  520. u32 tx_ant, u32 rx_ant)
  521. {
  522. int ret = -EOPNOTSUPP;
  523. might_sleep();
  524. if (local->ops->set_antenna)
  525. ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
  526. trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
  527. return ret;
  528. }
  529. static inline int drv_get_antenna(struct ieee80211_local *local,
  530. u32 *tx_ant, u32 *rx_ant)
  531. {
  532. int ret = -EOPNOTSUPP;
  533. might_sleep();
  534. if (local->ops->get_antenna)
  535. ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
  536. trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
  537. return ret;
  538. }
  539. static inline int drv_remain_on_channel(struct ieee80211_local *local,
  540. struct ieee80211_sub_if_data *sdata,
  541. struct ieee80211_channel *chan,
  542. unsigned int duration,
  543. enum ieee80211_roc_type type)
  544. {
  545. int ret;
  546. might_sleep();
  547. trace_drv_remain_on_channel(local, sdata, chan, duration, type);
  548. ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
  549. chan, duration, type);
  550. trace_drv_return_int(local, ret);
  551. return ret;
  552. }
  553. static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
  554. {
  555. int ret;
  556. might_sleep();
  557. trace_drv_cancel_remain_on_channel(local);
  558. ret = local->ops->cancel_remain_on_channel(&local->hw);
  559. trace_drv_return_int(local, ret);
  560. return ret;
  561. }
  562. static inline int drv_set_ringparam(struct ieee80211_local *local,
  563. u32 tx, u32 rx)
  564. {
  565. int ret = -ENOTSUPP;
  566. might_sleep();
  567. trace_drv_set_ringparam(local, tx, rx);
  568. if (local->ops->set_ringparam)
  569. ret = local->ops->set_ringparam(&local->hw, tx, rx);
  570. trace_drv_return_int(local, ret);
  571. return ret;
  572. }
  573. static inline void drv_get_ringparam(struct ieee80211_local *local,
  574. u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
  575. {
  576. might_sleep();
  577. trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
  578. if (local->ops->get_ringparam)
  579. local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
  580. trace_drv_return_void(local);
  581. }
  582. static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
  583. {
  584. bool ret = false;
  585. might_sleep();
  586. trace_drv_tx_frames_pending(local);
  587. if (local->ops->tx_frames_pending)
  588. ret = local->ops->tx_frames_pending(&local->hw);
  589. trace_drv_return_bool(local, ret);
  590. return ret;
  591. }
  592. static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
  593. struct ieee80211_sub_if_data *sdata,
  594. const struct cfg80211_bitrate_mask *mask)
  595. {
  596. int ret = -EOPNOTSUPP;
  597. might_sleep();
  598. if (!check_sdata_in_driver(sdata))
  599. return -EIO;
  600. trace_drv_set_bitrate_mask(local, sdata, mask);
  601. if (local->ops->set_bitrate_mask)
  602. ret = local->ops->set_bitrate_mask(&local->hw,
  603. &sdata->vif, mask);
  604. trace_drv_return_int(local, ret);
  605. return ret;
  606. }
  607. static inline void drv_set_rekey_data(struct ieee80211_local *local,
  608. struct ieee80211_sub_if_data *sdata,
  609. struct cfg80211_gtk_rekey_data *data)
  610. {
  611. if (!check_sdata_in_driver(sdata))
  612. return;
  613. trace_drv_set_rekey_data(local, sdata, data);
  614. if (local->ops->set_rekey_data)
  615. local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
  616. trace_drv_return_void(local);
  617. }
  618. static inline void drv_event_callback(struct ieee80211_local *local,
  619. struct ieee80211_sub_if_data *sdata,
  620. const struct ieee80211_event *event)
  621. {
  622. trace_drv_event_callback(local, sdata, event);
  623. if (local->ops->event_callback)
  624. local->ops->event_callback(&local->hw, &sdata->vif, event);
  625. trace_drv_return_void(local);
  626. }
  627. static inline void
  628. drv_release_buffered_frames(struct ieee80211_local *local,
  629. struct sta_info *sta, u16 tids, int num_frames,
  630. enum ieee80211_frame_release_type reason,
  631. bool more_data)
  632. {
  633. trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
  634. reason, more_data);
  635. if (local->ops->release_buffered_frames)
  636. local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
  637. num_frames, reason,
  638. more_data);
  639. trace_drv_return_void(local);
  640. }
  641. static inline void
  642. drv_allow_buffered_frames(struct ieee80211_local *local,
  643. struct sta_info *sta, u16 tids, int num_frames,
  644. enum ieee80211_frame_release_type reason,
  645. bool more_data)
  646. {
  647. trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
  648. reason, more_data);
  649. if (local->ops->allow_buffered_frames)
  650. local->ops->allow_buffered_frames(&local->hw, &sta->sta,
  651. tids, num_frames, reason,
  652. more_data);
  653. trace_drv_return_void(local);
  654. }
  655. static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
  656. struct ieee80211_sub_if_data *sdata)
  657. {
  658. might_sleep();
  659. if (!check_sdata_in_driver(sdata))
  660. return;
  661. WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  662. trace_drv_mgd_prepare_tx(local, sdata);
  663. if (local->ops->mgd_prepare_tx)
  664. local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
  665. trace_drv_return_void(local);
  666. }
  667. static inline void
  668. drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
  669. struct ieee80211_sub_if_data *sdata)
  670. {
  671. might_sleep();
  672. if (!check_sdata_in_driver(sdata))
  673. return;
  674. WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  675. trace_drv_mgd_protect_tdls_discover(local, sdata);
  676. if (local->ops->mgd_protect_tdls_discover)
  677. local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
  678. trace_drv_return_void(local);
  679. }
  680. static inline int drv_add_chanctx(struct ieee80211_local *local,
  681. struct ieee80211_chanctx *ctx)
  682. {
  683. int ret = -EOPNOTSUPP;
  684. might_sleep();
  685. trace_drv_add_chanctx(local, ctx);
  686. if (local->ops->add_chanctx)
  687. ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
  688. trace_drv_return_int(local, ret);
  689. if (!ret)
  690. ctx->driver_present = true;
  691. return ret;
  692. }
  693. static inline void drv_remove_chanctx(struct ieee80211_local *local,
  694. struct ieee80211_chanctx *ctx)
  695. {
  696. might_sleep();
  697. if (WARN_ON(!ctx->driver_present))
  698. return;
  699. trace_drv_remove_chanctx(local, ctx);
  700. if (local->ops->remove_chanctx)
  701. local->ops->remove_chanctx(&local->hw, &ctx->conf);
  702. trace_drv_return_void(local);
  703. ctx->driver_present = false;
  704. }
  705. static inline void drv_change_chanctx(struct ieee80211_local *local,
  706. struct ieee80211_chanctx *ctx,
  707. u32 changed)
  708. {
  709. might_sleep();
  710. trace_drv_change_chanctx(local, ctx, changed);
  711. if (local->ops->change_chanctx) {
  712. WARN_ON_ONCE(!ctx->driver_present);
  713. local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
  714. }
  715. trace_drv_return_void(local);
  716. }
  717. static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
  718. struct ieee80211_sub_if_data *sdata,
  719. struct ieee80211_chanctx *ctx)
  720. {
  721. int ret = 0;
  722. if (!check_sdata_in_driver(sdata))
  723. return -EIO;
  724. trace_drv_assign_vif_chanctx(local, sdata, ctx);
  725. if (local->ops->assign_vif_chanctx) {
  726. WARN_ON_ONCE(!ctx->driver_present);
  727. ret = local->ops->assign_vif_chanctx(&local->hw,
  728. &sdata->vif,
  729. &ctx->conf);
  730. }
  731. trace_drv_return_int(local, ret);
  732. return ret;
  733. }
  734. static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
  735. struct ieee80211_sub_if_data *sdata,
  736. struct ieee80211_chanctx *ctx)
  737. {
  738. might_sleep();
  739. if (!check_sdata_in_driver(sdata))
  740. return;
  741. trace_drv_unassign_vif_chanctx(local, sdata, ctx);
  742. if (local->ops->unassign_vif_chanctx) {
  743. WARN_ON_ONCE(!ctx->driver_present);
  744. local->ops->unassign_vif_chanctx(&local->hw,
  745. &sdata->vif,
  746. &ctx->conf);
  747. }
  748. trace_drv_return_void(local);
  749. }
  750. int drv_switch_vif_chanctx(struct ieee80211_local *local,
  751. struct ieee80211_vif_chanctx_switch *vifs,
  752. int n_vifs, enum ieee80211_chanctx_switch_mode mode);
  753. static inline int drv_start_ap(struct ieee80211_local *local,
  754. struct ieee80211_sub_if_data *sdata)
  755. {
  756. int ret = 0;
  757. might_sleep();
  758. if (!check_sdata_in_driver(sdata))
  759. return -EIO;
  760. trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
  761. if (local->ops->start_ap)
  762. ret = local->ops->start_ap(&local->hw, &sdata->vif);
  763. trace_drv_return_int(local, ret);
  764. return ret;
  765. }
  766. static inline void drv_stop_ap(struct ieee80211_local *local,
  767. struct ieee80211_sub_if_data *sdata)
  768. {
  769. if (!check_sdata_in_driver(sdata))
  770. return;
  771. trace_drv_stop_ap(local, sdata);
  772. if (local->ops->stop_ap)
  773. local->ops->stop_ap(&local->hw, &sdata->vif);
  774. trace_drv_return_void(local);
  775. }
  776. static inline void
  777. drv_reconfig_complete(struct ieee80211_local *local,
  778. enum ieee80211_reconfig_type reconfig_type)
  779. {
  780. might_sleep();
  781. trace_drv_reconfig_complete(local, reconfig_type);
  782. if (local->ops->reconfig_complete)
  783. local->ops->reconfig_complete(&local->hw, reconfig_type);
  784. trace_drv_return_void(local);
  785. }
  786. static inline void
  787. drv_set_default_unicast_key(struct ieee80211_local *local,
  788. struct ieee80211_sub_if_data *sdata,
  789. int key_idx)
  790. {
  791. if (!check_sdata_in_driver(sdata))
  792. return;
  793. WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
  794. trace_drv_set_default_unicast_key(local, sdata, key_idx);
  795. if (local->ops->set_default_unicast_key)
  796. local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
  797. key_idx);
  798. trace_drv_return_void(local);
  799. }
  800. #if IS_ENABLED(CONFIG_IPV6)
  801. static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
  802. struct ieee80211_sub_if_data *sdata,
  803. struct inet6_dev *idev)
  804. {
  805. trace_drv_ipv6_addr_change(local, sdata);
  806. if (local->ops->ipv6_addr_change)
  807. local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
  808. trace_drv_return_void(local);
  809. }
  810. #endif
  811. static inline void
  812. drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
  813. struct cfg80211_chan_def *chandef)
  814. {
  815. struct ieee80211_local *local = sdata->local;
  816. if (local->ops->channel_switch_beacon) {
  817. trace_drv_channel_switch_beacon(local, sdata, chandef);
  818. local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
  819. chandef);
  820. }
  821. }
  822. static inline int
  823. drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
  824. struct ieee80211_channel_switch *ch_switch)
  825. {
  826. struct ieee80211_local *local = sdata->local;
  827. int ret = 0;
  828. if (!check_sdata_in_driver(sdata))
  829. return -EIO;
  830. trace_drv_pre_channel_switch(local, sdata, ch_switch);
  831. if (local->ops->pre_channel_switch)
  832. ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
  833. ch_switch);
  834. trace_drv_return_int(local, ret);
  835. return ret;
  836. }
  837. static inline int
  838. drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
  839. {
  840. struct ieee80211_local *local = sdata->local;
  841. int ret = 0;
  842. if (!check_sdata_in_driver(sdata))
  843. return -EIO;
  844. trace_drv_post_channel_switch(local, sdata);
  845. if (local->ops->post_channel_switch)
  846. ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
  847. trace_drv_return_int(local, ret);
  848. return ret;
  849. }
  850. static inline int drv_join_ibss(struct ieee80211_local *local,
  851. struct ieee80211_sub_if_data *sdata)
  852. {
  853. int ret = 0;
  854. might_sleep();
  855. if (!check_sdata_in_driver(sdata))
  856. return -EIO;
  857. trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
  858. if (local->ops->join_ibss)
  859. ret = local->ops->join_ibss(&local->hw, &sdata->vif);
  860. trace_drv_return_int(local, ret);
  861. return ret;
  862. }
  863. static inline void drv_leave_ibss(struct ieee80211_local *local,
  864. struct ieee80211_sub_if_data *sdata)
  865. {
  866. might_sleep();
  867. if (!check_sdata_in_driver(sdata))
  868. return;
  869. trace_drv_leave_ibss(local, sdata);
  870. if (local->ops->leave_ibss)
  871. local->ops->leave_ibss(&local->hw, &sdata->vif);
  872. trace_drv_return_void(local);
  873. }
  874. static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
  875. struct sta_info *sta)
  876. {
  877. u32 ret = 0;
  878. trace_drv_get_expected_throughput(&sta->sta);
  879. if (local->ops->get_expected_throughput && sta->uploaded)
  880. ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
  881. trace_drv_return_u32(local, ret);
  882. return ret;
  883. }
  884. static inline int drv_get_txpower(struct ieee80211_local *local,
  885. struct ieee80211_sub_if_data *sdata, int *dbm)
  886. {
  887. int ret;
  888. if (!local->ops->get_txpower)
  889. return -EOPNOTSUPP;
  890. ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
  891. trace_drv_get_txpower(local, sdata, *dbm, ret);
  892. return ret;
  893. }
  894. static inline int
  895. drv_tdls_channel_switch(struct ieee80211_local *local,
  896. struct ieee80211_sub_if_data *sdata,
  897. struct ieee80211_sta *sta, u8 oper_class,
  898. struct cfg80211_chan_def *chandef,
  899. struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
  900. {
  901. int ret;
  902. might_sleep();
  903. if (!check_sdata_in_driver(sdata))
  904. return -EIO;
  905. if (!local->ops->tdls_channel_switch)
  906. return -EOPNOTSUPP;
  907. trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
  908. ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
  909. oper_class, chandef, tmpl_skb,
  910. ch_sw_tm_ie);
  911. trace_drv_return_int(local, ret);
  912. return ret;
  913. }
  914. static inline void
  915. drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
  916. struct ieee80211_sub_if_data *sdata,
  917. struct ieee80211_sta *sta)
  918. {
  919. might_sleep();
  920. if (!check_sdata_in_driver(sdata))
  921. return;
  922. if (!local->ops->tdls_cancel_channel_switch)
  923. return;
  924. trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
  925. local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
  926. trace_drv_return_void(local);
  927. }
  928. static inline void
  929. drv_tdls_recv_channel_switch(struct ieee80211_local *local,
  930. struct ieee80211_sub_if_data *sdata,
  931. struct ieee80211_tdls_ch_sw_params *params)
  932. {
  933. trace_drv_tdls_recv_channel_switch(local, sdata, params);
  934. if (local->ops->tdls_recv_channel_switch)
  935. local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
  936. params);
  937. trace_drv_return_void(local);
  938. }
  939. static inline void drv_wake_tx_queue(struct ieee80211_local *local,
  940. struct txq_info *txq)
  941. {
  942. struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
  943. if (!check_sdata_in_driver(sdata))
  944. return;
  945. trace_drv_wake_tx_queue(local, sdata, txq);
  946. local->ops->wake_tx_queue(&local->hw, &txq->txq);
  947. }
  948. static inline int drv_start_nan(struct ieee80211_local *local,
  949. struct ieee80211_sub_if_data *sdata,
  950. struct cfg80211_nan_conf *conf)
  951. {
  952. int ret;
  953. might_sleep();
  954. check_sdata_in_driver(sdata);
  955. trace_drv_start_nan(local, sdata, conf);
  956. ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
  957. trace_drv_return_int(local, ret);
  958. return ret;
  959. }
  960. static inline void drv_stop_nan(struct ieee80211_local *local,
  961. struct ieee80211_sub_if_data *sdata)
  962. {
  963. might_sleep();
  964. check_sdata_in_driver(sdata);
  965. trace_drv_stop_nan(local, sdata);
  966. local->ops->stop_nan(&local->hw, &sdata->vif);
  967. trace_drv_return_void(local);
  968. }
  969. static inline int drv_nan_change_conf(struct ieee80211_local *local,
  970. struct ieee80211_sub_if_data *sdata,
  971. struct cfg80211_nan_conf *conf,
  972. u32 changes)
  973. {
  974. int ret;
  975. might_sleep();
  976. check_sdata_in_driver(sdata);
  977. if (!local->ops->nan_change_conf)
  978. return -EOPNOTSUPP;
  979. trace_drv_nan_change_conf(local, sdata, conf, changes);
  980. ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
  981. changes);
  982. trace_drv_return_int(local, ret);
  983. return ret;
  984. }
  985. static inline int drv_add_nan_func(struct ieee80211_local *local,
  986. struct ieee80211_sub_if_data *sdata,
  987. const struct cfg80211_nan_func *nan_func)
  988. {
  989. int ret;
  990. might_sleep();
  991. check_sdata_in_driver(sdata);
  992. if (!local->ops->add_nan_func)
  993. return -EOPNOTSUPP;
  994. trace_drv_add_nan_func(local, sdata, nan_func);
  995. ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
  996. trace_drv_return_int(local, ret);
  997. return ret;
  998. }
  999. static inline void drv_del_nan_func(struct ieee80211_local *local,
  1000. struct ieee80211_sub_if_data *sdata,
  1001. u8 instance_id)
  1002. {
  1003. might_sleep();
  1004. check_sdata_in_driver(sdata);
  1005. trace_drv_del_nan_func(local, sdata, instance_id);
  1006. if (local->ops->del_nan_func)
  1007. local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
  1008. trace_drv_return_void(local);
  1009. }
  1010. #endif /* __MAC80211_DRIVER_OPS */