Skip to content

Commit 80d1b90

Browse files
ajaykathatajaysk
authored andcommitted
wilc1000: added featurization for kernel 4.x
Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
1 parent 07689a8 commit 80d1b90

7 files changed

Lines changed: 188 additions & 21 deletions

File tree

drivers/net/wireless/microchip/wilc1000/cfg80211.c

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,15 @@ static void cfg_scan_result(enum scan_event scan_event,
143143
mutex_lock(&priv->scan_req_lock);
144144

145145
if (priv->scan_req) {
146+
#if KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE
146147
struct cfg80211_scan_info info = {
147148
.aborted = false,
148149
};
149150

150151
cfg80211_scan_done(priv->scan_req, &info);
152+
#else
153+
cfg80211_scan_done(priv->scan_req, false);
154+
#endif
151155
priv->cfg_scanning = false;
152156
priv->scan_req = NULL;
153157
}
@@ -157,11 +161,16 @@ static void cfg_scan_result(enum scan_event scan_event,
157161

158162
PRINT_INFO(priv->dev, CFG80211_DBG, "Scan Aborted\n");
159163
if (priv->scan_req) {
164+
#if KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE
160165
struct cfg80211_scan_info info = {
161166
.aborted = false,
162167
};
163168

164169
cfg80211_scan_done(priv->scan_req, &info);
170+
#else
171+
cfg80211_scan_done(priv->scan_req, false);
172+
#endif
173+
165174
priv->cfg_scanning = false;
166175
priv->scan_req = NULL;
167176
}
@@ -178,7 +187,9 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status,
178187
struct wilc *wl = vif->wilc;
179188
struct host_if_drv *wfi_drv = priv->hif_drv;
180189
struct wilc_conn_info *conn_info = &wfi_drv->conn_info;
190+
#if KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE
181191
struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
192+
#endif
182193

183194
vif->connecting = false;
184195

@@ -215,6 +226,7 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status,
215226
PRINT_INFO(vif->ndev, CFG80211_DBG,
216227
"Association response info elements length = %d\n",
217228
conn_info->resp_ies_len);
229+
#if KERNEL_VERSION(4, 11, 0) <= LINUX_VERSION_CODE
218230
cfg80211_ref_bss(wiphy, vif->bss);
219231
cfg80211_connect_bss(dev, conn_info->bssid, vif->bss,
220232
conn_info->req_ies,
@@ -223,7 +235,22 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status,
223235
conn_info->resp_ies_len,
224236
connect_status, GFP_KERNEL,
225237
NL80211_TIMEOUT_UNSPECIFIED);
226-
238+
#elif KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE
239+
cfg80211_ref_bss(wiphy, vif->bss);
240+
cfg80211_connect_bss(dev, conn_info->bssid, vif->bss,
241+
conn_info->req_ies,
242+
conn_info->req_ies_len,
243+
conn_info->resp_ies,
244+
conn_info->resp_ies_len,
245+
connect_status, GFP_KERNEL);
246+
#else
247+
cfg80211_connect_result(dev, conn_info->bssid,
248+
conn_info->req_ies,
249+
conn_info->req_ies_len,
250+
conn_info->resp_ies,
251+
conn_info->resp_ies_len, connect_status,
252+
GFP_KERNEL);
253+
#endif
227254
vif->bss = NULL;
228255
} else if (conn_disconn_evt == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
229256
u16 reason = 0;
@@ -242,8 +269,11 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status,
242269
else
243270
reason = 1;
244271
}
245-
272+
#if KERNEL_VERSION(4, 2, 0) > LINUX_VERSION_CODE
273+
cfg80211_disconnected(dev, reason, NULL, 0, GFP_KERNEL);
274+
#else
246275
cfg80211_disconnected(dev, reason, NULL, 0, false, GFP_KERNEL);
276+
#endif
247277
}
248278
}
249279

@@ -481,9 +511,15 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
481511
goto out_error;
482512
}
483513

514+
#if KERNEL_VERSION(4, 1, 0) > LINUX_VERSION_CODE
515+
bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid, sme->ssid,
516+
sme->ssid_len, WLAN_CAPABILITY_ESS,
517+
WLAN_CAPABILITY_ESS);
518+
#else
484519
bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid, sme->ssid,
485520
sme->ssid_len, IEEE80211_BSS_TYPE_ANY,
486521
IEEE80211_PRIVACY(sme->privacy));
522+
#endif
487523
if (!bss) {
488524
ret = -EINVAL;
489525
goto out_error;
@@ -1194,8 +1230,11 @@ bool wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size)
11941230
return true;
11951231
}
11961232

1233+
#if KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE
11971234
freq = ieee80211_channel_to_frequency(wl->op_ch, NL80211_BAND_2GHZ);
1198-
1235+
#else
1236+
freq = ieee80211_channel_to_frequency(wl->op_ch, IEEE80211_BAND_2GHZ);
1237+
#endif
11991238
mgmt = (struct ieee80211_mgmt *)buff;
12001239
PRINT_D(vif->ndev, GENERIC_DBG, "Rx Frame Type:%x\n",
12011240
mgmt->frame_control);
@@ -1299,6 +1338,10 @@ static int remain_on_channel(struct wiphy *wiphy,
12991338
priv->remain_on_ch_params.listen_duration = duration;
13001339

13011340
cfg80211_ready_on_channel(wdev, *cookie, chan, duration, GFP_KERNEL);
1341+
1342+
#if KERNEL_VERSION(4, 15, 0) > LINUX_VERSION_CODE
1343+
vif->hif_drv->remain_on_ch_timer.data = (unsigned long)vif->hif_drv;
1344+
#endif
13021345
mod_timer(&vif->hif_drv->remain_on_ch_timer,
13031346
jiffies + msecs_to_jiffies(duration + 1000));
13041347

@@ -1552,9 +1595,15 @@ static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
15521595
return 0;
15531596
}
15541597

1598+
#if KERNEL_VERSION(4, 11, 0) <= LINUX_VERSION_CODE
15551599
static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
15561600
enum nl80211_iftype type,
15571601
struct vif_params *params)
1602+
#else
1603+
static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
1604+
enum nl80211_iftype type, u32 *flags,
1605+
struct vif_params *params)
1606+
#endif
15581607
{
15591608
struct wilc *wl = wiphy_priv(wiphy);
15601609
struct wilc_vif *vif = netdev_priv(dev);
@@ -2272,7 +2321,11 @@ struct wilc *wilc_create_wiphy(struct device *dev)
22722321
wl->band.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
22732322
wl->band.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
22742323

2324+
#if KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE
22752325
wiphy->bands[NL80211_BAND_2GHZ] = &wl->band;
2326+
#else
2327+
wiphy->bands[IEEE80211_BAND_2GHZ] = &wl->band;
2328+
#endif
22762329

22772330
wiphy->max_scan_ssids = WILC_MAX_NUM_PROBED_SSID;
22782331
#ifdef CONFIG_PM
@@ -2322,7 +2375,12 @@ int wilc_init_host_int(struct net_device *net)
23222375
struct wilc_priv *priv = &vif->priv;
23232376

23242377
PRINT_INFO(net, INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
2378+
2379+
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
23252380
timer_setup(&priv->eap_buff_timer, eap_buff_timeout, 0);
2381+
#else
2382+
setup_timer(&priv->eap_buff_timer, eap_buff_timeout, 0);
2383+
#endif
23262384

23272385
vif->p2p_listen_state = false;
23282386

drivers/net/wireless/microchip/wilc1000/hif.c

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
317317
wid_list[index].val = (s8 *)&scan_type;
318318
index++;
319319

320+
#if KERNEL_VERSION(4, 8, 0) > LINUX_VERSION_CODE
321+
scan_timeout = WILC_HIF_SCAN_TIMEOUT_MS;
322+
#else
320323
if (scan_type == WILC_FW_PASSIVE_SCAN && request->duration) {
321324
wid_list[index].id = WID_PASSIVE_SCAN_TIME;
322325
wid_list[index].type = WID_SHORT;
@@ -328,7 +331,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
328331
} else {
329332
scan_timeout = WILC_HIF_SCAN_TIMEOUT_MS;
330333
}
331-
334+
#endif
332335
wid_list[index].id = WID_SCAN_CHANNEL_LIST;
333336
wid_list[index].type = WID_BIN_DATA;
334337

@@ -360,6 +363,9 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
360363
hif_drv->scan_timer_vif = vif;
361364
PRINT_INFO(vif->ndev, HOSTINF_DBG,
362365
">> Starting the SCAN timer\n");
366+
#if KERNEL_VERSION(4, 15, 0) > LINUX_VERSION_CODE
367+
hif_drv->scan_timer.data = (unsigned long)hif_drv;
368+
#endif
363369
mod_timer(&hif_drv->scan_timer,
364370
jiffies + msecs_to_jiffies(scan_timeout));
365371
}
@@ -1172,10 +1178,18 @@ static void wilc_handle_listen_state_expired(struct work_struct *work)
11721178
kfree(msg);
11731179
}
11741180

1181+
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
11751182
static void listen_timer_cb(struct timer_list *t)
1183+
#else
1184+
static void listen_timer_cb(unsigned long arg)
1185+
#endif
11761186
{
1187+
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
11771188
struct host_if_drv *hif_drv = from_timer(hif_drv, t,
11781189
remain_on_ch_timer);
1190+
#else
1191+
struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
1192+
#endif
11791193
struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif;
11801194
int result;
11811195
struct host_if_msg *msg;
@@ -1277,9 +1291,17 @@ static void handle_scan_complete(struct work_struct *work)
12771291
kfree(msg);
12781292
}
12791293

1294+
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
12801295
static void timer_scan_cb(struct timer_list *t)
1296+
#else
1297+
static void timer_scan_cb(unsigned long arg)
1298+
#endif
12811299
{
1300+
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
12821301
struct host_if_drv *hif_drv = from_timer(hif_drv, t, scan_timer);
1302+
#else
1303+
struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
1304+
#endif
12831305
struct wilc_vif *vif = hif_drv->scan_timer_vif;
12841306
struct host_if_msg *msg;
12851307
int result;
@@ -1293,10 +1315,17 @@ static void timer_scan_cb(struct timer_list *t)
12931315
kfree(msg);
12941316
}
12951317

1318+
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
12961319
static void timer_connect_cb(struct timer_list *t)
1320+
#else
1321+
static void timer_connect_cb(unsigned long arg)
1322+
#endif
12971323
{
1298-
struct host_if_drv *hif_drv = from_timer(hif_drv, t,
1299-
connect_timer);
1324+
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
1325+
struct host_if_drv *hif_drv = from_timer(hif_drv, t, connect_timer);
1326+
#else
1327+
struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
1328+
#endif
13001329
struct wilc_vif *vif = hif_drv->connect_timer_vif;
13011330
struct host_if_msg *msg;
13021331
int result;
@@ -1659,6 +1688,9 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
16591688
goto free_ies;
16601689
}
16611690

1691+
#if KERNEL_VERSION(4, 15, 0) > LINUX_VERSION_CODE
1692+
hif_drv->connect_timer.data = (unsigned long)hif_drv;
1693+
#endif
16621694
hif_drv->connect_timer_vif = vif;
16631695
mod_timer(&hif_drv->connect_timer,
16641696
jiffies + msecs_to_jiffies(WILC_HIF_CONNECT_TIMEOUT_MS));
@@ -1826,9 +1858,17 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param)
18261858
return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, i);
18271859
}
18281860

1861+
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
18291862
static void get_periodic_rssi(struct timer_list *t)
1863+
#else
1864+
static void get_periodic_rssi(unsigned long arg)
1865+
#endif
18301866
{
1867+
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
18311868
struct wilc_vif *vif = from_timer(vif, t, periodic_rssi);
1869+
#else
1870+
struct wilc_vif *vif = (struct wilc_vif *)arg;
1871+
#endif
18321872

18331873
if (!vif->hif_drv) {
18341874
netdev_err(vif->ndev, "%s: hif driver is NULL", __func__);
@@ -1854,12 +1894,19 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
18541894
*hif_drv_handler = hif_drv;
18551895
vif->hif_drv = hif_drv;
18561896

1857-
timer_setup(&vif->periodic_rssi, get_periodic_rssi, 0);
1858-
mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000));
1859-
1897+
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
18601898
timer_setup(&hif_drv->scan_timer, timer_scan_cb, 0);
18611899
timer_setup(&hif_drv->connect_timer, timer_connect_cb, 0);
18621900
timer_setup(&hif_drv->remain_on_ch_timer, listen_timer_cb, 0);
1901+
timer_setup(&vif->periodic_rssi, get_periodic_rssi, 0);
1902+
#else
1903+
setup_timer(&hif_drv->scan_timer, timer_scan_cb, 0);
1904+
setup_timer(&hif_drv->connect_timer, timer_connect_cb, 0);
1905+
setup_timer(&hif_drv->remain_on_ch_timer, listen_timer_cb, 0);
1906+
setup_timer(&vif->periodic_rssi, get_periodic_rssi,
1907+
(unsigned long)vif);
1908+
#endif
1909+
mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000));
18631910

18641911
hif_drv->hif_state = HOST_IF_IDLE;
18651912

drivers/net/wireless/microchip/wilc1000/mon.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ void wilc_wfi_handle_monitor_rx(struct wilc *wilc, u8 *buff, u32 size)
3939
"Monitor if: No memory to allocate skb");
4040
return;
4141
}
42+
#if KERNEL_VERSION(4, 13, 0) <= LINUX_VERSION_CODE
4243
skb_put_data(skb, buff, size);
4344
hdr = skb_push(skb, sizeof(*hdr));
45+
#else
46+
memcpy(skb_put(skb, size), buff, size);
47+
hdr = (struct wilc_wfi_radiotap_hdr *)skb_push(skb, sizeof(*hdr));
48+
#endif
4449
memset(hdr, 0, sizeof(*hdr));
4550
hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
4651
hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
@@ -93,9 +98,15 @@ void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size)
9398
"Monitor if : No memory to allocate skb");
9499
return;
95100
}
101+
#if KERNEL_VERSION(4, 13, 0) <= LINUX_VERSION_CODE
96102
skb_put_data(skb, buff, size);
97103

98104
cb_hdr = skb_push(skb, sizeof(*cb_hdr));
105+
#else
106+
memcpy(skb_put(skb, size), buff, size);
107+
cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *)skb_push(skb,
108+
sizeof(*cb_hdr));
109+
#endif
99110
memset(cb_hdr, 0, sizeof(*cb_hdr));
100111

101112
cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
@@ -116,11 +127,19 @@ void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size)
116127
} else {
117128
skb = dev_alloc_skb(size + sizeof(*hdr));
118129

119-
if (!skb)
130+
if (!skb) {
131+
PRINT_D(mon_dev, HOSTAPD_DBG,
132+
"Monitor if : No memory to allocate skb");
120133
return;
121-
134+
}
135+
#if KERNEL_VERSION(4, 13, 0) <= LINUX_VERSION_CODE
122136
skb_put_data(skb, buff, size);
123137
hdr = skb_push(skb, sizeof(*hdr));
138+
#else
139+
memcpy(skb_put(skb, size), buff, size);
140+
hdr = (struct wilc_wfi_radiotap_hdr *)skb_push(skb,
141+
sizeof(*hdr));
142+
#endif
124143
memset(hdr, 0, sizeof(*hdr));
125144
hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
126145
hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
@@ -270,8 +289,11 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
270289
wl->monitor_dev->type = ARPHRD_IEEE80211_RADIOTAP;
271290
strlcpy(wl->monitor_dev->name, name, IFNAMSIZ);
272291
wl->monitor_dev->netdev_ops = &wilc_wfi_netdev_ops;
292+
#if KERNEL_VERSION(4, 11, 9) <= LINUX_VERSION_CODE
273293
wl->monitor_dev->needs_free_netdev = true;
274-
294+
#else
295+
wl->monitor_dev->destructor = free_netdev;
296+
#endif
275297
if (register_netdevice(wl->monitor_dev)) {
276298
PRINT_ER(real_dev, "register_netdevice failed\n");
277299
free_netdev(wl->monitor_dev);

0 commit comments

Comments
 (0)