at v206 12 kB view raw
1--- a/src/wl/sys/wl_cfg80211_hybrid.c 2014-06-26 12:42:08.000000000 +0200 2+++ b/src/wl/sys/wl_cfg80211_hybrid.c 2015-04-13 13:20:08.140013177 +0200 3@@ -63,8 +63,13 @@ 4 static s32 wl_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, 5 struct cfg80211_ibss_params *params); 6 static s32 wl_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev); 7+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) 8 static s32 wl_cfg80211_get_station(struct wiphy *wiphy, 9 struct net_device *dev, u8 *mac, struct station_info *sinfo); 10+#else 11+static s32 wl_cfg80211_get_station(struct wiphy *wiphy, 12+ struct net_device *dev, const u8 *mac, struct station_info *sinfo); 13+#endif 14 static s32 wl_cfg80211_set_power_mgmt(struct wiphy *wiphy, 15 struct net_device *dev, bool enabled, s32 timeout); 16 static int wl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, 17@@ -1387,7 +1392,7 @@ 18 key_endian_to_host(&key); 19 20 params.key_len = (u8) min_t(u8, DOT11_MAX_KEY_SIZE, key.len); 21- memcpy(params.key, key.data, params.key_len); 22+ memcpy((char *)params.key, key.data, params.key_len); 23 24 if ((err = wl_dev_ioctl(dev, WLC_GET_WSEC, &wsec, sizeof(wsec)))) { 25 return err; 26@@ -1421,9 +1426,15 @@ 27 return err; 28 } 29 30+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) 31 static s32 32 wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, 33 u8 *mac, struct station_info *sinfo) 34+#else 35+static s32 36+wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, 37+ const u8 *mac, struct station_info *sinfo) 38+#endif 39 { 40 struct wl_cfg80211_priv *wl = wiphy_to_wl(wiphy); 41 scb_val_t scb_val; 42@@ -1441,7 +1452,11 @@ 43 WL_DBG(("Could not get rate (%d)\n", err)); 44 } else { 45 rate = dtoh32(rate); 46+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) 47 sinfo->filled |= STATION_INFO_TX_BITRATE; 48+#else 49+ sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE); 50+#endif 51 sinfo->txrate.legacy = rate * 5; 52 WL_DBG(("Rate %d Mbps\n", (rate / 2))); 53 } 54@@ -1454,7 +1469,11 @@ 55 return err; 56 } 57 rssi = dtoh32(scb_val.val); 58+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) 59 sinfo->filled |= STATION_INFO_SIGNAL; 60+#else 61+ sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); 62+#endif 63 sinfo->signal = rssi; 64 WL_DBG(("RSSI %d dBm\n", rssi)); 65 } 66@@ -2010,9 +2029,15 @@ 67 68 notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); 69 notify_ielen = le32_to_cpu(bi->ie_length); 70+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0) 71 cbss = cfg80211_inform_bss(wiphy, channel, (const u8 *)(bi->BSSID.octet), 72 0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int, 73 (const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL); 74+#else 75+ cbss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, (const u8 *)(bi->BSSID.octet), 76+ 0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int, 77+ (const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL); 78+#endif 79 80 if (unlikely(!cbss)) 81 return -ENOMEM; 82@@ -2047,7 +2072,11 @@ 83 } 84 else if ((event == WLC_E_LINK && ~(flags & WLC_EVENT_MSG_LINK)) || 85 event == WLC_E_DEAUTH_IND || event == WLC_E_DISASSOC_IND) { 86+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) 87+ cfg80211_disconnected(ndev, 0, NULL, 0, false, GFP_KERNEL); 88+#else 89 cfg80211_disconnected(ndev, 0, NULL, 0, GFP_KERNEL); 90+#endif 91 clear_bit(WL_STATUS_CONNECTED, &wl->status); 92 wl_link_down(wl); 93 wl_init_prof(wl->profile); 94@@ -2071,7 +2100,26 @@ 95 wl_get_assoc_ies(wl); 96 memcpy(&wl->bssid, &e->addr, ETHER_ADDR_LEN); 97 wl_update_bss_info(wl); 98+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0) 99+ { 100+ struct wl_bss_info *bi; 101+ u16 bss_info_channel; 102+ struct ieee80211_channel *channel; 103+ u32 freq; 104+ 105+ bi = (struct wl_bss_info *)(wl->extra_buf + 4); 106+ bss_info_channel = bi->ctl_ch ? bi->ctl_ch : CHSPEC_CHANNEL(bi->chanspec); 107+ 108+ freq = ieee80211_channel_to_frequency(bss_info_channel, 109+ (bss_info_channel <= CH_MAX_2G_CHANNEL) ? 110+ IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ); 111+ 112+ channel = ieee80211_get_channel(wl_to_wiphy(wl), freq); 113+ cfg80211_ibss_joined(ndev, (u8 *)&wl->bssid, channel, GFP_KERNEL); 114+ } 115+#else 116 cfg80211_ibss_joined(ndev, (u8 *)&wl->bssid, GFP_KERNEL); 117+#endif 118 set_bit(WL_STATUS_CONNECTED, &wl->status); 119 wl->profile->active = true; 120 } 121@@ -2629,7 +2677,15 @@ 122 123 void wl_cfg80211_detach(struct net_device *ndev) 124 { 125- struct wl_cfg80211_priv *wl = ndev_to_wl(ndev); 126+ struct wl_cfg80211_priv *wl; 127+ struct wireless_dev *wdev; 128+ 129+ wdev = ndev->ieee80211_ptr; 130+ if (wdev == NULL) { 131+ printk(KERN_ERR "[%s()] in ndev=%p: IEEE80211ptr=%p\n", __FUNCTION__, ndev, wdev); 132+ return; 133+ } 134+ wl = ndev_to_wl(ndev); 135 136 wl_deinit_cfg80211_priv(wl); 137 wl_free_wdev(wl); 138--- a/src/wl/sys/wl_dbg.h 2014-06-26 12:42:08.000000000 +0200 139+++ b/src/wl/sys/wl_dbg.h 2015-04-13 13:19:52.443345832 +0200 140@@ -55,10 +55,12 @@ 141 142 #define WL_NONE(args) 143 144+#define FORCE_TRACE_LEVEL(fmt, ...) do { printk(KERN_ERR fmt, ## __VA_ARGS__); } while (0) /* ## is GCC specific syntax to remove comma when single arg */ 145+ 146 #ifdef BCMDBG_ERR 147 #define WL_ERROR(args) WL_PRINT(args) 148 #else 149-#define WL_ERROR(args) 150+#define WL_ERROR(args) FORCE_TRACE_LEVEL args 151 #endif 152 #define WL_TRACE(args) 153 #define WL_APSTA_UPDN(args) 154--- a/src/wl/sys/wl_linux.c 2014-06-26 12:42:08.000000000 +0200 155+++ b/src/wl/sys/wl_linux.c 2015-04-13 13:19:52.443345832 +0200 156@@ -878,7 +878,7 @@ 157 static SIMPLE_DEV_PM_OPS(wl_pm_ops, wl_suspend, wl_resume); 158 #endif 159 160-static struct pci_driver wl_pci_driver = { 161+static struct pci_driver wl_pci_driver __refdata = { 162 .name = "wl", 163 .probe = wl_pci_probe, 164 .remove = __devexit_p(wl_remove), 165@@ -1270,6 +1270,7 @@ 166 MFREE(wl->osh, wlif->dev, sizeof(struct net_device)); 167 #else 168 free_netdev(wlif->dev); 169+ wlif->dev = NULL; 170 #endif 171 } 172 173@@ -1307,7 +1308,12 @@ 174 dev->priv = priv_link; 175 #else 176 177+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)) 178 dev = alloc_netdev(sizeof(priv_link_t), intf_name, ether_setup); 179+#else 180+ dev = alloc_netdev(sizeof(priv_link_t), intf_name, NET_NAME_UNKNOWN, 181+ ether_setup); 182+#endif 183 if (!dev) { 184 WL_ERROR(("wl%d: %s: alloc_netdev failed\n", 185 (wl->pub)?wl->pub->unit:wlif->subunit, __FUNCTION__)); 186@@ -1651,11 +1657,7 @@ 187 } 188 189 WL_LOCK(wl); 190- if (!capable(CAP_NET_ADMIN)) { 191- bcmerror = BCME_EPERM; 192- } else { 193- bcmerror = wlc_ioctl(wl->wlc, ioc.cmd, buf, ioc.len, wlif->wlcif); 194- } 195+ bcmerror = wlc_ioctl(wl->wlc, ioc.cmd, buf, ioc.len, wlif->wlcif); 196 WL_UNLOCK(wl); 197 198 done1: 199@@ -2157,8 +2159,8 @@ 200 wlif = WL_DEV_IF(dev); 201 wl = WL_INFO(dev); 202 203+ skb->prev = NULL; 204 if (WL_ALL_PASSIVE_ENAB(wl) || (WL_RTR() && WL_CONFIG_SMP())) { 205- skb->prev = NULL; 206 207 TXQ_LOCK(wl); 208 209@@ -2455,8 +2457,10 @@ 210 p80211msg_t *phdr; 211 212 len = sizeof(p80211msg_t) + oskb->len - D11_PHY_HDR_LEN; 213- if ((skb = dev_alloc_skb(len)) == NULL) 214+ if ((skb = dev_alloc_skb(len)) == NULL) { 215+ WL_ERROR(("in %s:%d [%s()] dev_alloc_skb() failure!", __FILE__, __LINE__, __FUNCTION__)); 216 return; 217+ } 218 219 skb_put(skb, len); 220 phdr = (p80211msg_t*)skb->data; 221@@ -2535,8 +2539,10 @@ 222 rtap_len = sizeof(wl_radiotap_ht_brcm_2_t); 223 224 len = rtap_len + (oskb->len - D11_PHY_HDR_LEN); 225- if ((skb = dev_alloc_skb(len)) == NULL) 226+ if ((skb = dev_alloc_skb(len)) == NULL) { 227+ WL_ERROR(("in %s:%d [%s()] dev_alloc_skb() failure!", __FILE__, __LINE__, __FUNCTION__)); 228 return; 229+ } 230 231 skb_put(skb, len); 232 233@@ -2664,8 +2670,10 @@ 234 len += amsdu_len; 235 } 236 237- if ((skb = dev_alloc_skb(len)) == NULL) 238+ if ((skb = dev_alloc_skb(len)) == NULL) { 239+ WL_ERROR(("in %s:%d [%s()] dev_alloc_skb() failure!", __FILE__, __LINE__, __FUNCTION__)); 240 return; 241+ } 242 243 skb_put(skb, len); 244 245@@ -2990,7 +2998,7 @@ 246 } 247 248 void 249-wl_set_monitor(wl_info_t *wl, int val) 250+wl_set_monitor(wl_info_t *wl, int val) /* public => is called by wlc_hybrid.o_shipped */ 251 { 252 const char *devname; 253 wl_if_t *wlif; 254@@ -3224,42 +3232,75 @@ 255 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) 256 static int 257 wl_proc_read(char *buffer, char **start, off_t offset, int length, int *eof, void *data) 258+{ 259+ wl_info_t * wl = (wl_info_t *)data; 260 #else 261 static ssize_t 262-wl_proc_read(struct file *filp, char __user *buffer, size_t length, loff_t *data) 263-#endif 264+wl_proc_read(struct file *filp, char __user *buffer, size_t length, loff_t *offp) 265 { 266- wl_info_t * wl = (wl_info_t *)data; 267- int to_user; 268- int len; 269+ wl_info_t * wl = PDE_DATA(file_inode(filp)); 270+#endif 271+ int bcmerror, len; 272+ int to_user = 0; 273+ char tmp[8]; 274 275 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) 276 if (offset > 0) { 277 *eof = 1; 278 return 0; 279 } 280+#else 281+ if (*offp > 0) { /* for example, stop: cat /proc/brcm_monitor0 */ 282+ return 0; /* 0 <=> EOF */ 283+ } 284 #endif 285 286- if (!length) { 287- WL_ERROR(("%s: Not enough return buf space\n", __FUNCTION__)); 288- return 0; 289- } 290 WL_LOCK(wl); 291- wlc_ioctl(wl->wlc, WLC_GET_MONITOR, &to_user, sizeof(int), NULL); 292- len = sprintf(buffer, "%d\n", to_user); 293- WL_UNLOCK(wl); 294- return len; 295+ bcmerror = wlc_ioctl(wl->wlc, WLC_GET_MONITOR, &to_user, sizeof(int), NULL); 296+ WL_UNLOCK(wl); 297+ 298+ if (bcmerror != BCME_OK) { 299+ WL_ERROR(("%s: GET_MONITOR failed with %d\n", __FUNCTION__, bcmerror)); 300+ return -EIO; 301+ } 302+ 303+ len = snprintf(tmp, ARRAY_SIZE(tmp), "%d\n", to_user); 304+ tmp[ARRAY_SIZE(tmp) - 1] = '\0'; 305+ if (len >= ARRAY_SIZE(tmp)) { 306+ printk(KERN_ERR "%s:%d [%s()] output would be truncated (ret=%d)!", __FILE__, __LINE__, __FUNCTION__, len); 307+ return -ERANGE; 308+ } 309+ else if (len < 0) { 310+ printk(KERN_ERR "%s:%d [%s()] unable to convert value (ret=%d)!", __FILE__, __LINE__, __FUNCTION__, len); 311+ return len; 312+ } 313+ if (length < len) { 314+ printk(KERN_ERR "%s:%d [%s()] user buffer is too small (at least=%d ; user=%d)!", __FILE__, __LINE__, __FUNCTION__, len, (int)length); 315+ return -EMSGSIZE; 316+ } 317+ if (copy_to_user(buffer, tmp, len) != 0) { 318+ printk(KERN_ERR "%s:%d [%s()] unable to copy data!", __FILE__, __LINE__, __FUNCTION__); 319+ return -EFAULT; 320+ } 321+ 322+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) 323+ *offp += len; 324+#endif 325+ 326+ return len; 327 } 328 329 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) 330 static int 331 wl_proc_write(struct file *filp, const char *buff, unsigned long length, void *data) 332+{ 333+ wl_info_t * wl = (wl_info_t *)data; 334 #else 335 static ssize_t 336-wl_proc_write(struct file *filp, const char __user *buff, size_t length, loff_t *data) 337-#endif 338+wl_proc_write(struct file *filp, const char __user *buff, size_t length, loff_t *offp) 339 { 340- wl_info_t * wl = (wl_info_t *)data; 341+ wl_info_t * wl = PDE_DATA(file_inode(filp)); 342+#endif 343 int from_user = 0; 344 int bcmerror; 345 346@@ -3270,7 +3311,11 @@ 347 } 348 if (copy_from_user(&from_user, buff, 1)) { 349 WL_ERROR(("%s: copy from user failed\n", __FUNCTION__)); 350- return -EIO; 351+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) 352+ return -EIO; 353+#else 354+ return -EFAULT; 355+#endif 356 } 357 358 if (from_user >= 0x30) 359@@ -3280,10 +3325,15 @@ 360 bcmerror = wlc_ioctl(wl->wlc, WLC_SET_MONITOR, &from_user, sizeof(int), NULL); 361 WL_UNLOCK(wl); 362 363- if (bcmerror < 0) { 364+ if (bcmerror != BCME_OK) { 365 WL_ERROR(("%s: SET_MONITOR failed with %d\n", __FUNCTION__, bcmerror)); 366 return -EIO; 367 } 368+ 369+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) && 0 /* no need to update offset because this file should only trigger action... */ 370+ *offp += length; 371+#endif 372+ 373 return length; 374 } 375 376@@ -3304,8 +3354,8 @@ 377 if ((wl->proc_entry = create_proc_entry(tmp, 0644, NULL)) == NULL) { 378 WL_ERROR(("%s: create_proc_entry %s failed\n", __FUNCTION__, tmp)); 379 #else 380- if ((wl->proc_entry = proc_create(tmp, 0644, NULL, &wl_fops)) == NULL) { 381- WL_ERROR(("%s: proc_create %s failed\n", __FUNCTION__, tmp)); 382+ if ((wl->proc_entry = proc_create_data(tmp, 0644, NULL, &wl_fops, wl)) == NULL) { 383+ WL_ERROR(("%s: proc_create_data %s failed\n", __FUNCTION__, tmp)); 384 #endif 385 ASSERT(0); 386 return -1;