Skip to content

Commit 64a0b4c

Browse files
committed
wilc1000: move add & edit station WID to work queue
Move add and edit station WID handling to worker thread to avoid assocaition timeout issue which is observed sometime in AP mode. Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
1 parent 7d1f802 commit 64a0b4c

1 file changed

Lines changed: 137 additions & 30 deletions

File tree

  • drivers/net/wireless/microchip/wilc1000

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

Lines changed: 137 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ struct wilc_del_all_sta {
7979
u8 mac[WILC_MAX_NUM_STA][ETH_ALEN];
8080
};
8181

82+
struct add_sta_param {
83+
u8 bssid[ETH_ALEN];
84+
u16 aid;
85+
u8 supported_rates_len;
86+
const u8 *supported_rates;
87+
bool ht_supported;
88+
struct ieee80211_ht_cap ht_capa;
89+
u16 flags_mask;
90+
u16 flags_set;
91+
};
92+
8293
union wilc_message_body {
8394
struct wilc_rcvd_net_info net_info;
8495
struct wilc_rcvd_mac_info mac_info;
@@ -90,6 +101,8 @@ union wilc_message_body {
90101
struct host_if_set_ant set_ant;
91102
struct tx_power tx_power;
92103
struct power_mgmt_param pwr_mgmt_info;
104+
struct add_sta_param add_sta_info;
105+
struct add_sta_param edit_sta_info;
93106
};
94107

95108
struct host_if_msg {
@@ -1022,10 +1035,9 @@ static void handle_get_statistics(struct work_struct *work)
10221035
kfree(msg);
10231036
}
10241037

1025-
static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac,
1026-
struct station_parameters *params)
1038+
static void wilc_hif_pack_sta_param(u8 *cur_byte, struct add_sta_param *params)
10271039
{
1028-
ether_addr_copy(cur_byte, mac);
1040+
ether_addr_copy(cur_byte, params->bssid);
10291041
cur_byte += ETH_ALEN;
10301042

10311043
put_unaligned_le16(params->aid, cur_byte);
@@ -1037,18 +1049,18 @@ static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac,
10371049
params->supported_rates_len);
10381050
cur_byte += params->supported_rates_len;
10391051

1040-
if (params->ht_capa) {
1052+
if (params->ht_supported) {
10411053
*cur_byte++ = true;
1042-
memcpy(cur_byte, params->ht_capa,
1054+
memcpy(cur_byte, &params->ht_capa,
10431055
sizeof(struct ieee80211_ht_cap));
10441056
} else {
10451057
*cur_byte++ = false;
10461058
}
10471059
cur_byte += sizeof(struct ieee80211_ht_cap);
10481060

1049-
put_unaligned_le16(params->sta_flags_mask, cur_byte);
1061+
put_unaligned_le16(params->flags_mask, cur_byte);
10501062
cur_byte += 2;
1051-
put_unaligned_le16(params->sta_flags_set, cur_byte);
1063+
put_unaligned_le16(params->flags_set, cur_byte);
10521064
}
10531065

10541066
static int handle_remain_on_chan(struct wilc_vif *vif,
@@ -2229,31 +2241,78 @@ int wilc_del_beacon(struct wilc_vif *vif)
22292241
return result;
22302242
}
22312243

2232-
int wilc_add_station(struct wilc_vif *vif, const u8 *mac,
2233-
struct station_parameters *params)
2244+
static void handle_add_station(struct work_struct *work)
22342245
{
2235-
struct wid wid;
2246+
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
2247+
struct wilc_vif *vif = msg->vif;
2248+
struct add_sta_param *params = &msg->body.add_sta_info;
22362249
int result;
2237-
u8 *cur_byte;
2238-
2239-
PRINT_INFO(vif->ndev, HOSTINF_DBG,
2240-
"Setting adding station message queue params\n");
2250+
struct wid wid;
22412251

22422252
wid.id = WID_ADD_STA;
22432253
wid.type = WID_BIN;
22442254
wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len;
2255+
PRINT_INFO(vif->ndev, HOSTINF_DBG, "Handling add station\n");
22452256
wid.val = kmalloc(wid.size, GFP_KERNEL);
22462257
if (!wid.val)
2247-
return -ENOMEM;
2258+
goto error;
22482259

2249-
cur_byte = wid.val;
2250-
wilc_hif_pack_sta_param(cur_byte, mac, params);
2260+
wilc_hif_pack_sta_param(wid.val, params);
22512261

22522262
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
2253-
if (result != 0)
2254-
netdev_err(vif->ndev, "Failed to send add station\n");
2263+
if (result)
2264+
PRINT_ER(vif->ndev, "Failed to send add station\n");
22552265

22562266
kfree(wid.val);
2267+
error:
2268+
kfree(params->supported_rates);
2269+
kfree(msg);
2270+
}
2271+
2272+
int wilc_add_station(struct wilc_vif *vif, const u8 *mac,
2273+
struct station_parameters *params)
2274+
{
2275+
int result;
2276+
struct host_if_msg *msg;
2277+
struct add_sta_param *sta_params;
2278+
2279+
PRINT_INFO(vif->ndev, HOSTINF_DBG,
2280+
"Setting adding station message queue params\n");
2281+
2282+
msg = wilc_alloc_work(vif, handle_add_station, false);
2283+
if (IS_ERR(msg))
2284+
return PTR_ERR(msg);
2285+
2286+
sta_params = &msg->body.add_sta_info;
2287+
memcpy(sta_params->bssid, mac, ETH_ALEN);
2288+
sta_params->aid = params->aid;
2289+
if (!params->ht_capa) {
2290+
sta_params->ht_supported = false;
2291+
} else {
2292+
sta_params->ht_supported = true;
2293+
memcpy(&sta_params->ht_capa, params->ht_capa,
2294+
sizeof(struct ieee80211_ht_cap));
2295+
}
2296+
sta_params->flags_mask = params->sta_flags_mask;
2297+
sta_params->flags_set = params->sta_flags_set;
2298+
2299+
sta_params->supported_rates_len = params->supported_rates_len;
2300+
if (params->supported_rates_len > 0) {
2301+
sta_params->supported_rates = kmemdup(params->supported_rates,
2302+
params->supported_rates_len,
2303+
GFP_KERNEL);
2304+
if (!sta_params->supported_rates) {
2305+
kfree(msg);
2306+
return -ENOMEM;
2307+
}
2308+
}
2309+
2310+
result = wilc_enqueue_work(msg);
2311+
if (result) {
2312+
PRINT_ER(vif->ndev, "enqueue work failed\n");
2313+
kfree(sta_params->supported_rates);
2314+
kfree(msg);
2315+
}
22572316

22582317
return result;
22592318
}
@@ -2330,31 +2389,79 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN])
23302389
return result;
23312390
}
23322391

2333-
int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
2334-
struct station_parameters *params)
2392+
static void handle_edit_station(struct work_struct *work)
23352393
{
2336-
struct wid wid;
2394+
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
2395+
struct wilc_vif *vif = msg->vif;
2396+
struct add_sta_param *params = &msg->body.edit_sta_info;
23372397
int result;
2338-
u8 *cur_byte;
2339-
2340-
PRINT_INFO(vif->ndev, HOSTINF_DBG,
2341-
"Setting editing station message queue params\n");
2398+
struct wid wid;
23422399

23432400
wid.id = WID_EDIT_STA;
23442401
wid.type = WID_BIN;
23452402
wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len;
2403+
PRINT_INFO(vif->ndev, HOSTINF_DBG, "Handling edit station\n");
23462404
wid.val = kmalloc(wid.size, GFP_KERNEL);
23472405
if (!wid.val)
2348-
return -ENOMEM;
2406+
goto error;
23492407

2350-
cur_byte = wid.val;
2351-
wilc_hif_pack_sta_param(cur_byte, mac, params);
2408+
wilc_hif_pack_sta_param(wid.val, params);
23522409

23532410
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
23542411
if (result)
2355-
netdev_err(vif->ndev, "Failed to send edit station\n");
2412+
PRINT_ER(vif->ndev, "Failed to send edit station\n");
23562413

23572414
kfree(wid.val);
2415+
error:
2416+
kfree(params->supported_rates);
2417+
kfree(msg);
2418+
}
2419+
2420+
int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
2421+
struct station_parameters *params)
2422+
{
2423+
int result;
2424+
struct host_if_msg *msg;
2425+
struct add_sta_param *sta_params;
2426+
2427+
PRINT_INFO(vif->ndev, HOSTINF_DBG,
2428+
"Setting editing station message queue params\n");
2429+
2430+
msg = wilc_alloc_work(vif, handle_edit_station, false);
2431+
if (IS_ERR(msg))
2432+
return PTR_ERR(msg);
2433+
2434+
sta_params = &msg->body.edit_sta_info;
2435+
memcpy(sta_params->bssid, mac, ETH_ALEN);
2436+
sta_params->aid = params->aid;
2437+
if (!params->ht_capa) {
2438+
sta_params->ht_supported = false;
2439+
} else {
2440+
sta_params->ht_supported = true;
2441+
memcpy(&sta_params->ht_capa, params->ht_capa,
2442+
sizeof(struct ieee80211_ht_cap));
2443+
}
2444+
sta_params->flags_mask = params->sta_flags_mask;
2445+
sta_params->flags_set = params->sta_flags_set;
2446+
2447+
sta_params->supported_rates_len = params->supported_rates_len;
2448+
if (params->supported_rates_len > 0) {
2449+
sta_params->supported_rates = kmemdup(params->supported_rates,
2450+
params->supported_rates_len,
2451+
GFP_KERNEL);
2452+
if (!sta_params->supported_rates) {
2453+
kfree(msg);
2454+
return -ENOMEM;
2455+
}
2456+
}
2457+
2458+
result = wilc_enqueue_work(msg);
2459+
if (result) {
2460+
PRINT_ER(vif->ndev, "enqueue work failed\n");
2461+
kfree(sta_params->supported_rates);
2462+
kfree(msg);
2463+
}
2464+
23582465
return result;
23592466
}
23602467

0 commit comments

Comments
 (0)