linux/drivers/net/wireless/intel/iwlwifi/dvm/devices.c
<<
>>
Prefs
   1/******************************************************************************
   2 *
   3 * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved.
   4 *
   5 * This program is free software; you can redistribute it and/or modify it
   6 * under the terms of version 2 of the GNU General Public License as
   7 * published by the Free Software Foundation.
   8 *
   9 * This program is distributed in the hope that it will be useful, but WITHOUT
  10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  12 * more details.
  13 *
  14 * The full GNU General Public License is included in this distribution in the
  15 * file called LICENSE.
  16 *
  17 * Contact Information:
  18 *  Intel Linux Wireless <linuxwifi@intel.com>
  19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  20 *
  21 *****************************************************************************/
  22
  23/*
  24 * DVM device-specific data & functions
  25 */
  26#include "iwl-io.h"
  27#include "iwl-prph.h"
  28#include "iwl-eeprom-parse.h"
  29
  30#include "agn.h"
  31#include "dev.h"
  32#include "commands.h"
  33
  34
  35/*
  36 * 1000 series
  37 * ===========
  38 */
  39
  40/*
  41 * For 1000, use advance thermal throttling critical temperature threshold,
  42 * but legacy thermal management implementation for now.
  43 * This is for the reason of 1000 uCode using advance thermal throttling API
  44 * but not implement ct_kill_exit based on ct_kill exit temperature
  45 * so the thermal throttling will still based on legacy thermal throttling
  46 * management.
  47 * The code here need to be modified once 1000 uCode has the advanced thermal
  48 * throttling algorithm in place
  49 */
  50static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
  51{
  52        /* want Celsius */
  53        priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
  54        priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  55}
  56
  57/* NIC configuration for 1000 series */
  58static void iwl1000_nic_config(struct iwl_priv *priv)
  59{
  60        /* Setting digital SVR for 1000 card to 1.32V */
  61        /* locking is acquired in iwl_set_bits_mask_prph() function */
  62        iwl_set_bits_mask_prph(priv->trans, APMG_DIGITAL_SVR_REG,
  63                                APMG_SVR_DIGITAL_VOLTAGE_1_32,
  64                                ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
  65}
  66
  67/**
  68 * iwl_beacon_time_mask_low - mask of lower 32 bit of beacon time
  69 * @priv -- pointer to iwl_priv data structure
  70 * @tsf_bits -- number of bits need to shift for masking)
  71 */
  72static inline u32 iwl_beacon_time_mask_low(struct iwl_priv *priv,
  73                                           u16 tsf_bits)
  74{
  75        return (1 << tsf_bits) - 1;
  76}
  77
  78/**
  79 * iwl_beacon_time_mask_high - mask of higher 32 bit of beacon time
  80 * @priv -- pointer to iwl_priv data structure
  81 * @tsf_bits -- number of bits need to shift for masking)
  82 */
  83static inline u32 iwl_beacon_time_mask_high(struct iwl_priv *priv,
  84                                            u16 tsf_bits)
  85{
  86        return ((1 << (32 - tsf_bits)) - 1) << tsf_bits;
  87}
  88
  89/*
  90 * extended beacon time format
  91 * time in usec will be changed into a 32-bit value in extended:internal format
  92 * the extended part is the beacon counts
  93 * the internal part is the time in usec within one beacon interval
  94 */
  95static u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec,
  96                                u32 beacon_interval)
  97{
  98        u32 quot;
  99        u32 rem;
 100        u32 interval = beacon_interval * TIME_UNIT;
 101
 102        if (!interval || !usec)
 103                return 0;
 104
 105        quot = (usec / interval) &
 106                (iwl_beacon_time_mask_high(priv, IWLAGN_EXT_BEACON_TIME_POS) >>
 107                IWLAGN_EXT_BEACON_TIME_POS);
 108        rem = (usec % interval) & iwl_beacon_time_mask_low(priv,
 109                                   IWLAGN_EXT_BEACON_TIME_POS);
 110
 111        return (quot << IWLAGN_EXT_BEACON_TIME_POS) + rem;
 112}
 113
 114/* base is usually what we get from ucode with each received frame,
 115 * the same as HW timer counter counting down
 116 */
 117static __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
 118                           u32 addon, u32 beacon_interval)
 119{
 120        u32 base_low = base & iwl_beacon_time_mask_low(priv,
 121                                IWLAGN_EXT_BEACON_TIME_POS);
 122        u32 addon_low = addon & iwl_beacon_time_mask_low(priv,
 123                                IWLAGN_EXT_BEACON_TIME_POS);
 124        u32 interval = beacon_interval * TIME_UNIT;
 125        u32 res = (base & iwl_beacon_time_mask_high(priv,
 126                                IWLAGN_EXT_BEACON_TIME_POS)) +
 127                                (addon & iwl_beacon_time_mask_high(priv,
 128                                IWLAGN_EXT_BEACON_TIME_POS));
 129
 130        if (base_low > addon_low)
 131                res += base_low - addon_low;
 132        else if (base_low < addon_low) {
 133                res += interval + base_low - addon_low;
 134                res += (1 << IWLAGN_EXT_BEACON_TIME_POS);
 135        } else
 136                res += (1 << IWLAGN_EXT_BEACON_TIME_POS);
 137
 138        return cpu_to_le32(res);
 139}
 140
 141static const struct iwl_sensitivity_ranges iwl1000_sensitivity = {
 142        .min_nrg_cck = 95,
 143        .auto_corr_min_ofdm = 90,
 144        .auto_corr_min_ofdm_mrc = 170,
 145        .auto_corr_min_ofdm_x1 = 120,
 146        .auto_corr_min_ofdm_mrc_x1 = 240,
 147
 148        .auto_corr_max_ofdm = 120,
 149        .auto_corr_max_ofdm_mrc = 210,
 150        .auto_corr_max_ofdm_x1 = 155,
 151        .auto_corr_max_ofdm_mrc_x1 = 290,
 152
 153        .auto_corr_min_cck = 125,
 154        .auto_corr_max_cck = 200,
 155        .auto_corr_min_cck_mrc = 170,
 156        .auto_corr_max_cck_mrc = 400,
 157        .nrg_th_cck = 95,
 158        .nrg_th_ofdm = 95,
 159
 160        .barker_corr_th_min = 190,
 161        .barker_corr_th_min_mrc = 390,
 162        .nrg_th_cca = 62,
 163};
 164
 165static void iwl1000_hw_set_hw_params(struct iwl_priv *priv)
 166{
 167        iwl1000_set_ct_threshold(priv);
 168
 169        /* Set initial sensitivity parameters */
 170        priv->hw_params.sens = &iwl1000_sensitivity;
 171}
 172
 173const struct iwl_dvm_cfg iwl_dvm_1000_cfg = {
 174        .set_hw_params = iwl1000_hw_set_hw_params,
 175        .nic_config = iwl1000_nic_config,
 176        .temperature = iwlagn_temperature,
 177        .support_ct_kill_exit = true,
 178        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
 179        .chain_noise_scale = 1000,
 180};
 181
 182
 183/*
 184 * 2000 series
 185 * ===========
 186 */
 187
 188static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
 189{
 190        /* want Celsius */
 191        priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
 192        priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
 193}
 194
 195/* NIC configuration for 2000 series */
 196static void iwl2000_nic_config(struct iwl_priv *priv)
 197{
 198        iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
 199                    CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
 200}
 201
 202static const struct iwl_sensitivity_ranges iwl2000_sensitivity = {
 203        .min_nrg_cck = 97,
 204        .auto_corr_min_ofdm = 80,
 205        .auto_corr_min_ofdm_mrc = 128,
 206        .auto_corr_min_ofdm_x1 = 105,
 207        .auto_corr_min_ofdm_mrc_x1 = 192,
 208
 209        .auto_corr_max_ofdm = 145,
 210        .auto_corr_max_ofdm_mrc = 232,
 211        .auto_corr_max_ofdm_x1 = 110,
 212        .auto_corr_max_ofdm_mrc_x1 = 232,
 213
 214        .auto_corr_min_cck = 125,
 215        .auto_corr_max_cck = 175,
 216        .auto_corr_min_cck_mrc = 160,
 217        .auto_corr_max_cck_mrc = 310,
 218        .nrg_th_cck = 97,
 219        .nrg_th_ofdm = 100,
 220
 221        .barker_corr_th_min = 190,
 222        .barker_corr_th_min_mrc = 390,
 223        .nrg_th_cca = 62,
 224};
 225
 226static void iwl2000_hw_set_hw_params(struct iwl_priv *priv)
 227{
 228        iwl2000_set_ct_threshold(priv);
 229
 230        /* Set initial sensitivity parameters */
 231        priv->hw_params.sens = &iwl2000_sensitivity;
 232}
 233
 234const struct iwl_dvm_cfg iwl_dvm_2000_cfg = {
 235        .set_hw_params = iwl2000_hw_set_hw_params,
 236        .nic_config = iwl2000_nic_config,
 237        .temperature = iwlagn_temperature,
 238        .adv_thermal_throttle = true,
 239        .support_ct_kill_exit = true,
 240        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
 241        .chain_noise_scale = 1000,
 242        .hd_v2 = true,
 243        .need_temp_offset_calib = true,
 244        .temp_offset_v2 = true,
 245};
 246
 247const struct iwl_dvm_cfg iwl_dvm_105_cfg = {
 248        .set_hw_params = iwl2000_hw_set_hw_params,
 249        .nic_config = iwl2000_nic_config,
 250        .temperature = iwlagn_temperature,
 251        .adv_thermal_throttle = true,
 252        .support_ct_kill_exit = true,
 253        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
 254        .chain_noise_scale = 1000,
 255        .hd_v2 = true,
 256        .need_temp_offset_calib = true,
 257        .temp_offset_v2 = true,
 258        .adv_pm = true,
 259};
 260
 261static const struct iwl_dvm_bt_params iwl2030_bt_params = {
 262        /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
 263        .advanced_bt_coexist = true,
 264        .agg_time_limit = BT_AGG_THRESHOLD_DEF,
 265        .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
 266        .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT32,
 267        .bt_sco_disable = true,
 268        .bt_session_2 = true,
 269};
 270
 271const struct iwl_dvm_cfg iwl_dvm_2030_cfg = {
 272        .set_hw_params = iwl2000_hw_set_hw_params,
 273        .nic_config = iwl2000_nic_config,
 274        .temperature = iwlagn_temperature,
 275        .adv_thermal_throttle = true,
 276        .support_ct_kill_exit = true,
 277        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
 278        .chain_noise_scale = 1000,
 279        .hd_v2 = true,
 280        .bt_params = &iwl2030_bt_params,
 281        .need_temp_offset_calib = true,
 282        .temp_offset_v2 = true,
 283        .adv_pm = true,
 284};
 285
 286/*
 287 * 5000 series
 288 * ===========
 289 */
 290
 291/* NIC configuration for 5000 series */
 292static const struct iwl_sensitivity_ranges iwl5000_sensitivity = {
 293        .min_nrg_cck = 100,
 294        .auto_corr_min_ofdm = 90,
 295        .auto_corr_min_ofdm_mrc = 170,
 296        .auto_corr_min_ofdm_x1 = 105,
 297        .auto_corr_min_ofdm_mrc_x1 = 220,
 298
 299        .auto_corr_max_ofdm = 120,
 300        .auto_corr_max_ofdm_mrc = 210,
 301        .auto_corr_max_ofdm_x1 = 120,
 302        .auto_corr_max_ofdm_mrc_x1 = 240,
 303
 304        .auto_corr_min_cck = 125,
 305        .auto_corr_max_cck = 200,
 306        .auto_corr_min_cck_mrc = 200,
 307        .auto_corr_max_cck_mrc = 400,
 308        .nrg_th_cck = 100,
 309        .nrg_th_ofdm = 100,
 310
 311        .barker_corr_th_min = 190,
 312        .barker_corr_th_min_mrc = 390,
 313        .nrg_th_cca = 62,
 314};
 315
 316static const struct iwl_sensitivity_ranges iwl5150_sensitivity = {
 317        .min_nrg_cck = 95,
 318        .auto_corr_min_ofdm = 90,
 319        .auto_corr_min_ofdm_mrc = 170,
 320        .auto_corr_min_ofdm_x1 = 105,
 321        .auto_corr_min_ofdm_mrc_x1 = 220,
 322
 323        .auto_corr_max_ofdm = 120,
 324        .auto_corr_max_ofdm_mrc = 210,
 325        /* max = min for performance bug in 5150 DSP */
 326        .auto_corr_max_ofdm_x1 = 105,
 327        .auto_corr_max_ofdm_mrc_x1 = 220,
 328
 329        .auto_corr_min_cck = 125,
 330        .auto_corr_max_cck = 200,
 331        .auto_corr_min_cck_mrc = 170,
 332        .auto_corr_max_cck_mrc = 400,
 333        .nrg_th_cck = 95,
 334        .nrg_th_ofdm = 95,
 335
 336        .barker_corr_th_min = 190,
 337        .barker_corr_th_min_mrc = 390,
 338        .nrg_th_cca = 62,
 339};
 340
 341#define IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF   (-5)
 342
 343static s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
 344{
 345        u16 temperature, voltage;
 346
 347        temperature = le16_to_cpu(priv->nvm_data->kelvin_temperature);
 348        voltage = le16_to_cpu(priv->nvm_data->kelvin_voltage);
 349
 350        /* offset = temp - volt / coeff */
 351        return (s32)(temperature -
 352                        voltage / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
 353}
 354
 355static void iwl5150_set_ct_threshold(struct iwl_priv *priv)
 356{
 357        const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF;
 358        s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY) -
 359                        iwl_temp_calib_to_offset(priv);
 360
 361        priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef;
 362}
 363
 364static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
 365{
 366        /* want Celsius */
 367        priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
 368}
 369
 370static void iwl5000_hw_set_hw_params(struct iwl_priv *priv)
 371{
 372        iwl5000_set_ct_threshold(priv);
 373
 374        /* Set initial sensitivity parameters */
 375        priv->hw_params.sens = &iwl5000_sensitivity;
 376}
 377
 378static void iwl5150_hw_set_hw_params(struct iwl_priv *priv)
 379{
 380        iwl5150_set_ct_threshold(priv);
 381
 382        /* Set initial sensitivity parameters */
 383        priv->hw_params.sens = &iwl5150_sensitivity;
 384}
 385
 386static void iwl5150_temperature(struct iwl_priv *priv)
 387{
 388        u32 vt = 0;
 389        s32 offset =  iwl_temp_calib_to_offset(priv);
 390
 391        vt = le32_to_cpu(priv->statistics.common.temperature);
 392        vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset;
 393        /* now vt hold the temperature in Kelvin */
 394        priv->temperature = KELVIN_TO_CELSIUS(vt);
 395        iwl_tt_handler(priv);
 396}
 397
 398static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
 399                                     struct ieee80211_channel_switch *ch_switch)
 400{
 401        /*
 402         * MULTI-FIXME
 403         * See iwlagn_mac_channel_switch.
 404         */
 405        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
 406        struct iwl5000_channel_switch_cmd cmd;
 407        u32 switch_time_in_usec, ucode_switch_time;
 408        u16 ch;
 409        u32 tsf_low;
 410        u8 switch_count;
 411        u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
 412        struct ieee80211_vif *vif = ctx->vif;
 413        struct iwl_host_cmd hcmd = {
 414                .id = REPLY_CHANNEL_SWITCH,
 415                .len = { sizeof(cmd), },
 416                .data = { &cmd, },
 417        };
 418
 419        cmd.band = priv->band == NL80211_BAND_2GHZ;
 420        ch = ch_switch->chandef.chan->hw_value;
 421        IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
 422                      ctx->active.channel, ch);
 423        cmd.channel = cpu_to_le16(ch);
 424        cmd.rxon_flags = ctx->staging.flags;
 425        cmd.rxon_filter_flags = ctx->staging.filter_flags;
 426        switch_count = ch_switch->count;
 427        tsf_low = ch_switch->timestamp & 0x0ffffffff;
 428        /*
 429         * calculate the ucode channel switch time
 430         * adding TSF as one of the factor for when to switch
 431         */
 432        if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
 433                if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
 434                    beacon_interval)) {
 435                        switch_count -= (priv->ucode_beacon_time -
 436                                tsf_low) / beacon_interval;
 437                } else
 438                        switch_count = 0;
 439        }
 440        if (switch_count <= 1)
 441                cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time);
 442        else {
 443                switch_time_in_usec =
 444                        vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
 445                ucode_switch_time = iwl_usecs_to_beacons(priv,
 446                                                         switch_time_in_usec,
 447                                                         beacon_interval);
 448                cmd.switch_time = iwl_add_beacon_time(priv,
 449                                                      priv->ucode_beacon_time,
 450                                                      ucode_switch_time,
 451                                                      beacon_interval);
 452        }
 453        IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
 454                      cmd.switch_time);
 455        cmd.expect_beacon =
 456                ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
 457
 458        return iwl_dvm_send_cmd(priv, &hcmd);
 459}
 460
 461const struct iwl_dvm_cfg iwl_dvm_5000_cfg = {
 462        .set_hw_params = iwl5000_hw_set_hw_params,
 463        .set_channel_switch = iwl5000_hw_channel_switch,
 464        .temperature = iwlagn_temperature,
 465        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
 466        .chain_noise_scale = 1000,
 467        .no_idle_support = true,
 468};
 469
 470const struct iwl_dvm_cfg iwl_dvm_5150_cfg = {
 471        .set_hw_params = iwl5150_hw_set_hw_params,
 472        .set_channel_switch = iwl5000_hw_channel_switch,
 473        .temperature = iwl5150_temperature,
 474        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
 475        .chain_noise_scale = 1000,
 476        .no_idle_support = true,
 477        .no_xtal_calib = true,
 478};
 479
 480
 481
 482/*
 483 * 6000 series
 484 * ===========
 485 */
 486
 487static void iwl6000_set_ct_threshold(struct iwl_priv *priv)
 488{
 489        /* want Celsius */
 490        priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
 491        priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
 492}
 493
 494/* NIC configuration for 6000 series */
 495static void iwl6000_nic_config(struct iwl_priv *priv)
 496{
 497        switch (priv->cfg->device_family) {
 498        case IWL_DEVICE_FAMILY_6005:
 499        case IWL_DEVICE_FAMILY_6030:
 500        case IWL_DEVICE_FAMILY_6000:
 501                break;
 502        case IWL_DEVICE_FAMILY_6000i:
 503                /* 2x2 IPA phy type */
 504                iwl_write32(priv->trans, CSR_GP_DRIVER_REG,
 505                             CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
 506                break;
 507        case IWL_DEVICE_FAMILY_6050:
 508                /* Indicate calibration version to uCode. */
 509                if (priv->nvm_data->calib_version >= 6)
 510                        iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
 511                                        CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
 512                break;
 513        case IWL_DEVICE_FAMILY_6150:
 514                /* Indicate calibration version to uCode. */
 515                if (priv->nvm_data->calib_version >= 6)
 516                        iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
 517                                        CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
 518                iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
 519                            CSR_GP_DRIVER_REG_BIT_6050_1x2);
 520                break;
 521        default:
 522                WARN_ON(1);
 523        }
 524}
 525
 526static const struct iwl_sensitivity_ranges iwl6000_sensitivity = {
 527        .min_nrg_cck = 110,
 528        .auto_corr_min_ofdm = 80,
 529        .auto_corr_min_ofdm_mrc = 128,
 530        .auto_corr_min_ofdm_x1 = 105,
 531        .auto_corr_min_ofdm_mrc_x1 = 192,
 532
 533        .auto_corr_max_ofdm = 145,
 534        .auto_corr_max_ofdm_mrc = 232,
 535        .auto_corr_max_ofdm_x1 = 110,
 536        .auto_corr_max_ofdm_mrc_x1 = 232,
 537
 538        .auto_corr_min_cck = 125,
 539        .auto_corr_max_cck = 175,
 540        .auto_corr_min_cck_mrc = 160,
 541        .auto_corr_max_cck_mrc = 310,
 542        .nrg_th_cck = 110,
 543        .nrg_th_ofdm = 110,
 544
 545        .barker_corr_th_min = 190,
 546        .barker_corr_th_min_mrc = 336,
 547        .nrg_th_cca = 62,
 548};
 549
 550static void iwl6000_hw_set_hw_params(struct iwl_priv *priv)
 551{
 552        iwl6000_set_ct_threshold(priv);
 553
 554        /* Set initial sensitivity parameters */
 555        priv->hw_params.sens = &iwl6000_sensitivity;
 556
 557}
 558
 559static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
 560                                     struct ieee80211_channel_switch *ch_switch)
 561{
 562        /*
 563         * MULTI-FIXME
 564         * See iwlagn_mac_channel_switch.
 565         */
 566        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
 567        struct iwl6000_channel_switch_cmd *cmd;
 568        u32 switch_time_in_usec, ucode_switch_time;
 569        u16 ch;
 570        u32 tsf_low;
 571        u8 switch_count;
 572        u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
 573        struct ieee80211_vif *vif = ctx->vif;
 574        struct iwl_host_cmd hcmd = {
 575                .id = REPLY_CHANNEL_SWITCH,
 576                .len = { sizeof(*cmd), },
 577                .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
 578        };
 579        int err;
 580
 581        cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
 582        if (!cmd)
 583                return -ENOMEM;
 584
 585        hcmd.data[0] = cmd;
 586
 587        cmd->band = priv->band == NL80211_BAND_2GHZ;
 588        ch = ch_switch->chandef.chan->hw_value;
 589        IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
 590                      ctx->active.channel, ch);
 591        cmd->channel = cpu_to_le16(ch);
 592        cmd->rxon_flags = ctx->staging.flags;
 593        cmd->rxon_filter_flags = ctx->staging.filter_flags;
 594        switch_count = ch_switch->count;
 595        tsf_low = ch_switch->timestamp & 0x0ffffffff;
 596        /*
 597         * calculate the ucode channel switch time
 598         * adding TSF as one of the factor for when to switch
 599         */
 600        if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
 601                if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
 602                    beacon_interval)) {
 603                        switch_count -= (priv->ucode_beacon_time -
 604                                tsf_low) / beacon_interval;
 605                } else
 606                        switch_count = 0;
 607        }
 608        if (switch_count <= 1)
 609                cmd->switch_time = cpu_to_le32(priv->ucode_beacon_time);
 610        else {
 611                switch_time_in_usec =
 612                        vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
 613                ucode_switch_time = iwl_usecs_to_beacons(priv,
 614                                                         switch_time_in_usec,
 615                                                         beacon_interval);
 616                cmd->switch_time = iwl_add_beacon_time(priv,
 617                                                       priv->ucode_beacon_time,
 618                                                       ucode_switch_time,
 619                                                       beacon_interval);
 620        }
 621        IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
 622                      cmd->switch_time);
 623        cmd->expect_beacon =
 624                ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
 625
 626        err = iwl_dvm_send_cmd(priv, &hcmd);
 627        kfree(cmd);
 628        return err;
 629}
 630
 631const struct iwl_dvm_cfg iwl_dvm_6000_cfg = {
 632        .set_hw_params = iwl6000_hw_set_hw_params,
 633        .set_channel_switch = iwl6000_hw_channel_switch,
 634        .nic_config = iwl6000_nic_config,
 635        .temperature = iwlagn_temperature,
 636        .adv_thermal_throttle = true,
 637        .support_ct_kill_exit = true,
 638        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
 639        .chain_noise_scale = 1000,
 640};
 641
 642const struct iwl_dvm_cfg iwl_dvm_6005_cfg = {
 643        .set_hw_params = iwl6000_hw_set_hw_params,
 644        .set_channel_switch = iwl6000_hw_channel_switch,
 645        .nic_config = iwl6000_nic_config,
 646        .temperature = iwlagn_temperature,
 647        .adv_thermal_throttle = true,
 648        .support_ct_kill_exit = true,
 649        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
 650        .chain_noise_scale = 1000,
 651        .need_temp_offset_calib = true,
 652};
 653
 654const struct iwl_dvm_cfg iwl_dvm_6050_cfg = {
 655        .set_hw_params = iwl6000_hw_set_hw_params,
 656        .set_channel_switch = iwl6000_hw_channel_switch,
 657        .nic_config = iwl6000_nic_config,
 658        .temperature = iwlagn_temperature,
 659        .adv_thermal_throttle = true,
 660        .support_ct_kill_exit = true,
 661        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
 662        .chain_noise_scale = 1500,
 663};
 664
 665static const struct iwl_dvm_bt_params iwl6000_bt_params = {
 666        /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
 667        .advanced_bt_coexist = true,
 668        .agg_time_limit = BT_AGG_THRESHOLD_DEF,
 669        .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
 670        .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
 671        .bt_sco_disable = true,
 672};
 673
 674const struct iwl_dvm_cfg iwl_dvm_6030_cfg = {
 675        .set_hw_params = iwl6000_hw_set_hw_params,
 676        .set_channel_switch = iwl6000_hw_channel_switch,
 677        .nic_config = iwl6000_nic_config,
 678        .temperature = iwlagn_temperature,
 679        .adv_thermal_throttle = true,
 680        .support_ct_kill_exit = true,
 681        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
 682        .chain_noise_scale = 1000,
 683        .bt_params = &iwl6000_bt_params,
 684        .need_temp_offset_calib = true,
 685        .adv_pm = true,
 686};
 687