driver-ops.h 32 KB

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