driver-ops.h 34 KB

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