[PATCH] mac80211: add TDLS supported channels correctly

2014-12-29 Thread Arik Nemtsov
The function adding the supported channels IE during a TDLS connection had
several issues:
1. If the entire subband is usable, the function exitted the loop without
adding it
2. The function only checked chandef_usable, ignoring flags like RADAR
which would prevent TDLS off-channel communcation.
3. HT20 was explicitly required in the chandef, while not a requirement
for TDLS off-channel.

Signed-off-by: Arik Nemtsov 
Reviewed-by: Emmanuel Grumbach 
---
 net/mac80211/tdls.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/net/mac80211/tdls.c b/net/mac80211/tdls.c
index 55ddd77..bd89249 100644
--- a/net/mac80211/tdls.c
+++ b/net/mac80211/tdls.c
@@ -68,12 +68,11 @@ ieee80211_tdls_add_subband(struct ieee80211_sub_if_data 
*sdata,
ch = ieee80211_get_channel(sdata->local->hw.wiphy, i);
if (ch) {
/* we will be active on the channel */
-   u32 flags = IEEE80211_CHAN_DISABLED |
-   IEEE80211_CHAN_NO_IR;
cfg80211_chandef_create(&chandef, ch,
-   NL80211_CHAN_HT20);
-   if (cfg80211_chandef_usable(sdata->local->hw.wiphy,
-   &chandef, flags)) {
+   NL80211_CHAN_NO_HT);
+   if (cfg80211_reg_can_beacon(sdata->local->hw.wiphy,
+   &chandef,
+   sdata->wdev.iftype)) {
ch_cnt++;
continue;
}
@@ -89,6 +88,14 @@ ieee80211_tdls_add_subband(struct ieee80211_sub_if_data 
*sdata,
}
}
 
+   if (ch_cnt) {
+   u8 *pos = skb_put(skb, 2);
+   *pos++ = ieee80211_frequency_to_channel(subband_start);
+   *pos++ = ch_cnt;
+
+   subband_cnt++;
+   }
+
return subband_cnt;
 }
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cfg80211: fix deadlock during reg chan check

2014-12-29 Thread Arik Nemtsov
If a P2P GO is active, the cfg80211_reg_can_beacon function will take
the wdev lock, in its call to cfg80211_go_permissive_chan. But the wdev lock
is already taken by the parent channel-checking function, causing a
deadlock.
Split the checking code into two parts. The first part will check if the
wdev is active and saves the channel under the wdev lock. The second part
will check actual channel validity according to type.

Signed-off-by: Arik Nemtsov 
Reviewed-by: Ilan Peer 
Reviewed-by: Emmanuel Grumbach 
---
Requires the patch "cfg80211: correctly check ad-hoc channels" to be applied
first.

 net/wireless/reg.c | 56 +-
 1 file changed, 34 insertions(+), 22 deletions(-)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 978a5fd..fde4e17 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1533,45 +1533,40 @@ static void reg_call_notifier(struct wiphy *wiphy,
 
 static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)
 {
-   struct ieee80211_channel *ch;
struct cfg80211_chan_def chandef;
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
-   bool ret = true;
+   enum nl80211_iftype iftype;
 
wdev_lock(wdev);
+   iftype = wdev->iftype;
 
+   /* make sure the interface is active */
if (!wdev->netdev || !netif_running(wdev->netdev))
-   goto out;
+   goto wdev_inactive_unlock;
 
-   switch (wdev->iftype) {
+   switch (iftype) {
case NL80211_IFTYPE_AP:
case NL80211_IFTYPE_P2P_GO:
if (!wdev->beacon_interval)
-   goto out;
-
-   ret = cfg80211_reg_can_beacon(wiphy,
- &wdev->chandef, wdev->iftype);
+   goto wdev_inactive_unlock;
+   chandef = wdev->chandef;
break;
case NL80211_IFTYPE_ADHOC:
if (!wdev->ssid_len)
-   goto out;
-
-   ret = cfg80211_reg_can_beacon(wiphy,
- &wdev->chandef, wdev->iftype);
+   goto wdev_inactive_unlock;
+   chandef = wdev->chandef;
break;
case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_P2P_CLIENT:
if (!wdev->current_bss ||
!wdev->current_bss->pub.channel)
-   goto out;
+   goto wdev_inactive_unlock;
 
-   ch = wdev->current_bss->pub.channel;
-   if (rdev->ops->get_channel &&
-   !rdev_get_channel(rdev, wdev, &chandef))
-   ret = cfg80211_chandef_usable(wiphy, &chandef,
- IEEE80211_CHAN_DISABLED);
-   else
-   ret = !(ch->flags & IEEE80211_CHAN_DISABLED);
+   if (!rdev->ops->get_channel ||
+   rdev_get_channel(rdev, wdev, &chandef))
+   cfg80211_chandef_create(&chandef,
+   wdev->current_bss->pub.channel,
+   NL80211_CHAN_NO_HT);
break;
case NL80211_IFTYPE_MONITOR:
case NL80211_IFTYPE_AP_VLAN:
@@ -1584,9 +1579,26 @@ static bool reg_wdev_chan_valid(struct wiphy *wiphy, 
struct wireless_dev *wdev)
break;
}
 
-out:
wdev_unlock(wdev);
-   return ret;
+
+   switch (iftype) {
+   case NL80211_IFTYPE_AP:
+   case NL80211_IFTYPE_P2P_GO:
+   case NL80211_IFTYPE_ADHOC:
+   return cfg80211_reg_can_beacon(wiphy, &chandef, iftype);
+   case NL80211_IFTYPE_STATION:
+   case NL80211_IFTYPE_P2P_CLIENT:
+   return cfg80211_chandef_usable(wiphy, &chandef,
+  IEEE80211_CHAN_DISABLED);
+   default:
+   break;
+   }
+
+   return true;
+
+wdev_inactive_unlock:
+   wdev_unlock(wdev);
+   return true;
 }
 
 static void reg_leave_invalid_chans(struct wiphy *wiphy)
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 0/3] add TPC capability for AR9002 based chips

2014-12-29 Thread Oleksij Rempel
Am 28.12.2014 um 15:32 schrieb Lorenzo Bianconi:
>> Hi, can you please describe some testcases for you patches.
>>
> 
> This patchset adds Transmission Power Control (TPC) for AR9002 based
> chips. IOW it enables the capability of correct TX power on per-packet
> basis. It is preparatory for upcoming Thomas's joint rate and power
> control
>  algorithm.

Do you mean, right now there is no way to test your patches?


> Regards,
> Lorenzo
> 
>> Am 27.12.2014 um 15:12 schrieb Lorenzo Bianconi:
>>> This patchset adds TPC capability to ath9k for AR9002 based chips
>>>
>>> *[RFC 1/3]: add TX power per-rate tables to cap TX power in TX descriptor 
>>> path
>>> *[RFC 2/3]: cap per-packet TX power according to TX power per-rate tables
>>> *[RFC 3/3]: enable per-packet TPC on AR9002 based chips by default
>>>
>>> This pachset is based on Adrian Chadd's hints
>>> (https://www.mail-archive.com/ath9k-devel@lists.ath9k.org/msg10396.html)
>>>
>>> Lorenzo Bianconi (3):
>>>   ath9k: add power per-rate tables for AR9002 chips
>>>   ath9k: add TPC to TX path for AR9002 based chips
>>>   ath9k: enable per-packet TPC on AR9002 based chips
>>>
>>>  drivers/net/wireless/ath/ath9k/ar5008_phy.c  | 80 
>>> 
>>>  drivers/net/wireless/ath/ath9k/debug.c   |  5 --
>>>  drivers/net/wireless/ath/ath9k/eeprom_4k.c   | 14 +
>>>  drivers/net/wireless/ath/ath9k/eeprom_9287.c | 15 ++
>>>  drivers/net/wireless/ath/ath9k/eeprom_def.c  | 14 +
>>>  drivers/net/wireless/ath/ath9k/hw.c  |  3 +-
>>>  drivers/net/wireless/ath/ath9k/hw.h  |  2 +
>>>  drivers/net/wireless/ath/ath9k/xmit.c| 66 +++
>>>  8 files changed, 181 insertions(+), 18 deletions(-)
>>>
>>
>>
>> --
>> Regards,
>> Oleksij
>>
> 
> 
> 


-- 
Regards,
Oleksij



signature.asc
Description: OpenPGP digital signature


Re: [RFC 0/3] add TPC capability for AR9002 based chips

2014-12-29 Thread Lorenzo Bianconi
> Am 28.12.2014 um 15:32 schrieb Lorenzo Bianconi:
>>> Hi, can you please describe some testcases for you patches.
>>>
>>
>> This patchset adds Transmission Power Control (TPC) for AR9002 based
>> chips. IOW it enables the capability of correct TX power on per-packet
>> basis. It is preparatory for upcoming Thomas's joint rate and power
>> control
>>  algorithm.
>
> Do you mean, right now there is no way to test your patches?
>

I have just added TPC support to ath9k. In order to exploit that hw
feature we have to wait Thomas's algorithm :).
However in order to test patches you can set tx_power field of
ath_frame_info data structure in setup_frame_info() to a different
value (for the moment it is set to MAX_RATE_POWER) and measure the RX
power on the other end of the link (this is what I did).

Regards,
Lorenzo

>
>> Regards,
>> Lorenzo
>>
>>> Am 27.12.2014 um 15:12 schrieb Lorenzo Bianconi:
 This patchset adds TPC capability to ath9k for AR9002 based chips

 *[RFC 1/3]: add TX power per-rate tables to cap TX power in TX descriptor 
 path
 *[RFC 2/3]: cap per-packet TX power according to TX power per-rate tables
 *[RFC 3/3]: enable per-packet TPC on AR9002 based chips by default

 This pachset is based on Adrian Chadd's hints
 (https://www.mail-archive.com/ath9k-devel@lists.ath9k.org/msg10396.html)

 Lorenzo Bianconi (3):
   ath9k: add power per-rate tables for AR9002 chips
   ath9k: add TPC to TX path for AR9002 based chips
   ath9k: enable per-packet TPC on AR9002 based chips

  drivers/net/wireless/ath/ath9k/ar5008_phy.c  | 80 
 
  drivers/net/wireless/ath/ath9k/debug.c   |  5 --
  drivers/net/wireless/ath/ath9k/eeprom_4k.c   | 14 +
  drivers/net/wireless/ath/ath9k/eeprom_9287.c | 15 ++
  drivers/net/wireless/ath/ath9k/eeprom_def.c  | 14 +
  drivers/net/wireless/ath/ath9k/hw.c  |  3 +-
  drivers/net/wireless/ath/ath9k/hw.h  |  2 +
  drivers/net/wireless/ath/ath9k/xmit.c| 66 +++
  8 files changed, 181 insertions(+), 18 deletions(-)

>>>
>>>
>>> --
>>> Regards,
>>> Oleksij
>>>
>>
>>
>>
>
>
> --
> Regards,
> Oleksij
>



-- 
UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch;
unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp;
umount; make clean; sleep
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 8/8] ath10k: fix error return code

2014-12-29 Thread Julia Lawall
Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// 
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret = 0
)
... when != ret = e1
when != &ret
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}
// 

Signed-off-by: Julia Lawall 

---
 drivers/net/wireless/ath/ath10k/htt_tx.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c 
b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 4bc51d8..2836f4c 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -480,8 +480,10 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff 
*msdu)
 
skb_cb->htt.txbuf = dma_pool_alloc(htt->tx_pool, GFP_ATOMIC,
   &paddr);
-   if (!skb_cb->htt.txbuf)
+   if (!skb_cb->htt.txbuf) {
+   res = -ENOMEM;
goto err_free_msdu_id;
+   }
skb_cb->htt.txbuf_paddr = paddr;
 
skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/8] adm8211: fix error return code

2014-12-29 Thread Julia Lawall
Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// 
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret = 0
)
... when != ret = e1
when != &ret
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}
// 

Signed-off-by: Julia Lawall 

---
 drivers/net/wireless/adm8211.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index 17fcaab..f07a618 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -1837,6 +1837,7 @@ static int adm8211_probe(struct pci_dev *pdev,
if (!priv->map) {
printk(KERN_ERR "%s (adm8211): Cannot map device memory\n",
   pci_name(pdev));
+   err = -ENOMEM;
goto err_free_dev;
}
 

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/8] fix error return code

2014-12-29 Thread Julia Lawall
The complate semantic patch that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// 
@ok exists@
identifier f,ret,i;
expression e;
constant c;
@@

// identify a function that returns a negative return value at least once.
f(...) {
... when any
(
return -c@i;
|
ret = -c@i;
... when != ret = e
return ret;
|
if (ret < 0) { ... return ret; }
)
... when any
}

@r exists@
identifier ret,ok.f,fn;
expression e1,e2,e3,e4,e5,e6,x;
statement S,S1;
position p1,p2,p3;
@@

// identify a case where the return variable is set to a non-negative value
// and then returned in error-handling code
f(...) {
... when any
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\)
when != &ret
when any
(
 if (<+... ret = e5 ...+>) S1
|
 if (<+... &ret ...+>) S1
|
if@p2(<+...x = fn(...)...+>)
 {
  ... when != ret = e6
  when forall
 return@p3 ret;
}
|
break;
|
x = fn(...)
... when != \(ret = e4\|ret++\|ret--\|ret+=e4\|ret-=e4\)
when != &ret
(
 if (<+... ret = e3 ...+>) S
|
 if (<+... &ret ...+>) S
|
if@p2(<+...\(x != 0\|x < 0\|x == NULL\|IS_ERR(x)\)...+>)
 {
  ... when != ret = e2
  when forall
 return@p3 ret;
}
)
)
... when any
}

@printer depends on r@
position p;
identifier ok.f,pr;
constant char [] c;
@@

f(...) { <...pr@p(...,c,...)...> }

@bad0 exists@
identifier r.ret,ok.f,g != {ERR_PTR,IS_ERR};
position p != printer.p;
@@

f(...) { ... when any
g@p(...,ret,...)
... when any
 }

@bad depends on !bad0 exists@
position r.p1,r.p2;
statement S1,S2;
identifier r.ret;
expression e1;
@@

// ignore the above if there is some path where the variable is set to
// something else
(
if@p1 (\(ret < 0\|ret != 0\)) S1
|
ret@p1 = 0
)
... when any
 \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\|&ret\)
... when any
if@p2(...) S2

@bad1 depends on !bad0 && !bad exists@
position r.p2;
statement S2;
identifier r.ret;
expression e1;
constant c;
@@

ret = -c
... when != \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\)
when != &ret
when any
if@p2(...) S2

@bad2 depends on !bad0 && !bad && !bad1 exists@
position r.p1,r.p2;
identifier r.ret;
expression e1;
statement S2;
constant c;
@@

// likewise ignore it if there has been an intervening return
ret@p1 = 0
... when != if (...) { ... ret = e1 ... return ret; }
when != if (...) { ... return -c; }
when any
if@p2(...) S2


@script:python depends on !bad0 && !bad && !bad1 && !bad2@
p1 << r.p1;
p2 << r.p2;
p3 << r.p3;
@@

cocci.print_main("",p1)
cocci.print_secs("",p2)
cocci.print_secs("",p3)
// 

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


IBSS or Hostapd, but not both

2014-12-29 Thread Tuc at Beach House
Hi,

Raspberry Pi Model B+, Linux blue 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00
BST 2014 armv6l GNU/Linux, hostapd v2.3 (defconfig), Ralink using rt2800usb
driver on either a Wi-Pi or Panda Ultra Wireless N USB Adapter.

What I'm trying to accomplish is using a single interface to be an AP on
one SSID, and ad-hoc on another SSID. The problem is that I can either do
one, or the other, but not both...

root@blue:~# iwconfig wlan1
wlan1 IEEE 802.11bgn  ESSID:off/any
  Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm
  Retry  long limit:7   RTS thr:off   Fragment thr:off
  Encryption key:off
  Power Management:on

So if I set up ad-hoc, works fine :

root@blue:~# iw dev wlan1 interface add wlan10 type ibss
root@blue:~# iwconfig wlan10
wlan10IEEE 802.11bgn  ESSID:off/any
  Mode:Ad-Hoc  Cell: Not-Associated   Tx-Power=0 dBm
  Retry  long limit:7   RTS thr:off   Fragment thr:off
  Encryption key:off
  Power Management:on

root@blue:~# iwconfig wlan10 essid WEDDING
root@blue:~# ifconfig wlan10 10.4.4.8 netmask 255.255.255.0
root@blue:~# ping -c2 new
PING new.wedding.ramolaandscott,com (10.4.4.6) 56(84) bytes of data.
64 bytes from new.wedding.ramolaandscott,com (10.4.4.6): icmp_req=1 ttl=64
time=3.51 ms
64 bytes from new.wedding.ramolaandscott,com (10.4.4.6): icmp_req=2 ttl=64
time=1.02 ms

--- new.wedding.ramolaandscott,com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.024/2.268/3.512/1.244 ms


Now invoke hostapd with the following /etc/hostapd/hostapd.conf :

root@blue:~# cat /etc/hostapd/hostapd.conf
interface=wlan1
ssid=FREE
hw_mode=g
channel=1
root@blue:~# /usr/local/bin/hostapd -dd /etc/hostapd/hostapd.conf
(Please see http://pastebin.com/cjqukwyH)


But if I reboot and try backwards :

root@blue:~# hostapd -dd /etc/hostapd/hostapd.conf
(Please see http://pastebin.com/Tdc5dz81)


And its fine, but then :

root@blue:~# iw dev wlan1 interface add wlan10 type ibss
root@blue:~# iwconfig wlan10
wlan10IEEE 802.11bgn  ESSID:off/any
  Mode:Ad-Hoc  Cell: Not-Associated   Tx-Power=20 dBm
  Retry  long limit:7   RTS thr:off   Fragment thr:off
  Encryption key:off
  Power Management:on

root@blue:~# iwconfig wlan10 essid WEDDING
root@blue:~# ifconfig wlan10
wlan10Link encap:Ethernet  HWaddr 00:c1:41:07:07:d1
  BROADCAST MULTICAST  MTU:1500  Metric:1
  RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@blue:~# ifconfig wlan10 10.4.4.8 netmask 255.255.255.0
SIOCSIFFLAGS: Device or resource busy
root@blue:~# ifconfig wlan10
wlan10Link encap:Ethernet  HWaddr 00:c1:41:07:07:d1
  inet addr:10.4.4.8  Bcast:10.4.4.255  Mask:255.255.255.0
  BROADCAST MULTICAST  MTU:1500  Metric:1
  RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@blue:~# ping -c2 new
PING new.wedding.ramolaandscott,com (10.4.4.6) 56(84) bytes of data.

--- new.wedding.ramolaandscott,com ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1001ms



Any idea where to look or what to do to get them to work and play together?

Thanks, Tuc
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html