driver-ops.h 31 KB

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