1*7569SXinghua.Wen@Sun.COM /* 2*7569SXinghua.Wen@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 3*7569SXinghua.Wen@Sun.COM * Use is subject to license terms. 4*7569SXinghua.Wen@Sun.COM */ 5*7569SXinghua.Wen@Sun.COM 6*7569SXinghua.Wen@Sun.COM /* 7*7569SXinghua.Wen@Sun.COM * Copyright (c) 2008, Intel Corporation 8*7569SXinghua.Wen@Sun.COM * All rights reserved. 9*7569SXinghua.Wen@Sun.COM */ 10*7569SXinghua.Wen@Sun.COM 11*7569SXinghua.Wen@Sun.COM /* 12*7569SXinghua.Wen@Sun.COM * Sun elects to have this file available under and governed by the BSD 13*7569SXinghua.Wen@Sun.COM * license (see below for full license text). However, the following 14*7569SXinghua.Wen@Sun.COM * notice accompanied the original version of this file: 15*7569SXinghua.Wen@Sun.COM */ 16*7569SXinghua.Wen@Sun.COM 17*7569SXinghua.Wen@Sun.COM /* 18*7569SXinghua.Wen@Sun.COM * This file is provided under a dual BSD/GPLv2 license. When using or 19*7569SXinghua.Wen@Sun.COM * redistributing this file, you may do so under either license. 20*7569SXinghua.Wen@Sun.COM * 21*7569SXinghua.Wen@Sun.COM * GPL LICENSE SUMMARY 22*7569SXinghua.Wen@Sun.COM * 23*7569SXinghua.Wen@Sun.COM * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved. 24*7569SXinghua.Wen@Sun.COM * 25*7569SXinghua.Wen@Sun.COM * This program is free software; you can redistribute it and/or modify 26*7569SXinghua.Wen@Sun.COM * it under the terms of version 2 of the GNU Geeral Public License as 27*7569SXinghua.Wen@Sun.COM * published by the Free Software Foundation. 28*7569SXinghua.Wen@Sun.COM * 29*7569SXinghua.Wen@Sun.COM * This program is distributed in the hope that it will be useful, but 30*7569SXinghua.Wen@Sun.COM * WITHOUT ANY WARRANTY; without even the implied warranty of 31*7569SXinghua.Wen@Sun.COM * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32*7569SXinghua.Wen@Sun.COM * General Public License for more details. 33*7569SXinghua.Wen@Sun.COM * 34*7569SXinghua.Wen@Sun.COM * You should have received a copy of the GNU General Public License 35*7569SXinghua.Wen@Sun.COM * along with this program; if not, write to the Free Software 36*7569SXinghua.Wen@Sun.COM * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, 37*7569SXinghua.Wen@Sun.COM * USA 38*7569SXinghua.Wen@Sun.COM * 39*7569SXinghua.Wen@Sun.COM * The full GNU General Public License is included in this distribution 40*7569SXinghua.Wen@Sun.COM * in the file called LICENSE.GPL. 41*7569SXinghua.Wen@Sun.COM * 42*7569SXinghua.Wen@Sun.COM * Contact Information: 43*7569SXinghua.Wen@Sun.COM * James P. Ketrenos <ipw2100-admin@linux.intel.com> 44*7569SXinghua.Wen@Sun.COM * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 45*7569SXinghua.Wen@Sun.COM * 46*7569SXinghua.Wen@Sun.COM * BSD LICENSE 47*7569SXinghua.Wen@Sun.COM * 48*7569SXinghua.Wen@Sun.COM * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved. 49*7569SXinghua.Wen@Sun.COM * All rights reserved. 50*7569SXinghua.Wen@Sun.COM * 51*7569SXinghua.Wen@Sun.COM * Redistribution and use in source and binary forms, with or without 52*7569SXinghua.Wen@Sun.COM * modification, are permitted provided that the following conditions 53*7569SXinghua.Wen@Sun.COM * are met: 54*7569SXinghua.Wen@Sun.COM * 55*7569SXinghua.Wen@Sun.COM * * Redistributions of source code must retain the above copyright 56*7569SXinghua.Wen@Sun.COM * notice, this list of conditions and the following disclaimer. 57*7569SXinghua.Wen@Sun.COM * * Redistributions in binary form must reproduce the above copyright 58*7569SXinghua.Wen@Sun.COM * notice, this list of conditions and the following disclaimer in 59*7569SXinghua.Wen@Sun.COM * the documentation and/or other materials provided with the 60*7569SXinghua.Wen@Sun.COM * distribution. 61*7569SXinghua.Wen@Sun.COM * * Neither the name Intel Corporation nor the names of its 62*7569SXinghua.Wen@Sun.COM * contributors may be used to endorse or promote products derived 63*7569SXinghua.Wen@Sun.COM * from this software without specific prior written permission. 64*7569SXinghua.Wen@Sun.COM * 65*7569SXinghua.Wen@Sun.COM * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 66*7569SXinghua.Wen@Sun.COM * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 67*7569SXinghua.Wen@Sun.COM * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 68*7569SXinghua.Wen@Sun.COM * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 69*7569SXinghua.Wen@Sun.COM * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 70*7569SXinghua.Wen@Sun.COM * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 71*7569SXinghua.Wen@Sun.COM * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 72*7569SXinghua.Wen@Sun.COM * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 73*7569SXinghua.Wen@Sun.COM * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 74*7569SXinghua.Wen@Sun.COM * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 75*7569SXinghua.Wen@Sun.COM * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 76*7569SXinghua.Wen@Sun.COM */ 77*7569SXinghua.Wen@Sun.COM 78*7569SXinghua.Wen@Sun.COM 79*7569SXinghua.Wen@Sun.COM #ifndef _IWK_CALIBRATION_H_ 80*7569SXinghua.Wen@Sun.COM #define _IWK_CALIBRATION_H_ 81*7569SXinghua.Wen@Sun.COM 82*7569SXinghua.Wen@Sun.COM /* 83*7569SXinghua.Wen@Sun.COM * Most Tx and Rx calibration is done by uCode during the initialization 84*7569SXinghua.Wen@Sun.COM * phase of uCode boot. Driver must calibrate only: 85*7569SXinghua.Wen@Sun.COM * 86*7569SXinghua.Wen@Sun.COM * 1) Tx power (depends on temperature) 87*7569SXinghua.Wen@Sun.COM * 2) Receiver gain balance (and detect disconnected antennas) 88*7569SXinghua.Wen@Sun.COM * 3) Receiver sensitivity (to optimize signal detection) 89*7569SXinghua.Wen@Sun.COM */ 90*7569SXinghua.Wen@Sun.COM 91*7569SXinghua.Wen@Sun.COM /* START TEMPERATURE */ 92*7569SXinghua.Wen@Sun.COM 93*7569SXinghua.Wen@Sun.COM /* 94*7569SXinghua.Wen@Sun.COM * 4965 temperature calculation. 95*7569SXinghua.Wen@Sun.COM * 96*7569SXinghua.Wen@Sun.COM * The driver must calculate the device temperature before calculating 97*7569SXinghua.Wen@Sun.COM * a txpower setting (amplifier gain is temperature dependent). The 98*7569SXinghua.Wen@Sun.COM * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration 99*7569SXinghua.Wen@Sun.COM * values used for the life of the driver, and one of which (R4) is the 100*7569SXinghua.Wen@Sun.COM * real-time temperature indicator. 101*7569SXinghua.Wen@Sun.COM * 102*7569SXinghua.Wen@Sun.COM * uCode provides all 4 values to the driver via the "initialize alive" 103*7569SXinghua.Wen@Sun.COM * notification (see struct iwk_init_alive_resp). After the runtime uCode 104*7569SXinghua.Wen@Sun.COM * image loads, uCode updates the R4 value via statistics notifications 105*7569SXinghua.Wen@Sun.COM * (see STATISTICS_NOTIFICATION), which occur after each received beacon 106*7569SXinghua.Wen@Sun.COM * when associated, or can be requested via REPLY_STATISTICS_CMD. 107*7569SXinghua.Wen@Sun.COM * 108*7569SXinghua.Wen@Sun.COM * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver 109*7569SXinghua.Wen@Sun.COM * must sign-extend to 32 bits before applying formula below. 110*7569SXinghua.Wen@Sun.COM * 111*7569SXinghua.Wen@Sun.COM * Formula: 112*7569SXinghua.Wen@Sun.COM * 113*7569SXinghua.Wen@Sun.COM * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8 114*7569SXinghua.Wen@Sun.COM * 115*7569SXinghua.Wen@Sun.COM * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is 116*7569SXinghua.Wen@Sun.COM * an additional correction, which should be centered around 0 degrees 117*7569SXinghua.Wen@Sun.COM * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for 118*7569SXinghua.Wen@Sun.COM * centering the 97/100 correction around 0 degrees K. 119*7569SXinghua.Wen@Sun.COM * 120*7569SXinghua.Wen@Sun.COM * Add 273 to Kelvin value to find degrees Celsius, for comparing current 121*7569SXinghua.Wen@Sun.COM * temperature with factory-measured temperatures when calculating txpower 122*7569SXinghua.Wen@Sun.COM * settings. 123*7569SXinghua.Wen@Sun.COM */ 124*7569SXinghua.Wen@Sun.COM 125*7569SXinghua.Wen@Sun.COM /* END TEMPERATURE */ 126*7569SXinghua.Wen@Sun.COM 127*7569SXinghua.Wen@Sun.COM /* START TXPOWER */ 128*7569SXinghua.Wen@Sun.COM 129*7569SXinghua.Wen@Sun.COM /* 130*7569SXinghua.Wen@Sun.COM * 4965 txpower calculations rely on information from three sources: 131*7569SXinghua.Wen@Sun.COM * 132*7569SXinghua.Wen@Sun.COM * 1) EEPROM 133*7569SXinghua.Wen@Sun.COM * 2) "initialize" alive notification 134*7569SXinghua.Wen@Sun.COM * 3) statistics notifications 135*7569SXinghua.Wen@Sun.COM * 136*7569SXinghua.Wen@Sun.COM * EEPROM data consists of: 137*7569SXinghua.Wen@Sun.COM * 138*7569SXinghua.Wen@Sun.COM * 1) Regulatory information (max txpower and channel usage flags) is provided 139*7569SXinghua.Wen@Sun.COM * separately for each channel that can possibly supported by 4965. 140*7569SXinghua.Wen@Sun.COM * 40 MHz wide (.11n fat) channels are listed separately from 20 MHz 141*7569SXinghua.Wen@Sun.COM * (legacy) channels. 142*7569SXinghua.Wen@Sun.COM * 143*7569SXinghua.Wen@Sun.COM * See struct iwk_eep_channel for format, and struct iwk_eep for 144*7569SXinghua.Wen@Sun.COM * locations in EEPROM. 145*7569SXinghua.Wen@Sun.COM * 146*7569SXinghua.Wen@Sun.COM * 2) Factory txpower calibration information is provided separately for 147*7569SXinghua.Wen@Sun.COM * sub-bands of contiguous channels. 2.4GHz has just one sub-band, 148*7569SXinghua.Wen@Sun.COM * but 5 GHz has several sub-bands. 149*7569SXinghua.Wen@Sun.COM * 150*7569SXinghua.Wen@Sun.COM * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided. 151*7569SXinghua.Wen@Sun.COM * 152*7569SXinghua.Wen@Sun.COM * See struct iwk_eep_calib_info (and the tree of structures contained 153*7569SXinghua.Wen@Sun.COM * within it) for format, and struct iwk_eep for locations in EEPROM. 154*7569SXinghua.Wen@Sun.COM * 155*7569SXinghua.Wen@Sun.COM * "Initialization alive" notification (see struct iwk_init_alive_resp) 156*7569SXinghua.Wen@Sun.COM * consists of: 157*7569SXinghua.Wen@Sun.COM * 158*7569SXinghua.Wen@Sun.COM * 1) Temperature calculation parameters. 159*7569SXinghua.Wen@Sun.COM * 160*7569SXinghua.Wen@Sun.COM * 2) Power supply voltage measurement. 161*7569SXinghua.Wen@Sun.COM * 162*7569SXinghua.Wen@Sun.COM * 3) Tx gain compensation to balance 2 transmitters for MIMO use. 163*7569SXinghua.Wen@Sun.COM * 164*7569SXinghua.Wen@Sun.COM * Statistics notifications deliver: 165*7569SXinghua.Wen@Sun.COM * 166*7569SXinghua.Wen@Sun.COM * 1) Current values for temperature param R4. 167*7569SXinghua.Wen@Sun.COM */ 168*7569SXinghua.Wen@Sun.COM 169*7569SXinghua.Wen@Sun.COM /* 170*7569SXinghua.Wen@Sun.COM * To calculate a txpower setting for a given desired target txpower, channel, 171*7569SXinghua.Wen@Sun.COM * modulation bit rate, and transmitter chain (4965 has 2 transmitters to 172*7569SXinghua.Wen@Sun.COM * support MIMO and transmit diversity), driver must do the following: 173*7569SXinghua.Wen@Sun.COM * 174*7569SXinghua.Wen@Sun.COM * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel. 175*7569SXinghua.Wen@Sun.COM * Do not exceed regulatory limit; reduce target txpower if necessary. 176*7569SXinghua.Wen@Sun.COM * 177*7569SXinghua.Wen@Sun.COM * If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31), 178*7569SXinghua.Wen@Sun.COM * 2 transmitters will be used simultaneously; driver must reduce the 179*7569SXinghua.Wen@Sun.COM * regulatory limit by 3 dB (half-power) for each transmitter, so the 180*7569SXinghua.Wen@Sun.COM * combined total output of the 2 transmitters is within regulatory limits. 181*7569SXinghua.Wen@Sun.COM * 182*7569SXinghua.Wen@Sun.COM * 183*7569SXinghua.Wen@Sun.COM * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by 184*7569SXinghua.Wen@Sun.COM * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]); 185*7569SXinghua.Wen@Sun.COM * reduce target txpower if necessary. 186*7569SXinghua.Wen@Sun.COM * 187*7569SXinghua.Wen@Sun.COM * Backoff values below are in 1/2 dB units (equivalent to steps in 188*7569SXinghua.Wen@Sun.COM * txpower gain tables): 189*7569SXinghua.Wen@Sun.COM * 190*7569SXinghua.Wen@Sun.COM * OFDM 6 - 36 MBit: 10 steps (5 dB) 191*7569SXinghua.Wen@Sun.COM * OFDM 48 MBit: 15 steps (7.5 dB) 192*7569SXinghua.Wen@Sun.COM * OFDM 54 MBit: 17 steps (8.5 dB) 193*7569SXinghua.Wen@Sun.COM * OFDM 60 MBit: 20 steps (10 dB) 194*7569SXinghua.Wen@Sun.COM * CCK all rates: 10 steps (5 dB) 195*7569SXinghua.Wen@Sun.COM * 196*7569SXinghua.Wen@Sun.COM * Backoff values apply to saturation txpower on a per-transmitter basis; 197*7569SXinghua.Wen@Sun.COM * when using MIMO (2 transmitters), each transmitter uses the same 198*7569SXinghua.Wen@Sun.COM * saturation level provided in EEPROM, and the same backoff values; 199*7569SXinghua.Wen@Sun.COM * no reduction (such as with regulatory txpower limits) is required. 200*7569SXinghua.Wen@Sun.COM * 201*7569SXinghua.Wen@Sun.COM * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel 202*7569SXinghua.Wen@Sun.COM * widths and 40 Mhz (.11n fat) channel widths; there is no separate 203*7569SXinghua.Wen@Sun.COM * factory measurement for fat channels. 204*7569SXinghua.Wen@Sun.COM * 205*7569SXinghua.Wen@Sun.COM * The result of this step is the final target txpower. The rest of 206*7569SXinghua.Wen@Sun.COM * the steps figure out the proper settings for the device. 207*7569SXinghua.Wen@Sun.COM * 208*7569SXinghua.Wen@Sun.COM * 209*7569SXinghua.Wen@Sun.COM * 3) Determine (EEPROM) calibration subband for the target channel, by 210*7569SXinghua.Wen@Sun.COM * comparing against first and last channels in each subband 211*7569SXinghua.Wen@Sun.COM * (see struct iwk_eep_calib_subband_info). 212*7569SXinghua.Wen@Sun.COM * 213*7569SXinghua.Wen@Sun.COM * 214*7569SXinghua.Wen@Sun.COM * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, 215*7569SXinghua.Wen@Sun.COM * referencing the 2 factory-measured (sample) channels within the subband. 216*7569SXinghua.Wen@Sun.COM * 217*7569SXinghua.Wen@Sun.COM * Interpolation is based on difference between target channel's frequency 218*7569SXinghua.Wen@Sun.COM * and the sample channels' frequencies. Since channel numbers are based 219*7569SXinghua.Wen@Sun.COM * on frequency (5 MHz between each channel number), this is equivalent 220*7569SXinghua.Wen@Sun.COM * to interpolating based on channel number differences. 221*7569SXinghua.Wen@Sun.COM * 222*7569SXinghua.Wen@Sun.COM * Note that the sample channels may or may not be the channels at the 223*7569SXinghua.Wen@Sun.COM * edges of the subband. The target channel may be "outside" of the 224*7569SXinghua.Wen@Sun.COM * span of the sampled channels. 225*7569SXinghua.Wen@Sun.COM * 226*7569SXinghua.Wen@Sun.COM * Driver may choose the pair (for 2 Tx chains) of measurements (see 227*7569SXinghua.Wen@Sun.COM * struct iwk_eep_calib_channel_info) for which the actual measured 228*7569SXinghua.Wen@Sun.COM * txpower comes closest to the desired txpower. Usually, though, 229*7569SXinghua.Wen@Sun.COM * the middle set of measurements is closest to the regulatory limits, 230*7569SXinghua.Wen@Sun.COM * and is therefore a good choice for all txpower calculations. 231*7569SXinghua.Wen@Sun.COM * 232*7569SXinghua.Wen@Sun.COM * Driver should interpolate both members of the chosen measurement pair, 233*7569SXinghua.Wen@Sun.COM * i.e. for both Tx chains (radio transmitters), unless the driver knows 234*7569SXinghua.Wen@Sun.COM * that only one of the chains will be used (e.g. only one tx antenna 235*7569SXinghua.Wen@Sun.COM * connected, but this should be unusual). 236*7569SXinghua.Wen@Sun.COM * 237*7569SXinghua.Wen@Sun.COM * Driver should interpolate factory values for temperature, gain table 238*7569SXinghua.Wen@Sun.COM * index, and actual power. The power amplifier detector values are 239*7569SXinghua.Wen@Sun.COM * not used by the driver. 240*7569SXinghua.Wen@Sun.COM * 241*7569SXinghua.Wen@Sun.COM * If the target channel happens to be one of the sample channels, the 242*7569SXinghua.Wen@Sun.COM * results should agree with the sample channel's measurements! 243*7569SXinghua.Wen@Sun.COM * 244*7569SXinghua.Wen@Sun.COM * 245*7569SXinghua.Wen@Sun.COM * 5) Find difference between desired txpower and (interpolated) 246*7569SXinghua.Wen@Sun.COM * factory-measured txpower. Using (interpolated) factory gain table index 247*7569SXinghua.Wen@Sun.COM * as a starting point, adjust this index lower to increase txpower, 248*7569SXinghua.Wen@Sun.COM * or higher to decrease txpower, until the target txpower is reached. 249*7569SXinghua.Wen@Sun.COM * Each step in the gain table is 1/2 dB. 250*7569SXinghua.Wen@Sun.COM * 251*7569SXinghua.Wen@Sun.COM * For example, if factory measured txpower is 16 dBm, and target txpower 252*7569SXinghua.Wen@Sun.COM * is 13 dBm, add 6 steps to the factory gain index to reduce txpower 253*7569SXinghua.Wen@Sun.COM * by 3 dB. 254*7569SXinghua.Wen@Sun.COM * 255*7569SXinghua.Wen@Sun.COM * 256*7569SXinghua.Wen@Sun.COM * 6) Find difference between current device temperature and (interpolated) 257*7569SXinghua.Wen@Sun.COM * factory-measured temperature for sub-band. Factory values are in 258*7569SXinghua.Wen@Sun.COM * degrees Celsius. To calculate current temperature, see comments for 259*7569SXinghua.Wen@Sun.COM * "4965 temperature calculation". 260*7569SXinghua.Wen@Sun.COM * 261*7569SXinghua.Wen@Sun.COM * If current temperature is higher than factory temperature, driver must 262*7569SXinghua.Wen@Sun.COM * increase gain (lower gain table index), and vice versa. 263*7569SXinghua.Wen@Sun.COM * 264*7569SXinghua.Wen@Sun.COM * Temperature affects gain differently for different channels: 265*7569SXinghua.Wen@Sun.COM * 266*7569SXinghua.Wen@Sun.COM * 2.4 GHz all channels: 3.5 degrees per half-dB step 267*7569SXinghua.Wen@Sun.COM * 5 GHz channels 34-43: 4.5 degrees per half-dB step 268*7569SXinghua.Wen@Sun.COM * 5 GHz channels >= 44: 4.0 degrees per half-dB step 269*7569SXinghua.Wen@Sun.COM * 270*7569SXinghua.Wen@Sun.COM * NOTE: Temperature can increase rapidly when transmitting, especially 271*7569SXinghua.Wen@Sun.COM * with heavy traffic at high txpowers. Driver should update 272*7569SXinghua.Wen@Sun.COM * temperature calculations often under these conditions to 273*7569SXinghua.Wen@Sun.COM * maintain strong txpower in the face of rising temperature. 274*7569SXinghua.Wen@Sun.COM * 275*7569SXinghua.Wen@Sun.COM * 276*7569SXinghua.Wen@Sun.COM * 7) Find difference between current power supply voltage indicator 277*7569SXinghua.Wen@Sun.COM * (from "initialize alive") and factory-measured power supply voltage 278*7569SXinghua.Wen@Sun.COM * indicator (EEPROM). 279*7569SXinghua.Wen@Sun.COM * 280*7569SXinghua.Wen@Sun.COM * If the current voltage is higher (indicator is lower) than factory 281*7569SXinghua.Wen@Sun.COM * voltage, gain should be reduced (gain table index increased) by: 282*7569SXinghua.Wen@Sun.COM * 283*7569SXinghua.Wen@Sun.COM * (eeprom - current) / 7 284*7569SXinghua.Wen@Sun.COM * 285*7569SXinghua.Wen@Sun.COM * If the current voltage is lower (indicator is higher) than factory 286*7569SXinghua.Wen@Sun.COM * voltage, gain should be increased (gain table index decreased) by: 287*7569SXinghua.Wen@Sun.COM * 288*7569SXinghua.Wen@Sun.COM * 2 * (current - eeprom) / 7 289*7569SXinghua.Wen@Sun.COM * 290*7569SXinghua.Wen@Sun.COM * If number of index steps in either direction turns out to be > 2, 291*7569SXinghua.Wen@Sun.COM * something is wrong ... just use 0. 292*7569SXinghua.Wen@Sun.COM * 293*7569SXinghua.Wen@Sun.COM * NOTE: Voltage compensation is independent of band/channel. 294*7569SXinghua.Wen@Sun.COM * 295*7569SXinghua.Wen@Sun.COM * NOTE: "Initialize" uCode measures current voltage, which is assumed 296*7569SXinghua.Wen@Sun.COM * to be constant after this initial measurement. Voltage 297*7569SXinghua.Wen@Sun.COM * compensation for txpower (number of steps in gain table) 298*7569SXinghua.Wen@Sun.COM * may be calculated once and used until the next uCode bootload. 299*7569SXinghua.Wen@Sun.COM * 300*7569SXinghua.Wen@Sun.COM * 301*7569SXinghua.Wen@Sun.COM * 8) If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31), 302*7569SXinghua.Wen@Sun.COM * adjust txpower for each transmitter chain, so txpower is balanced 303*7569SXinghua.Wen@Sun.COM * between the two chains. There are 5 pairs of tx_atten[group][chain] 304*7569SXinghua.Wen@Sun.COM * values in "initialize alive", one pair for each of 5 channel ranges: 305*7569SXinghua.Wen@Sun.COM * 306*7569SXinghua.Wen@Sun.COM * Group 0: 5 GHz channel 34-43 307*7569SXinghua.Wen@Sun.COM * Group 1: 5 GHz channel 44-70 308*7569SXinghua.Wen@Sun.COM * Group 2: 5 GHz channel 71-124 309*7569SXinghua.Wen@Sun.COM * Group 3: 5 GHz channel 125-200 310*7569SXinghua.Wen@Sun.COM * Group 4: 2.4 GHz all channels 311*7569SXinghua.Wen@Sun.COM * 312*7569SXinghua.Wen@Sun.COM * Add the tx_atten[group][chain] value to the index for the target chain. 313*7569SXinghua.Wen@Sun.COM * The values are signed, but are in pairs of 0 and a non-negative number, 314*7569SXinghua.Wen@Sun.COM * so as to reduce gain (if necessary) of the "hotter" channel. This 315*7569SXinghua.Wen@Sun.COM * avoids any need to double-check for regulatory compliance after 316*7569SXinghua.Wen@Sun.COM * this step. 317*7569SXinghua.Wen@Sun.COM * 318*7569SXinghua.Wen@Sun.COM * 319*7569SXinghua.Wen@Sun.COM * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation 320*7569SXinghua.Wen@Sun.COM * value to the index: 321*7569SXinghua.Wen@Sun.COM * 322*7569SXinghua.Wen@Sun.COM * Hardware rev B: 9 steps (4.5 dB) 323*7569SXinghua.Wen@Sun.COM * Hardware rev C: 5 steps (2.5 dB) 324*7569SXinghua.Wen@Sun.COM * 325*7569SXinghua.Wen@Sun.COM * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, 326*7569SXinghua.Wen@Sun.COM * bits [3:2], 1 = B, 2 = C. 327*7569SXinghua.Wen@Sun.COM * 328*7569SXinghua.Wen@Sun.COM * NOTE: This compensation is in addition to any saturation backoff that 329*7569SXinghua.Wen@Sun.COM * might have been applied in an earlier step. 330*7569SXinghua.Wen@Sun.COM * 331*7569SXinghua.Wen@Sun.COM * 332*7569SXinghua.Wen@Sun.COM * 10) Select the gain table, based on band (2.4 vs 5 GHz). 333*7569SXinghua.Wen@Sun.COM * 334*7569SXinghua.Wen@Sun.COM * Limit the adjusted index to stay within the table! 335*7569SXinghua.Wen@Sun.COM * 336*7569SXinghua.Wen@Sun.COM * 337*7569SXinghua.Wen@Sun.COM * 11) Read gain table entries for DSP and radio gain, place into appropriate 338*7569SXinghua.Wen@Sun.COM * location(s) in command. 339*7569SXinghua.Wen@Sun.COM */ 340*7569SXinghua.Wen@Sun.COM 341*7569SXinghua.Wen@Sun.COM /* Temperature calibration offset is 3% 0C in Kelvin */ 342*7569SXinghua.Wen@Sun.COM #define TEMPERATURE_CALIB_KELVIN_OFFSET 8 343*7569SXinghua.Wen@Sun.COM #define TEMPERATURE_CALIB_A_VAL 259 344*7569SXinghua.Wen@Sun.COM 345*7569SXinghua.Wen@Sun.COM #define KELVIN_TO_CELSIUS(x) ((x)-273) 346*7569SXinghua.Wen@Sun.COM #define CELSIUS_TO_KELVIN(x) ((x)+273) 347*7569SXinghua.Wen@Sun.COM 348*7569SXinghua.Wen@Sun.COM /* First and last channels of all groups */ 349*7569SXinghua.Wen@Sun.COM #define CALIB_IWK_TX_ATTEN_GR1_FCH 34 350*7569SXinghua.Wen@Sun.COM #define CALIB_IWK_TX_ATTEN_GR1_LCH 43 351*7569SXinghua.Wen@Sun.COM #define CALIB_IWK_TX_ATTEN_GR2_FCH 44 352*7569SXinghua.Wen@Sun.COM #define CALIB_IWK_TX_ATTEN_GR2_LCH 70 353*7569SXinghua.Wen@Sun.COM #define CALIB_IWK_TX_ATTEN_GR3_FCH 71 354*7569SXinghua.Wen@Sun.COM #define CALIB_IWK_TX_ATTEN_GR3_LCH 124 355*7569SXinghua.Wen@Sun.COM #define CALIB_IWK_TX_ATTEN_GR4_FCH 125 356*7569SXinghua.Wen@Sun.COM #define CALIB_IWK_TX_ATTEN_GR4_LCH 200 357*7569SXinghua.Wen@Sun.COM #define CALIB_IWK_TX_ATTEN_GR5_FCH 1 358*7569SXinghua.Wen@Sun.COM #define CALIB_IWK_TX_ATTEN_GR5_LCH 20 359*7569SXinghua.Wen@Sun.COM 360*7569SXinghua.Wen@Sun.COM /* Limit range of txpower output target to be between these values */ 361*7569SXinghua.Wen@Sun.COM #define IWK_TX_POWER_TARGET_POWER_MIN (0) /* 0 dBm = 1 milliwatt */ 362*7569SXinghua.Wen@Sun.COM #define IWK_TX_POWER_TARGET_POWER_MAX (16) /* 16 dBm */ 363*7569SXinghua.Wen@Sun.COM 364*7569SXinghua.Wen@Sun.COM #define TX_POWER_IWK_ILLEGAL_VOLTAGE (-10000) 365*7569SXinghua.Wen@Sun.COM 366*7569SXinghua.Wen@Sun.COM /* 367*7569SXinghua.Wen@Sun.COM * 4965 power supply voltage compensation 368*7569SXinghua.Wen@Sun.COM */ 369*7569SXinghua.Wen@Sun.COM #define TX_POWER_IWK_VOLTAGE_CODES_PER_03V (7) 370*7569SXinghua.Wen@Sun.COM 371*7569SXinghua.Wen@Sun.COM /* Limit range of calculated temperature to be between these Kelvin values */ 372*7569SXinghua.Wen@Sun.COM #define IWK_TX_POWER_TEMPERATURE_MIN (263) 373*7569SXinghua.Wen@Sun.COM #define IWK_TX_POWER_TEMPERATURE_MAX (410) 374*7569SXinghua.Wen@Sun.COM 375*7569SXinghua.Wen@Sun.COM union iwk_tx_power_dual_stream { 376*7569SXinghua.Wen@Sun.COM struct { 377*7569SXinghua.Wen@Sun.COM uint8_t radio_tx_gain[2]; 378*7569SXinghua.Wen@Sun.COM uint8_t dsp_predis_atten[2]; 379*7569SXinghua.Wen@Sun.COM } s; 380*7569SXinghua.Wen@Sun.COM uint32_t dw; 381*7569SXinghua.Wen@Sun.COM }; 382*7569SXinghua.Wen@Sun.COM 383*7569SXinghua.Wen@Sun.COM #define POWER_TABLE_NUM_ENTRIES (33) 384*7569SXinghua.Wen@Sun.COM #define POWER_TABLE_CCK_ENTRY (32) 385*7569SXinghua.Wen@Sun.COM 386*7569SXinghua.Wen@Sun.COM /* 387*7569SXinghua.Wen@Sun.COM * When MIMO is used (2 transmitters operating simultaneously), driver should 388*7569SXinghua.Wen@Sun.COM * limit each transmitter to deliver a max of 3 dB below the regulatory limit 389*7569SXinghua.Wen@Sun.COM * for the device. That is, half power for each transmitter, so total power 390*7569SXinghua.Wen@Sun.COM * is within regulatory limits. 391*7569SXinghua.Wen@Sun.COM * 392*7569SXinghua.Wen@Sun.COM * The value "6" represents number of steps in gain table to reduce power. 393*7569SXinghua.Wen@Sun.COM * Each step is 1/2 dB. 394*7569SXinghua.Wen@Sun.COM */ 395*7569SXinghua.Wen@Sun.COM #define IWK_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) 396*7569SXinghua.Wen@Sun.COM 397*7569SXinghua.Wen@Sun.COM /* 398*7569SXinghua.Wen@Sun.COM * CCK gain compensation. 399*7569SXinghua.Wen@Sun.COM * 400*7569SXinghua.Wen@Sun.COM * When calculating txpowers for CCK, after making sure that the target power 401*7569SXinghua.Wen@Sun.COM * is within regulatory and saturation limits, driver must additionally 402*7569SXinghua.Wen@Sun.COM * back off gain by adding these values to the gain table index. 403*7569SXinghua.Wen@Sun.COM */ 404*7569SXinghua.Wen@Sun.COM #define IWK_TX_POWER_CCK_COMPENSATION_C_STEP (5) 405*7569SXinghua.Wen@Sun.COM 406*7569SXinghua.Wen@Sun.COM /* 407*7569SXinghua.Wen@Sun.COM * Gain tables. 408*7569SXinghua.Wen@Sun.COM * 409*7569SXinghua.Wen@Sun.COM * The following tables contain pair of values for setting txpower, i.e. 410*7569SXinghua.Wen@Sun.COM * gain settings for the output of the device's digital signal processor (DSP), 411*7569SXinghua.Wen@Sun.COM * and for the analog gain structure of the transmitter. 412*7569SXinghua.Wen@Sun.COM * 413*7569SXinghua.Wen@Sun.COM * Each entry in the gain tables represents a step of 1/2 dB. Note that these 414*7569SXinghua.Wen@Sun.COM * are *relative* steps, not indications of absolute output power. Output 415*7569SXinghua.Wen@Sun.COM * power varies with temperature, voltage, and channel frequency, and also 416*7569SXinghua.Wen@Sun.COM * requires consideration of average power (to satisfy regulatory constraints), 417*7569SXinghua.Wen@Sun.COM * and peak power (to avoid distortion of the output signal). 418*7569SXinghua.Wen@Sun.COM * 419*7569SXinghua.Wen@Sun.COM * Each entry contains two values: 420*7569SXinghua.Wen@Sun.COM * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained 421*7569SXinghua.Wen@Sun.COM * linear value that multiplies the output of the digital signal processor, 422*7569SXinghua.Wen@Sun.COM * before being sent to the analog radio. 423*7569SXinghua.Wen@Sun.COM * 2) Radio gain. This sets the analog gain of the radio Tx path. 424*7569SXinghua.Wen@Sun.COM * It is a coarser setting, and behaves in a logarithmic (dB) fashion. 425*7569SXinghua.Wen@Sun.COM * 426*7569SXinghua.Wen@Sun.COM * EEPROM contains factory calibration data for txpower. This maps actual 427*7569SXinghua.Wen@Sun.COM * measured txpower levels to gain settings in the "well known" tables 428*7569SXinghua.Wen@Sun.COM * below ("well-known" means here that both factory calibration *and* the 429*7569SXinghua.Wen@Sun.COM * driver work with the same table). 430*7569SXinghua.Wen@Sun.COM * 431*7569SXinghua.Wen@Sun.COM * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table 432*7569SXinghua.Wen@Sun.COM * has an extension (into negative indexes), in case the driver needs to 433*7569SXinghua.Wen@Sun.COM * boost power setting for high device temperatures (higher than would be 434*7569SXinghua.Wen@Sun.COM * present during factory calibration). A 5 Ghz EEPROM index of "40" 435*7569SXinghua.Wen@Sun.COM * corresponds to the 49th entry in the table used by the driver. 436*7569SXinghua.Wen@Sun.COM */ 437*7569SXinghua.Wen@Sun.COM #define MIN_TX_GAIN_INDEX (0) /* highest gain, lowest idx, 2.4 */ 438*7569SXinghua.Wen@Sun.COM #define MIN_TX_GAIN_INDEX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ 439*7569SXinghua.Wen@Sun.COM 440*7569SXinghua.Wen@Sun.COM struct gain_entry { 441*7569SXinghua.Wen@Sun.COM uint8_t dsp; 442*7569SXinghua.Wen@Sun.COM uint8_t radio; 443*7569SXinghua.Wen@Sun.COM }; 444*7569SXinghua.Wen@Sun.COM 445*7569SXinghua.Wen@Sun.COM static const struct gain_entry gains_table[2][108] = { 446*7569SXinghua.Wen@Sun.COM /* 5.2GHz power gain index table */ 447*7569SXinghua.Wen@Sun.COM { 448*7569SXinghua.Wen@Sun.COM {123, 0x3F}, /* highest txpower */ 449*7569SXinghua.Wen@Sun.COM {117, 0x3F}, 450*7569SXinghua.Wen@Sun.COM {110, 0x3F}, 451*7569SXinghua.Wen@Sun.COM {104, 0x3F}, 452*7569SXinghua.Wen@Sun.COM {98, 0x3F}, 453*7569SXinghua.Wen@Sun.COM {110, 0x3E}, 454*7569SXinghua.Wen@Sun.COM {104, 0x3E}, 455*7569SXinghua.Wen@Sun.COM {98, 0x3E}, 456*7569SXinghua.Wen@Sun.COM {110, 0x3D}, 457*7569SXinghua.Wen@Sun.COM {104, 0x3D}, 458*7569SXinghua.Wen@Sun.COM {98, 0x3D}, 459*7569SXinghua.Wen@Sun.COM {110, 0x3C}, 460*7569SXinghua.Wen@Sun.COM {104, 0x3C}, 461*7569SXinghua.Wen@Sun.COM {98, 0x3C}, 462*7569SXinghua.Wen@Sun.COM {110, 0x3B}, 463*7569SXinghua.Wen@Sun.COM {104, 0x3B}, 464*7569SXinghua.Wen@Sun.COM {98, 0x3B}, 465*7569SXinghua.Wen@Sun.COM {110, 0x3A}, 466*7569SXinghua.Wen@Sun.COM {104, 0x3A}, 467*7569SXinghua.Wen@Sun.COM {98, 0x3A}, 468*7569SXinghua.Wen@Sun.COM {110, 0x39}, 469*7569SXinghua.Wen@Sun.COM {104, 0x39}, 470*7569SXinghua.Wen@Sun.COM {98, 0x39}, 471*7569SXinghua.Wen@Sun.COM {110, 0x38}, 472*7569SXinghua.Wen@Sun.COM {104, 0x38}, 473*7569SXinghua.Wen@Sun.COM {98, 0x38}, 474*7569SXinghua.Wen@Sun.COM {110, 0x37}, 475*7569SXinghua.Wen@Sun.COM {104, 0x37}, 476*7569SXinghua.Wen@Sun.COM {98, 0x37}, 477*7569SXinghua.Wen@Sun.COM {110, 0x36}, 478*7569SXinghua.Wen@Sun.COM {104, 0x36}, 479*7569SXinghua.Wen@Sun.COM {98, 0x36}, 480*7569SXinghua.Wen@Sun.COM {110, 0x35}, 481*7569SXinghua.Wen@Sun.COM {104, 0x35}, 482*7569SXinghua.Wen@Sun.COM {98, 0x35}, 483*7569SXinghua.Wen@Sun.COM {110, 0x34}, 484*7569SXinghua.Wen@Sun.COM {104, 0x34}, 485*7569SXinghua.Wen@Sun.COM {98, 0x34}, 486*7569SXinghua.Wen@Sun.COM {110, 0x33}, 487*7569SXinghua.Wen@Sun.COM {104, 0x33}, 488*7569SXinghua.Wen@Sun.COM {98, 0x33}, 489*7569SXinghua.Wen@Sun.COM {110, 0x32}, 490*7569SXinghua.Wen@Sun.COM {104, 0x32}, 491*7569SXinghua.Wen@Sun.COM {98, 0x32}, 492*7569SXinghua.Wen@Sun.COM {110, 0x31}, 493*7569SXinghua.Wen@Sun.COM {104, 0x31}, 494*7569SXinghua.Wen@Sun.COM {98, 0x31}, 495*7569SXinghua.Wen@Sun.COM {110, 0x30}, 496*7569SXinghua.Wen@Sun.COM {104, 0x30}, 497*7569SXinghua.Wen@Sun.COM {98, 0x30}, 498*7569SXinghua.Wen@Sun.COM {110, 0x25}, 499*7569SXinghua.Wen@Sun.COM {104, 0x25}, 500*7569SXinghua.Wen@Sun.COM {98, 0x25}, 501*7569SXinghua.Wen@Sun.COM {110, 0x24}, 502*7569SXinghua.Wen@Sun.COM {104, 0x24}, 503*7569SXinghua.Wen@Sun.COM {98, 0x24}, 504*7569SXinghua.Wen@Sun.COM {110, 0x23}, 505*7569SXinghua.Wen@Sun.COM {104, 0x23}, 506*7569SXinghua.Wen@Sun.COM {98, 0x23}, 507*7569SXinghua.Wen@Sun.COM {110, 0x22}, 508*7569SXinghua.Wen@Sun.COM {104, 0x18}, 509*7569SXinghua.Wen@Sun.COM {98, 0x18}, 510*7569SXinghua.Wen@Sun.COM {110, 0x17}, 511*7569SXinghua.Wen@Sun.COM {104, 0x17}, 512*7569SXinghua.Wen@Sun.COM {98, 0x17}, 513*7569SXinghua.Wen@Sun.COM {110, 0x16}, 514*7569SXinghua.Wen@Sun.COM {104, 0x16}, 515*7569SXinghua.Wen@Sun.COM {98, 0x16}, 516*7569SXinghua.Wen@Sun.COM {110, 0x15}, 517*7569SXinghua.Wen@Sun.COM {104, 0x15}, 518*7569SXinghua.Wen@Sun.COM {98, 0x15}, 519*7569SXinghua.Wen@Sun.COM {110, 0x14}, 520*7569SXinghua.Wen@Sun.COM {104, 0x14}, 521*7569SXinghua.Wen@Sun.COM {98, 0x14}, 522*7569SXinghua.Wen@Sun.COM {110, 0x13}, 523*7569SXinghua.Wen@Sun.COM {104, 0x13}, 524*7569SXinghua.Wen@Sun.COM {98, 0x13}, 525*7569SXinghua.Wen@Sun.COM {110, 0x12}, 526*7569SXinghua.Wen@Sun.COM {104, 0x08}, 527*7569SXinghua.Wen@Sun.COM {98, 0x08}, 528*7569SXinghua.Wen@Sun.COM {110, 0x07}, 529*7569SXinghua.Wen@Sun.COM {104, 0x07}, 530*7569SXinghua.Wen@Sun.COM {98, 0x07}, 531*7569SXinghua.Wen@Sun.COM {110, 0x06}, 532*7569SXinghua.Wen@Sun.COM {104, 0x06}, 533*7569SXinghua.Wen@Sun.COM {98, 0x06}, 534*7569SXinghua.Wen@Sun.COM {110, 0x05}, 535*7569SXinghua.Wen@Sun.COM {104, 0x05}, 536*7569SXinghua.Wen@Sun.COM {98, 0x05}, 537*7569SXinghua.Wen@Sun.COM {110, 0x04}, 538*7569SXinghua.Wen@Sun.COM {104, 0x04}, 539*7569SXinghua.Wen@Sun.COM {98, 0x04}, 540*7569SXinghua.Wen@Sun.COM {110, 0x03}, 541*7569SXinghua.Wen@Sun.COM {104, 0x03}, 542*7569SXinghua.Wen@Sun.COM {98, 0x03}, 543*7569SXinghua.Wen@Sun.COM {110, 0x02}, 544*7569SXinghua.Wen@Sun.COM {104, 0x02}, 545*7569SXinghua.Wen@Sun.COM {98, 0x02}, 546*7569SXinghua.Wen@Sun.COM {110, 0x01}, 547*7569SXinghua.Wen@Sun.COM {104, 0x01}, 548*7569SXinghua.Wen@Sun.COM {98, 0x01}, 549*7569SXinghua.Wen@Sun.COM {110, 0x00}, 550*7569SXinghua.Wen@Sun.COM {104, 0x00}, 551*7569SXinghua.Wen@Sun.COM {98, 0x00}, 552*7569SXinghua.Wen@Sun.COM {93, 0x00}, 553*7569SXinghua.Wen@Sun.COM {88, 0x00}, 554*7569SXinghua.Wen@Sun.COM {83, 0x00}, 555*7569SXinghua.Wen@Sun.COM {78, 0x00}, 556*7569SXinghua.Wen@Sun.COM }, 557*7569SXinghua.Wen@Sun.COM /* 2.4GHz power gain index table */ 558*7569SXinghua.Wen@Sun.COM { 559*7569SXinghua.Wen@Sun.COM {110, 0x3f}, /* highest txpower */ 560*7569SXinghua.Wen@Sun.COM {104, 0x3f}, 561*7569SXinghua.Wen@Sun.COM {98, 0x3f}, 562*7569SXinghua.Wen@Sun.COM {110, 0x3e}, 563*7569SXinghua.Wen@Sun.COM {104, 0x3e}, 564*7569SXinghua.Wen@Sun.COM {98, 0x3e}, 565*7569SXinghua.Wen@Sun.COM {110, 0x3d}, 566*7569SXinghua.Wen@Sun.COM {104, 0x3d}, 567*7569SXinghua.Wen@Sun.COM {98, 0x3d}, 568*7569SXinghua.Wen@Sun.COM {110, 0x3c}, 569*7569SXinghua.Wen@Sun.COM {104, 0x3c}, 570*7569SXinghua.Wen@Sun.COM {98, 0x3c}, 571*7569SXinghua.Wen@Sun.COM {110, 0x3b}, 572*7569SXinghua.Wen@Sun.COM {104, 0x3b}, 573*7569SXinghua.Wen@Sun.COM {98, 0x3b}, 574*7569SXinghua.Wen@Sun.COM {110, 0x3a}, 575*7569SXinghua.Wen@Sun.COM {104, 0x3a}, 576*7569SXinghua.Wen@Sun.COM {98, 0x3a}, 577*7569SXinghua.Wen@Sun.COM {110, 0x39}, 578*7569SXinghua.Wen@Sun.COM {104, 0x39}, 579*7569SXinghua.Wen@Sun.COM {98, 0x39}, 580*7569SXinghua.Wen@Sun.COM {110, 0x38}, 581*7569SXinghua.Wen@Sun.COM {104, 0x38}, 582*7569SXinghua.Wen@Sun.COM {98, 0x38}, 583*7569SXinghua.Wen@Sun.COM {110, 0x37}, 584*7569SXinghua.Wen@Sun.COM {104, 0x37}, 585*7569SXinghua.Wen@Sun.COM {98, 0x37}, 586*7569SXinghua.Wen@Sun.COM {110, 0x36}, 587*7569SXinghua.Wen@Sun.COM {104, 0x36}, 588*7569SXinghua.Wen@Sun.COM {98, 0x36}, 589*7569SXinghua.Wen@Sun.COM {110, 0x35}, 590*7569SXinghua.Wen@Sun.COM {104, 0x35}, 591*7569SXinghua.Wen@Sun.COM {98, 0x35}, 592*7569SXinghua.Wen@Sun.COM {110, 0x34}, 593*7569SXinghua.Wen@Sun.COM {104, 0x34}, 594*7569SXinghua.Wen@Sun.COM {98, 0x34}, 595*7569SXinghua.Wen@Sun.COM {110, 0x33}, 596*7569SXinghua.Wen@Sun.COM {104, 0x33}, 597*7569SXinghua.Wen@Sun.COM {98, 0x33}, 598*7569SXinghua.Wen@Sun.COM {110, 0x32}, 599*7569SXinghua.Wen@Sun.COM {104, 0x32}, 600*7569SXinghua.Wen@Sun.COM {98, 0x32}, 601*7569SXinghua.Wen@Sun.COM {110, 0x31}, 602*7569SXinghua.Wen@Sun.COM {104, 0x31}, 603*7569SXinghua.Wen@Sun.COM {98, 0x31}, 604*7569SXinghua.Wen@Sun.COM {110, 0x30}, 605*7569SXinghua.Wen@Sun.COM {104, 0x30}, 606*7569SXinghua.Wen@Sun.COM {98, 0x30}, 607*7569SXinghua.Wen@Sun.COM {110, 0x6}, 608*7569SXinghua.Wen@Sun.COM {104, 0x6}, 609*7569SXinghua.Wen@Sun.COM {98, 0x6}, 610*7569SXinghua.Wen@Sun.COM {110, 0x5}, 611*7569SXinghua.Wen@Sun.COM {104, 0x5}, 612*7569SXinghua.Wen@Sun.COM {98, 0x5}, 613*7569SXinghua.Wen@Sun.COM {110, 0x4}, 614*7569SXinghua.Wen@Sun.COM {104, 0x4}, 615*7569SXinghua.Wen@Sun.COM {98, 0x4}, 616*7569SXinghua.Wen@Sun.COM {110, 0x3}, 617*7569SXinghua.Wen@Sun.COM {104, 0x3}, 618*7569SXinghua.Wen@Sun.COM {98, 0x3}, 619*7569SXinghua.Wen@Sun.COM {110, 0x2}, 620*7569SXinghua.Wen@Sun.COM {104, 0x2}, 621*7569SXinghua.Wen@Sun.COM {98, 0x2}, 622*7569SXinghua.Wen@Sun.COM {110, 0x1}, 623*7569SXinghua.Wen@Sun.COM {104, 0x1}, 624*7569SXinghua.Wen@Sun.COM {98, 0x1}, 625*7569SXinghua.Wen@Sun.COM {110, 0x0}, 626*7569SXinghua.Wen@Sun.COM {104, 0x0}, 627*7569SXinghua.Wen@Sun.COM {98, 0x0}, 628*7569SXinghua.Wen@Sun.COM {97, 0}, 629*7569SXinghua.Wen@Sun.COM {96, 0}, 630*7569SXinghua.Wen@Sun.COM {95, 0}, 631*7569SXinghua.Wen@Sun.COM {94, 0}, 632*7569SXinghua.Wen@Sun.COM {93, 0}, 633*7569SXinghua.Wen@Sun.COM {92, 0}, 634*7569SXinghua.Wen@Sun.COM {91, 0}, 635*7569SXinghua.Wen@Sun.COM {90, 0}, 636*7569SXinghua.Wen@Sun.COM {89, 0}, 637*7569SXinghua.Wen@Sun.COM {88, 0}, 638*7569SXinghua.Wen@Sun.COM {87, 0}, 639*7569SXinghua.Wen@Sun.COM {86, 0}, 640*7569SXinghua.Wen@Sun.COM {85, 0}, 641*7569SXinghua.Wen@Sun.COM {84, 0}, 642*7569SXinghua.Wen@Sun.COM {83, 0}, 643*7569SXinghua.Wen@Sun.COM {82, 0}, 644*7569SXinghua.Wen@Sun.COM {81, 0}, 645*7569SXinghua.Wen@Sun.COM {80, 0}, 646*7569SXinghua.Wen@Sun.COM {79, 0}, 647*7569SXinghua.Wen@Sun.COM {78, 0}, 648*7569SXinghua.Wen@Sun.COM {77, 0}, 649*7569SXinghua.Wen@Sun.COM {76, 0}, 650*7569SXinghua.Wen@Sun.COM {75, 0}, 651*7569SXinghua.Wen@Sun.COM {74, 0}, 652*7569SXinghua.Wen@Sun.COM {73, 0}, 653*7569SXinghua.Wen@Sun.COM {72, 0}, 654*7569SXinghua.Wen@Sun.COM {71, 0}, 655*7569SXinghua.Wen@Sun.COM {70, 0}, 656*7569SXinghua.Wen@Sun.COM {69, 0}, 657*7569SXinghua.Wen@Sun.COM {68, 0}, 658*7569SXinghua.Wen@Sun.COM {67, 0}, 659*7569SXinghua.Wen@Sun.COM {66, 0}, 660*7569SXinghua.Wen@Sun.COM {65, 0}, 661*7569SXinghua.Wen@Sun.COM {64, 0}, 662*7569SXinghua.Wen@Sun.COM {63, 0}, 663*7569SXinghua.Wen@Sun.COM {62, 0}, 664*7569SXinghua.Wen@Sun.COM {61, 0}, 665*7569SXinghua.Wen@Sun.COM {60, 0}, 666*7569SXinghua.Wen@Sun.COM {59, 0}, 667*7569SXinghua.Wen@Sun.COM } 668*7569SXinghua.Wen@Sun.COM }; 669*7569SXinghua.Wen@Sun.COM 670*7569SXinghua.Wen@Sun.COM /* END TXPOWER */ 671*7569SXinghua.Wen@Sun.COM 672*7569SXinghua.Wen@Sun.COM struct statistics_div { 673*7569SXinghua.Wen@Sun.COM uint32_t tx_on_a; 674*7569SXinghua.Wen@Sun.COM uint32_t tx_on_b; 675*7569SXinghua.Wen@Sun.COM uint32_t exec_time; 676*7569SXinghua.Wen@Sun.COM uint32_t probe_time; 677*7569SXinghua.Wen@Sun.COM uint32_t reserved1; 678*7569SXinghua.Wen@Sun.COM uint32_t reserved2; 679*7569SXinghua.Wen@Sun.COM }; 680*7569SXinghua.Wen@Sun.COM 681*7569SXinghua.Wen@Sun.COM struct statistics_dbg { 682*7569SXinghua.Wen@Sun.COM uint32_t burst_check; 683*7569SXinghua.Wen@Sun.COM uint32_t burst_count; 684*7569SXinghua.Wen@Sun.COM uint32_t reserved[4]; 685*7569SXinghua.Wen@Sun.COM }; 686*7569SXinghua.Wen@Sun.COM 687*7569SXinghua.Wen@Sun.COM 688*7569SXinghua.Wen@Sun.COM struct statistics_general { 689*7569SXinghua.Wen@Sun.COM uint32_t temperature; 690*7569SXinghua.Wen@Sun.COM uint32_t temperature_m; 691*7569SXinghua.Wen@Sun.COM struct statistics_dbg dbg; 692*7569SXinghua.Wen@Sun.COM uint32_t sleep_time; 693*7569SXinghua.Wen@Sun.COM uint32_t slots_out; 694*7569SXinghua.Wen@Sun.COM uint32_t slots_idle; 695*7569SXinghua.Wen@Sun.COM uint32_t ttl_timestamp; 696*7569SXinghua.Wen@Sun.COM struct statistics_div div; 697*7569SXinghua.Wen@Sun.COM uint32_t rx_enable_counter; 698*7569SXinghua.Wen@Sun.COM uint32_t reserved1; 699*7569SXinghua.Wen@Sun.COM uint32_t reserved2; 700*7569SXinghua.Wen@Sun.COM uint32_t reserved3; 701*7569SXinghua.Wen@Sun.COM }; 702*7569SXinghua.Wen@Sun.COM 703*7569SXinghua.Wen@Sun.COM 704*7569SXinghua.Wen@Sun.COM struct statistics_tx_non_phy_agg { 705*7569SXinghua.Wen@Sun.COM uint32_t ba_timeout; 706*7569SXinghua.Wen@Sun.COM uint32_t ba_reschedule_frames; 707*7569SXinghua.Wen@Sun.COM uint32_t scd_query_agg_frame_cnt; 708*7569SXinghua.Wen@Sun.COM uint32_t scd_query_no_agg; 709*7569SXinghua.Wen@Sun.COM uint32_t scd_query_agg; 710*7569SXinghua.Wen@Sun.COM uint32_t scd_query_mismatch; 711*7569SXinghua.Wen@Sun.COM uint32_t frame_not_ready; 712*7569SXinghua.Wen@Sun.COM uint32_t underrun; 713*7569SXinghua.Wen@Sun.COM uint32_t bt_prio_kill; 714*7569SXinghua.Wen@Sun.COM uint32_t rx_ba_rsp_cnt; 715*7569SXinghua.Wen@Sun.COM uint32_t reserved2; 716*7569SXinghua.Wen@Sun.COM uint32_t reserved3; 717*7569SXinghua.Wen@Sun.COM }; 718*7569SXinghua.Wen@Sun.COM 719*7569SXinghua.Wen@Sun.COM 720*7569SXinghua.Wen@Sun.COM struct statistics_tx { 721*7569SXinghua.Wen@Sun.COM uint32_t preamble_cnt; 722*7569SXinghua.Wen@Sun.COM uint32_t rx_detected_cnt; 723*7569SXinghua.Wen@Sun.COM uint32_t bt_prio_defer_cnt; 724*7569SXinghua.Wen@Sun.COM uint32_t bt_prio_kill_cnt; 725*7569SXinghua.Wen@Sun.COM uint32_t few_bytes_cnt; 726*7569SXinghua.Wen@Sun.COM uint32_t cts_timeout; 727*7569SXinghua.Wen@Sun.COM uint32_t ack_timeout; 728*7569SXinghua.Wen@Sun.COM uint32_t expected_ack_cnt; 729*7569SXinghua.Wen@Sun.COM uint32_t actual_ack_cnt; 730*7569SXinghua.Wen@Sun.COM uint32_t dump_msdu_cnt; 731*7569SXinghua.Wen@Sun.COM uint32_t burst_abort_next_frame_mismatch_cnt; 732*7569SXinghua.Wen@Sun.COM uint32_t burst_abort_missing_next_frame_cnt; 733*7569SXinghua.Wen@Sun.COM uint32_t cts_timeout_collision; 734*7569SXinghua.Wen@Sun.COM uint32_t ack_or_ba_timeout_collision; 735*7569SXinghua.Wen@Sun.COM struct statistics_tx_non_phy_agg agg; 736*7569SXinghua.Wen@Sun.COM }; 737*7569SXinghua.Wen@Sun.COM 738*7569SXinghua.Wen@Sun.COM 739*7569SXinghua.Wen@Sun.COM struct statistics_rx_ht_phy { 740*7569SXinghua.Wen@Sun.COM uint32_t plcp_err; 741*7569SXinghua.Wen@Sun.COM uint32_t overrun_err; 742*7569SXinghua.Wen@Sun.COM uint32_t early_overrun_err; 743*7569SXinghua.Wen@Sun.COM uint32_t crc32_good; 744*7569SXinghua.Wen@Sun.COM uint32_t crc32_err; 745*7569SXinghua.Wen@Sun.COM uint32_t mh_format_err; 746*7569SXinghua.Wen@Sun.COM uint32_t agg_crc32_good; 747*7569SXinghua.Wen@Sun.COM uint32_t agg_mpdu_cnt; 748*7569SXinghua.Wen@Sun.COM uint32_t agg_cnt; 749*7569SXinghua.Wen@Sun.COM uint32_t reserved2; 750*7569SXinghua.Wen@Sun.COM }; 751*7569SXinghua.Wen@Sun.COM 752*7569SXinghua.Wen@Sun.COM struct statistics_rx_non_phy { 753*7569SXinghua.Wen@Sun.COM uint32_t bogus_cts; /* CTS received when not expecting CTS */ 754*7569SXinghua.Wen@Sun.COM uint32_t bogus_ack; /* ACK received when not expecting ACK */ 755*7569SXinghua.Wen@Sun.COM uint32_t non_bssid_frames; /* number of frames with BSSID that */ 756*7569SXinghua.Wen@Sun.COM /* doesn't belong to the STA BSSID */ 757*7569SXinghua.Wen@Sun.COM uint32_t filtered_frames; /* count frames that were dumped in the */ 758*7569SXinghua.Wen@Sun.COM /* filtering process */ 759*7569SXinghua.Wen@Sun.COM uint32_t non_channel_beacons; /* beacons with our bss id but not on */ 760*7569SXinghua.Wen@Sun.COM /* our serving channel */ 761*7569SXinghua.Wen@Sun.COM uint32_t channel_beacons; /* beacons with our bss id and in our */ 762*7569SXinghua.Wen@Sun.COM /* serving channel */ 763*7569SXinghua.Wen@Sun.COM uint32_t num_missed_bcon; /* number of missed beacons */ 764*7569SXinghua.Wen@Sun.COM uint32_t adc_rx_saturation_time; /* count in 0.8us units the time */ 765*7569SXinghua.Wen@Sun.COM /* the ADC was in saturation */ 766*7569SXinghua.Wen@Sun.COM uint32_t ina_detection_search_time; /* total time (in 0.8us) */ 767*7569SXinghua.Wen@Sun.COM /* searched for INA */ 768*7569SXinghua.Wen@Sun.COM uint32_t beacon_silence_rssi_a; /* RSSI silence after beacon frame */ 769*7569SXinghua.Wen@Sun.COM uint32_t beacon_silence_rssi_b; /* RSSI silence after beacon frame */ 770*7569SXinghua.Wen@Sun.COM uint32_t beacon_silence_rssi_c; /* RSSI silence after beacon frame */ 771*7569SXinghua.Wen@Sun.COM uint32_t interference_data_flag; /* flag for interference data */ 772*7569SXinghua.Wen@Sun.COM /* availability. 1 when data is */ 773*7569SXinghua.Wen@Sun.COM /* available. */ 774*7569SXinghua.Wen@Sun.COM uint32_t channel_load; /* counts RX Enable time */ 775*7569SXinghua.Wen@Sun.COM uint32_t dsp_false_alarms; /* DSP false alarm (both OFDM */ 776*7569SXinghua.Wen@Sun.COM /* and CCK) counter */ 777*7569SXinghua.Wen@Sun.COM uint32_t beacon_rssi_a; 778*7569SXinghua.Wen@Sun.COM uint32_t beacon_rssi_b; 779*7569SXinghua.Wen@Sun.COM uint32_t beacon_rssi_c; 780*7569SXinghua.Wen@Sun.COM uint32_t beacon_energy_a; 781*7569SXinghua.Wen@Sun.COM uint32_t beacon_energy_b; 782*7569SXinghua.Wen@Sun.COM uint32_t beacon_energy_c; 783*7569SXinghua.Wen@Sun.COM }; 784*7569SXinghua.Wen@Sun.COM 785*7569SXinghua.Wen@Sun.COM struct statistics_rx_phy { 786*7569SXinghua.Wen@Sun.COM uint32_t ina_cnt; 787*7569SXinghua.Wen@Sun.COM uint32_t fina_cnt; 788*7569SXinghua.Wen@Sun.COM uint32_t plcp_err; 789*7569SXinghua.Wen@Sun.COM uint32_t crc32_err; 790*7569SXinghua.Wen@Sun.COM uint32_t overrun_err; 791*7569SXinghua.Wen@Sun.COM uint32_t early_overrun_err; 792*7569SXinghua.Wen@Sun.COM uint32_t crc32_good; 793*7569SXinghua.Wen@Sun.COM uint32_t false_alarm_cnt; 794*7569SXinghua.Wen@Sun.COM uint32_t fina_sync_err_cnt; 795*7569SXinghua.Wen@Sun.COM uint32_t sfd_timeout; 796*7569SXinghua.Wen@Sun.COM uint32_t fina_timeout; 797*7569SXinghua.Wen@Sun.COM uint32_t unresponded_rts; 798*7569SXinghua.Wen@Sun.COM uint32_t rxe_frame_limit_overrun; 799*7569SXinghua.Wen@Sun.COM uint32_t sent_ack_cnt; 800*7569SXinghua.Wen@Sun.COM uint32_t sent_cts_cnt; 801*7569SXinghua.Wen@Sun.COM uint32_t sent_ba_rsp_cnt; 802*7569SXinghua.Wen@Sun.COM uint32_t dsp_self_kill; 803*7569SXinghua.Wen@Sun.COM uint32_t mh_format_err; 804*7569SXinghua.Wen@Sun.COM uint32_t re_acq_main_rssi_sum; 805*7569SXinghua.Wen@Sun.COM uint32_t reserved3; 806*7569SXinghua.Wen@Sun.COM }; 807*7569SXinghua.Wen@Sun.COM 808*7569SXinghua.Wen@Sun.COM struct statistics_rx { 809*7569SXinghua.Wen@Sun.COM struct statistics_rx_phy ofdm; 810*7569SXinghua.Wen@Sun.COM struct statistics_rx_phy cck; 811*7569SXinghua.Wen@Sun.COM struct statistics_rx_non_phy general; 812*7569SXinghua.Wen@Sun.COM struct statistics_rx_ht_phy ofdm_ht; 813*7569SXinghua.Wen@Sun.COM }; 814*7569SXinghua.Wen@Sun.COM 815*7569SXinghua.Wen@Sun.COM struct iwk_notif_statistics { 816*7569SXinghua.Wen@Sun.COM uint32_t flag; 817*7569SXinghua.Wen@Sun.COM struct statistics_rx rx; 818*7569SXinghua.Wen@Sun.COM struct statistics_tx tx; 819*7569SXinghua.Wen@Sun.COM struct statistics_general general; 820*7569SXinghua.Wen@Sun.COM }; 821*7569SXinghua.Wen@Sun.COM 822*7569SXinghua.Wen@Sun.COM /* START Receiver gain balance */ 823*7569SXinghua.Wen@Sun.COM 824*7569SXinghua.Wen@Sun.COM /* 825*7569SXinghua.Wen@Sun.COM * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response) 826*7569SXinghua.Wen@Sun.COM * 827*7569SXinghua.Wen@Sun.COM * This command sets the relative gains of 4965's 3 radio receiver chains. 828*7569SXinghua.Wen@Sun.COM * 829*7569SXinghua.Wen@Sun.COM * After the first association, driver should accumulate signal and noise 830*7569SXinghua.Wen@Sun.COM * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20 831*7569SXinghua.Wen@Sun.COM * beacons from the associated network (don't collect statistics that come 832*7569SXinghua.Wen@Sun.COM * in from scanning, or any other non-network source). 833*7569SXinghua.Wen@Sun.COM * 834*7569SXinghua.Wen@Sun.COM * DISCONNECTED ANTENNA: 835*7569SXinghua.Wen@Sun.COM * 836*7569SXinghua.Wen@Sun.COM * Driver should determine which antennas are actually connected, by comparing 837*7569SXinghua.Wen@Sun.COM * average beacon signal levels for the 3 Rx chains. Accumulate (add) the 838*7569SXinghua.Wen@Sun.COM * following values over 20 beacons, one accumulator for each of the chains 839*7569SXinghua.Wen@Sun.COM * a/b/c, from struct statistics_rx_non_phy: 840*7569SXinghua.Wen@Sun.COM * 841*7569SXinghua.Wen@Sun.COM * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB) 842*7569SXinghua.Wen@Sun.COM * 843*7569SXinghua.Wen@Sun.COM * Find the strongest signal from among a/b/c. Compare the other two to the 844*7569SXinghua.Wen@Sun.COM * strongest. If any signal is more than 15 dB (times 20, unless you 845*7569SXinghua.Wen@Sun.COM * divide the accumulated values by 20) below the strongest, the driver 846*7569SXinghua.Wen@Sun.COM * considers that antenna to be disconnected, and should not try to use that 847*7569SXinghua.Wen@Sun.COM * antenna/chain for Rx or Tx. If both A and B seem to be disconnected, 848*7569SXinghua.Wen@Sun.COM * driver should declare the stronger one as connected, and attempt to use it 849*7569SXinghua.Wen@Sun.COM * (A and B are the only 2 Tx chains!). 850*7569SXinghua.Wen@Sun.COM * 851*7569SXinghua.Wen@Sun.COM * 852*7569SXinghua.Wen@Sun.COM * RX BALANCE: 853*7569SXinghua.Wen@Sun.COM * 854*7569SXinghua.Wen@Sun.COM * Driver should balance the 3 receivers (but just the ones that are connected 855*7569SXinghua.Wen@Sun.COM * to antennas, see above) for gain, by comparing the average signal levels 856*7569SXinghua.Wen@Sun.COM * detected during the silence after each beacon (background noise). 857*7569SXinghua.Wen@Sun.COM * Accumulate (add) the following values over 20 beacons, one accumulator for 858*7569SXinghua.Wen@Sun.COM * each of the chains a/b/c, from struct statistics_rx_non_phy: 859*7569SXinghua.Wen@Sun.COM * 860*7569SXinghua.Wen@Sun.COM * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB) 861*7569SXinghua.Wen@Sun.COM * 862*7569SXinghua.Wen@Sun.COM * Find the weakest background noise level from among a/b/c. This Rx chain 863*7569SXinghua.Wen@Sun.COM * will be the reference, with 0 gain adjustment. Attenuate other channels by 864*7569SXinghua.Wen@Sun.COM * finding noise difference: 865*7569SXinghua.Wen@Sun.COM * 866*7569SXinghua.Wen@Sun.COM * (accum_noise[i] - accum_noise[reference]) / 30 867*7569SXinghua.Wen@Sun.COM * 868*7569SXinghua.Wen@Sun.COM * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB. 869*7569SXinghua.Wen@Sun.COM * For use in diff_gain_[abc] fields of struct iwk_calibration_cmd, the 870*7569SXinghua.Wen@Sun.COM * driver should limit the difference results to a range of 0-3 (0-4.5 dB), 871*7569SXinghua.Wen@Sun.COM * and set bit 2 to indicate "reduce gain". The value for the reference 872*7569SXinghua.Wen@Sun.COM * (weakest) chain should be "0". 873*7569SXinghua.Wen@Sun.COM * 874*7569SXinghua.Wen@Sun.COM * diff_gain_[abc] bit fields: 875*7569SXinghua.Wen@Sun.COM * 2: (1) reduce gain, (0) increase gain 876*7569SXinghua.Wen@Sun.COM * 1-0: amount of gain, units of 1.5 dB 877*7569SXinghua.Wen@Sun.COM */ 878*7569SXinghua.Wen@Sun.COM 879*7569SXinghua.Wen@Sun.COM #define RX_CHAINS_NUM (3) 880*7569SXinghua.Wen@Sun.COM #define CHAIN_GAIN_DIFF_INIT_VAL (4) 881*7569SXinghua.Wen@Sun.COM 882*7569SXinghua.Wen@Sun.COM #define IWK_GAIN_DIFF_ALIVE (0) 883*7569SXinghua.Wen@Sun.COM #define IWK_GAIN_DIFF_ACCUMULATE (1) 884*7569SXinghua.Wen@Sun.COM #define IWK_GAIN_DIFF_CALIBRATED (2) 885*7569SXinghua.Wen@Sun.COM 886*7569SXinghua.Wen@Sun.COM #define INTERFERENCE_DATA_AVAILABLE (1) 887*7569SXinghua.Wen@Sun.COM #define BEACON_NUM_20 (20) 888*7569SXinghua.Wen@Sun.COM #define MAX_ALLOWED_DIFF (15) 889*7569SXinghua.Wen@Sun.COM 890*7569SXinghua.Wen@Sun.COM struct iwk_rx_gain_diff { 891*7569SXinghua.Wen@Sun.COM uint8_t state; 892*7569SXinghua.Wen@Sun.COM uint16_t beacon_count; 893*7569SXinghua.Wen@Sun.COM uint8_t gain_diff_send; 894*7569SXinghua.Wen@Sun.COM uint32_t beacon_stren_a; 895*7569SXinghua.Wen@Sun.COM uint32_t beacon_stren_b; 896*7569SXinghua.Wen@Sun.COM uint32_t beacon_stren_c; 897*7569SXinghua.Wen@Sun.COM uint32_t noise_stren_a; 898*7569SXinghua.Wen@Sun.COM uint32_t noise_stren_b; 899*7569SXinghua.Wen@Sun.COM uint32_t noise_stren_c; 900*7569SXinghua.Wen@Sun.COM uint8_t disconnect_chain[RX_CHAINS_NUM]; 901*7569SXinghua.Wen@Sun.COM uint8_t connected_chains; 902*7569SXinghua.Wen@Sun.COM uint8_t gain_diff_chain[RX_CHAINS_NUM]; 903*7569SXinghua.Wen@Sun.COM }; 904*7569SXinghua.Wen@Sun.COM 905*7569SXinghua.Wen@Sun.COM /* END Receiver gain balance */ 906*7569SXinghua.Wen@Sun.COM 907*7569SXinghua.Wen@Sun.COM /* START Receiver sensitivity */ 908*7569SXinghua.Wen@Sun.COM 909*7569SXinghua.Wen@Sun.COM /* 910*7569SXinghua.Wen@Sun.COM * SENSITIVITY_CMD = 0xa8 911*7569SXinghua.Wen@Sun.COM * 912*7569SXinghua.Wen@Sun.COM * This command sets up the Rx signal detector for a sensitivity level that 913*7569SXinghua.Wen@Sun.COM * is high enough to lock onto all signals within the associated network, 914*7569SXinghua.Wen@Sun.COM * but low enough to ignore signals that are below a certain threshold, so as 915*7569SXinghua.Wen@Sun.COM * not to have too many "false alarms". False alarms are signals that the 916*7569SXinghua.Wen@Sun.COM * Rx DSP tries to lock onto, but then discards after determining that they 917*7569SXinghua.Wen@Sun.COM * are noise. 918*7569SXinghua.Wen@Sun.COM * 919*7569SXinghua.Wen@Sun.COM * The optimum number of false alarms is between 5 and 50 per 200 TUs 920*7569SXinghua.Wen@Sun.COM * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e. 921*7569SXinghua.Wen@Sun.COM * time listening, not transmitting). Driver must adjust sensitivity so that 922*7569SXinghua.Wen@Sun.COM * the ratio of actual false alarms to actual Rx time falls within this range. 923*7569SXinghua.Wen@Sun.COM * 924*7569SXinghua.Wen@Sun.COM * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each 925*7569SXinghua.Wen@Sun.COM * received beacon. These provide information to the driver to analyze the 926*7569SXinghua.Wen@Sun.COM * sensitivity. Don't analyze statistics that come in from scanning, or any 927*7569SXinghua.Wen@Sun.COM * other non-associated-network source. Pertinent statistics include: 928*7569SXinghua.Wen@Sun.COM * 929*7569SXinghua.Wen@Sun.COM * From "general" statistics (struct statistics_rx_non_phy): 930*7569SXinghua.Wen@Sun.COM * 931*7569SXinghua.Wen@Sun.COM * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level) 932*7569SXinghua.Wen@Sun.COM * Measure of energy of desired signal. Used for establishing a level 933*7569SXinghua.Wen@Sun.COM * below which the device does not detect signals. 934*7569SXinghua.Wen@Sun.COM * 935*7569SXinghua.Wen@Sun.COM * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB) 936*7569SXinghua.Wen@Sun.COM * Measure of background noise in silent period after beacon. 937*7569SXinghua.Wen@Sun.COM * 938*7569SXinghua.Wen@Sun.COM * channel_load 939*7569SXinghua.Wen@Sun.COM * uSecs of actual Rx time during beacon period (varies according to 940*7569SXinghua.Wen@Sun.COM * how much time was spent transmitting). 941*7569SXinghua.Wen@Sun.COM * 942*7569SXinghua.Wen@Sun.COM * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately: 943*7569SXinghua.Wen@Sun.COM * 944*7569SXinghua.Wen@Sun.COM * false_alarm_cnt 945*7569SXinghua.Wen@Sun.COM * Signal locks abandoned early (before phy-level header). 946*7569SXinghua.Wen@Sun.COM * 947*7569SXinghua.Wen@Sun.COM * plcp_err 948*7569SXinghua.Wen@Sun.COM * Signal locks abandoned late (during phy-level header). 949*7569SXinghua.Wen@Sun.COM * 950*7569SXinghua.Wen@Sun.COM * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from 951*7569SXinghua.Wen@Sun.COM * beacon to beacon, i.e. each value is an accumulation of all errors 952*7569SXinghua.Wen@Sun.COM * before and including the latest beacon. Values will wrap around to 0 953*7569SXinghua.Wen@Sun.COM * after counting up to 2^32 - 1. Driver must differentiate vs. 954*7569SXinghua.Wen@Sun.COM * previous beacon's values to determine # false alarms in the current 955*7569SXinghua.Wen@Sun.COM * beacon period. 956*7569SXinghua.Wen@Sun.COM * 957*7569SXinghua.Wen@Sun.COM * Total number of false alarms = false_alarms + plcp_errs 958*7569SXinghua.Wen@Sun.COM * 959*7569SXinghua.Wen@Sun.COM * For OFDM, adjust the following table entries in struct iwk_rx_sensitivity_cmd 960*7569SXinghua.Wen@Sun.COM * (notice that the start points for OFDM are at or close to settings for 961*7569SXinghua.Wen@Sun.COM * maximum sensitivity): 962*7569SXinghua.Wen@Sun.COM * 963*7569SXinghua.Wen@Sun.COM * START / MIN / MAX 964*7569SXinghua.Wen@Sun.COM * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120 965*7569SXinghua.Wen@Sun.COM * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210 966*7569SXinghua.Wen@Sun.COM * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140 967*7569SXinghua.Wen@Sun.COM * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270 968*7569SXinghua.Wen@Sun.COM * 969*7569SXinghua.Wen@Sun.COM * If actual rate of OFDM false alarms (+ plcp_errors) is too high 970*7569SXinghua.Wen@Sun.COM * (greater than 50 for each 204.8 msecs listening), reduce sensitivity 971*7569SXinghua.Wen@Sun.COM * by *adding* 1 to all 4 of the table entries above, up to the max for 972*7569SXinghua.Wen@Sun.COM * each entry. Conversely, if false alarm rate is too low (less than 5 973*7569SXinghua.Wen@Sun.COM * for each 204.8 msecs listening), *subtract* 1 from each entry to 974*7569SXinghua.Wen@Sun.COM * increase sensitivity. 975*7569SXinghua.Wen@Sun.COM * 976*7569SXinghua.Wen@Sun.COM * For CCK sensitivity, keep track of the following: 977*7569SXinghua.Wen@Sun.COM * 978*7569SXinghua.Wen@Sun.COM * 1). 20-beacon history of maximum background noise, indicated by 979*7569SXinghua.Wen@Sun.COM * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the 980*7569SXinghua.Wen@Sun.COM * 3 receivers. For any given beacon, the "silence reference" is 981*7569SXinghua.Wen@Sun.COM * the maximum of last 60 samples (20 beacons * 3 receivers). 982*7569SXinghua.Wen@Sun.COM * 983*7569SXinghua.Wen@Sun.COM * 2). 10-beacon history of strongest signal level, as indicated 984*7569SXinghua.Wen@Sun.COM * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers, 985*7569SXinghua.Wen@Sun.COM * i.e. the strength of the signal through the best receiver at the 986*7569SXinghua.Wen@Sun.COM * moment. These measurements are "upside down", with lower values 987*7569SXinghua.Wen@Sun.COM * for stronger signals, so max energy will be *minimum* value. 988*7569SXinghua.Wen@Sun.COM * 989*7569SXinghua.Wen@Sun.COM * Then for any given beacon, the driver must determine the *weakest* 990*7569SXinghua.Wen@Sun.COM * of the strongest signals; this is the minimum level that needs to be 991*7569SXinghua.Wen@Sun.COM * successfully detected, when using the best receiver at the moment. 992*7569SXinghua.Wen@Sun.COM * "Max cck energy" is the maximum (higher value means lower energy!) 993*7569SXinghua.Wen@Sun.COM * of the last 10 minima. Once this is determined, driver must add 994*7569SXinghua.Wen@Sun.COM * a little margin by adding "6" to it. 995*7569SXinghua.Wen@Sun.COM * 996*7569SXinghua.Wen@Sun.COM * 3). Number of consecutive beacon periods with too few false alarms. 997*7569SXinghua.Wen@Sun.COM * Reset this to 0 at the first beacon period that falls within the 998*7569SXinghua.Wen@Sun.COM * "good" range (5 to 50 false alarms per 204.8 milliseconds rx). 999*7569SXinghua.Wen@Sun.COM * 1000*7569SXinghua.Wen@Sun.COM * Then, adjust the following CCK table entries in struct iwk_rx_sensitivity_cmd 1001*7569SXinghua.Wen@Sun.COM * (notice that the start points for CCK are at maximum sensitivity): 1002*7569SXinghua.Wen@Sun.COM * 1003*7569SXinghua.Wen@Sun.COM * START / MIN / MAX 1004*7569SXinghua.Wen@Sun.COM * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200 1005*7569SXinghua.Wen@Sun.COM * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400 1006*7569SXinghua.Wen@Sun.COM * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100 1007*7569SXinghua.Wen@Sun.COM * 1008*7569SXinghua.Wen@Sun.COM * If actual rate of CCK false alarms (+ plcp_errors) is too high 1009*7569SXinghua.Wen@Sun.COM * (greater than 50 for each 204.8 msecs listening), method for reducing 1010*7569SXinghua.Wen@Sun.COM * sensitivity is: 1011*7569SXinghua.Wen@Sun.COM * 1012*7569SXinghua.Wen@Sun.COM * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX, 1013*7569SXinghua.Wen@Sun.COM * up to max 400. 1014*7569SXinghua.Wen@Sun.COM * 1015*7569SXinghua.Wen@Sun.COM * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160, 1016*7569SXinghua.Wen@Sun.COM * sensitivity has been reduced a significant amount; bring it up to 1017*7569SXinghua.Wen@Sun.COM * a moderate 161. Otherwise, *add* 3, up to max 200. 1018*7569SXinghua.Wen@Sun.COM * 1019*7569SXinghua.Wen@Sun.COM * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160, 1020*7569SXinghua.Wen@Sun.COM * sensitivity has been reduced only a moderate or small amount; 1021*7569SXinghua.Wen@Sun.COM * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX, 1022*7569SXinghua.Wen@Sun.COM * down to min 0. Otherwise (if gain has been significantly reduced), 1023*7569SXinghua.Wen@Sun.COM * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value. 1024*7569SXinghua.Wen@Sun.COM * 1025*7569SXinghua.Wen@Sun.COM * b) Save a snapshot of the "silence reference". 1026*7569SXinghua.Wen@Sun.COM * 1027*7569SXinghua.Wen@Sun.COM * If actual rate of CCK false alarms (+ plcp_errors) is too low 1028*7569SXinghua.Wen@Sun.COM * (less than 5 for each 204.8 msecs listening), method for increasing 1029*7569SXinghua.Wen@Sun.COM * sensitivity is used only if: 1030*7569SXinghua.Wen@Sun.COM * 1031*7569SXinghua.Wen@Sun.COM * 1a) Previous beacon did not have too many false alarms 1032*7569SXinghua.Wen@Sun.COM * 1b) AND difference between previous "silence reference" and current 1033*7569SXinghua.Wen@Sun.COM * "silence reference" (prev - current) is 2 or more, 1034*7569SXinghua.Wen@Sun.COM * OR 2) 100 or more consecutive beacon periods have had rate of 1035*7569SXinghua.Wen@Sun.COM * less than 5 false alarms per 204.8 milliseconds rx time. 1036*7569SXinghua.Wen@Sun.COM * 1037*7569SXinghua.Wen@Sun.COM * Method for increasing sensitivity: 1038*7569SXinghua.Wen@Sun.COM * 1039*7569SXinghua.Wen@Sun.COM * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX, 1040*7569SXinghua.Wen@Sun.COM * down to min 125. 1041*7569SXinghua.Wen@Sun.COM * 1042*7569SXinghua.Wen@Sun.COM * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX, 1043*7569SXinghua.Wen@Sun.COM * down to min 200. 1044*7569SXinghua.Wen@Sun.COM * 1045*7569SXinghua.Wen@Sun.COM * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100. 1046*7569SXinghua.Wen@Sun.COM * 1047*7569SXinghua.Wen@Sun.COM * If actual rate of CCK false alarms (+ plcp_errors) is within good range 1048*7569SXinghua.Wen@Sun.COM * (between 5 and 50 for each 204.8 msecs listening): 1049*7569SXinghua.Wen@Sun.COM * 1050*7569SXinghua.Wen@Sun.COM * 1) Save a snapshot of the silence reference. 1051*7569SXinghua.Wen@Sun.COM * 1052*7569SXinghua.Wen@Sun.COM * 2) If previous beacon had too many CCK false alarms (+ plcp_errors), 1053*7569SXinghua.Wen@Sun.COM * give some extra margin to energy threshold by *subtracting* 8 1054*7569SXinghua.Wen@Sun.COM * from value in HD_MIN_ENERGY_CCK_DET_INDEX. 1055*7569SXinghua.Wen@Sun.COM * 1056*7569SXinghua.Wen@Sun.COM * For all cases (too few, too many, good range), make sure that the CCK 1057*7569SXinghua.Wen@Sun.COM * detection threshold (energy) is below the energy level for robust 1058*7569SXinghua.Wen@Sun.COM * detection over the past 10 beacon periods, the "Max cck energy". 1059*7569SXinghua.Wen@Sun.COM * Lower values mean higher energy; this means making sure that the value 1060*7569SXinghua.Wen@Sun.COM * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy". 1061*7569SXinghua.Wen@Sun.COM * 1062*7569SXinghua.Wen@Sun.COM * Driver should set the following entries to fixed values: 1063*7569SXinghua.Wen@Sun.COM * 1064*7569SXinghua.Wen@Sun.COM * HD_MIN_ENERGY_OFDM_DET_INDEX 100 1065*7569SXinghua.Wen@Sun.COM * HD_BARKER_CORR_TH_ADD_MIN_INDEX 190 1066*7569SXinghua.Wen@Sun.COM * HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX 390 1067*7569SXinghua.Wen@Sun.COM * HD_OFDM_ENERGY_TH_IN_INDEX 62 1068*7569SXinghua.Wen@Sun.COM */ 1069*7569SXinghua.Wen@Sun.COM 1070*7569SXinghua.Wen@Sun.COM #define IWK_SENSITIVITY_CALIB_ALLOW_MSK (1 << 0) 1071*7569SXinghua.Wen@Sun.COM #define IWK_SENSITIVITY_OFDM_UPDATE_MSK (1 << 1) 1072*7569SXinghua.Wen@Sun.COM #define IWK_SENSITIVITY_CCK_UPDATE_MSK (1 << 2) 1073*7569SXinghua.Wen@Sun.COM 1074*7569SXinghua.Wen@Sun.COM #define MIN_ENERGY_CCK_DET_IDX (0) 1075*7569SXinghua.Wen@Sun.COM #define MIN_ENERGY_OFDM_DET_IDX (1) 1076*7569SXinghua.Wen@Sun.COM #define AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) 1077*7569SXinghua.Wen@Sun.COM #define AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX (3) 1078*7569SXinghua.Wen@Sun.COM #define AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX (4) 1079*7569SXinghua.Wen@Sun.COM #define AUTO_CORR32_X4_TH_ADD_MIN_IDX (5) 1080*7569SXinghua.Wen@Sun.COM #define AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX (6) 1081*7569SXinghua.Wen@Sun.COM #define BARKER_CORR_TH_ADD_MIN_IDX (7) 1082*7569SXinghua.Wen@Sun.COM #define BARKER_CORR_TH_ADD_MIN_MRC_IDX (8) 1083*7569SXinghua.Wen@Sun.COM #define AUTO_CORR40_X4_TH_ADD_MIN_IDX (9) 1084*7569SXinghua.Wen@Sun.COM #define PTAM_ENERGY_TH_IDX (10) 1085*7569SXinghua.Wen@Sun.COM 1086*7569SXinghua.Wen@Sun.COM #define IWK_GOOD_RANGE_FALSE_ALARM (0) 1087*7569SXinghua.Wen@Sun.COM #define IWK_TOO_MANY_FALSE_ALARM (1) 1088*7569SXinghua.Wen@Sun.COM #define IWK_TOO_FEW_FALSE_ALARM (2) 1089*7569SXinghua.Wen@Sun.COM 1090*7569SXinghua.Wen@Sun.COM #define IWK_SENSITIVITY_CONTROL_DEFAULT_TABLE (0) 1091*7569SXinghua.Wen@Sun.COM #define IWK_SENSITIVITY_CONTROL_WORK_TABLE (1) 1092*7569SXinghua.Wen@Sun.COM 1093*7569SXinghua.Wen@Sun.COM struct iwk_rx_sensitivity_cmd { 1094*7569SXinghua.Wen@Sun.COM uint16_t control; 1095*7569SXinghua.Wen@Sun.COM uint16_t table[11]; 1096*7569SXinghua.Wen@Sun.COM }; 1097*7569SXinghua.Wen@Sun.COM 1098*7569SXinghua.Wen@Sun.COM struct iwk_rx_sensitivity { 1099*7569SXinghua.Wen@Sun.COM uint16_t auto_corr_ofdm_x4; 1100*7569SXinghua.Wen@Sun.COM uint16_t auto_corr_mrc_ofdm_x4; 1101*7569SXinghua.Wen@Sun.COM uint16_t auto_corr_ofdm_x1; 1102*7569SXinghua.Wen@Sun.COM uint16_t auto_corr_mrc_ofdm_x1; 1103*7569SXinghua.Wen@Sun.COM 1104*7569SXinghua.Wen@Sun.COM uint16_t auto_corr_cck_x4; 1105*7569SXinghua.Wen@Sun.COM uint16_t auto_corr_mrc_cck_x4; 1106*7569SXinghua.Wen@Sun.COM uint16_t min_energy_det_cck; 1107*7569SXinghua.Wen@Sun.COM 1108*7569SXinghua.Wen@Sun.COM uint16_t flags; 1109*7569SXinghua.Wen@Sun.COM 1110*7569SXinghua.Wen@Sun.COM uint32_t last_bad_plcp_cnt_ofdm; 1111*7569SXinghua.Wen@Sun.COM uint32_t last_false_alarm_cnt_ofdm; 1112*7569SXinghua.Wen@Sun.COM uint32_t last_bad_plcp_cnt_cck; 1113*7569SXinghua.Wen@Sun.COM uint32_t last_false_alarm_cnt_cck; 1114*7569SXinghua.Wen@Sun.COM 1115*7569SXinghua.Wen@Sun.COM uint32_t cck_curr_state; 1116*7569SXinghua.Wen@Sun.COM uint32_t cck_prev_state; 1117*7569SXinghua.Wen@Sun.COM uint32_t cck_beacon_min[10]; 1118*7569SXinghua.Wen@Sun.COM uint32_t cck_beacon_idx; 1119*7569SXinghua.Wen@Sun.COM uint8_t cck_noise_max[20]; 1120*7569SXinghua.Wen@Sun.COM uint32_t cck_noise_ref; 1121*7569SXinghua.Wen@Sun.COM uint32_t cck_noise_idx; 1122*7569SXinghua.Wen@Sun.COM int32_t cck_noise_diff; 1123*7569SXinghua.Wen@Sun.COM uint32_t cck_no_false_alarm_num; 1124*7569SXinghua.Wen@Sun.COM }; 1125*7569SXinghua.Wen@Sun.COM 1126*7569SXinghua.Wen@Sun.COM /* END Receiver sensitivity */ 1127*7569SXinghua.Wen@Sun.COM 1128*7569SXinghua.Wen@Sun.COM #endif /* _IWK_CALIBRATION_H_ */ 1129