* [PATCH 1/2] ath6kl: iw dev wlan0 link implementation
@ 2011-05-10 4:40 Kalle Valo
2011-05-10 4:40 ` [PATCH 2/2] ath6kl: provide hardware version to userspace Kalle Valo
2011-05-10 12:02 ` [PATCH 1/2] ath6kl: iw dev wlan0 link implementation Senthil Balasubramanian
0 siblings, 2 replies; 4+ messages in thread
From: Kalle Valo @ 2011-05-10 4:40 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-wireless
From: Naveen Singh <nsingh@atheros.com>
implementing the cfg ops that gets called when iw dev wlan0
link is issued by user. The ops that needs to be implemented
is get_station.
kvalo: check the mac address and fix style issues
Signed-off-by: Naveen Singh <nsingh@atheros.com>
Signed-off-by: Kalle Valo <kalle.valo@atheros.com>
---
drivers/staging/ath6kl/os/linux/cfg80211.c | 130 ++++++++++++++++++++++++++++
1 files changed, 130 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/ath6kl/os/linux/cfg80211.c b/drivers/staging/ath6kl/os/linux/cfg80211.c
index efd4ae5..cb3187e 100644
--- a/drivers/staging/ath6kl/os/linux/cfg80211.c
+++ b/drivers/staging/ath6kl/os/linux/cfg80211.c
@@ -1460,6 +1460,135 @@ 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 < 12; i++) {
+ if (rate == legacy[i])
+ return true;
+ }
+
+ return false;
+}
+
+bool is_rate_ht20(s32 rate, u8 *mcs)
+{
+ static const s32 ht20[] = { 6500, 13000, 19500, 26000, 39000,
+ 52000, 58500, 65000, 72200 };
+ u8 i;
+
+ for (i = 0; i < 9; i++) {
+ if (rate == ht20[i]) {
+ *mcs = i;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool is_rate_ht40(s32 rate, u8 *mcs)
+{
+ static const s32 ht40[] = { 13500, 27000, 40500, 54000,
+ 81000, 108000, 121500, 135000 };
+ u8 i;
+
+ for (i = 0; i < 9; i++) {
+ if (rate == ht40[i]) {
+ *mcs = i;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+int ar6k_get_station(struct wiphy *wiphy, struct net_device *dev,
+ u8 *mac, struct station_info *sinfo)
+{
+ struct ar6_softc *ar = ar6k_priv(dev);
+ u8 mcs, ret, timeout = false;
+
+ if (compare_ether_addr(mac, ar->arBssid))
+ 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;
+ }
+
+ wait_event_interruptible_timeout(arEvent,
+ ar->statsUpdatePending == false,
+ wmitimeout * HZ);
+
+ if (signal_pending(current)) {
+ timeout = true;
+ AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
+ ("ar6000 : WMI get stats timeout\n"));
+ }
+
+ up(&ar->arSem);
+
+ if (timeout)
+ return -ETIMEDOUT;
+
+ 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;
+
+ if (is_rate_legacy(ar->arTargetStats.tx_unicast_rate)) {
+ sinfo->txrate.legacy = ar->arTargetStats.tx_unicast_rate / 100;
+ } else if (is_rate_ht20(ar->arTargetStats.tx_unicast_rate, &mcs)) {
+ if (mcs == 0x08) {
+ 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(ar->arTargetStats.tx_unicast_rate, &mcs)) {
+ if (mcs == 0x08) {
+ 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", ar->arTargetStats.tx_unicast_rate);
+ }
+
+ sinfo->filled |= STATION_INFO_TX_BITRATE;
+
+ return 0;
+}
+
static struct
cfg80211_ops ar6k_cfg80211_ops = {
.change_virtual_intf = ar6k_cfg80211_change_iface,
@@ -1480,6 +1609,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 *
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ath6kl: provide hardware version to userspace
2011-05-10 4:40 [PATCH 1/2] ath6kl: iw dev wlan0 link implementation Kalle Valo
@ 2011-05-10 4:40 ` Kalle Valo
2011-05-10 12:02 ` [PATCH 1/2] ath6kl: iw dev wlan0 link implementation Senthil Balasubramanian
1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2011-05-10 4:40 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-wireless
From: Kalle Valo <kalle.valo@atheros.com>
Signed-off-by: Kalle Valo <kalle.valo@atheros.com>
---
drivers/staging/ath6kl/os/linux/ar6000_drv.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/ath6kl/os/linux/ar6000_drv.c b/drivers/staging/ath6kl/os/linux/ar6000_drv.c
index 513f205..48dd9e3 100644
--- a/drivers/staging/ath6kl/os/linux/ar6000_drv.c
+++ b/drivers/staging/ath6kl/os/linux/ar6000_drv.c
@@ -1732,6 +1732,7 @@ ar6000_avail_ev(void *context, void *hif_handle)
ar->arVersion.target_ver = targ_info.target_ver;
ar->arTargetType = targ_info.target_type;
+ wdev->wiphy->hw_version = targ_info.target_ver;
}
r = ar6000_configure_target(ar);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ath6kl: iw dev wlan0 link implementation
2011-05-10 4:40 [PATCH 1/2] ath6kl: iw dev wlan0 link implementation Kalle Valo
2011-05-10 4:40 ` [PATCH 2/2] ath6kl: provide hardware version to userspace Kalle Valo
@ 2011-05-10 12:02 ` Senthil Balasubramanian
2011-05-10 22:32 ` Kalle Valo
1 sibling, 1 reply; 4+ messages in thread
From: Senthil Balasubramanian @ 2011-05-10 12:02 UTC (permalink / raw)
To: Kalle Valo
Cc: gregkh@suse.de, devel@linuxdriverproject.org,
linux-wireless@vger.kernel.org, Naveen Singh
On Tue, May 10, 2011 at 10:10:23AM +0530, Kalle Valo wrote:
> From: Naveen Singh <nsingh@atheros.com>
>
> implementing the cfg ops that gets called when iw dev wlan0
> link is issued by user. The ops that needs to be implemented
> is get_station.
>
> kvalo: check the mac address and fix style issues
>
> Signed-off-by: Naveen Singh <nsingh@atheros.com>
> Signed-off-by: Kalle Valo <kalle.valo@atheros.com>
> ---
> drivers/staging/ath6kl/os/linux/cfg80211.c | 130 ++++++++++++++++++++++++++++
> 1 files changed, 130 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/staging/ath6kl/os/linux/cfg80211.c b/drivers/staging/ath6kl/os/linux/cfg80211.c
> index efd4ae5..cb3187e 100644
> --- a/drivers/staging/ath6kl/os/linux/cfg80211.c
> +++ b/drivers/staging/ath6kl/os/linux/cfg80211.c
> @@ -1460,6 +1460,135 @@ 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 < 12; i++) {
> + if (rate == legacy[i])
> + return true;
> + }
> +
> + return false;
> +}
[...]
> +
> +bool is_rate_ht20(s32 rate, u8 *mcs)
> +{
> + static const s32 ht20[] = { 6500, 13000, 19500, 26000, 39000,
> + 52000, 58500, 65000, 72200 };
> + u8 i;
> +
> + for (i = 0; i < 9; i++) {
> + if (rate == ht20[i]) {
> + *mcs = i;
> + return true;
> + }
> + }
> + return false;
> +}
> +
> +bool is_rate_ht40(s32 rate, u8 *mcs)
> +{
> + static const s32 ht40[] = { 13500, 27000, 40500, 54000,
> + 81000, 108000, 121500, 135000 };
> + u8 i;
> +
> + for (i = 0; i < 9; i++) {
> + if (rate == ht40[i]) {
> + *mcs = i;
> + return true;
> + }
> + }
> +
> + return false;
> +}
[...]
> +
> +int ar6k_get_station(struct wiphy *wiphy, struct net_device *dev,
> + u8 *mac, struct station_info *sinfo)
> +{
> + struct ar6_softc *ar = ar6k_priv(dev);
> + u8 mcs, ret, timeout = false;
> +
> + if (compare_ether_addr(mac, ar->arBssid))
this may result in unaligned memeory access on some platforms as mac
may not be 2 byte aligned. This is the case with the caller as per
cfg80211_wext_giwrate() and cfg80211_wireless_stats().
> + 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;
> + }
> +
> + wait_event_interruptible_timeout(arEvent,
> + ar->statsUpdatePending == false,
> + wmitimeout * HZ);
> +
> + if (signal_pending(current)) {
wait_event_interruptible_tiemout() itself checks for signal_pending and so this is
not necessary. You can check for the return status of
wait_event_interruptible_timeout() to know whether the task was interrupted by a
signal.
> + timeout = true;
> + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
> + ("ar6000 : WMI get stats timeout\n"));
> + }
> +
> + up(&ar->arSem);
I believe we can release the semaphore early on. I don't see any reason..
> +
> + if (timeout)
Not required as mentioned earlier.. You can check the return value..
> + return -ETIMEDOUT;
> +
> + 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;
> +
> + if (is_rate_legacy(ar->arTargetStats.tx_unicast_rate)) {
> + sinfo->txrate.legacy = ar->arTargetStats.tx_unicast_rate / 100;
> + } else if (is_rate_ht20(ar->arTargetStats.tx_unicast_rate, &mcs)) {
> + if (mcs == 0x08) {
> + 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(ar->arTargetStats.tx_unicast_rate, &mcs)) {
> + if (mcs == 0x08) {
> + 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", ar->arTargetStats.tx_unicast_rate);
> + }
> +
> + sinfo->filled |= STATION_INFO_TX_BITRATE;
> +
> + return 0;
> +}
> +
> static struct
> cfg80211_ops ar6k_cfg80211_ops = {
> .change_virtual_intf = ar6k_cfg80211_change_iface,
> @@ -1480,6 +1609,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 *
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ath6kl: iw dev wlan0 link implementation
2011-05-10 12:02 ` [PATCH 1/2] ath6kl: iw dev wlan0 link implementation Senthil Balasubramanian
@ 2011-05-10 22:32 ` Kalle Valo
0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2011-05-10 22:32 UTC (permalink / raw)
To: Senthil Balasubramanian
Cc: gregkh@suse.de, devel@linuxdriverproject.org,
linux-wireless@vger.kernel.org, Naveen Singh
Senthil Balasubramanian <senthilkumar@atheros.com> writes:
> On Tue, May 10, 2011 at 10:10:23AM +0530, Kalle Valo wrote:
>> From: Naveen Singh <nsingh@atheros.com>
>>
>> implementing the cfg ops that gets called when iw dev wlan0
>> link is issued by user. The ops that needs to be implemented
>> is get_station.
>>
>> kvalo: check the mac address and fix style issues
[...]
>> +int ar6k_get_station(struct wiphy *wiphy, struct net_device *dev,
>> + u8 *mac, struct station_info *sinfo)
>> +{
>> + struct ar6_softc *ar = ar6k_priv(dev);
>> + u8 mcs, ret, timeout = false;
>> +
>> + if (compare_ether_addr(mac, ar->arBssid))
>
> this may result in unaligned memeory access on some platforms as mac
> may not be 2 byte aligned. This is the case with the caller as per
> cfg80211_wext_giwrate() and cfg80211_wireless_stats().
I didn't think of this. I'll change it to use memcmp() instead.
>> + wait_event_interruptible_timeout(arEvent,
>> + ar->statsUpdatePending == false,
>> + wmitimeout * HZ);
>> +
>> + if (signal_pending(current)) {
>
> wait_event_interruptible_tiemout() itself checks for signal_pending
> and so this is not necessary. You can check for the return status of
> wait_event_interruptible_timeout() to know whether the task was
> interrupted by a signal.
Will fix.
>> + timeout = true;
>> + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
>> + ("ar6000 : WMI get stats timeout\n"));
>> + }
>> +
>> + up(&ar->arSem);
>
> I believe we can release the semaphore early on. I don't see any reason..
What do you mean? I'm not the author of the patch, but I assume that
the idea is to protect the access to ar->statsUpdatePending.
Thanks for the review, I'll submit v2.
--
Kalle Valo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-10 22:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-10 4:40 [PATCH 1/2] ath6kl: iw dev wlan0 link implementation Kalle Valo
2011-05-10 4:40 ` [PATCH 2/2] ath6kl: provide hardware version to userspace Kalle Valo
2011-05-10 12:02 ` [PATCH 1/2] ath6kl: iw dev wlan0 link implementation Senthil Balasubramanian
2011-05-10 22:32 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox