327-mac80211-reorganize-code-to-remove-a-forward-declara.patch 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  1. From: Felix Fietkau <[email protected]>
  2. Date: Tue, 8 Sep 2020 12:16:26 +0200
  3. Subject: [PATCH] mac80211: reorganize code to remove a forward
  4. declaration
  5. Remove the newly added ieee80211_set_vif_encap_ops declaration.
  6. No further code changes
  7. Signed-off-by: Felix Fietkau <[email protected]>
  8. ---
  9. --- a/net/mac80211/iface.c
  10. +++ b/net/mac80211/iface.c
  11. @@ -43,7 +43,6 @@
  12. */
  13. static void ieee80211_iface_work(struct work_struct *work);
  14. -static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata);
  15. bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
  16. {
  17. @@ -349,6 +348,518 @@ static int ieee80211_check_queues(struct
  18. return 0;
  19. }
  20. +static int ieee80211_open(struct net_device *dev)
  21. +{
  22. + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  23. + int err;
  24. +
  25. + /* fail early if user set an invalid address */
  26. + if (!is_valid_ether_addr(dev->dev_addr))
  27. + return -EADDRNOTAVAIL;
  28. +
  29. + err = ieee80211_check_concurrent_iface(sdata, sdata->vif.type);
  30. + if (err)
  31. + return err;
  32. +
  33. + return ieee80211_do_open(&sdata->wdev, true);
  34. +}
  35. +
  36. +static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
  37. + bool going_down)
  38. +{
  39. + struct ieee80211_local *local = sdata->local;
  40. + unsigned long flags;
  41. + struct sk_buff *skb, *tmp;
  42. + u32 hw_reconf_flags = 0;
  43. + int i, flushed;
  44. + struct ps_data *ps;
  45. + struct cfg80211_chan_def chandef;
  46. + bool cancel_scan;
  47. + struct cfg80211_nan_func *func;
  48. +
  49. + clear_bit(SDATA_STATE_RUNNING, &sdata->state);
  50. +
  51. + cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata;
  52. + if (cancel_scan)
  53. + ieee80211_scan_cancel(local);
  54. +
  55. + /*
  56. + * Stop TX on this interface first.
  57. + */
  58. + if (sdata->dev)
  59. + netif_tx_stop_all_queues(sdata->dev);
  60. +
  61. + ieee80211_roc_purge(local, sdata);
  62. +
  63. + switch (sdata->vif.type) {
  64. + case NL80211_IFTYPE_STATION:
  65. + ieee80211_mgd_stop(sdata);
  66. + break;
  67. + case NL80211_IFTYPE_ADHOC:
  68. + ieee80211_ibss_stop(sdata);
  69. + break;
  70. + case NL80211_IFTYPE_MONITOR:
  71. + if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES)
  72. + break;
  73. + list_del_rcu(&sdata->u.mntr.list);
  74. + break;
  75. + default:
  76. + break;
  77. + }
  78. +
  79. + /*
  80. + * Remove all stations associated with this interface.
  81. + *
  82. + * This must be done before calling ops->remove_interface()
  83. + * because otherwise we can later invoke ops->sta_notify()
  84. + * whenever the STAs are removed, and that invalidates driver
  85. + * assumptions about always getting a vif pointer that is valid
  86. + * (because if we remove a STA after ops->remove_interface()
  87. + * the driver will have removed the vif info already!)
  88. + *
  89. + * In WDS mode a station must exist here and be flushed, for
  90. + * AP_VLANs stations may exist since there's nothing else that
  91. + * would have removed them, but in other modes there shouldn't
  92. + * be any stations.
  93. + */
  94. + flushed = sta_info_flush(sdata);
  95. + WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  96. + ((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) ||
  97. + (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1)));
  98. +
  99. + /* don't count this interface for allmulti while it is down */
  100. + if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
  101. + atomic_dec(&local->iff_allmultis);
  102. +
  103. + if (sdata->vif.type == NL80211_IFTYPE_AP) {
  104. + local->fif_pspoll--;
  105. + local->fif_probe_req--;
  106. + } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
  107. + local->fif_probe_req--;
  108. + }
  109. +
  110. + if (sdata->dev) {
  111. + netif_addr_lock_bh(sdata->dev);
  112. + spin_lock_bh(&local->filter_lock);
  113. + __hw_addr_unsync(&local->mc_list, &sdata->dev->mc,
  114. + sdata->dev->addr_len);
  115. + spin_unlock_bh(&local->filter_lock);
  116. + netif_addr_unlock_bh(sdata->dev);
  117. + }
  118. +
  119. + del_timer_sync(&local->dynamic_ps_timer);
  120. + cancel_work_sync(&local->dynamic_ps_enable_work);
  121. +
  122. + cancel_work_sync(&sdata->recalc_smps);
  123. + sdata_lock(sdata);
  124. + mutex_lock(&local->mtx);
  125. + sdata->vif.csa_active = false;
  126. + if (sdata->vif.type == NL80211_IFTYPE_STATION)
  127. + sdata->u.mgd.csa_waiting_bcn = false;
  128. + if (sdata->csa_block_tx) {
  129. + ieee80211_wake_vif_queues(local, sdata,
  130. + IEEE80211_QUEUE_STOP_REASON_CSA);
  131. + sdata->csa_block_tx = false;
  132. + }
  133. + mutex_unlock(&local->mtx);
  134. + sdata_unlock(sdata);
  135. +
  136. + cancel_work_sync(&sdata->csa_finalize_work);
  137. +
  138. + cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
  139. +
  140. + if (sdata->wdev.cac_started) {
  141. + chandef = sdata->vif.bss_conf.chandef;
  142. + WARN_ON(local->suspended);
  143. + mutex_lock(&local->mtx);
  144. + ieee80211_vif_release_channel(sdata);
  145. + mutex_unlock(&local->mtx);
  146. + cfg80211_cac_event(sdata->dev, &chandef,
  147. + NL80211_RADAR_CAC_ABORTED,
  148. + GFP_KERNEL);
  149. + }
  150. +
  151. + /* APs need special treatment */
  152. + if (sdata->vif.type == NL80211_IFTYPE_AP) {
  153. + struct ieee80211_sub_if_data *vlan, *tmpsdata;
  154. +
  155. + /* down all dependent devices, that is VLANs */
  156. + list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans,
  157. + u.vlan.list)
  158. + dev_close(vlan->dev);
  159. + WARN_ON(!list_empty(&sdata->u.ap.vlans));
  160. + } else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
  161. + /* remove all packets in parent bc_buf pointing to this dev */
  162. + ps = &sdata->bss->ps;
  163. +
  164. + spin_lock_irqsave(&ps->bc_buf.lock, flags);
  165. + skb_queue_walk_safe(&ps->bc_buf, skb, tmp) {
  166. + if (skb->dev == sdata->dev) {
  167. + __skb_unlink(skb, &ps->bc_buf);
  168. + local->total_ps_buffered--;
  169. + ieee80211_free_txskb(&local->hw, skb);
  170. + }
  171. + }
  172. + spin_unlock_irqrestore(&ps->bc_buf.lock, flags);
  173. + }
  174. +
  175. + if (going_down)
  176. + local->open_count--;
  177. +
  178. + switch (sdata->vif.type) {
  179. + case NL80211_IFTYPE_AP_VLAN:
  180. + mutex_lock(&local->mtx);
  181. + list_del(&sdata->u.vlan.list);
  182. + mutex_unlock(&local->mtx);
  183. + RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL);
  184. + /* see comment in the default case below */
  185. + ieee80211_free_keys(sdata, true);
  186. + /* no need to tell driver */
  187. + break;
  188. + case NL80211_IFTYPE_MONITOR:
  189. + if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) {
  190. + local->cooked_mntrs--;
  191. + break;
  192. + }
  193. +
  194. + local->monitors--;
  195. + if (local->monitors == 0) {
  196. + local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR;
  197. + hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
  198. + }
  199. +
  200. + ieee80211_adjust_monitor_flags(sdata, -1);
  201. + break;
  202. + case NL80211_IFTYPE_NAN:
  203. + /* clean all the functions */
  204. + spin_lock_bh(&sdata->u.nan.func_lock);
  205. +
  206. + idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, i) {
  207. + idr_remove(&sdata->u.nan.function_inst_ids, i);
  208. + cfg80211_free_nan_func(func);
  209. + }
  210. + idr_destroy(&sdata->u.nan.function_inst_ids);
  211. +
  212. + spin_unlock_bh(&sdata->u.nan.func_lock);
  213. + break;
  214. + case NL80211_IFTYPE_P2P_DEVICE:
  215. + /* relies on synchronize_rcu() below */
  216. + RCU_INIT_POINTER(local->p2p_sdata, NULL);
  217. + fallthrough;
  218. + default:
  219. + cancel_work_sync(&sdata->work);
  220. + /*
  221. + * When we get here, the interface is marked down.
  222. + * Free the remaining keys, if there are any
  223. + * (which can happen in AP mode if userspace sets
  224. + * keys before the interface is operating, and maybe
  225. + * also in WDS mode)
  226. + *
  227. + * Force the key freeing to always synchronize_net()
  228. + * to wait for the RX path in case it is using this
  229. + * interface enqueuing frames at this very time on
  230. + * another CPU.
  231. + */
  232. + ieee80211_free_keys(sdata, true);
  233. + skb_queue_purge(&sdata->skb_queue);
  234. + }
  235. +
  236. + spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
  237. + for (i = 0; i < IEEE80211_MAX_QUEUES; i++) {
  238. + skb_queue_walk_safe(&local->pending[i], skb, tmp) {
  239. + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  240. + if (info->control.vif == &sdata->vif) {
  241. + __skb_unlink(skb, &local->pending[i]);
  242. + ieee80211_free_txskb(&local->hw, skb);
  243. + }
  244. + }
  245. + }
  246. + spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
  247. +
  248. + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  249. + ieee80211_txq_remove_vlan(local, sdata);
  250. +
  251. + sdata->bss = NULL;
  252. +
  253. + if (local->open_count == 0)
  254. + ieee80211_clear_tx_pending(local);
  255. +
  256. + sdata->vif.bss_conf.beacon_int = 0;
  257. +
  258. + /*
  259. + * If the interface goes down while suspended, presumably because
  260. + * the device was unplugged and that happens before our resume,
  261. + * then the driver is already unconfigured and the remainder of
  262. + * this function isn't needed.
  263. + * XXX: what about WoWLAN? If the device has software state, e.g.
  264. + * memory allocated, it might expect teardown commands from
  265. + * mac80211 here?
  266. + */
  267. + if (local->suspended) {
  268. + WARN_ON(local->wowlan);
  269. + WARN_ON(rtnl_dereference(local->monitor_sdata));
  270. + return;
  271. + }
  272. +
  273. + switch (sdata->vif.type) {
  274. + case NL80211_IFTYPE_AP_VLAN:
  275. + break;
  276. + case NL80211_IFTYPE_MONITOR:
  277. + if (local->monitors == 0)
  278. + ieee80211_del_virtual_monitor(local);
  279. +
  280. + mutex_lock(&local->mtx);
  281. + ieee80211_recalc_idle(local);
  282. + mutex_unlock(&local->mtx);
  283. +
  284. + if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))
  285. + break;
  286. +
  287. + fallthrough;
  288. + default:
  289. + if (going_down)
  290. + drv_remove_interface(local, sdata);
  291. + }
  292. +
  293. + ieee80211_recalc_ps(local);
  294. +
  295. + if (cancel_scan)
  296. + flush_delayed_work(&local->scan_work);
  297. +
  298. + if (local->open_count == 0) {
  299. + ieee80211_stop_device(local);
  300. +
  301. + /* no reconfiguring after stop! */
  302. + return;
  303. + }
  304. +
  305. + /* do after stop to avoid reconfiguring when we stop anyway */
  306. + ieee80211_configure_filter(local);
  307. + ieee80211_hw_config(local, hw_reconf_flags);
  308. +
  309. + if (local->monitors == local->open_count)
  310. + ieee80211_add_virtual_monitor(local);
  311. +}
  312. +
  313. +static int ieee80211_stop(struct net_device *dev)
  314. +{
  315. + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  316. +
  317. + ieee80211_do_stop(sdata, true);
  318. +
  319. + return 0;
  320. +}
  321. +
  322. +static void ieee80211_set_multicast_list(struct net_device *dev)
  323. +{
  324. + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  325. + struct ieee80211_local *local = sdata->local;
  326. + int allmulti, sdata_allmulti;
  327. +
  328. + allmulti = !!(dev->flags & IFF_ALLMULTI);
  329. + sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI);
  330. +
  331. + if (allmulti != sdata_allmulti) {
  332. + if (dev->flags & IFF_ALLMULTI)
  333. + atomic_inc(&local->iff_allmultis);
  334. + else
  335. + atomic_dec(&local->iff_allmultis);
  336. + sdata->flags ^= IEEE80211_SDATA_ALLMULTI;
  337. + }
  338. +
  339. + spin_lock_bh(&local->filter_lock);
  340. + __hw_addr_sync(&local->mc_list, &dev->mc, dev->addr_len);
  341. + spin_unlock_bh(&local->filter_lock);
  342. + ieee80211_queue_work(&local->hw, &local->reconfig_filter);
  343. +}
  344. +
  345. +/*
  346. + * Called when the netdev is removed or, by the code below, before
  347. + * the interface type changes.
  348. + */
  349. +static void ieee80211_teardown_sdata(struct ieee80211_sub_if_data *sdata)
  350. +{
  351. + int i;
  352. +
  353. + /* free extra data */
  354. + ieee80211_free_keys(sdata, false);
  355. +
  356. + ieee80211_debugfs_remove_netdev(sdata);
  357. +
  358. + for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
  359. + __skb_queue_purge(&sdata->fragments[i].skb_list);
  360. + sdata->fragment_next = 0;
  361. +
  362. + if (ieee80211_vif_is_mesh(&sdata->vif))
  363. + ieee80211_mesh_teardown_sdata(sdata);
  364. +}
  365. +
  366. +static void ieee80211_uninit(struct net_device *dev)
  367. +{
  368. + ieee80211_teardown_sdata(IEEE80211_DEV_TO_SUB_IF(dev));
  369. +}
  370. +
  371. +#if LINUX_VERSION_IS_GEQ(5,2,0)
  372. +static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  373. + struct sk_buff *skb,
  374. + struct net_device *sb_dev)
  375. +#elif LINUX_VERSION_IS_GEQ(4,19,0)
  376. +static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  377. + struct sk_buff *skb,
  378. + struct net_device *sb_dev,
  379. + select_queue_fallback_t fallback)
  380. +#elif LINUX_VERSION_IS_GEQ(3,14,0) || \
  381. + (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
  382. +static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  383. + struct sk_buff *skb,
  384. + void *accel_priv,
  385. + select_queue_fallback_t fallback)
  386. +#elif LINUX_VERSION_IS_GEQ(3,13,0)
  387. +static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  388. + struct sk_buff *skb,
  389. + void *accel_priv)
  390. +#else
  391. +static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  392. + struct sk_buff *skb)
  393. +#endif
  394. +{
  395. + return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb);
  396. +}
  397. +
  398. +static void
  399. +ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
  400. +{
  401. + int i;
  402. +
  403. + for_each_possible_cpu(i) {
  404. + const struct pcpu_sw_netstats *tstats;
  405. + u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
  406. + unsigned int start;
  407. +
  408. + tstats = per_cpu_ptr(netdev_tstats(dev), i);
  409. +
  410. + do {
  411. + start = u64_stats_fetch_begin_irq(&tstats->syncp);
  412. + rx_packets = tstats->rx_packets;
  413. + tx_packets = tstats->tx_packets;
  414. + rx_bytes = tstats->rx_bytes;
  415. + tx_bytes = tstats->tx_bytes;
  416. + } while (u64_stats_fetch_retry_irq(&tstats->syncp, start));
  417. +
  418. + stats->rx_packets += rx_packets;
  419. + stats->tx_packets += tx_packets;
  420. + stats->rx_bytes += rx_bytes;
  421. + stats->tx_bytes += tx_bytes;
  422. + }
  423. +}
  424. +#if LINUX_VERSION_IS_LESS(4,11,0)
  425. +/* Just declare it here to keep sparse happy */
  426. +struct rtnl_link_stats64 *bp_ieee80211_get_stats64(struct net_device *dev,
  427. + struct rtnl_link_stats64 *stats);
  428. +struct rtnl_link_stats64 *
  429. +bp_ieee80211_get_stats64(struct net_device *dev,
  430. + struct rtnl_link_stats64 *stats){
  431. + ieee80211_get_stats64(dev, stats);
  432. + return stats;
  433. +}
  434. +#endif
  435. +
  436. +static const struct net_device_ops ieee80211_dataif_ops = {
  437. + .ndo_open = ieee80211_open,
  438. + .ndo_stop = ieee80211_stop,
  439. + .ndo_uninit = ieee80211_uninit,
  440. + .ndo_start_xmit = ieee80211_subif_start_xmit,
  441. + .ndo_set_rx_mode = ieee80211_set_multicast_list,
  442. + .ndo_set_mac_address = ieee80211_change_mac,
  443. + .ndo_select_queue = ieee80211_netdev_select_queue,
  444. +#if LINUX_VERSION_IS_GEQ(4,11,0)
  445. + .ndo_get_stats64 = ieee80211_get_stats64,
  446. +#else
  447. + .ndo_get_stats64 = bp_ieee80211_get_stats64,
  448. +#endif
  449. +
  450. +};
  451. +
  452. +#if LINUX_VERSION_IS_GEQ(5,2,0)
  453. +static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  454. + struct sk_buff *skb,
  455. + struct net_device *sb_dev)
  456. +#elif LINUX_VERSION_IS_GEQ(4,19,0)
  457. +static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  458. + struct sk_buff *skb,
  459. + struct net_device *sb_dev,
  460. + select_queue_fallback_t fallback)
  461. +#elif LINUX_VERSION_IS_GEQ(3,14,0) || \
  462. + (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
  463. +static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  464. + struct sk_buff *skb,
  465. + void *accel_priv,
  466. + select_queue_fallback_t fallback)
  467. +#elif LINUX_VERSION_IS_GEQ(3,13,0)
  468. +static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  469. + struct sk_buff *skb,
  470. + void *accel_priv)
  471. +#else
  472. +static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  473. + struct sk_buff *skb)
  474. +#endif
  475. +{
  476. + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  477. + struct ieee80211_local *local = sdata->local;
  478. + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  479. + struct ieee80211_hdr *hdr;
  480. + int len_rthdr;
  481. +
  482. + if (local->hw.queues < IEEE80211_NUM_ACS)
  483. + return 0;
  484. +
  485. + /* reset flags and info before parsing radiotap header */
  486. + memset(info, 0, sizeof(*info));
  487. +
  488. + if (!ieee80211_parse_tx_radiotap(skb, dev))
  489. + return 0; /* doesn't matter, frame will be dropped */
  490. +
  491. + len_rthdr = ieee80211_get_radiotap_len(skb->data);
  492. + hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr);
  493. + if (skb->len < len_rthdr + 2 ||
  494. + skb->len < len_rthdr + ieee80211_hdrlen(hdr->frame_control))
  495. + return 0; /* doesn't matter, frame will be dropped */
  496. +
  497. + return ieee80211_select_queue_80211(sdata, skb, hdr);
  498. +}
  499. +
  500. +static const struct net_device_ops ieee80211_monitorif_ops = {
  501. + .ndo_open = ieee80211_open,
  502. + .ndo_stop = ieee80211_stop,
  503. + .ndo_uninit = ieee80211_uninit,
  504. + .ndo_start_xmit = ieee80211_monitor_start_xmit,
  505. + .ndo_set_rx_mode = ieee80211_set_multicast_list,
  506. + .ndo_set_mac_address = ieee80211_change_mac,
  507. + .ndo_select_queue = ieee80211_monitor_select_queue,
  508. +#if LINUX_VERSION_IS_GEQ(4,11,0)
  509. + .ndo_get_stats64 = ieee80211_get_stats64,
  510. +#else
  511. + .ndo_get_stats64 = bp_ieee80211_get_stats64,
  512. +#endif
  513. +
  514. +};
  515. +
  516. +static const struct net_device_ops ieee80211_dataif_8023_ops = {
  517. + .ndo_open = ieee80211_open,
  518. + .ndo_stop = ieee80211_stop,
  519. + .ndo_uninit = ieee80211_uninit,
  520. + .ndo_start_xmit = ieee80211_subif_start_xmit_8023,
  521. + .ndo_set_rx_mode = ieee80211_set_multicast_list,
  522. + .ndo_set_mac_address = ieee80211_change_mac,
  523. + .ndo_select_queue = ieee80211_netdev_select_queue,
  524. +#if LINUX_VERSION_IS_GEQ(4,11,0)
  525. + .ndo_get_stats64 = ieee80211_get_stats64,
  526. +#else
  527. + .ndo_get_stats64 = bp_ieee80211_get_stats64,
  528. +#endif
  529. +
  530. +};
  531. +
  532. static bool ieee80211_iftype_supports_encap_offload(enum nl80211_iftype iftype)
  533. {
  534. switch (iftype) {
  535. @@ -389,6 +900,31 @@ static bool ieee80211_set_sdata_offload_
  536. return true;
  537. }
  538. +static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata)
  539. +{
  540. + struct ieee80211_local *local = sdata->local;
  541. + struct ieee80211_sub_if_data *bss = sdata;
  542. + bool enabled;
  543. +
  544. + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
  545. + if (!sdata->bss)
  546. + return;
  547. +
  548. + bss = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap);
  549. + }
  550. +
  551. + if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) ||
  552. + !ieee80211_iftype_supports_encap_offload(bss->vif.type))
  553. + return;
  554. +
  555. + enabled = bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED;
  556. + if (sdata->wdev.use_4addr &&
  557. + !(bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_4ADDR))
  558. + enabled = false;
  559. +
  560. + sdata->dev->netdev_ops = enabled ? &ieee80211_dataif_8023_ops :
  561. + &ieee80211_dataif_ops;
  562. +}
  563. static void ieee80211_recalc_sdata_offload(struct ieee80211_sub_if_data *sdata)
  564. {
  565. @@ -866,518 +1402,6 @@ int ieee80211_do_open(struct wireless_de
  566. return res;
  567. }
  568. -static int ieee80211_open(struct net_device *dev)
  569. -{
  570. - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  571. - int err;
  572. -
  573. - /* fail early if user set an invalid address */
  574. - if (!is_valid_ether_addr(dev->dev_addr))
  575. - return -EADDRNOTAVAIL;
  576. -
  577. - err = ieee80211_check_concurrent_iface(sdata, sdata->vif.type);
  578. - if (err)
  579. - return err;
  580. -
  581. - return ieee80211_do_open(&sdata->wdev, true);
  582. -}
  583. -
  584. -static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
  585. - bool going_down)
  586. -{
  587. - struct ieee80211_local *local = sdata->local;
  588. - unsigned long flags;
  589. - struct sk_buff *skb, *tmp;
  590. - u32 hw_reconf_flags = 0;
  591. - int i, flushed;
  592. - struct ps_data *ps;
  593. - struct cfg80211_chan_def chandef;
  594. - bool cancel_scan;
  595. - struct cfg80211_nan_func *func;
  596. -
  597. - clear_bit(SDATA_STATE_RUNNING, &sdata->state);
  598. -
  599. - cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata;
  600. - if (cancel_scan)
  601. - ieee80211_scan_cancel(local);
  602. -
  603. - /*
  604. - * Stop TX on this interface first.
  605. - */
  606. - if (sdata->dev)
  607. - netif_tx_stop_all_queues(sdata->dev);
  608. -
  609. - ieee80211_roc_purge(local, sdata);
  610. -
  611. - switch (sdata->vif.type) {
  612. - case NL80211_IFTYPE_STATION:
  613. - ieee80211_mgd_stop(sdata);
  614. - break;
  615. - case NL80211_IFTYPE_ADHOC:
  616. - ieee80211_ibss_stop(sdata);
  617. - break;
  618. - case NL80211_IFTYPE_MONITOR:
  619. - if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES)
  620. - break;
  621. - list_del_rcu(&sdata->u.mntr.list);
  622. - break;
  623. - default:
  624. - break;
  625. - }
  626. -
  627. - /*
  628. - * Remove all stations associated with this interface.
  629. - *
  630. - * This must be done before calling ops->remove_interface()
  631. - * because otherwise we can later invoke ops->sta_notify()
  632. - * whenever the STAs are removed, and that invalidates driver
  633. - * assumptions about always getting a vif pointer that is valid
  634. - * (because if we remove a STA after ops->remove_interface()
  635. - * the driver will have removed the vif info already!)
  636. - *
  637. - * In WDS mode a station must exist here and be flushed, for
  638. - * AP_VLANs stations may exist since there's nothing else that
  639. - * would have removed them, but in other modes there shouldn't
  640. - * be any stations.
  641. - */
  642. - flushed = sta_info_flush(sdata);
  643. - WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  644. - ((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) ||
  645. - (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1)));
  646. -
  647. - /* don't count this interface for allmulti while it is down */
  648. - if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
  649. - atomic_dec(&local->iff_allmultis);
  650. -
  651. - if (sdata->vif.type == NL80211_IFTYPE_AP) {
  652. - local->fif_pspoll--;
  653. - local->fif_probe_req--;
  654. - } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
  655. - local->fif_probe_req--;
  656. - }
  657. -
  658. - if (sdata->dev) {
  659. - netif_addr_lock_bh(sdata->dev);
  660. - spin_lock_bh(&local->filter_lock);
  661. - __hw_addr_unsync(&local->mc_list, &sdata->dev->mc,
  662. - sdata->dev->addr_len);
  663. - spin_unlock_bh(&local->filter_lock);
  664. - netif_addr_unlock_bh(sdata->dev);
  665. - }
  666. -
  667. - del_timer_sync(&local->dynamic_ps_timer);
  668. - cancel_work_sync(&local->dynamic_ps_enable_work);
  669. -
  670. - cancel_work_sync(&sdata->recalc_smps);
  671. - sdata_lock(sdata);
  672. - mutex_lock(&local->mtx);
  673. - sdata->vif.csa_active = false;
  674. - if (sdata->vif.type == NL80211_IFTYPE_STATION)
  675. - sdata->u.mgd.csa_waiting_bcn = false;
  676. - if (sdata->csa_block_tx) {
  677. - ieee80211_wake_vif_queues(local, sdata,
  678. - IEEE80211_QUEUE_STOP_REASON_CSA);
  679. - sdata->csa_block_tx = false;
  680. - }
  681. - mutex_unlock(&local->mtx);
  682. - sdata_unlock(sdata);
  683. -
  684. - cancel_work_sync(&sdata->csa_finalize_work);
  685. -
  686. - cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
  687. -
  688. - if (sdata->wdev.cac_started) {
  689. - chandef = sdata->vif.bss_conf.chandef;
  690. - WARN_ON(local->suspended);
  691. - mutex_lock(&local->mtx);
  692. - ieee80211_vif_release_channel(sdata);
  693. - mutex_unlock(&local->mtx);
  694. - cfg80211_cac_event(sdata->dev, &chandef,
  695. - NL80211_RADAR_CAC_ABORTED,
  696. - GFP_KERNEL);
  697. - }
  698. -
  699. - /* APs need special treatment */
  700. - if (sdata->vif.type == NL80211_IFTYPE_AP) {
  701. - struct ieee80211_sub_if_data *vlan, *tmpsdata;
  702. -
  703. - /* down all dependent devices, that is VLANs */
  704. - list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans,
  705. - u.vlan.list)
  706. - dev_close(vlan->dev);
  707. - WARN_ON(!list_empty(&sdata->u.ap.vlans));
  708. - } else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
  709. - /* remove all packets in parent bc_buf pointing to this dev */
  710. - ps = &sdata->bss->ps;
  711. -
  712. - spin_lock_irqsave(&ps->bc_buf.lock, flags);
  713. - skb_queue_walk_safe(&ps->bc_buf, skb, tmp) {
  714. - if (skb->dev == sdata->dev) {
  715. - __skb_unlink(skb, &ps->bc_buf);
  716. - local->total_ps_buffered--;
  717. - ieee80211_free_txskb(&local->hw, skb);
  718. - }
  719. - }
  720. - spin_unlock_irqrestore(&ps->bc_buf.lock, flags);
  721. - }
  722. -
  723. - if (going_down)
  724. - local->open_count--;
  725. -
  726. - switch (sdata->vif.type) {
  727. - case NL80211_IFTYPE_AP_VLAN:
  728. - mutex_lock(&local->mtx);
  729. - list_del(&sdata->u.vlan.list);
  730. - mutex_unlock(&local->mtx);
  731. - RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL);
  732. - /* see comment in the default case below */
  733. - ieee80211_free_keys(sdata, true);
  734. - /* no need to tell driver */
  735. - break;
  736. - case NL80211_IFTYPE_MONITOR:
  737. - if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) {
  738. - local->cooked_mntrs--;
  739. - break;
  740. - }
  741. -
  742. - local->monitors--;
  743. - if (local->monitors == 0) {
  744. - local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR;
  745. - hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
  746. - }
  747. -
  748. - ieee80211_adjust_monitor_flags(sdata, -1);
  749. - break;
  750. - case NL80211_IFTYPE_NAN:
  751. - /* clean all the functions */
  752. - spin_lock_bh(&sdata->u.nan.func_lock);
  753. -
  754. - idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, i) {
  755. - idr_remove(&sdata->u.nan.function_inst_ids, i);
  756. - cfg80211_free_nan_func(func);
  757. - }
  758. - idr_destroy(&sdata->u.nan.function_inst_ids);
  759. -
  760. - spin_unlock_bh(&sdata->u.nan.func_lock);
  761. - break;
  762. - case NL80211_IFTYPE_P2P_DEVICE:
  763. - /* relies on synchronize_rcu() below */
  764. - RCU_INIT_POINTER(local->p2p_sdata, NULL);
  765. - fallthrough;
  766. - default:
  767. - cancel_work_sync(&sdata->work);
  768. - /*
  769. - * When we get here, the interface is marked down.
  770. - * Free the remaining keys, if there are any
  771. - * (which can happen in AP mode if userspace sets
  772. - * keys before the interface is operating, and maybe
  773. - * also in WDS mode)
  774. - *
  775. - * Force the key freeing to always synchronize_net()
  776. - * to wait for the RX path in case it is using this
  777. - * interface enqueuing frames at this very time on
  778. - * another CPU.
  779. - */
  780. - ieee80211_free_keys(sdata, true);
  781. - skb_queue_purge(&sdata->skb_queue);
  782. - }
  783. -
  784. - spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
  785. - for (i = 0; i < IEEE80211_MAX_QUEUES; i++) {
  786. - skb_queue_walk_safe(&local->pending[i], skb, tmp) {
  787. - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  788. - if (info->control.vif == &sdata->vif) {
  789. - __skb_unlink(skb, &local->pending[i]);
  790. - ieee80211_free_txskb(&local->hw, skb);
  791. - }
  792. - }
  793. - }
  794. - spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
  795. -
  796. - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  797. - ieee80211_txq_remove_vlan(local, sdata);
  798. -
  799. - sdata->bss = NULL;
  800. -
  801. - if (local->open_count == 0)
  802. - ieee80211_clear_tx_pending(local);
  803. -
  804. - sdata->vif.bss_conf.beacon_int = 0;
  805. -
  806. - /*
  807. - * If the interface goes down while suspended, presumably because
  808. - * the device was unplugged and that happens before our resume,
  809. - * then the driver is already unconfigured and the remainder of
  810. - * this function isn't needed.
  811. - * XXX: what about WoWLAN? If the device has software state, e.g.
  812. - * memory allocated, it might expect teardown commands from
  813. - * mac80211 here?
  814. - */
  815. - if (local->suspended) {
  816. - WARN_ON(local->wowlan);
  817. - WARN_ON(rtnl_dereference(local->monitor_sdata));
  818. - return;
  819. - }
  820. -
  821. - switch (sdata->vif.type) {
  822. - case NL80211_IFTYPE_AP_VLAN:
  823. - break;
  824. - case NL80211_IFTYPE_MONITOR:
  825. - if (local->monitors == 0)
  826. - ieee80211_del_virtual_monitor(local);
  827. -
  828. - mutex_lock(&local->mtx);
  829. - ieee80211_recalc_idle(local);
  830. - mutex_unlock(&local->mtx);
  831. -
  832. - if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))
  833. - break;
  834. -
  835. - fallthrough;
  836. - default:
  837. - if (going_down)
  838. - drv_remove_interface(local, sdata);
  839. - }
  840. -
  841. - ieee80211_recalc_ps(local);
  842. -
  843. - if (cancel_scan)
  844. - flush_delayed_work(&local->scan_work);
  845. -
  846. - if (local->open_count == 0) {
  847. - ieee80211_stop_device(local);
  848. -
  849. - /* no reconfiguring after stop! */
  850. - return;
  851. - }
  852. -
  853. - /* do after stop to avoid reconfiguring when we stop anyway */
  854. - ieee80211_configure_filter(local);
  855. - ieee80211_hw_config(local, hw_reconf_flags);
  856. -
  857. - if (local->monitors == local->open_count)
  858. - ieee80211_add_virtual_monitor(local);
  859. -}
  860. -
  861. -static int ieee80211_stop(struct net_device *dev)
  862. -{
  863. - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  864. -
  865. - ieee80211_do_stop(sdata, true);
  866. -
  867. - return 0;
  868. -}
  869. -
  870. -static void ieee80211_set_multicast_list(struct net_device *dev)
  871. -{
  872. - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  873. - struct ieee80211_local *local = sdata->local;
  874. - int allmulti, sdata_allmulti;
  875. -
  876. - allmulti = !!(dev->flags & IFF_ALLMULTI);
  877. - sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI);
  878. -
  879. - if (allmulti != sdata_allmulti) {
  880. - if (dev->flags & IFF_ALLMULTI)
  881. - atomic_inc(&local->iff_allmultis);
  882. - else
  883. - atomic_dec(&local->iff_allmultis);
  884. - sdata->flags ^= IEEE80211_SDATA_ALLMULTI;
  885. - }
  886. -
  887. - spin_lock_bh(&local->filter_lock);
  888. - __hw_addr_sync(&local->mc_list, &dev->mc, dev->addr_len);
  889. - spin_unlock_bh(&local->filter_lock);
  890. - ieee80211_queue_work(&local->hw, &local->reconfig_filter);
  891. -}
  892. -
  893. -/*
  894. - * Called when the netdev is removed or, by the code below, before
  895. - * the interface type changes.
  896. - */
  897. -static void ieee80211_teardown_sdata(struct ieee80211_sub_if_data *sdata)
  898. -{
  899. - int i;
  900. -
  901. - /* free extra data */
  902. - ieee80211_free_keys(sdata, false);
  903. -
  904. - ieee80211_debugfs_remove_netdev(sdata);
  905. -
  906. - for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
  907. - __skb_queue_purge(&sdata->fragments[i].skb_list);
  908. - sdata->fragment_next = 0;
  909. -
  910. - if (ieee80211_vif_is_mesh(&sdata->vif))
  911. - ieee80211_mesh_teardown_sdata(sdata);
  912. -}
  913. -
  914. -static void ieee80211_uninit(struct net_device *dev)
  915. -{
  916. - ieee80211_teardown_sdata(IEEE80211_DEV_TO_SUB_IF(dev));
  917. -}
  918. -
  919. -#if LINUX_VERSION_IS_GEQ(5,2,0)
  920. -static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  921. - struct sk_buff *skb,
  922. - struct net_device *sb_dev)
  923. -#elif LINUX_VERSION_IS_GEQ(4,19,0)
  924. -static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  925. - struct sk_buff *skb,
  926. - struct net_device *sb_dev,
  927. - select_queue_fallback_t fallback)
  928. -#elif LINUX_VERSION_IS_GEQ(3,14,0) || \
  929. - (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
  930. -static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  931. - struct sk_buff *skb,
  932. - void *accel_priv,
  933. - select_queue_fallback_t fallback)
  934. -#elif LINUX_VERSION_IS_GEQ(3,13,0)
  935. -static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  936. - struct sk_buff *skb,
  937. - void *accel_priv)
  938. -#else
  939. -static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  940. - struct sk_buff *skb)
  941. -#endif
  942. -{
  943. - return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb);
  944. -}
  945. -
  946. -static void
  947. -ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
  948. -{
  949. - int i;
  950. -
  951. - for_each_possible_cpu(i) {
  952. - const struct pcpu_sw_netstats *tstats;
  953. - u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
  954. - unsigned int start;
  955. -
  956. - tstats = per_cpu_ptr(netdev_tstats(dev), i);
  957. -
  958. - do {
  959. - start = u64_stats_fetch_begin_irq(&tstats->syncp);
  960. - rx_packets = tstats->rx_packets;
  961. - tx_packets = tstats->tx_packets;
  962. - rx_bytes = tstats->rx_bytes;
  963. - tx_bytes = tstats->tx_bytes;
  964. - } while (u64_stats_fetch_retry_irq(&tstats->syncp, start));
  965. -
  966. - stats->rx_packets += rx_packets;
  967. - stats->tx_packets += tx_packets;
  968. - stats->rx_bytes += rx_bytes;
  969. - stats->tx_bytes += tx_bytes;
  970. - }
  971. -}
  972. -#if LINUX_VERSION_IS_LESS(4,11,0)
  973. -/* Just declare it here to keep sparse happy */
  974. -struct rtnl_link_stats64 *bp_ieee80211_get_stats64(struct net_device *dev,
  975. - struct rtnl_link_stats64 *stats);
  976. -struct rtnl_link_stats64 *
  977. -bp_ieee80211_get_stats64(struct net_device *dev,
  978. - struct rtnl_link_stats64 *stats){
  979. - ieee80211_get_stats64(dev, stats);
  980. - return stats;
  981. -}
  982. -#endif
  983. -
  984. -static const struct net_device_ops ieee80211_dataif_ops = {
  985. - .ndo_open = ieee80211_open,
  986. - .ndo_stop = ieee80211_stop,
  987. - .ndo_uninit = ieee80211_uninit,
  988. - .ndo_start_xmit = ieee80211_subif_start_xmit,
  989. - .ndo_set_rx_mode = ieee80211_set_multicast_list,
  990. - .ndo_set_mac_address = ieee80211_change_mac,
  991. - .ndo_select_queue = ieee80211_netdev_select_queue,
  992. -#if LINUX_VERSION_IS_GEQ(4,11,0)
  993. - .ndo_get_stats64 = ieee80211_get_stats64,
  994. -#else
  995. - .ndo_get_stats64 = bp_ieee80211_get_stats64,
  996. -#endif
  997. -
  998. -};
  999. -
  1000. -#if LINUX_VERSION_IS_GEQ(5,2,0)
  1001. -static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  1002. - struct sk_buff *skb,
  1003. - struct net_device *sb_dev)
  1004. -#elif LINUX_VERSION_IS_GEQ(4,19,0)
  1005. -static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  1006. - struct sk_buff *skb,
  1007. - struct net_device *sb_dev,
  1008. - select_queue_fallback_t fallback)
  1009. -#elif LINUX_VERSION_IS_GEQ(3,14,0) || \
  1010. - (LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
  1011. -static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  1012. - struct sk_buff *skb,
  1013. - void *accel_priv,
  1014. - select_queue_fallback_t fallback)
  1015. -#elif LINUX_VERSION_IS_GEQ(3,13,0)
  1016. -static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  1017. - struct sk_buff *skb,
  1018. - void *accel_priv)
  1019. -#else
  1020. -static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  1021. - struct sk_buff *skb)
  1022. -#endif
  1023. -{
  1024. - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1025. - struct ieee80211_local *local = sdata->local;
  1026. - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  1027. - struct ieee80211_hdr *hdr;
  1028. - int len_rthdr;
  1029. -
  1030. - if (local->hw.queues < IEEE80211_NUM_ACS)
  1031. - return 0;
  1032. -
  1033. - /* reset flags and info before parsing radiotap header */
  1034. - memset(info, 0, sizeof(*info));
  1035. -
  1036. - if (!ieee80211_parse_tx_radiotap(skb, dev))
  1037. - return 0; /* doesn't matter, frame will be dropped */
  1038. -
  1039. - len_rthdr = ieee80211_get_radiotap_len(skb->data);
  1040. - hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr);
  1041. - if (skb->len < len_rthdr + 2 ||
  1042. - skb->len < len_rthdr + ieee80211_hdrlen(hdr->frame_control))
  1043. - return 0; /* doesn't matter, frame will be dropped */
  1044. -
  1045. - return ieee80211_select_queue_80211(sdata, skb, hdr);
  1046. -}
  1047. -
  1048. -static const struct net_device_ops ieee80211_monitorif_ops = {
  1049. - .ndo_open = ieee80211_open,
  1050. - .ndo_stop = ieee80211_stop,
  1051. - .ndo_uninit = ieee80211_uninit,
  1052. - .ndo_start_xmit = ieee80211_monitor_start_xmit,
  1053. - .ndo_set_rx_mode = ieee80211_set_multicast_list,
  1054. - .ndo_set_mac_address = ieee80211_change_mac,
  1055. - .ndo_select_queue = ieee80211_monitor_select_queue,
  1056. -#if LINUX_VERSION_IS_GEQ(4,11,0)
  1057. - .ndo_get_stats64 = ieee80211_get_stats64,
  1058. -#else
  1059. - .ndo_get_stats64 = bp_ieee80211_get_stats64,
  1060. -#endif
  1061. -
  1062. -};
  1063. -
  1064. -static const struct net_device_ops ieee80211_dataif_8023_ops = {
  1065. - .ndo_open = ieee80211_open,
  1066. - .ndo_stop = ieee80211_stop,
  1067. - .ndo_uninit = ieee80211_uninit,
  1068. - .ndo_start_xmit = ieee80211_subif_start_xmit_8023,
  1069. - .ndo_set_rx_mode = ieee80211_set_multicast_list,
  1070. - .ndo_set_mac_address = ieee80211_change_mac,
  1071. - .ndo_select_queue = ieee80211_netdev_select_queue,
  1072. -#if LINUX_VERSION_IS_GEQ(4,11,0)
  1073. - .ndo_get_stats64 = ieee80211_get_stats64,
  1074. -#else
  1075. - .ndo_get_stats64 = bp_ieee80211_get_stats64,
  1076. -#endif
  1077. -
  1078. -};
  1079. -
  1080. static void ieee80211_if_free(struct net_device *dev)
  1081. {
  1082. free_percpu(netdev_tstats(dev));
  1083. @@ -1408,32 +1432,6 @@ static void ieee80211_if_setup_no_queue(
  1084. #endif
  1085. }
  1086. -static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata)
  1087. -{
  1088. - struct ieee80211_local *local = sdata->local;
  1089. - struct ieee80211_sub_if_data *bss = sdata;
  1090. - bool enabled;
  1091. -
  1092. - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
  1093. - if (!sdata->bss)
  1094. - return;
  1095. -
  1096. - bss = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap);
  1097. - }
  1098. -
  1099. - if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) ||
  1100. - !ieee80211_iftype_supports_encap_offload(bss->vif.type))
  1101. - return;
  1102. -
  1103. - enabled = bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED;
  1104. - if (sdata->wdev.use_4addr &&
  1105. - !(bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_4ADDR))
  1106. - enabled = false;
  1107. -
  1108. - sdata->dev->netdev_ops = enabled ? &ieee80211_dataif_8023_ops :
  1109. - &ieee80211_dataif_ops;
  1110. -}
  1111. -
  1112. static void ieee80211_iface_work(struct work_struct *work)
  1113. {
  1114. struct ieee80211_sub_if_data *sdata =