driver-ops.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  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_MONITOR))
  137. return;
  138. if (!check_sdata_in_driver(sdata))
  139. return;
  140. trace_drv_bss_info_changed(local, sdata, info, changed);
  141. if (local->ops->bss_info_changed)
  142. local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
  143. trace_drv_return_void(local);
  144. }
  145. static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
  146. struct netdev_hw_addr_list *mc_list)
  147. {
  148. u64 ret = 0;
  149. trace_drv_prepare_multicast(local, mc_list->count);
  150. if (local->ops->prepare_multicast)
  151. ret = local->ops->prepare_multicast(&local->hw, mc_list);
  152. trace_drv_return_u64(local, ret);
  153. return ret;
  154. }
  155. static inline void drv_configure_filter(struct ieee80211_local *local,
  156. unsigned int changed_flags,
  157. unsigned int *total_flags,
  158. u64 multicast)
  159. {
  160. might_sleep();
  161. trace_drv_configure_filter(local, changed_flags, total_flags,
  162. multicast);
  163. local->ops->configure_filter(&local->hw, changed_flags, total_flags,
  164. multicast);
  165. trace_drv_return_void(local);
  166. }
  167. static inline void drv_config_iface_filter(struct ieee80211_local *local,
  168. struct ieee80211_sub_if_data *sdata,
  169. unsigned int filter_flags,
  170. unsigned int changed_flags)
  171. {
  172. might_sleep();
  173. trace_drv_config_iface_filter(local, sdata, filter_flags,
  174. changed_flags);
  175. if (local->ops->config_iface_filter)
  176. local->ops->config_iface_filter(&local->hw, &sdata->vif,
  177. filter_flags,
  178. changed_flags);
  179. trace_drv_return_void(local);
  180. }
  181. static inline int drv_set_tim(struct ieee80211_local *local,
  182. struct ieee80211_sta *sta, bool set)
  183. {
  184. int ret = 0;
  185. trace_drv_set_tim(local, sta, set);
  186. if (local->ops->set_tim)
  187. ret = local->ops->set_tim(&local->hw, sta, set);
  188. trace_drv_return_int(local, ret);
  189. return ret;
  190. }
  191. static inline int drv_set_key(struct ieee80211_local *local,
  192. enum set_key_cmd cmd,
  193. struct ieee80211_sub_if_data *sdata,
  194. struct ieee80211_sta *sta,
  195. struct ieee80211_key_conf *key)
  196. {
  197. int ret;
  198. might_sleep();
  199. sdata = get_bss_sdata(sdata);
  200. if (!check_sdata_in_driver(sdata))
  201. return -EIO;
  202. trace_drv_set_key(local, cmd, sdata, sta, key);
  203. ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
  204. trace_drv_return_int(local, ret);
  205. return ret;
  206. }
  207. static inline void drv_update_tkip_key(struct ieee80211_local *local,
  208. struct ieee80211_sub_if_data *sdata,
  209. struct ieee80211_key_conf *conf,
  210. struct sta_info *sta, u32 iv32,
  211. u16 *phase1key)
  212. {
  213. struct ieee80211_sta *ista = NULL;
  214. if (sta)
  215. ista = &sta->sta;
  216. sdata = get_bss_sdata(sdata);
  217. if (!check_sdata_in_driver(sdata))
  218. return;
  219. trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
  220. if (local->ops->update_tkip_key)
  221. local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
  222. ista, iv32, phase1key);
  223. trace_drv_return_void(local);
  224. }
  225. static inline int drv_hw_scan(struct ieee80211_local *local,
  226. struct ieee80211_sub_if_data *sdata,
  227. struct ieee80211_scan_request *req)
  228. {
  229. int ret;
  230. might_sleep();
  231. if (!check_sdata_in_driver(sdata))
  232. return -EIO;
  233. trace_drv_hw_scan(local, sdata);
  234. ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
  235. trace_drv_return_int(local, ret);
  236. return ret;
  237. }
  238. static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
  239. struct ieee80211_sub_if_data *sdata)
  240. {
  241. might_sleep();
  242. if (!check_sdata_in_driver(sdata))
  243. return;
  244. trace_drv_cancel_hw_scan(local, sdata);
  245. local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
  246. trace_drv_return_void(local);
  247. }
  248. static inline int
  249. drv_sched_scan_start(struct ieee80211_local *local,
  250. struct ieee80211_sub_if_data *sdata,
  251. struct cfg80211_sched_scan_request *req,
  252. struct ieee80211_scan_ies *ies)
  253. {
  254. int ret;
  255. might_sleep();
  256. if (!check_sdata_in_driver(sdata))
  257. return -EIO;
  258. trace_drv_sched_scan_start(local, sdata);
  259. ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
  260. req, ies);
  261. trace_drv_return_int(local, ret);
  262. return ret;
  263. }
  264. static inline int drv_sched_scan_stop(struct ieee80211_local *local,
  265. struct ieee80211_sub_if_data *sdata)
  266. {
  267. int ret;
  268. might_sleep();
  269. if (!check_sdata_in_driver(sdata))
  270. return -EIO;
  271. trace_drv_sched_scan_stop(local, sdata);
  272. ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
  273. trace_drv_return_int(local, ret);
  274. return ret;
  275. }
  276. static inline void drv_sw_scan_start(struct ieee80211_local *local,
  277. struct ieee80211_sub_if_data *sdata,
  278. const u8 *mac_addr)
  279. {
  280. might_sleep();
  281. trace_drv_sw_scan_start(local, sdata, mac_addr);
  282. if (local->ops->sw_scan_start)
  283. local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
  284. trace_drv_return_void(local);
  285. }
  286. static inline void drv_sw_scan_complete(struct ieee80211_local *local,
  287. struct ieee80211_sub_if_data *sdata)
  288. {
  289. might_sleep();
  290. trace_drv_sw_scan_complete(local, sdata);
  291. if (local->ops->sw_scan_complete)
  292. local->ops->sw_scan_complete(&local->hw, &sdata->vif);
  293. trace_drv_return_void(local);
  294. }
  295. static inline int drv_get_stats(struct ieee80211_local *local,
  296. struct ieee80211_low_level_stats *stats)
  297. {
  298. int ret = -EOPNOTSUPP;
  299. might_sleep();
  300. if (local->ops->get_stats)
  301. ret = local->ops->get_stats(&local->hw, stats);
  302. trace_drv_get_stats(local, stats, ret);
  303. return ret;
  304. }
  305. static inline void drv_get_key_seq(struct ieee80211_local *local,
  306. struct ieee80211_key *key,
  307. struct ieee80211_key_seq *seq)
  308. {
  309. if (local->ops->get_key_seq)
  310. local->ops->get_key_seq(&local->hw, &key->conf, seq);
  311. trace_drv_get_key_seq(local, &key->conf);
  312. }
  313. static inline int drv_set_frag_threshold(struct ieee80211_local *local,
  314. u32 value)
  315. {
  316. int ret = 0;
  317. might_sleep();
  318. trace_drv_set_frag_threshold(local, value);
  319. if (local->ops->set_frag_threshold)
  320. ret = local->ops->set_frag_threshold(&local->hw, value);
  321. trace_drv_return_int(local, ret);
  322. return ret;
  323. }
  324. static inline int drv_set_rts_threshold(struct ieee80211_local *local,
  325. u32 value)
  326. {
  327. int ret = 0;
  328. might_sleep();
  329. trace_drv_set_rts_threshold(local, value);
  330. if (local->ops->set_rts_threshold)
  331. ret = local->ops->set_rts_threshold(&local->hw, value);
  332. trace_drv_return_int(local, ret);
  333. return ret;
  334. }
  335. static inline int drv_set_coverage_class(struct ieee80211_local *local,
  336. s16 value)
  337. {
  338. int ret = 0;
  339. might_sleep();
  340. trace_drv_set_coverage_class(local, value);
  341. if (local->ops->set_coverage_class)
  342. local->ops->set_coverage_class(&local->hw, value);
  343. else
  344. ret = -EOPNOTSUPP;
  345. trace_drv_return_int(local, ret);
  346. return ret;
  347. }
  348. static inline void drv_sta_notify(struct ieee80211_local *local,
  349. struct ieee80211_sub_if_data *sdata,
  350. enum sta_notify_cmd cmd,
  351. struct ieee80211_sta *sta)
  352. {
  353. sdata = get_bss_sdata(sdata);
  354. if (!check_sdata_in_driver(sdata))
  355. return;
  356. trace_drv_sta_notify(local, sdata, cmd, sta);
  357. if (local->ops->sta_notify)
  358. local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
  359. trace_drv_return_void(local);
  360. }
  361. static inline int drv_sta_add(struct ieee80211_local *local,
  362. struct ieee80211_sub_if_data *sdata,
  363. struct ieee80211_sta *sta)
  364. {
  365. int ret = 0;
  366. might_sleep();
  367. sdata = get_bss_sdata(sdata);
  368. if (!check_sdata_in_driver(sdata))
  369. return -EIO;
  370. trace_drv_sta_add(local, sdata, sta);
  371. if (local->ops->sta_add)
  372. ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
  373. trace_drv_return_int(local, ret);
  374. return ret;
  375. }
  376. static inline void drv_sta_remove(struct ieee80211_local *local,
  377. struct ieee80211_sub_if_data *sdata,
  378. struct ieee80211_sta *sta)
  379. {
  380. might_sleep();
  381. sdata = get_bss_sdata(sdata);
  382. if (!check_sdata_in_driver(sdata))
  383. return;
  384. trace_drv_sta_remove(local, sdata, sta);
  385. if (local->ops->sta_remove)
  386. local->ops->sta_remove(&local->hw, &sdata->vif, sta);
  387. trace_drv_return_void(local);
  388. }
  389. #ifdef CONFIG_MAC80211_DEBUGFS
  390. static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
  391. struct ieee80211_sub_if_data *sdata,
  392. struct ieee80211_sta *sta,
  393. struct dentry *dir)
  394. {
  395. might_sleep();
  396. sdata = get_bss_sdata(sdata);
  397. if (!check_sdata_in_driver(sdata))
  398. return;
  399. if (local->ops->sta_add_debugfs)
  400. local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
  401. sta, dir);
  402. }
  403. static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
  404. struct ieee80211_sub_if_data *sdata,
  405. struct ieee80211_sta *sta,
  406. struct dentry *dir)
  407. {
  408. might_sleep();
  409. sdata = get_bss_sdata(sdata);
  410. check_sdata_in_driver(sdata);
  411. if (local->ops->sta_remove_debugfs)
  412. local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
  413. sta, dir);
  414. }
  415. #endif
  416. static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
  417. struct ieee80211_sub_if_data *sdata,
  418. struct sta_info *sta)
  419. {
  420. might_sleep();
  421. sdata = get_bss_sdata(sdata);
  422. if (!check_sdata_in_driver(sdata))
  423. return;
  424. trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
  425. if (local->ops->sta_pre_rcu_remove)
  426. local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
  427. &sta->sta);
  428. trace_drv_return_void(local);
  429. }
  430. __must_check
  431. int drv_sta_state(struct ieee80211_local *local,
  432. struct ieee80211_sub_if_data *sdata,
  433. struct sta_info *sta,
  434. enum ieee80211_sta_state old_state,
  435. enum ieee80211_sta_state new_state);
  436. void drv_sta_rc_update(struct ieee80211_local *local,
  437. struct ieee80211_sub_if_data *sdata,
  438. struct ieee80211_sta *sta, u32 changed);
  439. static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
  440. struct ieee80211_sub_if_data *sdata,
  441. struct ieee80211_sta *sta)
  442. {
  443. sdata = get_bss_sdata(sdata);
  444. if (!check_sdata_in_driver(sdata))
  445. return;
  446. trace_drv_sta_rate_tbl_update(local, sdata, sta);
  447. if (local->ops->sta_rate_tbl_update)
  448. local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
  449. trace_drv_return_void(local);
  450. }
  451. static inline void drv_sta_statistics(struct ieee80211_local *local,
  452. struct ieee80211_sub_if_data *sdata,
  453. struct ieee80211_sta *sta,
  454. struct station_info *sinfo)
  455. {
  456. sdata = get_bss_sdata(sdata);
  457. if (!check_sdata_in_driver(sdata))
  458. return;
  459. trace_drv_sta_statistics(local, sdata, sta);
  460. if (local->ops->sta_statistics)
  461. local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
  462. trace_drv_return_void(local);
  463. }
  464. int drv_conf_tx(struct ieee80211_local *local,
  465. struct ieee80211_sub_if_data *sdata, u16 ac,
  466. const struct ieee80211_tx_queue_params *params);
  467. u64 drv_get_tsf(struct ieee80211_local *local,
  468. struct ieee80211_sub_if_data *sdata);
  469. void drv_set_tsf(struct ieee80211_local *local,
  470. struct ieee80211_sub_if_data *sdata,
  471. u64 tsf);
  472. void drv_reset_tsf(struct ieee80211_local *local,
  473. struct ieee80211_sub_if_data *sdata);
  474. static inline int drv_tx_last_beacon(struct ieee80211_local *local)
  475. {
  476. int ret = 0; /* default unsupported op for less congestion */
  477. might_sleep();
  478. trace_drv_tx_last_beacon(local);
  479. if (local->ops->tx_last_beacon)
  480. ret = local->ops->tx_last_beacon(&local->hw);
  481. trace_drv_return_int(local, ret);
  482. return ret;
  483. }
  484. int drv_ampdu_action(struct ieee80211_local *local,
  485. struct ieee80211_sub_if_data *sdata,
  486. struct ieee80211_ampdu_params *params);
  487. static inline int drv_get_survey(struct ieee80211_local *local, int idx,
  488. struct survey_info *survey)
  489. {
  490. int ret = -EOPNOTSUPP;
  491. trace_drv_get_survey(local, idx, survey);
  492. if (local->ops->get_survey)
  493. ret = local->ops->get_survey(&local->hw, idx, survey);
  494. trace_drv_return_int(local, ret);
  495. return ret;
  496. }
  497. static inline void drv_rfkill_poll(struct ieee80211_local *local)
  498. {
  499. might_sleep();
  500. if (local->ops->rfkill_poll)
  501. local->ops->rfkill_poll(&local->hw);
  502. }
  503. static inline void drv_flush(struct ieee80211_local *local,
  504. struct ieee80211_sub_if_data *sdata,
  505. u32 queues, bool drop)
  506. {
  507. struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
  508. might_sleep();
  509. if (sdata && !check_sdata_in_driver(sdata))
  510. return;
  511. trace_drv_flush(local, queues, drop);
  512. if (local->ops->flush)
  513. local->ops->flush(&local->hw, vif, queues, drop);
  514. trace_drv_return_void(local);
  515. }
  516. static inline void drv_channel_switch(struct ieee80211_local *local,
  517. struct ieee80211_sub_if_data *sdata,
  518. struct ieee80211_channel_switch *ch_switch)
  519. {
  520. might_sleep();
  521. trace_drv_channel_switch(local, sdata, ch_switch);
  522. local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
  523. trace_drv_return_void(local);
  524. }
  525. static inline int drv_set_antenna(struct ieee80211_local *local,
  526. u32 tx_ant, u32 rx_ant)
  527. {
  528. int ret = -EOPNOTSUPP;
  529. might_sleep();
  530. if (local->ops->set_antenna)
  531. ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
  532. trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
  533. return ret;
  534. }
  535. static inline int drv_get_antenna(struct ieee80211_local *local,
  536. u32 *tx_ant, u32 *rx_ant)
  537. {
  538. int ret = -EOPNOTSUPP;
  539. might_sleep();
  540. if (local->ops->get_antenna)
  541. ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
  542. trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
  543. return ret;
  544. }
  545. static inline int drv_remain_on_channel(struct ieee80211_local *local,
  546. struct ieee80211_sub_if_data *sdata,
  547. struct ieee80211_channel *chan,
  548. unsigned int duration,
  549. enum ieee80211_roc_type type)
  550. {
  551. int ret;
  552. might_sleep();
  553. trace_drv_remain_on_channel(local, sdata, chan, duration, type);
  554. ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
  555. chan, duration, type);
  556. trace_drv_return_int(local, ret);
  557. return ret;
  558. }
  559. static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
  560. {
  561. int ret;
  562. might_sleep();
  563. trace_drv_cancel_remain_on_channel(local);
  564. ret = local->ops->cancel_remain_on_channel(&local->hw);
  565. trace_drv_return_int(local, ret);
  566. return ret;
  567. }
  568. static inline int drv_set_ringparam(struct ieee80211_local *local,
  569. u32 tx, u32 rx)
  570. {
  571. int ret = -ENOTSUPP;
  572. might_sleep();
  573. trace_drv_set_ringparam(local, tx, rx);
  574. if (local->ops->set_ringparam)
  575. ret = local->ops->set_ringparam(&local->hw, tx, rx);
  576. trace_drv_return_int(local, ret);
  577. return ret;
  578. }
  579. static inline void drv_get_ringparam(struct ieee80211_local *local,
  580. u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
  581. {
  582. might_sleep();
  583. trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
  584. if (local->ops->get_ringparam)
  585. local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
  586. trace_drv_return_void(local);
  587. }
  588. static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
  589. {
  590. bool ret = false;
  591. might_sleep();
  592. trace_drv_tx_frames_pending(local);
  593. if (local->ops->tx_frames_pending)
  594. ret = local->ops->tx_frames_pending(&local->hw);
  595. trace_drv_return_bool(local, ret);
  596. return ret;
  597. }
  598. static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
  599. struct ieee80211_sub_if_data *sdata,
  600. const struct cfg80211_bitrate_mask *mask)
  601. {
  602. int ret = -EOPNOTSUPP;
  603. might_sleep();
  604. if (!check_sdata_in_driver(sdata))
  605. return -EIO;
  606. trace_drv_set_bitrate_mask(local, sdata, mask);
  607. if (local->ops->set_bitrate_mask)
  608. ret = local->ops->set_bitrate_mask(&local->hw,
  609. &sdata->vif, mask);
  610. trace_drv_return_int(local, ret);
  611. return ret;
  612. }
  613. static inline void drv_set_rekey_data(struct ieee80211_local *local,
  614. struct ieee80211_sub_if_data *sdata,
  615. struct cfg80211_gtk_rekey_data *data)
  616. {
  617. if (!check_sdata_in_driver(sdata))
  618. return;
  619. trace_drv_set_rekey_data(local, sdata, data);
  620. if (local->ops->set_rekey_data)
  621. local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
  622. trace_drv_return_void(local);
  623. }
  624. static inline void drv_event_callback(struct ieee80211_local *local,
  625. struct ieee80211_sub_if_data *sdata,
  626. const struct ieee80211_event *event)
  627. {
  628. trace_drv_event_callback(local, sdata, event);
  629. if (local->ops->event_callback)
  630. local->ops->event_callback(&local->hw, &sdata->vif, event);
  631. trace_drv_return_void(local);
  632. }
  633. static inline void
  634. drv_release_buffered_frames(struct ieee80211_local *local,
  635. struct sta_info *sta, u16 tids, int num_frames,
  636. enum ieee80211_frame_release_type reason,
  637. bool more_data)
  638. {
  639. trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
  640. reason, more_data);
  641. if (local->ops->release_buffered_frames)
  642. local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
  643. num_frames, reason,
  644. more_data);
  645. trace_drv_return_void(local);
  646. }
  647. static inline void
  648. drv_allow_buffered_frames(struct ieee80211_local *local,
  649. struct sta_info *sta, u16 tids, int num_frames,
  650. enum ieee80211_frame_release_type reason,
  651. bool more_data)
  652. {
  653. trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
  654. reason, more_data);
  655. if (local->ops->allow_buffered_frames)
  656. local->ops->allow_buffered_frames(&local->hw, &sta->sta,
  657. tids, num_frames, reason,
  658. more_data);
  659. trace_drv_return_void(local);
  660. }
  661. static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
  662. struct ieee80211_sub_if_data *sdata)
  663. {
  664. might_sleep();
  665. if (!check_sdata_in_driver(sdata))
  666. return;
  667. WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  668. trace_drv_mgd_prepare_tx(local, sdata);
  669. if (local->ops->mgd_prepare_tx)
  670. local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
  671. trace_drv_return_void(local);
  672. }
  673. static inline void
  674. drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
  675. struct ieee80211_sub_if_data *sdata)
  676. {
  677. might_sleep();
  678. if (!check_sdata_in_driver(sdata))
  679. return;
  680. WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  681. trace_drv_mgd_protect_tdls_discover(local, sdata);
  682. if (local->ops->mgd_protect_tdls_discover)
  683. local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
  684. trace_drv_return_void(local);
  685. }
  686. static inline int drv_add_chanctx(struct ieee80211_local *local,
  687. struct ieee80211_chanctx *ctx)
  688. {
  689. int ret = -EOPNOTSUPP;
  690. might_sleep();
  691. trace_drv_add_chanctx(local, ctx);
  692. if (local->ops->add_chanctx)
  693. ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
  694. trace_drv_return_int(local, ret);
  695. if (!ret)
  696. ctx->driver_present = true;
  697. return ret;
  698. }
  699. static inline void drv_remove_chanctx(struct ieee80211_local *local,
  700. struct ieee80211_chanctx *ctx)
  701. {
  702. might_sleep();
  703. if (WARN_ON(!ctx->driver_present))
  704. return;
  705. trace_drv_remove_chanctx(local, ctx);
  706. if (local->ops->remove_chanctx)
  707. local->ops->remove_chanctx(&local->hw, &ctx->conf);
  708. trace_drv_return_void(local);
  709. ctx->driver_present = false;
  710. }
  711. static inline void drv_change_chanctx(struct ieee80211_local *local,
  712. struct ieee80211_chanctx *ctx,
  713. u32 changed)
  714. {
  715. might_sleep();
  716. trace_drv_change_chanctx(local, ctx, changed);
  717. if (local->ops->change_chanctx) {
  718. WARN_ON_ONCE(!ctx->driver_present);
  719. local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
  720. }
  721. trace_drv_return_void(local);
  722. }
  723. static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
  724. struct ieee80211_sub_if_data *sdata,
  725. struct ieee80211_chanctx *ctx)
  726. {
  727. int ret = 0;
  728. if (!check_sdata_in_driver(sdata))
  729. return -EIO;
  730. trace_drv_assign_vif_chanctx(local, sdata, ctx);
  731. if (local->ops->assign_vif_chanctx) {
  732. WARN_ON_ONCE(!ctx->driver_present);
  733. ret = local->ops->assign_vif_chanctx(&local->hw,
  734. &sdata->vif,
  735. &ctx->conf);
  736. }
  737. trace_drv_return_int(local, ret);
  738. return ret;
  739. }
  740. static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
  741. struct ieee80211_sub_if_data *sdata,
  742. struct ieee80211_chanctx *ctx)
  743. {
  744. might_sleep();
  745. if (!check_sdata_in_driver(sdata))
  746. return;
  747. trace_drv_unassign_vif_chanctx(local, sdata, ctx);
  748. if (local->ops->unassign_vif_chanctx) {
  749. WARN_ON_ONCE(!ctx->driver_present);
  750. local->ops->unassign_vif_chanctx(&local->hw,
  751. &sdata->vif,
  752. &ctx->conf);
  753. }
  754. trace_drv_return_void(local);
  755. }
  756. int drv_switch_vif_chanctx(struct ieee80211_local *local,
  757. struct ieee80211_vif_chanctx_switch *vifs,
  758. int n_vifs, enum ieee80211_chanctx_switch_mode mode);
  759. static inline int drv_start_ap(struct ieee80211_local *local,
  760. struct ieee80211_sub_if_data *sdata)
  761. {
  762. int ret = 0;
  763. might_sleep();
  764. if (!check_sdata_in_driver(sdata))
  765. return -EIO;
  766. trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
  767. if (local->ops->start_ap)
  768. ret = local->ops->start_ap(&local->hw, &sdata->vif);
  769. trace_drv_return_int(local, ret);
  770. return ret;
  771. }
  772. static inline void drv_stop_ap(struct ieee80211_local *local,
  773. struct ieee80211_sub_if_data *sdata)
  774. {
  775. if (!check_sdata_in_driver(sdata))
  776. return;
  777. trace_drv_stop_ap(local, sdata);
  778. if (local->ops->stop_ap)
  779. local->ops->stop_ap(&local->hw, &sdata->vif);
  780. trace_drv_return_void(local);
  781. }
  782. static inline void
  783. drv_reconfig_complete(struct ieee80211_local *local,
  784. enum ieee80211_reconfig_type reconfig_type)
  785. {
  786. might_sleep();
  787. trace_drv_reconfig_complete(local, reconfig_type);
  788. if (local->ops->reconfig_complete)
  789. local->ops->reconfig_complete(&local->hw, reconfig_type);
  790. trace_drv_return_void(local);
  791. }
  792. static inline void
  793. drv_set_default_unicast_key(struct ieee80211_local *local,
  794. struct ieee80211_sub_if_data *sdata,
  795. int key_idx)
  796. {
  797. if (!check_sdata_in_driver(sdata))
  798. return;
  799. WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
  800. trace_drv_set_default_unicast_key(local, sdata, key_idx);
  801. if (local->ops->set_default_unicast_key)
  802. local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
  803. key_idx);
  804. trace_drv_return_void(local);
  805. }
  806. #if IS_ENABLED(CONFIG_IPV6)
  807. static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
  808. struct ieee80211_sub_if_data *sdata,
  809. struct inet6_dev *idev)
  810. {
  811. trace_drv_ipv6_addr_change(local, sdata);
  812. if (local->ops->ipv6_addr_change)
  813. local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
  814. trace_drv_return_void(local);
  815. }
  816. #endif
  817. static inline void
  818. drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
  819. struct cfg80211_chan_def *chandef)
  820. {
  821. struct ieee80211_local *local = sdata->local;
  822. if (local->ops->channel_switch_beacon) {
  823. trace_drv_channel_switch_beacon(local, sdata, chandef);
  824. local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
  825. chandef);
  826. }
  827. }
  828. static inline int
  829. drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
  830. struct ieee80211_channel_switch *ch_switch)
  831. {
  832. struct ieee80211_local *local = sdata->local;
  833. int ret = 0;
  834. if (!check_sdata_in_driver(sdata))
  835. return -EIO;
  836. trace_drv_pre_channel_switch(local, sdata, ch_switch);
  837. if (local->ops->pre_channel_switch)
  838. ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
  839. ch_switch);
  840. trace_drv_return_int(local, ret);
  841. return ret;
  842. }
  843. static inline int
  844. drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
  845. {
  846. struct ieee80211_local *local = sdata->local;
  847. int ret = 0;
  848. if (!check_sdata_in_driver(sdata))
  849. return -EIO;
  850. trace_drv_post_channel_switch(local, sdata);
  851. if (local->ops->post_channel_switch)
  852. ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
  853. trace_drv_return_int(local, ret);
  854. return ret;
  855. }
  856. static inline int drv_join_ibss(struct ieee80211_local *local,
  857. struct ieee80211_sub_if_data *sdata)
  858. {
  859. int ret = 0;
  860. might_sleep();
  861. if (!check_sdata_in_driver(sdata))
  862. return -EIO;
  863. trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
  864. if (local->ops->join_ibss)
  865. ret = local->ops->join_ibss(&local->hw, &sdata->vif);
  866. trace_drv_return_int(local, ret);
  867. return ret;
  868. }
  869. static inline void drv_leave_ibss(struct ieee80211_local *local,
  870. struct ieee80211_sub_if_data *sdata)
  871. {
  872. might_sleep();
  873. if (!check_sdata_in_driver(sdata))
  874. return;
  875. trace_drv_leave_ibss(local, sdata);
  876. if (local->ops->leave_ibss)
  877. local->ops->leave_ibss(&local->hw, &sdata->vif);
  878. trace_drv_return_void(local);
  879. }
  880. static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
  881. struct ieee80211_sta *sta)
  882. {
  883. u32 ret = 0;
  884. trace_drv_get_expected_throughput(sta);
  885. if (local->ops->get_expected_throughput)
  886. ret = local->ops->get_expected_throughput(&local->hw, sta);
  887. trace_drv_return_u32(local, ret);
  888. return ret;
  889. }
  890. static inline int drv_get_txpower(struct ieee80211_local *local,
  891. struct ieee80211_sub_if_data *sdata, int *dbm)
  892. {
  893. int ret;
  894. if (!local->ops->get_txpower)
  895. return -EOPNOTSUPP;
  896. ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
  897. trace_drv_get_txpower(local, sdata, *dbm, ret);
  898. return ret;
  899. }
  900. static inline int
  901. drv_tdls_channel_switch(struct ieee80211_local *local,
  902. struct ieee80211_sub_if_data *sdata,
  903. struct ieee80211_sta *sta, u8 oper_class,
  904. struct cfg80211_chan_def *chandef,
  905. struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
  906. {
  907. int ret;
  908. might_sleep();
  909. if (!check_sdata_in_driver(sdata))
  910. return -EIO;
  911. if (!local->ops->tdls_channel_switch)
  912. return -EOPNOTSUPP;
  913. trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
  914. ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
  915. oper_class, chandef, tmpl_skb,
  916. ch_sw_tm_ie);
  917. trace_drv_return_int(local, ret);
  918. return ret;
  919. }
  920. static inline void
  921. drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
  922. struct ieee80211_sub_if_data *sdata,
  923. struct ieee80211_sta *sta)
  924. {
  925. might_sleep();
  926. if (!check_sdata_in_driver(sdata))
  927. return;
  928. if (!local->ops->tdls_cancel_channel_switch)
  929. return;
  930. trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
  931. local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
  932. trace_drv_return_void(local);
  933. }
  934. static inline void
  935. drv_tdls_recv_channel_switch(struct ieee80211_local *local,
  936. struct ieee80211_sub_if_data *sdata,
  937. struct ieee80211_tdls_ch_sw_params *params)
  938. {
  939. trace_drv_tdls_recv_channel_switch(local, sdata, params);
  940. if (local->ops->tdls_recv_channel_switch)
  941. local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
  942. params);
  943. trace_drv_return_void(local);
  944. }
  945. static inline void drv_wake_tx_queue(struct ieee80211_local *local,
  946. struct txq_info *txq)
  947. {
  948. struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
  949. if (!check_sdata_in_driver(sdata))
  950. return;
  951. trace_drv_wake_tx_queue(local, sdata, txq);
  952. local->ops->wake_tx_queue(&local->hw, &txq->txq);
  953. }
  954. #endif /* __MAC80211_DRIVER_OPS */