linux-recent.patch 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. Since Linux 4.7, the enum ieee80211_band is no longer used
  2. This shall cause no problem's since both enums ieee80211_band
  3. and nl80211_band were added in the same commit:
  4. https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=13ae75b103e07304a34ab40c9136e9f53e06475c
  5. This patch refactors the references of IEEE80211_BAND_* to NL80211_BAND_*
  6. Reference:
  7. https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=57fbcce37be7c1d2622b56587c10ade00e96afa3
  8. --- a/src/wl/sys/wl_cfg80211_hybrid.c 2016-06-13 11:57:36.159340297 -0500
  9. +++ b/src/wl/sys/wl_cfg80211_hybrid.c 2016-06-13 11:58:18.442323435 -0500
  10. @@ -236,7 +236,7 @@
  11. #endif
  12. #define CHAN2G(_channel, _freq, _flags) { \
  13. - .band = IEEE80211_BAND_2GHZ, \
  14. + .band = NL80211_BAND_2GHZ, \
  15. .center_freq = (_freq), \
  16. .hw_value = (_channel), \
  17. .flags = (_flags), \
  18. @@ -245,7 +245,7 @@
  19. }
  20. #define CHAN5G(_channel, _flags) { \
  21. - .band = IEEE80211_BAND_5GHZ, \
  22. + .band = NL80211_BAND_5GHZ, \
  23. .center_freq = 5000 + (5 * (_channel)), \
  24. .hw_value = (_channel), \
  25. .flags = (_flags), \
  26. @@ -379,7 +379,7 @@
  27. };
  28. static struct ieee80211_supported_band __wl_band_2ghz = {
  29. - .band = IEEE80211_BAND_2GHZ,
  30. + .band = NL80211_BAND_2GHZ,
  31. .channels = __wl_2ghz_channels,
  32. .n_channels = ARRAY_SIZE(__wl_2ghz_channels),
  33. .bitrates = wl_g_rates,
  34. @@ -387,7 +387,7 @@
  35. };
  36. static struct ieee80211_supported_band __wl_band_5ghz_a = {
  37. - .band = IEEE80211_BAND_5GHZ,
  38. + .band = NL80211_BAND_5GHZ,
  39. .channels = __wl_5ghz_a_channels,
  40. .n_channels = ARRAY_SIZE(__wl_5ghz_a_channels),
  41. .bitrates = wl_a_rates,
  42. @@ -395,7 +395,7 @@
  43. };
  44. static struct ieee80211_supported_band __wl_band_5ghz_n = {
  45. - .band = IEEE80211_BAND_5GHZ,
  46. + .band = NL80211_BAND_5GHZ,
  47. .channels = __wl_5ghz_n_channels,
  48. .n_channels = ARRAY_SIZE(__wl_5ghz_n_channels),
  49. .bitrates = wl_a_rates,
  50. @@ -1876,8 +1876,8 @@
  51. wdev->wiphy->max_num_pmkids = WL_NUM_PMKIDS_MAX;
  52. #endif
  53. wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC);
  54. - wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &__wl_band_2ghz;
  55. - wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_a;
  56. + wdev->wiphy->bands[NL80211_BAND_2GHZ] = &__wl_band_2ghz;
  57. + wdev->wiphy->bands[NL80211_BAND_5GHZ] = &__wl_band_5ghz_a;
  58. wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
  59. wdev->wiphy->cipher_suites = __wl_cipher_suites;
  60. wdev->wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites);
  61. @@ -2000,7 +2000,7 @@
  62. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
  63. freq = ieee80211_channel_to_frequency(notif_bss_info->channel,
  64. (notif_bss_info->channel <= CH_MAX_2G_CHANNEL) ?
  65. - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ);
  66. + NL80211_BAND_2GHZ : NL80211_BAND_5GHZ);
  67. #else
  68. freq = ieee80211_channel_to_frequency(notif_bss_info->channel);
  69. #endif
  70. @@ -2116,7 +2116,7 @@
  71. return err;
  72. }
  73. chan = wf_chspec_ctlchan(chanspec);
  74. - band = (chan <= CH_MAX_2G_CHANNEL) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
  75. + band = (chan <= CH_MAX_2G_CHANNEL) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
  76. freq = ieee80211_channel_to_frequency(chan, band);
  77. channel = ieee80211_get_channel(wiphy, freq);
  78. cfg80211_ibss_joined(ndev, (u8 *)&wl->bssid, channel, GFP_KERNEL);
  79. @@ -2250,10 +2250,10 @@
  80. join_params->params.chanspec_list[0] =
  81. ieee80211_frequency_to_channel(chan->center_freq);
  82. - if (chan->band == IEEE80211_BAND_2GHZ) {
  83. + if (chan->band == NL80211_BAND_2GHZ) {
  84. chanspec |= WL_CHANSPEC_BAND_2G;
  85. }
  86. - else if (chan->band == IEEE80211_BAND_5GHZ) {
  87. + else if (chan->band == NL80211_BAND_5GHZ) {
  88. chanspec |= WL_CHANSPEC_BAND_5G;
  89. }
  90. else {
  91. @@ -2885,7 +2885,7 @@
  92. if (phy == 'n' || phy == 'a' || phy == 'v') {
  93. wiphy = wl_to_wiphy(wl);
  94. - wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_n;
  95. + wiphy->bands[NL80211_BAND_5GHZ] = &__wl_band_5ghz_n;
  96. }
  97. return err;
  98. diff --git a/src/wl/sys/wl_linux.c.orig b/src/wl/sys/wl_linux.c
  99. index eb00717..489c9f5 100644
  100. --- a/src/wl/sys/wl_linux.c.orig
  101. +++ b/src/wl/sys/wl_linux.c
  102. @@ -2166,8 +2166,8 @@ wl_start(struct sk_buff *skb, struct net_device *dev)
  103. wlif = WL_DEV_IF(dev);
  104. wl = WL_INFO(dev);
  105. + skb->prev = NULL;
  106. if (WL_ALL_PASSIVE_ENAB(wl) || (WL_RTR() && WL_CONFIG_SMP())) {
  107. - skb->prev = NULL;
  108. TXQ_LOCK(wl);
  109. --- a/src/wl/sys/wl_linux.h 2015-09-18 18:47:30.000000000 -0400
  110. +++ b/src/wl/sys/wl_linux.h 2016-10-03 22:42:26.703139289 -0400
  111. @@ -18,6 +18,11 @@
  112. * $Id: wl_linux.h 369548 2012-11-19 09:01:01Z $
  113. */
  114. +#define ieee80211_band nl80211_band
  115. +#define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ
  116. +#define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ
  117. +#define IEEE80211_NUM_BANDS NUM_NL80211_BANDS
  118. +
  119. #ifndef _wl_linux_h_
  120. #define _wl_linux_h_
  121. --- a/src/wl/sys/wl_cfg80211_hybrid.h 2016-10-03 22:45:53.849952542 -0400
  122. +++ b/src/wl/sys/wl_cfg80211_hybrid.h 2016-10-03 22:46:07.208589657 -0400
  123. @@ -19,6 +19,11 @@
  124. * $Id: wl_cfg80211.h,v 1.1.8.1 2011-01-26 00:57:46 $
  125. */
  126. +#define ieee80211_band nl80211_band
  127. +#define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ
  128. +#define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ
  129. +#define IEEE80211_NUM_BANDS NUM_NL80211_BANDS
  130. +
  131. #ifndef _wl_cfg80211_h_
  132. #define _wl_cfg80211_h_
  133. --- a/src/wl/sys/wl_cfg80211_hybrid.c 2016-10-03 10:53:55.588036464 +0200
  134. +++ b/src/wl/sys/wl_cfg80211_hybrid.c 2016-10-03 10:54:11.911695944 +0200
  135. @@ -2386,8 +2386,15 @@
  136. s32 err = 0;
  137. if (wl->scan_request) {
  138. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
  139. + struct cfg80211_scan_info info = {
  140. + .aborted = true
  141. + };
  142. WL_DBG(("%s: Aborting scan\n", __FUNCTION__));
  143. - cfg80211_scan_done(wl->scan_request, true);
  144. + cfg80211_scan_done(wl->scan_request, &info);
  145. +#else
  146. + cfg80211_scan_done(wl->scan_request, true);
  147. +#endif
  148. wl->scan_request = NULL;
  149. }
  150. @@ -2488,7 +2495,14 @@
  151. scan_done_out:
  152. if (wl->scan_request) {
  153. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
  154. + struct cfg80211_scan_info info = {
  155. + .aborted = false
  156. + };
  157. + cfg80211_scan_done(wl->scan_request, &info);
  158. +#else
  159. cfg80211_scan_done(wl->scan_request, false);
  160. +#endif
  161. wl->scan_request = NULL;
  162. }
  163. rtnl_unlock();
  164. @@ -2913,7 +2927,14 @@
  165. s32 err = 0;
  166. if (wl->scan_request) {
  167. - cfg80211_scan_done(wl->scan_request, true);
  168. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
  169. + struct cfg80211_scan_info info = {
  170. + .aborted = true
  171. + };
  172. + cfg80211_scan_done(wl->scan_request, &info);
  173. +#else
  174. + cfg80211_scan_done(wl->scan_request, true);
  175. +#endif
  176. wl->scan_request = NULL;
  177. }
  178. diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
  179. index a9671e2..da36405 100644
  180. --- a/src/wl/sys/wl_cfg80211_hybrid.c
  181. +++ b/src/wl/sys/wl_cfg80211_hybrid.c
  182. @@ -30,6 +30,9 @@
  183. #include <linux/kthread.h>
  184. #include <linux/netdevice.h>
  185. #include <linux/ieee80211.h>
  186. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
  187. +#include <linux/sched/signal.h>
  188. +#endif
  189. #include <net/cfg80211.h>
  190. #include <linux/nl80211.h>
  191. #include <net/rtnetlink.h>
  192. diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
  193. index 489c9f5..f8278ad 100644
  194. --- a/src/wl/sys/wl_linux.c
  195. +++ b/src/wl/sys/wl_linux.c
  196. @@ -117,6 +117,9 @@ int wl_found = 0;
  197. typedef struct priv_link {
  198. wl_if_t *wlif;
  199. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
  200. + unsigned long last_rx;
  201. +#endif
  202. } priv_link_t;
  203. #define WL_DEV_IF(dev) ((wl_if_t*)((priv_link_t*)DEV_PRIV(dev))->wlif)
  204. @@ -2450,6 +2453,9 @@ wl_monitor(wl_info_t *wl, wl_rxsts_t *rxsts, void *p)
  205. {
  206. struct sk_buff *oskb = (struct sk_buff *)p;
  207. struct sk_buff *skb;
  208. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
  209. + priv_link_t *priv_link;
  210. +#endif
  211. uchar *pdata;
  212. uint len;
  213. @@ -2916,7 +2922,13 @@ wl_monitor(wl_info_t *wl, wl_rxsts_t *rxsts, void *p)
  214. if (skb == NULL) return;
  215. skb->dev = wl->monitor_dev;
  216. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
  217. + priv_link = MALLOC(wl->osh, sizeof(priv_link_t));
  218. + priv_link = netdev_priv(skb->dev);
  219. + priv_link->last_rx = jiffies;
  220. +#else
  221. skb->dev->last_rx = jiffies;
  222. +#endif
  223. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
  224. skb_reset_mac_header(skb);
  225. #else
  226. diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
  227. index da36405..d3741eb 100644
  228. --- a/src/wl/sys/wl_cfg80211_hybrid.c
  229. +++ b/src/wl/sys/wl_cfg80211_hybrid.c
  230. @@ -53,7 +53,11 @@ u32 wl_dbg_level = WL_DBG_ERR;
  231. #endif
  232. static s32 wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
  233. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
  234. + enum nl80211_iftype type, struct vif_params *params);
  235. +#else
  236. enum nl80211_iftype type, u32 *flags, struct vif_params *params);
  237. +#endif
  238. #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
  239. static s32
  240. wl_cfg80211_scan(struct wiphy *wiphy,
  241. @@ -466,7 +470,11 @@ wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
  242. static s32
  243. wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
  244. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
  245. + enum nl80211_iftype type,
  246. +#else
  247. enum nl80211_iftype type, u32 *flags,
  248. +#endif
  249. struct vif_params *params)
  250. {
  251. struct wl_cfg80211_priv *wl = wiphy_to_wl(wiphy);
  252. @@ -2361,6 +2369,20 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
  253. const wl_event_msg_t *e, void *data)
  254. {
  255. struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
  256. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
  257. + struct cfg80211_bss *bss;
  258. + struct wlc_ssid *ssid;
  259. + ssid = &wl->profile->ssid;
  260. + bss = cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
  261. + ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
  262. + struct cfg80211_roam_info roam_info = {
  263. + .bss = bss,
  264. + .req_ie = conn_info->req_ie,
  265. + .req_ie_len = conn_info->req_ie_len,
  266. + .resp_ie = conn_info->resp_ie,
  267. + .resp_ie_len = conn_info->resp_ie_len,
  268. + };
  269. +#endif
  270. s32 err = 0;
  271. wl_get_assoc_ies(wl);
  272. @@ -2368,12 +2390,17 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
  273. memcpy(&wl->bssid, &e->addr, ETHER_ADDR_LEN);
  274. wl_update_bss_info(wl);
  275. cfg80211_roamed(ndev,
  276. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
  277. + &roam_info,
  278. +#else
  279. #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)
  280. &wl->conf->channel,
  281. #endif
  282. (u8 *)&wl->bssid,
  283. conn_info->req_ie, conn_info->req_ie_len,
  284. - conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL);
  285. + conn_info->resp_ie, conn_info->resp_ie_len,
  286. +#endif
  287. + GFP_KERNEL);
  288. WL_DBG(("Report roaming result\n"));
  289. set_bit(WL_STATUS_CONNECTED, &wl->status);
  290. diff -urNZ a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
  291. --- a/src/wl/sys/wl_linux.c 2015-09-18 22:47:30.000000000 +0000
  292. +++ b/src/wl/sys/wl_linux.c 2018-01-31 22:52:10.859856221 +0000
  293. @@ -93,7 +93,11 @@
  294. #include <wlc_wowl.h>
  295. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
  296. +static void wl_timer(struct timer_list *tl);
  297. +#else
  298. static void wl_timer(ulong data);
  299. +#endif
  300. static void _wl_timer(wl_timer_t *t);
  301. static struct net_device *wl_alloc_linux_if(wl_if_t *wlif);
  302. @@ -2298,9 +2302,15 @@
  303. }
  304. static void
  305. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
  306. +wl_timer(struct timer_list *tl)
  307. +{
  308. + wl_timer_t *t = from_timer(t, tl, timer);
  309. +#else
  310. wl_timer(ulong data)
  311. {
  312. wl_timer_t *t = (wl_timer_t *)data;
  313. +#endif
  314. if (!WL_ALL_PASSIVE_ENAB(t->wl))
  315. _wl_timer(t);
  316. @@ -2352,9 +2362,13 @@
  317. bzero(t, sizeof(wl_timer_t));
  318. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
  319. + timer_setup(&t->timer, wl_timer, 0);
  320. +#else
  321. init_timer(&t->timer);
  322. t->timer.data = (ulong) t;
  323. t->timer.function = wl_timer;
  324. +#endif
  325. t->wl = wl;
  326. t->fn = fn;
  327. t->arg = arg;
  328. diff --git a/src/shared/linux_osl.c b/src/shared/linux_osl.c
  329. index 6157d18..8237ec7 100644
  330. --- a/src/shared/linux_osl.c
  331. +++ b/src/shared/linux_osl.c
  332. @@ -942,7 +942,7 @@ osl_getcycles(void)
  333. void *
  334. osl_reg_map(uint32 pa, uint size)
  335. {
  336. - return (ioremap_nocache((unsigned long)pa, (unsigned long)size));
  337. + return (ioremap((unsigned long)pa, (unsigned long)size));
  338. }
  339. void
  340. diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
  341. index 0d05100..2ed1f0d 100644
  342. --- a/src/wl/sys/wl_linux.c
  343. +++ b/src/wl/sys/wl_linux.c
  344. @@ -582,7 +582,7 @@ wl_attach(uint16 vendor, uint16 device, ulong regs,
  345. }
  346. wl->bcm_bustype = bustype;
  347. - if ((wl->regsva = ioremap_nocache(dev->base_addr, PCI_BAR0_WINSZ)) == NULL) {
  348. + if ((wl->regsva = ioremap(dev->base_addr, PCI_BAR0_WINSZ)) == NULL) {
  349. WL_ERROR(("wl%d: ioremap() failed\n", unit));
  350. goto fail;
  351. }
  352. @@ -772,7 +772,7 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  353. if ((val & 0x0000ff00) != 0)
  354. pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
  355. bar1_size = pci_resource_len(pdev, 2);
  356. - bar1_addr = (uchar *)ioremap_nocache(pci_resource_start(pdev, 2),
  357. + bar1_addr = (uchar *)ioremap(pci_resource_start(pdev, 2),
  358. bar1_size);
  359. wl = wl_attach(pdev->vendor, pdev->device, pci_resource_start(pdev, 0), PCI_BUS, pdev,
  360. pdev->irq, bar1_addr, bar1_size);
  361. @@ -3335,12 +3335,19 @@ wl_proc_write(struct file *filp, const char __user *buff, size_t length, loff_t
  362. }
  363. #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
  364. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
  365. +static struct proc_ops wl_fops = {
  366. + .proc_read = wl_proc_read,
  367. + .proc_write = wl_proc_write,
  368. +};
  369. +#else
  370. static const struct file_operations wl_fops = {
  371. .owner = THIS_MODULE,
  372. .read = wl_proc_read,
  373. .write = wl_proc_write,
  374. };
  375. #endif
  376. +#endif
  377. static int
  378. wl_reg_proc_entry(wl_info_t *wl)
  379. diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
  380. index 7b606e0..1e0adb7 100644
  381. --- a/src/wl/sys/wl_cfg80211_hybrid.c
  382. +++ b/src/wl/sys/wl_cfg80211_hybrid.c
  383. @@ -38,6 +38,7 @@
  384. #include <wlioctl.h>
  385. #include <proto/802.11.h>
  386. #include <wl_cfg80211_hybrid.h>
  387. +#include <wl_linux.h>
  388. #define EVENT_TYPE(e) dtoh32((e)->event_type)
  389. #define EVENT_FLAGS(e) dtoh16((e)->flags)
  390. @@ -435,30 +436,7 @@ static void key_endian_to_host(struct wl_wsec_key *key)
  391. static s32
  392. wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
  393. {
  394. - struct ifreq ifr;
  395. - struct wl_ioctl ioc;
  396. - mm_segment_t fs;
  397. - s32 err = 0;
  398. -
  399. - BUG_ON(len < sizeof(int));
  400. -
  401. - memset(&ioc, 0, sizeof(ioc));
  402. - ioc.cmd = cmd;
  403. - ioc.buf = arg;
  404. - ioc.len = len;
  405. - strcpy(ifr.ifr_name, dev->name);
  406. - ifr.ifr_data = (caddr_t)&ioc;
  407. -
  408. - fs = get_fs();
  409. - set_fs(get_ds());
  410. -#if defined(WL_USE_NETDEV_OPS)
  411. - err = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
  412. -#else
  413. - err = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
  414. -#endif
  415. - set_fs(fs);
  416. -
  417. - return err;
  418. + return wlc_ioctl_internal(dev, cmd, arg, len);
  419. }
  420. static s32
  421. diff --git a/src/wl/sys/wl_iw.c b/src/wl/sys/wl_iw.c
  422. index c4c610b..e346b15 100644
  423. --- a/src/wl/sys/wl_iw.c
  424. +++ b/src/wl/sys/wl_iw.c
  425. @@ -37,6 +37,7 @@ typedef const struct si_pub si_t;
  426. #include <wl_dbg.h>
  427. #include <wl_iw.h>
  428. +#include <wl_linux.h>
  429. extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
  430. uint32 reason, char* stringBuf, uint buflen);
  431. @@ -103,29 +104,7 @@ dev_wlc_ioctl(
  432. int len
  433. )
  434. {
  435. - struct ifreq ifr;
  436. - wl_ioctl_t ioc;
  437. - mm_segment_t fs;
  438. - int ret;
  439. -
  440. - memset(&ioc, 0, sizeof(ioc));
  441. - ioc.cmd = cmd;
  442. - ioc.buf = arg;
  443. - ioc.len = len;
  444. -
  445. - strcpy(ifr.ifr_name, dev->name);
  446. - ifr.ifr_data = (caddr_t) &ioc;
  447. -
  448. - fs = get_fs();
  449. - set_fs(get_ds());
  450. -#if defined(WL_USE_NETDEV_OPS)
  451. - ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
  452. -#else
  453. - ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
  454. -#endif
  455. - set_fs(fs);
  456. -
  457. - return ret;
  458. + return wlc_ioctl_internal(dev, cmd, arg, len);
  459. }
  460. static int
  461. diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
  462. index 947cef3..f04c148 100644
  463. --- a/src/wl/sys/wl_linux.c
  464. +++ b/src/wl/sys/wl_linux.c
  465. @@ -1643,10 +1643,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  466. goto done2;
  467. }
  468. - if (segment_eq(get_fs(), KERNEL_DS))
  469. - buf = ioc.buf;
  470. -
  471. - else if (ioc.buf) {
  472. + if (ioc.buf) {
  473. if (!(buf = (void *) MALLOC(wl->osh, MAX(ioc.len, WLC_IOCTL_MAXLEN)))) {
  474. bcmerror = BCME_NORESOURCE;
  475. goto done2;
  476. @@ -1667,7 +1664,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  477. WL_UNLOCK(wl);
  478. done1:
  479. - if (ioc.buf && (ioc.buf != buf)) {
  480. + if (ioc.buf) {
  481. if (copy_to_user(ioc.buf, buf, ioc.len))
  482. bcmerror = BCME_BADADDR;
  483. MFREE(wl->osh, buf, MAX(ioc.len, WLC_IOCTL_MAXLEN));
  484. @@ -1680,6 +1677,39 @@ done2:
  485. return (OSL_ERROR(bcmerror));
  486. }
  487. +int
  488. +wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len)
  489. +{
  490. + wl_info_t *wl;
  491. + wl_if_t *wlif;
  492. + int bcmerror;
  493. +
  494. + if (!dev)
  495. + return -ENETDOWN;
  496. +
  497. + wl = WL_INFO(dev);
  498. + wlif = WL_DEV_IF(dev);
  499. + if (wlif == NULL || wl == NULL || wl->dev == NULL)
  500. + return -ENETDOWN;
  501. +
  502. + bcmerror = 0;
  503. +
  504. + WL_TRACE(("wl%d: wlc_ioctl_internal: cmd 0x%x\n", wl->pub->unit, cmd));
  505. +
  506. + WL_LOCK(wl);
  507. + if (!capable(CAP_NET_ADMIN)) {
  508. + bcmerror = BCME_EPERM;
  509. + } else {
  510. + bcmerror = wlc_ioctl(wl->wlc, cmd, buf, len, wlif->wlcif);
  511. + }
  512. + WL_UNLOCK(wl);
  513. +
  514. + ASSERT(VALID_BCMERROR(bcmerror));
  515. + if (bcmerror != 0)
  516. + wl->pub->bcmerror = bcmerror;
  517. + return (OSL_ERROR(bcmerror));
  518. +}
  519. +
  520. static struct net_device_stats*
  521. wl_get_stats(struct net_device *dev)
  522. {
  523. diff --git a/src/wl/sys/wl_linux.h b/src/wl/sys/wl_linux.h
  524. index 5b1048e..c8c1f41 100644
  525. --- a/src/wl/sys/wl_linux.h
  526. +++ b/src/wl/sys/wl_linux.h
  527. @@ -22,6 +22,7 @@
  528. #define _wl_linux_h_
  529. #include <wlc_types.h>
  530. +#include <wlc_pub.h>
  531. typedef struct wl_timer {
  532. struct timer_list timer;
  533. @@ -187,6 +188,7 @@ extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs);
  534. extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
  535. extern void wl_free(wl_info_t *wl);
  536. extern int wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
  537. +extern int wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len);
  538. extern struct net_device * wl_netdev_get(wl_info_t *wl);
  539. #endif
  540. diff --git a/src/wl/sys/wlc_pub.h b/src/wl/sys/wlc_pub.h
  541. index 53a98b8..2b5a029 100644
  542. --- a/src/wl/sys/wlc_pub.h
  543. +++ b/src/wl/sys/wlc_pub.h
  544. @@ -24,6 +24,7 @@
  545. #include <wlc_types.h>
  546. #include <wlc_utils.h>
  547. +#include <siutils.h>
  548. #include "proto/802.11.h"
  549. #include "proto/bcmevent.h"
  550. diff -u -r a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
  551. --- a/src/wl/sys/wl_linux.c 2022-03-23 00:35:42.930416350 +0000
  552. +++ b/src/wl/sys/wl_linux.c 2022-03-23 00:40:12.903771013 +0000
  553. @@ -2980,7 +2980,11 @@
  554. else
  555. dev->type = ARPHRD_IEEE80211_RADIOTAP;
  556. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)
  557. bcopy(wl->dev->dev_addr, dev->dev_addr, ETHER_ADDR_LEN);
  558. +#else
  559. + eth_hw_addr_set(wl->dev, dev->dev_addr);
  560. +#endif
  561. #if defined(WL_USE_NETDEV_OPS)
  562. dev->netdev_ops = &wl_netdev_monitor_ops;
  563. @@ -3261,7 +3265,11 @@
  564. static ssize_t
  565. wl_proc_read(struct file *filp, char __user *buffer, size_t length, loff_t *offp)
  566. {
  567. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)
  568. wl_info_t * wl = PDE_DATA(file_inode(filp));
  569. +#else
  570. + wl_info_t * wl = pde_data(file_inode(filp));
  571. +#endif
  572. #endif
  573. int bcmerror, len;
  574. int to_user = 0;
  575. @@ -3318,7 +3326,11 @@
  576. static ssize_t
  577. wl_proc_write(struct file *filp, const char __user *buff, size_t length, loff_t *offp)
  578. {
  579. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)
  580. wl_info_t * wl = PDE_DATA(file_inode(filp));
  581. +#else
  582. + wl_info_t * wl = pde_data(file_inode(filp));
  583. +#endif
  584. #endif
  585. int from_user = 0;
  586. int bcmerror;
  587. diff -u -r a/src/shared/linux_osl.c b/src/shared/linux_osl.c
  588. --- a/src/shared/linux_osl.c 2022-05-24 20:51:15.662604980 +0000
  589. +++ b/src/shared/linux_osl.c 2022-05-24 21:13:38.264472425 +0000
  590. @@ -599,6 +599,8 @@
  591. va = kmalloc(size, GFP_ATOMIC | __GFP_ZERO);
  592. if (va)
  593. *pap = (ulong)__virt_to_phys(va);
  594. +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  595. + va = dma_alloc_coherent(&((struct pci_dev *)osh->pdev)->dev, size, (dma_addr_t*)pap, GFP_ATOMIC);
  596. #else
  597. va = pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap);
  598. #endif
  599. @@ -612,6 +614,8 @@
  600. #ifdef __ARM_ARCH_7A__
  601. kfree(va);
  602. +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  603. + dma_free_coherent(&((struct pci_dev *)osh->pdev)->dev, size, va, (dma_addr_t)pa);
  604. #else
  605. pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
  606. #endif
  607. @@ -623,7 +627,11 @@
  608. int dir;
  609. ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
  610. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  611. + dir = (direction == DMA_TX)? DMA_TO_DEVICE: DMA_FROM_DEVICE;
  612. +#else
  613. dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
  614. +#endif
  615. #if defined(__ARM_ARCH_7A__) && defined(BCMDMASGLISTOSL)
  616. if (dmah != NULL) {
  617. @@ -641,7 +649,11 @@
  618. ASSERT(totsegs + nsegs <= MAX_DMA_SEGS);
  619. sg->page_link = 0;
  620. sg_set_buf(sg, PKTDATA(osh, skb), PKTLEN(osh, skb));
  621. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  622. + dma_map_single(&((struct pci_dev *)osh->pdev)->dev, PKTDATA(osh, skb), PKTLEN(osh, skb), dir);
  623. +#else
  624. pci_map_single(osh->pdev, PKTDATA(osh, skb), PKTLEN(osh, skb), dir);
  625. +#endif
  626. }
  627. totsegs += nsegs;
  628. totlen += PKTLEN(osh, skb);
  629. @@ -656,7 +668,11 @@
  630. }
  631. #endif
  632. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  633. + return (dma_map_single(&((struct pci_dev *)osh->pdev)->dev, va, size, dir));
  634. +#else
  635. return (pci_map_single(osh->pdev, va, size, dir));
  636. +#endif
  637. }
  638. void BCMFASTPATH
  639. @@ -665,8 +681,13 @@
  640. int dir;
  641. ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
  642. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  643. + dir = (direction == DMA_TX)? DMA_TO_DEVICE: DMA_FROM_DEVICE;
  644. + dma_unmap_single(&((struct pci_dev *)osh->pdev)->dev, (uint32)pa, size, dir);
  645. +#else
  646. dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
  647. pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
  648. +#endif
  649. }
  650. #if defined(BCMDBG_ASSERT)