From owner-svn-src-head@FreeBSD.ORG Mon Jan 12 17:15:10 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D14D1065759; Mon, 12 Jan 2009 17:15:10 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D55C88FC1B; Mon, 12 Jan 2009 17:15:09 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0CHF9Sm071541; Mon, 12 Jan 2009 17:15:09 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0CHF9Td071540; Mon, 12 Jan 2009 17:15:09 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200901121715.n0CHF9Td071540@svn.freebsd.org> From: Andrew Thompson Date: Mon, 12 Jan 2009 17:15:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187104 - head/sys/dev/if_ndis X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jan 2009 17:15:10 -0000 Author: thompsa Date: Mon Jan 12 17:15:09 2009 New Revision: 187104 URL: http://svn.freebsd.org/changeset/base/187104 Log: Provide a NDIS tx power level converstion to/from net80211, this uses a loookup table to approximate mW<->dBM. Submitted by: Paul B. Mahol 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 Jan 12 16:54:41 2009 (r187103) +++ head/sys/dev/if_ndis/if_ndis.c Mon Jan 12 17:15:09 2009 (r187104) @@ -101,6 +101,17 @@ int ndisusb_halt = 1; SYSCTL_INT(_hw_ndisusb, OID_AUTO, halt, CTLFLAG_RW, &ndisusb_halt, 0, "Halt NDIS USB driver when it's attached"); +/* 0 - 30 dBm to mW conversion table */ +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, + 32, 35, 40, 45, 50, 56, 63, 71, 79, 89, + 100, 112, 126, 141, 158, 178, 200, 224, 251, 282, + 316, 355, 398, 447, 501, 562, 631, 708, 794, 891, + 1000 +}; + MODULE_DEPEND(ndis, ether, 1, 1, 1); MODULE_DEPEND(ndis, wlan, 1, 1, 1); MODULE_DEPEND(ndis, ndisapi, 1, 1, 1); @@ -739,7 +750,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; + ic->ic_caps = IEEE80211_C_STA | IEEE80211_C_IBSS | IEEE80211_C_TXPMGT; setbit(ic->ic_modecaps, IEEE80211_MODE_AUTO); len = 0; r = ndis_get_info(sc, OID_802_11_NETWORK_TYPES_SUPPORTED, @@ -2312,6 +2323,13 @@ ndis_setstate_80211(sc) arg = NDIS_80211_POWERMODE_CAM; ndis_set_info(sc, OID_802_11_POWER_MODE, &arg, &len); + /* Set TX power */ + if (ic->ic_txpowlimit < sizeof(dBm2mW)) { + len = sizeof(arg); + arg = dBm2mW[ic->ic_txpowlimit]; + ndis_set_info(sc, OID_802_11_TX_POWER_LEVEL, &arg, &len); + } + /* * Default encryption mode to off, authentication * to open and privacy to 'accept everything.' @@ -2778,6 +2796,17 @@ ndis_getstate_80211(sc) ic->ic_flags |= IEEE80211_F_PMGTON; } + /* 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 (dBm2mW[i] >= arg) + break; + ic->ic_txpowlimit = i; + } + /* * Use the current association information to reflect * what channel we're on.