driver-ops.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482
  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, 2021 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_vif_cfg_changed(struct ieee80211_local *local,
  124. struct ieee80211_sub_if_data *sdata,
  125. u64 changed)
  126. {
  127. might_sleep();
  128. if (!check_sdata_in_driver(sdata))
  129. return;
  130. trace_drv_vif_cfg_changed(local, sdata, changed);
  131. if (local->ops->vif_cfg_changed)
  132. local->ops->vif_cfg_changed(&local->hw, &sdata->vif, changed);
  133. else if (local->ops->bss_info_changed)
  134. local->ops->bss_info_changed(&local->hw, &sdata->vif,
  135. &sdata->vif.bss_conf, changed);
  136. trace_drv_return_void(local);
  137. }
  138. void drv_link_info_changed(struct ieee80211_local *local,
  139. struct ieee80211_sub_if_data *sdata,
  140. struct ieee80211_bss_conf *info,
  141. int link_id, u64 changed);
  142. static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
  143. struct netdev_hw_addr_list *mc_list)
  144. {
  145. u64 ret = 0;
  146. trace_drv_prepare_multicast(local, mc_list->count);
  147. if (local->ops->prepare_multicast)
  148. ret = local->ops->prepare_multicast(&local->hw, mc_list);
  149. trace_drv_return_u64(local, ret);
  150. return ret;
  151. }
  152. static inline void drv_configure_filter(struct ieee80211_local *local,
  153. unsigned int changed_flags,
  154. unsigned int *total_flags,
  155. u64 multicast)
  156. {
  157. might_sleep();
  158. trace_drv_configure_filter(local, changed_flags, total_flags,
  159. multicast);
  160. local->ops->configure_filter(&local->hw, changed_flags, total_flags,
  161. multicast);
  162. trace_drv_return_void(local);
  163. }
  164. static inline void drv_config_iface_filter(struct ieee80211_local *local,
  165. struct ieee80211_sub_if_data *sdata,
  166. unsigned int filter_flags,
  167. unsigned int changed_flags)
  168. {
  169. might_sleep();
  170. trace_drv_config_iface_filter(local, sdata, filter_flags,
  171. changed_flags);
  172. if (local->ops->config_iface_filter)
  173. local->ops->config_iface_filter(&local->hw, &sdata->vif,
  174. filter_flags,
  175. changed_flags);
  176. trace_drv_return_void(local);
  177. }
  178. static inline int drv_set_tim(struct ieee80211_local *local,
  179. struct ieee80211_sta *sta, bool set)
  180. {
  181. int ret = 0;
  182. trace_drv_set_tim(local, sta, set);
  183. if (local->ops->set_tim)
  184. ret = local->ops->set_tim(&local->hw, sta, set);
  185. trace_drv_return_int(local, ret);
  186. return ret;
  187. }
  188. int drv_set_key(struct ieee80211_local *local,
  189. enum set_key_cmd cmd,
  190. struct ieee80211_sub_if_data *sdata,
  191. struct ieee80211_sta *sta,
  192. struct ieee80211_key_conf *key);
  193. static inline void drv_update_tkip_key(struct ieee80211_local *local,
  194. struct ieee80211_sub_if_data *sdata,
  195. struct ieee80211_key_conf *conf,
  196. struct sta_info *sta, u32 iv32,
  197. u16 *phase1key)
  198. {
  199. struct ieee80211_sta *ista = NULL;
  200. if (sta)
  201. ista = &sta->sta;
  202. sdata = get_bss_sdata(sdata);
  203. if (!check_sdata_in_driver(sdata))
  204. return;
  205. trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
  206. if (local->ops->update_tkip_key)
  207. local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
  208. ista, iv32, phase1key);
  209. trace_drv_return_void(local);
  210. }
  211. static inline int drv_hw_scan(struct ieee80211_local *local,
  212. struct ieee80211_sub_if_data *sdata,
  213. struct ieee80211_scan_request *req)
  214. {
  215. int ret;
  216. might_sleep();
  217. if (!check_sdata_in_driver(sdata))
  218. return -EIO;
  219. trace_drv_hw_scan(local, sdata);
  220. ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
  221. trace_drv_return_int(local, ret);
  222. return ret;
  223. }
  224. static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
  225. struct ieee80211_sub_if_data *sdata)
  226. {
  227. might_sleep();
  228. if (!check_sdata_in_driver(sdata))
  229. return;
  230. trace_drv_cancel_hw_scan(local, sdata);
  231. local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
  232. trace_drv_return_void(local);
  233. }
  234. static inline int
  235. drv_sched_scan_start(struct ieee80211_local *local,
  236. struct ieee80211_sub_if_data *sdata,
  237. struct cfg80211_sched_scan_request *req,
  238. struct ieee80211_scan_ies *ies)
  239. {
  240. int ret;
  241. might_sleep();
  242. if (!check_sdata_in_driver(sdata))
  243. return -EIO;
  244. trace_drv_sched_scan_start(local, sdata);
  245. ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
  246. req, ies);
  247. trace_drv_return_int(local, ret);
  248. return ret;
  249. }
  250. static inline int drv_sched_scan_stop(struct ieee80211_local *local,
  251. struct ieee80211_sub_if_data *sdata)
  252. {
  253. int ret;
  254. might_sleep();
  255. if (!check_sdata_in_driver(sdata))
  256. return -EIO;
  257. trace_drv_sched_scan_stop(local, sdata);
  258. ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
  259. trace_drv_return_int(local, ret);
  260. return ret;
  261. }
  262. static inline void drv_sw_scan_start(struct ieee80211_local *local,
  263. struct ieee80211_sub_if_data *sdata,
  264. const u8 *mac_addr)
  265. {
  266. might_sleep();
  267. trace_drv_sw_scan_start(local, sdata, mac_addr);
  268. if (local->ops->sw_scan_start)
  269. local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
  270. trace_drv_return_void(local);
  271. }
  272. static inline void drv_sw_scan_complete(struct ieee80211_local *local,
  273. struct ieee80211_sub_if_data *sdata)
  274. {
  275. might_sleep();
  276. trace_drv_sw_scan_complete(local, sdata);
  277. if (local->ops->sw_scan_complete)
  278. local->ops->sw_scan_complete(&local->hw, &sdata->vif);
  279. trace_drv_return_void(local);
  280. }
  281. static inline int drv_get_stats(struct ieee80211_local *local,
  282. struct ieee80211_low_level_stats *stats)
  283. {
  284. int ret = -EOPNOTSUPP;
  285. might_sleep();
  286. if (local->ops->get_stats)
  287. ret = local->ops->get_stats(&local->hw, stats);
  288. trace_drv_get_stats(local, stats, ret);
  289. return ret;
  290. }
  291. static inline void drv_get_key_seq(struct ieee80211_local *local,
  292. struct ieee80211_key *key,
  293. struct ieee80211_key_seq *seq)
  294. {
  295. if (local->ops->get_key_seq)
  296. local->ops->get_key_seq(&local->hw, &key->conf, seq);
  297. trace_drv_get_key_seq(local, &key->conf);
  298. }
  299. static inline int drv_set_frag_threshold(struct ieee80211_local *local,
  300. u32 value)
  301. {
  302. int ret = 0;
  303. might_sleep();
  304. trace_drv_set_frag_threshold(local, value);
  305. if (local->ops->set_frag_threshold)
  306. ret = local->ops->set_frag_threshold(&local->hw, value);
  307. trace_drv_return_int(local, ret);
  308. return ret;
  309. }
  310. static inline int drv_set_rts_threshold(struct ieee80211_local *local,
  311. u32 value)
  312. {
  313. int ret = 0;
  314. might_sleep();
  315. trace_drv_set_rts_threshold(local, value);
  316. if (local->ops->set_rts_threshold)
  317. ret = local->ops->set_rts_threshold(&local->hw, value);
  318. trace_drv_return_int(local, ret);
  319. return ret;
  320. }
  321. static inline int drv_set_coverage_class(struct ieee80211_local *local,
  322. s16 value)
  323. {
  324. int ret = 0;
  325. might_sleep();
  326. trace_drv_set_coverage_class(local, value);
  327. if (local->ops->set_coverage_class)
  328. local->ops->set_coverage_class(&local->hw, value);
  329. else
  330. ret = -EOPNOTSUPP;
  331. trace_drv_return_int(local, ret);
  332. return ret;
  333. }
  334. static inline void drv_sta_notify(struct ieee80211_local *local,
  335. struct ieee80211_sub_if_data *sdata,
  336. enum sta_notify_cmd cmd,
  337. struct ieee80211_sta *sta)
  338. {
  339. sdata = get_bss_sdata(sdata);
  340. if (!check_sdata_in_driver(sdata))
  341. return;
  342. trace_drv_sta_notify(local, sdata, cmd, sta);
  343. if (local->ops->sta_notify)
  344. local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
  345. trace_drv_return_void(local);
  346. }
  347. static inline int drv_sta_add(struct ieee80211_local *local,
  348. struct ieee80211_sub_if_data *sdata,
  349. struct ieee80211_sta *sta)
  350. {
  351. int ret = 0;
  352. might_sleep();
  353. sdata = get_bss_sdata(sdata);
  354. if (!check_sdata_in_driver(sdata))
  355. return -EIO;
  356. trace_drv_sta_add(local, sdata, sta);
  357. if (local->ops->sta_add)
  358. ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
  359. trace_drv_return_int(local, ret);
  360. return ret;
  361. }
  362. static inline void drv_sta_remove(struct ieee80211_local *local,
  363. struct ieee80211_sub_if_data *sdata,
  364. struct ieee80211_sta *sta)
  365. {
  366. might_sleep();
  367. sdata = get_bss_sdata(sdata);
  368. if (!check_sdata_in_driver(sdata))
  369. return;
  370. trace_drv_sta_remove(local, sdata, sta);
  371. if (local->ops->sta_remove)
  372. local->ops->sta_remove(&local->hw, &sdata->vif, sta);
  373. trace_drv_return_void(local);
  374. }
  375. #ifdef CONFIG_MAC80211_DEBUGFS
  376. static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
  377. struct ieee80211_sub_if_data *sdata,
  378. struct ieee80211_sta *sta,
  379. struct dentry *dir)
  380. {
  381. might_sleep();
  382. sdata = get_bss_sdata(sdata);
  383. if (!check_sdata_in_driver(sdata))
  384. return;
  385. if (local->ops->sta_add_debugfs)
  386. local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
  387. sta, dir);
  388. }
  389. #endif
  390. static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
  391. struct ieee80211_sub_if_data *sdata,
  392. struct sta_info *sta)
  393. {
  394. might_sleep();
  395. sdata = get_bss_sdata(sdata);
  396. if (!check_sdata_in_driver(sdata))
  397. return;
  398. trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
  399. if (local->ops->sta_pre_rcu_remove)
  400. local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
  401. &sta->sta);
  402. trace_drv_return_void(local);
  403. }
  404. __must_check
  405. int drv_sta_state(struct ieee80211_local *local,
  406. struct ieee80211_sub_if_data *sdata,
  407. struct sta_info *sta,
  408. enum ieee80211_sta_state old_state,
  409. enum ieee80211_sta_state new_state);
  410. __must_check
  411. int drv_sta_set_txpwr(struct ieee80211_local *local,
  412. struct ieee80211_sub_if_data *sdata,
  413. struct sta_info *sta);
  414. void drv_sta_rc_update(struct ieee80211_local *local,
  415. struct ieee80211_sub_if_data *sdata,
  416. struct ieee80211_sta *sta, u32 changed);
  417. static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
  418. struct ieee80211_sub_if_data *sdata,
  419. struct ieee80211_sta *sta)
  420. {
  421. sdata = get_bss_sdata(sdata);
  422. if (!check_sdata_in_driver(sdata))
  423. return;
  424. trace_drv_sta_rate_tbl_update(local, sdata, sta);
  425. if (local->ops->sta_rate_tbl_update)
  426. local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
  427. trace_drv_return_void(local);
  428. }
  429. static inline void drv_sta_statistics(struct ieee80211_local *local,
  430. struct ieee80211_sub_if_data *sdata,
  431. struct ieee80211_sta *sta,
  432. struct station_info *sinfo)
  433. {
  434. sdata = get_bss_sdata(sdata);
  435. if (!check_sdata_in_driver(sdata))
  436. return;
  437. trace_drv_sta_statistics(local, sdata, sta);
  438. if (local->ops->sta_statistics)
  439. local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
  440. trace_drv_return_void(local);
  441. }
  442. int drv_conf_tx(struct ieee80211_local *local,
  443. struct ieee80211_link_data *link, u16 ac,
  444. const struct ieee80211_tx_queue_params *params);
  445. u64 drv_get_tsf(struct ieee80211_local *local,
  446. struct ieee80211_sub_if_data *sdata);
  447. void drv_set_tsf(struct ieee80211_local *local,
  448. struct ieee80211_sub_if_data *sdata,
  449. u64 tsf);
  450. void drv_offset_tsf(struct ieee80211_local *local,
  451. struct ieee80211_sub_if_data *sdata,
  452. s64 offset);
  453. void drv_reset_tsf(struct ieee80211_local *local,
  454. struct ieee80211_sub_if_data *sdata);
  455. static inline int drv_tx_last_beacon(struct ieee80211_local *local)
  456. {
  457. int ret = 0; /* default unsupported op for less congestion */
  458. might_sleep();
  459. trace_drv_tx_last_beacon(local);
  460. if (local->ops->tx_last_beacon)
  461. ret = local->ops->tx_last_beacon(&local->hw);
  462. trace_drv_return_int(local, ret);
  463. return ret;
  464. }
  465. int drv_ampdu_action(struct ieee80211_local *local,
  466. struct ieee80211_sub_if_data *sdata,
  467. struct ieee80211_ampdu_params *params);
  468. static inline int drv_get_survey(struct ieee80211_local *local, int idx,
  469. struct survey_info *survey)
  470. {
  471. int ret = -EOPNOTSUPP;
  472. trace_drv_get_survey(local, idx, survey);
  473. if (local->ops->get_survey)
  474. ret = local->ops->get_survey(&local->hw, idx, survey);
  475. trace_drv_return_int(local, ret);
  476. return ret;
  477. }
  478. static inline void drv_rfkill_poll(struct ieee80211_local *local)
  479. {
  480. might_sleep();
  481. if (local->ops->rfkill_poll)
  482. local->ops->rfkill_poll(&local->hw);
  483. }
  484. static inline void drv_flush(struct ieee80211_local *local,
  485. struct ieee80211_sub_if_data *sdata,
  486. u32 queues, bool drop)
  487. {
  488. struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
  489. might_sleep();
  490. if (sdata && !check_sdata_in_driver(sdata))
  491. return;
  492. trace_drv_flush(local, queues, drop);
  493. if (local->ops->flush)
  494. local->ops->flush(&local->hw, vif, queues, drop);
  495. trace_drv_return_void(local);
  496. }
  497. static inline void drv_channel_switch(struct ieee80211_local *local,
  498. struct ieee80211_sub_if_data *sdata,
  499. struct ieee80211_channel_switch *ch_switch)
  500. {
  501. might_sleep();
  502. trace_drv_channel_switch(local, sdata, ch_switch);
  503. local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
  504. trace_drv_return_void(local);
  505. }
  506. static inline int drv_set_antenna(struct ieee80211_local *local,
  507. u32 tx_ant, u32 rx_ant)
  508. {
  509. int ret = -EOPNOTSUPP;
  510. might_sleep();
  511. if (local->ops->set_antenna)
  512. ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
  513. trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
  514. return ret;
  515. }
  516. static inline int drv_get_antenna(struct ieee80211_local *local,
  517. u32 *tx_ant, u32 *rx_ant)
  518. {
  519. int ret = -EOPNOTSUPP;
  520. might_sleep();
  521. if (local->ops->get_antenna)
  522. ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
  523. trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
  524. return ret;
  525. }
  526. static inline int drv_remain_on_channel(struct ieee80211_local *local,
  527. struct ieee80211_sub_if_data *sdata,
  528. struct ieee80211_channel *chan,
  529. unsigned int duration,
  530. enum ieee80211_roc_type type)
  531. {
  532. int ret;
  533. might_sleep();
  534. trace_drv_remain_on_channel(local, sdata, chan, duration, type);
  535. ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
  536. chan, duration, type);
  537. trace_drv_return_int(local, ret);
  538. return ret;
  539. }
  540. static inline int
  541. drv_cancel_remain_on_channel(struct ieee80211_local *local,
  542. struct ieee80211_sub_if_data *sdata)
  543. {
  544. int ret;
  545. might_sleep();
  546. trace_drv_cancel_remain_on_channel(local, sdata);
  547. ret = local->ops->cancel_remain_on_channel(&local->hw, &sdata->vif);
  548. trace_drv_return_int(local, ret);
  549. return ret;
  550. }
  551. static inline int drv_set_ringparam(struct ieee80211_local *local,
  552. u32 tx, u32 rx)
  553. {
  554. int ret = -ENOTSUPP;
  555. might_sleep();
  556. trace_drv_set_ringparam(local, tx, rx);
  557. if (local->ops->set_ringparam)
  558. ret = local->ops->set_ringparam(&local->hw, tx, rx);
  559. trace_drv_return_int(local, ret);
  560. return ret;
  561. }
  562. static inline void drv_get_ringparam(struct ieee80211_local *local,
  563. u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
  564. {
  565. might_sleep();
  566. trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
  567. if (local->ops->get_ringparam)
  568. local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
  569. trace_drv_return_void(local);
  570. }
  571. static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
  572. {
  573. bool ret = false;
  574. might_sleep();
  575. trace_drv_tx_frames_pending(local);
  576. if (local->ops->tx_frames_pending)
  577. ret = local->ops->tx_frames_pending(&local->hw);
  578. trace_drv_return_bool(local, ret);
  579. return ret;
  580. }
  581. static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
  582. struct ieee80211_sub_if_data *sdata,
  583. const struct cfg80211_bitrate_mask *mask)
  584. {
  585. int ret = -EOPNOTSUPP;
  586. might_sleep();
  587. if (!check_sdata_in_driver(sdata))
  588. return -EIO;
  589. trace_drv_set_bitrate_mask(local, sdata, mask);
  590. if (local->ops->set_bitrate_mask)
  591. ret = local->ops->set_bitrate_mask(&local->hw,
  592. &sdata->vif, mask);
  593. trace_drv_return_int(local, ret);
  594. return ret;
  595. }
  596. static inline void drv_set_rekey_data(struct ieee80211_local *local,
  597. struct ieee80211_sub_if_data *sdata,
  598. struct cfg80211_gtk_rekey_data *data)
  599. {
  600. if (!check_sdata_in_driver(sdata))
  601. return;
  602. trace_drv_set_rekey_data(local, sdata, data);
  603. if (local->ops->set_rekey_data)
  604. local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
  605. trace_drv_return_void(local);
  606. }
  607. static inline void drv_event_callback(struct ieee80211_local *local,
  608. struct ieee80211_sub_if_data *sdata,
  609. const struct ieee80211_event *event)
  610. {
  611. trace_drv_event_callback(local, sdata, event);
  612. if (local->ops->event_callback)
  613. local->ops->event_callback(&local->hw, &sdata->vif, event);
  614. trace_drv_return_void(local);
  615. }
  616. static inline void
  617. drv_release_buffered_frames(struct ieee80211_local *local,
  618. struct sta_info *sta, u16 tids, int num_frames,
  619. enum ieee80211_frame_release_type reason,
  620. bool more_data)
  621. {
  622. trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
  623. reason, more_data);
  624. if (local->ops->release_buffered_frames)
  625. local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
  626. num_frames, reason,
  627. more_data);
  628. trace_drv_return_void(local);
  629. }
  630. static inline void
  631. drv_allow_buffered_frames(struct ieee80211_local *local,
  632. struct sta_info *sta, u16 tids, int num_frames,
  633. enum ieee80211_frame_release_type reason,
  634. bool more_data)
  635. {
  636. trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
  637. reason, more_data);
  638. if (local->ops->allow_buffered_frames)
  639. local->ops->allow_buffered_frames(&local->hw, &sta->sta,
  640. tids, num_frames, reason,
  641. more_data);
  642. trace_drv_return_void(local);
  643. }
  644. static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
  645. struct ieee80211_sub_if_data *sdata,
  646. struct ieee80211_prep_tx_info *info)
  647. {
  648. might_sleep();
  649. if (!check_sdata_in_driver(sdata))
  650. return;
  651. WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  652. trace_drv_mgd_prepare_tx(local, sdata, info->duration,
  653. info->subtype, info->success);
  654. if (local->ops->mgd_prepare_tx)
  655. local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, info);
  656. trace_drv_return_void(local);
  657. }
  658. static inline void drv_mgd_complete_tx(struct ieee80211_local *local,
  659. struct ieee80211_sub_if_data *sdata,
  660. struct ieee80211_prep_tx_info *info)
  661. {
  662. might_sleep();
  663. if (!check_sdata_in_driver(sdata))
  664. return;
  665. WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  666. trace_drv_mgd_complete_tx(local, sdata, info->duration,
  667. info->subtype, info->success);
  668. if (local->ops->mgd_complete_tx)
  669. local->ops->mgd_complete_tx(&local->hw, &sdata->vif, info);
  670. trace_drv_return_void(local);
  671. }
  672. static inline void
  673. drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
  674. struct ieee80211_sub_if_data *sdata)
  675. {
  676. might_sleep();
  677. if (!check_sdata_in_driver(sdata))
  678. return;
  679. WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  680. trace_drv_mgd_protect_tdls_discover(local, sdata);
  681. if (local->ops->mgd_protect_tdls_discover)
  682. local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
  683. trace_drv_return_void(local);
  684. }
  685. static inline int drv_add_chanctx(struct ieee80211_local *local,
  686. struct ieee80211_chanctx *ctx)
  687. {
  688. int ret = -EOPNOTSUPP;
  689. might_sleep();
  690. trace_drv_add_chanctx(local, ctx);
  691. if (local->ops->add_chanctx)
  692. ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
  693. trace_drv_return_int(local, ret);
  694. if (!ret)
  695. ctx->driver_present = true;
  696. return ret;
  697. }
  698. static inline void drv_remove_chanctx(struct ieee80211_local *local,
  699. struct ieee80211_chanctx *ctx)
  700. {
  701. might_sleep();
  702. if (WARN_ON(!ctx->driver_present))
  703. return;
  704. trace_drv_remove_chanctx(local, ctx);
  705. if (local->ops->remove_chanctx)
  706. local->ops->remove_chanctx(&local->hw, &ctx->conf);
  707. trace_drv_return_void(local);
  708. ctx->driver_present = false;
  709. }
  710. static inline void drv_change_chanctx(struct ieee80211_local *local,
  711. struct ieee80211_chanctx *ctx,
  712. u32 changed)
  713. {
  714. might_sleep();
  715. trace_drv_change_chanctx(local, ctx, changed);
  716. if (local->ops->change_chanctx) {
  717. WARN_ON_ONCE(!ctx->driver_present);
  718. local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
  719. }
  720. trace_drv_return_void(local);
  721. }
  722. static inline void drv_verify_link_exists(struct ieee80211_sub_if_data *sdata,
  723. struct ieee80211_bss_conf *link_conf)
  724. {
  725. /* deflink always exists, so need to check only for other links */
  726. if (sdata->deflink.conf != link_conf)
  727. sdata_assert_lock(sdata);
  728. }
  729. int drv_assign_vif_chanctx(struct ieee80211_local *local,
  730. struct ieee80211_sub_if_data *sdata,
  731. struct ieee80211_bss_conf *link_conf,
  732. struct ieee80211_chanctx *ctx);
  733. void drv_unassign_vif_chanctx(struct ieee80211_local *local,
  734. struct ieee80211_sub_if_data *sdata,
  735. struct ieee80211_bss_conf *link_conf,
  736. struct ieee80211_chanctx *ctx);
  737. int drv_switch_vif_chanctx(struct ieee80211_local *local,
  738. struct ieee80211_vif_chanctx_switch *vifs,
  739. int n_vifs, enum ieee80211_chanctx_switch_mode mode);
  740. static inline int drv_start_ap(struct ieee80211_local *local,
  741. struct ieee80211_sub_if_data *sdata,
  742. struct ieee80211_bss_conf *link_conf)
  743. {
  744. int ret = 0;
  745. /* make sure link_conf is protected */
  746. drv_verify_link_exists(sdata, link_conf);
  747. might_sleep();
  748. if (!check_sdata_in_driver(sdata))
  749. return -EIO;
  750. trace_drv_start_ap(local, sdata, link_conf);
  751. if (local->ops->start_ap)
  752. ret = local->ops->start_ap(&local->hw, &sdata->vif, link_conf);
  753. trace_drv_return_int(local, ret);
  754. return ret;
  755. }
  756. static inline void drv_stop_ap(struct ieee80211_local *local,
  757. struct ieee80211_sub_if_data *sdata,
  758. struct ieee80211_bss_conf *link_conf)
  759. {
  760. /* make sure link_conf is protected */
  761. drv_verify_link_exists(sdata, link_conf);
  762. if (!check_sdata_in_driver(sdata))
  763. return;
  764. trace_drv_stop_ap(local, sdata, link_conf);
  765. if (local->ops->stop_ap)
  766. local->ops->stop_ap(&local->hw, &sdata->vif, link_conf);
  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 void
  844. drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
  845. {
  846. struct ieee80211_local *local = sdata->local;
  847. if (!check_sdata_in_driver(sdata))
  848. return;
  849. trace_drv_abort_channel_switch(local, sdata);
  850. if (local->ops->abort_channel_switch)
  851. local->ops->abort_channel_switch(&local->hw, &sdata->vif);
  852. }
  853. static inline void
  854. drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata,
  855. struct ieee80211_channel_switch *ch_switch)
  856. {
  857. struct ieee80211_local *local = sdata->local;
  858. if (!check_sdata_in_driver(sdata))
  859. return;
  860. trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch);
  861. if (local->ops->channel_switch_rx_beacon)
  862. local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif,
  863. ch_switch);
  864. }
  865. static inline int drv_join_ibss(struct ieee80211_local *local,
  866. struct ieee80211_sub_if_data *sdata)
  867. {
  868. int ret = 0;
  869. might_sleep();
  870. if (!check_sdata_in_driver(sdata))
  871. return -EIO;
  872. trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
  873. if (local->ops->join_ibss)
  874. ret = local->ops->join_ibss(&local->hw, &sdata->vif);
  875. trace_drv_return_int(local, ret);
  876. return ret;
  877. }
  878. static inline void drv_leave_ibss(struct ieee80211_local *local,
  879. struct ieee80211_sub_if_data *sdata)
  880. {
  881. might_sleep();
  882. if (!check_sdata_in_driver(sdata))
  883. return;
  884. trace_drv_leave_ibss(local, sdata);
  885. if (local->ops->leave_ibss)
  886. local->ops->leave_ibss(&local->hw, &sdata->vif);
  887. trace_drv_return_void(local);
  888. }
  889. static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
  890. struct sta_info *sta)
  891. {
  892. u32 ret = 0;
  893. trace_drv_get_expected_throughput(&sta->sta);
  894. if (local->ops->get_expected_throughput && sta->uploaded)
  895. ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
  896. trace_drv_return_u32(local, ret);
  897. return ret;
  898. }
  899. static inline int drv_get_txpower(struct ieee80211_local *local,
  900. struct ieee80211_sub_if_data *sdata, int *dbm)
  901. {
  902. int ret;
  903. if (!local->ops->get_txpower)
  904. return -EOPNOTSUPP;
  905. ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
  906. trace_drv_get_txpower(local, sdata, *dbm, ret);
  907. return ret;
  908. }
  909. static inline int
  910. drv_tdls_channel_switch(struct ieee80211_local *local,
  911. struct ieee80211_sub_if_data *sdata,
  912. struct ieee80211_sta *sta, u8 oper_class,
  913. struct cfg80211_chan_def *chandef,
  914. struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
  915. {
  916. int ret;
  917. might_sleep();
  918. if (!check_sdata_in_driver(sdata))
  919. return -EIO;
  920. if (!local->ops->tdls_channel_switch)
  921. return -EOPNOTSUPP;
  922. trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
  923. ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
  924. oper_class, chandef, tmpl_skb,
  925. ch_sw_tm_ie);
  926. trace_drv_return_int(local, ret);
  927. return ret;
  928. }
  929. static inline void
  930. drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
  931. struct ieee80211_sub_if_data *sdata,
  932. struct ieee80211_sta *sta)
  933. {
  934. might_sleep();
  935. if (!check_sdata_in_driver(sdata))
  936. return;
  937. if (!local->ops->tdls_cancel_channel_switch)
  938. return;
  939. trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
  940. local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
  941. trace_drv_return_void(local);
  942. }
  943. static inline void
  944. drv_tdls_recv_channel_switch(struct ieee80211_local *local,
  945. struct ieee80211_sub_if_data *sdata,
  946. struct ieee80211_tdls_ch_sw_params *params)
  947. {
  948. trace_drv_tdls_recv_channel_switch(local, sdata, params);
  949. if (local->ops->tdls_recv_channel_switch)
  950. local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
  951. params);
  952. trace_drv_return_void(local);
  953. }
  954. static inline void drv_wake_tx_queue(struct ieee80211_local *local,
  955. struct txq_info *txq)
  956. {
  957. struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
  958. /* In reconfig don't transmit now, but mark for waking later */
  959. if (local->in_reconfig) {
  960. set_bit(IEEE80211_TXQ_DIRTY, &txq->flags);
  961. return;
  962. }
  963. if (!check_sdata_in_driver(sdata))
  964. return;
  965. trace_drv_wake_tx_queue(local, sdata, txq);
  966. local->ops->wake_tx_queue(&local->hw, &txq->txq);
  967. }
  968. static inline void schedule_and_wake_txq(struct ieee80211_local *local,
  969. struct txq_info *txqi)
  970. {
  971. ieee80211_schedule_txq(&local->hw, &txqi->txq);
  972. drv_wake_tx_queue(local, txqi);
  973. }
  974. static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local,
  975. struct sk_buff *head,
  976. struct sk_buff *skb)
  977. {
  978. if (!local->ops->can_aggregate_in_amsdu)
  979. return true;
  980. return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb);
  981. }
  982. static inline int
  983. drv_get_ftm_responder_stats(struct ieee80211_local *local,
  984. struct ieee80211_sub_if_data *sdata,
  985. struct cfg80211_ftm_responder_stats *ftm_stats)
  986. {
  987. u32 ret = -EOPNOTSUPP;
  988. if (local->ops->get_ftm_responder_stats)
  989. ret = local->ops->get_ftm_responder_stats(&local->hw,
  990. &sdata->vif,
  991. ftm_stats);
  992. trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats);
  993. return ret;
  994. }
  995. static inline int drv_start_pmsr(struct ieee80211_local *local,
  996. struct ieee80211_sub_if_data *sdata,
  997. struct cfg80211_pmsr_request *request)
  998. {
  999. int ret = -EOPNOTSUPP;
  1000. might_sleep();
  1001. if (!check_sdata_in_driver(sdata))
  1002. return -EIO;
  1003. trace_drv_start_pmsr(local, sdata);
  1004. if (local->ops->start_pmsr)
  1005. ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request);
  1006. trace_drv_return_int(local, ret);
  1007. return ret;
  1008. }
  1009. static inline void drv_abort_pmsr(struct ieee80211_local *local,
  1010. struct ieee80211_sub_if_data *sdata,
  1011. struct cfg80211_pmsr_request *request)
  1012. {
  1013. trace_drv_abort_pmsr(local, sdata);
  1014. might_sleep();
  1015. if (!check_sdata_in_driver(sdata))
  1016. return;
  1017. if (local->ops->abort_pmsr)
  1018. local->ops->abort_pmsr(&local->hw, &sdata->vif, request);
  1019. trace_drv_return_void(local);
  1020. }
  1021. static inline int drv_start_nan(struct ieee80211_local *local,
  1022. struct ieee80211_sub_if_data *sdata,
  1023. struct cfg80211_nan_conf *conf)
  1024. {
  1025. int ret;
  1026. might_sleep();
  1027. check_sdata_in_driver(sdata);
  1028. trace_drv_start_nan(local, sdata, conf);
  1029. ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
  1030. trace_drv_return_int(local, ret);
  1031. return ret;
  1032. }
  1033. static inline void drv_stop_nan(struct ieee80211_local *local,
  1034. struct ieee80211_sub_if_data *sdata)
  1035. {
  1036. might_sleep();
  1037. check_sdata_in_driver(sdata);
  1038. trace_drv_stop_nan(local, sdata);
  1039. local->ops->stop_nan(&local->hw, &sdata->vif);
  1040. trace_drv_return_void(local);
  1041. }
  1042. static inline int drv_nan_change_conf(struct ieee80211_local *local,
  1043. struct ieee80211_sub_if_data *sdata,
  1044. struct cfg80211_nan_conf *conf,
  1045. u32 changes)
  1046. {
  1047. int ret;
  1048. might_sleep();
  1049. check_sdata_in_driver(sdata);
  1050. if (!local->ops->nan_change_conf)
  1051. return -EOPNOTSUPP;
  1052. trace_drv_nan_change_conf(local, sdata, conf, changes);
  1053. ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
  1054. changes);
  1055. trace_drv_return_int(local, ret);
  1056. return ret;
  1057. }
  1058. static inline int drv_add_nan_func(struct ieee80211_local *local,
  1059. struct ieee80211_sub_if_data *sdata,
  1060. const struct cfg80211_nan_func *nan_func)
  1061. {
  1062. int ret;
  1063. might_sleep();
  1064. check_sdata_in_driver(sdata);
  1065. if (!local->ops->add_nan_func)
  1066. return -EOPNOTSUPP;
  1067. trace_drv_add_nan_func(local, sdata, nan_func);
  1068. ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
  1069. trace_drv_return_int(local, ret);
  1070. return ret;
  1071. }
  1072. static inline void drv_del_nan_func(struct ieee80211_local *local,
  1073. struct ieee80211_sub_if_data *sdata,
  1074. u8 instance_id)
  1075. {
  1076. might_sleep();
  1077. check_sdata_in_driver(sdata);
  1078. trace_drv_del_nan_func(local, sdata, instance_id);
  1079. if (local->ops->del_nan_func)
  1080. local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
  1081. trace_drv_return_void(local);
  1082. }
  1083. static inline int drv_set_tid_config(struct ieee80211_local *local,
  1084. struct ieee80211_sub_if_data *sdata,
  1085. struct ieee80211_sta *sta,
  1086. struct cfg80211_tid_config *tid_conf)
  1087. {
  1088. int ret;
  1089. might_sleep();
  1090. ret = local->ops->set_tid_config(&local->hw, &sdata->vif, sta,
  1091. tid_conf);
  1092. trace_drv_return_int(local, ret);
  1093. return ret;
  1094. }
  1095. static inline int drv_reset_tid_config(struct ieee80211_local *local,
  1096. struct ieee80211_sub_if_data *sdata,
  1097. struct ieee80211_sta *sta, u8 tids)
  1098. {
  1099. int ret;
  1100. might_sleep();
  1101. ret = local->ops->reset_tid_config(&local->hw, &sdata->vif, sta, tids);
  1102. trace_drv_return_int(local, ret);
  1103. return ret;
  1104. }
  1105. static inline void drv_update_vif_offload(struct ieee80211_local *local,
  1106. struct ieee80211_sub_if_data *sdata)
  1107. {
  1108. might_sleep();
  1109. check_sdata_in_driver(sdata);
  1110. if (!local->ops->update_vif_offload)
  1111. return;
  1112. trace_drv_update_vif_offload(local, sdata);
  1113. local->ops->update_vif_offload(&local->hw, &sdata->vif);
  1114. trace_drv_return_void(local);
  1115. }
  1116. static inline void drv_sta_set_4addr(struct ieee80211_local *local,
  1117. struct ieee80211_sub_if_data *sdata,
  1118. struct ieee80211_sta *sta, bool enabled)
  1119. {
  1120. sdata = get_bss_sdata(sdata);
  1121. if (!check_sdata_in_driver(sdata))
  1122. return;
  1123. trace_drv_sta_set_4addr(local, sdata, sta, enabled);
  1124. if (local->ops->sta_set_4addr)
  1125. local->ops->sta_set_4addr(&local->hw, &sdata->vif, sta, enabled);
  1126. trace_drv_return_void(local);
  1127. }
  1128. static inline void drv_sta_set_decap_offload(struct ieee80211_local *local,
  1129. struct ieee80211_sub_if_data *sdata,
  1130. struct ieee80211_sta *sta,
  1131. bool enabled)
  1132. {
  1133. sdata = get_bss_sdata(sdata);
  1134. if (!check_sdata_in_driver(sdata))
  1135. return;
  1136. trace_drv_sta_set_decap_offload(local, sdata, sta, enabled);
  1137. if (local->ops->sta_set_decap_offload)
  1138. local->ops->sta_set_decap_offload(&local->hw, &sdata->vif, sta,
  1139. enabled);
  1140. trace_drv_return_void(local);
  1141. }
  1142. static inline void drv_add_twt_setup(struct ieee80211_local *local,
  1143. struct ieee80211_sub_if_data *sdata,
  1144. struct ieee80211_sta *sta,
  1145. struct ieee80211_twt_setup *twt)
  1146. {
  1147. struct ieee80211_twt_params *twt_agrt;
  1148. might_sleep();
  1149. if (!check_sdata_in_driver(sdata))
  1150. return;
  1151. twt_agrt = (void *)twt->params;
  1152. trace_drv_add_twt_setup(local, sta, twt, twt_agrt);
  1153. local->ops->add_twt_setup(&local->hw, sta, twt);
  1154. trace_drv_return_void(local);
  1155. }
  1156. static inline void drv_twt_teardown_request(struct ieee80211_local *local,
  1157. struct ieee80211_sub_if_data *sdata,
  1158. struct ieee80211_sta *sta,
  1159. u8 flowid)
  1160. {
  1161. might_sleep();
  1162. if (!check_sdata_in_driver(sdata))
  1163. return;
  1164. if (!local->ops->twt_teardown_request)
  1165. return;
  1166. trace_drv_twt_teardown_request(local, sta, flowid);
  1167. local->ops->twt_teardown_request(&local->hw, sta, flowid);
  1168. trace_drv_return_void(local);
  1169. }
  1170. static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
  1171. struct ieee80211_sub_if_data *sdata,
  1172. struct ieee80211_sta *sta,
  1173. struct net_device_path_ctx *ctx,
  1174. struct net_device_path *path)
  1175. {
  1176. int ret = -EOPNOTSUPP;
  1177. sdata = get_bss_sdata(sdata);
  1178. if (!check_sdata_in_driver(sdata))
  1179. return -EIO;
  1180. trace_drv_net_fill_forward_path(local, sdata, sta);
  1181. if (local->ops->net_fill_forward_path)
  1182. ret = local->ops->net_fill_forward_path(&local->hw,
  1183. &sdata->vif, sta,
  1184. ctx, path);
  1185. trace_drv_return_int(local, ret);
  1186. return ret;
  1187. }
  1188. int drv_change_vif_links(struct ieee80211_local *local,
  1189. struct ieee80211_sub_if_data *sdata,
  1190. u16 old_links, u16 new_links,
  1191. struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS]);
  1192. int drv_change_sta_links(struct ieee80211_local *local,
  1193. struct ieee80211_sub_if_data *sdata,
  1194. struct ieee80211_sta *sta,
  1195. u16 old_links, u16 new_links);
  1196. #endif /* __MAC80211_DRIVER_OPS */