driver-ops.h 31 KB

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