driver-ops.h 32 KB

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