Re: [zd1211-devs] duration_id field in zd1211rw

2012-02-02 Thread Jussi Kivilinna

Hello again!

I tested the patch with pspoll check and concluded it works as it  
should. I'm planing to post your patch (+ pspoll fix) to upstream, so  
may I add your 'Signed-off-by' to it?


-Jussi

ps. patch attached.

Quoting Jussi Kivilinna :


Quoting Tomas Vanek :


Hello developers,

first thank you for the rewrite of zd1211 driver.

I use a small x86 server currently with linux 3.2.1 and generic ZyDAS
wifi ZD1211B 802.11g (USB ID 0ace:1215), fw 1.4
hostapd v0.7.3 is used for AP mode with WPA2 security. 6 wifi clients
(ath and prism54 chips) connect without problems.

Unfortunately two notebooks with iwl5100 card cannot connect at all.
Tested with both linux and Win7 on the notebook.
I also tested without security and iwl5100 didn't work again.

Hostapd log shows that association worked but EAPOL frame is not replied
by iwl:
--
STA 00:22:fb:xx:xx:xx sent probe request for our SSID
mgmt::auth
authentication: STA=00:22:fb:xx:xx:xx auth_alg=0 auth_transaction=1
status_code=0 wep=0
   New STA
authentication reply: STA=00:22:fb:xx:xx:xx auth_alg=0
auth_transaction=2 resp=0 (IE len=0)
mgmt::proberesp cb
mgmt::auth cb
mgmt::assoc_req
association request: STA=00:22:fb:xx:xx:xx capab_info=0x411
listen_interval=10
   new AID 1
nl80211: Set beacon (beacon_set=1)
mgmt::assoc_resp cb
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0xa057900 key_idx=0
set_tx=1 seq_len=0 key_len=0
addr=00:22:fb:xx:xx:xx
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0xa057900 key_idx=0
set_tx=1 seq_len=0 key_len=0
addr=00:22:fb:xx:xx:xx
WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state INITIALIZE
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0xa057900 key_idx=0
set_tx=1 seq_len=0 key_len=0
addr=00:22:fb:xx:xx:xx
WPA: 00:22:fb:xx:xx:xx WPA_PTK_GROUP entering state IDLE
WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state AUTHENTICATION
WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state AUTHENTICATION2
WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state INITPSK
WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state PTKSTART
WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=8
kde_len=0 keyidx=0 encr=0)
nl80211: Event message available
nl80211: Ignored unknown event (cmd=19)
IEEE 802.1X: 00:22:fb:xx:xx:xx TX status - version=2 type=3 length=95 -
ack=0
WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state PTKSTART
WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=8
kde_len=0 keyidx=0 encr=0)
IEEE 802.1X: 00:22:fb:xx:xx:xx TX status - version=2 type=3 length=95 -
ack=0
WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state PTKSTART
WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=8
kde_len=0 keyidx=0 encr=0)
IEEE 802.1X: 00:22:fb:xx:xx:xx TX status - version=2 type=3 length=95 -
ack=0
mgmt::deauth
deauthentication: STA=00:22:fb:xx:xx:xx reason_code=1
AP-STA-DISCONNECTED 00:22:fb:xx:xx:xx
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0xa057900 key_idx=0
set_tx=1 seq_len=0 key_len=0
addr=00:22:fb:xx:xx:xx
WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state DISCONNECTED
WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state INITIALIZE
--

Sniffing wireless packets I found strange values in ieee80211 header of
EAPOL and other data packets:
duration_id was bigger than 6, such values should be reserved for PS
poll.
Sniffer at iwl5100 didn't showed these packets at all. Management
packets with duration_id=0 were
received ok.

After some trials I reset the duration computed by mac80211 to zero:
--
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c
b/drivers/net/wireless/zd1211rw/zd_mac.c
index 0a70149..ffbe208 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -866,6 +866,9 @@ static int fill_ctrlset(struct zd_mac *mac,

 ZD_ASSERT(frag_len <= 0x);

+   /* firmware computes the duration itself and needs the field set
to 0 at input */
+   hdr->duration_id= 0;
+
 txrate = ieee80211_get_tx_rate(mac->hw, info);

 cs->modulation = txrate->hw_value;
--
and surprisingly the ZD1211B firmware computes reasonable values of
duration.
iwl5100 connects ok with fixed driver.

This change probably breaks PS poll packets. They send assoc id in
duration_id field.


Looking at vendor's zd1211 driver, it appears that duration_id is kept
at zero for all packets except PSPoll. So following should work:

+   /* firmware computes the duration itself and needs the field set to 0
+* at input for all packet types than PSPoll.
+*/
+   if (!ieee80211_is_pspoll(hdr->fc))
+   hdr->duration_id = 0;



I don't know if non B version of ZD1211 has the same problem.



Both are handled same for duration_id by vendor driver.



Best regards
 Tomas Vanek

-

Re: [zd1211-devs] duration_id field in zd1211rw

2012-01-31 Thread Jussi Kivilinna
Quoting Tomas Vanek :

> Hello developers,
>
> first thank you for the rewrite of zd1211 driver.
>
> I use a small x86 server currently with linux 3.2.1 and generic ZyDAS
> wifi ZD1211B 802.11g (USB ID 0ace:1215), fw 1.4
> hostapd v0.7.3 is used for AP mode with WPA2 security. 6 wifi clients
> (ath and prism54 chips) connect without problems.
>
> Unfortunately two notebooks with iwl5100 card cannot connect at all.
> Tested with both linux and Win7 on the notebook.
> I also tested without security and iwl5100 didn't work again.
>
> Hostapd log shows that association worked but EAPOL frame is not replied
> by iwl:
> --
> STA 00:22:fb:xx:xx:xx sent probe request for our SSID
> mgmt::auth
> authentication: STA=00:22:fb:xx:xx:xx auth_alg=0 auth_transaction=1
> status_code=0 wep=0
>New STA
> authentication reply: STA=00:22:fb:xx:xx:xx auth_alg=0
> auth_transaction=2 resp=0 (IE len=0)
> mgmt::proberesp cb
> mgmt::auth cb
> mgmt::assoc_req
> association request: STA=00:22:fb:xx:xx:xx capab_info=0x411
> listen_interval=10
>new AID 1
> nl80211: Set beacon (beacon_set=1)
> mgmt::assoc_resp cb
> wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0xa057900 key_idx=0
> set_tx=1 seq_len=0 key_len=0
> addr=00:22:fb:xx:xx:xx
> wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0xa057900 key_idx=0
> set_tx=1 seq_len=0 key_len=0
> addr=00:22:fb:xx:xx:xx
> WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state INITIALIZE
> wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0xa057900 key_idx=0
> set_tx=1 seq_len=0 key_len=0
> addr=00:22:fb:xx:xx:xx
> WPA: 00:22:fb:xx:xx:xx WPA_PTK_GROUP entering state IDLE
> WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state AUTHENTICATION
> WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state AUTHENTICATION2
> WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state INITPSK
> WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state PTKSTART
> WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=8
> kde_len=0 keyidx=0 encr=0)
> nl80211: Event message available
> nl80211: Ignored unknown event (cmd=19)
> IEEE 802.1X: 00:22:fb:xx:xx:xx TX status - version=2 type=3 length=95 -
> ack=0
> WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state PTKSTART
> WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=8
> kde_len=0 keyidx=0 encr=0)
> IEEE 802.1X: 00:22:fb:xx:xx:xx TX status - version=2 type=3 length=95 -
> ack=0
> WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state PTKSTART
> WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=8
> kde_len=0 keyidx=0 encr=0)
> IEEE 802.1X: 00:22:fb:xx:xx:xx TX status - version=2 type=3 length=95 -
> ack=0
> mgmt::deauth
> deauthentication: STA=00:22:fb:xx:xx:xx reason_code=1
> AP-STA-DISCONNECTED 00:22:fb:xx:xx:xx
> wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0xa057900 key_idx=0
> set_tx=1 seq_len=0 key_len=0
> addr=00:22:fb:xx:xx:xx
> WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state DISCONNECTED
> WPA: 00:22:fb:xx:xx:xx WPA_PTK entering state INITIALIZE
> --
>
> Sniffing wireless packets I found strange values in ieee80211 header of
> EAPOL and other data packets:
> duration_id was bigger than 6, such values should be reserved for PS
> poll.
> Sniffer at iwl5100 didn't showed these packets at all. Management
> packets with duration_id=0 were
> received ok.
>
> After some trials I reset the duration computed by mac80211 to zero:
> --
> diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c
> b/drivers/net/wireless/zd1211rw/zd_mac.c
> index 0a70149..ffbe208 100644
> --- a/drivers/net/wireless/zd1211rw/zd_mac.c
> +++ b/drivers/net/wireless/zd1211rw/zd_mac.c
> @@ -866,6 +866,9 @@ static int fill_ctrlset(struct zd_mac *mac,
>
>  ZD_ASSERT(frag_len <= 0x);
>
> +   /* firmware computes the duration itself and needs the field set
> to 0 at input */
> +   hdr->duration_id= 0;
> +
>  txrate = ieee80211_get_tx_rate(mac->hw, info);
>
>  cs->modulation = txrate->hw_value;
> --
> and surprisingly the ZD1211B firmware computes reasonable values of
> duration.
> iwl5100 connects ok with fixed driver.
>
> This change probably breaks PS poll packets. They send assoc id in
> duration_id field.

Looking at vendor's zd1211 driver, it appears that duration_id is kept  
at zero for all packets except PSPoll. So following should work:

+   /* firmware computes the duration itself and needs the field set to 0
+* at input for all packet types than PSPoll.
+*/
+   if (!ieee80211_is_pspoll(hdr->fc))
+   hdr->duration_id = 0;

>
> I don't know if non B version of ZD1211 has the same problem.
>

Both are handled same for duration_id by vendor driver.

>
> Best regards
>  Tomas Vanek
>
>