Skip to content

Commit 38c9d66

Browse files
Amitkumar Karwarlinvjw
authored andcommitted
mwifiex: remove cfg_workqueue
cfg_workqueue was added to notify cfg80211 that scan, connect or disconnect is done by calling respective completion handlers. We can avoid use of this workqueue by calling those handlers from other places. 1) Call connect, disconnect completion handlers in their callback functions. ex. Call cfg80211_connect_result() in mwifiex_cfg80211_connect() 2) Call scan completion handler after parsing response of last scan command in a queue. After removing the workqueue, variables (assoc_request etc.) and checks used for mutual exclusion become redundant. Those are also removed in this patch. Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Yogesh Ashok Powar <yogeshp@marvell.com> Signed-off-by: Nishant Sarmukadam <nishants@marvell.com> Signed-off-by: Kiran Divekar <dkiran@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 00918d3 commit 38c9d66

6 files changed

Lines changed: 75 additions & 158 deletions

File tree

‎drivers/net/wireless/mwifiex/cfg80211.c‎

Lines changed: 57 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -751,17 +751,13 @@ mwifiex_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev,
751751
{
752752
struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
753753

754-
if (priv->disconnect)
755-
return -EBUSY;
756-
757-
priv->disconnect = 1;
758754
if (mwifiex_deauthenticate(priv, NULL))
759755
return -EFAULT;
760756

761757
wiphy_dbg(wiphy, "info: successfully disconnected from %pM:"
762758
" reason code %d\n", priv->cfg_bssid, reason_code);
763759

764-
queue_work(priv->workqueue, &priv->cfg_workqueue);
760+
memset(priv->cfg_bssid, 0, ETH_ALEN);
765761

766762
return 0;
767763
}
@@ -981,27 +977,32 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
981977
struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
982978
int ret = 0;
983979

984-
if (priv->assoc_request)
985-
return -EBUSY;
986-
987980
if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
988981
wiphy_err(wiphy, "received infra assoc request "
989982
"when station is in ibss mode\n");
990983
goto done;
991984
}
992985

993-
priv->assoc_request = -EINPROGRESS;
994-
995986
wiphy_dbg(wiphy, "info: Trying to associate to %s and bssid %pM\n",
996987
(char *) sme->ssid, sme->bssid);
997988

998989
ret = mwifiex_cfg80211_assoc(priv, sme->ssid_len, sme->ssid, sme->bssid,
999990
priv->bss_mode, sme->channel, sme, 0);
1000-
1001-
priv->assoc_request = 1;
1002991
done:
1003-
priv->assoc_result = ret;
1004-
queue_work(priv->workqueue, &priv->cfg_workqueue);
992+
if (!ret) {
993+
cfg80211_connect_result(priv->netdev, priv->cfg_bssid, NULL, 0,
994+
NULL, 0, WLAN_STATUS_SUCCESS,
995+
GFP_KERNEL);
996+
dev_dbg(priv->adapter->dev,
997+
"info: associated to bssid %pM successfully\n",
998+
priv->cfg_bssid);
999+
} else {
1000+
dev_dbg(priv->adapter->dev,
1001+
"info: association to bssid %pM failed\n",
1002+
priv->cfg_bssid);
1003+
memset(priv->cfg_bssid, 0, ETH_ALEN);
1004+
}
1005+
10051006
return ret;
10061007
}
10071008

@@ -1018,28 +1019,29 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
10181019
struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
10191020
int ret = 0;
10201021

1021-
if (priv->ibss_join_request)
1022-
return -EBUSY;
1023-
10241022
if (priv->bss_mode != NL80211_IFTYPE_ADHOC) {
10251023
wiphy_err(wiphy, "request to join ibss received "
10261024
"when station is not in ibss mode\n");
10271025
goto done;
10281026
}
10291027

1030-
priv->ibss_join_request = -EINPROGRESS;
1031-
10321028
wiphy_dbg(wiphy, "info: trying to join to %s and bssid %pM\n",
10331029
(char *) params->ssid, params->bssid);
10341030

10351031
ret = mwifiex_cfg80211_assoc(priv, params->ssid_len, params->ssid,
10361032
params->bssid, priv->bss_mode,
10371033
params->channel, NULL, params->privacy);
1038-
1039-
priv->ibss_join_request = 1;
10401034
done:
1041-
priv->ibss_join_result = ret;
1042-
queue_work(priv->workqueue, &priv->cfg_workqueue);
1035+
if (!ret) {
1036+
cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid, GFP_KERNEL);
1037+
dev_dbg(priv->adapter->dev,
1038+
"info: joined/created adhoc network with bssid"
1039+
" %pM successfully\n", priv->cfg_bssid);
1040+
} else {
1041+
dev_dbg(priv->adapter->dev,
1042+
"info: failed creating/joining adhoc network\n");
1043+
}
1044+
10431045
return ret;
10441046
}
10451047

@@ -1054,17 +1056,12 @@ mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
10541056
{
10551057
struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
10561058

1057-
if (priv->disconnect)
1058-
return -EBUSY;
1059-
1060-
priv->disconnect = 1;
1061-
10621059
wiphy_dbg(wiphy, "info: disconnecting from essid %pM\n",
10631060
priv->cfg_bssid);
10641061
if (mwifiex_deauthenticate(priv, NULL))
10651062
return -EFAULT;
10661063

1067-
queue_work(priv->workqueue, &priv->cfg_workqueue);
1064+
memset(priv->cfg_bssid, 0, ETH_ALEN);
10681065

10691066
return 0;
10701067
}
@@ -1081,15 +1078,42 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev,
10811078
struct cfg80211_scan_request *request)
10821079
{
10831080
struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
1081+
int i;
1082+
struct ieee80211_channel *chan;
10841083

10851084
wiphy_dbg(wiphy, "info: received scan request on %s\n", dev->name);
10861085

1087-
if (priv->scan_request && priv->scan_request != request)
1088-
return -EBUSY;
1089-
10901086
priv->scan_request = request;
10911087

1092-
queue_work(priv->workqueue, &priv->cfg_workqueue);
1088+
priv->user_scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg),
1089+
GFP_KERNEL);
1090+
if (!priv->user_scan_cfg) {
1091+
dev_err(priv->adapter->dev, "failed to alloc scan_req\n");
1092+
return -ENOMEM;
1093+
}
1094+
for (i = 0; i < request->n_ssids; i++) {
1095+
memcpy(priv->user_scan_cfg->ssid_list[i].ssid,
1096+
request->ssids[i].ssid, request->ssids[i].ssid_len);
1097+
priv->user_scan_cfg->ssid_list[i].max_len =
1098+
request->ssids[i].ssid_len;
1099+
}
1100+
for (i = 0; i < request->n_channels; i++) {
1101+
chan = request->channels[i];
1102+
priv->user_scan_cfg->chan_list[i].chan_number = chan->hw_value;
1103+
priv->user_scan_cfg->chan_list[i].radio_type = chan->band;
1104+
1105+
if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)
1106+
priv->user_scan_cfg->chan_list[i].scan_type =
1107+
MWIFIEX_SCAN_TYPE_PASSIVE;
1108+
else
1109+
priv->user_scan_cfg->chan_list[i].scan_type =
1110+
MWIFIEX_SCAN_TYPE_ACTIVE;
1111+
1112+
priv->user_scan_cfg->chan_list[i].scan_time = 0;
1113+
}
1114+
if (mwifiex_set_user_scan_ioctl(priv, priv->user_scan_cfg))
1115+
return -EFAULT;
1116+
10931117
return 0;
10941118
}
10951119

@@ -1295,10 +1319,6 @@ int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev)
12951319

12961320
priv->media_connected = false;
12971321

1298-
cancel_work_sync(&priv->cfg_workqueue);
1299-
flush_workqueue(priv->workqueue);
1300-
destroy_workqueue(priv->workqueue);
1301-
13021322
priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED;
13031323

13041324
return 0;
@@ -1404,100 +1424,3 @@ int mwifiex_register_cfg80211(struct mwifiex_private *priv)
14041424

14051425
return ret;
14061426
}
1407-
1408-
/*
1409-
* This function handles the result of different pending network operations.
1410-
*
1411-
* The following operations are handled and CFG802.11 subsystem is
1412-
* notified accordingly -
1413-
* - Scan request completion
1414-
* - Association request completion
1415-
* - IBSS join request completion
1416-
* - Disconnect request completion
1417-
*/
1418-
void
1419-
mwifiex_cfg80211_results(struct work_struct *work)
1420-
{
1421-
struct mwifiex_private *priv =
1422-
container_of(work, struct mwifiex_private, cfg_workqueue);
1423-
struct mwifiex_user_scan_cfg *scan_req;
1424-
int ret = 0, i;
1425-
struct ieee80211_channel *chan;
1426-
1427-
if (priv->scan_request) {
1428-
scan_req = kzalloc(sizeof(struct mwifiex_user_scan_cfg),
1429-
GFP_KERNEL);
1430-
if (!scan_req) {
1431-
dev_err(priv->adapter->dev, "failed to alloc "
1432-
"scan_req\n");
1433-
return;
1434-
}
1435-
for (i = 0; i < priv->scan_request->n_ssids; i++) {
1436-
memcpy(scan_req->ssid_list[i].ssid,
1437-
priv->scan_request->ssids[i].ssid,
1438-
priv->scan_request->ssids[i].ssid_len);
1439-
scan_req->ssid_list[i].max_len =
1440-
priv->scan_request->ssids[i].ssid_len;
1441-
}
1442-
for (i = 0; i < priv->scan_request->n_channels; i++) {
1443-
chan = priv->scan_request->channels[i];
1444-
scan_req->chan_list[i].chan_number = chan->hw_value;
1445-
scan_req->chan_list[i].radio_type = chan->band;
1446-
if (chan->flags & IEEE80211_CHAN_DISABLED)
1447-
scan_req->chan_list[i].scan_type =
1448-
MWIFIEX_SCAN_TYPE_PASSIVE;
1449-
else
1450-
scan_req->chan_list[i].scan_type =
1451-
MWIFIEX_SCAN_TYPE_ACTIVE;
1452-
scan_req->chan_list[i].scan_time = 0;
1453-
}
1454-
if (mwifiex_set_user_scan_ioctl(priv, scan_req))
1455-
ret = -EFAULT;
1456-
priv->scan_result_status = ret;
1457-
dev_dbg(priv->adapter->dev, "info: %s: sending scan results\n",
1458-
__func__);
1459-
cfg80211_scan_done(priv->scan_request,
1460-
(priv->scan_result_status < 0));
1461-
priv->scan_request = NULL;
1462-
kfree(scan_req);
1463-
}
1464-
1465-
if (priv->assoc_request == 1) {
1466-
if (!priv->assoc_result) {
1467-
cfg80211_connect_result(priv->netdev, priv->cfg_bssid,
1468-
NULL, 0, NULL, 0,
1469-
WLAN_STATUS_SUCCESS,
1470-
GFP_KERNEL);
1471-
dev_dbg(priv->adapter->dev,
1472-
"info: associated to bssid %pM successfully\n",
1473-
priv->cfg_bssid);
1474-
} else {
1475-
dev_dbg(priv->adapter->dev,
1476-
"info: association to bssid %pM failed\n",
1477-
priv->cfg_bssid);
1478-
memset(priv->cfg_bssid, 0, ETH_ALEN);
1479-
}
1480-
priv->assoc_request = 0;
1481-
priv->assoc_result = 0;
1482-
}
1483-
1484-
if (priv->ibss_join_request == 1) {
1485-
if (!priv->ibss_join_result) {
1486-
cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid,
1487-
GFP_KERNEL);
1488-
dev_dbg(priv->adapter->dev,
1489-
"info: joined/created adhoc network with bssid"
1490-
" %pM successfully\n", priv->cfg_bssid);
1491-
} else {
1492-
dev_dbg(priv->adapter->dev,
1493-
"info: failed creating/joining adhoc network\n");
1494-
}
1495-
priv->ibss_join_request = 0;
1496-
priv->ibss_join_result = 0;
1497-
}
1498-
1499-
if (priv->disconnect) {
1500-
memset(priv->cfg_bssid, 0, ETH_ALEN);
1501-
priv->disconnect = 0;
1502-
}
1503-
}

‎drivers/net/wireless/mwifiex/cfg80211.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@
2626

2727
int mwifiex_register_cfg80211(struct mwifiex_private *);
2828

29-
void mwifiex_cfg80211_results(struct work_struct *work);
3029
#endif

‎drivers/net/wireless/mwifiex/main.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,6 @@ void mwifiex_init_priv_params(struct mwifiex_private *priv,
586586
priv->media_connected = false;
587587
memset(&priv->nick_name, 0, sizeof(priv->nick_name));
588588
priv->num_tx_timeout = 0;
589-
priv->workqueue = create_singlethread_workqueue("cfg80211_wq");
590-
INIT_WORK(&priv->cfg_workqueue, mwifiex_cfg80211_results);
591589
memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN);
592590
}
593591

‎drivers/net/wireless/mwifiex/main.h‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,8 @@ struct mwifiex_private {
453453
u8 scan_pending_on_block;
454454
u8 report_scan_result;
455455
struct cfg80211_scan_request *scan_request;
456-
int scan_result_status;
457-
int assoc_request;
458-
u16 assoc_result;
459-
int ibss_join_request;
460-
u16 ibss_join_result;
461-
bool disconnect;
456+
struct mwifiex_user_scan_cfg *user_scan_cfg;
462457
u8 cfg_bssid[6];
463-
struct workqueue_struct *workqueue;
464-
struct work_struct cfg_workqueue;
465458
u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
466459
struct wps wps;
467460
u8 scan_block;

‎drivers/net/wireless/mwifiex/scan.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,11 +1391,8 @@ int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
13911391
{
13921392
int status;
13931393

1394-
priv->adapter->scan_wait_q_woken = false;
1395-
13961394
status = mwifiex_scan_networks(priv, scan_req);
1397-
if (!status)
1398-
status = mwifiex_wait_queue_complete(priv->adapter);
1395+
queue_work(priv->adapter->workqueue, &priv->adapter->main_work);
13991396

14001397
return status;
14011398
}
@@ -1796,6 +1793,14 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
17961793
up(&priv->async_sem);
17971794
}
17981795

1796+
if (priv->user_scan_cfg) {
1797+
dev_dbg(priv->adapter->dev, "info: %s: sending scan "
1798+
"results\n", __func__);
1799+
cfg80211_scan_done(priv->scan_request, 0);
1800+
priv->scan_request = NULL;
1801+
kfree(priv->user_scan_cfg);
1802+
priv->user_scan_cfg = NULL;
1803+
}
17991804
} else {
18001805
/* Get scan command from scan_pending_q and put to
18011806
cmd_pending_q */

‎drivers/net/wireless/mwifiex/sta_event.c‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,15 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv)
115115
if (adapter->num_cmd_timeout && adapter->curr_cmd)
116116
return;
117117
priv->media_connected = false;
118-
if (!priv->disconnect) {
119-
priv->disconnect = 1;
120-
dev_dbg(adapter->dev, "info: successfully disconnected from"
121-
" %pM: reason code %d\n", priv->cfg_bssid,
122-
WLAN_REASON_DEAUTH_LEAVING);
123-
cfg80211_disconnected(priv->netdev,
124-
WLAN_REASON_DEAUTH_LEAVING, NULL, 0,
125-
GFP_KERNEL);
126-
queue_work(priv->workqueue, &priv->cfg_workqueue);
118+
dev_dbg(adapter->dev, "info: successfully disconnected from"
119+
" %pM: reason code %d\n", priv->cfg_bssid,
120+
WLAN_REASON_DEAUTH_LEAVING);
121+
if (priv->bss_mode == NL80211_IFTYPE_STATION) {
122+
cfg80211_disconnected(priv->netdev, WLAN_REASON_DEAUTH_LEAVING,
123+
NULL, 0, GFP_KERNEL);
127124
}
125+
memset(priv->cfg_bssid, 0, ETH_ALEN);
126+
128127
if (!netif_queue_stopped(priv->netdev))
129128
mwifiex_stop_net_dev_queue(priv->netdev, adapter);
130129
if (netif_carrier_ok(priv->netdev))

0 commit comments

Comments
 (0)