Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 249723
b: refs/heads/master
c: 10ceaac
h: refs/heads/master
i:
  249721: de2a6f5
  249719: 59896f2
v: v3
  • Loading branch information
Naveen Singh authored and Greg Kroah-Hartman committed May 17, 2011
1 parent 633296f commit a049edc
Show file tree
Hide file tree
Showing 2 changed files with 147 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: d93089df1b752e4da048cd7f4749d29120b65e55
refs/heads/master: 10ceaac958b0b04d6939ec114b7182d78d2a0027
146 changes: 146 additions & 0 deletions trunk/drivers/staging/ath6kl/os/linux/cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,151 @@ u32 cipher_suites[] = {
WLAN_CIPHER_SUITE_CCMP,
};

bool is_rate_legacy(s32 rate)
{
static const s32 legacy[] = { 1000, 2000, 5500, 11000,
6000, 9000, 12000, 18000, 24000,
36000, 48000, 54000 };
u8 i;

for (i = 0; i < ARRAY_SIZE(legacy); i++) {
if (rate == legacy[i])
return true;
}

return false;
}

bool is_rate_ht20(s32 rate, u8 *mcs, bool *sgi)
{
static const s32 ht20[] = { 6500, 13000, 19500, 26000, 39000,
52000, 58500, 65000, 72200 };
u8 i;

for (i = 0; i < ARRAY_SIZE(ht20); i++) {
if (rate == ht20[i]) {
if (i == ARRAY_SIZE(ht20) - 1)
/* last rate uses sgi */
*sgi = true;
else
*sgi = false;

*mcs = i;
return true;
}
}
return false;
}

bool is_rate_ht40(s32 rate, u8 *mcs, bool *sgi)
{
static const s32 ht40[] = { 13500, 27000, 40500, 54000,
81000, 108000, 121500, 135000,
150000 };
u8 i;

for (i = 0; i < ARRAY_SIZE(ht40); i++) {
if (rate == ht40[i]) {
if (i == ARRAY_SIZE(ht40) - 1)
/* last rate uses sgi */
*sgi = true;
else
*sgi = false;

*mcs = i;
return true;
}
}

return false;
}

static int ar6k_get_station(struct wiphy *wiphy, struct net_device *dev,
u8 *mac, struct station_info *sinfo)
{
struct ar6_softc *ar = ar6k_priv(dev);
long left;
bool sgi;
s32 rate;
int ret;
u8 mcs;

if (memcmp(mac, ar->arBssid, ETH_ALEN) != 0)
return -ENOENT;

if (down_interruptible(&ar->arSem))
return -EBUSY;

ar->statsUpdatePending = true;

ret = wmi_get_stats_cmd(ar->arWmi);

if (ret != 0) {
up(&ar->arSem);
return -EIO;
}

left = wait_event_interruptible_timeout(arEvent,
ar->statsUpdatePending == false,
wmitimeout * HZ);

up(&ar->arSem);

if (left == 0)
return -ETIMEDOUT;
else if (left < 0)
return left;

if (ar->arTargetStats.rx_bytes) {
sinfo->rx_bytes = ar->arTargetStats.rx_bytes;
sinfo->filled |= STATION_INFO_RX_BYTES;
sinfo->rx_packets = ar->arTargetStats.rx_packets;
sinfo->filled |= STATION_INFO_RX_PACKETS;
}

if (ar->arTargetStats.tx_bytes) {
sinfo->tx_bytes = ar->arTargetStats.tx_bytes;
sinfo->filled |= STATION_INFO_TX_BYTES;
sinfo->tx_packets = ar->arTargetStats.tx_packets;
sinfo->filled |= STATION_INFO_TX_PACKETS;
}

sinfo->signal = ar->arTargetStats.cs_rssi;
sinfo->filled |= STATION_INFO_SIGNAL;

rate = ar->arTargetStats.tx_unicast_rate;

if (is_rate_legacy(rate)) {
sinfo->txrate.legacy = rate / 100;
} else if (is_rate_ht20(rate, &mcs, &sgi)) {
if (sgi) {
sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
sinfo->txrate.mcs = mcs - 1;
} else {
sinfo->txrate.mcs = mcs;
}

sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
} else if (is_rate_ht40(rate, &mcs, &sgi)) {
if (sgi) {
sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
sinfo->txrate.mcs = mcs - 1;
} else {
sinfo->txrate.mcs = mcs;
}

sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
} else {
WARN(1, "invalid rate: %d", rate);
return 0;
}

sinfo->filled |= STATION_INFO_TX_BITRATE;

return 0;
}

static struct
cfg80211_ops ar6k_cfg80211_ops = {
.change_virtual_intf = ar6k_cfg80211_change_iface,
Expand All @@ -1481,6 +1626,7 @@ cfg80211_ops ar6k_cfg80211_ops = {
.set_power_mgmt = ar6k_cfg80211_set_power_mgmt,
.join_ibss = ar6k_cfg80211_join_ibss,
.leave_ibss = ar6k_cfg80211_leave_ibss,
.get_station = ar6k_get_station,
};

struct wireless_dev *
Expand Down

0 comments on commit a049edc

Please sign in to comment.