Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 236884
b: refs/heads/master
c: f84f7d7
h: refs/heads/master
v: v3
  • Loading branch information
Arik Nemtsov authored and Luciano Coelho committed Jan 24, 2011
1 parent 2f4fad2 commit 5459039
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7d0578693107887d52d50b89723be7fa0a41cd36
refs/heads/master: f84f7d78bbfbbb17faa64bcca5799865074e1e7b
112 changes: 112 additions & 0 deletions trunk/drivers/net/wireless/wl12xx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl)
wl->flags = 0;
wl->vif = NULL;
wl->filters = 0;
memset(wl->ap_hlid_map, 0, sizeof(wl->ap_hlid_map));

for (i = 0; i < NUM_TX_QUEUES; i++)
wl->tx_blocks_freed[i] = 0;
Expand Down Expand Up @@ -2401,6 +2402,113 @@ static int wl1271_op_get_survey(struct ieee80211_hw *hw, int idx,
return 0;
}

static int wl1271_allocate_hlid(struct wl1271 *wl,
struct ieee80211_sta *sta,
u8 *hlid)
{
struct wl1271_station *wl_sta;
int id;

id = find_first_zero_bit(wl->ap_hlid_map, AP_MAX_STATIONS);
if (id >= AP_MAX_STATIONS) {
wl1271_warning("could not allocate HLID - too much stations");
return -EBUSY;
}

wl_sta = (struct wl1271_station *)sta->drv_priv;

__set_bit(id, wl->ap_hlid_map);
wl_sta->hlid = WL1271_AP_STA_HLID_START + id;
*hlid = wl_sta->hlid;
return 0;
}

static void wl1271_free_hlid(struct wl1271 *wl, u8 hlid)
{
int id = hlid - WL1271_AP_STA_HLID_START;

__clear_bit(id, wl->ap_hlid_map);
}

static int wl1271_op_sta_add(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
struct wl1271 *wl = hw->priv;
int ret = 0;
u8 hlid;

mutex_lock(&wl->mutex);

if (unlikely(wl->state == WL1271_STATE_OFF))
goto out;

if (wl->bss_type != BSS_TYPE_AP_BSS)
goto out;

wl1271_debug(DEBUG_MAC80211, "mac80211 add sta %d", (int)sta->aid);

ret = wl1271_allocate_hlid(wl, sta, &hlid);
if (ret < 0)
goto out;

ret = wl1271_ps_elp_wakeup(wl, false);
if (ret < 0)
goto out;

ret = wl1271_cmd_add_sta(wl, sta, hlid);
if (ret < 0)
goto out_sleep;

out_sleep:
wl1271_ps_elp_sleep(wl);

out:
mutex_unlock(&wl->mutex);
return ret;
}

static int wl1271_op_sta_remove(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
struct wl1271 *wl = hw->priv;
struct wl1271_station *wl_sta;
int ret = 0, id;

mutex_lock(&wl->mutex);

if (unlikely(wl->state == WL1271_STATE_OFF))
goto out;

if (wl->bss_type != BSS_TYPE_AP_BSS)
goto out;

wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid);

wl_sta = (struct wl1271_station *)sta->drv_priv;
id = wl_sta->hlid - WL1271_AP_STA_HLID_START;
if (WARN_ON(!test_bit(id, wl->ap_hlid_map)))
goto out;

ret = wl1271_ps_elp_wakeup(wl, false);
if (ret < 0)
goto out;

ret = wl1271_cmd_remove_sta(wl, wl_sta->hlid);
if (ret < 0)
goto out_sleep;

wl1271_free_hlid(wl, wl_sta->hlid);

out_sleep:
wl1271_ps_elp_sleep(wl);

out:
mutex_unlock(&wl->mutex);
return ret;
}

/* can't be const, mac80211 writes to this */
static struct ieee80211_rate wl1271_rates[] = {
{ .bitrate = 10,
Expand Down Expand Up @@ -2647,6 +2755,8 @@ static const struct ieee80211_ops wl1271_ops = {
.conf_tx = wl1271_op_conf_tx,
.get_tsf = wl1271_op_get_tsf,
.get_survey = wl1271_op_get_survey,
.sta_add = wl1271_op_sta_add,
.sta_remove = wl1271_op_sta_remove,
CFG80211_TESTMODE_CMD(wl1271_tm_cmd)
};

Expand Down Expand Up @@ -2840,6 +2950,8 @@ int wl1271_init_ieee80211(struct wl1271 *wl)

SET_IEEE80211_DEV(wl->hw, wl1271_wl_to_dev(wl));

wl->hw->sta_data_size = sizeof(struct wl1271_station);

return 0;
}
EXPORT_SYMBOL_GPL(wl1271_init_ieee80211);
Expand Down
7 changes: 7 additions & 0 deletions trunk/drivers/net/wireless/wl12xx/wl12xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,13 @@ struct wl1271 {

/* Most recently reported noise in dBm */
s8 noise;

/* map for HLIDs of associated stations - when operating in AP mode */
unsigned long ap_hlid_map[BITS_TO_LONGS(AP_MAX_STATIONS)];
};

struct wl1271_station {
u8 hlid;
};

int wl1271_plt_start(struct wl1271 *wl);
Expand Down

0 comments on commit 5459039

Please sign in to comment.