driver-ops.h 29 KB

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