wi tx-rate is set incorrectly with ifconfig

Eugene Perevyazko <[email protected]>
Newsgroups gmane.os.freebsd.devel.mobile
Message-ID <[email protected]>
 Hi there.

Abstract: 
wi driver tx-rate for Lucent chipset is set incorrectly by ifconfig 
'media DSx' option.

To confirm:
 ifconfig wi0 media DS11
 wicontrol
wicontrol reports not 11 but most probably 2 Mbit/s

Details:

I've moved to setting all wi params with ifconfig through /etc/rc.conf
some time ago just like that:

ifconfig_wi0="inet 1.2.3.4 netmask 0xfffffff0 \
nwkey 1:key01,key02,key03,key04 media DS11 \
station MyFineBox ssid MyFineNet"

Then noticed that wicontrol reports wrong tx-rate value.
A glimpse at the source shows that code in wi_media_change() in if_wi.c:

switch (IFM_SUBTYPE(sc->ifmedia.ifm_cur->ifm_media)) {
        case IFM_IEEE80211_DS1:
                sc->wi_tx_rate = 1;
                break;
        case IFM_IEEE80211_DS2:
                sc->wi_tx_rate = 2;
                break;
        case IFM_IEEE80211_DS5:
                sc->wi_tx_rate = 5;
                break;
        case IFM_IEEE80211_DS11:
                sc->wi_tx_rate = 11;
                break;
        case IFM_AUTO:
                sc->wi_tx_rate = 3;
                break;
        }

Then those values are translated for Prism2 in wi_write_record() but go 
unchanged for Lucent. Poor me!
The Prism2 gets those translated as:
		case WI_RID_TX_RATE:
                        p2ltv.wi_type = WI_RID_TX_RATE;
                        p2ltv.wi_len = 2;
                        switch (ltv->wi_val) {
                        case 1: p2ltv.wi_val = 1; break;
                        case 2: p2ltv.wi_val = 2; break;
                        case 3: p2ltv.wi_val = 15; break;
                        case 5: p2ltv.wi_val = 4; break;
                        case 6: p2ltv.wi_val = 3; break;
                        case 7: p2ltv.wi_val = 7; break;
                        case 11: p2ltv.wi_val = 8; break;
                        default: return EINVAL;
                        }
                        ltv = &p2ltv;
                        break;
So I think that Lucent should get values translated the following way:
                        switch (ltv->wi_val) {
                        case 1: p2ltv.wi_val = 1; break;/* 1Mb/s fixed */
                        case 2: p2ltv.wi_val = 2; break;/* 2Mb/s fixed */
                        case 3: p2ltv.wi_val = 3; break;/* 11Mb/s auto */
                        case 5: p2ltv.wi_val = 4; break;/* 5.5Mb/s fixed */
                        case 6: p2ltv.wi_val = 6; break;/* 2Mb/s auto */
                        case 7: p2ltv.wi_val = 7; break;/* 5.5Mb/s auto */
                        case 11: p2ltv.wi_val = 5; break;/* 11Mb/s fixed */
                        default: return EINVAL;
                        }

(I deduced the values from man wicontrol)
I've made a little patch and tried it. My Orinoco is happy now! :)
The patch is attached.

-- 
 Eugene Perevyazko
tx_rate.patch (text/plain, 1.1 KB)
*** if_wi.c.orig	Tue Aug 28 09:21:14 2001
--- if_wi.c	Tue Apr  9 15:39:13 2002
***************
*** 1045,1054 ****
--- 1045,1070 ----
  			}
  			return 0;
  		    }
  		}
  	}
+ 	else {  /* not Prism, Lucent for ex. */
+ 		switch (ltv->wi_type) {
+ 		case WI_RID_TX_RATE:
+ 			switch (ltv->wi_val) {
+                         case 1: ltv->wi_val = 1; break;  /* 1Mb/s fixed */
+                         case 2: ltv->wi_val = 2; break;  /* 2Mb/s fixed */
+                         case 3: ltv->wi_val = 3; break;  /* 11Mb/s auto */
+                         case 5: ltv->wi_val = 4; break;  /* 5.5Mb/s fixed */
+                         case 6: ltv->wi_val = 6; break;  /* 2Mb/s auto */
+                         case 7: ltv->wi_val = 7; break;  /* 5.5Mb/s auto */
+                         case 11: ltv->wi_val = 5; break; /* 11Mb/s fixed */
+                         default: return EINVAL;
+                         }
+                         break;
+ 		}
+ 	}
  
  	if (wi_seek(sc, ltv->wi_type, 0, WI_BAP1))
  		return(EIO);
  
  	CSR_WRITE_2(sc, WI_DATA1, ltv->wi_len);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.