Commit e51ae9be authored by Arik Nemtsov's avatar Arik Nemtsov Committed by Luciano Coelho

wl12xx: use dynamic hlids for AP-mode

Using hlid=0 in AP mode is a bug. Dynamically allocate HLIDs.

Set the "first sta hlid" as 3. This will have to be changed
when multiple vifs will be supported.
Signed-off-by: default avatarArik Nemtsov <arik@wizery.com>
Signed-off-by: default avatarEliad Peller <eliad@wizery.com>
Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent 712e9bf7
...@@ -682,11 +682,19 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl) ...@@ -682,11 +682,19 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl)
goto out; goto out;
} }
ret = wl12xx_allocate_link(wl, &wl->ap_global_hlid);
if (ret < 0)
goto out_free;
ret = wl12xx_allocate_link(wl, &wl->ap_bcast_hlid);
if (ret < 0)
goto out_free_global;
cmd->role_id = wl->role_id; cmd->role_id = wl->role_id;
cmd->ap.aging_period = cpu_to_le16(wl->conf.tx.ap_aging_period); cmd->ap.aging_period = cpu_to_le16(wl->conf.tx.ap_aging_period);
cmd->ap.bss_index = WL1271_AP_BSS_INDEX; cmd->ap.bss_index = WL1271_AP_BSS_INDEX;
cmd->ap.global_hlid = WL1271_AP_GLOBAL_HLID; cmd->ap.global_hlid = wl->ap_global_hlid;
cmd->ap.broadcast_hlid = WL1271_AP_BROADCAST_HLID; cmd->ap.broadcast_hlid = wl->ap_bcast_hlid;
cmd->ap.basic_rate_set = cpu_to_le32(wl->basic_rate_set); cmd->ap.basic_rate_set = cpu_to_le32(wl->basic_rate_set);
cmd->ap.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->ap.beacon_interval = cpu_to_le16(wl->beacon_int);
cmd->ap.dtim_interval = bss_conf->dtim_period; cmd->ap.dtim_interval = bss_conf->dtim_period;
...@@ -713,9 +721,17 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl) ...@@ -713,9 +721,17 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl)
ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0); ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0);
if (ret < 0) { if (ret < 0) {
wl1271_error("failed to initiate cmd role start ap"); wl1271_error("failed to initiate cmd role start ap");
goto out_free; goto out_free_bcast;
} }
goto out_free;
out_free_bcast:
wl12xx_free_link(wl, &wl->ap_bcast_hlid);
out_free_global:
wl12xx_free_link(wl, &wl->ap_global_hlid);
out_free: out_free:
kfree(cmd); kfree(cmd);
...@@ -744,6 +760,9 @@ int wl12xx_cmd_role_stop_ap(struct wl1271 *wl) ...@@ -744,6 +760,9 @@ int wl12xx_cmd_role_stop_ap(struct wl1271 *wl)
goto out_free; goto out_free;
} }
wl12xx_free_link(wl, &wl->ap_bcast_hlid);
wl12xx_free_link(wl, &wl->ap_global_hlid);
out_free: out_free:
kfree(cmd); kfree(cmd);
...@@ -1253,7 +1272,7 @@ int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, ...@@ -1253,7 +1272,7 @@ int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
if (!cmd) if (!cmd)
return -ENOMEM; return -ENOMEM;
if (hlid == WL1271_AP_BROADCAST_HLID) { if (hlid == wl->ap_bcast_hlid) {
if (key_type == KEY_WEP) if (key_type == KEY_WEP)
lid_type = WEP_DEFAULT_LID_TYPE; lid_type = WEP_DEFAULT_LID_TYPE;
else else
......
...@@ -1972,8 +1972,11 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, ...@@ -1972,8 +1972,11 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl,
wl1271_ps_elp_sleep(wl); wl1271_ps_elp_sleep(wl);
} }
deinit: deinit:
/* clear all hlids (except system_hlid) */
wl->sta_hlid = WL12XX_INVALID_LINK_ID; wl->sta_hlid = WL12XX_INVALID_LINK_ID;
wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->dev_hlid = WL12XX_INVALID_LINK_ID;
wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID;
wl->ap_global_hlid = WL12XX_INVALID_LINK_ID;
/* /*
* this must be before the cancel_work calls below, so that the work * this must be before the cancel_work calls below, so that the work
...@@ -2538,7 +2541,7 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl) ...@@ -2538,7 +2541,7 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl)
if (wep_key_added) { if (wep_key_added) {
ret = wl12xx_cmd_set_default_wep_key(wl, wl->default_key, ret = wl12xx_cmd_set_default_wep_key(wl, wl->default_key,
WL1271_AP_BROADCAST_HLID); wl->ap_bcast_hlid);
if (ret < 0) if (ret < 0)
goto out; goto out;
} }
...@@ -2563,7 +2566,7 @@ static int wl1271_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, ...@@ -2563,7 +2566,7 @@ static int wl1271_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
wl_sta = (struct wl1271_station *)sta->drv_priv; wl_sta = (struct wl1271_station *)sta->drv_priv;
hlid = wl_sta->hlid; hlid = wl_sta->hlid;
} else { } else {
hlid = WL1271_AP_BROADCAST_HLID; hlid = wl->ap_bcast_hlid;
} }
if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) {
...@@ -4449,6 +4452,8 @@ struct ieee80211_hw *wl1271_alloc_hw(void) ...@@ -4449,6 +4452,8 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
wl->dev_role_id = WL12XX_INVALID_ROLE_ID; wl->dev_role_id = WL12XX_INVALID_ROLE_ID;
wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->dev_hlid = WL12XX_INVALID_LINK_ID;
wl->session_counter = 0; wl->session_counter = 0;
wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID;
wl->ap_global_hlid = WL12XX_INVALID_LINK_ID;
setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer,
(unsigned long) wl); (unsigned long) wl);
wl->fwlog_size = 0; wl->fwlog_size = 0;
......
...@@ -38,7 +38,7 @@ static int wl1271_set_default_wep_key(struct wl1271 *wl, u8 id) ...@@ -38,7 +38,7 @@ static int wl1271_set_default_wep_key(struct wl1271 *wl, u8 id)
if (is_ap) if (is_ap)
ret = wl12xx_cmd_set_default_wep_key(wl, id, ret = wl12xx_cmd_set_default_wep_key(wl, id,
WL1271_AP_BROADCAST_HLID); wl->ap_bcast_hlid);
else else
ret = wl12xx_cmd_set_default_wep_key(wl, id, wl->sta_hlid); ret = wl12xx_cmd_set_default_wep_key(wl, id, wl->sta_hlid);
...@@ -168,9 +168,9 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct sk_buff *skb) ...@@ -168,9 +168,9 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct sk_buff *skb)
hdr = (struct ieee80211_hdr *)skb->data; hdr = (struct ieee80211_hdr *)skb->data;
if (ieee80211_is_mgmt(hdr->frame_control)) if (ieee80211_is_mgmt(hdr->frame_control))
return WL1271_AP_GLOBAL_HLID; return wl->ap_global_hlid;
else else
return WL1271_AP_BROADCAST_HLID; return wl->ap_bcast_hlid;
} }
} }
...@@ -317,17 +317,12 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, ...@@ -317,17 +317,12 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb,
else else
rate_idx = ACX_TX_BASIC_RATE; rate_idx = ACX_TX_BASIC_RATE;
} else { } else {
switch (hlid) { if (hlid == wl->ap_global_hlid)
case WL1271_AP_GLOBAL_HLID:
rate_idx = ACX_TX_AP_MODE_MGMT_RATE; rate_idx = ACX_TX_AP_MODE_MGMT_RATE;
break; else if (hlid == wl->ap_bcast_hlid)
case WL1271_AP_BROADCAST_HLID:
rate_idx = ACX_TX_AP_MODE_BCST_RATE; rate_idx = ACX_TX_AP_MODE_BCST_RATE;
break; else
default:
rate_idx = ac; rate_idx = ac;
break;
}
} }
tx_attr |= rate_idx << TX_HW_ATTR_OFST_RATE_POLICY; tx_attr |= rate_idx << TX_HW_ATTR_OFST_RATE_POLICY;
......
...@@ -141,10 +141,15 @@ extern u32 wl12xx_debug_level; ...@@ -141,10 +141,15 @@ extern u32 wl12xx_debug_level;
#define WL12XX_MAX_LINKS 8 #define WL12XX_MAX_LINKS 8
#define WL12XX_INVALID_ROLE_ID 0xff #define WL12XX_INVALID_ROLE_ID 0xff
#define WL12XX_INVALID_LINK_ID 0xff #define WL12XX_INVALID_LINK_ID 0xff
/* Defined by FW as 0. Will not be freed or allocated. */
#define WL12XX_SYSTEM_HLID 0 #define WL12XX_SYSTEM_HLID 0
#define WL1271_AP_GLOBAL_HLID 0
#define WL1271_AP_BROADCAST_HLID 1 /*
#define WL1271_AP_STA_HLID_START 2 * TODO: we currently don't support multirole. remove
* this constant from the code when we do.
*/
#define WL1271_AP_STA_HLID_START 3
/* /*
* When in AP-mode, we allow (at least) this number of mem-blocks * When in AP-mode, we allow (at least) this number of mem-blocks
...@@ -398,6 +403,8 @@ struct wl1271 { ...@@ -398,6 +403,8 @@ struct wl1271 {
u8 system_hlid; u8 system_hlid;
u8 sta_hlid; u8 sta_hlid;
u8 dev_hlid; u8 dev_hlid;
u8 ap_global_hlid;
u8 ap_bcast_hlid;
unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)];
unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment