Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Mar 2009 02:37:52 +0000 (UTC)
From:      Sam Leffler <sam@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r189550 - head/sys/dev/if_ndis
Message-ID:  <200903090237.n292bqUM007021@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sam
Date: Mon Mar  9 02:37:52 2009
New Revision: 189550
URL: http://svn.freebsd.org/changeset/base/189550

Log:
  Fix TXPMGT handling:
  o correct dBm<->mW conversion logic
  o set net80211 TXPMGT capability only if driver reports it is capable
  
  PR:		kern/132342
  Submitted by:	"Paul B. Mahol" <onemda@gmail.com>

Modified:
  head/sys/dev/if_ndis/if_ndis.c

Modified: head/sys/dev/if_ndis/if_ndis.c
==============================================================================
--- head/sys/dev/if_ndis/if_ndis.c	Mon Mar  9 02:34:02 2009	(r189549)
+++ head/sys/dev/if_ndis/if_ndis.c	Mon Mar  9 02:37:52 2009	(r189550)
@@ -102,7 +102,7 @@ SYSCTL_INT(_hw_ndisusb, OID_AUTO, halt, 
     "Halt NDIS USB driver when it's attached");
 
 /* 0 - 30 dBm to mW conversion table */
-const uint16_t dBm2mW[] = {
+static const uint16_t dBm2mW[] = {
 	1, 1, 1, 1, 2, 2, 2, 2, 3, 3,
 	3, 4, 4, 4, 5, 6, 6, 7, 8, 9,
 	10, 11, 13, 14, 16, 18, 20, 22, 25, 28,
@@ -749,7 +749,7 @@ ndis_attach(dev)
 		ic->ic_ifp = ifp;
 		ic->ic_opmode = IEEE80211_M_STA;
 	        ic->ic_phytype = IEEE80211_T_DS;
-		ic->ic_caps = IEEE80211_C_STA | IEEE80211_C_IBSS | IEEE80211_C_TXPMGT;
+		ic->ic_caps = IEEE80211_C_STA | IEEE80211_C_IBSS;
 		setbit(ic->ic_modecaps, IEEE80211_MODE_AUTO);
 		len = 0;
 		r = ndis_get_info(sc, OID_802_11_NETWORK_TYPES_SUPPORTED,
@@ -928,6 +928,11 @@ got_crypto:
 		r = ndis_get_info(sc, OID_802_11_POWER_MODE, &arg, &i);
 		if (r == 0)
 			ic->ic_caps |= IEEE80211_C_PMGT;
+
+		r = ndis_get_info(sc, OID_802_11_TX_POWER_LEVEL, &arg, &i);
+		if (r == 0)
+			ic->ic_caps |= IEEE80211_C_TXPMGT;
+
 		bcopy(eaddr, &ic->ic_myaddr, sizeof(eaddr));
 		ieee80211_ifattach(ic);
 		ic->ic_raw_xmit = ndis_raw_xmit;
@@ -2325,9 +2330,10 @@ ndis_setstate_80211(sc)
 	ndis_set_info(sc, OID_802_11_POWER_MODE, &arg, &len);
 
 	/* Set TX power */
-	if (ic->ic_txpowlimit < sizeof(dBm2mW)) {
-		len = sizeof(arg);
+	if ((ic->ic_caps & IEEE80211_C_TXPMGT) &&
+	    ic->ic_txpowlimit < (sizeof(dBm2mW) / sizeof(dBm2mW[0]))) {
 		arg = dBm2mW[ic->ic_txpowlimit];
+		len = sizeof(arg);
 		ndis_set_info(sc, OID_802_11_TX_POWER_LEVEL, &arg, &len);
 	}
 
@@ -2798,11 +2804,10 @@ ndis_getstate_80211(sc)
 	}
 
 	/* Get TX power */
-	len = sizeof(arg);
-	rval = ndis_get_info(sc, OID_802_11_TX_POWER_LEVEL, &arg, &len);
-
-	if (!rval) {
-		for (i = 0; i < sizeof(dBm2mW); i++)
+	if (ic->ic_caps & IEEE80211_C_TXPMGT) {
+		len = sizeof(arg);
+		ndis_get_info(sc, OID_802_11_TX_POWER_LEVEL, &arg, &len);
+		for (i = 0; i < (sizeof(dBm2mW) / sizeof(dBm2mW[0])); i++)
 			if (dBm2mW[i] >= arg)
 				break;
 		ic->ic_txpowlimit = i;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903090237.n292bqUM007021>