driver-ops.h 29 KB

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