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 void drv_sta_statistics(struct ieee80211_local *local,
  514. struct ieee80211_sub_if_data *sdata,
  515. struct ieee80211_sta *sta,
  516. struct station_info *sinfo)
  517. {
  518. sdata = get_bss_sdata(sdata);
  519. if (!check_sdata_in_driver(sdata))
  520. return;
  521. trace_drv_sta_statistics(local, sdata, sta);
  522. if (local->ops->sta_statistics)
  523. local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
  524. trace_drv_return_void(local);
  525. }
  526. static inline int drv_conf_tx(struct ieee80211_local *local,
  527. struct ieee80211_sub_if_data *sdata, u16 ac,
  528. const struct ieee80211_tx_queue_params *params)
  529. {
  530. int ret = -EOPNOTSUPP;
  531. might_sleep();
  532. if (!check_sdata_in_driver(sdata))
  533. return -EIO;
  534. if (WARN_ONCE(params->cw_min == 0 ||
  535. params->cw_min > params->cw_max,
  536. "%s: invalid CW_min/CW_max: %d/%d\n",
  537. sdata->name, params->cw_min, params->cw_max))
  538. return -EINVAL;
  539. trace_drv_conf_tx(local, sdata, ac, params);
  540. if (local->ops->conf_tx)
  541. ret = local->ops->conf_tx(&local->hw, &sdata->vif,
  542. ac, params);
  543. trace_drv_return_int(local, ret);
  544. return ret;
  545. }
  546. static inline u64 drv_get_tsf(struct ieee80211_local *local,
  547. struct ieee80211_sub_if_data *sdata)
  548. {
  549. u64 ret = -1ULL;
  550. might_sleep();
  551. if (!check_sdata_in_driver(sdata))
  552. return ret;
  553. trace_drv_get_tsf(local, sdata);
  554. if (local->ops->get_tsf)
  555. ret = local->ops->get_tsf(&local->hw, &sdata->vif);
  556. trace_drv_return_u64(local, ret);
  557. return ret;
  558. }
  559. static inline void drv_set_tsf(struct ieee80211_local *local,
  560. struct ieee80211_sub_if_data *sdata,
  561. u64 tsf)
  562. {
  563. might_sleep();
  564. if (!check_sdata_in_driver(sdata))
  565. return;
  566. trace_drv_set_tsf(local, sdata, tsf);
  567. if (local->ops->set_tsf)
  568. local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
  569. trace_drv_return_void(local);
  570. }
  571. static inline void drv_reset_tsf(struct ieee80211_local *local,
  572. struct ieee80211_sub_if_data *sdata)
  573. {
  574. might_sleep();
  575. if (!check_sdata_in_driver(sdata))
  576. return;
  577. trace_drv_reset_tsf(local, sdata);
  578. if (local->ops->reset_tsf)
  579. local->ops->reset_tsf(&local->hw, &sdata->vif);
  580. trace_drv_return_void(local);
  581. }
  582. static inline int drv_tx_last_beacon(struct ieee80211_local *local)
  583. {
  584. int ret = 0; /* default unsupported op for less congestion */
  585. might_sleep();
  586. trace_drv_tx_last_beacon(local);
  587. if (local->ops->tx_last_beacon)
  588. ret = local->ops->tx_last_beacon(&local->hw);
  589. trace_drv_return_int(local, ret);
  590. return ret;
  591. }
  592. static inline int drv_ampdu_action(struct ieee80211_local *local,
  593. struct ieee80211_sub_if_data *sdata,
  594. enum ieee80211_ampdu_mlme_action action,
  595. struct ieee80211_sta *sta, u16 tid,
  596. u16 *ssn, u8 buf_size)
  597. {
  598. int ret = -EOPNOTSUPP;
  599. might_sleep();
  600. sdata = get_bss_sdata(sdata);
  601. if (!check_sdata_in_driver(sdata))
  602. return -EIO;
  603. trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
  604. if (local->ops->ampdu_action)
  605. ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
  606. sta, tid, ssn, buf_size);
  607. trace_drv_return_int(local, ret);
  608. return ret;
  609. }
  610. static inline int drv_get_survey(struct ieee80211_local *local, int idx,
  611. struct survey_info *survey)
  612. {
  613. int ret = -EOPNOTSUPP;
  614. trace_drv_get_survey(local, idx, survey);
  615. if (local->ops->get_survey)
  616. ret = local->ops->get_survey(&local->hw, idx, survey);
  617. trace_drv_return_int(local, ret);
  618. return ret;
  619. }
  620. static inline void drv_rfkill_poll(struct ieee80211_local *local)
  621. {
  622. might_sleep();
  623. if (local->ops->rfkill_poll)
  624. local->ops->rfkill_poll(&local->hw);
  625. }
  626. static inline void drv_flush(struct ieee80211_local *local,
  627. struct ieee80211_sub_if_data *sdata,
  628. u32 queues, bool drop)
  629. {
  630. struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
  631. might_sleep();
  632. if (sdata && !check_sdata_in_driver(sdata))
  633. return;
  634. trace_drv_flush(local, queues, drop);
  635. if (local->ops->flush)
  636. local->ops->flush(&local->hw, vif, queues, drop);
  637. trace_drv_return_void(local);
  638. }
  639. static inline void drv_channel_switch(struct ieee80211_local *local,
  640. struct ieee80211_sub_if_data *sdata,
  641. struct ieee80211_channel_switch *ch_switch)
  642. {
  643. might_sleep();
  644. trace_drv_channel_switch(local, sdata, ch_switch);
  645. local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
  646. trace_drv_return_void(local);
  647. }
  648. static inline int drv_set_antenna(struct ieee80211_local *local,
  649. u32 tx_ant, u32 rx_ant)
  650. {
  651. int ret = -EOPNOTSUPP;
  652. might_sleep();
  653. if (local->ops->set_antenna)
  654. ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
  655. trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
  656. return ret;
  657. }
  658. static inline int drv_get_antenna(struct ieee80211_local *local,
  659. u32 *tx_ant, u32 *rx_ant)
  660. {
  661. int ret = -EOPNOTSUPP;
  662. might_sleep();
  663. if (local->ops->get_antenna)
  664. ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
  665. trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
  666. return ret;
  667. }
  668. static inline int drv_remain_on_channel(struct ieee80211_local *local,
  669. struct ieee80211_sub_if_data *sdata,
  670. struct ieee80211_channel *chan,
  671. unsigned int duration,
  672. enum ieee80211_roc_type type)
  673. {
  674. int ret;
  675. might_sleep();
  676. trace_drv_remain_on_channel(local, sdata, chan, duration, type);
  677. ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
  678. chan, duration, type);
  679. trace_drv_return_int(local, ret);
  680. return ret;
  681. }
  682. static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
  683. {
  684. int ret;
  685. might_sleep();
  686. trace_drv_cancel_remain_on_channel(local);
  687. ret = local->ops->cancel_remain_on_channel(&local->hw);
  688. trace_drv_return_int(local, ret);
  689. return ret;
  690. }
  691. static inline int drv_set_ringparam(struct ieee80211_local *local,
  692. u32 tx, u32 rx)
  693. {
  694. int ret = -ENOTSUPP;
  695. might_sleep();
  696. trace_drv_set_ringparam(local, tx, rx);
  697. if (local->ops->set_ringparam)
  698. ret = local->ops->set_ringparam(&local->hw, tx, rx);
  699. trace_drv_return_int(local, ret);
  700. return ret;
  701. }
  702. static inline void drv_get_ringparam(struct ieee80211_local *local,
  703. u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
  704. {
  705. might_sleep();
  706. trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
  707. if (local->ops->get_ringparam)
  708. local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
  709. trace_drv_return_void(local);
  710. }
  711. static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
  712. {
  713. bool ret = false;
  714. might_sleep();
  715. trace_drv_tx_frames_pending(local);
  716. if (local->ops->tx_frames_pending)
  717. ret = local->ops->tx_frames_pending(&local->hw);
  718. trace_drv_return_bool(local, ret);
  719. return ret;
  720. }
  721. static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
  722. struct ieee80211_sub_if_data *sdata,
  723. const struct cfg80211_bitrate_mask *mask)
  724. {
  725. int ret = -EOPNOTSUPP;
  726. might_sleep();
  727. if (!check_sdata_in_driver(sdata))
  728. return -EIO;
  729. trace_drv_set_bitrate_mask(local, sdata, mask);
  730. if (local->ops->set_bitrate_mask)
  731. ret = local->ops->set_bitrate_mask(&local->hw,
  732. &sdata->vif, mask);
  733. trace_drv_return_int(local, ret);
  734. return ret;
  735. }
  736. static inline void drv_set_rekey_data(struct ieee80211_local *local,
  737. struct ieee80211_sub_if_data *sdata,
  738. struct cfg80211_gtk_rekey_data *data)
  739. {
  740. if (!check_sdata_in_driver(sdata))
  741. return;
  742. trace_drv_set_rekey_data(local, sdata, data);
  743. if (local->ops->set_rekey_data)
  744. local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
  745. trace_drv_return_void(local);
  746. }
  747. static inline void drv_rssi_callback(struct ieee80211_local *local,
  748. struct ieee80211_sub_if_data *sdata,
  749. const enum ieee80211_rssi_event event)
  750. {
  751. trace_drv_rssi_callback(local, sdata, event);
  752. if (local->ops->rssi_callback)
  753. local->ops->rssi_callback(&local->hw, &sdata->vif, event);
  754. trace_drv_return_void(local);
  755. }
  756. static inline void
  757. drv_release_buffered_frames(struct ieee80211_local *local,
  758. struct sta_info *sta, u16 tids, int num_frames,
  759. enum ieee80211_frame_release_type reason,
  760. bool more_data)
  761. {
  762. trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
  763. reason, more_data);
  764. if (local->ops->release_buffered_frames)
  765. local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
  766. num_frames, reason,
  767. more_data);
  768. trace_drv_return_void(local);
  769. }
  770. static inline void
  771. drv_allow_buffered_frames(struct ieee80211_local *local,
  772. struct sta_info *sta, u16 tids, int num_frames,
  773. enum ieee80211_frame_release_type reason,
  774. bool more_data)
  775. {
  776. trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
  777. reason, more_data);
  778. if (local->ops->allow_buffered_frames)
  779. local->ops->allow_buffered_frames(&local->hw, &sta->sta,
  780. tids, num_frames, reason,
  781. more_data);
  782. trace_drv_return_void(local);
  783. }
  784. static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
  785. struct ieee80211_sub_if_data *sdata)
  786. {
  787. might_sleep();
  788. if (!check_sdata_in_driver(sdata))
  789. return;
  790. WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  791. trace_drv_mgd_prepare_tx(local, sdata);
  792. if (local->ops->mgd_prepare_tx)
  793. local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
  794. trace_drv_return_void(local);
  795. }
  796. static inline void
  797. drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
  798. struct ieee80211_sub_if_data *sdata)
  799. {
  800. might_sleep();
  801. if (!check_sdata_in_driver(sdata))
  802. return;
  803. WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  804. trace_drv_mgd_protect_tdls_discover(local, sdata);
  805. if (local->ops->mgd_protect_tdls_discover)
  806. local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
  807. trace_drv_return_void(local);
  808. }
  809. static inline int drv_add_chanctx(struct ieee80211_local *local,
  810. struct ieee80211_chanctx *ctx)
  811. {
  812. int ret = -EOPNOTSUPP;
  813. trace_drv_add_chanctx(local, ctx);
  814. if (local->ops->add_chanctx)
  815. ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
  816. trace_drv_return_int(local, ret);
  817. if (!ret)
  818. ctx->driver_present = true;
  819. return ret;
  820. }
  821. static inline void drv_remove_chanctx(struct ieee80211_local *local,
  822. struct ieee80211_chanctx *ctx)
  823. {
  824. if (WARN_ON(!ctx->driver_present))
  825. return;
  826. trace_drv_remove_chanctx(local, ctx);
  827. if (local->ops->remove_chanctx)
  828. local->ops->remove_chanctx(&local->hw, &ctx->conf);
  829. trace_drv_return_void(local);
  830. ctx->driver_present = false;
  831. }
  832. static inline void drv_change_chanctx(struct ieee80211_local *local,
  833. struct ieee80211_chanctx *ctx,
  834. u32 changed)
  835. {
  836. trace_drv_change_chanctx(local, ctx, changed);
  837. if (local->ops->change_chanctx) {
  838. WARN_ON_ONCE(!ctx->driver_present);
  839. local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
  840. }
  841. trace_drv_return_void(local);
  842. }
  843. static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
  844. struct ieee80211_sub_if_data *sdata,
  845. struct ieee80211_chanctx *ctx)
  846. {
  847. int ret = 0;
  848. if (!check_sdata_in_driver(sdata))
  849. return -EIO;
  850. trace_drv_assign_vif_chanctx(local, sdata, ctx);
  851. if (local->ops->assign_vif_chanctx) {
  852. WARN_ON_ONCE(!ctx->driver_present);
  853. ret = local->ops->assign_vif_chanctx(&local->hw,
  854. &sdata->vif,
  855. &ctx->conf);
  856. }
  857. trace_drv_return_int(local, ret);
  858. return ret;
  859. }
  860. static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
  861. struct ieee80211_sub_if_data *sdata,
  862. struct ieee80211_chanctx *ctx)
  863. {
  864. if (!check_sdata_in_driver(sdata))
  865. return;
  866. trace_drv_unassign_vif_chanctx(local, sdata, ctx);
  867. if (local->ops->unassign_vif_chanctx) {
  868. WARN_ON_ONCE(!ctx->driver_present);
  869. local->ops->unassign_vif_chanctx(&local->hw,
  870. &sdata->vif,
  871. &ctx->conf);
  872. }
  873. trace_drv_return_void(local);
  874. }
  875. static inline int
  876. drv_switch_vif_chanctx(struct ieee80211_local *local,
  877. struct ieee80211_vif_chanctx_switch *vifs,
  878. int n_vifs,
  879. enum ieee80211_chanctx_switch_mode mode)
  880. {
  881. int ret = 0;
  882. int i;
  883. if (!local->ops->switch_vif_chanctx)
  884. return -EOPNOTSUPP;
  885. for (i = 0; i < n_vifs; i++) {
  886. struct ieee80211_chanctx *new_ctx =
  887. container_of(vifs[i].new_ctx,
  888. struct ieee80211_chanctx,
  889. conf);
  890. struct ieee80211_chanctx *old_ctx =
  891. container_of(vifs[i].old_ctx,
  892. struct ieee80211_chanctx,
  893. conf);
  894. WARN_ON_ONCE(!old_ctx->driver_present);
  895. WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
  896. new_ctx->driver_present) ||
  897. (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
  898. !new_ctx->driver_present));
  899. }
  900. trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
  901. ret = local->ops->switch_vif_chanctx(&local->hw,
  902. vifs, n_vifs, mode);
  903. trace_drv_return_int(local, ret);
  904. if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
  905. for (i = 0; i < n_vifs; i++) {
  906. struct ieee80211_chanctx *new_ctx =
  907. container_of(vifs[i].new_ctx,
  908. struct ieee80211_chanctx,
  909. conf);
  910. struct ieee80211_chanctx *old_ctx =
  911. container_of(vifs[i].old_ctx,
  912. struct ieee80211_chanctx,
  913. conf);
  914. new_ctx->driver_present = true;
  915. old_ctx->driver_present = false;
  916. }
  917. }
  918. return ret;
  919. }
  920. static inline int drv_start_ap(struct ieee80211_local *local,
  921. struct ieee80211_sub_if_data *sdata)
  922. {
  923. int ret = 0;
  924. if (!check_sdata_in_driver(sdata))
  925. return -EIO;
  926. trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
  927. if (local->ops->start_ap)
  928. ret = local->ops->start_ap(&local->hw, &sdata->vif);
  929. trace_drv_return_int(local, ret);
  930. return ret;
  931. }
  932. static inline void drv_stop_ap(struct ieee80211_local *local,
  933. struct ieee80211_sub_if_data *sdata)
  934. {
  935. if (!check_sdata_in_driver(sdata))
  936. return;
  937. trace_drv_stop_ap(local, sdata);
  938. if (local->ops->stop_ap)
  939. local->ops->stop_ap(&local->hw, &sdata->vif);
  940. trace_drv_return_void(local);
  941. }
  942. static inline void
  943. drv_reconfig_complete(struct ieee80211_local *local,
  944. enum ieee80211_reconfig_type reconfig_type)
  945. {
  946. might_sleep();
  947. trace_drv_reconfig_complete(local, reconfig_type);
  948. if (local->ops->reconfig_complete)
  949. local->ops->reconfig_complete(&local->hw, reconfig_type);
  950. trace_drv_return_void(local);
  951. }
  952. static inline void
  953. drv_set_default_unicast_key(struct ieee80211_local *local,
  954. struct ieee80211_sub_if_data *sdata,
  955. int key_idx)
  956. {
  957. if (!check_sdata_in_driver(sdata))
  958. return;
  959. WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
  960. trace_drv_set_default_unicast_key(local, sdata, key_idx);
  961. if (local->ops->set_default_unicast_key)
  962. local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
  963. key_idx);
  964. trace_drv_return_void(local);
  965. }
  966. #if IS_ENABLED(CONFIG_IPV6)
  967. static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
  968. struct ieee80211_sub_if_data *sdata,
  969. struct inet6_dev *idev)
  970. {
  971. trace_drv_ipv6_addr_change(local, sdata);
  972. if (local->ops->ipv6_addr_change)
  973. local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
  974. trace_drv_return_void(local);
  975. }
  976. #endif
  977. static inline void
  978. drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
  979. struct cfg80211_chan_def *chandef)
  980. {
  981. struct ieee80211_local *local = sdata->local;
  982. if (local->ops->channel_switch_beacon) {
  983. trace_drv_channel_switch_beacon(local, sdata, chandef);
  984. local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
  985. chandef);
  986. }
  987. }
  988. static inline int
  989. drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
  990. struct ieee80211_channel_switch *ch_switch)
  991. {
  992. struct ieee80211_local *local = sdata->local;
  993. int ret = 0;
  994. if (!check_sdata_in_driver(sdata))
  995. return -EIO;
  996. trace_drv_pre_channel_switch(local, sdata, ch_switch);
  997. if (local->ops->pre_channel_switch)
  998. ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
  999. ch_switch);
  1000. trace_drv_return_int(local, ret);
  1001. return ret;
  1002. }
  1003. static inline int
  1004. drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
  1005. {
  1006. struct ieee80211_local *local = sdata->local;
  1007. int ret = 0;
  1008. if (!check_sdata_in_driver(sdata))
  1009. return -EIO;
  1010. trace_drv_post_channel_switch(local, sdata);
  1011. if (local->ops->post_channel_switch)
  1012. ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
  1013. trace_drv_return_int(local, ret);
  1014. return ret;
  1015. }
  1016. static inline int drv_join_ibss(struct ieee80211_local *local,
  1017. struct ieee80211_sub_if_data *sdata)
  1018. {
  1019. int ret = 0;
  1020. might_sleep();
  1021. if (!check_sdata_in_driver(sdata))
  1022. return -EIO;
  1023. trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
  1024. if (local->ops->join_ibss)
  1025. ret = local->ops->join_ibss(&local->hw, &sdata->vif);
  1026. trace_drv_return_int(local, ret);
  1027. return ret;
  1028. }
  1029. static inline void drv_leave_ibss(struct ieee80211_local *local,
  1030. struct ieee80211_sub_if_data *sdata)
  1031. {
  1032. might_sleep();
  1033. if (!check_sdata_in_driver(sdata))
  1034. return;
  1035. trace_drv_leave_ibss(local, sdata);
  1036. if (local->ops->leave_ibss)
  1037. local->ops->leave_ibss(&local->hw, &sdata->vif);
  1038. trace_drv_return_void(local);
  1039. }
  1040. static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
  1041. struct ieee80211_sta *sta)
  1042. {
  1043. u32 ret = 0;
  1044. trace_drv_get_expected_throughput(sta);
  1045. if (local->ops->get_expected_throughput)
  1046. ret = local->ops->get_expected_throughput(sta);
  1047. trace_drv_return_u32(local, ret);
  1048. return ret;
  1049. }
  1050. static inline int drv_get_txpower(struct ieee80211_local *local,
  1051. struct ieee80211_sub_if_data *sdata, int *dbm)
  1052. {
  1053. int ret;
  1054. if (!local->ops->get_txpower)
  1055. return -EOPNOTSUPP;
  1056. ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
  1057. trace_drv_get_txpower(local, sdata, *dbm, ret);
  1058. return ret;
  1059. }
  1060. static inline int
  1061. drv_tdls_channel_switch(struct ieee80211_local *local,
  1062. struct ieee80211_sub_if_data *sdata,
  1063. struct ieee80211_sta *sta, u8 oper_class,
  1064. struct cfg80211_chan_def *chandef,
  1065. struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
  1066. {
  1067. int ret;
  1068. might_sleep();
  1069. if (!check_sdata_in_driver(sdata))
  1070. return -EIO;
  1071. if (!local->ops->tdls_channel_switch)
  1072. return -EOPNOTSUPP;
  1073. trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
  1074. ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
  1075. oper_class, chandef, tmpl_skb,
  1076. ch_sw_tm_ie);
  1077. trace_drv_return_int(local, ret);
  1078. return ret;
  1079. }
  1080. static inline void
  1081. drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
  1082. struct ieee80211_sub_if_data *sdata,
  1083. struct ieee80211_sta *sta)
  1084. {
  1085. might_sleep();
  1086. if (!check_sdata_in_driver(sdata))
  1087. return;
  1088. if (!local->ops->tdls_cancel_channel_switch)
  1089. return;
  1090. trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
  1091. local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
  1092. trace_drv_return_void(local);
  1093. }
  1094. static inline void
  1095. drv_tdls_recv_channel_switch(struct ieee80211_local *local,
  1096. struct ieee80211_sub_if_data *sdata,
  1097. struct ieee80211_tdls_ch_sw_params *params)
  1098. {
  1099. trace_drv_tdls_recv_channel_switch(local, sdata, params);
  1100. if (local->ops->tdls_recv_channel_switch)
  1101. local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
  1102. params);
  1103. trace_drv_return_void(local);
  1104. }
  1105. #endif /* __MAC80211_DRIVER_OPS */