2019-01-17 13:21:12

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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



2019-01-17 13:21:17

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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 <[email protected]>
---
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


2019-01-17 13:21:20

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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

Signed-off-by: Ajay Singh <[email protected]>
---
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_SIZE 4
#define MAX_MAC_HDR_LEN 26 /* 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


2019-01-17 13:21:24

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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 <[email protected]>
---
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->ndev, "%s: info is NULL\n",
__func__);
goto done;
}

- for (i = 0; i < scan_req->ch_cnt; i++) {
- if (memcmp(scan_req->net_info[i].bssid, info->bssid, 6) == 0) {
- if (info->rssi <= scan_req->net_info[i].rssi) {
- goto done;
- } else {
- scan_req->net_info[i].rssi = info->rssi;
- found = false;
- break;
- }
- }
- }
-
- if (found) {
- if (scan_req->ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
- scan_req->net_info[scan_req->ch_cnt].rssi = info->rssi;
-
- memcpy(scan_req->net_info[scan_req->ch_cnt].bssid,
- info->bssid, 6);
-
- scan_req->ch_cnt++;
-
- info->new_network = true;
- params = host_int_parse_join_bss_param(info);
-
- scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, info,
- scan_req->arg, params);
- }
- } else {
- info->new_network = false;
- scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, info,
- scan_req->arg, NULL);
- }
+ scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, info, scan_req->arg);

done:
kfree(rcvd_info->buffer);
@@ -1150,8 +1126,7 @@ int wilc_disconnect(struct wilc_vif *vif)

if (scan_req->scan_result) {
del_timer(&hif_drv->scan_timer);
- scan_req->scan_result(SCAN_EVENT_ABORTED, NULL, scan_req->arg,
- NULL);
+ scan_req->scan_result(SCAN_EVENT_ABORTED, NULL, scan_req->arg);
scan_req->scan_result = NULL;
}

@@ -2131,8 +2106,7 @@ int wilc_deinit(struct wilc_vif *vif)

if (hif_drv->usr_scan_req.scan_result) {
hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
- hif_drv->usr_scan_req.arg,
- NULL);
+ hif_drv->usr_scan_req.arg);
hif_drv->usr_scan_req.scan_result = NULL;
}

diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 9b396a79..6a09a52 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -19,7 +19,6 @@ enum {

#define WILC_MAX_NUM_STA 9
#define MAX_NUM_SCANNED_NETWORKS 100
-#define MAX_NUM_SCANNED_NETWORKS_SHADOW 130
#define WILC_MAX_NUM_PROBED_SSID 10

#define TX_MIC_KEY_LEN 8
@@ -29,8 +28,6 @@ enum {
#define WILC_ADD_STA_LENGTH 40
#define WILC_NUM_CONCURRENT_IFC 2

-#define NUM_RSSI 5
-
enum {
WILC_SET_CFG = 0,
WILC_GET_CFG
@@ -38,12 +35,6 @@ enum {

#define WILC_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;
@@ -53,15 +44,9 @@ struct network_info {
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;
};

@@ -129,11 +114,6 @@ enum cfg_param {
WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
};

-struct found_net_info {
- u8 bssid[6];
- s8 rssi;
-};
-
enum scan_event {
SCAN_EVENT_NETWORK_FOUND = 0,
SCAN_EVENT_DONE = 1,
@@ -148,7 +128,7 @@ enum conn_event {
};

typedef void (*wilc_scan_result)(enum scan_event, struct network_info *,
- void *, void *);
+ void *);

typedef void (*wilc_connect_result)(enum conn_event,
struct connect_info *,
@@ -178,7 +158,6 @@ struct user_scan_req {
wilc_scan_result scan_result;
void *arg;
u32 ch_cnt;
- struct found_net_info net_info[MAX_NUM_SCANNED_NETWORKS];
};

struct user_conn_req {
@@ -307,4 +286,5 @@ 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);
+void *wilc_parse_join_bss_param(struct cfg80211_bss *bss);
#endif
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 987e5ff..381dfd8 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -29,9 +29,6 @@

#define INVALID_CHANNEL 0

-#define nl80211_SCAN_RESULT_EXPIRE (3 * HZ)
-#define SCAN_RESULT_EXPIRE (40 * HZ)
-
static const struct ieee80211_txrx_stypes
wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
[NL80211_IFTYPE_STATION] = {
@@ -75,115 +72,8 @@ static u8 curr_channel;
static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09};
static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};

-#define AGING_TIME (9 * 1000)
#define DURING_IP_TIME_OUT 15000

-static void clear_shadow_scan(struct wilc_priv *priv)
-{
- int i;
-
- for (i = 0; i < priv->scanned_cnt; i++) {
- kfree(priv->scanned_shadow[i].ies);
- priv->scanned_shadow[i].ies = NULL;
-
- kfree(priv->scanned_shadow[i].join_params);
- priv->scanned_shadow[i].join_params = NULL;
- }
- priv->scanned_cnt = 0;
-}
-
-static u32 get_rssi_avg(struct network_info *network_info)
-{
- u8 i;
- int rssi_v = 0;
- u8 num_rssi = (network_info->rssi_history.full) ?
- NUM_RSSI : (network_info->rssi_history.index);
-
- for (i = 0; i < num_rssi; i++)
- rssi_v += network_info->rssi_history.samples[i];
-
- rssi_v /= num_rssi;
- return rssi_v;
-}
-
-static void refresh_scan(struct wilc_priv *priv, bool direct_scan)
-{
- struct wiphy *wiphy = priv->dev->ieee80211_ptr->wiphy;
- int i;
-
- for (i = 0; i < priv->scanned_cnt; i++) {
- struct network_info *network_info;
- s32 freq;
- struct ieee80211_channel *channel;
- int rssi;
- struct cfg80211_bss *bss;
-
- network_info = &priv->scanned_shadow[i];
-
- if (!memcmp("DIRECT-", network_info->ssid, 7) && !direct_scan)
- continue;
-
- freq = ieee80211_channel_to_frequency((s32)network_info->ch,
- NL80211_BAND_2GHZ);
- channel = ieee80211_get_channel(wiphy, freq);
- rssi = get_rssi_avg(network_info);
- bss = cfg80211_inform_bss(wiphy,
- channel,
- CFG80211_BSS_FTYPE_UNKNOWN,
- network_info->bssid,
- network_info->tsf,
- network_info->cap_info,
- network_info->beacon_period,
- (const u8 *)network_info->ies,
- (size_t)network_info->ies_len,
- (s32)rssi * 100,
- GFP_KERNEL);
- cfg80211_put_bss(wiphy, bss);
- }
-}
-
-static void reset_shadow_found(struct wilc_priv *priv)
-{
- int i;
-
- for (i = 0; i < priv->scanned_cnt; i++)
- priv->scanned_shadow[i].found = 0;
-}
-
-static void update_scan_time(struct wilc_priv *priv)
-{
- int i;
-
- for (i = 0; i < priv->scanned_cnt; i++)
- priv->scanned_shadow[i].time_scan = jiffies;
-}
-
-static void remove_network_from_shadow(struct timer_list *t)
-{
- struct wilc_priv *priv = from_timer(priv, t, aging_timer);
- unsigned long now = jiffies;
- int i, j;
-
- for (i = 0; i < priv->scanned_cnt; i++) {
- if (!time_after(now, priv->scanned_shadow[i].time_scan +
- (unsigned long)(SCAN_RESULT_EXPIRE)))
- continue;
- kfree(priv->scanned_shadow[i].ies);
- priv->scanned_shadow[i].ies = NULL;
-
- kfree(priv->scanned_shadow[i].join_params);
-
- for (j = i; (j < priv->scanned_cnt - 1); j++)
- priv->scanned_shadow[j] = priv->scanned_shadow[j + 1];
-
- priv->scanned_cnt--;
- }
-
- if (priv->scanned_cnt != 0)
- mod_timer(&priv->aging_timer,
- jiffies + msecs_to_jiffies(AGING_TIME));
-}
-
static void clear_during_ip(struct timer_list *t)
{
struct wilc_vif *vif = from_timer(vif, t, during_ip_timer);
@@ -191,87 +81,15 @@ static void clear_during_ip(struct timer_list *t)
vif->obtaining_ip = false;
}

-static int is_network_in_shadow(struct network_info *nw_info,
- struct wilc_priv *priv)
-{
- int state = -1;
- int i;
-
- if (priv->scanned_cnt == 0) {
- mod_timer(&priv->aging_timer,
- jiffies + msecs_to_jiffies(AGING_TIME));
- state = -1;
- } else {
- for (i = 0; i < priv->scanned_cnt; i++) {
- if (memcmp(priv->scanned_shadow[i].bssid,
- nw_info->bssid, 6) == 0) {
- state = i;
- break;
- }
- }
- }
- return state;
-}
-
-static void add_network_to_shadow(struct network_info *nw_info,
- struct wilc_priv *priv, void *join_params)
-{
- int ap_found = is_network_in_shadow(nw_info, priv);
- u32 ap_index = 0;
- u8 rssi_index = 0;
- struct network_info *shadow_nw_info;
-
- if (priv->scanned_cnt >= MAX_NUM_SCANNED_NETWORKS_SHADOW)
- return;
-
- if (ap_found == -1) {
- ap_index = priv->scanned_cnt;
- priv->scanned_cnt++;
- } else {
- ap_index = ap_found;
- }
- shadow_nw_info = &priv->scanned_shadow[ap_index];
- rssi_index = shadow_nw_info->rssi_history.index;
- shadow_nw_info->rssi_history.samples[rssi_index++] = nw_info->rssi;
- if (rssi_index == NUM_RSSI) {
- rssi_index = 0;
- shadow_nw_info->rssi_history.full = true;
- }
- shadow_nw_info->rssi_history.index = rssi_index;
- shadow_nw_info->rssi = nw_info->rssi;
- shadow_nw_info->cap_info = nw_info->cap_info;
- shadow_nw_info->ssid_len = nw_info->ssid_len;
- memcpy(shadow_nw_info->ssid, nw_info->ssid, nw_info->ssid_len);
- memcpy(shadow_nw_info->bssid, nw_info->bssid, ETH_ALEN);
- 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 = nw_info->tsf;
- if (ap_found != -1)
- kfree(shadow_nw_info->ies);
- shadow_nw_info->ies = kmemdup(nw_info->ies, nw_info->ies_len,
- GFP_KERNEL);
- if (shadow_nw_info->ies)
- shadow_nw_info->ies_len = nw_info->ies_len;
- else
- shadow_nw_info->ies_len = 0;
- shadow_nw_info->time_scan = jiffies;
- shadow_nw_info->time_scan_cached = jiffies;
- shadow_nw_info->found = 1;
- if (ap_found != -1)
- kfree(shadow_nw_info->join_params);
- shadow_nw_info->join_params = join_params;
-}
-
static void cfg_scan_result(enum scan_event scan_event,
struct network_info *network_info,
- void *user_void, void *join_params)
+ void *user_void)
{
struct wilc_priv *priv;
struct wiphy *wiphy;
s32 freq;
struct ieee80211_channel *channel;
- struct cfg80211_bss *bss = NULL;
+ struct cfg80211_bss *bss;

priv = user_void;
if (!priv->cfg_scanning)
@@ -291,51 +109,22 @@ static void cfg_scan_result(enum scan_event scan_event,
freq = ieee80211_channel_to_frequency((s32)network_info->ch,
NL80211_BAND_2GHZ);
channel = ieee80211_get_channel(wiphy, freq);
-
if (!channel)
return;

- if (network_info->new_network) {
- if (priv->rcvd_ch_cnt >= MAX_NUM_SCANNED_NETWORKS)
- return;
-
- priv->rcvd_ch_cnt++;
-
- add_network_to_shadow(network_info, priv, join_params);
-
- if (memcmp("DIRECT-", network_info->ssid, 7))
- return;
-
- bss = cfg80211_inform_bss(wiphy,
- channel,
- CFG80211_BSS_FTYPE_UNKNOWN,
- network_info->bssid,
- network_info->tsf,
- network_info->cap_info,
- network_info->beacon_period,
- (const u8 *)network_info->ies,
- (size_t)network_info->ies_len,
- (s32)network_info->rssi * 100,
- GFP_KERNEL);
- cfg80211_put_bss(wiphy, bss);
- } else {
- u32 i;
-
- for (i = 0; i < priv->rcvd_ch_cnt; i++) {
- if (memcmp(priv->scanned_shadow[i].bssid,
- network_info->bssid, 6) == 0)
- break;
- }
-
- if (i >= priv->rcvd_ch_cnt)
- return;
-
- priv->scanned_shadow[i].rssi = network_info->rssi;
- priv->scanned_shadow[i].time_scan = jiffies;
- }
+ bss = cfg80211_inform_bss(wiphy,
+ channel,
+ CFG80211_BSS_FTYPE_UNKNOWN,
+ network_info->bssid,
+ network_info->tsf,
+ network_info->cap_info,
+ network_info->beacon_period,
+ (const u8 *)network_info->ies,
+ (size_t)network_info->ies_len,
+ (s32)network_info->rssi * 100,
+ GFP_KERNEL);
+ cfg80211_put_bss(wiphy, bss);
} else if (scan_event == SCAN_EVENT_DONE) {
- refresh_scan(priv, false);
-
mutex_lock(&priv->scan_req_lock);

if (priv->scan_req) {
@@ -344,7 +133,6 @@ static void cfg_scan_result(enum scan_event scan_event,
};

cfg80211_scan_done(priv->scan_req, &info);
- priv->rcvd_ch_cnt = 0;
priv->cfg_scanning = false;
priv->scan_req = NULL;
}
@@ -357,9 +145,6 @@ static void cfg_scan_result(enum scan_event scan_event,
.aborted = false,
};

- update_scan_time(priv);
- refresh_scan(priv, false);
-
cfg80211_scan_done(priv->scan_req, &info);
priv->cfg_scanning = false;
priv->scan_req = NULL;
@@ -368,17 +153,6 @@ static void cfg_scan_result(enum scan_event scan_event,
}
}

-static inline bool wilc_cfg_scan_time_expired(struct wilc_priv *priv, int i)
-{
- unsigned long now = jiffies;
-
- if (time_after(now, priv->scanned_shadow[i].time_scan_cached +
- (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ))))
- return true;
- else
- return false;
-}
-
static void cfg_connect_result(enum conn_event conn_disconn_evt,
struct connect_info *conn_info,
u8 mac_status,
@@ -409,28 +183,10 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt,
netdev_err(dev, "Unspecified failure\n");
}

- if (connect_status == WLAN_STATUS_SUCCESS) {
- bool scan_refresh = false;
- u32 i;
-
+ if (connect_status == WLAN_STATUS_SUCCESS)
memcpy(priv->associated_bss, conn_info->bssid,
ETH_ALEN);

- for (i = 0; i < priv->scanned_cnt; i++) {
- if (memcmp(priv->scanned_shadow[i].bssid,
- conn_info->bssid,
- ETH_ALEN) == 0) {
- if (wilc_cfg_scan_time_expired(priv, i))
- scan_refresh = true;
-
- break;
- }
- }
-
- if (scan_refresh)
- refresh_scan(priv, true);
- }
-
cfg80211_connect_result(dev, conn_info->bssid,
conn_info->req_ies,
conn_info->req_ies_len,
@@ -531,10 +287,6 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)

priv->scan_req = request;

- priv->rcvd_ch_cnt = 0;
-
- reset_shadow_found(priv);
-
priv->cfg_scanning = true;
if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) {
for (i = 0; i < request->n_channels; i++) {
@@ -583,13 +335,13 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
struct wilc_priv *priv = wiphy_priv(wiphy);
struct wilc_vif *vif = netdev_priv(priv->dev);
struct host_if_drv *wfi_drv = priv->hif_drv;
- struct network_info *nw_info;
int ret;
u32 i;
- u32 sel_bssi_idx = UINT_MAX;
u8 security = WILC_FW_SEC_NO;
enum authtype auth_type = WILC_FW_AUTH_ANY;
u32 cipher_group;
+ struct cfg80211_bss *bss;
+ void *join_params;

vif->connecting = true;

@@ -598,39 +350,6 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
else
wfi_drv->p2p_connect = 0;

- for (i = 0; i < priv->scanned_cnt; i++) {
- if (sme->ssid_len == priv->scanned_shadow[i].ssid_len &&
- memcmp(priv->scanned_shadow[i].ssid,
- sme->ssid,
- sme->ssid_len) == 0) {
- if (!sme->bssid) {
- if (sel_bssi_idx == UINT_MAX ||
- priv->scanned_shadow[i].rssi >
- priv->scanned_shadow[sel_bssi_idx].rssi)
- sel_bssi_idx = i;
- } else {
- if (memcmp(priv->scanned_shadow[i].bssid,
- sme->bssid,
- ETH_ALEN) == 0) {
- sel_bssi_idx = i;
- break;
- }
- }
- }
- }
-
- if (sel_bssi_idx < priv->scanned_cnt) {
- nw_info = &priv->scanned_shadow[sel_bssi_idx];
- } else {
- ret = -ENOENT;
- goto out_error;
- }
-
- if (ether_addr_equal_unaligned(vif->bssid, nw_info->bssid)) {
- ret = -EALREADY;
- goto out_error;
- }
-
memset(priv->wep_key, 0, sizeof(priv->wep_key));
memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len));

@@ -704,29 +423,54 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
auth_type = WILC_FW_AUTH_IEEE8021;
}

- curr_channel = nw_info->ch;
+ bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid, sme->ssid,
+ sme->ssid_len, IEEE80211_BSS_TYPE_ANY,
+ IEEE80211_PRIVACY(sme->privacy));
+ if (!bss) {
+ ret = -EINVAL;
+ goto out_error;
+ }
+
+ if (ether_addr_equal_unaligned(vif->bssid, bss->bssid)) {
+ ret = -EALREADY;
+ goto out_put_bss;
+ }
+
+ join_params = wilc_parse_join_bss_param(bss);
+ if (!join_params) {
+ netdev_err(dev, "%s: failed to construct join param\n",
+ __func__);
+ ret = -EINVAL;
+ goto out_put_bss;
+ }
+
+ curr_channel = ieee80211_frequency_to_channel(bss->channel->center_freq);

if (!wfi_drv->p2p_connect)
- wlan_channel = nw_info->ch;
+ wlan_channel = curr_channel;

- wilc_wlan_set_bssid(dev, nw_info->bssid, WILC_STATION_MODE);
+ wilc_wlan_set_bssid(dev, bss->bssid, WILC_STATION_MODE);

- ret = wilc_set_join_req(vif, nw_info->bssid, sme->ssid,
+ ret = wilc_set_join_req(vif, bss->bssid, sme->ssid,
sme->ssid_len, sme->ie, sme->ie_len,
cfg_connect_result, (void *)priv,
- security, auth_type,
- nw_info->ch,
- nw_info->join_params);
+ security, auth_type, curr_channel, join_params);
if (ret) {
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, WILC_STATION_MODE);
- goto out_error;
+ kfree(join_params);
+ goto out_put_bss;
}
+ kfree(join_params);
+ cfg80211_put_bss(wiphy, bss);
return 0;

+out_put_bss:
+ cfg80211_put_bss(wiphy, bss);
+
out_error:
vif->connecting = false;
return ret;
@@ -2096,7 +1840,6 @@ int wilc_init_host_int(struct net_device *net)
struct wilc_priv *priv = wdev_priv(net->ieee80211_ptr);
struct wilc_vif *vif = netdev_priv(priv->dev);

- timer_setup(&priv->aging_timer, remove_network_from_shadow, 0);
timer_setup(&vif->during_ip_timer, clear_during_ip, 0);

priv->p2p_listen_state = false;
@@ -2120,8 +1863,6 @@ void wilc_deinit_host_int(struct net_device *net)
mutex_destroy(&priv->scan_req_lock);
ret = wilc_deinit(vif);

- del_timer_sync(&priv->aging_timer);
- clear_shadow_scan(priv);
del_timer_sync(&vif->during_ip_timer);

if (ret)
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index a3400c1..59e8352 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -137,7 +137,6 @@ struct wilc_priv {
u64 tx_cookie;

bool cfg_scanning;
- u32 rcvd_ch_cnt;

u8 associated_bss[ETH_ALEN];
struct sta_info assoc_stainfo;
@@ -155,8 +154,6 @@ struct wilc_priv {
/* mutexes */
struct mutex scan_req_lock;
bool p2p_listen_state;
- struct timer_list aging_timer;
- struct network_info scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
int scanned_cnt;
struct wilc_p2p_var p2p;

--
2.7.4


2019-01-17 13:21:27

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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 <[email protected]>
---
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)
-{
- 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;
- struct network_info *info = NULL;
- struct user_scan_req *scan_req = &vif->hif_drv->usr_scan_req;
-
- if (!scan_req->scan_result)
- goto done;
+ rcvd_info->ch = ch_elm[2];

- wilc_parse_network_info(rcvd_info->buffer, &info);
- if (!info) {
- netdev_err(vif->ndev, "%s: info is NULL\n",
- __func__);
- goto done;
- }
-
- scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, info, scan_req->arg);
+ if (scan_req->scan_result)
+ scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, rcvd_info,
+ scan_req->arg);

done:
- kfree(rcvd_info->buffer);
- rcvd_info->buffer = NULL;
-
- if (info) {
- kfree(info->ies);
- kfree(info);
- }
-
+ kfree(rcvd_info->mgmt);
kfree(msg);
}

@@ -2143,9 +2052,12 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length)
if (IS_ERR(msg))
return;

- msg->body.net_info.len = length;
- msg->body.net_info.buffer = kmemdup(buffer, length, GFP_KERNEL);
- if (!msg->body.net_info.buffer) {
+ msg->body.net_info.frame_len = get_unaligned_le16(&buffer[6]) - 1;
+ msg->body.net_info.rssi = buffer[8];
+ msg->body.net_info.mgmt = kmemdup(&buffer[9],
+ msg->body.net_info.frame_len,
+ GFP_KERNEL);
+ if (!msg->body.net_info.mgmt) {
kfree(msg);
return;
}
@@ -2153,7 +2065,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length)
result = wilc_enqueue_work(msg);
if (result) {
netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
- kfree(msg->body.net_info.buffer);
+ kfree(msg->body.net_info.mgmt);
kfree(msg);
}
}
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 6a09a52..76da172 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -127,7 +127,14 @@ enum conn_event {
CONN_DISCONN_EVENT_FORCE_32BIT = 0xFFFFFFFF
};

-typedef void (*wilc_scan_result)(enum scan_event, struct network_info *,
+struct wilc_rcvd_net_info {
+ s8 rssi;
+ u8 ch;
+ u16 frame_len;
+ struct ieee80211_mgmt *mgmt;
+};
+
+typedef void (*wilc_scan_result)(enum scan_event, struct wilc_rcvd_net_info *,
void *);

typedef void (*wilc_connect_result)(enum conn_event,
@@ -139,11 +146,6 @@ 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 rcvd_net_info {
- u8 *buffer;
- u32 len;
-};
-
struct hidden_net_info {
u8 *ssid;
u8 ssid_len;
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 381dfd8..5da03bb 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -82,48 +82,34 @@ static void clear_during_ip(struct timer_list *t)
}

static void cfg_scan_result(enum scan_event scan_event,
- struct network_info *network_info,
- void *user_void)
+ struct wilc_rcvd_net_info *info, void *user_void)
{
- struct wilc_priv *priv;
- struct wiphy *wiphy;
- s32 freq;
- struct ieee80211_channel *channel;
- struct cfg80211_bss *bss;
+ struct wilc_priv *priv = user_void;

- priv = user_void;
if (!priv->cfg_scanning)
return;

if (scan_event == SCAN_EVENT_NETWORK_FOUND) {
- wiphy = priv->dev->ieee80211_ptr->wiphy;
-
- if (!wiphy || !network_info)
- return;
+ s32 freq;
+ struct ieee80211_channel *channel;
+ struct cfg80211_bss *bss;
+ struct wiphy *wiphy = priv->dev->ieee80211_ptr->wiphy;

- if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC &&
- (((s32)network_info->rssi * 100) < 0 ||
- ((s32)network_info->rssi * 100) > 100))
+ if (!wiphy || !info)
return;

- freq = ieee80211_channel_to_frequency((s32)network_info->ch,
+ freq = ieee80211_channel_to_frequency((s32)info->ch,
NL80211_BAND_2GHZ);
channel = ieee80211_get_channel(wiphy, freq);
if (!channel)
return;

- bss = cfg80211_inform_bss(wiphy,
- channel,
- CFG80211_BSS_FTYPE_UNKNOWN,
- network_info->bssid,
- network_info->tsf,
- network_info->cap_info,
- network_info->beacon_period,
- (const u8 *)network_info->ies,
- (size_t)network_info->ies_len,
- (s32)network_info->rssi * 100,
- GFP_KERNEL);
- cfg80211_put_bss(wiphy, bss);
+ bss = cfg80211_inform_bss_frame(wiphy, channel, info->mgmt,
+ info->frame_len,
+ (s32)info->rssi * 100,
+ GFP_KERNEL);
+ if (!bss)
+ cfg80211_put_bss(wiphy, bss);
} else if (scan_event == SCAN_EVENT_DONE) {
mutex_lock(&priv->scan_req_lock);

--
2.7.4


2019-01-17 13:21:32

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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 <[email protected]>
---
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);
-
- memcpy(cur_byte, bss_param->rsn_auth_policy,
- sizeof(bss_param->rsn_auth_policy));
- cur_byte += sizeof(bss_param->rsn_auth_policy);
-
- memcpy(cur_byte, bss_param->rsn_cap, sizeof(bss_param->rsn_cap));
- cur_byte += sizeof(bss_param->rsn_cap);
-
- *(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->idx;
- *(cur_byte++) = bss_param->opp_enabled;
-
- if (bss_param->opp_enabled)
- *(cur_byte++) = bss_param->ct_window;
-
- *(cur_byte++) = bss_param->cnt;
-
- memcpy(cur_byte, bss_param->duration,
- sizeof(bss_param->duration));
- cur_byte += sizeof(bss_param->duration);
-
- memcpy(cur_byte, bss_param->interval,
- sizeof(bss_param->interval));
- cur_byte += sizeof(bss_param->interval);
-
- memcpy(cur_byte, bss_param->start_time,
- sizeof(bss_param->start_time));
- cur_byte += sizeof(bss_param->start_time);
- }
-
- cur_byte = wid_list[wid_cnt].val;
+ wid_list[wid_cnt].size = sizeof(*bss_param);
+ wid_list[wid_cnt].val = (u8 *)bss_param;
wid_cnt++;

result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
@@ -469,13 +396,11 @@ static int wilc_send_connect_wid(struct wilc_vif *vif)
wilc_get_vif_idx(vif));
if (result) {
netdev_err(vif->ndev, "failed to send config packet\n");
- kfree(cur_byte);
goto error;
} else {
hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
}

- kfree(cur_byte);
return 0;

error:
@@ -561,181 +486,130 @@ static void handle_connect_timeout(struct work_struct *work)
kfree(msg);
}

-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)
+void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
+ struct cfg80211_crypto_settings *crypto)
{
- u8 ext_rates_no;
- u16 offset;
- u8 pcipher_cnt;
- u8 auth_cnt;
- u8 i, j;
- u16 index = *out_index;
-
- if (ies[index] == WLAN_EID_SUPP_RATES) {
- *rates_no = ies[index + 1];
- param->supp_rates[0] = *rates_no;
- index += 2;
+ struct wilc_join_bss_param *param;
+ struct ieee80211_p2p_noa_attr noa_attr;
+ u8 rates_len = 0;
+ const u8 *tim_elm, *ssid_elm, *rates_ie, *supp_rates_ie;
+ const u8 *ht_ie, *wpa_ie, *wmm_ie, *rsn_ie;
+ int ret;
+ const struct cfg80211_bss_ies *ies = bss->ies;

- for (i = 0; i < *rates_no; i++)
- param->supp_rates[i + 1] = ies[index + i];
+ param = kzalloc(sizeof(*param), GFP_KERNEL);
+ if (!param)
+ return NULL;

- index += *rates_no;
- } else if (ies[index] == WLAN_EID_EXT_SUPP_RATES) {
- ext_rates_no = ies[index + 1];
- if (ext_rates_no > (MAX_RATES_SUPPORTED - *rates_no))
- param->supp_rates[0] = MAX_RATES_SUPPORTED;
- else
- param->supp_rates[0] += ext_rates_no;
- index += 2;
- for (i = 0; i < (param->supp_rates[0] - *rates_no); i++)
- param->supp_rates[*rates_no + i + 1] = ies[index + i];
+ param->beacon_period = bss->beacon_interval;
+ param->cap_info = bss->capability;
+ param->bss_type = WILC_FW_BSS_TYPE_INFRA;
+ param->ch = ieee80211_frequency_to_channel(bss->channel->center_freq);
+ ether_addr_copy(param->bssid, bss->bssid);

- index += ext_rates_no;
- } else if (ies[index] == WLAN_EID_HT_CAPABILITY) {
- param->ht_capable = true;
- index += ies[index + 1] + 2;
- } else if ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) &&
- (ies[index + 2] == 0x00) && (ies[index + 3] == 0x50) &&
- (ies[index + 4] == 0xF2) && (ies[index + 5] == 0x02) &&
- ((ies[index + 6] == 0x00) || (ies[index + 6] == 0x01)) &&
- (ies[index + 7] == 0x01)) {
- param->wmm_cap = true;
-
- if (ies[index + 8] & BIT(7))
- param->uapsd_cap = true;
- index += ies[index + 1] + 2;
- } else if ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) &&
- (ies[index + 2] == 0x50) && (ies[index + 3] == 0x6f) &&
- (ies[index + 4] == 0x9a) &&
- (ies[index + 5] == 0x09) && (ies[index + 6] == 0x0c)) {
- u16 p2p_cnt;
-
- param->tsf = tsf_lo;
- param->noa_enabled = 1;
- param->idx = ies[index + 9];
+ ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len);
+ if (ssid_elm) {
+ if (ssid_elm[1] <= IEEE80211_MAX_SSID_LEN)
+ memcpy(param->ssid, ssid_elm + 2, ssid_elm[1]);
+ }

- if (ies[index + 10] & BIT(7)) {
- param->opp_enabled = 1;
- param->ct_window = ies[index + 10];
- } else {
- param->opp_enabled = 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];

- param->cnt = ies[index + 11];
- p2p_cnt = index + 12;
+ memset(param->p_suites, 0xFF, 3);
+ memset(param->akm_suites, 0xFF, 3);

- memcpy(param->duration, ies + p2p_cnt, 4);
- p2p_cnt += 4;
+ rates_ie = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies->data, ies->len);
+ if (rates_ie) {
+ rates_len = rates_ie[1];
+ param->supp_rates[0] = rates_len;
+ memcpy(&param->supp_rates[1], rates_ie + 2, rates_len);
+ }

- memcpy(param->interval, ies + p2p_cnt, 4);
- p2p_cnt += 4;
+ supp_rates_ie = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, ies->data,
+ ies->len);
+ if (supp_rates_ie) {
+ if (supp_rates_ie[1] > (MAX_RATES_SUPPORTED - rates_len))
+ param->supp_rates[0] = MAX_RATES_SUPPORTED;
+ else
+ param->supp_rates[0] += supp_rates_ie[1];

- memcpy(param->start_time, ies + p2p_cnt, 4);
+ memcpy(&param->supp_rates[rates_len + 1], supp_rates_ie + 2,
+ (param->supp_rates[0] - rates_len));
+ }

- index += ies[index + 1] + 2;
- } else if ((ies[index] == WLAN_EID_RSN) ||
- ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) &&
- (ies[index + 2] == 0x00) &&
- (ies[index + 3] == 0x50) && (ies[index + 4] == 0xF2) &&
- (ies[index + 5] == 0x01))) {
- u16 rsn_idx = index;
+ ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies->data, ies->len);
+ if (ht_ie)
+ param->ht_capable = true;

- if (ies[rsn_idx] == WLAN_EID_RSN) {
- param->mode_802_11i = 2;
+ ret = cfg80211_get_p2p_attr(ies->data, ies->len,
+ IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
+ (u8 *)&noa_attr, sizeof(noa_attr));
+ if (ret > 0) {
+ param->tsf_lo = cpu_to_le32(ies->tsf);
+ param->noa_enabled = 1;
+ param->idx = noa_attr.index;
+ if (noa_attr.oppps_ctwindow & IEEE80211_P2P_OPPPS_ENABLE_BIT) {
+ param->opp_enabled = 1;
+ param->opp_en.ct_window = noa_attr.oppps_ctwindow;
+ param->opp_en.cnt = noa_attr.desc[0].count;
+ param->opp_en.duration = noa_attr.desc[0].duration;
+ param->opp_en.interval = noa_attr.desc[0].interval;
+ param->opp_en.start_time = noa_attr.desc[0].start_time;
} else {
- if (param->mode_802_11i == 0)
- param->mode_802_11i = 1;
- rsn_idx += 4;
- }
-
- rsn_idx += 7;
- param->rsn_grp_policy = ies[rsn_idx];
- rsn_idx++;
- offset = ies[rsn_idx] * 4;
- pcipher_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx];
- rsn_idx += 2;
-
- i = *pcipher_tc;
- j = 0;
- for (; i < (pcipher_cnt + *pcipher_tc) && i < 3; i++, j++) {
- u8 *policy = &param->rsn_pcip_policy[i];
-
- *policy = ies[rsn_idx + ((j + 1) * 4) - 1];
+ param->opp_enabled = 0;
+ param->opp_dis.cnt = noa_attr.desc[0].count;
+ param->opp_dis.duration = noa_attr.desc[0].duration;
+ param->opp_dis.interval = noa_attr.desc[0].interval;
+ param->opp_dis.start_time = noa_attr.desc[0].start_time;
}
-
- *pcipher_tc += pcipher_cnt;
- rsn_idx += offset;
-
- offset = ies[rsn_idx] * 4;
-
- auth_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx];
- rsn_idx += 2;
- i = *auth_total_cnt;
- j = 0;
- for (; i < (*auth_total_cnt + auth_cnt); i++, j++) {
- u8 *policy = &param->rsn_auth_policy[i];
-
- *policy = ies[rsn_idx + ((j + 1) * 4) - 1];
+ }
+ wmm_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
+ WLAN_OUI_TYPE_MICROSOFT_WMM,
+ ies->data, ies->len);
+ if (wmm_ie) {
+ struct ieee80211_wmm_param_ie *ie;
+
+ ie = (struct ieee80211_wmm_param_ie *)wmm_ie;
+ if ((ie->oui_subtype == 0 || ie->oui_subtype == 1) &&
+ ie->version == 1) {
+ param->wmm_cap = true;
+ if (ie->qos_info & BIT(7))
+ param->uapsd_cap = true;
}
+ }

- *auth_total_cnt += auth_cnt;
- rsn_idx += offset;
-
- if (ies[index] == WLAN_EID_RSN) {
- param->rsn_cap[0] = ies[rsn_idx];
- param->rsn_cap[1] = ies[rsn_idx + 1];
- rsn_idx += 2;
- }
+ wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
+ WLAN_OUI_TYPE_MICROSOFT_WPA,
+ ies->data, ies->len);
+ if (wpa_ie) {
+ param->mode_802_11i = 1;
param->rsn_found = true;
- index += ies[index + 1] + 2;
- } else {
- index += ies[index + 1] + 2;
}

- *out_index = index;
-}
-
-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;
+ rsn_ie = cfg80211_find_ie(WLAN_EID_RSN, ies->data, ies->len);
+ if (rsn_ie) {
+ int offset = 8;

- param = kzalloc(sizeof(*param), GFP_KERNEL);
- if (!param)
- return NULL;
-
- 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;
+ param->mode_802_11i = 2;
+ param->rsn_found = true;
+ //extract RSN capabilities
+ offset += (rsn_ie[offset] * 4) + 2;
+ offset += (rsn_ie[offset] * 4) + 2;
+ memcpy(param->rsn_cap, &rsn_ie[offset], 2);
}

- 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];
+ if (param->rsn_found) {
+ int i;

- memset(param->rsn_pcip_policy, 0xFF, 3);
- memset(param->rsn_auth_policy, 0xFF, 3);
+ param->rsn_grp_policy = crypto->cipher_group & 0xFF;
+ for (i = 0; i < crypto->n_ciphers_pairwise && i < 3; i++)
+ param->p_suites[i] = crypto->ciphers_pairwise[i] & 0xFF;

- while (index < ies->len)
- host_int_fill_join_bss_param(param, ies->data, &index,
- &pcipher_total_cnt,
- &auth_total_cnt, ies->tsf,
- &rates_no);
+ for (i = 0; i < crypto->n_akm_suites && i < 3; i++)
+ param->akm_suites[i] = crypto->akm_suites[i] & 0xFF;
+ }

return (void *)param;
}
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 76da172..659e8cc 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -35,21 +35,6 @@ enum {

#define WILC_MAX_ASSOC_RESP_FRAME_SIZE 256

-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;
- u32 tsf_lo;
- u8 *ies;
- u16 ies_len;
- u64 tsf;
-};
-
struct connect_info {
u8 bssid[6];
u8 *req_ies;
@@ -288,5 +273,6 @@ 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);
-void *wilc_parse_join_bss_param(struct cfg80211_bss *bss);
+void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
+ struct cfg80211_crypto_settings *crypto);
#endif
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 5da03bb..5070cad 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -422,7 +422,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
goto out_put_bss;
}

- join_params = wilc_parse_join_bss_param(bss);
+ join_params = wilc_parse_join_bss_param(bss, &sme->crypto);
if (!join_params) {
netdev_err(dev, "%s: failed to construct join param\n",
__func__);
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h
index e2310d8..961b6bb 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -47,7 +47,6 @@ typedef void (*wilc_tx_complete_func_t)(void *, int);
*
********************************************/
#define WILC_MULTICAST_TABLE_SIZE 8
-#define MAX_SSID_LEN 33
#define MAX_RATES_SUPPORTED 12

enum bss_types {
--
2.7.4


2019-01-17 13:21:34

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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

Signed-off-by: Ajay Singh <[email protected]>
---
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);

if (buffer_size >= size) {
memcpy(buffer, &wl->cfg.s[i].str[2],
--
2.7.4


2019-01-17 13:21:39

by Ajay Singh

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

From: Ajay Singh <[email protected]>

Modified packing order for join param as expected by firmware.

Signed-off-by: Ajay Singh <[email protected]>
---
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_CHANNEL 100

-#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


2019-01-17 13:21:40

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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 <[email protected]>
---
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_req(struct host_if_drv *hif_drv)
-{
- 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;
-}
-
static s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,
- struct connect_info *ret_conn_info)
+ struct wilc_conn_info *ret_conn_info)
{
u8 *ies;
u16 ies_len;
@@ -708,10 +664,8 @@ static s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,
static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif,
u8 mac_status)
{
- struct connect_info conn_info;
struct host_if_drv *hif_drv = vif->hif_drv;
-
- memset(&conn_info, 0, sizeof(struct connect_info));
+ struct wilc_conn_info *conn_info = &hif_drv->conn_info;

if (mac_status == WILC_MAC_STATUS_CONNECTED) {
u32 assoc_resp_info_len;
@@ -727,7 +681,7 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif,

err = wilc_parse_assoc_resp_info(hif_drv->assoc_resp,
assoc_resp_info_len,
- &conn_info);
+ conn_info);
if (err)
netdev_err(vif->ndev,
"wilc_parse_assoc_resp_info() returned error %d\n",
@@ -735,31 +689,13 @@ 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 == WILC_MAC_STATUS_CONNECTED &&
- conn_info.status == WLAN_STATUS_SUCCESS) {
- memcpy(hif_drv->assoc_bssid,
- hif_drv->usr_conn_req.bssid, ETH_ALEN);
- }
- }
-
- if (hif_drv->usr_conn_req.ies) {
- conn_info.req_ies = kmemdup(hif_drv->usr_conn_req.ies,
- hif_drv->usr_conn_req.ies_len,
- GFP_KERNEL);
- if (conn_info.req_ies)
- conn_info.req_ies_len = hif_drv->usr_conn_req.ies_len;
- }
-
del_timer(&hif_drv->connect_timer);
- hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
- &conn_info, mac_status, NULL,
- hif_drv->usr_conn_req.arg);
+ conn_info->conn_result(CONN_DISCONN_EVENT_CONN_RESP, mac_status, NULL,
+ hif_drv->conn_info.arg);

if (mac_status == WILC_MAC_STATUS_CONNECTED &&
- conn_info.status == WLAN_STATUS_SUCCESS) {
+ conn_info->status == WLAN_STATUS_SUCCESS) {
+ ether_addr_copy(hif_drv->assoc_bssid, conn_info->bssid);
wilc_set_power_mgmt(vif, 0, 0);

hif_drv->hif_state = HOST_IF_CONNECTED;
@@ -771,19 +707,19 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif,
hif_drv->hif_state = HOST_IF_IDLE;
}

- kfree(conn_info.resp_ies);
- conn_info.resp_ies = NULL;
+ kfree(conn_info->resp_ies);
+ conn_info->resp_ies = NULL;
+ conn_info->resp_ies_len = 0;

- kfree(conn_info.req_ies);
- conn_info.req_ies = NULL;
- host_int_free_user_conn_req(hif_drv);
+ kfree(conn_info->req_ies);
+ conn_info->req_ies = NULL;
+ conn_info->req_ies_len = 0;
}

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;
- wilc_connect_result conn_result = hif_drv->usr_conn_req.conn_result;

memset(&disconn_info, 0, sizeof(struct disconnect_info));

@@ -796,19 +732,22 @@ static inline void host_int_handle_disconnect(struct wilc_vif *vif)
disconn_info.ie = NULL;
disconn_info.ie_len = 0;

- if (conn_result) {
+ if (hif_drv->conn_info.conn_result) {
vif->obtaining_ip = false;
wilc_set_power_mgmt(vif, 0, 0);

- conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL, 0,
- &disconn_info, hif_drv->usr_conn_req.arg);
+ hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
+ 0, &disconn_info,
+ hif_drv->conn_info.arg);
} else {
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
}

eth_zero_addr(hif_drv->assoc_bssid);

- host_int_free_user_conn_req(hif_drv);
+ hif_drv->conn_info.req_ies_len = 0;
+ kfree(hif_drv->conn_info.req_ies);
+ hif_drv->conn_info.req_ies = NULL;
hif_drv->hif_state = HOST_IF_IDLE;
}

@@ -834,7 +773,7 @@ static void handle_rcvd_gnrl_async_info(struct work_struct *work)
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->usr_conn_req.conn_result) {
+ if (!hif_drv->conn_info.conn_result) {
netdev_err(vif->ndev, "%s: conn_result is NULL\n",
__func__);
goto free_rcvd_info;
@@ -875,7 +814,7 @@ int wilc_disconnect(struct wilc_vif *vif)
struct host_if_drv *hif_drv = vif->hif_drv;
struct disconnect_info disconn_info;
struct user_scan_req *scan_req;
- struct user_conn_req *conn_req;
+ struct wilc_conn_info *conn_info;
int result;
u16 dummy_reason_code = 0;

@@ -900,7 +839,7 @@ int wilc_disconnect(struct wilc_vif *vif)
disconn_info.ie = NULL;
disconn_info.ie_len = 0;
scan_req = &hif_drv->usr_scan_req;
- conn_req = &hif_drv->usr_conn_req;
+ conn_info = &hif_drv->conn_info;

if (scan_req->scan_result) {
del_timer(&hif_drv->scan_timer);
@@ -908,12 +847,12 @@ int wilc_disconnect(struct wilc_vif *vif)
scan_req->scan_result = NULL;
}

- if (conn_req->conn_result) {
+ if (conn_info->conn_result) {
if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP)
del_timer(&hif_drv->connect_timer);

- conn_req->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
- 0, &disconn_info, conn_req->arg);
+ conn_info->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
+ 0, &disconn_info, conn_info->arg);
} else {
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
}
@@ -922,14 +861,9 @@ int wilc_disconnect(struct wilc_vif *vif)

eth_zero_addr(hif_drv->assoc_bssid);

- conn_req->ssid_len = 0;
- kfree(conn_req->ssid);
- conn_req->ssid = NULL;
- kfree(conn_req->bssid);
- conn_req->bssid = NULL;
- conn_req->ies_len = 0;
- kfree(conn_req->ies);
- conn_req->ies = NULL;
+ conn_info->req_ies_len = 0;
+ kfree(conn_info->req_ies);
+ conn_info->req_ies = NULL;

return 0;
}
@@ -1546,61 +1480,22 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
return result;
}

-int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
- size_t ssid_len, const u8 *ies, size_t ies_len,
- wilc_connect_result connect_result, void *user_arg,
- u8 security, enum authtype auth_type,
- u8 channel, void *join_params)
+int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
+ size_t ies_len)
{
int result;
struct host_if_drv *hif_drv = vif->hif_drv;
- struct user_conn_req *con_info = &hif_drv->usr_conn_req;
+ struct wilc_conn_info *conn_info = &hif_drv->conn_info;

- if (!hif_drv || !connect_result) {
- netdev_err(vif->ndev,
- "%s: hif driver or connect result is NULL",
- __func__);
- return -EFAULT;
- }
-
- if (!join_params) {
- netdev_err(vif->ndev, "%s: joinparams is NULL\n", __func__);
- return -EFAULT;
- }
-
- if (hif_drv->usr_scan_req.scan_result) {
- netdev_err(vif->ndev, "%s: Scan in progress\n", __func__);
- return -EBUSY;
- }
-
- con_info->security = security;
- con_info->auth_type = auth_type;
- con_info->ch = channel;
- con_info->conn_result = connect_result;
- con_info->arg = user_arg;
- con_info->param = join_params;
-
- if (bssid) {
- con_info->bssid = kmemdup(bssid, 6, GFP_KERNEL);
- if (!con_info->bssid)
- return -ENOMEM;
- }
-
- if (ssid) {
- con_info->ssid_len = ssid_len;
- con_info->ssid = kmemdup(ssid, ssid_len, GFP_KERNEL);
- if (!con_info->ssid) {
- result = -ENOMEM;
- goto free_bssid;
- }
- }
+ if (bssid)
+ ether_addr_copy(conn_info->bssid, bssid);

if (ies) {
- con_info->ies_len = ies_len;
- con_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
- if (!con_info->ies) {
+ conn_info->req_ies_len = ies_len;
+ conn_info->req_ies = kmemdup(ies, ies_len, GFP_KERNEL);
+ if (!conn_info->req_ies) {
result = -ENOMEM;
- goto free_ssid;
+ return result;
}
}

@@ -1615,13 +1510,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
return 0;

free_ies:
- kfree(con_info->ies);
-
-free_ssid:
- kfree(con_info->ssid);
-
-free_bssid:
- kfree(con_info->bssid);
+ kfree(conn_info->req_ies);

return result;
}
@@ -1963,7 +1852,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length)
return;
}

- if (!hif_drv->usr_conn_req.conn_result) {
+ if (!hif_drv->conn_info.conn_result) {
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
mutex_unlock(&hif_deinit_lock);
return;
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index e702404..459a084 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -35,15 +35,6 @@ enum {

#define WILC_MAX_ASSOC_RESP_FRAME_SIZE 256

-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;
@@ -122,12 +113,6 @@ struct wilc_rcvd_net_info {
typedef void (*wilc_scan_result)(enum scan_event, struct wilc_rcvd_net_info *,
void *);

-typedef void (*wilc_connect_result)(enum conn_event,
- struct connect_info *,
- u8,
- struct disconnect_info *,
- void *);
-
typedef void (*wilc_remain_on_chan_expired)(void *, u32);
typedef void (*wilc_remain_on_chan_ready)(void *);

@@ -148,17 +133,18 @@ struct user_scan_req {
u32 ch_cnt;
};

-struct user_conn_req {
- u8 *bssid;
- u8 *ssid;
+struct wilc_conn_info {
+ u8 bssid[ETH_ALEN];
u8 security;
enum authtype auth_type;
- size_t ssid_len;
- u8 *ies;
- size_t ies_len;
- wilc_connect_result conn_result;
- bool ht_capable;
u8 ch;
+ u8 *req_ies;
+ size_t req_ies_len;
+ 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 *arg;
void *param;
};
@@ -175,7 +161,7 @@ struct remain_ch {
struct wilc;
struct host_if_drv {
struct user_scan_req usr_scan_req;
- struct user_conn_req usr_conn_req;
+ struct wilc_conn_info conn_info;
struct remain_ch remain_on_ch;
u8 remain_on_ch_pending;
u64 p2p_timeout;
@@ -228,11 +214,8 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
u8 cipher_mode);
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 wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
- size_t ssid_len, const u8 *ies, size_t ies_len,
- wilc_connect_result connect_result, void *user_arg,
- u8 security, enum authtype auth_type,
- u8 channel, void *join_params);
+int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
+ size_t ies_len);
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);
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 1762c60..bc1d7a7 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -139,9 +139,7 @@ static void cfg_scan_result(enum scan_event scan_event,
}
}

-static void cfg_connect_result(enum conn_event conn_disconn_evt,
- struct connect_info *conn_info,
- u8 mac_status,
+static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status,
struct disconnect_info *disconn_info,
void *priv_data)
{
@@ -150,16 +148,15 @@ 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;
+ struct wilc_conn_info *conn_info = &wfi_drv->conn_info;

vif->connecting = false;

if (conn_disconn_evt == CONN_DISCONN_EVENT_CONN_RESP) {
- u16 connect_status;
-
- connect_status = conn_info->status;
+ u16 connect_status = conn_info->status;

if (mac_status == WILC_MAC_STATUS_DISCONNECTED &&
- conn_info->status == WLAN_STATUS_SUCCESS) {
+ connect_status == WLAN_STATUS_SUCCESS) {
connect_status = WLAN_STATUS_UNSPECIFIED_FAILURE;
wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE);

@@ -410,6 +407,12 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
auth_type = WILC_FW_AUTH_IEEE8021;
}

+ if (wfi_drv->usr_scan_req.scan_result) {
+ netdev_err(vif->ndev, "%s: Scan in progress\n", __func__);
+ ret = -EBUSY;
+ goto out_error;
+ }
+
bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid, sme->ssid,
sme->ssid_len, IEEE80211_BSS_TYPE_ANY,
IEEE80211_PRIVACY(sme->privacy));
@@ -438,16 +441,21 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,

wilc_wlan_set_bssid(dev, bss->bssid, WILC_STATION_MODE);

- ret = wilc_set_join_req(vif, bss->bssid, sme->ssid,
- sme->ssid_len, sme->ie, sme->ie_len,
- cfg_connect_result, (void *)priv,
- security, auth_type, curr_channel, join_params);
+ wfi_drv->conn_info.security = security;
+ wfi_drv->conn_info.auth_type = auth_type;
+ wfi_drv->conn_info.ch = curr_channel;
+ wfi_drv->conn_info.conn_result = cfg_connect_result;
+ wfi_drv->conn_info.arg = priv;
+ wfi_drv->conn_info.param = join_params;
+
+ ret = wilc_set_join_req(vif, bss->bssid, sme->ie, sme->ie_len);
if (ret) {
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, WILC_STATION_MODE);
+ wfi_drv->conn_info.conn_result = NULL;
kfree(join_params);
goto out_put_bss;
}
--
2.7.4


2019-01-17 13:21:42

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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

Signed-off-by: Ajay Singh <[email protected]>
---
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_CHANNEL 100

-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


2019-01-17 13:21:42

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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 <[email protected]>
---
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_network *hidden_network);
+ 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);
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 5070cad..1762c60 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -221,22 +221,23 @@ static int set_channel(struct wiphy *wiphy,

static inline int
wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request *request,
- struct hidden_network *ntwk)
+ struct wilc_probe_ssid *search)
{
int i;
int slot_id = 0;

- ntwk->net_info = kcalloc(request->n_ssids, sizeof(*ntwk->net_info),
- GFP_KERNEL);
- if (!ntwk->net_info)
+ search->ssid_info = kcalloc(request->n_ssids,
+ sizeof(*search->ssid_info), GFP_KERNEL);
+ if (!search->ssid_info)
goto out;

- ntwk->n_ssids = request->n_ssids;
+ search->n_ssids = request->n_ssids;

for (i = 0; i < request->n_ssids; i++) {
if (request->ssids[i].ssid_len > 0) {
- struct hidden_net_info *info = &ntwk->net_info[slot_id];
+ struct wilc_probe_ssid_info *info;

+ info = &search->ssid_info[slot_id];
info->ssid = kmemdup(request->ssids[i].ssid,
request->ssids[i].ssid_len,
GFP_KERNEL);
@@ -246,7 +247,7 @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request *request,
info->ssid_len = request->ssids[i].ssid_len;
slot_id++;
} else {
- ntwk->n_ssids -= 1;
+ search->n_ssids -= 1;
}
}
return 0;
@@ -254,9 +255,9 @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request *request,
out_free:

for (i = 0; i < slot_id; i++)
- kfree(ntwk->net_info[i].ssid);
+ kfree(search->ssid_info[i].ssid);

- kfree(ntwk->net_info);
+ kfree(search->ssid_info);
out:

return -ENOMEM;
@@ -269,7 +270,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
u32 i;
int ret = 0;
u8 scan_ch_list[MAX_NUM_SCANNED_NETWORKS];
- struct hidden_network hidden_ntwk;
+ struct wilc_probe_ssid probe_ssid;

priv->scan_req = request;

@@ -283,7 +284,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)

if (request->n_ssids >= 1) {
if (wilc_wfi_cfg_alloc_fill_ssid(request,
- &hidden_ntwk)) {
+ &probe_ssid)) {
ret = -ENOMEM;
goto out;
}
@@ -293,7 +294,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
request->n_channels,
(const u8 *)request->ie,
request->ie_len, cfg_scan_result,
- (void *)priv, &hidden_ntwk);
+ (void *)priv, &probe_ssid);
} else {
ret = wilc_scan(vif, WILC_FW_USER_SCAN,
WILC_FW_ACTIVE_SCAN, scan_ch_list,
--
2.7.4


2019-01-17 13:21:43

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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

Signed-off-by: Ajay Singh <[email protected]>
---
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
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -140,7 +140,6 @@ static void cfg_scan_result(enum scan_event scan_event,
}

static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status,
- struct disconnect_info *disconn_info,
void *priv_data)
{
struct wilc_priv *priv = priv_data;
@@ -177,6 +176,8 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status,
conn_info->resp_ies_len, connect_status,
GFP_KERNEL);
} else if (conn_disconn_evt == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
+ u16 reason = 0;
+
vif->obtaining_ip = false;
priv->p2p.local_random = 0x01;
priv->p2p.recv_random = 0x00;
@@ -186,14 +187,13 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status,

if (!wfi_drv->p2p_connect)
wlan_channel = INVALID_CHANNEL;
+
if (wfi_drv->ifc_up && dev == wl->vif[1]->ndev)
- disconn_info->reason = 3;
+ reason = 3;
else if (!wfi_drv->ifc_up && dev == wl->vif[1]->ndev)
- disconn_info->reason = 1;
+ reason = 1;

- cfg80211_disconnected(dev, disconn_info->reason,
- disconn_info->ie, disconn_info->ie_len,
- false, GFP_KERNEL);
+ cfg80211_disconnected(dev, reason, NULL, 0, false, GFP_KERNEL);
}
}

--
2.7.4


2019-01-17 13:21:46

by Ajay Singh

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

From: Ajay Singh <[email protected]>

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

Signed-off-by: Ajay Singh <[email protected]>
---
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/wilc1000/linux_wlan.c
@@ -811,12 +811,12 @@ static void wilc_set_multicast_list(struct net_device *dev)

if (dev->flags & IFF_ALLMULTI ||
dev->mc.count > WILC_MULTICAST_TABLE_SIZE) {
- wilc_setup_multicast_filter(vif, false, 0, NULL);
+ wilc_setup_multicast_filter(vif, 0, 0, NULL);
return;
}

if (dev->mc.count == 0) {
- wilc_setup_multicast_filter(vif, true, 0, NULL);
+ wilc_setup_multicast_filter(vif, 1, 0, NULL);
return;
}

@@ -833,7 +833,7 @@ static void wilc_set_multicast_list(struct net_device *dev)
cur_mc += ETH_ALEN;
}

- if (wilc_setup_multicast_filter(vif, true, dev->mc.count, mc_list))
+ if (wilc_setup_multicast_filter(vif, 1, dev->mc.count, mc_list))
kfree(mc_list);
}

--
2.7.4


2019-01-17 13:21:48

by Ajay Singh

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

From: Ajay Singh <[email protected]>

Remove typedef for function pointers.

Signed-off-by: Ajay Singh <[email protected]>
---
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, u16 frame_type, bool reg);
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index 16b6c55..9d3aaae 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -274,7 +274,8 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer,
}

int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
- u32 buffer_size, wilc_tx_complete_func_t func)
+ u32 buffer_size,
+ void (*tx_complete_fn)(void *, int))
{
struct txq_entry_t *tqe;
struct wilc_vif *vif = netdev_priv(dev);
@@ -292,7 +293,7 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
tqe->type = WILC_NET_PKT;
tqe->buffer = buffer;
tqe->buffer_size = buffer_size;
- tqe->tx_complete_func = func;
+ tqe->tx_complete_func = tx_complete_fn;
tqe->priv = priv;

tqe->ack_idx = NOT_TCP_ACK;
@@ -303,7 +304,8 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
}

int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
- u32 buffer_size, wilc_tx_complete_func_t func)
+ u32 buffer_size,
+ void (*tx_complete_fn)(void *, int))
{
struct txq_entry_t *tqe;
struct wilc_vif *vif = netdev_priv(dev);
@@ -321,7 +323,7 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
tqe->type = WILC_MGMT_PKT;
tqe->buffer = buffer;
tqe->buffer_size = buffer_size;
- tqe->tx_complete_func = func;
+ tqe->tx_complete_func = tx_complete_fn;
tqe->priv = priv;
tqe->ack_idx = NOT_TCP_ACK;
wilc_wlan_txq_add_to_tail(dev, tqe);
diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h
index c8ca13b..3880452 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -275,7 +275,8 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
int wilc_wlan_start(struct wilc *wilc);
int wilc_wlan_stop(struct wilc *wilc);
int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
- u32 buffer_size, wilc_tx_complete_func_t func);
+ u32 buffer_size,
+ void (*tx_complete_fn)(void *, int));
int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count);
void wilc_handle_isr(struct wilc *wilc);
void wilc_wlan_cleanup(struct net_device *dev);
@@ -286,7 +287,7 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit,
int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer,
u32 buffer_size);
int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
- u32 buffer_size, wilc_tx_complete_func_t func);
+ u32 buffer_size, void (*func)(void *, int));
void wilc_chip_sleep_manually(struct wilc *wilc);

void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value);
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h
index 961b6bb..9370caa 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -39,8 +39,6 @@ struct tx_complete_data {
struct sk_buff *skb;
};

-typedef void (*wilc_tx_complete_func_t)(void *, int);
-
/********************************************
*
* Wlan Configuration ID
--
2.7.4


2019-01-18 09:41:52

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 00/13] staging: wilc1000: address few mainline review

On Thu, Jan 17, 2019 at 01:21:06PM +0000, [email protected] wrote:
> From: Ajay Singh <[email protected]>
>
> 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(-)

Nice set of cleanups!

all applied, thanks.

greg k-h

2019-01-21 13:14:33

by Dan Carpenter

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

On Thu, Jan 17, 2019 at 01:21:10PM +0000, [email protected] wrote:
> From: Ajay Singh <[email protected]>
>
> Make use of get_unaligned_le16/le32 framework api's to pack data.
>
> Signed-off-by: Ajay Singh <[email protected]>
> ---
> 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];

Not related to this patch, but so far as I can see, length can't be zero
but there is nothing preventing if from being less than four so this
could be reading from buffer[-3].

regards,
dan carpenter