[PATCH] staging: wilc1000: update wilc1000 driver maintainer ids

2018-10-29 Thread Ajay.Kathat
From: Ajay Singh 

We would like to update the maintainer email id's for wilc1000 driver.

Signed-off-by: Ajay Singh 
Signed-off-by: Adham Abozaeid 
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7c7af53..9647ec7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13837,8 +13837,8 @@ S:  Odd Fixes
 F: drivers/staging/vt665?/
 
 STAGING - WILC1000 WIFI DRIVER
-M: Aditya Shankar 
-M: Ganesh Krishna 
+M: Adham Abozaeid 
+M: Ajay Singh 
 L: linux-wirel...@vger.kernel.org
 S: Supported
 F: drivers/staging/wilc1000/
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 7/8] staging: wilc1000: remove coreconfigurator.c file

2018-11-01 Thread Ajay.Kathat
From: Ajay Singh 

After use of framework API's most of the redundant functions are removed
in coreconfigurator.c file. Now moved left over function to
host_interface file and deleted the coreconfigurator.c file.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/Makefile   |   3 +-
 drivers/staging/wilc1000/coreconfigurator.c | 126 
 drivers/staging/wilc1000/coreconfigurator.h |   4 -
 drivers/staging/wilc1000/host_interface.c   | 117 ++
 4 files changed, 118 insertions(+), 132 deletions(-)
 delete mode 100644 drivers/staging/wilc1000/coreconfigurator.c

diff --git a/drivers/staging/wilc1000/Makefile 
b/drivers/staging/wilc1000/Makefile
index 37e8560..72a4daa 100644
--- a/drivers/staging/wilc1000/Makefile
+++ b/drivers/staging/wilc1000/Makefile
@@ -5,8 +5,7 @@ ccflags-y += -DFIRMWARE_1002=\"atmel/wilc1002_firmware.bin\" \
-DFIRMWARE_1003=\"atmel/wilc1003_firmware.bin\"
 
 wilc1000-objs := wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \
-   coreconfigurator.o host_interface.o \
-   wilc_wlan_cfg.o wilc_wlan.o
+   host_interface.o wilc_wlan_cfg.o wilc_wlan.o
 
 obj-$(CONFIG_WILC1000_SDIO) += wilc1000-sdio.o
 wilc1000-sdio-objs += wilc_sdio.o
diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
deleted file mode 100644
index 2bd62fd..000
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ /dev/null
@@ -1,126 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
- * All rights reserved.
- */
-
-#include 
-
-#include "coreconfigurator.h"
-
-static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt)
-{
-   if (ieee80211_has_fromds(mgmt->frame_control))
-   return mgmt->sa;
-   else if (ieee80211_has_tods(mgmt->frame_control))
-   return mgmt->da;
-   else
-   return mgmt->bssid;
-}
-
-s32 wilc_parse_network_info(u8 *msg_buffer,
-   struct network_info **ret_network_info)
-{
-   struct network_info *info;
-   struct ieee80211_mgmt *mgt;
-   u8 *wid_val, *msa, *ies;
-   u16 wid_len, rx_len, ies_len;
-   u8 msg_type;
-   size_t offset;
-   const u8 *ch_elm, *tim_elm, *ssid_elm;
-
-   msg_type = msg_buffer[0];
-   if ('N' != msg_type)
-   return -EFAULT;
-
-   wid_len = get_unaligned_le16(&msg_buffer[6]);
-   wid_val = &msg_buffer[8];
-
-   info = kzalloc(sizeof(*info), GFP_KERNEL);
-   if (!info)
-   return -ENOMEM;
-
-   info->rssi = wid_val[0];
-
-   msa = &wid_val[1];
-   mgt = (struct ieee80211_mgmt *)&wid_val[1];
-   rx_len = wid_len - 1;
-
-   if (ieee80211_is_probe_resp(mgt->frame_control)) {
-   info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info);
-   info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int);
-   info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp);
-   info->tsf_lo = (u32)info->tsf_hi;
-   offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable);
-   } else if (ieee80211_is_beacon(mgt->frame_control)) {
-   info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info);
-   info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int);
-   info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp);
-   info->tsf_lo = (u32)info->tsf_hi;
-   offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);
-   } else {
-   /* only process probe response and beacon frame */
-   kfree(info);
-   return -EIO;
-   }
-
-   ether_addr_copy(info->bssid, get_bssid(mgt));
-
-   ies = mgt->u.beacon.variable;
-   ies_len = rx_len - offset;
-   if (ies_len <= 0) {
-   kfree(info);
-   return -EIO;
-   }
-
-   info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
-   if (!info->ies) {
-   kfree(info);
-   return -ENOMEM;
-   }
-
-   info->ies_len = ies_len;
-
-   ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies, ies_len);
-   if (ssid_elm) {
-   info->ssid_len = ssid_elm[1];
-   if (info->ssid_len <= IEEE80211_MAX_SSID_LEN)
-   memcpy(info->ssid, ssid_elm + 2, info->ssid_len);
-   else
-   info->ssid_len = 0;
-   }
-
-   ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len);
-   if (ch_elm && ch_elm[1] > 0)
-   info->ch = ch_elm[2];
-
-   tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len);
-   if (tim_elm && tim_elm[1] >= 2)
-   info->dtim_period = tim_elm[3];
-
-   *ret_network_info = info;
-
-   return 0;
-}
-
-s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,
- 

[PATCH 2/8] staging: wilc1000: remove unused code in coreconfigurator

2018-11-01 Thread Ajay.Kathat
From: Ajay Singh 

After refactoring of wilc_parse_network_info(), some of the functions and
macro are not required, so removed the unused code.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.c | 157 
 drivers/staging/wilc1000/coreconfigurator.h |   8 --
 2 files changed, 165 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
index 4dfa658..166443d 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -8,99 +8,6 @@
 
 #include "coreconfigurator.h"
 
-#define TAG_PARAM_OFFSET   (MAC_HDR_LEN + TIME_STAMP_LEN + \
-BEACON_INTERVAL_LEN + CAP_INFO_LEN)
-
-enum sub_frame_type {
-   ASSOC_REQ = 0x00,
-   ASSOC_RSP = 0x10,
-   REASSOC_REQ   = 0x20,
-   REASSOC_RSP   = 0x30,
-   PROBE_REQ = 0x40,
-   PROBE_RSP = 0x50,
-   BEACON= 0x80,
-   ATIM  = 0x90,
-   DISASOC   = 0xA0,
-   AUTH  = 0xB0,
-   DEAUTH= 0xC0,
-   ACTION= 0xD0,
-   PS_POLL   = 0xA4,
-   RTS   = 0xB4,
-   CTS   = 0xC4,
-   ACK   = 0xD4,
-   CFEND = 0xE4,
-   CFEND_ACK = 0xF4,
-   DATA  = 0x08,
-   DATA_ACK  = 0x18,
-   DATA_POLL = 0x28,
-   DATA_POLL_ACK = 0x38,
-   NULL_FRAME= 0x48,
-   CFACK = 0x58,
-   CFPOLL= 0x68,
-   CFPOLL_ACK= 0x78,
-   QOS_DATA  = 0x88,
-   QOS_DATA_ACK  = 0x98,
-   QOS_DATA_POLL = 0xA8,
-   QOS_DATA_POLL_ACK = 0xB8,
-   QOS_NULL_FRAME= 0xC8,
-   QOS_CFPOLL= 0xE8,
-   QOS_CFPOLL_ACK= 0xF8,
-   BLOCKACK_REQ  = 0x84,
-   BLOCKACK  = 0x94,
-   FRAME_SUBTYPE_FORCE_32BIT  = 0x
-};
-
-static inline u16 get_beacon_period(u8 *data)
-{
-   u16 bcn_per;
-
-   bcn_per  = data[0];
-   bcn_per |= (data[1] << 8);
-
-   return bcn_per;
-}
-
-static inline u32 get_beacon_timestamp_lo(u8 *data)
-{
-   u32 time_stamp = 0;
-   u32 index= MAC_HDR_LEN;
-
-   time_stamp |= data[index++];
-   time_stamp |= (data[index++] << 8);
-   time_stamp |= (data[index++] << 16);
-   time_stamp |= (data[index]   << 24);
-
-   return time_stamp;
-}
-
-static inline u32 get_beacon_timestamp_hi(u8 *data)
-{
-   u32 time_stamp = 0;
-   u32 index= (MAC_HDR_LEN + 4);
-
-   time_stamp |= data[index++];
-   time_stamp |= (data[index++] << 8);
-   time_stamp |= (data[index++] << 16);
-   time_stamp |= (data[index]   << 24);
-
-   return time_stamp;
-}
-
-static inline enum sub_frame_type get_sub_type(u8 *header)
-{
-   return ((enum sub_frame_type)(header[0] & 0xFC));
-}
-
-static inline u8 get_to_ds(u8 *header)
-{
-   return (header[1] & 0x01);
-}
-
-static inline u8 get_from_ds(u8 *header)
-{
-   return ((header[1] & 0x02) >> 1);
-}
-
 static inline void get_address1(u8 *msa, u8 *addr)
 {
memcpy(addr, msa + 4, 6);
@@ -126,41 +33,6 @@ static inline void get_bssid(__le16 fc, u8 *data, u8 *bssid)
get_address3(data, bssid);
 }
 
-static inline void get_ssid(u8 *data, u8 *ssid, u8 *p_ssid_len)
-{
-   u8 i, j, len;
-
-   len = data[TAG_PARAM_OFFSET + 1];
-   j   = TAG_PARAM_OFFSET + 2;
-
-   if (len >= MAX_SSID_LEN)
-   len = 0;
-
-   for (i = 0; i < len; i++, j++)
-   ssid[i] = data[j];
-
-   ssid[len] = '\0';
-
-   *p_ssid_len = len;
-}
-
-static inline u16 get_cap_info(u8 *data)
-{
-   u16 cap_info = 0;
-   u16 index= MAC_HDR_LEN;
-   enum sub_frame_type st;
-
-   st = get_sub_type(data);
-
-   if (st == BEACON || st == PROBE_RSP)
-   index += TIME_STAMP_LEN + BEACON_INTERVAL_LEN;
-
-   cap_info  = data[index];
-   cap_info |= (data[index + 1] << 8);
-
-   return cap_info;
-}
-
 static inline u16 get_asoc_status(u8 *data)
 {
u16 asoc_status;
@@ -169,35 +41,6 @@ static inline u16 get_asoc_status(u8 *data)
return (asoc_status << 8) | data[2];
 }
 
-static u8 *get_tim_elm(u8 *msa, u16 rx_len, u16 tag_param_offset)
-{
-   u16 index;
-
-   index = tag_param_offset;
-
-   while (index < (rx_len - FCS_LEN)) {
-   if (msa[index] == WLAN_EID_TIM)
-   return &msa[index];
-   index += (IE_HDR_LEN + msa[index + 1]);
-   }
-
-   return NULL;
-}
-
-static u8 get_current_channel_802_11n(u8 *msa, u16 rx_len)
-{
-   u16 index;
-
-   index = TAG_PARAM_OFFSET;
-   while (index < (rx_len - FCS_LEN)) {
-

[PATCH 4/8] staging: wilc1000: avoid line over 80 chars in wilc_parse_network_info()

2018-11-01 Thread Ajay.Kathat
From: Ajay Singh 

Use shorter name for 'network_info' variable to avoid line over 80 chars
issue.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.c | 53 ++---
 1 file changed, 26 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
index ac44846..2c77e5a 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -29,7 +29,7 @@ static inline u16 get_asoc_status(u8 *data)
 s32 wilc_parse_network_info(u8 *msg_buffer,
struct network_info **ret_network_info)
 {
-   struct network_info *network_info;
+   struct network_info *info;
struct ieee80211_mgmt *mgt;
u8 *wid_val, *msa, *ies;
u16 wid_len, rx_len, ies_len;
@@ -44,70 +44,69 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
wid_len = get_unaligned_le16(&msg_buffer[6]);
wid_val = &msg_buffer[8];
 
-   network_info = kzalloc(sizeof(*network_info), GFP_KERNEL);
-   if (!network_info)
+   info = kzalloc(sizeof(*info), GFP_KERNEL);
+   if (!info)
return -ENOMEM;
 
-   network_info->rssi = wid_val[0];
+   info->rssi = wid_val[0];
 
msa = &wid_val[1];
mgt = (struct ieee80211_mgmt *)&wid_val[1];
rx_len = wid_len - 1;
 
if (ieee80211_is_probe_resp(mgt->frame_control)) {
-   network_info->cap_info = 
le16_to_cpu(mgt->u.probe_resp.capab_info);
-   network_info->beacon_period = 
le16_to_cpu(mgt->u.probe_resp.beacon_int);
-   network_info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp);
-   network_info->tsf_lo = (u32)network_info->tsf_hi;
+   info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info);
+   info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int);
+   info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp);
+   info->tsf_lo = (u32)info->tsf_hi;
offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable);
} else if (ieee80211_is_beacon(mgt->frame_control)) {
-   network_info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info);
-   network_info->beacon_period = 
le16_to_cpu(mgt->u.beacon.beacon_int);
-   network_info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp);
-   network_info->tsf_lo = (u32)network_info->tsf_hi;
+   info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info);
+   info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int);
+   info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp);
+   info->tsf_lo = (u32)info->tsf_hi;
offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);
} else {
/* only process probe response and beacon frame */
-   kfree(network_info);
+   kfree(info);
return -EIO;
}
 
-   ether_addr_copy(network_info->bssid, get_bssid(mgt));
+   ether_addr_copy(info->bssid, get_bssid(mgt));
 
ies = mgt->u.beacon.variable;
ies_len = rx_len - offset;
if (ies_len <= 0) {
-   kfree(network_info);
+   kfree(info);
return -EIO;
}
 
-   network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
-   if (!network_info->ies) {
-   kfree(network_info);
+   info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
+   if (!info->ies) {
+   kfree(info);
return -ENOMEM;
}
 
-   network_info->ies_len = ies_len;
+   info->ies_len = ies_len;
 
ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies, ies_len);
if (ssid_elm) {
-   network_info->ssid_len = ssid_elm[1];
-   if (network_info->ssid_len <= IEEE80211_MAX_SSID_LEN)
-   memcpy(network_info->ssid, ssid_elm + 2,
-  network_info->ssid_len);
+   info->ssid_len = ssid_elm[1];
+   if (info->ssid_len <= IEEE80211_MAX_SSID_LEN)
+   memcpy(info->ssid, ssid_elm + 2, info->ssid_len);
else
-   network_info->ssid_len = 0;
+   info->ssid_len = 0;
}
 
ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len);
if (ch_elm && ch_elm[1] > 0)
-   network_info->ch = ch_elm[2];
+   info->ch = ch_elm[2];
 
tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len);
if (tim_elm && tim_elm[1] >= 2)
-   network_info->dtim_period = tim_elm[3];
+   info->dtim_period = tim_elm[3];
 
-   *ret_network_info = network_info;
+   *ret_network_info = info;
 
return 0;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://

[PATCH 5/8] staging: wilc1000: refactor wilc_parse_assoc_resp_info()

2018-11-01 Thread Ajay.Kathat
From: Ajay Singh 

Refactor wilc_parse_assoc_resp_info() function by removing the use of
get_asoc_status() API. For parsing assoc response use the struct and
avoided the use of offset macros to extract the ies information.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.c | 16 
 drivers/staging/wilc1000/coreconfigurator.h | 10 ++
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
index 2c77e5a..2bd62fd 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -18,14 +18,6 @@ static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt)
return mgmt->bssid;
 }
 
-static inline u16 get_asoc_status(u8 *data)
-{
-   u16 asoc_status;
-
-   asoc_status = data[3];
-   return (asoc_status << 8) | data[2];
-}
-
 s32 wilc_parse_network_info(u8 *msg_buffer,
struct network_info **ret_network_info)
 {
@@ -116,12 +108,12 @@ s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,
 {
u8 *ies;
u16 ies_len;
+   struct assoc_resp *res = (struct assoc_resp *)buffer;
 
-   ret_conn_info->status = get_asoc_status(buffer);
+   ret_conn_info->status = le16_to_cpu(res->status_code);
if (ret_conn_info->status == WLAN_STATUS_SUCCESS) {
-   ies = &buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN];
-   ies_len = buffer_len - (CAP_INFO_LEN + STATUS_CODE_LEN +
-   AID_LEN);
+   ies = &buffer[sizeof(*res)];
+   ies_len = buffer_len - sizeof(*res);
 
ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL);
if (!ret_conn_info->resp_ies)
diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
b/drivers/staging/wilc1000/coreconfigurator.h
index 0d40c77..71a9f27 100644
--- a/drivers/staging/wilc1000/coreconfigurator.h
+++ b/drivers/staging/wilc1000/coreconfigurator.h
@@ -11,10 +11,6 @@
 
 #define NUM_RSSI5
 
-#define CAP_INFO_LEN2
-#define STATUS_CODE_LEN 2
-#define AID_LEN 2
-
 #define SET_CFG  0
 #define GET_CFG  1
 
@@ -63,6 +59,12 @@ struct disconnect_info {
size_t ie_len;
 };
 
+struct assoc_resp {
+   __le16 capab_info;
+   __le16 status_code;
+   __le16 aid;
+} __packed;
+
 s32 wilc_parse_network_info(u8 *msg_buffer,
struct network_info **ret_network_info);
 s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/8] staging: wilc1000: refactor get_bssid() function

2018-11-01 Thread Ajay.Kathat
From: Ajay Singh 

Refactor get_bssid() by making use of 'ieee80211_mgmt' struct. Instead
of passing the memory offset now using structure element to fetch the
bssid information.
Returning the pointer to bssid from get_bssid() instead of filing the
input argument.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.c | 29 +++--
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
index 166443d..ac44846 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -8,29 +8,14 @@
 
 #include "coreconfigurator.h"
 
-static inline void get_address1(u8 *msa, u8 *addr)
+static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt)
 {
-   memcpy(addr, msa + 4, 6);
-}
-
-static inline void get_address2(u8 *msa, u8 *addr)
-{
-   memcpy(addr, msa + 10, 6);
-}
-
-static inline void get_address3(u8 *msa, u8 *addr)
-{
-   memcpy(addr, msa + 16, 6);
-}
-
-static inline void get_bssid(__le16 fc, u8 *data, u8 *bssid)
-{
-   if (ieee80211_has_fromds(fc))
-   get_address2(data, bssid);
-   else if (ieee80211_has_tods(fc))
-   get_address1(data, bssid);
+   if (ieee80211_has_fromds(mgmt->frame_control))
+   return mgmt->sa;
+   else if (ieee80211_has_tods(mgmt->frame_control))
+   return mgmt->da;
else
-   get_address3(data, bssid);
+   return mgmt->bssid;
 }
 
 static inline u16 get_asoc_status(u8 *data)
@@ -87,7 +72,7 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
return -EIO;
}
 
-   get_bssid(mgt->frame_control, msa, network_info->bssid);
+   ether_addr_copy(network_info->bssid, get_bssid(mgt));
 
ies = mgt->u.beacon.variable;
ies_len = rx_len - offset;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/8] staging: wilc1000: make use of cfg80211 provided API's

2018-11-01 Thread Ajay.Kathat
From: Ajay Singh 

This series mainly contains the changes to make use of cfg80211 and
framework provided API's instead of having own implementation.
After refactoring of coreconfigurator functions, most of the redundant code
is removed, hence deleted the extra file.

Ajay Singh (8):
  staging: wilc1000: refactor wilc_parse_network_info() using kernel
framework api's
  staging: wilc1000: remove unused code in coreconfigurator
  staging: wilc1000: refactor get_bssid() function
  staging: wilc1000: avoid line over 80 chars in
wilc_parse_network_info()
  staging: wilc1000: refactor wilc_parse_assoc_resp_info()
  staging: wilc1000: remove unnecessary MAX_STRING_LEN macro
  staging: wilc1000: remove coreconfigurator.c file
  staging: wilc1000: remove coreconfigurator.h file

 drivers/staging/wilc1000/Makefile   |   3 +-
 drivers/staging/wilc1000/coreconfigurator.c | 287 
 drivers/staging/wilc1000/coreconfigurator.h |  81 
 drivers/staging/wilc1000/host_interface.c   | 117 
 drivers/staging/wilc1000/host_interface.h   |  61 +-
 drivers/staging/wilc1000/wilc_wlan_cfg.c|   1 -
 6 files changed, 177 insertions(+), 373 deletions(-)
 delete mode 100644 drivers/staging/wilc1000/coreconfigurator.c
 delete mode 100644 drivers/staging/wilc1000/coreconfigurator.h

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/8] staging: wilc1000: refactor wilc_parse_network_info() using kernel framework api's

2018-11-01 Thread Ajay.Kathat
From: Ajay Singh 

Refactor wilc_parse_network_info() by making use of cfg80211.h provided
API.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.c | 90 ++---
 1 file changed, 55 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
index d6d3a97..4dfa658 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -4,7 +4,7 @@
  * All rights reserved.
  */
 
-#include 
+#include 
 
 #include "coreconfigurator.h"
 
@@ -116,11 +116,11 @@ static inline void get_address3(u8 *msa, u8 *addr)
memcpy(addr, msa + 16, 6);
 }
 
-static inline void get_bssid(u8 *data, u8 *bssid)
+static inline void get_bssid(__le16 fc, u8 *data, u8 *bssid)
 {
-   if (get_from_ds(data) == 1)
+   if (ieee80211_has_fromds(fc))
get_address2(data, bssid);
-   else if (get_to_ds(data) == 1)
+   else if (ieee80211_has_tods(fc))
get_address1(data, bssid);
else
get_address3(data, bssid);
@@ -202,17 +202,18 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
struct network_info **ret_network_info)
 {
struct network_info *network_info;
-   u8 *wid_val, *msa, *tim_elm, *ies;
-   u32 tsf_lo, tsf_hi;
+   struct ieee80211_mgmt *mgt;
+   u8 *wid_val, *msa, *ies;
u16 wid_len, rx_len, ies_len;
-   u8 msg_type, index;
+   u8 msg_type;
+   size_t offset;
+   const u8 *ch_elm, *tim_elm, *ssid_elm;
 
msg_type = msg_buffer[0];
-
if ('N' != msg_type)
return -EFAULT;
 
-   wid_len = MAKE_WORD16(msg_buffer[6], msg_buffer[7]);
+   wid_len = get_unaligned_le16(&msg_buffer[6]);
wid_val = &msg_buffer[8];
 
network_info = kzalloc(sizeof(*network_info), GFP_KERNEL);
@@ -222,42 +223,61 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
network_info->rssi = wid_val[0];
 
msa = &wid_val[1];
-
+   mgt = (struct ieee80211_mgmt *)&wid_val[1];
rx_len = wid_len - 1;
-   network_info->cap_info = get_cap_info(msa);
-   network_info->tsf_lo = get_beacon_timestamp_lo(msa);
 
-   tsf_lo = get_beacon_timestamp_lo(msa);
-   tsf_hi = get_beacon_timestamp_hi(msa);
+   if (ieee80211_is_probe_resp(mgt->frame_control)) {
+   network_info->cap_info = 
le16_to_cpu(mgt->u.probe_resp.capab_info);
+   network_info->beacon_period = 
le16_to_cpu(mgt->u.probe_resp.beacon_int);
+   network_info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp);
+   network_info->tsf_lo = (u32)network_info->tsf_hi;
+   offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable);
+   } else if (ieee80211_is_beacon(mgt->frame_control)) {
+   network_info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info);
+   network_info->beacon_period = 
le16_to_cpu(mgt->u.beacon.beacon_int);
+   network_info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp);
+   network_info->tsf_lo = (u32)network_info->tsf_hi;
+   offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);
+   } else {
+   /* only process probe response and beacon frame */
+   kfree(network_info);
+   return -EIO;
+   }
 
-   network_info->tsf_hi = tsf_lo | ((u64)tsf_hi << 32);
+   get_bssid(mgt->frame_control, msa, network_info->bssid);
 
-   get_ssid(msa, network_info->ssid, &network_info->ssid_len);
-   get_bssid(msa, network_info->bssid);
+   ies = mgt->u.beacon.variable;
+   ies_len = rx_len - offset;
+   if (ies_len <= 0) {
+   kfree(network_info);
+   return -EIO;
+   }
 
-   network_info->ch = get_current_channel_802_11n(msa, rx_len
-  + FCS_LEN);
+   network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
+   if (!network_info->ies) {
+   kfree(network_info);
+   return -ENOMEM;
+   }
 
-   index = MAC_HDR_LEN + TIME_STAMP_LEN;
+   network_info->ies_len = ies_len;
 
-   network_info->beacon_period = get_beacon_period(msa + index);
+   ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies, ies_len);
+   if (ssid_elm) {
+   network_info->ssid_len = ssid_elm[1];
+   if (network_info->ssid_len <= IEEE80211_MAX_SSID_LEN)
+   memcpy(network_info->ssid, ssid_elm + 2,
+  network_info->ssid_len);
+   else
+   network_info->ssid_len = 0;
+   }
 
-   index += BEACON_INTERVAL_LEN + CAP_INFO_LEN;
+   ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len);
+   if (ch_elm && ch_elm[1] > 0)
+   network_info->ch = ch_elm[2];
 
-   tim_elm = get_tim_elm(msa, rx_len + FCS_LEN, index);

[PATCH 8/8] staging: wilc1000: remove coreconfigurator.h file

2018-11-01 Thread Ajay.Kathat
From: Ajay Singh 

Remove the coreconfigurator header file, as its source file is deleted
after code refactor. Moved the required structure and prototypes to
hostinterface header.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.h | 70 -
 drivers/staging/wilc1000/host_interface.h   | 61 -
 drivers/staging/wilc1000/wilc_wlan_cfg.c|  1 -
 3 files changed, 59 insertions(+), 73 deletions(-)
 delete mode 100644 drivers/staging/wilc1000/coreconfigurator.h

diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
b/drivers/staging/wilc1000/coreconfigurator.h
deleted file mode 100644
index 67f6855..000
--- a/drivers/staging/wilc1000/coreconfigurator.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
- * All rights reserved.
- */
-
-#ifndef CORECONFIGURATOR_H
-#define CORECONFIGURATOR_H
-
-#include "wilc_wlan_if.h"
-
-#define NUM_RSSI5
-
-#define SET_CFG  0
-#define GET_CFG  1
-
-#define MAX_ASSOC_RESP_FRAME_SIZE   256
-
-struct rssi_history_buffer {
-   bool full;
-   u8 index;
-   s8 samples[NUM_RSSI];
-};
-
-struct network_info {
-   s8 rssi;
-   u16 cap_info;
-   u8 ssid[MAX_SSID_LEN];
-   u8 ssid_len;
-   u8 bssid[6];
-   u16 beacon_period;
-   u8 dtim_period;
-   u8 ch;
-   unsigned long time_scan_cached;
-   unsigned long time_scan;
-   bool new_network;
-   u8 found;
-   u32 tsf_lo;
-   u8 *ies;
-   u16 ies_len;
-   void *join_params;
-   struct rssi_history_buffer rssi_history;
-   u64 tsf_hi;
-};
-
-struct connect_info {
-   u8 bssid[6];
-   u8 *req_ies;
-   size_t req_ies_len;
-   u8 *resp_ies;
-   u16 resp_ies_len;
-   u16 status;
-};
-
-struct disconnect_info {
-   u16 reason;
-   u8 *ie;
-   size_t ie_len;
-};
-
-struct assoc_resp {
-   __le16 capab_info;
-   __le16 status_code;
-   __le16 aid;
-} __packed;
-
-void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
-void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
-void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
-#endif
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 33fb731..5f8d30f 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -7,7 +7,7 @@
 #ifndef HOST_INT_H
 #define HOST_INT_H
 #include 
-#include "coreconfigurator.h"
+#include "wilc_wlan_if.h"
 
 #define IDLE_MODE  0x00
 #define AP_MODE0x01
@@ -56,6 +56,61 @@
 #define DRV_HANDLER_SIZE   5
 #define DRV_HANDLER_MASK   0x00FF
 
+#define NUM_RSSI5
+
+#define SET_CFG  0
+#define GET_CFG  1
+
+#define MAX_ASSOC_RESP_FRAME_SIZE   256
+
+struct rssi_history_buffer {
+   bool full;
+   u8 index;
+   s8 samples[NUM_RSSI];
+};
+
+struct network_info {
+   s8 rssi;
+   u16 cap_info;
+   u8 ssid[MAX_SSID_LEN];
+   u8 ssid_len;
+   u8 bssid[6];
+   u16 beacon_period;
+   u8 dtim_period;
+   u8 ch;
+   unsigned long time_scan_cached;
+   unsigned long time_scan;
+   bool new_network;
+   u8 found;
+   u32 tsf_lo;
+   u8 *ies;
+   u16 ies_len;
+   void *join_params;
+   struct rssi_history_buffer rssi_history;
+   u64 tsf_hi;
+};
+
+struct connect_info {
+   u8 bssid[6];
+   u8 *req_ies;
+   size_t req_ies_len;
+   u8 *resp_ies;
+   u16 resp_ies_len;
+   u16 status;
+};
+
+struct disconnect_info {
+   u16 reason;
+   u8 *ie;
+   size_t ie_len;
+};
+
+struct assoc_resp {
+   __le16 capab_info;
+   __le16 status_code;
+   __le16 aid;
+} __packed;
+
 struct rf_info {
u8 link_speed;
s8 rssi;
@@ -358,5 +413,7 @@ void wilc_resolve_disconnect_aberration(struct wilc_vif 
*vif);
 int wilc_get_vif_idx(struct wilc_vif *vif);
 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
-
+void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
+void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
+void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
 #endif
diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c 
b/drivers/staging/wilc1000/wilc_wlan_cfg.c
index faa001c..8390766 100644
--- a/drivers/staging/wilc1000/wilc_wlan_cfg.c
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c
@@ -7,7 +7,6 @@
 #include "wilc_wlan_if.h"
 #include "wilc_wlan.h"
 #include "wilc_wlan_cfg.h"
-#include "coreconfigurator.h"
 #include "wilc_wfi_netdevice.h"
 
 enum cfg_cmd_type {
-- 
2.7.4

_

[PATCH 6/8] staging: wilc1000: remove unnecessary MAX_STRING_LEN macro

2018-11-01 Thread Ajay.Kathat
From: Ajay Singh 

Cleanup patch to remove the use of unnecessary 'MAX_STRING_LEN' macro.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
b/drivers/staging/wilc1000/coreconfigurator.h
index 71a9f27..a1347f7 100644
--- a/drivers/staging/wilc1000/coreconfigurator.h
+++ b/drivers/staging/wilc1000/coreconfigurator.h
@@ -14,8 +14,7 @@
 #define SET_CFG  0
 #define GET_CFG  1
 
-#define MAX_STRING_LEN   256
-#define MAX_ASSOC_RESP_FRAME_SIZEMAX_STRING_LEN
+#define MAX_ASSOC_RESP_FRAME_SIZE   256
 
 struct rssi_history_buffer {
bool full;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/8] staging: wilc1000: avoid line over 80 chars in wilc_parse_network_info()

2018-11-04 Thread Ajay.Kathat
Hi Joe,

On 11/5/2018 12:47 AM, Joe Perches wrote:
> On Thu, 2018-11-01 at 16:45 +, ajay.kat...@microchip.com wrote:
>> From: Ajay Singh 
>>
>> Use shorter name for 'network_info' variable to avoid line over 80 chars
>> issue.
> This seems completely unnecessary as patch 7/8 and 8/8
> removes the file.
>
As wilc_parse_network_info() is moved to a different file in patch#7.
So to separate the variable name changes from the function movement I
have divided them into 2 different patches.

Regards,
Ajay

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/8] staging: wilc1000: avoid line over 80 chars in wilc_parse_network_info()

2018-11-05 Thread Ajay.Kathat
Hi Joe,

On 11/5/2018 4:27 PM, Joe Perches wrote:
> On Thu, 2018-11-01 at 16:45 +, ajay.kat...@microchip.com wrote:
>> From: Ajay Singh 
>>
>> Use shorter name for 'network_info' variable to avoid line over 80 chars
>> issue.
>
> I suppose this is OK, though perhaps unnecessary.
>
> As well, perhaps there are defects in the original code
> in a couple places.
>
>> diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
>> b/drivers/staging/wilc1000/coreconfigurator.c
> []
>> -network_info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp);
>> -network_info->tsf_lo = (u32)network_info->tsf_hi;
> Perhaps there is a defect for both tsf_hi assignments
> as it appears as if both are missing ">> 32"

Actually, 'tsf_hi' is used to store the complete tsf value as its data
type is u64.  This value is pass to the cfg80211_inform_bss() as it is.
So the conversion of 'tsf_hi' to 32 bit  is not required in this case.

>> +info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info);
>> +info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int);
>> +info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp);
>> +info->tsf_lo = (u32)info->tsf_hi;
> Perhaps this should be 
>
>   network_info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp) >> 
> 32;
>
> or
>
>   network_info->tsf_hi = upper_32_bits(le64_to_cpu(...));
>   network_info->tsf_lo = lower_32_bits(le64_to_cpu(...));
>
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: wilc1000: update wilc1000 driver maintainer ids

2018-11-05 Thread Ajay.Kathat
Hi Greg,

On 11/5/2018 7:46 PM, Greg KH wrote:
> On Tue, Oct 30, 2018 at 05:53:40AM +, ajay.kat...@microchip.com wrote:
>> From: Ajay Singh 
>>
>> We would like to update the maintainer email id's for wilc1000 driver.
>>
>> Signed-off-by: Ajay Singh 
>> Signed-off-by: Adham Abozaeid 
> It would be good to get the current maintainer's signed off by on this
> so I know that they also agree with this change.

Sure, I have submitted this patch with current maintainer's agreement.
As suggested, I will send the updated patch by including current
maintainers signed off tag.

Regards,
Ajay

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/8] staging: wilc1000: avoid line over 80 chars in wilc_parse_network_info()

2018-11-05 Thread Ajay.Kathat


On 11/5/2018 9:27 PM, Joe Perches wrote:
> On Mon, 2018-11-05 at 12:18 +, ajay.kat...@microchip.com wrote:
>> Hi Joe,
>>
>> On 11/5/2018 4:27 PM, Joe Perches wrote:
>>> On Thu, 2018-11-01 at 16:45 +, ajay.kat...@microchip.com wrote:
 From: Ajay Singh 

 Use shorter name for 'network_info' variable to avoid line over 80 chars
 issue.
>>> I suppose this is OK, though perhaps unnecessary.
>>>
>>> As well, perhaps there are defects in the original code
>>> in a couple places.
>>>
 diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
 b/drivers/staging/wilc1000/coreconfigurator.c
>>> []
 -  network_info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp);
 -  network_info->tsf_lo = (u32)network_info->tsf_hi;
>>> Perhaps there is a defect for both tsf_hi assignments
>>> as it appears as if both are missing ">> 32"
>> Actually, 'tsf_hi' is used to store the complete tsf value as its data
>> type is u64.  This value is pass to the cfg80211_inform_bss() as it is.
>> So the conversion of 'tsf_hi' to 32 bit  is not required in this case.
> Antipattern naming generally warrants a rename.
>
Thanks Joe.
Sure, I will rename tsf_hi in future patch to have clear meaning.

Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: wilc1000: update wilc1000 driver maintainer ids

2018-11-06 Thread Ajay.Kathat
From: Ajay Singh 

We would like to update the maintainer email id's for wilc1000 driver.

Signed-off-by: Aditya Shankar 
Signed-off-by: Ganesh Krishna 
Signed-off-by: Adham Abozaeid 
Signed-off-by: Ajay Singh 
---
Changes in v2:
- added sob of current wilc1000 maintainers
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index f485597..49ae03f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14132,8 +14132,8 @@ S:  Odd Fixes
 F: drivers/staging/vt665?/
 
 STAGING - WILC1000 WIFI DRIVER
-M: Aditya Shankar 
-M: Ganesh Krishna 
+M: Adham Abozaeid 
+M: Ajay Singh 
 L: linux-wirel...@vger.kernel.org
 S: Supported
 F: drivers/staging/wilc1000/
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/12] staging: wilc1000: use WLAN_PMKID_LEN macro from ieee80211.h header

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Make use of WLAN_PMKID_LEN macro provided by ieee80211.h header instead
of PMKID_LEN.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 4 ++--
 drivers/staging/wilc1000/host_interface.h | 3 +--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ++--
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 -
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index eb13b41..c200d90 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1460,7 +1460,7 @@ static int wilc_pmksa_key_copy(struct wilc_vif *vif, 
struct key_attr *hif_key)
memcpy(key_buf + ((PMKSA_KEY_LEN * i) + 1),
   hif_key->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
memcpy(key_buf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1),
-  hif_key->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
+  hif_key->attr.pmkid.pmkidlist[i].pmkid, WLAN_PMKID_LEN);
}
 
wid.id = WID_PMKID_INFO;
@@ -2793,7 +2793,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif,
memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].bssid,
   &pmkid->pmkidlist[i].bssid, ETH_ALEN);
memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].pmkid,
-  &pmkid->pmkidlist[i].pmkid, PMKID_LEN);
+  &pmkid->pmkidlist[i].pmkid, WLAN_PMKID_LEN);
}
 
result = wilc_enqueue_work(msg);
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 0185fc6..3d31153 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -46,7 +46,6 @@
 
 #define PMKSA_KEY_LEN  22
 #define ETH_ALEN   6
-#define PMKID_LEN  16
 #define WILC_MAX_NUM_PMKIDS16
 #define WILC_ADD_STA_LENGTH40
 #define NUM_CONCURRENT_IFC 2
@@ -128,7 +127,7 @@ enum host_if_state {
 
 struct host_if_pmkid {
u8 bssid[ETH_ALEN];
-   u8 pmkid[PMKID_LEN];
+   u8 pmkid[WLAN_PMKID_LEN];
 };
 
 struct host_if_pmkid_attr {
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index f92ecf6c..7b753c1 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1217,7 +1217,7 @@ static int set_pmksa(struct wiphy *wiphy, struct 
net_device *netdev,
memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
   ETH_ALEN);
memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
-  PMKID_LEN);
+  WLAN_PMKID_LEN);
if (!(flag == PMKID_FOUND))
priv->pmkid_list.numpmkid++;
} else {
@@ -1254,7 +1254,7 @@ static int del_pmksa(struct wiphy *wiphy, struct 
net_device *netdev,
   ETH_ALEN);
memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
   priv->pmkid_list.pmkidlist[i + 1].pmkid,
-  PMKID_LEN);
+  WLAN_PMKID_LEN);
}
priv->pmkid_list.numpmkid--;
} else {
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 4f05a16..6283d9e 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -22,7 +22,6 @@
 #define FLOW_CONTROL_UPPER_THRESHOLD   256
 
 #define WILC_MAX_NUM_PMKIDS16
-#define PMKID_LEN  16
 #define PMKID_FOUND1
 #define NUM_STA_ASSOCIATED 8
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/12] staging: wilc1000: better namespace for constants and cleanup

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

This patch series contains changes to address the review feedback
comments [1]. It mainly contains the changes to have clear names for
the constants. Most of the constants names are taken care, few are left
unchanged in hope with another cleanup those macros might be deleted. After
further cleanup will revisit if anything else is required to address this.

[1]. - https://www.spinics.net/lists/linux-wireless/msg178706.html
 - https://www.spinics.net/lists/linux-wireless/msg178704.html

Ajay Singh (12):
  staging: wilc1000: use macro from ieee80211.h in register frame api's
  staging: wilc1000: use WLAN_PMKID_LEN macro from ieee80211.h header
  staging: wilc1000: remove unused macros and struct members in
host_interface.h
  staging: wilc1000: move sdio_cmd52 & sdio_cmd53 struct to source file
  staging: wilc1000: use enum contants for mac status & added 'WILC_'
prefix
  staging: wilc1000: restructure macros used to handle security type
  staging: wilc1000: use proper namespace for macros in wilc_wlan_if.h
header
  staging: wilc1000: move current_tx_rate enum to wilc_wlan_if.h file
  staging: wilc1000: rename firmware related constants to follow better
namespace
  staging: wilc1000: added 'WILC_' prefix for constants to have clear
namespace
  staging: wilc1000: use ENOBUFS error code instead of
WILC_TX_ERR_NO_BUF macro
  staging: wilc1000: rename tsf_hi element of network_info struct

 drivers/staging/wilc1000/host_interface.c | 203 ++---
 drivers/staging/wilc1000/host_interface.h | 100 --
 drivers/staging/wilc1000/linux_wlan.c |  62 ---
 drivers/staging/wilc1000/wilc_sdio.c  |  22 ++-
 drivers/staging/wilc1000/wilc_spi.c   |   2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 133 +++---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   9 +-
 drivers/staging/wilc1000/wilc_wlan.c  |  94 +-
 drivers/staging/wilc1000/wilc_wlan_if.h   | 212 --
 9 files changed, 421 insertions(+), 416 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/12] staging: wilc1000: remove unused macros and struct members in host_interface.h

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Cleanup patch to remove the unused macros and struct members in
host_interface.h header file.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.h | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 3d31153..fefbce6 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -18,15 +18,10 @@
 #define ACTION_FRM_IDX 0
 #define PROBE_REQ_IDX  1
 #define MAX_NUM_STA9
-#define ACTIVE_SCAN_TIME   10
-#define PASSIVE_SCAN_TIME  1200
-#define MIN_SCAN_TIME  10
-#define MAX_SCAN_TIME  1200
 #define DEFAULT_SCAN   0
 #define USER_SCAN  BIT(0)
 #define OBSS_PERIODIC_SCAN BIT(1)
 #define OBSS_ONETIME_SCAN  BIT(2)
-#define GTK_RX_KEY_BUFF_LEN24
 #define ADDKEY 0x1
 #define REMOVEKEY  0x2
 #define DEFAULTKEY 0x4
@@ -34,18 +29,15 @@
 #define MAX_NUM_SCANNED_NETWORKS   100
 #define MAX_NUM_SCANNED_NETWORKS_SHADOW130
 #define MAX_NUM_PROBED_SSID10
-#define CHANNEL_SCAN_TIME  250
 
 #define TX_MIC_KEY_LEN 8
 #define RX_MIC_KEY_LEN 8
 #define PTK_KEY_LEN16
 
-#define TX_MIC_KEY_MSG_LEN 26
 #define RX_MIC_KEY_MSG_LEN 48
 #define PTK_KEY_MSG_LEN39
 
 #define PMKSA_KEY_LEN  22
-#define ETH_ALEN   6
 #define WILC_MAX_NUM_PMKIDS16
 #define WILC_ADD_STA_LENGTH40
 #define NUM_CONCURRENT_IFC 2
@@ -153,12 +145,10 @@ enum current_tx_rate {
 
 struct cfg_param_attr {
u32 flag;
-   u8 ht_enable;
u16 short_retry_limit;
u16 long_retry_limit;
u16 frag_threshold;
u16 rts_threshold;
-   u8 scan_source;
 };
 
 enum cfg_param {
@@ -166,7 +156,6 @@ enum cfg_param {
RETRY_LONG  = BIT(1),
FRAG_THRESHOLD  = BIT(2),
RTS_THRESHOLD   = BIT(3),
-   HT_ENABLE   = BIT(18),
 };
 
 struct found_net_info {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/12] staging: wilc1000: move sdio_cmd52 & sdio_cmd53 struct to source file

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved sdio_cmd52 & sdio_cmd53 struct from wilc_wlan_if.h, as its used in
wilc_sdio.cfile.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_sdio.c| 19 +++
 drivers/staging/wilc1000/wilc_wlan_if.h | 19 ---
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_sdio.c 
b/drivers/staging/wilc1000/wilc_sdio.c
index ca351c9..779614e 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -30,6 +30,25 @@ struct wilc_sdio {
int has_thrpt_enh3;
 };
 
+struct sdio_cmd52 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 raw:1;
+   u32 address:17;
+   u32 data:   8;
+};
+
+struct sdio_cmd53 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 block_mode: 1;
+   u32 increment:  1;
+   u32 address:17;
+   u32 count:  9;
+   u8 *buffer;
+   u32 block_size;
+};
+
 static const struct wilc_hif_func wilc_hif_sdio;
 
 static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data);
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index 4f258bf..dc40743 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -24,25 +24,6 @@
  *
  /
 
-struct sdio_cmd52 {
-   u32 read_write: 1;
-   u32 function:   3;
-   u32 raw:1;
-   u32 address:17;
-   u32 data:   8;
-};
-
-struct sdio_cmd53 {
-   u32 read_write: 1;
-   u32 function:   3;
-   u32 block_mode: 1;
-   u32 increment:  1;
-   u32 address:17;
-   u32 count:  9;
-   u8 *buffer;
-   u32 block_size;
-};
-
 #define MAC_STATUS_INIT-1
 #define MAC_STATUS_CONNECTED   1
 #define MAC_STATUS_DISCONNECTED0
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/12] staging: wilc1000: use proper namespace for macros in wilc_wlan_if.h header

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Rename the macros defined in wilc_wlan_if.h header to have clear
namespace. As convention used 'WILC_FW_' prefix for constants defined for
firmware and 'WILC_' prefix for driver constants.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c |   6 +-
 drivers/staging/wilc1000/linux_wlan.c |  32 +++---
 drivers/staging/wilc1000/wilc_sdio.c  |   3 +-
 drivers/staging/wilc1000/wilc_spi.c   |   2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  14 +--
 drivers/staging/wilc1000/wilc_wlan.c  |  88 +++
 drivers/staging/wilc1000/wilc_wlan_if.h   | 128 +++---
 7 files changed, 138 insertions(+), 135 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 46b1a00..4dfdc7c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -684,7 +684,7 @@ static void handle_connect(struct work_struct *work)
cur_byte[conn_attr->ssid_len] = '\0';
}
cur_byte += MAX_SSID_LEN;
-   *(cur_byte++) = INFRASTRUCTURE;
+   *(cur_byte++) = WILC_FW_BSS_TYPE_INFRA;
 
if (conn_attr->ch >= 1 && conn_attr->ch <= 14) {
*(cur_byte++) = conn_attr->ch;
@@ -2321,9 +2321,9 @@ static void handle_power_management(struct work_struct 
*work)
wid.id = WID_POWER_MANAGEMENT;
 
if (pm_param->enabled)
-   power_mode = MIN_FAST_PS;
+   power_mode = WILC_FW_MIN_FAST_PS;
else
-   power_mode = NO_POWERSAVE;
+   power_mode = WILC_FW_NO_POWERSAVE;
 
wid.val = &power_mode;
wid.size = sizeof(char);
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 6f0a2cd..c4787bb 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -338,7 +338,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = INFRASTRUCTURE;
+   c_val[0] = WILC_FW_BSS_TYPE_INFRA;
if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0))
goto fail;
 
@@ -346,7 +346,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = G_MIXED_11B_2_MODE;
+   c_val[0] = WILC_FW_OPER_MODE_G_MIXED_11B_2;
if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, c_val, 1, 0,
   0))
goto fail;
@@ -355,19 +355,19 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = G_SHORT_PREAMBLE;
+   c_val[0] = WILC_FW_PREAMBLE_SHORT;
if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = AUTO_PROT;
+   c_val[0] = WILC_FW_11N_PROT_AUTO;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = ACTIVE_SCAN;
+   c_val[0] = WILC_FW_ACTIVE_SCAN;
if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = SITE_SURVEY_OFF;
+   c_val[0] = WILC_FW_SITE_SURVEY_OFF;
if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, c_val, 1, 0, 0))
goto fail;
 
@@ -387,7 +387,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = NO_POWERSAVE;
+   c_val[0] = WILC_FW_NO_POWERSAVE;
if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
goto fail;
 
@@ -395,7 +395,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = OPEN_SYSTEM;
+   c_val[0] = WILC_FW_AUTH_OPEN_SYSTEM;
if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, c_val, 1, 0, 0))
goto fail;
 
@@ -429,7 +429,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_DTIM_PERIOD, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = NORMAL_ACK;
+   c_val[0] = WILC_FW_ACK_POLICY_NORMAL;
if (!wilc_wlan_cfg_set(vif, 0, WID_ACK_POLICY, c_val, 1, 0, 0))
goto fail;
 
@@ -452,7 +452,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_BEACON_INTERVAL, c_val, 2, 0, 0))
goto fail;
 
-   c_val[0] = REKEY_DISABLE;
+   c_val[0] = WILC_F

[PATCH 01/12] staging: wilc1000: use macro from ieee80211.h in register frame api's

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Make use of ieee80211.h provided macros and removed the extra macro
defined for the same purpose.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 4 ++--
 drivers/staging/wilc1000/host_interface.h | 3 ---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ++--
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 2bf91df..eb13b41 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3483,11 +3483,11 @@ void wilc_frame_register(struct wilc_vif *vif, u16 
frame_type, bool reg)
return;
 
switch (frame_type) {
-   case ACTION:
+   case IEEE80211_STYPE_ACTION:
msg->body.reg_frame.reg_id = ACTION_FRM_IDX;
break;
 
-   case PROBE_REQ:
+   case IEEE80211_STYPE_PROBE_REQ:
msg->body.reg_frame.reg_id = PROBE_REQ_IDX;
break;
 
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 523b46b..0185fc6 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -14,9 +14,6 @@
 #define STATION_MODE   0x02
 #define GO_MODE0x03
 #define CLIENT_MODE0x04
-#define ACTION 0xD0
-#define PROBE_REQ  0x40
-#define PROBE_RESP 0x50
 
 #define ACTION_FRM_IDX 0
 #define PROBE_REQ_IDX  1
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index a6f4fad..f92ecf6c 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1700,12 +1700,12 @@ void wilc_mgmt_frame_register(struct wiphy *wiphy, 
struct wireless_dev *wdev,
return;
 
switch (frame_type) {
-   case PROBE_REQ:
+   case IEEE80211_STYPE_PROBE_REQ:
vif->frame_reg[0].type = frame_type;
vif->frame_reg[0].reg = reg;
break;
 
-   case ACTION:
+   case IEEE80211_STYPE_ACTION:
vif->frame_reg[1].type = frame_type;
vif->frame_reg[1].reg = reg;
break;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/12] staging: wilc1000: move current_tx_rate enum to wilc_wlan_if.h file

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Move 'current_tx_rate' enum to wilc_wlan_if.h, to have it along with the
other FW related to constants. Also added prefix to have a better
namespace.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.h | 16 
 drivers/staging/wilc1000/linux_wlan.c |  2 +-
 drivers/staging/wilc1000/wilc_wlan_if.h   | 16 
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index fefbce6..91e60e3 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -127,22 +127,6 @@ struct host_if_pmkid_attr {
struct host_if_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS];
 };
 
-enum current_tx_rate {
-   AUTORATE= 0,
-   MBPS_1  = 1,
-   MBPS_2  = 2,
-   MBPS_5_5= 5,
-   MBPS_11 = 11,
-   MBPS_6  = 6,
-   MBPS_9  = 9,
-   MBPS_12 = 12,
-   MBPS_18 = 18,
-   MBPS_24 = 24,
-   MBPS_36 = 36,
-   MBPS_48 = 48,
-   MBPS_54 = 54
-};
-
 struct cfg_param_attr {
u32 flag;
u16 short_retry_limit;
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index c4787bb..faf97df 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -342,7 +342,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = AUTORATE;
+   c_val[0] = WILC_FW_TX_RATE_AUTO;
if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
goto fail;
 
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index c7e745d..36d6905 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -193,6 +193,22 @@ enum {
WILC_FW_SMPS_MODE_MIMO = 3, /* power save disable */
 };
 
+enum {
+   WILC_FW_TX_RATE_AUTO = 0,
+   WILC_FW_TX_RATE_MBPS_1 = 1,
+   WILC_FW_TX_RATE_MBPS_2 = 2,
+   WILC_FW_TX_RATE_MBPS_5_5 = 5,
+   WILC_FW_TX_RATE_MBPS_11 = 11,
+   WILC_FW_TX_RATE_MBPS_6 = 6,
+   WILC_FW_TX_RATE_MBPS_9 = 9,
+   WILC_FW_TX_RATE_MBPS_12 = 12,
+   WILC_FW_TX_RATE_MBPS_18 = 18,
+   WILC_FW_TX_RATE_MBPS_24 = 24,
+   WILC_FW_TX_RATE_MBPS_36 = 36,
+   WILC_FW_TX_RATE_MBPS_48 = 48,
+   WILC_FW_TX_RATE_MBPS_54 = 54
+};
+
 enum wid_type {
WID_CHAR= 0,
WID_SHORT   = 1,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/12] staging: wilc1000: rename tsf_hi element of network_info struct

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Rename 'tsf_hi' element in network_info struct as it's not used to store
only the higher 32-bit value but the complete 64-bit tsf value.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 8 
 drivers/staging/wilc1000/host_interface.h | 2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 5ab426c..3f3b013 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1098,14 +1098,14 @@ static s32 wilc_parse_network_info(u8 *msg_buffer,
if (ieee80211_is_probe_resp(mgt->frame_control)) {
info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info);
info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int);
-   info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp);
-   info->tsf_lo = (u32)info->tsf_hi;
+   info->tsf = le64_to_cpu(mgt->u.probe_resp.timestamp);
+   info->tsf_lo = (u32)info->tsf;
offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable);
} else if (ieee80211_is_beacon(mgt->frame_control)) {
info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info);
info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int);
-   info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp);
-   info->tsf_lo = (u32)info->tsf_hi;
+   info->tsf = le64_to_cpu(mgt->u.beacon.timestamp);
+   info->tsf_lo = (u32)info->tsf;
offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);
} else {
/* only process probe response and beacon frame */
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 606e80a..8279345 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -76,7 +76,7 @@ struct network_info {
u16 ies_len;
void *join_params;
struct rssi_history_buffer rssi_history;
-   u64 tsf_hi;
+   u64 tsf;
 };
 
 struct connect_info {
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 9906a9f7..1dec6bb 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -193,7 +193,7 @@ static void refresh_scan(struct wilc_priv *priv, bool 
direct_scan)
  channel,
  CFG80211_BSS_FTYPE_UNKNOWN,
  network_info->bssid,
- network_info->tsf_hi,
+ network_info->tsf,
  network_info->cap_info,
  network_info->beacon_period,
  (const u8 *)network_info->ies,
@@ -308,7 +308,7 @@ static void add_network_to_shadow(struct network_info 
*nw_info,
shadow_nw_info->beacon_period = nw_info->beacon_period;
shadow_nw_info->dtim_period = nw_info->dtim_period;
shadow_nw_info->ch = nw_info->ch;
-   shadow_nw_info->tsf_hi = nw_info->tsf_hi;
+   shadow_nw_info->tsf = nw_info->tsf;
if (ap_found != -1)
kfree(shadow_nw_info->ies);
shadow_nw_info->ies = kmemdup(nw_info->ies, nw_info->ies_len,
@@ -372,7 +372,7 @@ static void cfg_scan_result(enum scan_event scan_event,
  channel,
  CFG80211_BSS_FTYPE_UNKNOWN,
  network_info->bssid,
- network_info->tsf_hi,
+ network_info->tsf,
  network_info->cap_info,
  network_info->beacon_period,
  (const u8 *)network_info->ies,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/12] staging: wilc1000: rename firmware related constants to follow better namespace

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Rename the firmware related macro by prefix with 'WILC_FW_' prefix for
a better namespace. Also, move them to wilc_wlan_if.h file along with other
FW related macros.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c |  4 ++--
 drivers/staging/wilc1000/host_interface.h |  6 --
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  8 
 drivers/staging/wilc1000/wilc_wlan_if.h   | 12 
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 4dfdc7c..c238d39 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3485,11 +3485,11 @@ void wilc_frame_register(struct wilc_vif *vif, u16 
frame_type, bool reg)
 
switch (frame_type) {
case IEEE80211_STYPE_ACTION:
-   msg->body.reg_frame.reg_id = ACTION_FRM_IDX;
+   msg->body.reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX;
break;
 
case IEEE80211_STYPE_PROBE_REQ:
-   msg->body.reg_frame.reg_id = PROBE_REQ_IDX;
+   msg->body.reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX;
break;
 
default:
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 91e60e3..610ca2b 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -15,13 +15,7 @@
 #define GO_MODE0x03
 #define CLIENT_MODE0x04
 
-#define ACTION_FRM_IDX 0
-#define PROBE_REQ_IDX  1
 #define MAX_NUM_STA9
-#define DEFAULT_SCAN   0
-#define USER_SCAN  BIT(0)
-#define OBSS_PERIODIC_SCAN BIT(1)
-#define OBSS_ONETIME_SCAN  BIT(2)
 #define ADDKEY 0x1
 #define REMOVEKEY  0x2
 #define DEFAULTKEY 0x4
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index b882fe9..4cfa3ff4 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -612,15 +612,15 @@ static int scan(struct wiphy *wiphy, struct 
cfg80211_scan_request *request)
 &hidden_ntwk))
return -ENOMEM;
 
-   ret = wilc_scan(vif, USER_SCAN, WILC_FW_ACTIVE_SCAN,
-   scan_ch_list,
+   ret = wilc_scan(vif, WILC_FW_USER_SCAN,
+   WILC_FW_ACTIVE_SCAN, scan_ch_list,
request->n_channels,
(const u8 *)request->ie,
request->ie_len, cfg_scan_result,
(void *)priv, &hidden_ntwk);
} else {
-   ret = wilc_scan(vif, USER_SCAN, WILC_FW_ACTIVE_SCAN,
-   scan_ch_list,
+   ret = wilc_scan(vif, WILC_FW_USER_SCAN,
+   WILC_FW_ACTIVE_SCAN, scan_ch_list,
request->n_channels,
(const u8 *)request->ie,
request->ie_len, cfg_scan_result,
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index 36d6905..f4f6ac6 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -209,6 +209,18 @@ enum {
WILC_FW_TX_RATE_MBPS_54 = 54
 };
 
+enum {
+   WILC_FW_DEFAULT_SCAN = 0,
+   WILC_FW_USER_SCAN = BIT(0),
+   WILC_FW_OBSS_PERIODIC_SCAN = BIT(1),
+   WILC_FW_OBSS_ONETIME_SCAN = BIT(2)
+};
+
+enum {
+   WILC_FW_ACTION_FRM_IDX = 0,
+   WILC_FW_PROBE_REQ_IDX = 1
+};
+
 enum wid_type {
WID_CHAR= 0,
WID_SHORT   = 1,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/12] staging: wilc1000: use ENOBUFS error code instead of WILC_TX_ERR_NO_BUF macro

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Make use of 'ENOBUFS' instead of WILC_TX_ERR_NO_BUF macro. The value of
WILC_TX_ERR_NO_BUF is -2, which is confusing with ENOENT error code.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c   | 2 +-
 drivers/staging/wilc1000/wilc_wlan.c| 2 +-
 drivers/staging/wilc1000/wilc_wlan_if.h | 2 --
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 96d8834..66fb988 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -242,7 +242,7 @@ static int linux_wlan_txq_task(void *vp)
if (netif_queue_stopped(wl->vif[1]->ndev))
netif_wake_queue(wl->vif[1]->ndev);
}
-   } while (ret == WILC_TX_ERR_NO_BUF && !wl->close);
+   } while (ret == -ENOBUFS && !wl->close);
}
return 0;
 }
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 563ce62..f0b10e2 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -611,7 +611,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
goto out_release_bus;
 
if (entries == 0) {
-   ret = WILC_TX_ERR_NO_BUF;
+   ret = -ENOBUFS;
goto out_release_bus;
}
 
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index f4f6ac6..e2310d8 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -41,8 +41,6 @@ struct tx_complete_data {
 
 typedef void (*wilc_tx_complete_func_t)(void *, int);
 
-#define WILC_TX_ERR_NO_BUF (-2)
-
 /
  *
  *  Wlan Configuration ID
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/12] staging: wilc1000: use enum contants for mac status & added 'WILC_' prefix

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Clubbed mac status constants inside the enum constant and also added
'WILC_' prefix to have better namespace.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 15 ---
 drivers/staging/wilc1000/linux_wlan.c |  4 ++--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  2 +-
 drivers/staging/wilc1000/wilc_wlan_if.h   |  8 +---
 4 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index c200d90..46b1a00 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -797,7 +797,8 @@ static void handle_connect(struct work_struct *work)
}
 
conn_attr->result(CONN_DISCONN_EVENT_CONN_RESP,
- &conn_info, MAC_STATUS_DISCONNECTED,
+ &conn_info,
+ WILC_MAC_STATUS_DISCONNECTED,
  NULL, conn_attr->arg);
hif_drv->hif_state = HOST_IF_IDLE;
kfree(conn_info.req_ies);
@@ -857,7 +858,7 @@ static void handle_connect_timeout(struct work_struct *work)
 
hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
  &info,
- MAC_STATUS_DISCONNECTED,
+ WILC_MAC_STATUS_DISCONNECTED,
  NULL,
  hif_drv->usr_conn_req.arg);
 
@@ -1286,7 +1287,7 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
 
memset(&conn_info, 0, sizeof(struct connect_info));
 
-   if (mac_status == MAC_STATUS_CONNECTED) {
+   if (mac_status == WILC_MAC_STATUS_CONNECTED) {
u32 assoc_resp_info_len;
 
memset(hif_drv->assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
@@ -1311,7 +1312,7 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
if (hif_drv->usr_conn_req.bssid) {
memcpy(conn_info.bssid, hif_drv->usr_conn_req.bssid, 6);
 
-   if (mac_status == MAC_STATUS_CONNECTED &&
+   if (mac_status == WILC_MAC_STATUS_CONNECTED &&
conn_info.status == WLAN_STATUS_SUCCESS) {
memcpy(hif_drv->assoc_bssid,
   hif_drv->usr_conn_req.bssid, ETH_ALEN);
@@ -1331,7 +1332,7 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
  &conn_info, mac_status, NULL,
  hif_drv->usr_conn_req.arg);
 
-   if (mac_status == MAC_STATUS_CONNECTED &&
+   if (mac_status == WILC_MAC_STATUS_CONNECTED &&
conn_info.status == WLAN_STATUS_SUCCESS) {
wilc_set_power_mgmt(vif, 0, 0);
 
@@ -1423,10 +1424,10 @@ static void handle_rcvd_gnrl_async_info(struct 
work_struct *work)
mac_status  = rcvd_info->buffer[7];
if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
host_int_parse_assoc_resp_info(vif, mac_status);
-   } else if ((mac_status == MAC_STATUS_DISCONNECTED) &&
+   } else if ((mac_status == WILC_MAC_STATUS_DISCONNECTED) &&
   (hif_drv->hif_state == HOST_IF_CONNECTED)) {
host_int_handle_disconnect(vif);
-   } else if ((mac_status == MAC_STATUS_DISCONNECTED) &&
+   } else if ((mac_status == WILC_MAC_STATUS_DISCONNECTED) &&
   (hif_drv->usr_scan_req.scan_result)) {
del_timer(&hif_drv->scan_timer);
if (hif_drv->usr_scan_req.scan_result)
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 76c9012..274c4f6 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -162,7 +162,7 @@ void wilc_mac_indicate(struct wilc *wilc)
s8 status;
 
wilc_wlan_cfg_get_val(wilc, WID_STATUS, &status, 1);
-   if (wilc->mac_status == MAC_STATUS_INIT) {
+   if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
wilc->mac_status = status;
complete(&wilc->sync_event);
} else {
@@ -624,7 +624,7 @@ static int wilc_wlan_initialize(struct net_device *dev, 
struct wilc_vif *vif)
struct wilc *wl = vif->wilc;
 
if (!wl->initialized) {
-   wl->mac_status = MAC_STATUS_INIT;
+   wl->mac_status = WILC_MAC_STATUS_INIT;
wl->close = 0;
 
wlan_init_locks(dev);
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/w

[PATCH 06/12] staging: wilc1000: restructure macros used to handle security type

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Restructure the code to have a proper namespace for macro defined to
handle the security types. Move them as part of wilc_wlan_if.h header as
along with other macro defined for firmware.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c |  2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 43 +--
 drivers/staging/wilc1000/wilc_wlan_if.h   | 29 ++-
 3 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 274c4f6..6f0a2cd 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -391,7 +391,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = NO_SECURITY; /* NO_ENCRYPT, 0x79 */
+   c_val[0] = WILC_FW_SEC_NO;
if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0))
goto fail;
 
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 9038f8c..4b04775 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -6,15 +6,6 @@
 
 #include "wilc_wfi_cfgoperations.h"
 
-#define NO_ENCRYPT 0
-#define ENCRYPT_ENABLEDBIT(0)
-#define WEPBIT(1)
-#define WEP_EXTENDED   BIT(2)
-#define WPABIT(3)
-#define WPA2   BIT(4)
-#define AESBIT(5)
-#define TKIP   BIT(6)
-
 #define FRAME_TYPE_ID  0
 #define ACTION_CAT_ID  24
 #define ACTION_SUBTYPE_ID  25
@@ -655,7 +646,7 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
int ret;
u32 i;
u32 sel_bssi_idx = UINT_MAX;
-   u8 security = NO_ENCRYPT;
+   u8 security = WILC_FW_SEC_NO;
enum authtype auth_type = ANY;
u32 cipher_group;
 
@@ -703,9 +694,9 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len));
 
cipher_group = sme->crypto.cipher_group;
-   if (cipher_group != NO_ENCRYPT) {
+   if (cipher_group != 0) {
if (cipher_group == WLAN_CIPHER_SUITE_WEP40) {
-   security = ENCRYPT_ENABLED | WEP;
+   security = WILC_FW_SEC_WEP;
 
priv->wep_key_len[sme->key_idx] = sme->key_len;
memcpy(priv->wep_key[sme->key_idx], sme->key,
@@ -715,7 +706,7 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len,
 sme->key_idx);
} else if (cipher_group == WLAN_CIPHER_SUITE_WEP104) {
-   security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
+   security = WILC_FW_SEC_WEP_EXTENDED;
 
priv->wep_key_len[sme->key_idx] = sme->key_len;
memcpy(priv->wep_key[sme->key_idx], sme->key,
@@ -726,14 +717,14 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
 sme->key_idx);
} else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
if (cipher_group == WLAN_CIPHER_SUITE_TKIP)
-   security = ENCRYPT_ENABLED | WPA2 | TKIP;
+   security = WILC_FW_SEC_WPA2_TKIP;
else
-   security = ENCRYPT_ENABLED | WPA2 | AES;
+   security = WILC_FW_SEC_WPA2_AES;
} else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
if (cipher_group == WLAN_CIPHER_SUITE_TKIP)
-   security = ENCRYPT_ENABLED | WPA | TKIP;
+   security = WILC_FW_SEC_WPA_TKIP;
else
-   security = ENCRYPT_ENABLED | WPA | AES;
+   security = WILC_FW_SEC_WPA_AES;
} else {
ret = -ENOTSUPP;
netdev_err(dev, "%s: Unsupported cipher\n",
@@ -748,9 +739,9 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
u32 ciphers_pairwise = sme->crypto.ciphers_pairwise[i];
 
if (ciphers_pairwise == WLAN_CIPHER_SUITE_TKIP)
-   security = security | TKIP;
+   security |= WILC_FW_TKIP;
else
-   security = security | AES;
+   security |= WILC_F

[PATCH 10/12] staging: wilc1000: added 'WILC_' prefix for constants to have clear namespace

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

For better namespace added 'WILC_' prefix for driver specific constants.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 162 +++---
 drivers/staging/wilc1000/host_interface.h |  59 
 drivers/staging/wilc1000/linux_wlan.c |  20 +--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  56 
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   8 +-
 drivers/staging/wilc1000/wilc_wlan.c  |   4 +-
 6 files changed, 159 insertions(+), 150 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index c238d39..5ab426c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -94,7 +94,7 @@ struct set_multicast {
 };
 
 struct del_all_sta {
-   u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
+   u8 del_all_sta[WILC_MAX_NUM_STA][ETH_ALEN];
u8 assoc_sta;
 };
 
@@ -242,7 +242,7 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc 
*wilc, int idx)
 {
int index = idx - 1;
 
-   if (index < 0 || index >= NUM_CONCURRENT_IFC)
+   if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC)
return NULL;
 
return wilc->vif[index];
@@ -261,7 +261,7 @@ static void handle_set_channel(struct work_struct *work)
wid.val = (char *)&hif_set_ch->set_ch;
wid.size = sizeof(char);
 
-   ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
+   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
   wilc_get_vif_idx(vif));
 
if (ret)
@@ -284,7 +284,7 @@ static void handle_set_wfi_drv_handler(struct work_struct 
*work)
 
hif_drv = vif->hif_drv;
 
-   buffer = kzalloc(DRV_HANDLER_SIZE, GFP_KERNEL);
+   buffer = kzalloc(WILC_DRV_HANDLER_SIZE, GFP_KERNEL);
if (!buffer)
goto free_msg;
 
@@ -302,9 +302,9 @@ static void handle_set_wfi_drv_handler(struct work_struct 
*work)
wid.id = WID_SET_DRV_HANDLER;
wid.type = WID_STR;
wid.val = (s8 *)buffer;
-   wid.size = DRV_HANDLER_SIZE;
+   wid.size = WILC_DRV_HANDLER_SIZE;
 
-   ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
+   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
   hif_drv->driver_handler_id);
if (ret)
netdev_err(vif->ndev, "Failed to set driver handler\n");
@@ -331,7 +331,7 @@ static void handle_set_operation_mode(struct work_struct 
*work)
wid.val = (s8 *)&hif_op_mode->mode;
wid.size = sizeof(u32);
 
-   ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
+   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
   wilc_get_vif_idx(vif));
 
if (ret)
@@ -353,7 +353,7 @@ static void handle_get_mac_address(struct work_struct *work)
wid.val = get_mac_addr->mac_addr;
wid.size = ETH_ALEN;
 
-   ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
+   ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
   wilc_get_vif_idx(vif));
 
if (ret)
@@ -371,28 +371,28 @@ static void handle_cfg_param(struct work_struct *work)
struct wid wid_list[32];
int i = 0;
 
-   if (param->flag & RETRY_SHORT) {
+   if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) {
wid_list[i].id = WID_SHORT_RETRY_LIMIT;
wid_list[i].val = (s8 *)¶m->short_retry_limit;
wid_list[i].type = WID_SHORT;
wid_list[i].size = sizeof(u16);
i++;
}
-   if (param->flag & RETRY_LONG) {
+   if (param->flag & WILC_CFG_PARAM_RETRY_LONG) {
wid_list[i].id = WID_LONG_RETRY_LIMIT;
wid_list[i].val = (s8 *)¶m->long_retry_limit;
wid_list[i].type = WID_SHORT;
wid_list[i].size = sizeof(u16);
i++;
}
-   if (param->flag & FRAG_THRESHOLD) {
+   if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) {
wid_list[i].id = WID_FRAG_THRESHOLD;
wid_list[i].val = (s8 *)¶m->frag_threshold;
wid_list[i].type = WID_SHORT;
wid_list[i].size = sizeof(u16);
i++;
}
-   if (param->flag & RTS_THRESHOLD) {
+   if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) {
wid_list[i].id = WID_RTS_THRESHOLD;
wid_list[i].val = (s8 *)¶m->rts_threshold;
wid_list[i].type = WID_SHORT;
@@ -400,7 +400,7 @@ static void handle_cfg_param(struct work_struct *work)
i++;
}
 
-   ret = wilc_send_config_pkt(vif, SET_CFG, wid_list,
+   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
   i, wilc_get_vif_idx(vif));
 
if (ret)
@@ -424,7 +424,7 @@ static int handle_scan_done(struct wilc_vif *vif, enu

[PATCH 00/29] staging: wilc1000: avoid deferring of cfg80211 operation callback

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

This patch series mainly contains the change to handle the cfg80211
operation from its context. Now the WID commands are sent to firmware
directly from the caller context.
Also added few more patches to address the review comment received
earlier in series[1].

[1]. https://www.spinics.net/lists/linux-wireless/msg178705.html
 https://www.spinics.net/lists/linux-wireless/msg178707.html
 https://www.spinics.net/lists/linux-wireless/msg178709.html

Ajay Singh (29):
  staging: wilc1000: remove unnecessary checks in wilc_mac_close()
  staging: wilc1000: make use of put_unaligned_le32 in
handle_set_wfi_drv_handler()
  staging: wilc1000: avoid the use of the static variable to configure
wiphy struct
  staging: wilc1000: use mutex lock to synchronized sending 'wid' cmd to
firmware
  staging: wilc1000: handle tx power related callback from cfg80211
context
  staging: wilc1000: handle setting power management from cfg80211
context
  staging: wilc1000: handle add and edit station from the cfg80211
context
  staging: wilc1000: use void return for wilc_hif_pack_sta_param()
  staging: wilc1000: handle delete station related callback ops from
cfg80211 context
  staging: wilc1000: use is_zero_ether_addr() API to check mac address
  staging: wilc1000: handle delete beacon cfg ops from cfg80211
context()
  staging: wilc1000: handle add beacon operation callback from cfg80211
context
  staging: wilc1000: handle mgmt_frame_register ops from cfg82011
context
  staging: wilc1000: refactor wilc_set_mac_chnl_num() to avoid deferred
handling
  staging: wilc1000: refactor wilc_hif_set_cfg() to avoid deferred
handling
  staging: wilc1000: handle station dump cfg ops from cfg80211 context
  staging: wilc1000: refactor wilc_set_operation_mode() to avoid
deferred handling
  staging: wilc1000: refactor wilc_set_wfi_drv_handler() to avoid
deferred handling
  staging: wilc1000: refactor wilc_get_inactive_time() to avoid deferred
handling
  staging: wilc1000: handle key related cfg operation from cfg80211
context
  staging: wilc1000: delete the unused code after code refactor
  staging: wilc1000: refactor wilc_get_mac_address() to avoid deferred
handling
  staging: wilc1000: use correct 'struct remain_ch' variable in scan
complete
  staging: wilc1000: handle remain on channel cfg ops from cfg80211
context
  staging: wilc1000: handle get_station() ops callback in cfg80211
context
  staging: wilc1000: avoid deferred handling of cfg80211 disconnect
callback
  staging: wilc1000: handle connect ops callback from cfg80211 context
  staging: wilc1000: avoid extra buffer copy while connect cfg ops
  staging: wilc1000: handle scan operation callback from cfg80211
context

 drivers/staging/wilc1000/host_interface.c | 2405 ++---
 drivers/staging/wilc1000/host_interface.h |   79 +-
 drivers/staging/wilc1000/linux_wlan.c |   30 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  167 +-
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   65 +-
 drivers/staging/wilc1000/wilc_wlan.c  |   21 +-
 6 files changed, 755 insertions(+), 2012 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/29] staging: wilc1000: handle tx power related callback from cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Avoid the use of internal work queue to defer the handling of tx power
related cfg operations callback. Now issuing the wid command to firmware
directly from the caller context.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 85 +--
 1 file changed, 14 insertions(+), 71 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index e179a8e..88d9010 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -117,10 +117,6 @@ struct sta_inactive_t {
u8 mac[6];
 };
 
-struct tx_power {
-   u8 tx_pwr;
-};
-
 union message_body {
struct scan_attr scan_info;
struct connect_attr con_info;
@@ -145,7 +141,6 @@ union message_body {
struct reg_frame reg_frame;
char *data;
struct del_all_sta del_all_sta_info;
-   struct tx_power tx_power;
 };
 
 struct host_if_msg {
@@ -2371,48 +2366,6 @@ static void handle_set_mcast_filter(struct work_struct 
*work)
kfree(msg);
 }
 
-static void handle_set_tx_pwr(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   u8 tx_pwr = msg->body.tx_power.tx_pwr;
-   int ret;
-   struct wid wid;
-
-   wid.id = WID_TX_POWER;
-   wid.type = WID_CHAR;
-   wid.val = &tx_pwr;
-   wid.size = sizeof(char);
-
-   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
-  wilc_get_vif_idx(vif));
-   if (ret)
-   netdev_err(vif->ndev, "Failed to set TX PWR\n");
-   kfree(msg);
-}
-
-/* Note: 'msg' will be free after using data */
-static void handle_get_tx_pwr(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   u8 *tx_pwr = &msg->body.tx_power.tx_pwr;
-   int ret;
-   struct wid wid;
-
-   wid.id = WID_TX_POWER;
-   wid.type = WID_CHAR;
-   wid.val = (s8 *)tx_pwr;
-   wid.size = sizeof(char);
-
-   ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
-  wilc_get_vif_idx(vif));
-   if (ret)
-   netdev_err(vif->ndev, "Failed to get TX PWR\n");
-
-   complete(&msg->work_comp);
-}
-
 static void handle_scan_timer(struct work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -3740,19 +3693,15 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, 
bool enabled, u32 count,
 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
 {
int ret;
-   struct host_if_msg *msg;
-
-   msg = wilc_alloc_work(vif, handle_set_tx_pwr, false);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
+   struct wid wid;
 
-   msg->body.tx_power.tx_pwr = tx_power;
+   wid.id = WID_TX_POWER;
+   wid.type = WID_CHAR;
+   wid.val = &tx_power;
+   wid.size = sizeof(char);
 
-   ret = wilc_enqueue_work(msg);
-   if (ret) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   kfree(msg);
-   }
+   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+  wilc_get_vif_idx(vif));
 
return ret;
 }
@@ -3760,21 +3709,15 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
 {
int ret;
-   struct host_if_msg *msg;
+   struct wid wid;
 
-   msg = wilc_alloc_work(vif, handle_get_tx_pwr, true);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
+   wid.id = WID_TX_POWER;
+   wid.type = WID_CHAR;
+   wid.val = tx_power;
+   wid.size = sizeof(char);
 
-   ret = wilc_enqueue_work(msg);
-   if (ret) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   } else {
-   wait_for_completion(&msg->work_comp);
-   *tx_power = msg->body.tx_power.tx_pwr;
-   }
+   ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
+  wilc_get_vif_idx(vif));
 
-   /* free 'msg' after copying data */
-   kfree(msg);
return ret;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/29] staging: wilc1000: handle delete beacon cfg ops from cfg80211 context()

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor the code to handle delete beacon cfg operation from cfg80211
context.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 39 ---
 1 file changed, 10 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 310138d..995ca65 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1934,26 +1934,6 @@ static void handle_add_beacon(struct work_struct *work)
kfree(msg);
 }
 
-static void handle_del_beacon(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   int result;
-   struct wid wid;
-   u8 del_beacon = 0;
-
-   wid.id = WID_DEL_BEACON;
-   wid.type = WID_CHAR;
-   wid.size = sizeof(char);
-   wid.val = &del_beacon;
-
-   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-   if (result)
-   netdev_err(vif->ndev, "Failed to send delete beacon\n");
-   kfree(msg);
-}
-
 static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac,
struct station_parameters *params)
 {
@@ -3326,17 +3306,18 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, 
u32 dtim_period,
 int wilc_del_beacon(struct wilc_vif *vif)
 {
int result;
-   struct host_if_msg *msg;
+   struct wid wid;
+   u8 del_beacon = 0;
 
-   msg = wilc_alloc_work(vif, handle_del_beacon, false);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
+   wid.id = WID_DEL_BEACON;
+   wid.type = WID_CHAR;
+   wid.size = sizeof(char);
+   wid.val = &del_beacon;
 
-   result = wilc_enqueue_work(msg);
-   if (result) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   kfree(msg);
-   }
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
+   if (result)
+   netdev_err(vif->ndev, "Failed to send delete beacon\n");
 
return result;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/29] staging: wilc1000: handle delete station related callback ops from cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor the code to handle delete/delete_all station operation callback
from cfg80211 context.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 147 +++---
 1 file changed, 33 insertions(+), 114 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 40477ca..8ce56a3 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -94,12 +94,8 @@ struct set_multicast {
 };
 
 struct del_all_sta {
-   u8 del_all_sta[WILC_MAX_NUM_STA][ETH_ALEN];
u8 assoc_sta;
-};
-
-struct del_sta {
-   u8 mac_addr[ETH_ALEN];
+   u8 mac[WILC_MAX_NUM_STA][ETH_ALEN];
 };
 
 struct set_ip_addr {
@@ -121,7 +117,6 @@ union message_body {
struct cfg_param_attr cfg_info;
struct channel_attr channel_info;
struct beacon_attr beacon_info;
-   struct del_sta del_sta_info;
struct sta_inactive_t mac_info;
struct set_ip_addr ip_info;
struct drv_handler drv;
@@ -132,7 +127,6 @@ union message_body {
struct remain_ch remain_on_ch;
struct reg_frame reg_frame;
char *data;
-   struct del_all_sta del_all_sta_info;
 };
 
 struct host_if_msg {
@@ -1989,78 +1983,6 @@ static void wilc_hif_pack_sta_param(u8 *cur_byte, const 
u8 *mac,
put_unaligned_le16(params->sta_flags_set, cur_byte);
 }
 
-static void handle_del_all_sta(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct del_all_sta *param = &msg->body.del_all_sta_info;
-   int result;
-   struct wid wid;
-   u8 *curr_byte;
-   u8 i;
-   u8 zero_buff[6] = {0};
-
-   wid.id = WID_DEL_ALL_STA;
-   wid.type = WID_STR;
-   wid.size = (param->assoc_sta * ETH_ALEN) + 1;
-
-   wid.val = kmalloc((param->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
-   if (!wid.val)
-   goto error;
-
-   curr_byte = wid.val;
-
-   *(curr_byte++) = param->assoc_sta;
-
-   for (i = 0; i < WILC_MAX_NUM_STA; i++) {
-   if (memcmp(param->del_all_sta[i], zero_buff, ETH_ALEN))
-   memcpy(curr_byte, param->del_all_sta[i], ETH_ALEN);
-   else
-   continue;
-
-   curr_byte += ETH_ALEN;
-   }
-
-   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-   if (result)
-   netdev_err(vif->ndev, "Failed to send delete all station\n");
-
-error:
-   kfree(wid.val);
-
-   /* free 'msg' data in caller */
-   complete(&msg->work_comp);
-}
-
-static void handle_del_station(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct del_sta *param = &msg->body.del_sta_info;
-   int result;
-   struct wid wid;
-
-   wid.id = WID_REMOVE_STA;
-   wid.type = WID_BIN;
-   wid.size = ETH_ALEN;
-
-   wid.val = kmalloc(wid.size, GFP_KERNEL);
-   if (!wid.val)
-   goto error;
-
-   ether_addr_copy(wid.val, param->mac_addr);
-
-   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-   if (result)
-   netdev_err(vif->ndev, "Failed to del station\n");
-
-error:
-   kfree(wid.val);
-   kfree(msg);
-}
-
 static int handle_remain_on_chan(struct wilc_vif *vif,
 struct remain_ch *hif_remain_ch)
 {
@@ -3448,65 +3370,62 @@ int wilc_add_station(struct wilc_vif *vif, const u8 
*mac,
 
 int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr)
 {
+   struct wid wid;
int result;
-   struct host_if_msg *msg;
-   struct del_sta *del_sta_info;
-
-   msg = wilc_alloc_work(vif, handle_del_station, false);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
 
-   del_sta_info = &msg->body.del_sta_info;
+   wid.id = WID_REMOVE_STA;
+   wid.type = WID_BIN;
+   wid.size = ETH_ALEN;
+   wid.val = kzalloc(wid.size, GFP_KERNEL);
+   if (!wid.val)
+   return -ENOMEM;
 
if (!mac_addr)
-   eth_broadcast_addr(del_sta_info->mac_addr);
+   eth_broadcast_addr(wid.val);
else
-   memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
+   ether_addr_copy(wid.val, mac_addr);
+
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
+   if (result)
+   netdev_err(vif->ndev, "Failed to del station\n");
+
+   kfree(wid.val);
 
-   result = wilc_enqueue_work(msg);
-   if (result) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   

[PATCH 12/29] staging: wilc1000: handle add beacon operation callback from cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor add/change beacon cfg80211 operation callback to handle from
cfg context. Also avoided extra copy of information by packing directly
in firmware expected format.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 128 +-
 drivers/staging/wilc1000/host_interface.h |   2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  10 +-
 3 files changed, 32 insertions(+), 108 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 995ca65..97b84d2 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -78,15 +78,6 @@ struct channel_attr {
u8 set_ch;
 };
 
-struct beacon_attr {
-   u32 interval;
-   u32 dtim_period;
-   u32 head_len;
-   u8 *head;
-   u32 tail_len;
-   u8 *tail;
-};
-
 struct set_multicast {
bool enabled;
u32 cnt;
@@ -116,7 +107,6 @@ union message_body {
struct key_attr key_info;
struct cfg_param_attr cfg_info;
struct channel_attr channel_info;
-   struct beacon_attr beacon_info;
struct sta_inactive_t mac_info;
struct set_ip_addr ip_info;
struct drv_handler drv;
@@ -1878,62 +1868,6 @@ static void handle_get_inactive_time(struct work_struct 
*work)
complete(&msg->work_comp);
 }
 
-static void handle_add_beacon(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct beacon_attr *param = &msg->body.beacon_info;
-   int result;
-   struct wid wid;
-   u8 *cur_byte;
-
-   wid.id = WID_ADD_BEACON;
-   wid.type = WID_BIN;
-   wid.size = param->head_len + param->tail_len + 16;
-   wid.val = kmalloc(wid.size, GFP_KERNEL);
-   if (!wid.val)
-   goto error;
-
-   cur_byte = wid.val;
-   *cur_byte++ = (param->interval & 0xFF);
-   *cur_byte++ = ((param->interval >> 8) & 0xFF);
-   *cur_byte++ = ((param->interval >> 16) & 0xFF);
-   *cur_byte++ = ((param->interval >> 24) & 0xFF);
-
-   *cur_byte++ = (param->dtim_period & 0xFF);
-   *cur_byte++ = ((param->dtim_period >> 8) & 0xFF);
-   *cur_byte++ = ((param->dtim_period >> 16) & 0xFF);
-   *cur_byte++ = ((param->dtim_period >> 24) & 0xFF);
-
-   *cur_byte++ = (param->head_len & 0xFF);
-   *cur_byte++ = ((param->head_len >> 8) & 0xFF);
-   *cur_byte++ = ((param->head_len >> 16) & 0xFF);
-   *cur_byte++ = ((param->head_len >> 24) & 0xFF);
-
-   memcpy(cur_byte, param->head, param->head_len);
-   cur_byte += param->head_len;
-
-   *cur_byte++ = (param->tail_len & 0xFF);
-   *cur_byte++ = ((param->tail_len >> 8) & 0xFF);
-   *cur_byte++ = ((param->tail_len >> 16) & 0xFF);
-   *cur_byte++ = ((param->tail_len >> 24) & 0xFF);
-
-   if (param->tail)
-   memcpy(cur_byte, param->tail, param->tail_len);
-   cur_byte += param->tail_len;
-
-   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-   if (result)
-   netdev_err(vif->ndev, "Failed to send add beacon\n");
-
-error:
-   kfree(wid.val);
-   kfree(param->head);
-   kfree(param->tail);
-   kfree(msg);
-}
-
 static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac,
struct station_parameters *params)
 {
@@ -3258,47 +3192,43 @@ void wilc_frame_register(struct wilc_vif *vif, u16 
frame_type, bool reg)
 }
 
 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
-   u32 head_len, u8 *head, u32 tail_len, u8 *tail)
+   struct cfg80211_beacon_data *params)
 {
+   struct wid wid;
int result;
-   struct host_if_msg *msg;
-   struct beacon_attr *beacon_info;
+   u8 *cur_byte;
 
-   msg = wilc_alloc_work(vif, handle_add_beacon, false);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
+   wid.id = WID_ADD_BEACON;
+   wid.type = WID_BIN;
+   wid.size = params->head_len + params->tail_len + 16;
+   wid.val = kzalloc(wid.size, GFP_KERNEL);
+   if (!wid.val)
+   return -ENOMEM;
 
-   beacon_info = &msg->body.beacon_info;
-   beacon_info->interval = interval;
-   beacon_info->dtim_period = dtim_period;
-   beacon_info->head_len = head_len;
-   beacon_info->head = kmemdup(head, head_len, GFP_KERNEL);
-   if (!beacon_info->head) {
-   result = -ENOMEM;
-   goto error;
-   }
-   beacon_info->tail_len = tail_len;
+   cur_byte = wid.val;
+   put_unaligned_le32(interval, cur_byte);
+   cur_byte += 4;
+   put_unaligned_le32(dtim_period, cur_byte);
+   cur_byte += 4;
+   put_unaligned_le32(params->head_len, cur_byte);
+   cur_byte += 4;
 
-   

[PATCH 06/29] staging: wilc1000: handle setting power management from cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor the code to handle the power management cfg operation from the
caller context.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 56 +++
 1 file changed, 13 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 88d9010..4074a37 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -102,11 +102,6 @@ struct del_sta {
u8 mac_addr[ETH_ALEN];
 };
 
-struct power_mgmt_param {
-   bool enabled;
-   u32 timeout;
-};
-
 struct set_ip_addr {
u8 *ip_addr;
u8 idx;
@@ -129,7 +124,6 @@ union message_body {
struct add_sta_param add_sta_info;
struct del_sta del_sta_info;
struct add_sta_param edit_sta_info;
-   struct power_mgmt_param pwr_mgmt_info;
struct sta_inactive_t mac_info;
struct set_ip_addr ip_info;
struct drv_handler drv;
@@ -2298,32 +2292,6 @@ static void listen_timer_cb(struct timer_list *t)
}
 }
 
-static void handle_power_management(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct power_mgmt_param *pm_param = &msg->body.pwr_mgmt_info;
-   int result;
-   struct wid wid;
-   s8 power_mode;
-
-   wid.id = WID_POWER_MANAGEMENT;
-
-   if (pm_param->enabled)
-   power_mode = WILC_FW_MIN_FAST_PS;
-   else
-   power_mode = WILC_FW_NO_POWERSAVE;
-
-   wid.val = &power_mode;
-   wid.size = sizeof(char);
-
-   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-   if (result)
-   netdev_err(vif->ndev, "Failed to send power management\n");
-   kfree(msg);
-}
-
 static void handle_set_mcast_filter(struct work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -3647,24 +3615,26 @@ int wilc_edit_station(struct wilc_vif *vif,
 
 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout)
 {
+   struct wid wid;
int result;
-   struct host_if_msg *msg;
+   s8 power_mode;
 
if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled)
return 0;
 
-   msg = wilc_alloc_work(vif, handle_power_management, false);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
+   if (enabled)
+   power_mode = WILC_FW_MIN_FAST_PS;
+   else
+   power_mode = WILC_FW_NO_POWERSAVE;
 
-   msg->body.pwr_mgmt_info.enabled = enabled;
-   msg->body.pwr_mgmt_info.timeout = timeout;
+   wid.id = WID_POWER_MANAGEMENT;
+   wid.val = &power_mode;
+   wid.size = sizeof(char);
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
+   if (result)
+   netdev_err(vif->ndev, "Failed to send power management\n");
 
-   result = wilc_enqueue_work(msg);
-   if (result) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   kfree(msg);
-   }
return result;
 }
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/29] staging: wilc1000: use void return for wilc_hif_pack_sta_param()

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Change the return type from u32 to void for wilc_hif_pack_sta_param() as
its value is not used. Also remove the use of extra pointer as it's not
required now.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index fedcff8..40477ca 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1960,12 +1960,9 @@ static void handle_del_beacon(struct work_struct *work)
kfree(msg);
 }
 
-static u32 wilc_hif_pack_sta_param(u8 *buff, const u8 *mac,
-  struct station_parameters *params)
+static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac,
+   struct station_parameters *params)
 {
-   u8 *cur_byte;
-
-   cur_byte = buff;
ether_addr_copy(cur_byte, mac);
cur_byte += ETH_ALEN;
 
@@ -1990,9 +1987,6 @@ static u32 wilc_hif_pack_sta_param(u8 *buff, const u8 
*mac,
put_unaligned_le16(params->sta_flags_mask, cur_byte);
cur_byte += 2;
put_unaligned_le16(params->sta_flags_set, cur_byte);
-   cur_byte += 2;
-
-   return cur_byte - buff;
 }
 
 static void handle_del_all_sta(struct work_struct *work)
@@ -3440,7 +3434,7 @@ int wilc_add_station(struct wilc_vif *vif, const u8 *mac,
return -ENOMEM;
 
cur_byte = wid.val;
-   cur_byte += wilc_hif_pack_sta_param(cur_byte, mac, params);
+   wilc_hif_pack_sta_param(cur_byte, mac, params);
 
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
  wilc_get_vif_idx(vif));
@@ -3532,7 +3526,7 @@ int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
return -ENOMEM;
 
cur_byte = wid.val;
-   cur_byte += wilc_hif_pack_sta_param(cur_byte, mac, params);
+   wilc_hif_pack_sta_param(cur_byte, mac, params);
 
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
  wilc_get_vif_idx(vif));
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/29] staging: wilc1000: remove unnecessary checks in wilc_mac_close()

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Remove unnecessary 'if' check in wilc_mac_close() as those conditions
will not happen.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c | 22 +-
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 66fb988..c92ee79 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -896,31 +896,11 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct 
net_device *ndev)
 
 static int wilc_mac_close(struct net_device *ndev)
 {
-   struct wilc_priv *priv;
struct wilc_vif *vif = netdev_priv(ndev);
-   struct host_if_drv *hif_drv;
-   struct wilc *wl;
-
-   if (!vif || !vif->ndev || !vif->ndev->ieee80211_ptr ||
-   !vif->ndev->ieee80211_ptr->wiphy)
-   return 0;
-
-   priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy);
-   wl = vif->wilc;
-
-   if (!priv)
-   return 0;
-
-   hif_drv = (struct host_if_drv *)priv->hif_drv;
+   struct wilc *wl = vif->wilc;
 
netdev_dbg(ndev, "Mac close\n");
 
-   if (!wl)
-   return 0;
-
-   if (!hif_drv)
-   return 0;
-
if (wl->open_ifcs > 0)
wl->open_ifcs--;
else
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/29] staging: wilc1000: avoid the use of the static variable to configure wiphy struct

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor code to avoid the use of static variables to configure the
'wiphy' structure. Now move static variables as part of 'priv' data so
it helped to maintain this information per interface.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 92 +--
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 60 +++
 2 files changed, 80 insertions(+), 72 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 1dec6bb..69b181f 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -32,14 +32,6 @@
 #define nl80211_SCAN_RESULT_EXPIRE (3 * HZ)
 #define SCAN_RESULT_EXPIRE (40 * HZ)
 
-static const u32 cipher_suites[] = {
-   WLAN_CIPHER_SUITE_WEP40,
-   WLAN_CIPHER_SUITE_WEP104,
-   WLAN_CIPHER_SUITE_TKIP,
-   WLAN_CIPHER_SUITE_CCMP,
-   WLAN_CIPHER_SUITE_AES_CMAC,
-};
-
 static const struct ieee80211_txrx_stypes
wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
[NL80211_IFTYPE_STATION] = {
@@ -73,53 +65,6 @@ static const struct wiphy_wowlan_support wowlan_support = {
.flags = WIPHY_WOWLAN_ANY
 };
 
-#define CHAN2G(_channel, _freq, _flags) {   \
-   .band = NL80211_BAND_2GHZ, \
-   .center_freq  = (_freq), \
-   .hw_value = (_channel),  \
-   .flags= (_flags),\
-   .max_antenna_gain = 0,   \
-   .max_power= 30,  \
-}
-
-static struct ieee80211_channel ieee80211_2ghz_channels[] = {
-   CHAN2G(1,  2412, 0),
-   CHAN2G(2,  2417, 0),
-   CHAN2G(3,  2422, 0),
-   CHAN2G(4,  2427, 0),
-   CHAN2G(5,  2432, 0),
-   CHAN2G(6,  2437, 0),
-   CHAN2G(7,  2442, 0),
-   CHAN2G(8,  2447, 0),
-   CHAN2G(9,  2452, 0),
-   CHAN2G(10, 2457, 0),
-   CHAN2G(11, 2462, 0),
-   CHAN2G(12, 2467, 0),
-   CHAN2G(13, 2472, 0),
-   CHAN2G(14, 2484, 0),
-};
-
-#define RATETAB_ENT(_rate, _hw_value, _flags) {\
-   .bitrate  = (_rate),\
-   .hw_value = (_hw_value),\
-   .flags= (_flags),   \
-}
-
-static struct ieee80211_rate ieee80211_bitrates[] = {
-   RATETAB_ENT(10,  0,  0),
-   RATETAB_ENT(20,  1,  0),
-   RATETAB_ENT(55,  2,  0),
-   RATETAB_ENT(110, 3,  0),
-   RATETAB_ENT(60,  9,  0),
-   RATETAB_ENT(90,  6,  0),
-   RATETAB_ENT(120, 7,  0),
-   RATETAB_ENT(180, 8,  0),
-   RATETAB_ENT(240, 9,  0),
-   RATETAB_ENT(360, 10, 0),
-   RATETAB_ENT(480, 11, 0),
-   RATETAB_ENT(540, 12, 0),
-};
-
 struct p2p_mgmt_data {
int size;
u8 *buff;
@@ -130,13 +75,6 @@ static u8 curr_channel;
 static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09};
 static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
 
-static struct ieee80211_supported_band wilc_band_2ghz = {
-   .channels = ieee80211_2ghz_channels,
-   .n_channels = ARRAY_SIZE(ieee80211_2ghz_channels),
-   .bitrates = ieee80211_bitrates,
-   .n_bitrates = ARRAY_SIZE(ieee80211_bitrates),
-};
-
 #define AGING_TIME (9 * 1000)
 #define DURING_IP_TIME_OUT 15000
 
@@ -2110,14 +2048,6 @@ static struct wireless_dev *wilc_wfi_cfg_alloc(void)
if (!wdev->wiphy)
goto free_mem;
 
-   wilc_band_2ghz.ht_cap.ht_supported = 1;
-   wilc_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
-   wilc_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
-   wilc_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
-   wilc_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
-
-   wdev->wiphy->bands[NL80211_BAND_2GHZ] = &wilc_band_2ghz;
-
return wdev;
 
 free_mem:
@@ -2141,6 +2071,22 @@ struct wireless_dev *wilc_create_wiphy(struct net_device 
*net,
 
priv = wdev_priv(wdev);
priv->wdev = wdev;
+
+   memcpy(priv->bitrates, wilc_bitrates, sizeof(wilc_bitrates));
+   memcpy(priv->channels, wilc_2ghz_channels, sizeof(wilc_2ghz_channels));
+   priv->band.bitrates = priv->bitrates;
+   priv->band.n_bitrates = ARRAY_SIZE(priv->bitrates);
+   priv->band.channels = priv->channels;
+   priv->band.n_channels = ARRAY_SIZE(wilc_2ghz_channels);
+
+   priv->band.ht_cap.ht_supported = 1;
+   priv->band.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
+   priv->band.ht_cap.mcs.rx_mask[0] = 0xff;
+   priv->band.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
+   priv->band.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
+
+   wdev->wiphy->bands[NL80211_BAND_2GHZ] = &priv->band;
+
wdev->wiphy->max_scan_ssids = WILC_MAX_NUM_PROBED_SSID;
 #ifdef CONFIG_PM
wdev->wiphy->wow

[PATCH 04/29] staging: wilc1000: use mutex lock to synchronized sending 'wid' cmd to firmware

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Use mutex lock to protect the issuing of wid cmd to the firmware.
Currently the wid commands are synchronized by use of hif_workqueue work
queue.
Now, these changes are required to synchronize the access to wid
command, so the commands can be issued directly from cfg80211 context
and 'WILC_wq' thread.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c |  2 ++
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  3 ++-
 drivers/staging/wilc1000/wilc_wlan.c  | 21 ++---
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index c92ee79..e246d18 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -531,6 +531,7 @@ static void wlan_deinit_locks(struct net_device *dev)
 
mutex_destroy(&wilc->hif_cs);
mutex_destroy(&wilc->rxq_cs);
+   mutex_destroy(&wilc->cfg_cmd_lock);
mutex_destroy(&wilc->txq_add_to_head_cs);
 }
 
@@ -592,6 +593,7 @@ static void wlan_init_locks(struct net_device *dev)
 
mutex_init(&wl->hif_cs);
mutex_init(&wl->rxq_cs);
+   mutex_init(&wl->cfg_cmd_lock);
 
spin_lock_init(&wl->txq_spinlock);
mutex_init(&wl->txq_add_to_head_cs);
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index e71d949..02970c3 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -247,7 +247,8 @@ struct wilc {
struct task_struct *txq_thread;
 
int quit;
-   int cfg_frame_in_use;
+   /* lock to protect issue of wid command to firmware */
+   struct mutex cfg_cmd_lock;
struct wilc_cfg_frame cfg_frame;
u32 cfg_frame_offset;
int cfg_seq_no;
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index f0b10e2..3c5e9e0 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1122,8 +1122,7 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, 
u16 wid, u8 *buffer,
int ret_size;
struct wilc *wilc = vif->wilc;
 
-   if (wilc->cfg_frame_in_use)
-   return 0;
+   mutex_lock(&wilc->cfg_cmd_lock);
 
if (start)
wilc->cfg_frame_offset = 0;
@@ -1134,11 +1133,12 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, 
u16 wid, u8 *buffer,
offset += ret_size;
wilc->cfg_frame_offset = offset;
 
-   if (!commit)
+   if (!commit) {
+   mutex_unlock(&wilc->cfg_cmd_lock);
return ret_size;
+   }
 
netdev_dbg(vif->ndev, "%s: seqno[%d]\n", __func__, wilc->cfg_seq_no);
-   wilc->cfg_frame_in_use = 1;
 
if (wilc_wlan_cfg_commit(vif, WILC_CFG_SET, drv_handler))
ret_size = 0;
@@ -1149,9 +1149,9 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, 
u16 wid, u8 *buffer,
ret_size = 0;
}
 
-   wilc->cfg_frame_in_use = 0;
wilc->cfg_frame_offset = 0;
wilc->cfg_seq_no += 1;
+   mutex_unlock(&wilc->cfg_cmd_lock);
 
return ret_size;
 }
@@ -1163,8 +1163,7 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, 
u16 wid, int commit,
int ret_size;
struct wilc *wilc = vif->wilc;
 
-   if (wilc->cfg_frame_in_use)
-   return 0;
+   mutex_lock(&wilc->cfg_cmd_lock);
 
if (start)
wilc->cfg_frame_offset = 0;
@@ -1174,10 +1173,10 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, 
u16 wid, int commit,
offset += ret_size;
wilc->cfg_frame_offset = offset;
 
-   if (!commit)
+   if (!commit) {
+   mutex_unlock(&wilc->cfg_cmd_lock);
return ret_size;
-
-   wilc->cfg_frame_in_use = 1;
+   }
 
if (wilc_wlan_cfg_commit(vif, WILC_CFG_QUERY, drv_handler))
ret_size = 0;
@@ -1187,9 +1186,9 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, 
u16 wid, int commit,
netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__);
ret_size = 0;
}
-   wilc->cfg_frame_in_use = 0;
wilc->cfg_frame_offset = 0;
wilc->cfg_seq_no += 1;
+   mutex_unlock(&wilc->cfg_cmd_lock);
 
return ret_size;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/29] staging: wilc1000: handle add and edit station from the cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor the code to avoid handling of add/edit stations using work
queue and now set the wid value from caller context.
Avoid making an extra copy of buffer and directly copy the data in
firmware expected format.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 192 +++---
 drivers/staging/wilc1000/host_interface.h |   7 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  35 +---
 3 files changed, 67 insertions(+), 167 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 4074a37..fedcff8 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -121,9 +121,7 @@ union message_body {
struct cfg_param_attr cfg_info;
struct channel_attr channel_info;
struct beacon_attr beacon_info;
-   struct add_sta_param add_sta_info;
struct del_sta del_sta_info;
-   struct add_sta_param edit_sta_info;
struct sta_inactive_t mac_info;
struct set_ip_addr ip_info;
struct drv_handler drv;
@@ -1962,67 +1960,41 @@ static void handle_del_beacon(struct work_struct *work)
kfree(msg);
 }
 
-static u32 wilc_hif_pack_sta_param(u8 *buff, struct add_sta_param *param)
+static u32 wilc_hif_pack_sta_param(u8 *buff, const u8 *mac,
+  struct station_parameters *params)
 {
u8 *cur_byte;
 
cur_byte = buff;
-
-   memcpy(cur_byte, param->bssid, ETH_ALEN);
-   cur_byte +=  ETH_ALEN;
-
-   *cur_byte++ = param->aid & 0xFF;
-   *cur_byte++ = (param->aid >> 8) & 0xFF;
-
-   *cur_byte++ = param->rates_len;
-   if (param->rates_len > 0)
-   memcpy(cur_byte, param->rates, param->rates_len);
-   cur_byte += param->rates_len;
-
-   *cur_byte++ = param->ht_supported;
-   memcpy(cur_byte, ¶m->ht_capa, sizeof(struct ieee80211_ht_cap));
+   ether_addr_copy(cur_byte, mac);
+   cur_byte += ETH_ALEN;
+
+   put_unaligned_le16(params->aid, cur_byte);
+   cur_byte += 2;
+
+   *cur_byte++ = params->supported_rates_len;
+   if (params->supported_rates_len > 0)
+   memcpy(cur_byte, params->supported_rates,
+  params->supported_rates_len);
+   cur_byte += params->supported_rates_len;
+
+   if (params->ht_capa) {
+   *cur_byte++ = true;
+   memcpy(cur_byte, ¶ms->ht_capa,
+  sizeof(struct ieee80211_ht_cap));
+   } else {
+   *cur_byte++ = false;
+   }
cur_byte += sizeof(struct ieee80211_ht_cap);
 
-   *cur_byte++ = param->flags_mask & 0xFF;
-   *cur_byte++ = (param->flags_mask >> 8) & 0xFF;
-
-   *cur_byte++ = param->flags_set & 0xFF;
-   *cur_byte++ = (param->flags_set >> 8) & 0xFF;
+   put_unaligned_le16(params->sta_flags_mask, cur_byte);
+   cur_byte += 2;
+   put_unaligned_le16(params->sta_flags_set, cur_byte);
+   cur_byte += 2;
 
return cur_byte - buff;
 }
 
-static void handle_add_station(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct add_sta_param *param = &msg->body.add_sta_info;
-   int result;
-   struct wid wid;
-   u8 *cur_byte;
-
-   wid.id = WID_ADD_STA;
-   wid.type = WID_BIN;
-   wid.size = WILC_ADD_STA_LENGTH + param->rates_len;
-
-   wid.val = kmalloc(wid.size, GFP_KERNEL);
-   if (!wid.val)
-   goto error;
-
-   cur_byte = wid.val;
-   cur_byte += wilc_hif_pack_sta_param(cur_byte, param);
-
-   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-   if (result != 0)
-   netdev_err(vif->ndev, "Failed to send add station\n");
-
-error:
-   kfree(param->rates);
-   kfree(wid.val);
-   kfree(msg);
-}
-
 static void handle_del_all_sta(struct work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -2095,37 +2067,6 @@ static void handle_del_station(struct work_struct *work)
kfree(msg);
 }
 
-static void handle_edit_station(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct add_sta_param *param = &msg->body.edit_sta_info;
-   int result;
-   struct wid wid;
-   u8 *cur_byte;
-
-   wid.id = WID_EDIT_STA;
-   wid.type = WID_BIN;
-   wid.size = WILC_ADD_STA_LENGTH + param->rates_len;
-
-   wid.val = kmalloc(wid.size, GFP_KERNEL);
-   if (!wid.val)
-   goto error;
-
-   cur_byte = wid.val;
-   cur_byte += wilc_hif_pack_sta_param(cur_byte, param);
-
-   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
-   

[PATCH 14/29] staging: wilc1000: refactor wilc_set_mac_chnl_num() to avoid deferred handling

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Avoid handling of WID_CURRENT_CHANNEL wid command in deferred approach.
Instead of posting the wid to workqueue now handle directly from the
caller context.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 46 ++-
 1 file changed, 9 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 4d1fa4a..f6bd76c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -74,10 +74,6 @@ struct rcvd_async_info {
u32 len;
 };
 
-struct channel_attr {
-   u8 set_ch;
-};
-
 struct set_multicast {
bool enabled;
u32 cnt;
@@ -112,7 +108,6 @@ union message_body {
struct rcvd_async_info async_info;
struct key_attr key_info;
struct cfg_param_attr cfg_info;
-   struct channel_attr channel_info;
struct sta_inactive_t mac_info;
struct set_ip_addr ip_info;
struct drv_handler drv;
@@ -224,27 +219,6 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc 
*wilc, int idx)
return wilc->vif[index];
 }
 
-static void handle_set_channel(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct channel_attr *hif_set_ch = &msg->body.channel_info;
-   int ret;
-   struct wid wid;
-
-   wid.id = WID_CURRENT_CHANNEL;
-   wid.type = WID_CHAR;
-   wid.val = (char *)&hif_set_ch->set_ch;
-   wid.size = sizeof(char);
-
-   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
-  wilc_get_vif_idx(vif));
-
-   if (ret)
-   netdev_err(vif->ndev, "Failed to set channel\n");
-   kfree(msg);
-}
-
 static void handle_set_wfi_drv_handler(struct work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -2600,20 +2574,18 @@ int wilc_disconnect(struct wilc_vif *vif, u16 
reason_code)
 
 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
 {
+   struct wid wid;
int result;
-   struct host_if_msg *msg;
 
-   msg = wilc_alloc_work(vif, handle_set_channel, false);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
-
-   msg->body.channel_info.set_ch = channel;
+   wid.id = WID_CURRENT_CHANNEL;
+   wid.type = WID_CHAR;
+   wid.size = sizeof(char);
+   wid.val = &channel;
 
-   result = wilc_enqueue_work(msg);
-   if (result) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   kfree(msg);
-   }
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
+   if (result)
+   netdev_err(vif->ndev, "Failed to set channel\n");
 
return result;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/29] staging: wilc1000: use is_zero_ether_addr() API to check mac address

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Use is_zero_ether_addr() API to check if mac address value is zero.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 3 +--
 drivers/staging/wilc1000/linux_wlan.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 8ce56a3..310138d 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3400,13 +3400,12 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 
mac_addr[][ETH_ALEN])
struct wid wid;
int result;
int i;
-   u8 zero_addr[ETH_ALEN] = {0};
u8 assoc_sta = 0;
struct del_all_sta del_sta;
 
memset(&del_sta, 0x0, sizeof(del_sta));
for (i = 0; i < WILC_MAX_NUM_STA; i++) {
-   if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) {
+   if (!is_zero_ether_addr(mac_addr[i])) {
assoc_sta++;
ether_addr_copy(del_sta.mac[i], mac_addr[i]);
}
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index e246d18..142816a 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -205,11 +205,10 @@ void wilc_wlan_set_bssid(struct net_device *wilc_netdev, 
u8 *bssid, u8 mode)
 int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
 {
u8 i = 0;
-   u8 null_bssid[6] = {0};
u8 ret_val = 0;
 
for (i = 0; i < wilc->vif_num; i++)
-   if (memcmp(wilc->vif[i]->bssid, null_bssid, 6))
+   if (!is_zero_ether_addr(wilc->vif[i]->bssid))
ret_val++;
 
return ret_val;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/29] staging: wilc1000: make use of put_unaligned_le32 in handle_set_wfi_drv_handler()

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Make use of put_unaligned_le32() function to pack the wid command buffer
for firmware.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 10 ++
 drivers/staging/wilc1000/host_interface.h |  1 -
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 3f3b013..e179a8e 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -289,14 +289,8 @@ static void handle_set_wfi_drv_handler(struct work_struct 
*work)
goto free_msg;
 
currbyte = buffer;
-   *currbyte = hif_drv->driver_handler_id & DRV_HANDLER_MASK;
-   currbyte++;
-   *currbyte = (u32)0 & DRV_HANDLER_MASK;
-   currbyte++;
-   *currbyte = (u32)0 & DRV_HANDLER_MASK;
-   currbyte++;
-   *currbyte = (u32)0 & DRV_HANDLER_MASK;
-   currbyte++;
+   put_unaligned_le32(hif_drv->driver_handler_id, currbyte);
+   currbyte += 4;
*currbyte = (hif_drv_handler->name | (hif_drv_handler->mode << 1));
 
wid.id = WID_SET_DRV_HANDLER;
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 8279345..7a71cb6 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -41,7 +41,6 @@ enum {
 #define WILC_ADD_STA_LENGTH40
 #define WILC_NUM_CONCURRENT_IFC2
 #define WILC_DRV_HANDLER_SIZE  5
-#define DRV_HANDLER_MASK   0x00FF
 
 #define NUM_RSSI5
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/29] staging: wilc1000: refactor wilc_set_operation_mode() to avoid deferred handling

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Avoid handling of WID_CURRENT_CHANNEL wid command in deferred approach.
Instead of posting the wid to work queue now handle directly from the
caller context. Use structure to fill in the firmware specific format.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 49 ++-
 drivers/staging/wilc1000/host_interface.h |  4 ---
 2 files changed, 16 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 1910f9a..312c01e 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -85,6 +85,10 @@ struct del_all_sta {
u8 mac[WILC_MAX_NUM_STA][ETH_ALEN];
 };
 
+struct wilc_op_mode {
+   __le32 mode;
+};
+
 struct wilc_reg_frame {
bool reg;
u8 reg_id;
@@ -111,7 +115,6 @@ union message_body {
struct set_ip_addr ip_info;
struct drv_handler drv;
struct set_multicast multicast_info;
-   struct op_mode mode;
struct get_mac_addr get_mac_info;
struct ba_session_info session_info;
struct remain_ch remain_on_ch;
@@ -261,28 +264,6 @@ static void handle_set_wfi_drv_handler(struct work_struct 
*work)
kfree(msg);
 }
 
-static void handle_set_operation_mode(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct op_mode *hif_op_mode = &msg->body.mode;
-   int ret;
-   struct wid wid;
-
-   wid.id = WID_SET_OPERATION_MODE;
-   wid.type = WID_INT;
-   wid.val = (s8 *)&hif_op_mode->mode;
-   wid.size = sizeof(u32);
-
-   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
-  wilc_get_vif_idx(vif));
-
-   if (ret)
-   netdev_err(vif->ndev, "Failed to set operation mode\n");
-
-   kfree(msg);
-}
-
 static void handle_get_mac_address(struct work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -2550,19 +2531,21 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int 
index, u8 mode,
 
 int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode)
 {
+   struct wid wid;
+   struct wilc_op_mode op_mode;
int result;
-   struct host_if_msg *msg;
 
-   msg  = wilc_alloc_work(vif, handle_set_operation_mode, false);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
+   wid.id = WID_SET_OPERATION_MODE;
+   wid.type = WID_INT;
+   wid.size = sizeof(op_mode);
+   wid.val = (u8 *)&op_mode;
 
-   msg->body.mode.mode = mode;
-   result = wilc_enqueue_work(msg);
-   if (result) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   kfree(msg);
-   }
+   op_mode.mode = cpu_to_le32(mode);
+
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
+   if (result)
+   netdev_err(vif->ndev, "Failed to set operation mode\n");
 
return result;
 }
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 10d5627..e958357 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -220,10 +220,6 @@ struct drv_handler {
u8 name;
 };
 
-struct op_mode {
-   u32 mode;
-};
-
 struct get_mac_addr {
u8 *mac_addr;
 };
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 20/29] staging: wilc1000: handle key related cfg operation from cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor add/delete key operation to handle directly from cfg80211
context. Also, avoid an extra copy of the information in hif layer and
directly fill the buffer in firmware format.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 691 ++
 drivers/staging/wilc1000/host_interface.h |  13 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |   4 +-
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   2 +-
 4 files changed, 204 insertions(+), 506 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index e3dc9b6..596a321 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -37,12 +37,6 @@ union host_if_key_attr {
struct host_if_pmkid_attr pmkid;
 };
 
-struct key_attr {
-   enum KEY_TYPE type;
-   u8 action;
-   union host_if_key_attr attr;
-};
-
 struct scan_attr {
u8 src;
u8 type;
@@ -100,6 +94,33 @@ struct wilc_drv_handler {
u8 mode;
 } __packed;
 
+struct wilc_wep_key {
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_sta_wpa_ptk {
+   u8 mac_addr[ETH_ALEN];
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_ap_wpa_ptk {
+   u8 mac_addr[ETH_ALEN];
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
+struct wilc_gtk_key {
+   u8 mac_addr[ETH_ALEN];
+   u8 rsc[8];
+   u8 index;
+   u8 key_len;
+   u8 key[0];
+} __packed;
+
 struct set_ip_addr {
u8 *ip_addr;
u8 idx;
@@ -110,7 +131,6 @@ union message_body {
struct connect_attr con_info;
struct rcvd_net_info net_info;
struct rcvd_async_info async_info;
-   struct key_attr key_info;
struct set_ip_addr ip_info;
struct set_multicast multicast_info;
struct get_mac_addr get_mac_info;
@@ -1275,264 +1295,6 @@ static void handle_rcvd_gnrl_async_info(struct 
work_struct *work)
kfree(msg);
 }
 
-static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key)
-{
-   int i;
-   int ret;
-   struct wid wid;
-   u8 *key_buf;
-
-   key_buf = kmalloc((hif_key->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1,
- GFP_KERNEL);
-   if (!key_buf)
-   return -ENOMEM;
-
-   key_buf[0] = hif_key->attr.pmkid.numpmkid;
-
-   for (i = 0; i < hif_key->attr.pmkid.numpmkid; i++) {
-   memcpy(key_buf + ((PMKSA_KEY_LEN * i) + 1),
-  hif_key->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
-   memcpy(key_buf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1),
-  hif_key->attr.pmkid.pmkidlist[i].pmkid, WLAN_PMKID_LEN);
-   }
-
-   wid.id = WID_PMKID_INFO;
-   wid.type = WID_STR;
-   wid.val = (s8 *)key_buf;
-   wid.size = (hif_key->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
-
-   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
-  wilc_get_vif_idx(vif));
-
-   kfree(key_buf);
-
-   return ret;
-}
-
-static void handle_key(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct key_attr *hif_key = &msg->body.key_info;
-   int result = 0;
-   struct wid wid;
-   struct wid wid_list[5];
-   u8 *key_buf;
-   struct host_if_drv *hif_drv = vif->hif_drv;
-
-   switch (hif_key->type) {
-   case WILC_KEY_TYPE_WEP:
-
-   if (hif_key->action & WILC_ADD_KEY_AP) {
-   wid_list[0].id = WID_11I_MODE;
-   wid_list[0].type = WID_CHAR;
-   wid_list[0].size = sizeof(char);
-   wid_list[0].val = (s8 *)&hif_key->attr.wep.mode;
-
-   wid_list[1].id = WID_AUTH_TYPE;
-   wid_list[1].type = WID_CHAR;
-   wid_list[1].size = sizeof(char);
-   wid_list[1].val = (s8 *)&hif_key->attr.wep.auth_type;
-
-   key_buf = kmalloc(hif_key->attr.wep.key_len + 2,
- GFP_KERNEL);
-   if (!key_buf) {
-   result = -ENOMEM;
-   goto out_wep;
-   }
-
-   key_buf[0] = hif_key->attr.wep.index;
-   key_buf[1] = hif_key->attr.wep.key_len;
-
-   memcpy(&key_buf[2], hif_key->attr.wep.key,
-  hif_key->attr.wep.key_len);
-
-   wid_list[2].id = WID_WEP_KEY_VALUE;
-   wid_list[2].type = WID_STR;
-   wid_list[2].size = hif_key->attr.wep.key_len + 2;
-   wid_list[2].val = (s8 *)key_buf;
-
-   result = wilc_send_

[PATCH 16/29] staging: wilc1000: handle station dump cfg ops from cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor code to handle dump_station() callback from cfg80211 context.
Instead of deferring issue of wid command now send it directly from cfg
context. Also making use of wilc_get_rssi() error status in case there
is a failure to post the wid command to the firmware.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 51 ---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  5 ++-
 2 files changed, 13 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 6b1c9e3..1910f9a 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1678,27 +1678,6 @@ void wilc_resolve_disconnect_aberration(struct wilc_vif 
*vif)
wilc_disconnect(vif, 1);
 }
 
-static void handle_get_rssi(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   int result;
-   struct wid wid;
-
-   wid.id = WID_RSSI;
-   wid.type = WID_CHAR;
-   wid.val = msg->body.data;
-   wid.size = sizeof(char);
-
-   result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-   if (result)
-   netdev_err(vif->ndev, "Failed to get RSSI value\n");
-
-   complete(&msg->work_comp);
-   /* free 'msg' data in caller */
-}
-
 static void handle_get_statistics(struct work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -2620,34 +2599,22 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const 
u8 *mac,
 
 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
 {
+   struct wid wid;
int result;
-   struct host_if_msg *msg;
 
if (!rssi_level) {
netdev_err(vif->ndev, "%s: RSSI level is NULL\n", __func__);
return -EFAULT;
}
 
-   msg = wilc_alloc_work(vif, handle_get_rssi, true);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
-
-   msg->body.data = kzalloc(sizeof(s8), GFP_KERNEL);
-   if (!msg->body.data) {
-   kfree(msg);
-   return -ENOMEM;
-   }
-
-   result = wilc_enqueue_work(msg);
-   if (result) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   } else {
-   wait_for_completion(&msg->work_comp);
-   *rssi_level = *msg->body.data;
-   }
-
-   kfree(msg->body.data);
-   kfree(msg);
+   wid.id = WID_RSSI;
+   wid.type = WID_CHAR;
+   wid.size = sizeof(char);
+   wid.val = rssi_level;
+   result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
+   if (result)
+   netdev_err(vif->ndev, "Failed to get RSSI value\n");
 
return result;
 }
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 18370ef..4802ce9 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1659,13 +1659,16 @@ static int dump_station(struct wiphy *wiphy, struct 
net_device *dev,
 {
struct wilc_priv *priv = wiphy_priv(wiphy);
struct wilc_vif *vif = netdev_priv(priv->dev);
+   int ret;
 
if (idx != 0)
return -ENOENT;
 
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
 
-   wilc_get_rssi(vif, &sinfo->signal);
+   ret = wilc_get_rssi(vif, &sinfo->signal);
+   if (ret)
+   return ret;
 
memcpy(mac, priv->associated_bss, ETH_ALEN);
return 0;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/29] staging: wilc1000: handle mgmt_frame_register ops from cfg82011 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Avoid handling of mgmt_frame_register operation callback in a deferred
manner. Now set the wid command to firmware directly from caller
context.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 70 ++-
 drivers/staging/wilc1000/host_interface.h |  6 ---
 2 files changed, 22 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 97b84d2..4d1fa4a 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -89,6 +89,12 @@ struct del_all_sta {
u8 mac[WILC_MAX_NUM_STA][ETH_ALEN];
 };
 
+struct wilc_reg_frame {
+   bool reg;
+   u8 reg_id;
+   __le32 frame_type;
+} __packed;
+
 struct set_ip_addr {
u8 *ip_addr;
u8 idx;
@@ -115,7 +121,6 @@ union message_body {
struct get_mac_addr get_mac_info;
struct ba_session_info session_info;
struct remain_ch remain_on_ch;
-   struct reg_frame reg_frame;
char *data;
 };
 
@@ -1963,39 +1968,6 @@ static int handle_remain_on_chan(struct wilc_vif *vif,
return result;
 }
 
-static void handle_register_frame(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct reg_frame *hif_reg_frame = &msg->body.reg_frame;
-   int result;
-   struct wid wid;
-   u8 *cur_byte;
-
-   wid.id = WID_REGISTER_FRAME;
-   wid.type = WID_STR;
-   wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
-   if (!wid.val)
-   goto out;
-
-   cur_byte = wid.val;
-
-   *cur_byte++ = hif_reg_frame->reg;
-   *cur_byte++ = hif_reg_frame->reg_id;
-   memcpy(cur_byte, &hif_reg_frame->frame_type, sizeof(u16));
-
-   wid.size = sizeof(u16) + 2;
-
-   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-   kfree(wid.val);
-   if (result)
-   netdev_err(vif->ndev, "Failed to frame register\n");
-
-out:
-   kfree(msg);
-}
-
 static void handle_listen_state_expired(struct work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -3162,33 +3134,35 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 
session_id)
 
 void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg)
 {
+   struct wid wid;
int result;
-   struct host_if_msg *msg;
+   struct wilc_reg_frame reg_frame;
 
-   msg = wilc_alloc_work(vif, handle_register_frame, false);
-   if (IS_ERR(msg))
-   return;
+   wid.id = WID_REGISTER_FRAME;
+   wid.type = WID_STR;
+   wid.size = sizeof(reg_frame);
+   wid.val = (u8 *)®_frame;
+
+   memset(®_frame, 0x0, sizeof(reg_frame));
+   reg_frame.reg = reg;
 
switch (frame_type) {
case IEEE80211_STYPE_ACTION:
-   msg->body.reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX;
+   reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX;
break;
 
case IEEE80211_STYPE_PROBE_REQ:
-   msg->body.reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX;
+   reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX;
break;
 
default:
break;
}
-   msg->body.reg_frame.frame_type = frame_type;
-   msg->body.reg_frame.reg = reg;
-
-   result = wilc_enqueue_work(msg);
-   if (result) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   kfree(msg);
-   }
+   reg_frame.frame_type = cpu_to_le16(frame_type);
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
+   if (result)
+   netdev_err(vif->ndev, "Failed to frame register\n");
 }
 
 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 647a1af..10d5627 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -244,12 +244,6 @@ struct remain_ch {
u32 id;
 };
 
-struct reg_frame {
-   bool reg;
-   u16 frame_type;
-   u8 reg_id;
-};
-
 struct wilc;
 struct host_if_drv {
struct user_scan_req usr_scan_req;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/29] staging: wilc1000: refactor wilc_hif_set_cfg() to avoid deferred handling

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Avoid handling configuration params wid command in deferred approach.
Instead of posting to workqueue now handle directly from the caller
context. Reduce the size of wid array from 32 to 4 as maximum only 4 wid
used at a time.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 95 +++
 1 file changed, 32 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index f6bd76c..6b1c9e3 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -107,7 +107,6 @@ union message_body {
struct rcvd_net_info net_info;
struct rcvd_async_info async_info;
struct key_attr key_info;
-   struct cfg_param_attr cfg_info;
struct sta_inactive_t mac_info;
struct set_ip_addr ip_info;
struct drv_handler drv;
@@ -306,53 +305,6 @@ static void handle_get_mac_address(struct work_struct 
*work)
/* free 'msg' data later, in caller */
 }
 
-static void handle_cfg_param(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct cfg_param_attr *param = &msg->body.cfg_info;
-   int ret;
-   struct wid wid_list[32];
-   int i = 0;
-
-   if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) {
-   wid_list[i].id = WID_SHORT_RETRY_LIMIT;
-   wid_list[i].val = (s8 *)¶m->short_retry_limit;
-   wid_list[i].type = WID_SHORT;
-   wid_list[i].size = sizeof(u16);
-   i++;
-   }
-   if (param->flag & WILC_CFG_PARAM_RETRY_LONG) {
-   wid_list[i].id = WID_LONG_RETRY_LIMIT;
-   wid_list[i].val = (s8 *)¶m->long_retry_limit;
-   wid_list[i].type = WID_SHORT;
-   wid_list[i].size = sizeof(u16);
-   i++;
-   }
-   if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) {
-   wid_list[i].id = WID_FRAG_THRESHOLD;
-   wid_list[i].val = (s8 *)¶m->frag_threshold;
-   wid_list[i].type = WID_SHORT;
-   wid_list[i].size = sizeof(u16);
-   i++;
-   }
-   if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) {
-   wid_list[i].id = WID_RTS_THRESHOLD;
-   wid_list[i].val = (s8 *)¶m->rts_threshold;
-   wid_list[i].type = WID_SHORT;
-   wid_list[i].size = sizeof(u16);
-   i++;
-   }
-
-   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
-  i, wilc_get_vif_idx(vif));
-
-   if (ret)
-   netdev_err(vif->ndev, "Error in setting CFG params\n");
-
-   kfree(msg);
-}
-
 static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt)
 {
int result = 0;
@@ -2797,26 +2749,43 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 
scan_type,
return result;
 }
 
-int wilc_hif_set_cfg(struct wilc_vif *vif,
-struct cfg_param_attr *cfg_param)
+int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param)
 {
-   struct host_if_msg *msg;
-   struct host_if_drv *hif_drv = vif->hif_drv;
+   struct wid wid_list[4];
+   int i = 0;
int result;
 
-   if (!hif_drv) {
-   netdev_err(vif->ndev, "%s: hif driver is NULL", __func__);
-   return -EFAULT;
+   if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) {
+   wid_list[i].id = WID_SHORT_RETRY_LIMIT;
+   wid_list[i].val = (s8 *)¶m->short_retry_limit;
+   wid_list[i].type = WID_SHORT;
+   wid_list[i].size = sizeof(u16);
+   i++;
+   }
+   if (param->flag & WILC_CFG_PARAM_RETRY_LONG) {
+   wid_list[i].id = WID_LONG_RETRY_LIMIT;
+   wid_list[i].val = (s8 *)¶m->long_retry_limit;
+   wid_list[i].type = WID_SHORT;
+   wid_list[i].size = sizeof(u16);
+   i++;
+   }
+   if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) {
+   wid_list[i].id = WID_FRAG_THRESHOLD;
+   wid_list[i].val = (s8 *)¶m->frag_threshold;
+   wid_list[i].type = WID_SHORT;
+   wid_list[i].size = sizeof(u16);
+   i++;
+   }
+   if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) {
+   wid_list[i].id = WID_RTS_THRESHOLD;
+   wid_list[i].val = (s8 *)¶m->rts_threshold;
+   wid_list[i].type = WID_SHORT;
+   wid_list[i].size = sizeof(u16);
+   i++;
}
 
-   msg = wilc_alloc_work(vif, handle_cfg_param, false);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
-
-   msg->body.cfg_info = *cfg_param;
-   result = wilc_enqueue_work(msg);
-   if (result)
-   kfree(msg);
+   result = wilc_send_config_pkt(vif, WILC_SE

[PATCH 26/29] staging: wilc1000: avoid deferred handling of cfg80211 disconnect callback

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor disconnect operation callback to handle from the cfg80211
context. The reason code is not required to pass as parameter to the
function, so remove it.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 39 +++
 drivers/staging/wilc1000/host_interface.h |  2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  2 +-
 3 files changed, 6 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 7ab46ef..6a908ea 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1241,10 +1241,8 @@ static void handle_rcvd_gnrl_async_info(struct 
work_struct *work)
kfree(msg);
 }
 
-static void handle_disconnect(struct work_struct *work)
+int wilc_disconnect(struct wilc_vif *vif)
 {
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
struct wid wid;
struct host_if_drv *hif_drv = vif->hif_drv;
struct disconnect_info disconn_info;
@@ -1263,10 +1261,9 @@ static void handle_disconnect(struct work_struct *work)
 
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
  wilc_get_vif_idx(vif));
-
if (result) {
netdev_err(vif->ndev, "Failed to send dissconect\n");
-   goto out;
+   return result;
}
 
memset(&disconn_info, 0, sizeof(struct disconnect_info));
@@ -1307,10 +1304,7 @@ static void handle_disconnect(struct work_struct *work)
kfree(conn_req->ies);
conn_req->ies = NULL;
 
-out:
-
-   complete(&msg->work_comp);
-   /* free 'msg' in caller after receiving completion */
+   return 0;
 }
 
 void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
@@ -1319,7 +1313,7 @@ void wilc_resolve_disconnect_aberration(struct wilc_vif 
*vif)
return;
if (vif->hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP ||
vif->hif_drv->hif_state == HOST_IF_CONNECTING)
-   wilc_disconnect(vif, 1);
+   wilc_disconnect(vif);
 }
 
 int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats)
@@ -2012,31 +2006,6 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, 
const u8 *ssid,
return result;
 }
 
-int wilc_disconnect(struct wilc_vif *vif, u16 reason_code)
-{
-   int result;
-   struct host_if_msg *msg;
-   struct host_if_drv *hif_drv = vif->hif_drv;
-
-   if (!hif_drv) {
-   netdev_err(vif->ndev, "%s: hif driver is NULL", __func__);
-   return -EFAULT;
-   }
-
-   msg = wilc_alloc_work(vif, handle_disconnect, true);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
-
-   result = wilc_enqueue_work(msg);
-   if (result)
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   else
-   wait_for_completion(&msg->work_comp);
-
-   kfree(msg);
-   return result;
-}
-
 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
 {
struct wid wid;
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 20af5c4..ac4bdfe 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -264,7 +264,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, 
const u8 *ssid,
  wilc_connect_result connect_result, void *user_arg,
  u8 security, enum authtype auth_type,
  u8 channel, void *join_params);
-int wilc_disconnect(struct wilc_vif *vif, u16 reason_code);
+int wilc_disconnect(struct wilc_vif *vif);
 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 045e365..7cc985e 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -760,7 +760,7 @@ static int disconnect(struct wiphy *wiphy, struct 
net_device *dev,
priv->p2p.is_wilc_ie = false;
wfi_drv->p2p_timeout = 0;
 
-   ret = wilc_disconnect(vif, reason_code);
+   ret = wilc_disconnect(vif);
if (ret != 0) {
netdev_err(priv->dev, "Error in disconnecting\n");
ret = -EINVAL;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 19/29] staging: wilc1000: refactor wilc_get_inactive_time() to avoid deferred handling

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Avoid handling of inactive time related wid command in deferred manner.
Instead of posting the wid to workqueue now handle directly from the
caller context.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 91 ---
 1 file changed, 23 insertions(+), 68 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index ab770d8..e3dc9b6 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -105,18 +105,12 @@ struct set_ip_addr {
u8 idx;
 };
 
-struct sta_inactive_t {
-   u32 inactive_time;
-   u8 mac[6];
-};
-
 union message_body {
struct scan_attr scan_info;
struct connect_attr con_info;
struct rcvd_net_info net_info;
struct rcvd_async_info async_info;
struct key_attr key_info;
-   struct sta_inactive_t mac_info;
struct set_ip_addr ip_info;
struct set_multicast multicast_info;
struct get_mac_addr get_mac_info;
@@ -1678,48 +1672,6 @@ static void handle_get_statistics(struct work_struct 
*work)
kfree(msg);
 }
 
-static void handle_get_inactive_time(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct sta_inactive_t *hif_sta_inactive = &msg->body.mac_info;
-   int result;
-   struct wid wid;
-
-   wid.id = WID_SET_STA_MAC_INACTIVE_TIME;
-   wid.type = WID_STR;
-   wid.size = ETH_ALEN;
-   wid.val = kmalloc(wid.size, GFP_KERNEL);
-   if (!wid.val)
-   goto out;
-
-   ether_addr_copy(wid.val, hif_sta_inactive->mac);
-
-   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-   kfree(wid.val);
-
-   if (result) {
-   netdev_err(vif->ndev, "Failed to set inactive mac\n");
-   goto out;
-   }
-
-   wid.id = WID_GET_INACTIVE_TIME;
-   wid.type = WID_INT;
-   wid.val = (s8 *)&hif_sta_inactive->inactive_time;
-   wid.size = sizeof(u32);
-
-   result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
- wilc_get_vif_idx(vif));
-
-   if (result)
-   netdev_err(vif->ndev, "Failed to get inactive time\n");
-
-out:
-   /* free 'msg' data in caller */
-   complete(&msg->work_comp);
-}
-
 static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac,
struct station_parameters *params)
 {
@@ -2508,32 +2460,35 @@ int wilc_set_operation_mode(struct wilc_vif *vif, u32 
mode)
return result;
 }
 
-s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
-  u32 *out_val)
+s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val)
 {
+   struct wid wid;
s32 result;
-   struct host_if_msg *msg;
-   struct host_if_drv *hif_drv = vif->hif_drv;
-
-   if (!hif_drv) {
-   netdev_err(vif->ndev, "%s: hif driver is NULL", __func__);
-   return -EFAULT;
-   }
 
-   msg = wilc_alloc_work(vif, handle_get_inactive_time, true);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
+   wid.id = WID_SET_STA_MAC_INACTIVE_TIME;
+   wid.type = WID_STR;
+   wid.size = ETH_ALEN;
+   wid.val = kzalloc(wid.size, GFP_KERNEL);
+   if (!wid.val)
+   return -ENOMEM;
 
-   memcpy(msg->body.mac_info.mac, mac, ETH_ALEN);
+   ether_addr_copy(wid.val, mac);
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
+   kfree(wid.val);
+   if (result) {
+   netdev_err(vif->ndev, "Failed to set inactive mac\n");
+   return result;
+   }
 
-   result = wilc_enqueue_work(msg);
+   wid.id = WID_GET_INACTIVE_TIME;
+   wid.type = WID_INT;
+   wid.val = (s8 *)out_val;
+   wid.size = sizeof(u32);
+   result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
if (result)
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   else
-   wait_for_completion(&msg->work_comp);
-
-   *out_val = msg->body.mac_info.inactive_time;
-   kfree(msg);
+   netdev_err(vif->ndev, "Failed to get inactive time\n");
 
return result;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/29] staging: wilc1000: refactor wilc_set_wfi_drv_handler() to avoid deferred handling

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Avoid handling of WID_SET_DRV_HANDLER wid command in deferred approach.
Instead of posting the wid to work queue now handle directly from the
caller context. Remove 'is_sync' parameter from the API as it's not
required anymore.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 82 ++-
 drivers/staging/wilc1000/host_interface.h |  8 +--
 drivers/staging/wilc1000/linux_wlan.c |  3 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  2 +-
 4 files changed, 23 insertions(+), 72 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 312c01e..ab770d8 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -95,6 +95,11 @@ struct wilc_reg_frame {
__le32 frame_type;
 } __packed;
 
+struct wilc_drv_handler {
+   __le32 handler;
+   u8 mode;
+} __packed;
+
 struct set_ip_addr {
u8 *ip_addr;
u8 idx;
@@ -113,7 +118,6 @@ union message_body {
struct key_attr key_info;
struct sta_inactive_t mac_info;
struct set_ip_addr ip_info;
-   struct drv_handler drv;
struct set_multicast multicast_info;
struct get_mac_addr get_mac_info;
struct ba_session_info session_info;
@@ -221,49 +225,6 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc 
*wilc, int idx)
return wilc->vif[index];
 }
 
-static void handle_set_wfi_drv_handler(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct drv_handler *hif_drv_handler = &msg->body.drv;
-   int ret;
-   struct wid wid;
-   u8 *currbyte, *buffer;
-   struct host_if_drv *hif_drv;
-
-   if (!vif->hif_drv || !hif_drv_handler)
-   goto free_msg;
-
-   hif_drv = vif->hif_drv;
-
-   buffer = kzalloc(WILC_DRV_HANDLER_SIZE, GFP_KERNEL);
-   if (!buffer)
-   goto free_msg;
-
-   currbyte = buffer;
-   put_unaligned_le32(hif_drv->driver_handler_id, currbyte);
-   currbyte += 4;
-   *currbyte = (hif_drv_handler->name | (hif_drv_handler->mode << 1));
-
-   wid.id = WID_SET_DRV_HANDLER;
-   wid.type = WID_STR;
-   wid.val = (s8 *)buffer;
-   wid.size = WILC_DRV_HANDLER_SIZE;
-
-   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
-  hif_drv->driver_handler_id);
-   if (ret)
-   netdev_err(vif->ndev, "Failed to set driver handler\n");
-
-   kfree(buffer);
-
-free_msg:
-   if (msg->is_sync)
-   complete(&msg->work_comp);
-
-   kfree(msg);
-}
-
 static void handle_get_mac_address(struct work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -2503,28 +2464,25 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 
channel)
 }
 
 int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode,
-u8 ifc_id, bool is_sync)
+u8 ifc_id)
 {
+   struct wid wid;
+   struct host_if_drv *hif_drv = vif->hif_drv;
int result;
-   struct host_if_msg *msg;
-
-   msg = wilc_alloc_work(vif, handle_set_wfi_drv_handler, is_sync);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
+   struct wilc_drv_handler drv;
 
-   msg->body.drv.handler = index;
-   msg->body.drv.mode = mode;
-   msg->body.drv.name = ifc_id;
+   wid.id = WID_SET_DRV_HANDLER;
+   wid.type = WID_STR;
+   wid.size = sizeof(drv);
+   wid.val = (u8 *)&drv;
 
-   result = wilc_enqueue_work(msg);
-   if (result) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   kfree(msg);
-   return result;
-   }
+   drv.handler = cpu_to_le32(index);
+   drv.mode = (ifc_id | (mode << 1));
 
-   if (is_sync)
-   wait_for_completion(&msg->work_comp);
+   result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+ hif_drv->driver_handler_id);
+   if (result)
+   netdev_err(vif->ndev, "Failed to set driver handler\n");
 
return result;
 }
@@ -2814,7 +2772,7 @@ int wilc_deinit(struct wilc_vif *vif)
del_timer_sync(&vif->periodic_rssi);
del_timer_sync(&hif_drv->remain_on_ch_timer);
 
-   wilc_set_wfi_drv_handler(vif, 0, 0, 0, true);
+   wilc_set_wfi_drv_handler(vif, 0, 0, 0);
 
if (hif_drv->usr_scan_req.scan_result) {
hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index e958357..7748f65 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -214,12 +214,6 @@ struct user_con

[PATCH 22/29] staging: wilc1000: refactor wilc_get_mac_address() to avoid deferred handling

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Avoid handling of WID_MAC_ADDR wid command in deferred approach. Instead
of posting the wid to workqueue now handle directly from the caller
context.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 43 ++-
 drivers/staging/wilc1000/host_interface.h |  4 ---
 2 files changed, 8 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 71395d8..dc02561 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -103,7 +103,6 @@ union message_body {
struct rcvd_net_info net_info;
struct rcvd_async_info async_info;
struct set_multicast multicast_info;
-   struct get_mac_addr get_mac_info;
struct remain_ch remain_on_ch;
char *data;
 };
@@ -208,28 +207,6 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc 
*wilc, int idx)
return wilc->vif[index];
 }
 
-static void handle_get_mac_address(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct get_mac_addr *get_mac_addr = &msg->body.get_mac_info;
-   int ret;
-   struct wid wid;
-
-   wid.id = WID_MAC_ADDR;
-   wid.type = WID_STR;
-   wid.val = get_mac_addr->mac_addr;
-   wid.size = ETH_ALEN;
-
-   ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
-  wilc_get_vif_idx(vif));
-
-   if (ret)
-   netdev_err(vif->ndev, "Failed to get mac address\n");
-   complete(&msg->work_comp);
-   /* free 'msg' data later, in caller */
-}
-
 static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt)
 {
int result = 0;
@@ -1934,21 +1911,17 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, struct 
wilc_pmkid_attr *pmkid)
 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
 {
int result;
-   struct host_if_msg *msg;
-
-   msg = wilc_alloc_work(vif, handle_get_mac_address, true);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
+   struct wid wid;
 
-   msg->body.get_mac_info.mac_addr = mac_addr;
+   wid.id = WID_MAC_ADDR;
+   wid.type = WID_STR;
+   wid.size = ETH_ALEN;
+   wid.val = mac_addr;
 
-   result = wilc_enqueue_work(msg);
+   result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
+ wilc_get_vif_idx(vif));
if (result)
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   else
-   wait_for_completion(&msg->work_comp);
-
-   kfree(msg);
+   netdev_err(vif->ndev, "Failed to get mac address\n");
 
return result;
 }
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index d2f29ea..953f0ea 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -194,10 +194,6 @@ struct user_conn_req {
void *arg;
 };
 
-struct get_mac_addr {
-   u8 *mac_addr;
-};
-
 struct remain_ch {
u16 ch;
u32 duration;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 27/29] staging: wilc1000: handle connect ops callback from cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor the connect related cfg callback to be called from cfg80211
context. No need to post connect command internally in case scan is in
progress instead simply return the error status in connect ops callback.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 104 +-
 1 file changed, 44 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 6a908ea..783c99b 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -362,34 +362,16 @@ static void handle_scan(struct work_struct *work)
kfree(msg);
 }
 
-static void handle_connect(struct work_struct *work)
+static int wilc_send_connect_wid(struct wilc_vif *vif,
+struct connect_attr *conn_attr)
 {
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct connect_attr *conn_attr = &msg->body.con_info;
int result = 0;
struct wid wid_list[8];
u32 wid_cnt = 0, dummyval = 0;
u8 *cur_byte = NULL;
-   struct join_bss_param *bss_param;
+   struct join_bss_param *bss_param = conn_attr->params;
struct host_if_drv *hif_drv = vif->hif_drv;
 
-   if (msg->vif->hif_drv->usr_scan_req.scan_result) {
-   result = wilc_enqueue_work(msg);
-   if (result)
-   goto error;
-
-   usleep_range(2 * 1000, 2 * 1000);
-   return;
-   }
-
-   bss_param = conn_attr->params;
-   if (!bss_param) {
-   netdev_err(vif->ndev, "Required BSSID not found\n");
-   result = -ENOENT;
-   goto error;
-   }
-
if (conn_attr->bssid) {
hif_drv->usr_conn_req.bssid = kmemdup(conn_attr->bssid, 6,
  GFP_KERNEL);
@@ -490,8 +472,8 @@ static void handle_connect(struct work_struct *work)
netdev_err(vif->ndev, "Channel out of range\n");
*(cur_byte++) = 0xFF;
}
-   *(cur_byte++)  = (bss_param->cap_info) & 0xFF;
-   *(cur_byte++)  = ((bss_param->cap_info) >> 8) & 0xFF;
+   put_unaligned_le16(bss_param->cap_info, cur_byte);
+   cur_byte += 2;
 
if (conn_attr->bssid)
memcpy(cur_byte, conn_attr->bssid, 6);
@@ -501,8 +483,8 @@ static void handle_connect(struct work_struct *work)
memcpy(cur_byte, conn_attr->bssid, 6);
cur_byte += 6;
 
-   *(cur_byte++)  = (bss_param->beacon_period) & 0xFF;
-   *(cur_byte++)  = ((bss_param->beacon_period) >> 8) & 0xFF;
+   put_unaligned_le16(bss_param->beacon_period, cur_byte);
+   cur_byte += 2;
*(cur_byte++)  =  bss_param->dtim_period;
 
memcpy(cur_byte, bss_param->supp_rates, MAX_RATES_SUPPORTED + 1);
@@ -533,10 +515,8 @@ static void handle_connect(struct work_struct *work)
*(cur_byte++) = bss_param->noa_enabled;
 
if (bss_param->noa_enabled) {
-   *(cur_byte++) = (bss_param->tsf) & 0xFF;
-   *(cur_byte++) = ((bss_param->tsf) >> 8) & 0xFF;
-   *(cur_byte++) = ((bss_param->tsf) >> 16) & 0xFF;
-   *(cur_byte++) = ((bss_param->tsf) >> 24) & 0xFF;
+   put_unaligned_le32(bss_param->tsf, cur_byte);
+   cur_byte += 4;
 
*(cur_byte++) = bss_param->opp_enabled;
*(cur_byte++) = bss_param->idx;
@@ -616,8 +596,10 @@ static void handle_connect(struct work_struct *work)
kfree(conn_attr->ies);
conn_attr->ies = NULL;
 
+   kfree(conn_attr);
kfree(cur_byte);
-   kfree(msg);
+
+   return result;
 }
 
 static void handle_connect_timeout(struct work_struct *work)
@@ -1926,8 +1908,8 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, 
const u8 *ssid,
  u8 channel, void *join_params)
 {
int result;
-   struct host_if_msg *msg;
struct host_if_drv *hif_drv = vif->hif_drv;
+   struct connect_attr *con_info;
 
if (!hif_drv || !connect_result) {
netdev_err(vif->ndev,
@@ -1941,50 +1923,51 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, 
const u8 *ssid,
return -EFAULT;
}
 
-   msg = wilc_alloc_work(vif, handle_connect, false);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
+   if (hif_drv->usr_scan_req.scan_result) {
+   netdev_err(vif->ndev, "%s: Scan in progress\n", __func__);
+   return -EBUSY;
+   }
+
+   con_info = kzalloc(sizeof(*con_info), GFP_KERNEL);
+   if (!con_info)
+   return -ENOMEM;
 
-   msg->body.con_info.security = security;
-   msg->body.con_info.auth_type = auth_type;
-   msg->body.con_info.ch = channel;
-   msg->body.con_info.result = connect_result;
-

[PATCH 23/29] staging: wilc1000: use correct 'struct remain_ch' variable in scan complete

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Use the correct reference to remain_ch variable in scan complete.
Passing 'msg->body.remain_on_ch' to handle_remain_on_chan is not
correct. So used the correct reference used to store roc related
information during the scan.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index dc02561..9139e0e 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1613,7 +1613,8 @@ static void handle_scan_complete(struct work_struct *work)
handle_scan_done(msg->vif, SCAN_EVENT_DONE);
 
if (msg->vif->hif_drv->remain_on_ch_pending)
-   handle_remain_on_chan(msg->vif, &msg->body.remain_on_ch);
+   handle_remain_on_chan(msg->vif,
+ &msg->vif->hif_drv->remain_on_ch);
kfree(msg);
 }
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 21/29] staging: wilc1000: delete the unused code after code refactor

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

After code refactor some of the macro and variables are not required any
more, so deleted the unused code.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 31 ---
 drivers/staging/wilc1000/host_interface.h | 27 ---
 2 files changed, 58 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 596a321..71395d8 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -13,30 +13,6 @@
 
 #define REAL_JOIN_REQ  0
 
-struct host_if_wpa_attr {
-   u8 *key;
-   const u8 *mac_addr;
-   u8 *seq;
-   u8 seq_len;
-   u8 index;
-   u8 key_len;
-   u8 mode;
-};
-
-struct host_if_wep_attr {
-   u8 *key;
-   u8 key_len;
-   u8 index;
-   u8 mode;
-   enum authtype auth_type;
-};
-
-union host_if_key_attr {
-   struct host_if_wep_attr wep;
-   struct host_if_wpa_attr wpa;
-   struct host_if_pmkid_attr pmkid;
-};
-
 struct scan_attr {
u8 src;
u8 type;
@@ -121,20 +97,13 @@ struct wilc_gtk_key {
u8 key[0];
 } __packed;
 
-struct set_ip_addr {
-   u8 *ip_addr;
-   u8 idx;
-};
-
 union message_body {
struct scan_attr scan_info;
struct connect_attr con_info;
struct rcvd_net_info net_info;
struct rcvd_async_info async_info;
-   struct set_ip_addr ip_info;
struct set_multicast multicast_info;
struct get_mac_addr get_mac_info;
-   struct ba_session_info session_info;
struct remain_ch remain_on_ch;
char *data;
 };
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 477372b..d2f29ea 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -17,13 +17,6 @@ enum {
WILC_CLIENT_MODE = 0x4
 };
 
-enum {
-   WILC_ADD_KEY = 0x1,
-   WILC_REMOVE_KEY = 0x2,
-   WILC_DEFAULT_KEY = 0x4,
-   WILC_ADD_KEY_AP = 0x8
-};
-
 #define WILC_MAX_NUM_STA   9
 #define MAX_NUM_SCANNED_NETWORKS   100
 #define MAX_NUM_SCANNED_NETWORKS_SHADOW130
@@ -31,16 +24,10 @@ enum {
 
 #define TX_MIC_KEY_LEN 8
 #define RX_MIC_KEY_LEN 8
-#define PTK_KEY_LEN16
 
-#define RX_MIC_KEY_MSG_LEN 48
-#define PTK_KEY_MSG_LEN39
-
-#define PMKSA_KEY_LEN  22
 #define WILC_MAX_NUM_PMKIDS16
 #define WILC_ADD_STA_LENGTH40
 #define WILC_NUM_CONCURRENT_IFC2
-#define WILC_DRV_HANDLER_SIZE  5
 
 #define NUM_RSSI5
 
@@ -160,13 +147,6 @@ enum conn_event {
CONN_DISCONN_EVENT_FORCE_32BIT  = 0x
 };
 
-enum KEY_TYPE {
-   WILC_KEY_TYPE_WEP,
-   WILC_KEY_TYPE_WPA_RX_GTK,
-   WILC_KEY_TYPE_WPA_PTK,
-   WILC_KEY_TYPE_PMKSA,
-};
-
 typedef void (*wilc_scan_result)(enum scan_event, struct network_info *,
 void *, void *);
 
@@ -218,13 +198,6 @@ struct get_mac_addr {
u8 *mac_addr;
 };
 
-struct ba_session_info {
-   u8 bssid[ETH_ALEN];
-   u8 tid;
-   u16 buf_size;
-   u16 time_out;
-};
-
 struct remain_ch {
u16 ch;
u32 duration;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 24/29] staging: wilc1000: handle remain on channel cfg ops from cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor wilc_remain_on_channel() to handle remain_on_channel callback
from cfg80211 context.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 36 ++-
 1 file changed, 11 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 9139e0e..4762925 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1592,14 +1592,6 @@ static void handle_scan_timer(struct work_struct *work)
kfree(msg);
 }
 
-static void handle_remain_on_chan_work(struct work_struct *work)
-{
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-
-   handle_remain_on_chan(msg->vif, &msg->body.remain_on_ch);
-   kfree(msg);
-}
-
 static void handle_scan_complete(struct work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -2527,25 +2519,19 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 
session_id,
   wilc_remain_on_chan_ready ready,
   void *user_arg)
 {
+   struct remain_ch roc;
int result;
-   struct host_if_msg *msg;
-
-   msg = wilc_alloc_work(vif, handle_remain_on_chan_work, false);
-   if (IS_ERR(msg))
-   return PTR_ERR(msg);
 
-   msg->body.remain_on_ch.ch = chan;
-   msg->body.remain_on_ch.expired = expired;
-   msg->body.remain_on_ch.ready = ready;
-   msg->body.remain_on_ch.arg = user_arg;
-   msg->body.remain_on_ch.duration = duration;
-   msg->body.remain_on_ch.id = session_id;
-
-   result = wilc_enqueue_work(msg);
-   if (result) {
-   netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   kfree(msg);
-   }
+   roc.ch = chan;
+   roc.expired = expired;
+   roc.ready = ready;
+   roc.arg = user_arg;
+   roc.duration = duration;
+   roc.id = session_id;
+   result = handle_remain_on_chan(vif, &roc);
+   if (result)
+   netdev_err(vif->ndev, "%s: failed to set remain on channel\n",
+  __func__);
 
return result;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 25/29] staging: wilc1000: handle get_station() ops callback in cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor code to handle the get_station() callback from cfg80211
context. Provided different API's to fetch the station statistics
information in sync or async call. From cfg80211 get_station() ops
callback calls the sync version of API.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 38 +++
 drivers/staging/wilc1000/host_interface.h |  3 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  2 +-
 3 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 4762925..7ab46ef 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1322,13 +1322,10 @@ void wilc_resolve_disconnect_aberration(struct wilc_vif 
*vif)
wilc_disconnect(vif, 1);
 }
 
-static void handle_get_statistics(struct work_struct *work)
+int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats)
 {
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
struct wid wid_list[5];
u32 wid_cnt = 0, result;
-   struct rf_info *stats = (struct rf_info *)msg->body.data;
 
wid_list[wid_cnt].id = WID_LINKSPEED;
wid_list[wid_cnt].type = WID_CHAR;
@@ -1364,8 +1361,10 @@ static void handle_get_statistics(struct work_struct 
*work)
  wid_cnt,
  wilc_get_vif_idx(vif));
 
-   if (result)
+   if (result) {
netdev_err(vif->ndev, "Failed to send scan parameters\n");
+   return result;
+   }
 
if (stats->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH &&
stats->link_speed != DEFAULT_LINK_SPEED)
@@ -1373,11 +1372,18 @@ static void handle_get_statistics(struct work_struct 
*work)
else if (stats->link_speed != DEFAULT_LINK_SPEED)
wilc_enable_tcp_ack_filter(vif, false);
 
-   /* free 'msg' for async command, for sync caller will free it */
-   if (msg->is_sync)
-   complete(&msg->work_comp);
-   else
-   kfree(msg);
+   return result;
+}
+
+static void handle_get_statistics(struct work_struct *work)
+{
+   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
+   struct wilc_vif *vif = msg->vif;
+   struct rf_info *stats = (struct rf_info *)msg->body.data;
+
+   wilc_get_statistics(vif, stats);
+
+   kfree(msg);
 }
 
 static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac,
@@ -2149,13 +2155,12 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
return result;
 }
 
-int
-wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, bool is_sync)
+int wilc_get_stats_async(struct wilc_vif *vif, struct rf_info *stats)
 {
int result;
struct host_if_msg *msg;
 
-   msg = wilc_alloc_work(vif, handle_get_statistics, is_sync);
+   msg = wilc_alloc_work(vif, handle_get_statistics, false);
if (IS_ERR(msg))
return PTR_ERR(msg);
 
@@ -2168,11 +2173,6 @@ wilc_get_statistics(struct wilc_vif *vif, struct rf_info 
*stats, bool is_sync)
return result;
}
 
-   if (is_sync) {
-   wait_for_completion(&msg->work_comp);
-   kfree(msg);
-   }
-
return result;
 }
 
@@ -2297,7 +2297,7 @@ static void get_periodic_rssi(struct timer_list *t)
}
 
if (vif->hif_drv->hif_state == HOST_IF_CONNECTED)
-   wilc_get_statistics(vif, &vif->periodic_stat, false);
+   wilc_get_stats_async(vif, &vif->periodic_stat);
 
mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000));
 }
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 953f0ea..20af5c4 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -297,8 +297,7 @@ void wilc_frame_register(struct wilc_vif *vif, u16 
frame_type, bool reg);
 int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode,
 u8 ifc_id);
 int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode);
-int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats,
-   bool is_sync);
+int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats);
 void wilc_resolve_disconnect_aberration(struct wilc_vif *vif);
 int wilc_get_vif_idx(struct wilc_vif *vif);
 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 4c9444e..045e365 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1039,7 +1039,7 @@ static int get_station(struct wiphy *wiphy, struct 
net_

[PATCH 29/29] staging: wilc1000: handle scan operation callback from cfg80211 context

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor code to handle scan operation callback from cfg80211 context.
No need to maintain 'scan_attr' struct as the wid command is directly
sent to firmware from cfg80211 context.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 143 --
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  13 +-
 2 files changed, 33 insertions(+), 123 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index f50728c..b8603f2 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -13,18 +13,6 @@
 
 #define REAL_JOIN_REQ  0
 
-struct scan_attr {
-   u8 src;
-   u8 type;
-   u8 *ch_freq_list;
-   u8 ch_list_len;
-   u8 *ies;
-   size_t ies_len;
-   wilc_scan_result result;
-   void *arg;
-   struct hidden_network hidden_network;
-};
-
 struct rcvd_async_info {
u8 *buffer;
u32 len;
@@ -84,7 +72,6 @@ struct wilc_gtk_key {
 } __packed;
 
 union message_body {
-   struct scan_attr scan_info;
struct rcvd_net_info net_info;
struct rcvd_async_info async_info;
struct set_multicast multicast_info;
@@ -230,11 +217,11 @@ static int handle_scan_done(struct wilc_vif *vif, enum 
scan_event evt)
return result;
 }
 
-static void handle_scan(struct work_struct *work)
+int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
+ u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
+ size_t ies_len, wilc_scan_result scan_result, void *user_arg,
+ struct hidden_network *hidden_net)
 {
-   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-   struct wilc_vif *vif = msg->vif;
-   struct scan_attr *scan_info = &msg->body.scan_info;
int result = 0;
struct wid wid_list[5];
u32 index = 0;
@@ -243,10 +230,6 @@ static void handle_scan(struct work_struct *work)
u8 valuesize = 0;
u8 *hdn_ntwk_wid_val = NULL;
struct host_if_drv *hif_drv = vif->hif_drv;
-   struct hidden_network *hidden_net = &scan_info->hidden_network;
-
-   hif_drv->usr_scan_req.scan_result = scan_info->result;
-   hif_drv->usr_scan_req.arg = scan_info->arg;
 
if (hif_drv->hif_state >= HOST_IF_SCANNING &&
hif_drv->hif_state < HOST_IF_CONNECTED) {
@@ -288,63 +271,55 @@ static void handle_scan(struct work_struct *work)
 
wid_list[index].id = WID_INFO_ELEMENT_PROBE;
wid_list[index].type = WID_BIN_DATA;
-   wid_list[index].val = scan_info->ies;
-   wid_list[index].size = scan_info->ies_len;
+   wid_list[index].val = (s8 *)ies;
+   wid_list[index].size = ies_len;
index++;
 
wid_list[index].id = WID_SCAN_TYPE;
wid_list[index].type = WID_CHAR;
wid_list[index].size = sizeof(char);
-   wid_list[index].val = (s8 *)&scan_info->type;
+   wid_list[index].val = (s8 *)&scan_type;
index++;
 
wid_list[index].id = WID_SCAN_CHANNEL_LIST;
wid_list[index].type = WID_BIN_DATA;
 
-   if (scan_info->ch_freq_list &&
-   scan_info->ch_list_len > 0) {
-   int i;
-
-   for (i = 0; i < scan_info->ch_list_len; i++) {
-   if (scan_info->ch_freq_list[i] > 0)
-   scan_info->ch_freq_list[i] -= 1;
+   if (ch_freq_list && ch_list_len > 0) {
+   for (i = 0; i < ch_list_len; i++) {
+   if (ch_freq_list[i] > 0)
+   ch_freq_list[i] -= 1;
}
}
 
-   wid_list[index].val = scan_info->ch_freq_list;
-   wid_list[index].size = scan_info->ch_list_len;
+   wid_list[index].val = ch_freq_list;
+   wid_list[index].size = ch_list_len;
index++;
 
wid_list[index].id = WID_START_SCAN_REQ;
wid_list[index].type = WID_CHAR;
wid_list[index].size = sizeof(char);
-   wid_list[index].val = (s8 *)&scan_info->src;
+   wid_list[index].val = (s8 *)&scan_source;
index++;
 
result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
  index,
  wilc_get_vif_idx(vif));
-
-   if (result)
-   netdev_err(vif->ndev, "Failed to send scan parameters\n");
-
-error:
if (result) {
-   del_timer(&hif_drv->scan_timer);
-   handle_scan_done(vif, SCAN_EVENT_ABORTED);
+   netdev_err(vif->ndev, "Failed to send scan parameters\n");
+   goto error;
}
 
-   kfree(scan_info->ch_freq_list);
-   scan_info->ch_freq_list = NULL;
-
-   kfree(scan_info->ies);
-   scan_info->ies = NULL;
-   kfree(scan_info->hidden_network.net_info);
-   scan_info->hidden_network.net_info = NULL;
+   hif_drv->usr_scan_req.scan_result = scan_result;

[PATCH 28/29] staging: wilc1000: avoid extra buffer copy while connect cfg ops

2018-12-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor the code to avoid the use of an extra buffer to store the
connection related parameter. No need to call cfg80211_disconnected in
case of failure to send the wid command to firmware, an error status is
directly returned in cfg80211 connect callback.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 129 +++---
 drivers/staging/wilc1000/host_interface.h |   2 +
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |   2 +
 3 files changed, 21 insertions(+), 112 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 783c99b..f50728c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -25,20 +25,6 @@ struct scan_attr {
struct hidden_network hidden_network;
 };
 
-struct connect_attr {
-   u8 *bssid;
-   u8 *ssid;
-   size_t ssid_len;
-   u8 *ies;
-   size_t ies_len;
-   u8 security;
-   wilc_connect_result result;
-   void *arg;
-   enum authtype auth_type;
-   u8 ch;
-   void *params;
-};
-
 struct rcvd_async_info {
u8 *buffer;
u32 len;
@@ -99,7 +85,6 @@ struct wilc_gtk_key {
 
 union message_body {
struct scan_attr scan_info;
-   struct connect_attr con_info;
struct rcvd_net_info net_info;
struct rcvd_async_info async_info;
struct set_multicast multicast_info;
@@ -362,54 +347,15 @@ static void handle_scan(struct work_struct *work)
kfree(msg);
 }
 
-static int wilc_send_connect_wid(struct wilc_vif *vif,
-struct connect_attr *conn_attr)
+static int wilc_send_connect_wid(struct wilc_vif *vif)
 {
int result = 0;
struct wid wid_list[8];
u32 wid_cnt = 0, dummyval = 0;
u8 *cur_byte = NULL;
-   struct join_bss_param *bss_param = conn_attr->params;
struct host_if_drv *hif_drv = vif->hif_drv;
-
-   if (conn_attr->bssid) {
-   hif_drv->usr_conn_req.bssid = kmemdup(conn_attr->bssid, 6,
- GFP_KERNEL);
-   if (!hif_drv->usr_conn_req.bssid) {
-   result = -ENOMEM;
-   goto error;
-   }
-   }
-
-   hif_drv->usr_conn_req.ssid_len = conn_attr->ssid_len;
-   if (conn_attr->ssid) {
-   hif_drv->usr_conn_req.ssid = kmalloc(conn_attr->ssid_len + 1,
-GFP_KERNEL);
-   if (!hif_drv->usr_conn_req.ssid) {
-   result = -ENOMEM;
-   goto error;
-   }
-   memcpy(hif_drv->usr_conn_req.ssid,
-  conn_attr->ssid,
-  conn_attr->ssid_len);
-   hif_drv->usr_conn_req.ssid[conn_attr->ssid_len] = '\0';
-   }
-
-   hif_drv->usr_conn_req.ies_len = conn_attr->ies_len;
-   if (conn_attr->ies) {
-   hif_drv->usr_conn_req.ies = kmemdup(conn_attr->ies,
-   conn_attr->ies_len,
-   GFP_KERNEL);
-   if (!hif_drv->usr_conn_req.ies) {
-   result = -ENOMEM;
-   goto error;
-   }
-   }
-
-   hif_drv->usr_conn_req.security = conn_attr->security;
-   hif_drv->usr_conn_req.auth_type = conn_attr->auth_type;
-   hif_drv->usr_conn_req.conn_result = conn_attr->result;
-   hif_drv->usr_conn_req.arg = conn_attr->arg;
+   struct user_conn_req *conn_attr = &hif_drv->usr_conn_req;
+   struct join_bss_param *bss_param = hif_drv->usr_conn_req.param;
 
wid_list[wid_cnt].id = WID_SUCCESS_FRAME_COUNT;
wid_list[wid_cnt].type = WID_INT;
@@ -431,20 +377,20 @@ static int wilc_send_connect_wid(struct wilc_vif *vif,
 
wid_list[wid_cnt].id = WID_INFO_ELEMENT_ASSOCIATE;
wid_list[wid_cnt].type = WID_BIN_DATA;
-   wid_list[wid_cnt].val = hif_drv->usr_conn_req.ies;
-   wid_list[wid_cnt].size = hif_drv->usr_conn_req.ies_len;
+   wid_list[wid_cnt].val = conn_attr->ies;
+   wid_list[wid_cnt].size = conn_attr->ies_len;
wid_cnt++;
 
wid_list[wid_cnt].id = WID_11I_MODE;
wid_list[wid_cnt].type = WID_CHAR;
wid_list[wid_cnt].size = sizeof(char);
-   wid_list[wid_cnt].val = (s8 *)&hif_drv->usr_conn_req.security;
+   wid_list[wid_cnt].val = (s8 *)&conn_attr->security;
wid_cnt++;
 
wid_list[wid_cnt].id = WID_AUTH_TYPE;
wid_list[wid_cnt].type = WID_CHAR;
wid_list[wid_cnt].size = sizeof(char);
-   wid_list[wid_cnt].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
+   wid_list[wid_cnt].val = (s8 *)&conn_attr->auth_type;
wid_cnt++;
 
wid_list[wid_cnt].id = WID_JOIN_REQ_EXTENDED;
@@ -494,7 +440,7 @@ static int wilc_send_connect_wid(struct wilc_vif

[PATCH] staging: wilc1000: fix NULL dereference inside wilc_scan()

2018-12-14 Thread Ajay.Kathat
From: Ajay Singh 

Added NULL check before accessing 'hidden_net' pointer inside
wilc_scan() to fix the issue found by static code checker.

Fixes: 8f1a0ac1eba7 ("staging: wilc1000: handle scan operation callback from 
cfg80211 context")
Reported-by: Dan Carpenter 
Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 48 +--
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index b8603f2..70c854d 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -246,27 +246,29 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 
scan_type,
 
hif_drv->usr_scan_req.ch_cnt = 0;
 
-   wid_list[index].id = WID_SSID_PROBE_REQ;
-   wid_list[index].type = WID_STR;
-
-   for (i = 0; i < hidden_net->n_ssids; i++)
-   valuesize += ((hidden_net->net_info[i].ssid_len) + 1);
-   hdn_ntwk_wid_val = kmalloc(valuesize + 1, GFP_KERNEL);
-   wid_list[index].val = hdn_ntwk_wid_val;
-   if (wid_list[index].val) {
-   buffer = wid_list[index].val;
-
-   *buffer++ = hidden_net->n_ssids;
-
-   for (i = 0; i < hidden_net->n_ssids; i++) {
-   *buffer++ = hidden_net->net_info[i].ssid_len;
-   memcpy(buffer, hidden_net->net_info[i].ssid,
-  hidden_net->net_info[i].ssid_len);
-   buffer += hidden_net->net_info[i].ssid_len;
-   }
+   if (hidden_net) {
+   wid_list[index].id = WID_SSID_PROBE_REQ;
+   wid_list[index].type = WID_STR;
+
+   for (i = 0; i < hidden_net->n_ssids; i++)
+   valuesize += ((hidden_net->net_info[i].ssid_len) + 1);
+   hdn_ntwk_wid_val = kmalloc(valuesize + 1, GFP_KERNEL);
+   wid_list[index].val = hdn_ntwk_wid_val;
+   if (wid_list[index].val) {
+   buffer = wid_list[index].val;
+
+   *buffer++ = hidden_net->n_ssids;
+
+   for (i = 0; i < hidden_net->n_ssids; i++) {
+   *buffer++ = hidden_net->net_info[i].ssid_len;
+   memcpy(buffer, hidden_net->net_info[i].ssid,
+  hidden_net->net_info[i].ssid_len);
+   buffer += hidden_net->net_info[i].ssid_len;
+   }
 
-   wid_list[index].size = (s32)(valuesize + 1);
-   index++;
+   wid_list[index].size = (s32)(valuesize + 1);
+   index++;
+   }
}
 
wid_list[index].id = WID_INFO_ELEMENT_PROBE;
@@ -316,8 +318,10 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 
scan_type,
  jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
 
 error:
-   kfree(hidden_net->net_info);
-   kfree(hdn_ntwk_wid_val);
+   if (hidden_net) {
+   kfree(hidden_net->net_info);
+   kfree(hdn_ntwk_wid_val);
+   }
 
return result;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: wilc1000: fix missing read_write setting when reading data

2018-12-19 Thread Ajay.Kathat



On 12/19/2018 10:00 PM, Colin King wrote:
> From: Colin Ian King 
> 
> Currently the cmd.read_write setting is not initialized so it contains
> garbage from the stack.  Fix this by setting it to 0 to indicate a
> read is required.
> 
> Detected by CoverityScan, CID#1357925 ("Uninitialized scalar variable")
> 
> Fixes: c5c77ba18ea6 ("staging: wilc1000: Add SDIO/SPI 802.11 driver")

Acked-by: Ajay Singh 
> Signed-off-by: Colin Ian King 
> ---
>  drivers/staging/wilc1000/wilc_sdio.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/wilc1000/wilc_sdio.c 
> b/drivers/staging/wilc1000/wilc_sdio.c
> index 27fdfbdda5c0..e2f739fef21c 100644
> --- a/drivers/staging/wilc1000/wilc_sdio.c
> +++ b/drivers/staging/wilc1000/wilc_sdio.c
> @@ -861,6 +861,7 @@ static int sdio_read_int(struct wilc *wilc, u32 
> *int_status)
>   if (!sdio_priv->irq_gpio) {
>   int i;
>  
> + cmd.read_write = 0;
>   cmd.function = 1;
>   cmd.address = 0x04;
>   cmd.data = 0;
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: wilc1000: fix cast to restricted __le32

2019-01-06 Thread Ajay.Kathat
Hi Julius,

On 1/6/2019 12:48 PM, Július Milan wrote:
>> Before you send V3, are you sure this is the correct fix? As "frame_type" is
>> input as u16, it seems to me that the frame_type member of struct 
>> wilc_reg_frame
>> should be __le16, not __le32.
> 
> Yes, I am confident about it.
> The frame_type member of struct wilc_reg_frame contains in some cases
> 32 bit value
> as you can see in function wilc_wlan_cfg_set_wid.
> Cast to 32 bits is also safe, due to resultant endianness.

Thanks for submitting your patch.

But as Larry pointed we need to change the 'frame_type' type to '__le16'
in 'wilc_reg_frame' struct.
The correct fix for this issue is to change the datatype from ‘__le32’
to ‘__le16’, as the firmware expects it to be a 16bit value.

As wilc_wlan_cfg_set_wid(), is a generic function to pack different
types of WID's e.g char u8 (0x0xxx), short (u16) (0x1xxx), int (u32)
(0x2xxx), byte-string (0x3xxx) and binary data(0x4xxx). And based on the
WID type the specific pack format is used.
To frame register, WID_REGISTER_FRAME(0x3085) WID value is used and it's
of byte-string type. So the packed struct value is transmitted as an
array of u8 data. IMO there is no endianness issue provided firmware
extracts members information in the correct structure order.

Please resubmit the patch by changing 'frame_type' type to '__le16' in
'wilc_reg_frame' struct.

Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4] staging: wilc1000: fix registration frame size

2019-01-07 Thread Ajay.Kathat


On 1/7/2019 8:13 PM, Július Milan wrote:
> Fixes the following sparse warnings:
> 
> drivers/staging/wilc1000/host_interface.c:2360:30: warning:
>  incorrect type in assignment (different base types)
> expected restricted __le32 [addressable] [assigned] [usertype] frame_type
> got restricted __le16 [usertype] 
> 
> Fixes: 147ccfd451024 ("staging: wilc1000: handle mgmt_frame_register ops from 
> cfg82011 context")
> Signed-off-by: Július Milan 

Thanks, the change looks fine to me.

Reviewed-by: Ajay Singh 

Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/13] staging: wilc1000: refactor information message parsing logic

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Refactor code to avoid maintaining an unnecessary buffer to keep the
information type message ('I' msg type).

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 66 ---
 1 file changed, 16 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index e37d8ab..a146b78 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -11,9 +11,8 @@
 
 #define FALSE_FRMWR_CHANNEL100
 
-struct rcvd_async_info {
-   u8 *buffer;
-   u32 len;
+struct wilc_rcvd_mac_info {
+   u8 status;
 };
 
 struct set_multicast {
@@ -71,7 +70,7 @@ struct wilc_gtk_key {
 
 union message_body {
struct wilc_rcvd_net_info net_info;
-   struct rcvd_async_info async_info;
+   struct wilc_rcvd_mac_info mac_info;
struct set_multicast multicast_info;
struct remain_ch remain_on_ch;
char *data;
@@ -755,55 +754,30 @@ static void handle_rcvd_gnrl_async_info(struct 
work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
struct wilc_vif *vif = msg->vif;
-   struct rcvd_async_info *rcvd_info = &msg->body.async_info;
-   u8 msg_type;
-   u8 mac_status;
+   struct wilc_rcvd_mac_info *mac_info = &msg->body.mac_info;
struct host_if_drv *hif_drv = vif->hif_drv;
 
-   if (!rcvd_info->buffer) {
-   netdev_err(vif->ndev, "%s: buffer is NULL\n", __func__);
-   goto free_msg;
-   }
-
if (!hif_drv) {
netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__);
-   goto free_rcvd_info;
+   goto free_msg;
}
 
-   if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP ||
-   hif_drv->hif_state == HOST_IF_CONNECTED ||
-   hif_drv->usr_scan_req.scan_result) {
-   if (!hif_drv->conn_info.conn_result) {
-   netdev_err(vif->ndev, "%s: conn_result is NULL\n",
-  __func__);
-   goto free_rcvd_info;
-   }
-
-   msg_type = rcvd_info->buffer[0];
-
-   if ('I' != msg_type) {
-   netdev_err(vif->ndev, "Received Message incorrect.\n");
-   goto free_rcvd_info;
-   }
+   if (!hif_drv->conn_info.conn_result) {
+   netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
+   goto free_msg;
+   }
 
-   mac_status  = rcvd_info->buffer[7];
-   if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
-   host_int_parse_assoc_resp_info(vif, mac_status);
-   } else if ((mac_status == WILC_MAC_STATUS_DISCONNECTED) &&
-  (hif_drv->hif_state == HOST_IF_CONNECTED)) {
+   if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
+   host_int_parse_assoc_resp_info(vif, mac_info->status);
+   } else if (mac_info->status == WILC_MAC_STATUS_DISCONNECTED) {
+   if (hif_drv->hif_state == HOST_IF_CONNECTED) {
host_int_handle_disconnect(vif);
-   } else if ((mac_status == WILC_MAC_STATUS_DISCONNECTED) &&
-  (hif_drv->usr_scan_req.scan_result)) {
+   } else if (hif_drv->usr_scan_req.scan_result) {
del_timer(&hif_drv->scan_timer);
-   if (hif_drv->usr_scan_req.scan_result)
-   handle_scan_done(vif, SCAN_EVENT_ABORTED);
+   handle_scan_done(vif, SCAN_EVENT_ABORTED);
}
}
 
-free_rcvd_info:
-   kfree(rcvd_info->buffer);
-   rcvd_info->buffer = NULL;
-
 free_msg:
kfree(msg);
 }
@@ -1864,18 +1838,10 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, 
u8 *buffer, u32 length)
return;
}
 
-   msg->body.async_info.len = length;
-   msg->body.async_info.buffer = kmemdup(buffer, length, GFP_KERNEL);
-   if (!msg->body.async_info.buffer) {
-   kfree(msg);
-   mutex_unlock(&hif_deinit_lock);
-   return;
-   }
-
+   msg->body.mac_info.status = buffer[7];
result = wilc_enqueue_work(msg);
if (result) {
netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-   kfree(msg->body.async_info.buffer);
kfree(msg);
}
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/13] staging: wilc1000: corrected order to pack join param buffer

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Modified packing order for join param as expected by firmware.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 68f58d1..2fb5697 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -11,8 +11,6 @@
 
 #define FALSE_FRMWR_CHANNEL100
 
-#define REAL_JOIN_REQ  0
-
 struct rcvd_async_info {
u8 *buffer;
u32 len;
@@ -436,15 +434,14 @@ static int wilc_send_connect_wid(struct wilc_vif *vif)
memcpy(cur_byte, bss_param->rsn_cap, sizeof(bss_param->rsn_cap));
cur_byte += sizeof(bss_param->rsn_cap);
 
-   *(cur_byte++) = REAL_JOIN_REQ;
*(cur_byte++) = bss_param->noa_enabled;
 
if (bss_param->noa_enabled) {
put_unaligned_le32(bss_param->tsf, cur_byte);
cur_byte += 4;
 
-   *(cur_byte++) = bss_param->opp_enabled;
*(cur_byte++) = bss_param->idx;
+   *(cur_byte++) = bss_param->opp_enabled;
 
if (bss_param->opp_enabled)
*(cur_byte++) = bss_param->ct_window;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/13] staging: wilc1000: make use of get_unaligned_le16/le32 to pack data

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Make use of get_unaligned_le16/le32 framework api's to pack data.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 15 +++
 drivers/staging/wilc1000/wilc_wlan_cfg.c  | 27 +--
 2 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index c05c120..a718842 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -2154,10 +2154,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 
*buffer, u32 length)
struct host_if_drv *hif_drv;
struct wilc_vif *vif;
 
-   id = buffer[length - 4];
-   id |= (buffer[length - 3] << 8);
-   id |= (buffer[length - 2] << 16);
-   id |= (buffer[length - 1] << 24);
+   id = get_unaligned_le32(&buffer[length - 4]);
vif = wilc_get_vif_from_idx(wilc, id);
if (!vif)
return;
@@ -2197,10 +2194,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 
*buffer, u32 length)
 
mutex_lock(&hif_deinit_lock);
 
-   id = buffer[length - 4];
-   id |= (buffer[length - 3] << 8);
-   id |= (buffer[length - 2] << 16);
-   id |= (buffer[length - 1] << 24);
+   id = get_unaligned_le32(&buffer[length - 4]);
vif = wilc_get_vif_from_idx(wilc, id);
if (!vif) {
mutex_unlock(&hif_deinit_lock);
@@ -2251,10 +2245,7 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 
*buffer, u32 length)
struct host_if_drv *hif_drv;
struct wilc_vif *vif;
 
-   id = buffer[length - 4];
-   id |= buffer[length - 3] << 8;
-   id |= buffer[length - 2] << 16;
-   id |= buffer[length - 1] << 24;
+   id = get_unaligned_le32(&buffer[length - 4]);
vif = wilc_get_vif_from_idx(wilc, id);
if (!vif)
return;
diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c 
b/drivers/staging/wilc1000/wilc_wlan_cfg.c
index 8390766..67e9f93 100644
--- a/drivers/staging/wilc1000/wilc_wlan_cfg.c
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c
@@ -168,7 +168,7 @@ static void wilc_wlan_parse_response_frame(struct wilc *wl, 
u8 *info, int size)
 
while (size > 0) {
i = 0;
-   wid = info[0] | (info[1] << 8);
+   wid = get_unaligned_le16(info);
 
switch (GET_WID_TYPE(wid)) {
case WID_CHAR:
@@ -187,12 +187,13 @@ static void wilc_wlan_parse_response_frame(struct wilc 
*wl, u8 *info, int size)
 
case WID_SHORT:
do {
-   if (wl->cfg.hw[i].id == WID_NIL)
+   struct wilc_cfg_hword *hw = &wl->cfg.hw[i];
+
+   if (hw->id == WID_NIL)
break;
 
-   if (wl->cfg.hw[i].id == wid) {
-   wl->cfg.hw[i].val = (info[4] |
-(info[5] << 8));
+   if (hw->id == wid) {
+   hw->val = get_unaligned_le16(&info[4]);
break;
}
i++;
@@ -202,14 +203,13 @@ static void wilc_wlan_parse_response_frame(struct wilc 
*wl, u8 *info, int size)
 
case WID_INT:
do {
-   if (wl->cfg.w[i].id == WID_NIL)
+   struct wilc_cfg_word *w = &wl->cfg.w[i];
+
+   if (w->id == WID_NIL)
break;
 
-   if (wl->cfg.w[i].id == wid) {
-   wl->cfg.w[i].val = (info[4] |
-   (info[5] << 8) |
-   (info[6] << 16) |
-   (info[7] << 24));
+   if (w->id == wid) {
+   w->val = get_unaligned_le32(&info[4]);
break;
}
i++;
@@ -244,7 +244,7 @@ static void wilc_wlan_parse_info_frame(struct wilc *wl, u8 
*info)
 {
u32 wid, len;
 
-   wid = info[0] | (info[1] << 8);
+   wid = get_unaligned_le16(info);
 
len = info[2];
 
@@ -371,8 +371,7 @@ int wilc_wlan_cfg_get_wid_value(struct wilc *wl, u16 wid, 
u8 *buffer,
break;
 
if (id == wid) {
-   u32 size = (wl->cfg.s[i].str[0] |
-   (wl->cfg.s[i].str[1] << 8));
+   u16 size = get_unaligned_le16(wl->cfg.s[i].str);

[PATCH 09/13] staging: wilc1000: use single struct for 'connect' related parameters

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Use single structure to store the connect request and response
information. It helped in avoiding unnecessary buffer allocation to
handle request and response flow.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 217 ++
 drivers/staging/wilc1000/host_interface.h |  41 ++--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  30 +--
 3 files changed, 84 insertions(+), 204 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 6c2be43..e37d8ab 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -344,8 +344,8 @@ static int wilc_send_connect_wid(struct wilc_vif *vif)
struct wid wid_list[8];
u32 wid_cnt = 0, dummyval = 0;
struct host_if_drv *hif_drv = vif->hif_drv;
-   struct user_conn_req *conn_attr = &hif_drv->usr_conn_req;
-   struct wilc_join_bss_param *bss_param = hif_drv->usr_conn_req.param;
+   struct wilc_conn_info *conn_attr = &hif_drv->conn_info;
+   struct wilc_join_bss_param *bss_param = conn_attr->param;
 
wid_list[wid_cnt].id = WID_SUCCESS_FRAME_COUNT;
wid_list[wid_cnt].type = WID_INT;
@@ -367,8 +367,8 @@ static int wilc_send_connect_wid(struct wilc_vif *vif)
 
wid_list[wid_cnt].id = WID_INFO_ELEMENT_ASSOCIATE;
wid_list[wid_cnt].type = WID_BIN_DATA;
-   wid_list[wid_cnt].val = conn_attr->ies;
-   wid_list[wid_cnt].size = conn_attr->ies_len;
+   wid_list[wid_cnt].val = conn_attr->req_ies;
+   wid_list[wid_cnt].size = conn_attr->req_ies_len;
wid_cnt++;
 
wid_list[wid_cnt].id = WID_11I_MODE;
@@ -403,14 +403,8 @@ static int wilc_send_connect_wid(struct wilc_vif *vif)
 
 error:
 
-   kfree(conn_attr->bssid);
-   conn_attr->bssid = NULL;
-
-   kfree(conn_attr->ssid);
-   conn_attr->ssid = NULL;
-
-   kfree(conn_attr->ies);
-   conn_attr->ies = NULL;
+   kfree(conn_attr->req_ies);
+   conn_attr->req_ies = NULL;
 
return result;
 }
@@ -420,7 +414,6 @@ static void handle_connect_timeout(struct work_struct *work)
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
struct wilc_vif *vif = msg->vif;
int result;
-   struct connect_info info;
struct wid wid;
u16 dummy_reason_code = 0;
struct host_if_drv *hif_drv = vif->hif_drv;
@@ -432,31 +425,11 @@ static void handle_connect_timeout(struct work_struct 
*work)
 
hif_drv->hif_state = HOST_IF_IDLE;
 
-   memset(&info, 0, sizeof(struct connect_info));
-
-   if (hif_drv->usr_conn_req.conn_result) {
-   if (hif_drv->usr_conn_req.bssid) {
-   memcpy(info.bssid,
-  hif_drv->usr_conn_req.bssid, 6);
-   }
-
-   if (hif_drv->usr_conn_req.ies) {
-   info.req_ies_len = hif_drv->usr_conn_req.ies_len;
-   info.req_ies = kmemdup(hif_drv->usr_conn_req.ies,
-  hif_drv->usr_conn_req.ies_len,
-  GFP_KERNEL);
-   if (!info.req_ies)
-   goto out;
-   }
-
-   hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
- &info,
- WILC_MAC_STATUS_DISCONNECTED,
- NULL,
- hif_drv->usr_conn_req.arg);
+   if (hif_drv->conn_info.conn_result) {
+   hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
+  WILC_MAC_STATUS_DISCONNECTED,
+  NULL, hif_drv->conn_info.arg);
 
-   kfree(info.req_ies);
-   info.req_ies = NULL;
} else {
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
}
@@ -471,14 +444,9 @@ static void handle_connect_timeout(struct work_struct 
*work)
if (result)
netdev_err(vif->ndev, "Failed to send disconnect\n");
 
-   hif_drv->usr_conn_req.ssid_len = 0;
-   kfree(hif_drv->usr_conn_req.ssid);
-   hif_drv->usr_conn_req.ssid = NULL;
-   kfree(hif_drv->usr_conn_req.bssid);
-   hif_drv->usr_conn_req.bssid = NULL;
-   hif_drv->usr_conn_req.ies_len = 0;
-   kfree(hif_drv->usr_conn_req.ies);
-   hif_drv->usr_conn_req.ies = NULL;
+   hif_drv->conn_info.req_ies_len = 0;
+   kfree(hif_drv->conn_info.req_ies);
+   hif_drv->conn_info.req_ies = NULL;
 
 out:
kfree(msg);
@@ -671,20 +639,8 @@ static void host_int_get_assoc_res_info(struct wilc_vif 
*vif,
*rcvd_assoc_resp_info_len = wid.size;
 }
 
-static inline void host_int_free_user_conn

[PATCH 05/13] staging: wilc1000: make use of cfg80211_inform_bss_frame()

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Use cfg80211_inform_bss_frame() api instead of cfg80211_inform_bss() to
inform cfg80211 about the BSS frame, to avoid unnecessary parsing of
frame in driver.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 144 +-
 drivers/staging/wilc1000/host_interface.h |  14 ++-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  42 +++
 3 files changed, 50 insertions(+), 150 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index e7f8fab..68f58d1 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -72,7 +72,7 @@ struct wilc_gtk_key {
 } __packed;
 
 union message_body {
-   struct rcvd_net_info net_info;
+   struct wilc_rcvd_net_info net_info;
struct rcvd_async_info async_info;
struct set_multicast multicast_info;
struct remain_ch remain_on_ch;
@@ -743,129 +743,38 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss)
return (void *)param;
 }
 
-static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt)
-{
-   if (ieee80211_has_fromds(mgmt->frame_control))
-   return mgmt->sa;
-   else if (ieee80211_has_tods(mgmt->frame_control))
-   return mgmt->da;
-   else
-   return mgmt->bssid;
-}
-
-static s32 wilc_parse_network_info(u8 *msg_buffer,
-  struct network_info **ret_network_info)
+static void handle_rcvd_ntwrk_info(struct work_struct *work)
 {
-   struct network_info *info;
-   struct ieee80211_mgmt *mgt;
-   u8 *wid_val, *ies;
-   u16 wid_len, rx_len, ies_len;
-   u8 msg_type;
+   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
+   struct wilc_rcvd_net_info *rcvd_info = &msg->body.net_info;
+   struct user_scan_req *scan_req = &msg->vif->hif_drv->usr_scan_req;
+   const u8 *ch_elm;
+   u8 *ies;
+   int ies_len;
size_t offset;
-   const u8 *ch_elm, *tim_elm, *ssid_elm;
-
-   msg_type = msg_buffer[0];
-   if ('N' != msg_type)
-   return -EFAULT;
-
-   wid_len = get_unaligned_le16(&msg_buffer[6]);
-   wid_val = &msg_buffer[8];
-
-   info = kzalloc(sizeof(*info), GFP_KERNEL);
-   if (!info)
-   return -ENOMEM;
 
-   info->rssi = wid_val[0];
-
-   mgt = (struct ieee80211_mgmt *)&wid_val[1];
-   rx_len = wid_len - 1;
-
-   if (ieee80211_is_probe_resp(mgt->frame_control)) {
-   info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info);
-   info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int);
-   info->tsf = le64_to_cpu(mgt->u.probe_resp.timestamp);
-   info->tsf_lo = (u32)info->tsf;
+   if (ieee80211_is_probe_resp(rcvd_info->mgmt->frame_control))
offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable);
-   } else if (ieee80211_is_beacon(mgt->frame_control)) {
-   info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info);
-   info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int);
-   info->tsf = le64_to_cpu(mgt->u.beacon.timestamp);
-   info->tsf_lo = (u32)info->tsf;
+   else if (ieee80211_is_beacon(rcvd_info->mgmt->frame_control))
offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);
-   } else {
-   /* only process probe response and beacon frame */
-   kfree(info);
-   return -EIO;
-   }
-
-   ether_addr_copy(info->bssid, get_bssid(mgt));
-
-   ies = mgt->u.beacon.variable;
-   ies_len = rx_len - offset;
-   if (ies_len <= 0) {
-   kfree(info);
-   return -EIO;
-   }
-
-   info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
-   if (!info->ies) {
-   kfree(info);
-   return -ENOMEM;
-   }
-
-   info->ies_len = ies_len;
+   else
+   goto done;
 
-   ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies, ies_len);
-   if (ssid_elm) {
-   info->ssid_len = ssid_elm[1];
-   if (info->ssid_len <= IEEE80211_MAX_SSID_LEN)
-   memcpy(info->ssid, ssid_elm + 2, info->ssid_len);
-   else
-   info->ssid_len = 0;
-   }
+   ies = rcvd_info->mgmt->u.beacon.variable;
+   ies_len = rcvd_info->frame_len - offset;
+   if (ies_len <= 0)
+   goto done;
 
ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len);
if (ch_elm && ch_elm[1] > 0)
-   info->ch = ch_elm[2];
-
-   tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len);
-   if (tim_elm && tim_elm[1] >= 2)
-   info->dtim_period = tim_elm[3];
-
-   *ret_network_info = info;
-
-   return 0;
-}
-
-static void handle_rcvd_ntwrk_info(struct work_struct *work)
-{

[PATCH 04/13] staging: wilc1000: remove the use of scan shadow buffer

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Remove scan shadow buffer, which is used to store a copy of scan
results. Instead, use cfg80211 provided API's to retrieve required
info. Remove the helper functions which are operating on shadow buffer,
as it's not require now.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c |  94 ++
 drivers/staging/wilc1000/host_interface.h |  24 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 359 +++---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   3 -
 4 files changed, 86 insertions(+), 394 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index a718842..e7f8fab 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -210,7 +210,7 @@ static int handle_scan_done(struct wilc_vif *vif, enum 
scan_event evt)
 
scan_req = &hif_drv->usr_scan_req;
if (scan_req->scan_result) {
-   scan_req->scan_result(evt, NULL, scan_req->arg, NULL);
+   scan_req->scan_result(evt, NULL, scan_req->arg);
scan_req->scan_result = NULL;
}
 
@@ -564,10 +564,10 @@ static void handle_connect_timeout(struct work_struct 
*work)
kfree(msg);
 }
 
-static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies,
-u16 *out_index, u8 *pcipher_tc,
-u8 *auth_total_cnt, u32 tsf_lo,
-u8 *rates_no)
+static void host_int_fill_join_bss_param(struct join_bss_param *param,
+const u8 *ies, u16 *out_index,
+u8 *pcipher_tc, u8 *auth_total_cnt,
+u32 tsf_lo, u8 *rates_no)
 {
u8 ext_rates_no;
u16 offset;
@@ -700,31 +700,44 @@ static void host_int_fill_join_bss_param(struct 
join_bss_param *param, u8 *ies,
*out_index = index;
 }
 
-static void *host_int_parse_join_bss_param(struct network_info *info)
+void *wilc_parse_join_bss_param(struct cfg80211_bss *bss)
 {
struct join_bss_param *param;
u16 index = 0;
u8 rates_no = 0;
u8 pcipher_total_cnt = 0;
u8 auth_total_cnt = 0;
+   const u8 *tim_elm, *ssid_elm;
+   const struct cfg80211_bss_ies *ies = bss->ies;
 
param = kzalloc(sizeof(*param), GFP_KERNEL);
if (!param)
return NULL;
 
-   param->dtim_period = info->dtim_period;
-   param->beacon_period = info->beacon_period;
-   param->cap_info = info->cap_info;
-   memcpy(param->bssid, info->bssid, 6);
-   memcpy((u8 *)param->ssid, info->ssid, info->ssid_len + 1);
-   param->ssid_len = info->ssid_len;
+   param->beacon_period = bss->beacon_interval;
+   param->cap_info = bss->capability;
+   ether_addr_copy(param->bssid, bss->bssid);
+
+   ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len);
+   if (ssid_elm) {
+   param->ssid_len = ssid_elm[1];
+   if (param->ssid_len <= IEEE80211_MAX_SSID_LEN)
+   memcpy(param->ssid, ssid_elm + 2, param->ssid_len);
+   else
+   param->ssid_len = 0;
+   }
+
+   tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len);
+   if (tim_elm && tim_elm[1] >= 2)
+   param->dtim_period = tim_elm[3];
+
memset(param->rsn_pcip_policy, 0xFF, 3);
memset(param->rsn_auth_policy, 0xFF, 3);
 
-   while (index < info->ies_len)
-   host_int_fill_join_bss_param(param, info->ies, &index,
+   while (index < ies->len)
+   host_int_fill_join_bss_param(param, ies->data, &index,
 &pcipher_total_cnt,
-&auth_total_cnt, info->tsf_lo,
+&auth_total_cnt, ies->tsf,
 &rates_no);
 
return (void *)param;
@@ -829,57 +842,20 @@ static void handle_rcvd_ntwrk_info(struct work_struct 
*work)
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
struct wilc_vif *vif = msg->vif;
struct rcvd_net_info *rcvd_info = &msg->body.net_info;
-   u32 i;
-   bool found;
struct network_info *info = NULL;
-   void *params;
-   struct host_if_drv *hif_drv = vif->hif_drv;
-   struct user_scan_req *scan_req = &hif_drv->usr_scan_req;
-
-   found = true;
+   struct user_scan_req *scan_req = &vif->hif_drv->usr_scan_req;
 
if (!scan_req->scan_result)
goto done;
 
wilc_parse_network_info(rcvd_info->buffer, &info);
-   if (!info || !scan_req->scan_result) {
-   netdev_err(vif->ndev, "%s: info or scan result NULL\n",
+   if (!info) {
+   netdev_err(vif->nd

[PATCH 13/13] staging: wilc1000: avoid the use of typedef for function pointers

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Remove typedef for function pointers.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 13 +++--
 drivers/staging/wilc1000/host_interface.h | 24 ++--
 drivers/staging/wilc1000/wilc_wlan.c  | 10 ++
 drivers/staging/wilc1000/wilc_wlan.h  |  5 +++--
 drivers/staging/wilc1000/wilc_wlan_if.h   |  2 --
 5 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index f463865..85573eb 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -231,9 +231,10 @@ static int handle_scan_done(struct wilc_vif *vif, enum 
scan_event evt)
 }
 
 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
- u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
- size_t ies_len, wilc_scan_result scan_result, void *user_arg,
- struct wilc_probe_ssid *search)
+ u8 *ch_freq_list, u8 ch_list_len, const u8 *ies, size_t ies_len,
+ void (*scan_result_fn)(enum scan_event,
+struct wilc_rcvd_net_info *, void *),
+ void *user_arg, struct wilc_probe_ssid *search)
 {
int result = 0;
struct wid wid_list[5];
@@ -322,7 +323,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 
scan_type,
goto error;
}
 
-   hif_drv->usr_scan_req.scan_result = scan_result;
+   hif_drv->usr_scan_req.scan_result = scan_result_fn;
hif_drv->usr_scan_req.arg = user_arg;
hif_drv->scan_timer_vif = vif;
mod_timer(&hif_drv->scan_timer,
@@ -1863,8 +1864,8 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 
*buffer, u32 length)
 
 int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
   u32 duration, u16 chan,
-  wilc_remain_on_chan_expired expired,
-  wilc_remain_on_chan_ready ready,
+  void (*expired)(void *, u32),
+  void (*ready)(void *),
   void *user_arg)
 {
struct remain_ch roc;
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 527ae05..7f3fc4c 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -104,12 +104,6 @@ struct wilc_rcvd_net_info {
struct ieee80211_mgmt *mgmt;
 };
 
-typedef void (*wilc_scan_result)(enum scan_event, struct wilc_rcvd_net_info *,
-void *);
-
-typedef void (*wilc_remain_on_chan_expired)(void *, u32);
-typedef void (*wilc_remain_on_chan_ready)(void *);
-
 struct wilc_probe_ssid_info {
u8 ssid_len;
u8 *ssid;
@@ -122,7 +116,8 @@ struct wilc_probe_ssid {
 };
 
 struct user_scan_req {
-   wilc_scan_result scan_result;
+   void (*scan_result)(enum scan_event evt,
+   struct wilc_rcvd_net_info *info, void *priv);
void *arg;
u32 ch_cnt;
 };
@@ -145,8 +140,8 @@ struct wilc_conn_info {
 struct remain_ch {
u16 ch;
u32 duration;
-   wilc_remain_on_chan_expired expired;
-   wilc_remain_on_chan_ready ready;
+   void (*expired)(void *priv, u32 session_id);
+   void (*ready)(void *priv);
void *arg;
u32 id;
 };
@@ -213,9 +208,10 @@ int wilc_disconnect(struct wilc_vif *vif);
 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
- u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
- size_t ies_len, wilc_scan_result scan_result, void *user_arg,
- struct wilc_probe_ssid *search);
+ u8 *ch_freq_list, u8 ch_list_len, const u8 *ies, size_t ies_len,
+ void (*scan_result_fn)(enum scan_event,
+struct wilc_rcvd_net_info *, void *),
+ void *user_arg, struct wilc_probe_ssid *search);
 int wilc_hif_set_cfg(struct wilc_vif *vif,
 struct cfg_param_attr *cfg_param);
 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
@@ -234,8 +230,8 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 
enabled, u32 count,
u8 *mc_list);
 int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
   u32 duration, u16 chan,
-  wilc_remain_on_chan_expired expired,
-  wilc_remain_on_chan_ready ready,
+  void (*expired)(void *, u32),
+  void (*ready)(void *),
   void *user_arg);
 int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id);
 void wilc_frame_register(struct wilc_vif *vif,

[PATCH 08/13] staging: wilc1000: rename hidden_network related data structure

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Rename hidden_network related data structure to have more appropriate
names, as it's used to keep search network SSID details.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 40 +++
 drivers/staging/wilc1000/host_interface.h | 11 ---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 25 +++---
 3 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 46fd448..6c2be43 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -234,7 +234,7 @@ static int handle_scan_done(struct wilc_vif *vif, enum 
scan_event evt)
 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
  u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
  size_t ies_len, wilc_scan_result scan_result, void *user_arg,
- struct hidden_network *hidden_net)
+ struct wilc_probe_ssid *search)
 {
int result = 0;
struct wid wid_list[5];
@@ -242,7 +242,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 
scan_type,
u32 i;
u8 *buffer;
u8 valuesize = 0;
-   u8 *hdn_ntwk_wid_val = NULL;
+   u8 *search_ssid_vals = NULL;
struct host_if_drv *hif_drv = vif->hif_drv;
 
if (hif_drv->hif_state >= HOST_IF_SCANNING &&
@@ -260,26 +260,24 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 
scan_type,
 
hif_drv->usr_scan_req.ch_cnt = 0;
 
-   if (hidden_net) {
-   wid_list[index].id = WID_SSID_PROBE_REQ;
-   wid_list[index].type = WID_STR;
-
-   for (i = 0; i < hidden_net->n_ssids; i++)
-   valuesize += ((hidden_net->net_info[i].ssid_len) + 1);
-   hdn_ntwk_wid_val = kmalloc(valuesize + 1, GFP_KERNEL);
-   wid_list[index].val = hdn_ntwk_wid_val;
-   if (wid_list[index].val) {
+   if (search) {
+   for (i = 0; i < search->n_ssids; i++)
+   valuesize += ((search->ssid_info[i].ssid_len) + 1);
+   search_ssid_vals = kmalloc(valuesize + 1, GFP_KERNEL);
+   if (search_ssid_vals) {
+   wid_list[index].id = WID_SSID_PROBE_REQ;
+   wid_list[index].type = WID_STR;
+   wid_list[index].val = search_ssid_vals;
buffer = wid_list[index].val;
 
-   *buffer++ = hidden_net->n_ssids;
+   *buffer++ = search->n_ssids;
 
-   for (i = 0; i < hidden_net->n_ssids; i++) {
-   *buffer++ = hidden_net->net_info[i].ssid_len;
-   memcpy(buffer, hidden_net->net_info[i].ssid,
-  hidden_net->net_info[i].ssid_len);
-   buffer += hidden_net->net_info[i].ssid_len;
+   for (i = 0; i < search->n_ssids; i++) {
+   *buffer++ = search->ssid_info[i].ssid_len;
+   memcpy(buffer, search->ssid_info[i].ssid,
+  search->ssid_info[i].ssid_len);
+   buffer += search->ssid_info[i].ssid_len;
}
-
wid_list[index].size = (s32)(valuesize + 1);
index++;
}
@@ -332,9 +330,9 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 
scan_type,
  jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
 
 error:
-   if (hidden_net) {
-   kfree(hidden_net->net_info);
-   kfree(hdn_ntwk_wid_val);
+   if (search) {
+   kfree(search->ssid_info);
+   kfree(search_ssid_vals);
}
 
return result;
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 659e8cc..e702404 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -131,14 +131,15 @@ typedef void (*wilc_connect_result)(enum conn_event,
 typedef void (*wilc_remain_on_chan_expired)(void *, u32);
 typedef void (*wilc_remain_on_chan_ready)(void *);
 
-struct hidden_net_info {
-   u8  *ssid;
+struct wilc_probe_ssid_info {
u8 ssid_len;
+   u8 *ssid;
 };
 
-struct hidden_network {
-   struct hidden_net_info *net_info;
+struct wilc_probe_ssid {
+   struct wilc_probe_ssid_info *ssid_info;
u8 n_ssids;
+   u32 size;
 };
 
 struct user_scan_req {
@@ -238,7 +239,7 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
  u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
  size_t ies_len, wilc_scan_result scan_result, void *user_arg,
- struct hidden_net

[PATCH 07/13] staging: wilc1000: use struct to pack join parameters for FW

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Refactor code to use struct to construct the join parameters. Avoid use
of extra buffer before sending to FW instead directly pass the struct
pointer.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 404 --
 drivers/staging/wilc1000/host_interface.h |  18 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |   2 +-
 drivers/staging/wilc1000/wilc_wlan_if.h   |   1 -
 4 files changed, 142 insertions(+), 283 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 2fb5697..46fd448 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -86,34 +86,50 @@ struct host_if_msg {
bool is_sync;
 };
 
-struct join_bss_param {
-   enum bss_types bss_type;
+struct wilc_noa_opp_enable {
+   u8 ct_window;
+   u8 cnt;
+   __le32 duration;
+   __le32 interval;
+   __le32 start_time;
+} __packed;
+
+struct wilc_noa_opp_disable {
+   u8 cnt;
+   __le32 duration;
+   __le32 interval;
+   __le32 start_time;
+} __packed;
+
+struct wilc_join_bss_param {
+   char ssid[IEEE80211_MAX_SSID_LEN];
+   u8 ssid_terminator;
+   u8 bss_type;
+   u8 ch;
+   __le16 cap_info;
+   u8 sa[ETH_ALEN];
+   u8 bssid[ETH_ALEN];
+   __le16 beacon_period;
u8 dtim_period;
-   u16 beacon_period;
-   u16 cap_info;
-   u8 bssid[6];
-   char ssid[MAX_SSID_LEN];
-   u8 ssid_len;
u8 supp_rates[MAX_RATES_SUPPORTED + 1];
-   u8 ht_capable;
u8 wmm_cap;
u8 uapsd_cap;
-   bool rsn_found;
+   u8 ht_capable;
+   u8 rsn_found;
u8 rsn_grp_policy;
u8 mode_802_11i;
-   u8 rsn_pcip_policy[3];
-   u8 rsn_auth_policy[3];
+   u8 p_suites[3];
+   u8 akm_suites[3];
u8 rsn_cap[2];
-   u32 tsf;
u8 noa_enabled;
-   u8 opp_enabled;
-   u8 ct_window;
-   u8 cnt;
+   __le32 tsf_lo;
u8 idx;
-   u8 duration[4];
-   u8 interval[4];
-   u8 start_time[4];
-};
+   u8 opp_enabled;
+   union {
+   struct wilc_noa_opp_disable opp_dis;
+   struct wilc_noa_opp_enable opp_en;
+   };
+} __packed;
 
 static struct host_if_drv *terminated_handle;
 static struct mutex hif_deinit_lock;
@@ -329,10 +345,9 @@ static int wilc_send_connect_wid(struct wilc_vif *vif)
int result = 0;
struct wid wid_list[8];
u32 wid_cnt = 0, dummyval = 0;
-   u8 *cur_byte = NULL;
struct host_if_drv *hif_drv = vif->hif_drv;
struct user_conn_req *conn_attr = &hif_drv->usr_conn_req;
-   struct join_bss_param *bss_param = hif_drv->usr_conn_req.param;
+   struct wilc_join_bss_param *bss_param = hif_drv->usr_conn_req.param;
 
wid_list[wid_cnt].id = WID_SUCCESS_FRAME_COUNT;
wid_list[wid_cnt].type = WID_INT;
@@ -372,96 +387,8 @@ static int wilc_send_connect_wid(struct wilc_vif *vif)
 
wid_list[wid_cnt].id = WID_JOIN_REQ_EXTENDED;
wid_list[wid_cnt].type = WID_STR;
-   wid_list[wid_cnt].size = 112;
-   wid_list[wid_cnt].val = kmalloc(wid_list[wid_cnt].size, GFP_KERNEL);
-
-   if (!wid_list[wid_cnt].val) {
-   result = -EFAULT;
-   goto error;
-   }
-
-   cur_byte = wid_list[wid_cnt].val;
-
-   if (conn_attr->ssid) {
-   memcpy(cur_byte, conn_attr->ssid, conn_attr->ssid_len);
-   cur_byte[conn_attr->ssid_len] = '\0';
-   }
-   cur_byte += MAX_SSID_LEN;
-   *(cur_byte++) = WILC_FW_BSS_TYPE_INFRA;
-
-   if (conn_attr->ch >= 1 && conn_attr->ch <= 14) {
-   *(cur_byte++) = conn_attr->ch;
-   } else {
-   netdev_err(vif->ndev, "Channel out of range\n");
-   *(cur_byte++) = 0xFF;
-   }
-   put_unaligned_le16(bss_param->cap_info, cur_byte);
-   cur_byte += 2;
-
-   if (conn_attr->bssid)
-   memcpy(cur_byte, conn_attr->bssid, 6);
-   cur_byte += 6;
-
-   if (conn_attr->bssid)
-   memcpy(cur_byte, conn_attr->bssid, 6);
-   cur_byte += 6;
-
-   put_unaligned_le16(bss_param->beacon_period, cur_byte);
-   cur_byte += 2;
-   *(cur_byte++)  =  bss_param->dtim_period;
-
-   memcpy(cur_byte, bss_param->supp_rates, MAX_RATES_SUPPORTED + 1);
-   cur_byte += (MAX_RATES_SUPPORTED + 1);
-
-   *(cur_byte++)  =  bss_param->wmm_cap;
-   *(cur_byte++)  = bss_param->uapsd_cap;
-
-   *(cur_byte++)  = bss_param->ht_capable;
-   conn_attr->ht_capable = bss_param->ht_capable;
-
-   *(cur_byte++)  =  bss_param->rsn_found;
-   *(cur_byte++)  =  bss_param->rsn_grp_policy;
-   *(cur_byte++) =  bss_param->mode_802_11i;
-
-   memcpy(cur_byte, bss_param->rsn_pcip_policy,
-  sizeof(bss_param->rsn_pcip_policy));
-   cur_byte += sizeof(bss_param->rsn_pcip_policy);
-
-   memcp

[PATCH 11/13] staging: wilc1000: remove 'disconnect_info' structure

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Remove 'disconnect_info' struct use because its passed values are not
required in cfg_connect_result().

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 24 +--
 drivers/staging/wilc1000/host_interface.h |  9 +
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 12 ++--
 3 files changed, 12 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index a146b78..fa3af2c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -427,7 +427,7 @@ static void handle_connect_timeout(struct work_struct *work)
if (hif_drv->conn_info.conn_result) {
hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
   WILC_MAC_STATUS_DISCONNECTED,
-  NULL, hif_drv->conn_info.arg);
+  hif_drv->conn_info.arg);
 
} else {
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
@@ -689,7 +689,7 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
}
 
del_timer(&hif_drv->connect_timer);
-   conn_info->conn_result(CONN_DISCONN_EVENT_CONN_RESP, mac_status, NULL,
+   conn_info->conn_result(CONN_DISCONN_EVENT_CONN_RESP, mac_status,
   hif_drv->conn_info.arg);
 
if (mac_status == WILC_MAC_STATUS_CONNECTED &&
@@ -717,27 +717,19 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
 
 static inline void host_int_handle_disconnect(struct wilc_vif *vif)
 {
-   struct disconnect_info disconn_info;
struct host_if_drv *hif_drv = vif->hif_drv;
 
-   memset(&disconn_info, 0, sizeof(struct disconnect_info));
-
if (hif_drv->usr_scan_req.scan_result) {
del_timer(&hif_drv->scan_timer);
handle_scan_done(vif, SCAN_EVENT_ABORTED);
}
 
-   disconn_info.reason = 0;
-   disconn_info.ie = NULL;
-   disconn_info.ie_len = 0;
-
if (hif_drv->conn_info.conn_result) {
vif->obtaining_ip = false;
wilc_set_power_mgmt(vif, 0, 0);
 
hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
-  0, &disconn_info,
-  hif_drv->conn_info.arg);
+  0, hif_drv->conn_info.arg);
} else {
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
}
@@ -786,7 +778,6 @@ int wilc_disconnect(struct wilc_vif *vif)
 {
struct wid wid;
struct host_if_drv *hif_drv = vif->hif_drv;
-   struct disconnect_info disconn_info;
struct user_scan_req *scan_req;
struct wilc_conn_info *conn_info;
int result;
@@ -807,11 +798,6 @@ int wilc_disconnect(struct wilc_vif *vif)
return result;
}
 
-   memset(&disconn_info, 0, sizeof(struct disconnect_info));
-
-   disconn_info.reason = 0;
-   disconn_info.ie = NULL;
-   disconn_info.ie_len = 0;
scan_req = &hif_drv->usr_scan_req;
conn_info = &hif_drv->conn_info;
 
@@ -825,8 +811,8 @@ int wilc_disconnect(struct wilc_vif *vif)
if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP)
del_timer(&hif_drv->connect_timer);
 
-   conn_info->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
-  0, &disconn_info, conn_info->arg);
+   conn_info->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, 0,
+  conn_info->arg);
} else {
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
}
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 459a084..363db0b 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -35,12 +35,6 @@ enum {
 
 #define WILC_MAX_ASSOC_RESP_FRAME_SIZE   256
 
-struct disconnect_info {
-   u16 reason;
-   u8 *ie;
-   size_t ie_len;
-};
-
 struct assoc_resp {
__le16 capab_info;
__le16 status_code;
@@ -143,8 +137,7 @@ struct wilc_conn_info {
u8 *resp_ies;
u16 resp_ies_len;
u16 status;
-   void (*conn_result)(enum conn_event evt, u8 status,
-   struct disconnect_info *info, void *priv_data);
+   void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
void *arg;
void *param;
 };
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index bc1d7a7..79753ad 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
++

[PATCH 00/13] staging: wilc1000: address few mainline review

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

This series contains changes to address few of the review comments[1].
It mainly has the modification to remove the use of scan shadow
buffer, make use of kernel provided API, avoid typedef's and few
changes to simplify the logic.

[1]. https://www.spinics.net/lists/linux-wireless/msg178735.html
 https://www.spinics.net/lists/linux-wireless/msg179533.html
 https://www.spinics.net/lists/linux-wireless/msg178760.html

Ajay Singh (13):
  staging: wilc1000: make use of get_unaligned_le16/le32 to pack data
  staging: wilc1000: refactor wilc_wlan_set_bssid()
  staging: wilc1000: use 'struct' to pack cfg header frame in
wilc_wlan_cfg_commit()
  staging: wilc1000: remove the use of scan shadow buffer
  staging: wilc1000: make use of cfg80211_inform_bss_frame()
  staging: wilc1000: corrected order to pack join param buffer
  staging: wilc1000: use struct to pack join parameters for FW
  staging: wilc1000: rename hidden_network related data structure
  staging: wilc1000: use single struct for 'connect' related parameters
  staging: wilc1000: refactor information message parsing logic
  staging: wilc1000: remove 'disconnect_info' structure
  staging: wilc1000: refactor handle_set_mcast_filter()
  staging: wilc1000: avoid the use of typedef for function pointers

 drivers/staging/wilc1000/host_interface.c | 979 +++---
 drivers/staging/wilc1000/host_interface.h | 127 +--
 drivers/staging/wilc1000/linux_wlan.c |  12 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 450 ++
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   5 +-
 drivers/staging/wilc1000/wilc_wlan.c  |  35 +-
 drivers/staging/wilc1000/wilc_wlan.h  |  19 +-
 drivers/staging/wilc1000/wilc_wlan_cfg.c  |  27 +-
 drivers/staging/wilc1000/wilc_wlan_if.h   |   3 -
 9 files changed, 456 insertions(+), 1201 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/13] staging: wilc1000: refactor handle_set_mcast_filter()

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Refactor handle_set_mcast_filter() by making use of put_unaligned32() to
pack the data instead of byte operation.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 37 +--
 drivers/staging/wilc1000/host_interface.h |  2 +-
 drivers/staging/wilc1000/linux_wlan.c |  6 ++---
 3 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index fa3af2c..f463865 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -15,8 +15,8 @@ struct wilc_rcvd_mac_info {
u8 status;
 };
 
-struct set_multicast {
-   bool enabled;
+struct wilc_set_multicast {
+   u32 enabled;
u32 cnt;
u8 *mc_list;
 };
@@ -71,7 +71,7 @@ struct wilc_gtk_key {
 union message_body {
struct wilc_rcvd_net_info net_info;
struct wilc_rcvd_mac_info mac_info;
-   struct set_multicast multicast_info;
+   struct wilc_set_multicast mc_info;
struct remain_ch remain_on_ch;
char *data;
 };
@@ -1067,32 +1067,27 @@ static void handle_set_mcast_filter(struct work_struct 
*work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
struct wilc_vif *vif = msg->vif;
-   struct set_multicast *hif_set_mc = &msg->body.multicast_info;
+   struct wilc_set_multicast *set_mc = &msg->body.mc_info;
int result;
struct wid wid;
u8 *cur_byte;
 
wid.id = WID_SETUP_MULTICAST_FILTER;
wid.type = WID_BIN;
-   wid.size = sizeof(struct set_multicast) + (hif_set_mc->cnt * ETH_ALEN);
+   wid.size = sizeof(struct wilc_set_multicast) + (set_mc->cnt * ETH_ALEN);
wid.val = kmalloc(wid.size, GFP_KERNEL);
if (!wid.val)
goto error;
 
cur_byte = wid.val;
-   *cur_byte++ = (hif_set_mc->enabled & 0xFF);
-   *cur_byte++ = 0;
-   *cur_byte++ = 0;
-   *cur_byte++ = 0;
+   put_unaligned_le32(set_mc->enabled, cur_byte);
+   cur_byte += 4;
 
-   *cur_byte++ = (hif_set_mc->cnt & 0xFF);
-   *cur_byte++ = ((hif_set_mc->cnt >> 8) & 0xFF);
-   *cur_byte++ = ((hif_set_mc->cnt >> 16) & 0xFF);
-   *cur_byte++ = ((hif_set_mc->cnt >> 24) & 0xFF);
+   put_unaligned_le32(set_mc->cnt, cur_byte);
+   cur_byte += 4;
 
-   if (hif_set_mc->cnt > 0 && hif_set_mc->mc_list)
-   memcpy(cur_byte, hif_set_mc->mc_list,
-  ((hif_set_mc->cnt) * ETH_ALEN));
+   if (set_mc->cnt > 0 && set_mc->mc_list)
+   memcpy(cur_byte, set_mc->mc_list, set_mc->cnt * ETH_ALEN);
 
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
  wilc_get_vif_idx(vif));
@@ -1100,7 +1095,7 @@ static void handle_set_mcast_filter(struct work_struct 
*work)
netdev_err(vif->ndev, "Failed to send setup multicast\n");
 
 error:
-   kfree(hif_set_mc->mc_list);
+   kfree(set_mc->mc_list);
kfree(wid.val);
kfree(msg);
 }
@@ -2150,7 +2145,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool 
enabled, u32 timeout)
return result;
 }
 
-int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, u32 count,
+int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
u8 *mc_list)
 {
int result;
@@ -2160,9 +2155,9 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, 
bool enabled, u32 count,
if (IS_ERR(msg))
return PTR_ERR(msg);
 
-   msg->body.multicast_info.enabled = enabled;
-   msg->body.multicast_info.cnt = count;
-   msg->body.multicast_info.mc_list = mc_list;
+   msg->body.mc_info.enabled = enabled;
+   msg->body.mc_info.cnt = count;
+   msg->body.mc_info.mc_list = mc_list;
 
result = wilc_enqueue_work(msg);
if (result) {
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 363db0b..527ae05 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -230,7 +230,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 
*mac_addr);
 int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
  struct station_parameters *params);
 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
-int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, u32 count,
+int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
u8 *mc_list);
 int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
   u32 duration, u16 chan,
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 5b554c6..87ec048 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc100

[PATCH 02/13] staging: wilc1000: refactor wilc_wlan_set_bssid()

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Refactor code by making use of eth_zero_addr() to clear the mac address
value in wilc_wlan_set_bssid().

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c |  6 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 16 +---
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 7216890..5b554c6 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -198,7 +198,11 @@ void wilc_wlan_set_bssid(struct net_device *wilc_netdev, 
u8 *bssid, u8 mode)
 {
struct wilc_vif *vif = netdev_priv(wilc_netdev);
 
-   memcpy(vif->bssid, bssid, 6);
+   if (bssid)
+   ether_addr_copy(vif->bssid, bssid);
+   else
+   eth_zero_addr(vif->bssid);
+
vif->mode = mode;
 }
 
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index ac47dda..987e5ff 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -390,7 +390,6 @@ static void cfg_connect_result(enum conn_event 
conn_disconn_evt,
struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wl = vif->wilc;
struct host_if_drv *wfi_drv = priv->hif_drv;
-   u8 null_bssid[ETH_ALEN] = {0};
 
vif->connecting = false;
 
@@ -402,8 +401,7 @@ static void cfg_connect_result(enum conn_event 
conn_disconn_evt,
if (mac_status == WILC_MAC_STATUS_DISCONNECTED &&
conn_info->status == WLAN_STATUS_SUCCESS) {
connect_status = WLAN_STATUS_UNSPECIFIED_FAILURE;
-   wilc_wlan_set_bssid(priv->dev, null_bssid,
-   WILC_STATION_MODE);
+   wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE);
 
if (!wfi_drv->p2p_connect)
wlan_channel = INVALID_CHANNEL;
@@ -445,7 +443,7 @@ static void cfg_connect_result(enum conn_event 
conn_disconn_evt,
priv->p2p.recv_random = 0x00;
priv->p2p.is_wilc_ie = false;
eth_zero_addr(priv->associated_bss);
-   wilc_wlan_set_bssid(priv->dev, null_bssid, WILC_STATION_MODE);
+   wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE);
 
if (!wfi_drv->p2p_connect)
wlan_channel = INVALID_CHANNEL;
@@ -720,13 +718,11 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
nw_info->ch,
nw_info->join_params);
if (ret) {
-   u8 null_bssid[ETH_ALEN] = {0};
-
netdev_err(dev, "wilc_set_join_req(): Error\n");
ret = -ENOENT;
if (!wfi_drv->p2p_connect)
wlan_channel = INVALID_CHANNEL;
-   wilc_wlan_set_bssid(dev, null_bssid, WILC_STATION_MODE);
+   wilc_wlan_set_bssid(dev, NULL, WILC_STATION_MODE);
goto out_error;
}
return 0;
@@ -744,7 +740,6 @@ static int disconnect(struct wiphy *wiphy, struct 
net_device *dev,
struct wilc *wilc = vif->wilc;
struct host_if_drv *wfi_drv;
int ret;
-   u8 null_bssid[ETH_ALEN] = {0};
 
vif->connecting = false;
 
@@ -760,7 +755,7 @@ static int disconnect(struct wiphy *wiphy, struct 
net_device *dev,
wfi_drv = (struct host_if_drv *)priv->hif_drv;
if (!wfi_drv->p2p_connect)
wlan_channel = INVALID_CHANNEL;
-   wilc_wlan_set_bssid(priv->dev, null_bssid, WILC_STATION_MODE);
+   wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE);
 
priv->p2p.local_random = 0x01;
priv->p2p.recv_random = 0x00;
@@ -1805,9 +1800,8 @@ static int stop_ap(struct wiphy *wiphy, struct net_device 
*dev)
int ret;
struct wilc_priv *priv = wiphy_priv(wiphy);
struct wilc_vif *vif = netdev_priv(priv->dev);
-   u8 null_bssid[ETH_ALEN] = {0};
 
-   wilc_wlan_set_bssid(dev, null_bssid, WILC_AP_MODE);
+   wilc_wlan_set_bssid(dev, NULL, WILC_AP_MODE);
 
ret = wilc_del_beacon(vif);
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/13] staging: wilc1000: use 'struct' to pack cfg header frame in wilc_wlan_cfg_commit()

2019-01-17 Thread Ajay.Kathat
From: Ajay Singh 

Make use of 'struct' to pack cfg header in wilc_wlan_cfg_commit()
instead of byte by byte filling.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  2 +-
 drivers/staging/wilc1000/wilc_wlan.c  | 25 ++---
 drivers/staging/wilc1000/wilc_wlan.h  | 14 ++
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index c6685c0..a3400c1 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -251,7 +251,7 @@ struct wilc {
struct mutex cfg_cmd_lock;
struct wilc_cfg_frame cfg_frame;
u32 cfg_frame_offset;
-   int cfg_seq_no;
+   u8 cfg_seq_no;
 
u8 *rx_buffer;
u32 rx_buffer_offset;
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 3c5e9e0..16b6c55 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1092,24 +1092,19 @@ static int wilc_wlan_cfg_commit(struct wilc_vif *vif, 
int type,
 {
struct wilc *wilc = vif->wilc;
struct wilc_cfg_frame *cfg = &wilc->cfg_frame;
-   int total_len = wilc->cfg_frame_offset + 4 + DRIVER_HANDLER_SIZE;
-   int seq_no = wilc->cfg_seq_no % 256;
-   int driver_handler = (u32)drv_handler;
+   int t_len = wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr);
 
if (type == WILC_CFG_SET)
-   cfg->wid_header[0] = 'W';
+   cfg->hdr.cmd_type = 'W';
else
-   cfg->wid_header[0] = 'Q';
-   cfg->wid_header[1] = seq_no;
-   cfg->wid_header[2] = (u8)total_len;
-   cfg->wid_header[3] = (u8)(total_len >> 8);
-   cfg->wid_header[4] = (u8)driver_handler;
-   cfg->wid_header[5] = (u8)(driver_handler >> 8);
-   cfg->wid_header[6] = (u8)(driver_handler >> 16);
-   cfg->wid_header[7] = (u8)(driver_handler >> 24);
-   wilc->cfg_seq_no = seq_no;
-
-   if (!wilc_wlan_txq_add_cfg_pkt(vif, &cfg->wid_header[0], total_len))
+   cfg->hdr.cmd_type = 'Q';
+
+   cfg->hdr.seq_no = wilc->cfg_seq_no % 256;
+   cfg->hdr.total_len = cpu_to_le16(t_len);
+   cfg->hdr.driver_handler = cpu_to_le32(drv_handler);
+   wilc->cfg_seq_no = cfg->hdr.seq_no;
+
+   if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len))
return -1;
 
return 0;
diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
b/drivers/staging/wilc1000/wilc_wlan.h
index 2766713..c8ca13b 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -14,7 +14,6 @@
  *  Mac eth header length
  *
  /
-#define DRIVER_HANDLER_SIZE4
 #define MAX_MAC_HDR_LEN26 /* QOS_MAC_HDR_LEN */
 #define SUB_MSDU_HEADER_LENGTH 14
 #define SNAP_HDR_LEN   8
@@ -251,14 +250,21 @@ struct wilc_hif_func {
 
 #define MAX_CFG_FRAME_SIZE 1468
 
+struct wilc_cfg_cmd_hdr {
+   u8 cmd_type;
+   u8 seq_no;
+   __le16 total_len;
+   __le32 driver_handler;
+};
+
 struct wilc_cfg_frame {
-   u8 wid_header[8];
+   struct wilc_cfg_cmd_hdr hdr;
u8 frame[MAX_CFG_FRAME_SIZE];
 };
 
 struct wilc_cfg_rsp {
-   int type;
-   u32 seq_no;
+   u8 type;
+   u8 seq_no;
 };
 
 struct wilc;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/15] staging: wilc1000: use correct condition in loops for 'vif_num' count

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

The value of 'vif_num'(interface count) starts with 0, so modified the
loop conditions to execute for all interface.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 2 +-
 drivers/staging/wilc1000/linux_wlan.c | 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 3576834..fde236a 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1659,7 +1659,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv 
**hif_drv_handler)
return -ENOMEM;
 
*hif_drv_handler = hif_drv;
-   for (i = 0; i < wilc->vif_num; i++)
+   for (i = 0; i <= wilc->vif_num; i++)
if (dev == wilc->vif[i]->ndev) {
wilc->vif[i]->hif_drv = hif_drv;
hif_drv->driver_handler_id = i + 1;
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 81472d2..466a1fa 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -164,7 +164,7 @@ static struct net_device *get_if_handler(struct wilc *wilc, 
u8 *mac_header)
bssid = mac_header + 10;
bssid1 = mac_header + 4;
 
-   for (i = 0; i < wilc->vif_num; i++) {
+   for (i = 0; i <= wilc->vif_num; i++) {
if (wilc->vif[i]->mode == WILC_STATION_MODE)
if (ether_addr_equal_unaligned(bssid,
   wilc->vif[i]->bssid))
@@ -195,7 +195,7 @@ int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
u8 i = 0;
u8 ret_val = 0;
 
-   for (i = 0; i < wilc->vif_num; i++)
+   for (i = 0; i <= wilc->vif_num; i++)
if (!is_zero_ether_addr(wilc->vif[i]->bssid))
ret_val++;
 
@@ -739,7 +739,7 @@ static int wilc_mac_open(struct net_device *ndev)
return ret;
}
 
-   for (i = 0; i < wl->vif_num; i++) {
+   for (i = 0; i <= wl->vif_num; i++) {
if (ndev == wl->vif[i]->ndev) {
wilc_set_wfi_drv_handler(vif, wilc_get_vif_idx(vif),
 vif->iftype, vif->ifc_id);
@@ -941,7 +941,7 @@ void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size)
int i = 0;
struct wilc_vif *vif;
 
-   for (i = 0; i < wilc->vif_num; i++) {
+   for (i = 0; i <= wilc->vif_num; i++) {
vif = netdev_priv(wilc->vif[i]->ndev);
if (vif->monitor_flag) {
wilc_wfi_monitor_rx(wilc->monitor_dev, buff, size);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/15] staging: wilc1000: refactor code to use cookie information

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Make use of cookie information to pass to wpa_s and handle cookie value
received in the cfg80211_ops callbacks.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 72 +++
 drivers/staging/wilc1000/host_interface.h | 13 ++--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 51 
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  2 +-
 4 files changed, 53 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 4598920..c6fcf27 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -920,40 +920,22 @@ static int handle_remain_on_chan(struct wilc_vif *vif,
struct wid wid;
struct host_if_drv *hif_drv = vif->hif_drv;
 
-   if (!hif_drv->remain_on_ch_pending) {
-   hif_drv->remain_on_ch.arg = hif_remain_ch->arg;
-   hif_drv->remain_on_ch.expired = hif_remain_ch->expired;
-   hif_drv->remain_on_ch.ready = hif_remain_ch->ready;
-   hif_drv->remain_on_ch.ch = hif_remain_ch->ch;
-   hif_drv->remain_on_ch.id = hif_remain_ch->id;
-   } else {
-   hif_remain_ch->ch = hif_drv->remain_on_ch.ch;
-   }
+   if (hif_drv->usr_scan_req.scan_result)
+   return -EBUSY;
 
-   if (hif_drv->usr_scan_req.scan_result) {
-   hif_drv->remain_on_ch_pending = 1;
-   result = -EBUSY;
-   goto error;
-   }
-   if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
-   result = -EBUSY;
-   goto error;
-   }
+   if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP)
+   return -EBUSY;
 
-   if (vif->obtaining_ip || vif->connecting) {
-   result = -EBUSY;
-   goto error;
-   }
+   if (vif->obtaining_ip || vif->connecting)
+   return -EBUSY;
 
remain_on_chan_flag = true;
wid.id = WID_REMAIN_ON_CHAN;
wid.type = WID_STR;
wid.size = 2;
wid.val = kmalloc(wid.size, GFP_KERNEL);
-   if (!wid.val) {
-   result = -ENOMEM;
-   goto error;
-   }
+   if (!wid.val)
+   return -ENOMEM;
 
wid.val[0] = remain_on_chan_flag;
wid.val[1] = (s8)hif_remain_ch->ch;
@@ -961,21 +943,16 @@ static int handle_remain_on_chan(struct wilc_vif *vif,
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
  wilc_get_vif_idx(vif));
kfree(wid.val);
-   if (result != 0)
-   netdev_err(vif->ndev, "Failed to set remain on channel\n");
+   if (result)
+   return -EBUSY;
 
-error:
+   hif_drv->remain_on_ch.arg = hif_remain_ch->arg;
+   hif_drv->remain_on_ch.expired = hif_remain_ch->expired;
+   hif_drv->remain_on_ch.ch = hif_remain_ch->ch;
+   hif_drv->remain_on_ch.cookie = hif_remain_ch->cookie;
hif_drv->remain_on_ch_timer_vif = vif;
-   mod_timer(&hif_drv->remain_on_ch_timer,
- jiffies + msecs_to_jiffies(hif_remain_ch->duration));
-
-   if (hif_drv->remain_on_ch.ready)
-   hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
 
-   if (hif_drv->remain_on_ch_pending)
-   hif_drv->remain_on_ch_pending = 0;
-
-   return result;
+   return 0;
 }
 
 static void handle_listen_state_expired(struct work_struct *work)
@@ -1012,7 +989,7 @@ static void handle_listen_state_expired(struct work_struct 
*work)
 
if (hif_drv->remain_on_ch.expired) {
hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
- hif_remain_ch->id);
+ hif_remain_ch->cookie);
}
} else {
netdev_dbg(vif->ndev, "Not in listen state\n");
@@ -1036,7 +1013,7 @@ static void listen_timer_cb(struct timer_list *t)
if (IS_ERR(msg))
return;
 
-   msg->body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
+   msg->body.remain_on_ch.cookie = vif->hif_drv->remain_on_ch.cookie;
 
result = wilc_enqueue_work(msg);
if (result) {
@@ -1102,9 +1079,6 @@ static void handle_scan_complete(struct work_struct *work)
 
handle_scan_done(msg->vif, SCAN_EVENT_DONE);
 
-   if (msg->vif->hif_drv->remain_on_ch_pending)
-   handle_remain_on_chan(msg->vif,
- &msg->vif->hif_drv->remain_on_ch);
kfree(msg);
 }
 
@@ -1842,10 +1816,9 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 
*buffer, u32 length)
}
 }
 
-int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
+int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
   u32 duration, u16 chan,
-  

[PATCH 07/15] staging: wilc1000: refactor scan() cfg80211 ops callback

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor scan() cfg80211 callback function and use correct value for
valid channel number limit.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.h |  2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 55 +++
 2 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 8fa97a7..0feb63f 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -18,7 +18,7 @@ enum {
 };
 
 #define WILC_MAX_NUM_STA   9
-#define MAX_NUM_SCANNED_NETWORKS   100
+#define WILC_MAX_NUM_SCANNED_CH14
 #define WILC_MAX_NUM_PROBED_SSID   10
 
 #define TX_MIC_KEY_LEN 8
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index faffcc8..08b60ddd 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -266,42 +266,41 @@ static int scan(struct wiphy *wiphy, struct 
cfg80211_scan_request *request)
struct wilc_vif *vif = netdev_priv(priv->dev);
u32 i;
int ret = 0;
-   u8 scan_ch_list[MAX_NUM_SCANNED_NETWORKS];
+   u8 scan_ch_list[WILC_MAX_NUM_SCANNED_CH];
struct wilc_probe_ssid probe_ssid;
 
-   priv->scan_req = request;
+   if (request->n_channels > WILC_MAX_NUM_SCANNED_CH) {
+   netdev_err(priv->dev, "Requested scanned channels over\n");
+   return -EINVAL;
+   }
 
+   priv->scan_req = request;
priv->cfg_scanning = true;
-   if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) {
-   for (i = 0; i < request->n_channels; i++) {
-   u16 freq = request->channels[i]->center_freq;
-
-   scan_ch_list[i] = ieee80211_frequency_to_channel(freq);
-   }
+   for (i = 0; i < request->n_channels; i++) {
+   u16 freq = request->channels[i]->center_freq;
 
-   if (request->n_ssids >= 1) {
-   if (wilc_wfi_cfg_alloc_fill_ssid(request,
-&probe_ssid)) {
-   ret = -ENOMEM;
-   goto out;
-   }
+   scan_ch_list[i] = ieee80211_frequency_to_channel(freq);
+   }
 
-   ret = wilc_scan(vif, WILC_FW_USER_SCAN,
-   WILC_FW_ACTIVE_SCAN, scan_ch_list,
-   request->n_channels,
-   (const u8 *)request->ie,
-   request->ie_len, cfg_scan_result,
-   (void *)priv, &probe_ssid);
-   } else {
-   ret = wilc_scan(vif, WILC_FW_USER_SCAN,
-   WILC_FW_ACTIVE_SCAN, scan_ch_list,
-   request->n_channels,
-   (const u8 *)request->ie,
-   request->ie_len, cfg_scan_result,
-   (void *)priv, NULL);
+   if (request->n_ssids >= 1) {
+   if (wilc_wfi_cfg_alloc_fill_ssid(request, &probe_ssid)) {
+   ret = -ENOMEM;
+   goto out;
}
+
+   ret = wilc_scan(vif, WILC_FW_USER_SCAN,
+   WILC_FW_ACTIVE_SCAN, scan_ch_list,
+   request->n_channels,
+   (const u8 *)request->ie,
+   request->ie_len, cfg_scan_result,
+   (void *)priv, &probe_ssid);
} else {
-   netdev_err(priv->dev, "Requested scanned channels over\n");
+   ret = wilc_scan(vif, WILC_FW_USER_SCAN,
+   WILC_FW_ACTIVE_SCAN, scan_ch_list,
+   request->n_channels,
+   (const u8 *)request->ie,
+   request->ie_len, cfg_scan_result,
+   (void *)priv, NULL);
}
 
 out:
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/15] staging: wilc1000: remove unnecessary debug log messages

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Remove unnecessary debug log messages.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c | 31 ---
 1 file changed, 31 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index b0249d2..81472d2 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -19,9 +19,7 @@ static int dev_state_ev_handler(struct notifier_block *this,
struct wilc_priv *priv;
struct host_if_drv *hif_drv;
struct net_device *dev;
-   u8 *ip_addr_buf;
struct wilc_vif *vif;
-   u8 null_ip[4] = {0};
char wlan_dev_name[5] = "wlan0";
 
if (!dev_iface || !dev_iface->ifa_dev || !dev_iface->ifa_dev->dev)
@@ -56,13 +54,6 @@ static int dev_state_ev_handler(struct notifier_block *this,
if (vif->wilc->enable_ps)
wilc_set_power_mgmt(vif, 1, 0);
 
-   netdev_dbg(dev, "[%s] Up IP\n", dev_iface->ifa_label);
-
-   ip_addr_buf = (char *)&dev_iface->ifa_address;
-   netdev_dbg(dev, "IP add=%d:%d:%d:%d\n",
-  ip_addr_buf[0], ip_addr_buf[1],
-  ip_addr_buf[2], ip_addr_buf[3]);
-
break;
 
case NETDEV_DOWN:
@@ -77,13 +68,6 @@ static int dev_state_ev_handler(struct notifier_block *this,
 
wilc_resolve_disconnect_aberration(vif);
 
-   netdev_dbg(dev, "[%s] Down IP\n", dev_iface->ifa_label);
-
-   ip_addr_buf = null_ip;
-   netdev_dbg(dev, "IP add=%d:%d:%d:%d\n",
-  ip_addr_buf[0], ip_addr_buf[1],
-  ip_addr_buf[2], ip_addr_buf[3]);
-
break;
 
default:
@@ -851,9 +835,6 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct 
net_device *ndev)
struct wilc *wilc = vif->wilc;
struct tx_complete_data *tx_data = NULL;
int queue_count;
-   char *udp_buf;
-   struct iphdr *ih;
-   struct ethhdr *eth_h;
 
if (skb->dev != ndev) {
netdev_err(ndev, "Packet not destined to this device\n");
@@ -871,18 +852,6 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct 
net_device *ndev)
tx_data->size = skb->len;
tx_data->skb  = skb;
 
-   eth_h = (struct ethhdr *)(skb->data);
-   if (eth_h->h_proto == cpu_to_be16(0x8e88))
-   netdev_dbg(ndev, "EAPOL transmitted\n");
-
-   ih = (struct iphdr *)(skb->data + sizeof(struct ethhdr));
-
-   udp_buf = (char *)ih + sizeof(struct iphdr);
-   if ((udp_buf[1] == 68 && udp_buf[3] == 67) ||
-   (udp_buf[1] == 67 && udp_buf[3] == 68))
-   netdev_dbg(ndev, "DHCP Message transmitted, type:%x %x %x\n",
-  udp_buf[248], udp_buf[249], udp_buf[250]);
-
vif->netstats.tx_packets++;
vif->netstats.tx_bytes += tx_data->size;
tx_data->bssid = wilc->vif[vif->idx]->bssid;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/15] staging: wilc1000: remove redundant macros for radiotap

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Remove macro define which are already present in the included header.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_mon.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_mon.c 
b/drivers/staging/wilc1000/linux_mon.c
index 32d0c81..ce37b6f 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -21,9 +21,6 @@ struct wilc_wfi_radiotap_cb_hdr {
 static u8 srcadd[6];
 static u8 bssid[6];
 
-#define IEEE80211_RADIOTAP_F_TX_RTS0x0004  /* used rts/cts handshake */
-#define IEEE80211_RADIOTAP_F_TX_FAIL   0x0001  /* failed due to excessive*/
-
 #define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) |  \
 (1 << IEEE80211_RADIOTAP_TX_FLAGS))
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/15] staging: wilc1000: use random number for cookie instead of pointer

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Use random number to assign to cookie value.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index f719b74..98121ec 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1252,7 +1252,7 @@ static int mgmt_tx(struct wiphy *wiphy,
u32 buf_len = len + sizeof(p2p_vendor_spec) + 
sizeof(priv->p2p.local_random);
int ret = 0;
 
-   *cookie = (unsigned long)buf;
+   *cookie = prandom_u32();
priv->tx_cookie = *cookie;
mgmt = (const struct ieee80211_mgmt *)buf;
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/15] staging: wilc1000: remove conditional lock in wilc_wfi_deinit_mon_interface()

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

wilc_wfi_deinit_mon_interface() calls unregister_netdev() which
requires the rtnl lock again. Now move wilc_wfi_deinit_mon_interface()
out of wilc_mac_close(). Also remove explicit call to wilc_mac_close()
because unregister_netdev() takes care of calling wilc_mac_close().

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_mon.c  | 19 +--
 drivers/staging/wilc1000/linux_wlan.c | 11 +++
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_mon.c 
b/drivers/staging/wilc1000/linux_mon.c
index ed06834..32d0c81 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -253,19 +253,10 @@ struct net_device *wilc_wfi_init_mon_interface(struct 
wilc *wl,
 
 void wilc_wfi_deinit_mon_interface(struct wilc *wl)
 {
-   bool rollback_lock = false;
-
-   if (wl->monitor_dev) {
-   if (rtnl_is_locked()) {
-   rtnl_unlock();
-   rollback_lock = true;
-   }
-   unregister_netdev(wl->monitor_dev);
+   if (!wl->monitor_dev)
+   return;
 
-   if (rollback_lock) {
-   rtnl_lock();
-   rollback_lock = false;
-   }
-   wl->monitor_dev = NULL;
-   }
+   unregister_netdev(wl->monitor_dev);
+   free_netdev(wl->monitor_dev);
+   wl->monitor_dev = NULL;
 }
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 1362d8f..b0249d2 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -920,7 +920,6 @@ static int wilc_mac_close(struct net_device *ndev)
netdev_dbg(ndev, "Deinitializing wilc1000\n");
wl->close = 1;
wilc_wlan_deinitialize(ndev);
-   wilc_wfi_deinit_mon_interface(wl);
}
 
vif->mac_opened = 0;
@@ -1006,19 +1005,15 @@ void wilc_netdev_cleanup(struct wilc *wilc)
wilc->firmware = NULL;
}
 
-   if (wilc->vif[0]->ndev || wilc->vif[1]->ndev) {
-   for (i = 0; i < WILC_NUM_CONCURRENT_IFC; i++)
-   if (wilc->vif[i]->ndev)
-   if (wilc->vif[i]->mac_opened)
-   wilc_mac_close(wilc->vif[i]->ndev);
-
-   for (i = 0; i < WILC_NUM_CONCURRENT_IFC; i++) {
+   for (i = 0; i < WILC_NUM_CONCURRENT_IFC; i++) {
+   if (wilc->vif[i] && wilc->vif[i]->ndev) {
unregister_netdev(wilc->vif[i]->ndev);
wilc_free_wiphy(wilc->vif[i]->ndev);
free_netdev(wilc->vif[i]->ndev);
}
}
 
+   wilc_wfi_deinit_mon_interface(wilc);
flush_workqueue(wilc->hif_workqueue);
destroy_workqueue(wilc->hif_workqueue);
wilc_wlan_cfg_deinit(wilc);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/15] staging: wilc1000: remove use of 'terminated_handle' static variable

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Remove use of 'terminated_handle' variable and set the 'hif_drv' to
NULL once it's free.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index fde236a..4598920 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -130,7 +130,6 @@ struct wilc_join_bss_param {
};
 } __packed;
 
-static struct host_if_drv *terminated_handle;
 static struct mutex hif_deinit_lock;
 
 /* 'msg' should be free by the caller for syc */
@@ -1478,6 +1477,9 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int 
index, u8 mode,
int result;
struct wilc_drv_handler drv;
 
+   if (!hif_drv)
+   return -EFAULT;
+
wid.id = WID_SET_DRV_HANDLER;
wid.type = WID_STR;
wid.size = sizeof(drv);
@@ -1699,8 +1701,6 @@ int wilc_deinit(struct wilc_vif *vif)
 
mutex_lock(&hif_deinit_lock);
 
-   terminated_handle = hif_drv;
-
del_timer_sync(&hif_drv->scan_timer);
del_timer_sync(&hif_drv->connect_timer);
del_timer_sync(&vif->periodic_rssi);
@@ -1717,9 +1717,8 @@ int wilc_deinit(struct wilc_vif *vif)
hif_drv->hif_state = HOST_IF_IDLE;
 
kfree(hif_drv);
-
+   vif->hif_drv = NULL;
vif->wilc->clients_count--;
-   terminated_handle = NULL;
mutex_unlock(&hif_deinit_lock);
return result;
 }
@@ -1738,7 +1737,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 
*buffer, u32 length)
return;
hif_drv = vif->hif_drv;
 
-   if (!hif_drv || hif_drv == terminated_handle) {
+   if (!hif_drv) {
netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv);
return;
}
@@ -1784,7 +1783,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 
*buffer, u32 length)
 
hif_drv = vif->hif_drv;
 
-   if (!hif_drv || hif_drv == terminated_handle) {
+   if (!hif_drv) {
mutex_unlock(&hif_deinit_lock);
return;
}
@@ -1824,7 +1823,7 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 
*buffer, u32 length)
return;
hif_drv = vif->hif_drv;
 
-   if (!hif_drv || hif_drv == terminated_handle)
+   if (!hif_drv)
return;
 
if (hif_drv->usr_scan_req.scan_result) {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/15] staging: wilc1000: refactor linux_wlan_init_test_config()

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Refactor linux_wlan_init_test_config() to use correct endianness for wid
values and remove unnecessary code.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c   | 200 +---
 drivers/staging/wilc1000/wilc_wlan_if.h |   1 -
 2 files changed, 83 insertions(+), 118 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 466a1fa..484fe3d 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -304,204 +304,170 @@ static int wilc1000_firmware_download(struct net_device 
*dev)
return 0;
 }
 
-static int linux_wlan_init_test_config(struct net_device *dev,
-  struct wilc_vif *vif)
+static int linux_wlan_init_fw_config(struct net_device *dev,
+struct wilc_vif *vif)
 {
-   unsigned char c_val[64];
-   struct wilc *wilc = vif->wilc;
struct wilc_priv *priv;
struct host_if_drv *hif_drv;
+   u8 b;
+   u16 hw;
+   u32 w;
 
netdev_dbg(dev, "Start configuring Firmware\n");
priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
hif_drv = (struct host_if_drv *)priv->hif_drv;
netdev_dbg(dev, "Host = %p\n", hif_drv);
-   wilc_get_chipid(wilc, false);
-
-   *(int *)c_val = 1;
-
-   if (!wilc_wlan_cfg_set(vif, 1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
-   goto fail;
-
-   c_val[0] = 0;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
-   goto fail;
-
-   c_val[0] = WILC_FW_BSS_TYPE_INFRA;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0))
-   goto fail;
-
-   c_val[0] = WILC_FW_TX_RATE_AUTO;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
-   goto fail;
-
-   c_val[0] = WILC_FW_OPER_MODE_G_MIXED_11B_2;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, c_val, 1, 0,
-  0))
-   goto fail;
 
-   c_val[0] = 1;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
-   goto fail;
-
-   c_val[0] = WILC_FW_PREAMBLE_SHORT;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, c_val, 1, 0, 0))
+   w = vif->iftype;
+   cpu_to_le32s(&w);
+   if (!wilc_wlan_cfg_set(vif, 1, WID_SET_OPERATION_MODE, (u8 *)&w, 4,
+  0, 0))
goto fail;
 
-   c_val[0] = WILC_FW_11N_PROT_AUTO;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
+   b = WILC_FW_BSS_TYPE_INFRA;
+   if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, &b, 1, 0, 0))
goto fail;
 
-   c_val[0] = WILC_FW_ACTIVE_SCAN;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, c_val, 1, 0, 0))
+   b = WILC_FW_TX_RATE_AUTO;
+   if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, &b, 1, 0, 0))
goto fail;
 
-   c_val[0] = WILC_FW_SITE_SURVEY_OFF;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, c_val, 1, 0, 0))
+   b = WILC_FW_OPER_MODE_G_MIXED_11B_2;
+   if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, &b, 1, 0, 0))
goto fail;
 
-   *((int *)c_val) = 0x;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_RTS_THRESHOLD, c_val, 2, 0, 0))
+   b = WILC_FW_PREAMBLE_SHORT;
+   if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, &b, 1, 0, 0))
goto fail;
 
-   *((int *)c_val) = 2346;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0))
+   b = WILC_FW_11N_PROT_AUTO;
+   if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, &b, 1, 0, 0))
goto fail;
 
-   c_val[0] = 0;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_BCAST_SSID, c_val, 1, 0, 0))
+   b = WILC_FW_ACTIVE_SCAN;
+   if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, &b, 1, 0, 0))
goto fail;
 
-   c_val[0] = 1;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, c_val, 1, 0, 0))
+   b = WILC_FW_SITE_SURVEY_OFF;
+   if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, &b, 1, 0, 0))
goto fail;
 
-   c_val[0] = WILC_FW_NO_POWERSAVE;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
+   hw = 0x;
+   cpu_to_le16s(&hw);
+   if (!wilc_wlan_cfg_set(vif, 0, WID_RTS_THRESHOLD, (u8 *)&hw, 2, 0, 0))
goto fail;
 
-   c_val[0] = WILC_FW_SEC_NO;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0))
+   hw = 2346;
+   cpu_to_le16s(&hw);
+   if (!wilc_wlan_cfg_set(vif, 0, WID_FRAG_THRESHOLD, (u8 *)&hw, 2, 0, 0))
goto fail;
 
-   c_val[0] = WILC_FW_AUTH_OPEN_SYSTEM;
-   if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, c_val, 1, 0, 0))
+   b = 0;
+   if (!wilc_wlan_cfg_set(vif, 0, WID_BCAST_SSID, &b, 1, 0, 0))
goto fail;
 

[PATCH 01/15] staging: wilc1000: avoid the use of 'wilc_wfi_mon' static variable

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Avoid use of static variable for monitor net_device and move it inside
wilc structure.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_mon.c  | 52 +++
 drivers/staging/wilc1000/linux_wlan.c |  4 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  3 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.h |  7 +--
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  1 +
 5 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_mon.c 
b/drivers/staging/wilc1000/linux_mon.c
index a634468..ed06834 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -18,8 +18,6 @@ struct wilc_wfi_radiotap_cb_hdr {
u16 tx_flags;
 } __packed;
 
-static struct net_device *wilc_wfi_mon; /* global monitor netdev */
-
 static u8 srcadd[6];
 static u8 bssid[6];
 
@@ -29,17 +27,17 @@ static u8 bssid[6];
 #define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) |  \
 (1 << IEEE80211_RADIOTAP_TX_FLAGS))
 
-void wilc_wfi_monitor_rx(u8 *buff, u32 size)
+void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size)
 {
u32 header, pkt_offset;
struct sk_buff *skb = NULL;
struct wilc_wfi_radiotap_hdr *hdr;
struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
 
-   if (!wilc_wfi_mon)
+   if (!mon_dev)
return;
 
-   if (!netif_running(wilc_wfi_mon))
+   if (!netif_running(mon_dev))
return;
 
/* Get WILC header */
@@ -94,7 +92,7 @@ void wilc_wfi_monitor_rx(u8 *buff, u32 size)
hdr->rate = 5;
}
 
-   skb->dev = wilc_wfi_mon;
+   skb->dev = mon_dev;
skb_reset_mac_header(skb);
skb->ip_summed = CHECKSUM_UNNECESSARY;
skb->pkt_type = PACKET_OTHERHOST;
@@ -156,12 +154,10 @@ static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
struct sk_buff *skb2;
struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
 
-   if (!wilc_wfi_mon)
-   return -EFAULT;
-
-   mon_priv = netdev_priv(wilc_wfi_mon);
+   mon_priv = netdev_priv(dev);
if (!mon_priv)
return -EFAULT;
+
rtap_len = ieee80211_get_radiotap_len(skb->data);
if (skb->len < rtap_len)
return -1;
@@ -187,7 +183,7 @@ static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
cb_hdr->rate = 5;
cb_hdr->tx_flags = 0x0004;
 
-   skb2->dev = wilc_wfi_mon;
+   skb2->dev = dev;
skb_reset_mac_header(skb2);
skb2->ip_summed = CHECKSUM_UNNECESSARY;
skb2->pkt_type = PACKET_OTHERHOST;
@@ -223,51 +219,53 @@ static const struct net_device_ops wilc_wfi_netdev_ops = {
 
 };
 
-struct net_device *wilc_wfi_init_mon_interface(const char *name,
+struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
+  const char *name,
   struct net_device *real_dev)
 {
struct wilc_wfi_mon_priv *priv;
 
/*If monitor interface is already initialized, return it*/
-   if (wilc_wfi_mon)
-   return wilc_wfi_mon;
+   if (wl->monitor_dev)
+   return wl->monitor_dev;
 
-   wilc_wfi_mon = alloc_etherdev(sizeof(struct wilc_wfi_mon_priv));
-   if (!wilc_wfi_mon)
+   wl->monitor_dev = alloc_etherdev(sizeof(struct wilc_wfi_mon_priv));
+   if (!wl->monitor_dev)
return NULL;
-   wilc_wfi_mon->type = ARPHRD_IEEE80211_RADIOTAP;
-   strncpy(wilc_wfi_mon->name, name, IFNAMSIZ);
-   wilc_wfi_mon->name[IFNAMSIZ - 1] = 0;
-   wilc_wfi_mon->netdev_ops = &wilc_wfi_netdev_ops;
 
-   if (register_netdevice(wilc_wfi_mon)) {
+   wl->monitor_dev->type = ARPHRD_IEEE80211_RADIOTAP;
+   strncpy(wl->monitor_dev->name, name, IFNAMSIZ);
+   wl->monitor_dev->name[IFNAMSIZ - 1] = 0;
+   wl->monitor_dev->netdev_ops = &wilc_wfi_netdev_ops;
+
+   if (register_netdevice(wl->monitor_dev)) {
netdev_err(real_dev, "register_netdevice failed\n");
return NULL;
}
-   priv = netdev_priv(wilc_wfi_mon);
+   priv = netdev_priv(wl->monitor_dev);
if (!priv)
return NULL;
 
priv->real_ndev = real_dev;
 
-   return wilc_wfi_mon;
+   return wl->monitor_dev;
 }
 
-void wilc_wfi_deinit_mon_interface(void)
+void wilc_wfi_deinit_mon_interface(struct wilc *wl)
 {
bool rollback_lock = false;
 
-   if (wilc_wfi_mon) {
+   if (wl->monitor_dev) {
if (rtnl_is_locked()) {
rtnl_unlock();
rollback_lock = true;
}
-   unregister_netdev(wilc_wfi_mon);
+   unregister_netdev(wl->monitor_dev);
 
if (rollback_lock) {
rtnl_lock();
  

[PATCH 14/15] staging: wilc1000: add check before performing operation on net_device

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Before calling an operation on net_device check if that interface is
available.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index dcd5861..bafb454 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -159,9 +159,11 @@ static int linux_wlan_txq_task(void *vp)
do {
ret = wilc_wlan_handle_txq(dev, &txq_count);
if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) {
-   if (netif_queue_stopped(wl->vif[0]->ndev))
+   if (wl->vif[0]->mac_opened &&
+   netif_queue_stopped(wl->vif[0]->ndev))
netif_wake_queue(wl->vif[0]->ndev);
-   if (netif_queue_stopped(wl->vif[1]->ndev))
+   if (wl->vif[1]->mac_opened &&
+   netif_queue_stopped(wl->vif[1]->ndev))
netif_wake_queue(wl->vif[1]->ndev);
}
} while (ret == -ENOBUFS && !wl->close);
@@ -761,8 +763,10 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct 
net_device *ndev)
linux_wlan_tx_complete);
 
if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) {
-   netif_stop_queue(wilc->vif[0]->ndev);
-   netif_stop_queue(wilc->vif[1]->ndev);
+   if (wilc->vif[0]->mac_opened)
+   netif_stop_queue(wilc->vif[0]->ndev);
+   if (wilc->vif[1]->mac_opened)
+   netif_stop_queue(wilc->vif[1]->ndev);
}
 
return 0;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/15] staging: wilc1000: remove unused struct 'add_sta_param'

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Remove 'add_sta_param' structure as its not used now.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.h | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 994e641..790f83e 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -170,17 +170,6 @@ struct host_if_drv {
u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
 };
 
-struct add_sta_param {
-   u8 bssid[ETH_ALEN];
-   u16 aid;
-   u8 rates_len;
-   const u8 *rates;
-   bool ht_supported;
-   struct ieee80211_ht_cap ht_capa;
-   u16 flags_mask;
-   u16 flags_set;
-};
-
 struct wilc_vif;
 int wilc_remove_wep_key(struct wilc_vif *vif, u8 index);
 int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/15] staging: wilc1000: avoid use of interface names for validation

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Avoid use of interface name i.e 'wlan0' & 'p2p0' to check the interface
type in dev_state_ev_handler(). Now making use of netdev_ops and iface
type to know interface. Reorder the functions to avoid the forward
declaration after the above changes

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c | 144 +-
 1 file changed, 70 insertions(+), 74 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 484fe3d..dcd5861 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -12,71 +12,6 @@
 
 #include "wilc_wfi_cfgoperations.h"
 
-static int dev_state_ev_handler(struct notifier_block *this,
-   unsigned long event, void *ptr)
-{
-   struct in_ifaddr *dev_iface = ptr;
-   struct wilc_priv *priv;
-   struct host_if_drv *hif_drv;
-   struct net_device *dev;
-   struct wilc_vif *vif;
-   char wlan_dev_name[5] = "wlan0";
-
-   if (!dev_iface || !dev_iface->ifa_dev || !dev_iface->ifa_dev->dev)
-   return NOTIFY_DONE;
-
-   if (memcmp(dev_iface->ifa_label, "wlan0", 5) &&
-   memcmp(dev_iface->ifa_label, "p2p0", 4))
-   return NOTIFY_DONE;
-
-   dev  = (struct net_device *)dev_iface->ifa_dev->dev;
-   if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy)
-   return NOTIFY_DONE;
-
-   priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
-   if (!priv)
-   return NOTIFY_DONE;
-
-   hif_drv = (struct host_if_drv *)priv->hif_drv;
-   vif = netdev_priv(dev);
-   if (!vif || !hif_drv)
-   return NOTIFY_DONE;
-
-   switch (event) {
-   case NETDEV_UP:
-   if (vif->iftype == WILC_STATION_MODE ||
-   vif->iftype == WILC_CLIENT_MODE) {
-   hif_drv->ifc_up = 1;
-   vif->obtaining_ip = false;
-   del_timer(&vif->during_ip_timer);
-   }
-
-   if (vif->wilc->enable_ps)
-   wilc_set_power_mgmt(vif, 1, 0);
-
-   break;
-
-   case NETDEV_DOWN:
-   if (vif->iftype == WILC_STATION_MODE ||
-   vif->iftype == WILC_CLIENT_MODE) {
-   hif_drv->ifc_up = 0;
-   vif->obtaining_ip = false;
-   }
-
-   if (memcmp(dev_iface->ifa_label, wlan_dev_name, 5) == 0)
-   wilc_set_power_mgmt(vif, 0, 0);
-
-   wilc_resolve_disconnect_aberration(vif);
-
-   break;
-
-   default:
-   break;
-   }
-
-   return NOTIFY_DONE;
-}
-
 static irqreturn_t isr_uh_routine(int irq, void *user_data)
 {
struct net_device *dev = user_data;
@@ -921,6 +856,76 @@ void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 
size)
wilc_wfi_p2p_rx(wilc->vif[1]->ndev, buff, size);
 }
 
+static const struct net_device_ops wilc_netdev_ops = {
+   .ndo_init = mac_init_fn,
+   .ndo_open = wilc_mac_open,
+   .ndo_stop = wilc_mac_close,
+   .ndo_start_xmit = wilc_mac_xmit,
+   .ndo_get_stats = mac_stats,
+   .ndo_set_rx_mode  = wilc_set_multicast_list,
+};
+
+static int dev_state_ev_handler(struct notifier_block *this,
+   unsigned long event, void *ptr)
+{
+   struct in_ifaddr *dev_iface = ptr;
+   struct wilc_priv *priv;
+   struct host_if_drv *hif_drv;
+   struct net_device *dev;
+   struct wilc_vif *vif;
+
+   if (!dev_iface || !dev_iface->ifa_dev || !dev_iface->ifa_dev->dev)
+   return NOTIFY_DONE;
+
+   dev  = (struct net_device *)dev_iface->ifa_dev->dev;
+   if (dev->netdev_ops != &wilc_netdev_ops)
+   return NOTIFY_DONE;
+
+   if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy)
+   return NOTIFY_DONE;
+
+   priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
+   if (!priv)
+   return NOTIFY_DONE;
+
+   hif_drv = (struct host_if_drv *)priv->hif_drv;
+   vif = netdev_priv(dev);
+   if (!vif || !hif_drv)
+   return NOTIFY_DONE;
+
+   switch (event) {
+   case NETDEV_UP:
+   if (vif->iftype == WILC_STATION_MODE ||
+   vif->iftype == WILC_CLIENT_MODE) {
+   hif_drv->ifc_up = 1;
+   vif->obtaining_ip = false;
+   del_timer(&vif->during_ip_timer);
+   }
+
+   if (vif->wilc->enable_ps)
+   wilc_set_power_mgmt(vif, 1, 0);
+
+   break;
+
+   case NETDEV_DOWN:
+   if (vif->iftype == WILC_STATION_MODE ||
+   vif->iftype == WILC_CLIENT_MODE) {
+   hif_drv->ifc_up = 0;
+   vif->obtaining_ip = false;
+   wilc_set_power_mgmt(vif, 0, 0);
+   

[PATCH 00/15] staging: wilc1000: cleanup patches & handle review comments

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

This series contains cleanup patches and modification to handle few mainline
review comments mentioned below:
 - avoid static variable for monitor net_device.
 - remove conditional locking in wilc_wfi_deinit_mon_interface().
 - avoid use of interface name('wlan0' & 'p2p0') string for validation.
 - use cookie information in roc related callback.

Ajay Singh (15):
  staging: wilc1000: avoid the use of 'wilc_wfi_mon' static variable
  staging: wilc1000: remove conditional lock in
wilc_wfi_deinit_mon_interface()
  staging: wilc1000: remove redundant macros for radiotap
  staging: wilc1000: remove unnecessary debug log messages
  staging: wilc1000: rename timeout related macros
  staging: wilc1000: make use of iface type to identify p2p interface
  staging: wilc1000: refactor scan() cfg80211 ops callback
  staging: wilc1000: use correct condition in loops for 'vif_num' count
  staging: wilc1000: remove use of 'terminated_handle' static variable
  staging: wilc1000: refactor linux_wlan_init_test_config()
  staging: wilc1000: refactor code to use cookie information
  staging: wilc1000: use random number for cookie instead of pointer
  staging: wilc1000: avoid use of interface names for validation
  staging: wilc1000: add check before performing operation on net_device
  staging: wilc1000: remove unused struct 'add_sta_param'

 drivers/staging/wilc1000/host_interface.c |  97 ++---
 drivers/staging/wilc1000/host_interface.h |  27 +-
 drivers/staging/wilc1000/linux_mon.c  |  68 ++--
 drivers/staging/wilc1000/linux_wlan.c | 408 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 134 ---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.h |   7 +-
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   3 +-
 drivers/staging/wilc1000/wilc_wlan.c  |   4 +-
 drivers/staging/wilc1000/wilc_wlan.h  |   2 +-
 drivers/staging/wilc1000/wilc_wlan_if.h   |   1 -
 10 files changed, 308 insertions(+), 443 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/15] staging: wilc1000: rename timeout related macros

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Rename timeout related macros to have their unit clear from their name.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 8 
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ++--
 drivers/staging/wilc1000/wilc_wlan.c  | 4 ++--
 drivers/staging/wilc1000/wilc_wlan.h  | 2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index e958f9b..3576834 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -6,8 +6,8 @@
 
 #include "wilc_wfi_netdevice.h"
 
-#define HOST_IF_SCAN_TIMEOUT4000
-#define HOST_IF_CONNECT_TIMEOUT 9500
+#define WILC_HIF_SCAN_TIMEOUT_MS4000
+#define WILC_HIF_CONNECT_TIMEOUT_MS 9500
 
 #define FALSE_FRMWR_CHANNEL100
 
@@ -327,7 +327,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 
scan_type,
hif_drv->usr_scan_req.arg = user_arg;
hif_drv->scan_timer_vif = vif;
mod_timer(&hif_drv->scan_timer,
- jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
+ jiffies + msecs_to_jiffies(WILC_HIF_SCAN_TIMEOUT_MS));
 
 error:
if (search) {
@@ -1442,7 +1442,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, 
const u8 *ies,
 
hif_drv->connect_timer_vif = vif;
mod_timer(&hif_drv->connect_timer,
- jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
+ jiffies + msecs_to_jiffies(WILC_HIF_CONNECT_TIMEOUT_MS));
 
return 0;
 
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index cd3df42..95230d7 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -72,7 +72,7 @@ static u8 curr_channel;
 static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09};
 static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
 
-#define DURING_IP_TIME_OUT 15000
+#define WILC_IP_TIMEOUT_MS 15000
 
 static void clear_during_ip(struct timer_list *t)
 {
@@ -1489,7 +1489,7 @@ static int change_virtual_intf(struct wiphy *wiphy, 
struct net_device *dev,
case NL80211_IFTYPE_P2P_GO:
vif->obtaining_ip = true;
mod_timer(&vif->during_ip_timer,
- jiffies + msecs_to_jiffies(DURING_IP_TIME_OUT));
+ jiffies + msecs_to_jiffies(WILC_IP_TIMEOUT_MS));
wilc_set_operation_mode(vif, WILC_AP_MODE);
dev->ieee80211_ptr->iftype = type;
priv->wdev->iftype = type;
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 58bcdc1..7a757c9 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1141,7 +1141,7 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, 
u16 wid, u8 *buffer,
ret_size = 0;
 
if (!wait_for_completion_timeout(&wilc->cfg_event,
-msecs_to_jiffies(CFG_PKTS_TIMEOUT))) {
+WILC_CFG_PKTS_TIMEOUT)) {
netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__);
ret_size = 0;
}
@@ -1179,7 +1179,7 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, 
u16 wid, int commit,
ret_size = 0;
 
if (!wait_for_completion_timeout(&wilc->cfg_event,
-msecs_to_jiffies(CFG_PKTS_TIMEOUT))) {
+WILC_CFG_PKTS_TIMEOUT)) {
netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__);
ret_size = 0;
}
diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
b/drivers/staging/wilc1000/wilc_wlan.h
index 3880452..1d61e20 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -196,7 +196,7 @@
 #define ENABLE_RX_VMM  (SEL_VMM_TBL1 | EN_VMM)
 #define ENABLE_TX_VMM  (SEL_VMM_TBL0 | EN_VMM)
 /*time for expiring the completion of cfg packets*/
-#define CFG_PKTS_TIMEOUT   2000
+#define WILC_CFG_PKTS_TIMEOUT  msecs_to_jiffies(2000)
 
 #define IS_MANAGMEMENT 0x100
 #define IS_MANAGMEMENT_CALLBACK0x080
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/15] staging: wilc1000: make use of iface type to identify p2p interface

2019-02-02 Thread Ajay.Kathat
From: Ajay Singh 

Remove SSID string compare instead use interface type check for p2p
client interface.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.h |  1 -
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 19 ++-
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 7f3fc4c..8fa97a7 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -153,7 +153,6 @@ struct host_if_drv {
struct remain_ch remain_on_ch;
u8 remain_on_ch_pending;
u64 p2p_timeout;
-   u8 p2p_connect;
 
enum host_if_state hif_state;
 
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 95230d7..faffcc8 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -159,7 +159,7 @@ static void cfg_connect_result(enum conn_event 
conn_disconn_evt, u8 mac_status,
connect_status = WLAN_STATUS_UNSPECIFIED_FAILURE;
wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE);
 
-   if (!wfi_drv->p2p_connect)
+   if (vif->iftype != WILC_CLIENT_MODE)
wlan_channel = INVALID_CHANNEL;
 
netdev_err(dev, "Unspecified failure\n");
@@ -185,7 +185,7 @@ static void cfg_connect_result(enum conn_event 
conn_disconn_evt, u8 mac_status,
eth_zero_addr(priv->associated_bss);
wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE);
 
-   if (!wfi_drv->p2p_connect)
+   if (vif->iftype != WILC_CLIENT_MODE)
wlan_channel = INVALID_CHANNEL;
 
if (wfi_drv->ifc_up && dev == wl->vif[1]->ndev)
@@ -329,11 +329,6 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
 
vif->connecting = true;
 
-   if (!(strncmp(sme->ssid, "DIRECT-", 7)))
-   wfi_drv->p2p_connect = 1;
-   else
-   wfi_drv->p2p_connect = 0;
-
memset(priv->wep_key, 0, sizeof(priv->wep_key));
memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len));
 
@@ -436,7 +431,7 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
 
curr_channel = 
ieee80211_frequency_to_channel(bss->channel->center_freq);
 
-   if (!wfi_drv->p2p_connect)
+   if (vif->iftype != WILC_CLIENT_MODE)
wlan_channel = curr_channel;
 
wilc_wlan_set_bssid(dev, bss->bssid, WILC_STATION_MODE);
@@ -452,7 +447,7 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
if (ret) {
netdev_err(dev, "wilc_set_join_req(): Error\n");
ret = -ENOENT;
-   if (!wfi_drv->p2p_connect)
+   if (vif->iftype != WILC_CLIENT_MODE)
wlan_channel = INVALID_CHANNEL;
wilc_wlan_set_bssid(dev, NULL, WILC_STATION_MODE);
wfi_drv->conn_info.conn_result = NULL;
@@ -477,7 +472,6 @@ static int disconnect(struct wiphy *wiphy, struct 
net_device *dev,
struct wilc_priv *priv = wiphy_priv(wiphy);
struct wilc_vif *vif = netdev_priv(priv->dev);
struct wilc *wilc = vif->wilc;
-   struct host_if_drv *wfi_drv;
int ret;
 
vif->connecting = false;
@@ -491,15 +485,14 @@ static int disconnect(struct wiphy *wiphy, struct 
net_device *dev,
return 0;
}
 
-   wfi_drv = (struct host_if_drv *)priv->hif_drv;
-   if (!wfi_drv->p2p_connect)
+   if (vif->iftype != WILC_CLIENT_MODE)
wlan_channel = INVALID_CHANNEL;
wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE);
 
priv->p2p.local_random = 0x01;
priv->p2p.recv_random = 0x00;
priv->p2p.is_wilc_ie = false;
-   wfi_drv->p2p_timeout = 0;
+   priv->hif_drv->p2p_timeout = 0;
 
ret = wilc_disconnect(vif);
if (ret != 0) {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 08/15] staging: wilc1000: use correct condition in loops for 'vif_num' count

2019-02-04 Thread Ajay.Kathat



On 2/4/2019 1:43 PM, Dan Carpenter wrote:
> On Sat, Feb 02, 2019 at 07:17:13PM +, ajay.kat...@microchip.com wrote:
>> From: Ajay Singh 
>>
>> The value of 'vif_num'(interface count) starts with 0, so modified the
>> loop conditions to execute for all interface.
>>
>> Signed-off-by: Ajay Singh 
> 
> The right thing to do is to change ->vif_num = i + 1 in
> wilc_netdev_init().  That's how it was originally.  Please, add a
> Fixes tag.
> 
> Fixes: 735bb39ca3be ("staging: wilc1000: simplify vif[i]->ndev accesses")
> 

Thanks. Sure, I will add Fixes tag and resubmit the changes.

Can other patches from the series be applied excluding this or should I
resubmit the complete series?
Please suggest.

Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 08/15] staging: wilc1000: use correct condition in loops for 'vif_num' count

2019-02-04 Thread Ajay.Kathat
Hi Greg,

On 2/4/2019 5:09 PM, Greg KH wrote:
> On Mon, Feb 04, 2019 at 12:47:23PM +0300, Dan Carpenter wrote:
>> On Mon, Feb 04, 2019 at 09:42:36AM +, ajay.kat...@microchip.com wrote:
>>>
>>>
>>> On 2/4/2019 1:43 PM, Dan Carpenter wrote:
 On Sat, Feb 02, 2019 at 07:17:13PM +, ajay.kat...@microchip.com wrote:
> From: Ajay Singh 
>
> The value of 'vif_num'(interface count) starts with 0, so modified the
> loop conditions to execute for all interface.
>
> Signed-off-by: Ajay Singh 

 The right thing to do is to change ->vif_num = i + 1 in
 wilc_netdev_init().  That's how it was originally.  Please, add a
 Fixes tag.

 Fixes: 735bb39ca3be ("staging: wilc1000: simplify vif[i]->ndev accesses")

>>>
>>> Thanks. Sure, I will add Fixes tag and resubmit the changes.
>>>
>>> Can other patches from the series be applied excluding this or should I
>>> resubmit the complete series?
>>> Please suggest.
>>
>> I don't have an opinion on that.  I guess if you just resend them all,
>> that's the easiest for Greg.
> 
> I took the first 7 patches here, so just a respin of the remaining ones
> would be fine.
> 

Thanks alot.
This patch will take some time for modification. As remaining patches
are not dependent on this. I will resend them.

Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 01/15] staging: wilc1000: avoid the use of 'wilc_wfi_mon' static variable

2019-02-04 Thread Ajay.Kathat
Hi Kalle,

On 2/4/2019 7:08 PM, Kalle Valo wrote:
>  writes:
> 
>> From: Ajay Singh 
>>
>> Avoid use of static variable for monitor net_device and move it inside
>> wilc structure.
>>
>> Signed-off-by: Ajay Singh 
> 
> [...]
> 
>> --- a/drivers/staging/wilc1000/linux_mon.c
>> +++ b/drivers/staging/wilc1000/linux_mon.c
>> @@ -18,8 +18,6 @@ struct wilc_wfi_radiotap_cb_hdr {
>>  u16 tx_flags;
>>  } __packed;
>>  
>> -static struct net_device *wilc_wfi_mon; /* global monitor netdev */
>> -
>>  static u8 srcadd[6];
>>  static u8 bssid[6];
> 
> I hope you are working on moving srcadd and bssid as well (at some
> point).
> 

Yes, I will take care of this before submitting the driver for another
mainline review.

Regards,
Ajay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/12] staging: wilc1000: remove use of 'terminated_handle' static variable

2019-02-04 Thread Ajay.Kathat
From: Ajay Singh 

Remove use of 'terminated_handle' variable and set the 'hif_drv' to
NULL once it's free.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 3576834..97bf747 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -130,7 +130,6 @@ struct wilc_join_bss_param {
};
 } __packed;
 
-static struct host_if_drv *terminated_handle;
 static struct mutex hif_deinit_lock;
 
 /* 'msg' should be free by the caller for syc */
@@ -1478,6 +1477,9 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int 
index, u8 mode,
int result;
struct wilc_drv_handler drv;
 
+   if (!hif_drv)
+   return -EFAULT;
+
wid.id = WID_SET_DRV_HANDLER;
wid.type = WID_STR;
wid.size = sizeof(drv);
@@ -1699,8 +1701,6 @@ int wilc_deinit(struct wilc_vif *vif)
 
mutex_lock(&hif_deinit_lock);
 
-   terminated_handle = hif_drv;
-
del_timer_sync(&hif_drv->scan_timer);
del_timer_sync(&hif_drv->connect_timer);
del_timer_sync(&vif->periodic_rssi);
@@ -1717,9 +1717,8 @@ int wilc_deinit(struct wilc_vif *vif)
hif_drv->hif_state = HOST_IF_IDLE;
 
kfree(hif_drv);
-
+   vif->hif_drv = NULL;
vif->wilc->clients_count--;
-   terminated_handle = NULL;
mutex_unlock(&hif_deinit_lock);
return result;
 }
@@ -1738,7 +1737,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 
*buffer, u32 length)
return;
hif_drv = vif->hif_drv;
 
-   if (!hif_drv || hif_drv == terminated_handle) {
+   if (!hif_drv) {
netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv);
return;
}
@@ -1784,7 +1783,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 
*buffer, u32 length)
 
hif_drv = vif->hif_drv;
 
-   if (!hif_drv || hif_drv == terminated_handle) {
+   if (!hif_drv) {
mutex_unlock(&hif_deinit_lock);
return;
}
@@ -1824,7 +1823,7 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 
*buffer, u32 length)
return;
hif_drv = vif->hif_drv;
 
-   if (!hif_drv || hif_drv == terminated_handle)
+   if (!hif_drv)
return;
 
if (hif_drv->usr_scan_req.scan_result) {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/12] staging: wilc1000: avoid use of static variable in linux_mon.c

2019-02-04 Thread Ajay.Kathat
From: Ajay Singh 

Define local variable for 'srcadd' & 'bssid' static variables and use
ether_addr_copy() to copy value into them.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_mon.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_mon.c 
b/drivers/staging/wilc1000/linux_mon.c
index ce37b6f..9fe19a3 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -18,9 +18,6 @@ struct wilc_wfi_radiotap_cb_hdr {
u16 tx_flags;
 } __packed;
 
-static u8 srcadd[6];
-static u8 bssid[6];
-
 #define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) |  \
 (1 << IEEE80211_RADIOTAP_TX_FLAGS))
 
@@ -150,6 +147,8 @@ static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
struct wilc_wfi_mon_priv  *mon_priv;
struct sk_buff *skb2;
struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+   u8 srcadd[ETH_ALEN];
+   u8 bssid[ETH_ALEN];
 
mon_priv = netdev_priv(dev);
if (!mon_priv)
@@ -193,8 +192,8 @@ static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
}
skb->dev = mon_priv->real_ndev;
 
-   memcpy(srcadd, &skb->data[10], 6);
-   memcpy(bssid, &skb->data[16], 6);
+   ether_addr_copy(srcadd, &skb->data[10]);
+   ether_addr_copy(bssid, &skb->data[16]);
/*
 * Identify if data or mgmt packet, if source address and bssid
 * fields are equal send it to mgmt frames handler
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/12] staging: wilc1000: define p2p related static variable as constants

2019-02-04 Thread Ajay.Kathat
From: Ajay Singh 

Add constant qualifer for 'p2p_vendor_spec' & 'p2p_oui' static
variable because they are treated like constant values.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index dd1fe3f..8fb4bd4 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -67,8 +67,8 @@ struct p2p_mgmt_data {
u8 *buff;
 };
 
-static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09};
-static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
+static const u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09};
+static const u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
 
 #define WILC_IP_TIMEOUT_MS 15000
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/12] staging: wilc1000: add check before performing operation on net_device

2019-02-04 Thread Ajay.Kathat
From: Ajay Singh 

Before calling an operation on net_device check if that interface is
available.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 56272b3..f096f9e 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -159,9 +159,11 @@ static int linux_wlan_txq_task(void *vp)
do {
ret = wilc_wlan_handle_txq(dev, &txq_count);
if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) {
-   if (netif_queue_stopped(wl->vif[0]->ndev))
+   if (wl->vif[0]->mac_opened &&
+   netif_queue_stopped(wl->vif[0]->ndev))
netif_wake_queue(wl->vif[0]->ndev);
-   if (netif_queue_stopped(wl->vif[1]->ndev))
+   if (wl->vif[1]->mac_opened &&
+   netif_queue_stopped(wl->vif[1]->ndev))
netif_wake_queue(wl->vif[1]->ndev);
}
} while (ret == -ENOBUFS && !wl->close);
@@ -761,8 +763,10 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct 
net_device *ndev)
linux_wlan_tx_complete);
 
if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) {
-   netif_stop_queue(wilc->vif[0]->ndev);
-   netif_stop_queue(wilc->vif[1]->ndev);
+   if (wilc->vif[0]->mac_opened)
+   netif_stop_queue(wilc->vif[0]->ndev);
+   if (wilc->vif[1]->mac_opened)
+   netif_stop_queue(wilc->vif[1]->ndev);
}
 
return 0;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/12] staging: wilc1000: avoid use of 'hif_deinit_lock' static variable

2019-02-04 Thread Ajay.Kathat
From: Ajay Singh 

Avoid use of static variable 'hif_deinit_lock' and move it as part of
wilc struct.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 20 +---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  2 ++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 115b6f25..0fb6ca3 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -130,8 +130,6 @@ struct wilc_join_bss_param {
};
 } __packed;
 
-static struct mutex hif_deinit_lock;
-
 /* 'msg' should be free by the caller for syc */
 static struct host_if_msg*
 wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *),
@@ -1645,7 +1643,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv 
**hif_drv_handler)
vif->obtaining_ip = false;
 
if (wilc->clients_count == 0)
-   mutex_init(&hif_deinit_lock);
+   mutex_init(&wilc->deinit_lock);
 
timer_setup(&vif->periodic_rssi, get_periodic_rssi, 0);
mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000));
@@ -1673,7 +1671,7 @@ int wilc_deinit(struct wilc_vif *vif)
return -EFAULT;
}
 
-   mutex_lock(&hif_deinit_lock);
+   mutex_lock(&vif->wilc->deinit_lock);
 
del_timer_sync(&hif_drv->scan_timer);
del_timer_sync(&hif_drv->connect_timer);
@@ -1693,7 +1691,7 @@ int wilc_deinit(struct wilc_vif *vif)
kfree(hif_drv);
vif->hif_drv = NULL;
vif->wilc->clients_count--;
-   mutex_unlock(&hif_deinit_lock);
+   mutex_unlock(&vif->wilc->deinit_lock);
return result;
 }
 
@@ -1746,31 +1744,31 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, 
u8 *buffer, u32 length)
struct host_if_drv *hif_drv;
struct wilc_vif *vif;
 
-   mutex_lock(&hif_deinit_lock);
+   mutex_lock(&wilc->deinit_lock);
 
id = get_unaligned_le32(&buffer[length - 4]);
vif = wilc_get_vif_from_idx(wilc, id);
if (!vif) {
-   mutex_unlock(&hif_deinit_lock);
+   mutex_unlock(&wilc->deinit_lock);
return;
}
 
hif_drv = vif->hif_drv;
 
if (!hif_drv) {
-   mutex_unlock(&hif_deinit_lock);
+   mutex_unlock(&wilc->deinit_lock);
return;
}
 
if (!hif_drv->conn_info.conn_result) {
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
-   mutex_unlock(&hif_deinit_lock);
+   mutex_unlock(&wilc->deinit_lock);
return;
}
 
msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info, false);
if (IS_ERR(msg)) {
-   mutex_unlock(&hif_deinit_lock);
+   mutex_unlock(&wilc->deinit_lock);
return;
}
 
@@ -1781,7 +1779,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 
*buffer, u32 length)
kfree(msg);
}
 
-   mutex_unlock(&hif_deinit_lock);
+   mutex_unlock(&wilc->deinit_lock);
 }
 
 void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length)
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index a06b0c0..3a78ffd 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -271,6 +271,8 @@ struct wilc {
struct wilc_cfg cfg;
void *bus_data;
struct net_device *monitor_dev;
+   /* deinit lock */
+   struct mutex deinit_lock;
 };
 
 struct wilc_wfi_mon_priv {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   3   4   >