driver-ops.h 36 KB

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