/* * il_verify_inst_sparse - verify runtime uCode image in card vs. host, * using sample data 100 bytes apart. If these sample points are good, * it's a pretty good bet that everything between them is good, too.
*/ staticint
il4965_verify_inst_sparse(struct il_priv *il, __le32 * image, u32 len)
{
u32 val; int ret = 0;
u32 errcnt = 0;
u32 i;
D_INFO("ucode inst image size is %u\n", len);
for (i = 0; i < len; i += 100, image += 100 / sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log
* if IL_DL_IO is set */
il_wr(il, HBUS_TARG_MEM_RADDR, i + IL4965_RTC_INST_LOWER_BOUND);
val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) {
ret = -EIO;
errcnt++; if (errcnt >= 3) break;
}
}
return ret;
}
/* * il4965_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data.
*/ staticint
il4965_verify_inst_full(struct il_priv *il, __le32 * image, u32 len)
{
u32 val;
u32 save_len = len; int ret = 0;
u32 errcnt;
errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log
* if IL_DL_IO is set */
val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) {
IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n",
save_len - len, val, le32_to_cpu(*image));
ret = -EIO;
errcnt++; if (errcnt >= 20) break;
}
}
if (!errcnt)
D_INFO("ucode image in INSTRUCTION memory is good\n");
return ret;
}
/* * il4965_verify_ucode - determine which instruction image is in SRAM, * and verify its contents
*/ int
il4965_verify_ucode(struct il_priv *il)
{
__le32 *image;
u32 len; int ret;
/* Try bootstrap */
image = (__le32 *) il->ucode_boot.v_addr;
len = il->ucode_boot.len;
ret = il4965_verify_inst_sparse(il, image, len); if (!ret) {
D_INFO("Bootstrap uCode is good in inst SRAM\n"); return 0;
}
/* Try initialize */
image = (__le32 *) il->ucode_init.v_addr;
len = il->ucode_init.len;
ret = il4965_verify_inst_sparse(il, image, len); if (!ret) {
D_INFO("Initialize uCode is good in inst SRAM\n"); return 0;
}
/* Try runtime/protocol */
image = (__le32 *) il->ucode_code.v_addr;
len = il->ucode_code.len;
ret = il4965_verify_inst_sparse(il, image, len); if (!ret) {
D_INFO("Runtime uCode is good in inst SRAM\n"); return 0;
}
IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
/* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue.
* Selection of bootstrap image (vs. other images) is arbitrary. */
image = (__le32 *) il->ucode_boot.v_addr;
len = il->ucode_boot.len;
ret = il4965_verify_inst_full(il, image, len);
return ret;
}
/****************************************************************************** * * EEPROM related functions *
******************************************************************************/
/* * The device's EEPROM semaphore prevents conflicts between driver and uCode * when accessing the EEPROM; each access is a series of pulses to/from the * EEPROM chip, not a single event, so even reads could conflict if they * weren't arbitrated by the semaphore.
*/ int
il4965_eeprom_acquire_semaphore(struct il_priv *il)
{
u16 count; int ret;
/* See if we got it */
ret =
_il_poll_bit(il, CSR_HW_IF_CONFIG_REG,
CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
EEPROM_SEM_TIMEOUT); if (ret >= 0) return ret;
}
/* check contents of special bootstrap uCode SRAM */ staticint
il4965_verify_bsm(struct il_priv *il)
{
__le32 *image = il->ucode_boot.v_addr;
u32 len = il->ucode_boot.len;
u32 reg;
u32 val;
D_INFO("Begin verify bsm\n");
/* verify BSM SRAM contents */
val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len;
reg += sizeof(u32), image++) {
val = il_rd_prph(il, reg); if (val != le32_to_cpu(*image)) {
IL_ERR("BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n",
BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND,
len, val, le32_to_cpu(*image)); return -EIO;
}
}
D_INFO("BSM bootstrap uCode image OK\n");
return 0;
}
/* * il4965_load_bsm - Load bootstrap instructions * * BSM operation: * * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program * in special SRAM that does not power down during RFKILL. When powering back * up after power-saving sleeps (or during initial uCode load), the BSM loads * the bootstrap program into the on-board processor, and starts it. * * The bootstrap program loads (via DMA) instructions and data for a new * program from host DRAM locations indicated by the host driver in the * BSM_DRAM_* registers. Once the new program is loaded, it starts * automatically. * * When initializing the NIC, the host driver points the BSM to the * "initialize" uCode image. This uCode sets up some internal data, then * notifies host via "initialize alive" that it is complete. * * The host then replaces the BSM_DRAM_* pointer values to point to the * normal runtime uCode instructions and a backup uCode data cache buffer * (filled initially with starting data values for the on-board processor), * then triggers the "initialize" uCode to load and launch the runtime uCode, * which begins normal operation. * * When doing a power-save shutdown, runtime uCode saves data SRAM into * the backup data cache in DRAM before SRAM is powered down. * * When powering back up, the BSM loads the bootstrap program. This reloads * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off.
*/ staticint
il4965_load_bsm(struct il_priv *il)
{
__le32 *image = il->ucode_boot.v_addr;
u32 len = il->ucode_boot.len;
dma_addr_t pinst;
dma_addr_t pdata;
u32 inst_len;
u32 data_len; int i;
u32 done;
u32 reg_offset; int ret;
D_INFO("Begin load bsm\n");
il->ucode_type = UCODE_RT;
/* make sure bootstrap program is no larger than BSM's SRAM size */ if (len > IL49_MAX_BSM_SIZE) return -EINVAL;
/* Tell bootstrap uCode where to find the "Initialize" uCode * in host DRAM ... host DRAM physical address bits 35:4 for 4965. * NOTE: il_init_alive_start() will replace these values, * after the "initialize" uCode has run, to point to * runtime/protocol instructions and backup data cache.
*/
pinst = il->ucode_init.p_addr >> 4;
pdata = il->ucode_init_data.p_addr >> 4;
inst_len = il->ucode_init.len;
data_len = il->ucode_init_data.len;
/* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND;
reg_offset < BSM_SRAM_LOWER_BOUND + len;
reg_offset += sizeof(u32), image++)
_il_wr_prph(il, reg_offset, le32_to_cpu(*image));
ret = il4965_verify_bsm(il); if (ret) return ret;
/* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */
il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0);
il_wr_prph(il, BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND);
il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32));
/* Load bootstrap code into instruction SRAM now,
* to prepare to load "initialize" uCode */
il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START);
/* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) {
done = il_rd_prph(il, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break;
udelay(10);
} if (i < 100)
D_INFO("BSM write complete, poll %d iterations\n", i); else {
IL_ERR("BSM write did not complete!\n"); return -EIO;
}
/* Enable future boot loads whenever power management unit triggers it
* (e.g. when powering back up after power-save shutdown) */
il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN);
return 0;
}
/* * il4965_set_ucode_ptrs - Set uCode address location * * Tell initialization uCode where to find runtime uCode. * * BSM registers initially contain pointers to initialization uCode. * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down.
*/ staticint
il4965_set_ucode_ptrs(struct il_priv *il)
{
dma_addr_t pinst;
dma_addr_t pdata;
/* Tell bootstrap uCode where to find image to load */
il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst);
il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata);
il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, il->ucode_data.len);
/* Inst byte count must be last to set up, bit 31 signals uCode
* that all new ptr/size info is in place */
il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG,
il->ucode_code.len | BSM_DRAM_INST_LOAD);
D_INFO("Runtime uCode pointers are set.\n");
return 0;
}
/* * il4965_init_alive_start - Called after N_ALIVE notification received * * Called after N_ALIVE notification received from "initialize" uCode. * * The 4965 "initialize" ALIVE reply contains calibration data for: * Voltage, temperature, and MIMO tx gain correction, now stored in il * (3945 does not contain this data). * * Tell "initialize" uCode to go ahead and load the runtime uCode.
*/ staticvoid
il4965_init_alive_start(struct il_priv *il)
{ /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the
* "initialize" alive if code weren't properly loaded. */ if (il4965_verify_ucode(il)) { /* Runtime instruction load was bad;
* take it all the way back down so we can try again */
D_INFO("Bad \"initialize\" uCode load.\n"); goto restart;
}
/* Calculate temperature */
il->temperature = il4965_hw_get_temperature(il);
/* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive"
* notification. */
D_INFO("Initialization Alive received.\n"); if (il4965_set_ucode_ptrs(il)) { /* Runtime instruction load won't happen;
* take it all the way back down so we can try again */
D_INFO("Couldn't set up uCode pointers.\n"); goto restart;
} return;
/* Reset differential Rx gains in NIC to prepare for chain noise calibration. * Called after every association, but this runs only once!
* ... once chain noise is calibrated the first time, it's good forever. */ staticvoid
il4965_chain_noise_reset(struct il_priv *il)
{ struct il_chain_noise_data *data = &(il->chain_noise_data);
if (data->state == IL_CHAIN_NOISE_ALIVE && il_is_any_associated(il)) { struct il_calib_diff_gain_cmd cmd;
/* * il4965_get_voltage_compensation - Power supply voltage comp for txpower * * Determines power supply voltage compensation for txpower calculations. * Returns number of 1/2-dB steps to subtract from gain table idx, * to compensate for difference between power supply voltage during * factory measurements, vs. current power supply voltage. * * Voltage indication is higher for lower voltage. * Lower voltage requires more gain (lower gain table idx).
*/ static s32
il4965_get_voltage_compensation(s32 eeprom_voltage, s32 current_voltage)
{
s32 comp = 0;
if (TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage ||
TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage) return 0;
/* * il4965_interpolate_chan - Interpolate factory measurements for one channel * * Interpolates factory measurements from the two sample channels within a * sub-band, to apply to channel of interest. Interpolation is proportional to * differences in channel frequencies, which is proportional to differences * in channel number.
*/ staticint
il4965_interpolate_chan(struct il_priv *il, u32 channel, struct il_eeprom_calib_ch_info *chan_info)
{
s32 s = -1;
u32 c;
u32 m; conststruct il_eeprom_calib_measure *m1; conststruct il_eeprom_calib_measure *m2; struct il_eeprom_calib_measure *omeas;
u32 ch_i1;
u32 ch_i2;
s = il4965_get_sub_band(il, channel); if (s >= EEPROM_TX_POWER_BANDS) {
IL_ERR("Tx Power can not find channel %d\n", channel); return -1;
}
/* tx_power_user_lmt is in dBm, convert to half-dBm (half-dB units
* are used for idxing into txpower table) */
user_target_power = 2 * il->tx_power_user_lmt;
/* Get current (RXON) channel, band, width */
D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, is_ht40);
if (!il_is_channel_valid(ch_info)) return -EINVAL;
/* get txatten group, used to select 1) thermal txpower adjustment
* and 2) mimo txpower balance between Tx chains. */
txatten_grp = il4965_get_tx_atten_grp(channel); if (txatten_grp < 0) {
IL_ERR("Can't find txatten group for channel %d.\n", channel); return txatten_grp;
}
D_TXPOWER("channel %d belongs to txatten group %d\n", channel,
txatten_grp);
if (is_ht40) { if (ctrl_chan_high)
channel -= 2; else
channel += 2;
}
/* hardware txpower limits ...
* saturation (clipping distortion) txpowers are in half-dBm */ if (band)
saturation_power = il->calib_info->saturation_power24; else
saturation_power = il->calib_info->saturation_power52;
if (saturation_power < IL_TX_POWER_SATURATION_MIN ||
saturation_power > IL_TX_POWER_SATURATION_MAX) { if (band)
saturation_power = IL_TX_POWER_DEFAULT_SATURATION_24; else
saturation_power = IL_TX_POWER_DEFAULT_SATURATION_52;
}
/* regulatory txpower limits ... reg_limit values are in half-dBm,
* max_power_avg values are in dBm, convert * 2 */ if (is_ht40)
reg_limit = ch_info->ht40_max_power_avg * 2; else
reg_limit = ch_info->max_power_avg * 2;
if ((reg_limit < IL_TX_POWER_REGULATORY_MIN) ||
(reg_limit > IL_TX_POWER_REGULATORY_MAX)) { if (band)
reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_24; else
reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_52;
}
/* Interpolate txpower calibration values for this channel,
* based on factory calibration tests on spaced channels. */
il4965_interpolate_chan(il, channel, &ch_eeprom_info);
/* calculate tx gain adjustment based on power supply voltage */
voltage = le16_to_cpu(il->calib_info->voltage);
init_voltage = (s32) le32_to_cpu(il->card_alive_init.voltage);
voltage_compensation =
il4965_get_voltage_compensation(voltage, init_voltage);
D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", init_voltage,
voltage, voltage_compensation);
/* get current temperature (Celsius) */
current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN);
current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX);
current_temp = kelvin_to_celsius(current_temp);
/* select thermal txpower adjustment params, based on channel group
* (same frequency group used for mimo txatten adjustment) */
degrees_per_05db_num =
tx_power_cmp_tble[txatten_grp].degrees_per_05db_a;
degrees_per_05db_denom =
tx_power_cmp_tble[txatten_grp].degrees_per_05db_a_denom;
/* get per-chain txpower values from factory measurements */ for (c = 0; c < 2; c++) {
measurement = &ch_eeprom_info.measurements[c][1];
/* txgain adjustment (in half-dB steps) based on difference
* between factory and current temperature */
factory_temp = measurement->temperature;
il4965_math_div_round((current_temp -
factory_temp) * degrees_per_05db_denom,
degrees_per_05db_num,
&temperature_comp[c]);
/* for each of 33 bit-rates (including 1 for CCK) */ for (i = 0; i < POWER_TBL_NUM_ENTRIES; i++) {
u8 is_mimo_rate; union il4965_tx_power_dual_stream tx_power;
/* for mimo, reduce each chain's txpower by half * (3dB, 6 steps), so total output power is regulatory
* compliant. */ if (i & 0x8) {
current_regulatory =
reg_limit -
IL_TX_POWER_MIMO_REGULATORY_COMPENSATION;
is_mimo_rate = 1;
} else {
current_regulatory = reg_limit;
is_mimo_rate = 0;
}
/* find txpower limit, either hardware or regulatory */
power_limit = saturation_power - back_off_table[i]; if (power_limit > current_regulatory)
power_limit = current_regulatory;
/* reduce user's txpower request if necessary
* for this rate on this channel */
target_power = user_target_power; if (target_power > power_limit)
target_power = power_limit;
D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", i,
saturation_power - back_off_table[i],
current_regulatory, user_target_power, target_power);
/* for each of 2 Tx chains (radio transmitters) */ for (c = 0; c < 2; c++) {
s32 atten_value;
if (power_idx < get_min_power_idx(i, band))
power_idx = get_min_power_idx(i, band);
/* adjust 5 GHz idx to support negative idxes */ if (!band)
power_idx += 9;
/* CCK, rate 32, reduce txpower for CCK */ if (i == POWER_TBL_CCK_ENTRY)
power_idx +=
IL_TX_POWER_CCK_COMPENSATION_C_STEP;
/* stay within the table! */ if (power_idx > 107) {
IL_WARN("txpower idx %d > 107\n", power_idx);
power_idx = 107;
} if (power_idx < 0) {
IL_WARN("txpower idx %d < 0\n", power_idx);
power_idx = 0;
}
/* fill txpower command for this rate/chain */
tx_power.s.radio_tx_gain[c] =
gain_table[band][power_idx].radio;
tx_power.s.dsp_predis_atten[c] =
gain_table[band][power_idx].dsp;
D_TXPOWER("chain %d mimo %d idx %d " "gain 0x%02x dsp %d\n", c, atten_value,
power_idx, tx_power.s.radio_tx_gain[c],
tx_power.s.dsp_predis_atten[c]);
} /* for each chain */
/* * il4965_send_tx_power - Configure the TXPOWER level user limit * * Uses the active RXON for channel, band, and characteristics (ht40, high) * The power limit is taken from il->tx_power_user_lmt.
*/ staticint
il4965_send_tx_power(struct il_priv *il)
{ struct il4965_txpowertable_cmd cmd = { 0 }; int ret;
u8 band = 0; bool is_ht40 = false;
u8 ctrl_chan_high = 0;
if (WARN_ONCE
(test_bit(S_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) return -EAGAIN;
ret =
il_send_cmd_pdu_async(il, C_RXON_ASSOC, sizeof(rxon_assoc),
&rxon_assoc, NULL);
return ret;
}
staticint
il4965_commit_rxon(struct il_priv *il)
{ /* cast away the const for active_rxon in this function */ struct il_rxon_cmd *active_rxon = (void *)&il->active; int ret; bool new_assoc = !!(il->staging.filter_flags & RXON_FILTER_ASSOC_MSK);
if (!il_is_alive(il)) return -EBUSY;
/* always get timestamp with Rx frame */
il->staging.flags |= RXON_FLG_TSF2HOST_MSK;
ret = il_check_rxon_cmd(il); if (ret) {
IL_ERR("Invalid RXON configuration. Not committing.\n"); return -EINVAL;
}
/* * receive commit_rxon request * abort any previous channel switch if still in process
*/ if (test_bit(S_CHANNEL_SWITCH_PENDING, &il->status) &&
il->switch_channel != il->staging.channel) {
D_11H("abort channel switch on %d\n",
le16_to_cpu(il->switch_channel));
il_chswitch_done(il, false);
}
/* If we don't need to send a full RXON, we can use * il_rxon_assoc_cmd which is used to reconfigure filter
* and other flags for the current radio configuration. */ if (!il_full_rxon_required(il)) {
ret = il_send_rxon_assoc(il); if (ret) {
IL_ERR("Error setting RXON_ASSOC (%d)\n", ret); return ret;
}
memcpy(active_rxon, &il->staging, sizeof(*active_rxon));
il_print_rx_config_cmd(il); /* * We do not commit tx power settings while channel changing, * do it now if tx power changed.
*/
il_set_tx_power(il, il->tx_power_next, false); return 0;
}
/* If we are currently associated and the new config requires * an RXON_ASSOC and the new config wants the associated mask enabled, * we must clear the associated from the active configuration
* before we apply the new config */ if (il_is_associated(il) && new_assoc) {
D_INFO("Toggling associated bit on current RXON\n");
active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
ret =
il_send_cmd_pdu(il, C_RXON, sizeof(struct il_rxon_cmd), active_rxon);
/* If the mask clearing failed then we set
* active_rxon back to what it was previously */ if (ret) {
active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK;
IL_ERR("Error clearing ASSOC_MSK (%d)\n", ret); return ret;
}
il_clear_ucode_stations(il);
il_restore_stations(il);
ret = il4965_restore_default_wep_keys(il); if (ret) {
IL_ERR("Failed to restore WEP keys (%d)\n", ret); return ret;
}
}
/* Apply the new configuration * RXON unassoc clears the station table in uCode so restoration of * stations is needed after it (the RXON command) completes
*/ if (!new_assoc) {
ret =
il_send_cmd_pdu(il, C_RXON, sizeof(struct il_rxon_cmd), &il->staging); if (ret) {
IL_ERR("Error setting new RXON (%d)\n", ret); return ret;
}
D_INFO("Return from !new_assoc RXON.\n");
memcpy(active_rxon, &il->staging, sizeof(*active_rxon));
il_clear_ucode_stations(il);
il_restore_stations(il);
ret = il4965_restore_default_wep_keys(il); if (ret) {
IL_ERR("Failed to restore WEP keys (%d)\n", ret); return ret;
}
} if (new_assoc) {
il->start_calib = 0; /* Apply the new configuration * RXON assoc doesn't clear the station table in uCode,
*/
ret =
il_send_cmd_pdu(il, C_RXON, sizeof(struct il_rxon_cmd), &il->staging); if (ret) {
IL_ERR("Error setting new RXON (%d)\n", ret); return ret;
}
memcpy(active_rxon, &il->staging, sizeof(*active_rxon));
}
il_print_rx_config_cmd(il);
il4965_init_sensitivity(il);
/* If we issue a new RXON command which required a tune then we must
* send a new TXPOWER command or we won't be able to Tx any frames */
ret = il_set_tx_power(il, il->tx_power_next, true); if (ret) {
IL_ERR("Error sending TX power (%d)\n", ret); return ret;
}
bc_ent = cpu_to_le16(len & 0xFFF); /* Set up byte count within first 256 entries */
scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent;
/* If within first 64 entries, duplicate at end */ if (write_ptr < TFD_QUEUE_SIZE_BC_DUP)
scd_bc_tbl[txq_id].tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] =
bc_ent;
}
/* * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin) * * A return of <0 indicates bogus data in the stats
*/ staticint
il4965_hw_get_temperature(struct il_priv *il)
{
s32 temperature;
s32 vt;
s32 R1, R2, R3;
u32 R4;
/* * Temperature is only 23 bits, so sign extend out to 32. * * NOTE If we haven't received a stats notification yet * with an updated temperature, use R4 provided to us in the * "initialize" ALIVE response.
*/ if (!test_bit(S_TEMPERATURE, &il->status))
vt = sign_extend32(R4, 23); else
vt = sign_extend32(le32_to_cpu
(il->_4965.stats.general.common.temperature),
23);
/* Calculate temperature in degrees Kelvin, adjust by 97%.
* Add offset to center the adjustment around 0 degrees Centigrade. */
temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2);
temperature /= (R3 - R1);
temperature =
(temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET;
/* Adjust Txpower only if temperature variance is greater than threshold. */ #define IL_TEMPERATURE_THRESHOLD 3
/* * il4965_is_temp_calib_needed - determines if new calibration is needed * * If the temperature changed has changed sufficiently, then a recalibration * is needed. * * Assumes caller will replace il->last_temperature once calibration * executed.
*/ staticint
il4965_is_temp_calib_needed(struct il_priv *il)
{ int temp_diff;
if (!test_bit(S_STATS, &il->status)) {
D_TEMP("Temperature not updated -- no stats.\n"); return 0;
}
staticvoid
il4965_post_scan(struct il_priv *il)
{ /* * Since setting the RXON may have been deferred while * performing the scan, fire one off if needed
*/ if (memcmp(&il->staging, &il->active, sizeof(il->staging)))
il_commit_rxon(il);
}
staticvoid
il4965_post_associate(struct il_priv *il)
{ struct ieee80211_vif *vif = il->vif; int ret = 0;
if (!vif || !il->is_open) return;
if (test_bit(S_EXIT_PENDING, &il->status)) return;
if (il->ops->set_rxon_chain)
il->ops->set_rxon_chain(il);
il->staging.assoc_id = cpu_to_le16(vif->cfg.aid);
D_ASSOC("assoc id %d beacon interval %d\n", vif->cfg.aid,
vif->bss_conf.beacon_int);
if (vif->bss_conf.use_short_preamble)
il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else
il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
if (il->staging.flags & RXON_FLG_BAND_24G_MSK) { if (vif->bss_conf.use_short_slot)
il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else
il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
}
il_commit_rxon(il);
D_ASSOC("Associated as %d to: %pM\n", vif->cfg.aid,
il->active.bssid_addr);
switch (vif->type) { case NL80211_IFTYPE_STATION: break; case NL80211_IFTYPE_ADHOC:
il4965_send_beacon_cmd(il); break; default:
IL_ERR("%s Should not be called in %d mode\n", __func__,
vif->type); break;
}
/* the chain noise calibration will enabled PM upon completion * If chain noise has already been run, then we need to enable
* power management here */ if (il->chain_noise_data.state == IL_CHAIN_NOISE_DONE)
il_power_update_mode(il, false);
/* Enable Rx differential gain and sensitivity calibrations */
il4965_chain_noise_reset(il);
il->start_calib = 1;
}
staticvoid
il4965_config_ap(struct il_priv *il)
{ struct ieee80211_vif *vif = il->vif; int ret = 0;
lockdep_assert_held(&il->mutex);
if (test_bit(S_EXIT_PENDING, &il->status)) return;
/* The following should be done only at AP bring up */ if (!il_is_associated(il)) {
/* RXON Timing */
ret = il_send_rxon_timing(il); if (ret)
IL_WARN("RXON timing failed - " "Attempting to continue.\n");
/* AP has all antennas */
il->chain_noise_data.active_chains = il->hw_params.valid_rx_ant;
il_set_rxon_ht(il, &il->current_ht_config); if (il->ops->set_rxon_chain)
il->ops->set_rxon_chain(il);
il->staging.assoc_id = 0;
if (vif->bss_conf.use_short_preamble)
il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else
il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
if (il->staging.flags & RXON_FLG_BAND_24G_MSK) { if (vif->bss_conf.use_short_slot)
il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else
il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
} /* need to send beacon cmd before committing assoc RXON! */
il4965_send_beacon_cmd(il); /* restore RXON assoc */
il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
il_commit_rxon(il);
}
il4965_send_beacon_cmd(il);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.