Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /******************************************************************************
0003  *
0004  * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved.
0005  * Copyright (C) 2019 Intel Corporation
0006  *****************************************************************************/
0007 
0008 #include <linux/units.h>
0009 
0010 /*
0011  * DVM device-specific data & functions
0012  */
0013 #include "iwl-io.h"
0014 #include "iwl-prph.h"
0015 #include "iwl-eeprom-parse.h"
0016 
0017 #include "agn.h"
0018 #include "dev.h"
0019 #include "commands.h"
0020 
0021 
0022 /*
0023  * 1000 series
0024  * ===========
0025  */
0026 
0027 /*
0028  * For 1000, use advance thermal throttling critical temperature threshold,
0029  * but legacy thermal management implementation for now.
0030  * This is for the reason of 1000 uCode using advance thermal throttling API
0031  * but not implement ct_kill_exit based on ct_kill exit temperature
0032  * so the thermal throttling will still based on legacy thermal throttling
0033  * management.
0034  * The code here need to be modified once 1000 uCode has the advanced thermal
0035  * throttling algorithm in place
0036  */
0037 static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
0038 {
0039     /* want Celsius */
0040     priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
0041     priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
0042 }
0043 
0044 /* NIC configuration for 1000 series */
0045 static void iwl1000_nic_config(struct iwl_priv *priv)
0046 {
0047     /* Setting digital SVR for 1000 card to 1.32V */
0048     /* locking is acquired in iwl_set_bits_mask_prph() function */
0049     iwl_set_bits_mask_prph(priv->trans, APMG_DIGITAL_SVR_REG,
0050                 APMG_SVR_DIGITAL_VOLTAGE_1_32,
0051                 ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
0052 }
0053 
0054 /**
0055  * iwl_beacon_time_mask_low - mask of lower 32 bit of beacon time
0056  * @priv: pointer to iwl_priv data structure
0057  * @tsf_bits: number of bits need to shift for masking)
0058  */
0059 static inline u32 iwl_beacon_time_mask_low(struct iwl_priv *priv,
0060                        u16 tsf_bits)
0061 {
0062     return (1 << tsf_bits) - 1;
0063 }
0064 
0065 /**
0066  * iwl_beacon_time_mask_high - mask of higher 32 bit of beacon time
0067  * @priv: pointer to iwl_priv data structure
0068  * @tsf_bits: number of bits need to shift for masking)
0069  */
0070 static inline u32 iwl_beacon_time_mask_high(struct iwl_priv *priv,
0071                         u16 tsf_bits)
0072 {
0073     return ((1 << (32 - tsf_bits)) - 1) << tsf_bits;
0074 }
0075 
0076 /*
0077  * extended beacon time format
0078  * time in usec will be changed into a 32-bit value in extended:internal format
0079  * the extended part is the beacon counts
0080  * the internal part is the time in usec within one beacon interval
0081  */
0082 static u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec,
0083                 u32 beacon_interval)
0084 {
0085     u32 quot;
0086     u32 rem;
0087     u32 interval = beacon_interval * TIME_UNIT;
0088 
0089     if (!interval || !usec)
0090         return 0;
0091 
0092     quot = (usec / interval) &
0093         (iwl_beacon_time_mask_high(priv, IWLAGN_EXT_BEACON_TIME_POS) >>
0094         IWLAGN_EXT_BEACON_TIME_POS);
0095     rem = (usec % interval) & iwl_beacon_time_mask_low(priv,
0096                    IWLAGN_EXT_BEACON_TIME_POS);
0097 
0098     return (quot << IWLAGN_EXT_BEACON_TIME_POS) + rem;
0099 }
0100 
0101 /* base is usually what we get from ucode with each received frame,
0102  * the same as HW timer counter counting down
0103  */
0104 static __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
0105                u32 addon, u32 beacon_interval)
0106 {
0107     u32 base_low = base & iwl_beacon_time_mask_low(priv,
0108                 IWLAGN_EXT_BEACON_TIME_POS);
0109     u32 addon_low = addon & iwl_beacon_time_mask_low(priv,
0110                 IWLAGN_EXT_BEACON_TIME_POS);
0111     u32 interval = beacon_interval * TIME_UNIT;
0112     u32 res = (base & iwl_beacon_time_mask_high(priv,
0113                 IWLAGN_EXT_BEACON_TIME_POS)) +
0114                 (addon & iwl_beacon_time_mask_high(priv,
0115                 IWLAGN_EXT_BEACON_TIME_POS));
0116 
0117     if (base_low > addon_low)
0118         res += base_low - addon_low;
0119     else if (base_low < addon_low) {
0120         res += interval + base_low - addon_low;
0121         res += (1 << IWLAGN_EXT_BEACON_TIME_POS);
0122     } else
0123         res += (1 << IWLAGN_EXT_BEACON_TIME_POS);
0124 
0125     return cpu_to_le32(res);
0126 }
0127 
0128 static const struct iwl_sensitivity_ranges iwl1000_sensitivity = {
0129     .min_nrg_cck = 95,
0130     .auto_corr_min_ofdm = 90,
0131     .auto_corr_min_ofdm_mrc = 170,
0132     .auto_corr_min_ofdm_x1 = 120,
0133     .auto_corr_min_ofdm_mrc_x1 = 240,
0134 
0135     .auto_corr_max_ofdm = 120,
0136     .auto_corr_max_ofdm_mrc = 210,
0137     .auto_corr_max_ofdm_x1 = 155,
0138     .auto_corr_max_ofdm_mrc_x1 = 290,
0139 
0140     .auto_corr_min_cck = 125,
0141     .auto_corr_max_cck = 200,
0142     .auto_corr_min_cck_mrc = 170,
0143     .auto_corr_max_cck_mrc = 400,
0144     .nrg_th_cck = 95,
0145     .nrg_th_ofdm = 95,
0146 
0147     .barker_corr_th_min = 190,
0148     .barker_corr_th_min_mrc = 390,
0149     .nrg_th_cca = 62,
0150 };
0151 
0152 static void iwl1000_hw_set_hw_params(struct iwl_priv *priv)
0153 {
0154     iwl1000_set_ct_threshold(priv);
0155 
0156     /* Set initial sensitivity parameters */
0157     priv->hw_params.sens = &iwl1000_sensitivity;
0158 }
0159 
0160 const struct iwl_dvm_cfg iwl_dvm_1000_cfg = {
0161     .set_hw_params = iwl1000_hw_set_hw_params,
0162     .nic_config = iwl1000_nic_config,
0163     .temperature = iwlagn_temperature,
0164     .support_ct_kill_exit = true,
0165     .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
0166     .chain_noise_scale = 1000,
0167 };
0168 
0169 
0170 /*
0171  * 2000 series
0172  * ===========
0173  */
0174 
0175 static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
0176 {
0177     /* want Celsius */
0178     priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
0179     priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
0180 }
0181 
0182 /* NIC configuration for 2000 series */
0183 static void iwl2000_nic_config(struct iwl_priv *priv)
0184 {
0185     iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
0186             CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
0187 }
0188 
0189 static const struct iwl_sensitivity_ranges iwl2000_sensitivity = {
0190     .min_nrg_cck = 97,
0191     .auto_corr_min_ofdm = 80,
0192     .auto_corr_min_ofdm_mrc = 128,
0193     .auto_corr_min_ofdm_x1 = 105,
0194     .auto_corr_min_ofdm_mrc_x1 = 192,
0195 
0196     .auto_corr_max_ofdm = 145,
0197     .auto_corr_max_ofdm_mrc = 232,
0198     .auto_corr_max_ofdm_x1 = 110,
0199     .auto_corr_max_ofdm_mrc_x1 = 232,
0200 
0201     .auto_corr_min_cck = 125,
0202     .auto_corr_max_cck = 175,
0203     .auto_corr_min_cck_mrc = 160,
0204     .auto_corr_max_cck_mrc = 310,
0205     .nrg_th_cck = 97,
0206     .nrg_th_ofdm = 100,
0207 
0208     .barker_corr_th_min = 190,
0209     .barker_corr_th_min_mrc = 390,
0210     .nrg_th_cca = 62,
0211 };
0212 
0213 static void iwl2000_hw_set_hw_params(struct iwl_priv *priv)
0214 {
0215     iwl2000_set_ct_threshold(priv);
0216 
0217     /* Set initial sensitivity parameters */
0218     priv->hw_params.sens = &iwl2000_sensitivity;
0219 }
0220 
0221 const struct iwl_dvm_cfg iwl_dvm_2000_cfg = {
0222     .set_hw_params = iwl2000_hw_set_hw_params,
0223     .nic_config = iwl2000_nic_config,
0224     .temperature = iwlagn_temperature,
0225     .adv_thermal_throttle = true,
0226     .support_ct_kill_exit = true,
0227     .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
0228     .chain_noise_scale = 1000,
0229     .hd_v2 = true,
0230     .need_temp_offset_calib = true,
0231     .temp_offset_v2 = true,
0232 };
0233 
0234 const struct iwl_dvm_cfg iwl_dvm_105_cfg = {
0235     .set_hw_params = iwl2000_hw_set_hw_params,
0236     .nic_config = iwl2000_nic_config,
0237     .temperature = iwlagn_temperature,
0238     .adv_thermal_throttle = true,
0239     .support_ct_kill_exit = true,
0240     .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
0241     .chain_noise_scale = 1000,
0242     .hd_v2 = true,
0243     .need_temp_offset_calib = true,
0244     .temp_offset_v2 = true,
0245     .adv_pm = true,
0246 };
0247 
0248 static const struct iwl_dvm_bt_params iwl2030_bt_params = {
0249     /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
0250     .advanced_bt_coexist = true,
0251     .agg_time_limit = BT_AGG_THRESHOLD_DEF,
0252     .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
0253     .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT32,
0254     .bt_sco_disable = true,
0255     .bt_session_2 = true,
0256 };
0257 
0258 const struct iwl_dvm_cfg iwl_dvm_2030_cfg = {
0259     .set_hw_params = iwl2000_hw_set_hw_params,
0260     .nic_config = iwl2000_nic_config,
0261     .temperature = iwlagn_temperature,
0262     .adv_thermal_throttle = true,
0263     .support_ct_kill_exit = true,
0264     .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
0265     .chain_noise_scale = 1000,
0266     .hd_v2 = true,
0267     .bt_params = &iwl2030_bt_params,
0268     .need_temp_offset_calib = true,
0269     .temp_offset_v2 = true,
0270     .adv_pm = true,
0271 };
0272 
0273 /*
0274  * 5000 series
0275  * ===========
0276  */
0277 
0278 /* NIC configuration for 5000 series */
0279 static const struct iwl_sensitivity_ranges iwl5000_sensitivity = {
0280     .min_nrg_cck = 100,
0281     .auto_corr_min_ofdm = 90,
0282     .auto_corr_min_ofdm_mrc = 170,
0283     .auto_corr_min_ofdm_x1 = 105,
0284     .auto_corr_min_ofdm_mrc_x1 = 220,
0285 
0286     .auto_corr_max_ofdm = 120,
0287     .auto_corr_max_ofdm_mrc = 210,
0288     .auto_corr_max_ofdm_x1 = 120,
0289     .auto_corr_max_ofdm_mrc_x1 = 240,
0290 
0291     .auto_corr_min_cck = 125,
0292     .auto_corr_max_cck = 200,
0293     .auto_corr_min_cck_mrc = 200,
0294     .auto_corr_max_cck_mrc = 400,
0295     .nrg_th_cck = 100,
0296     .nrg_th_ofdm = 100,
0297 
0298     .barker_corr_th_min = 190,
0299     .barker_corr_th_min_mrc = 390,
0300     .nrg_th_cca = 62,
0301 };
0302 
0303 static const struct iwl_sensitivity_ranges iwl5150_sensitivity = {
0304     .min_nrg_cck = 95,
0305     .auto_corr_min_ofdm = 90,
0306     .auto_corr_min_ofdm_mrc = 170,
0307     .auto_corr_min_ofdm_x1 = 105,
0308     .auto_corr_min_ofdm_mrc_x1 = 220,
0309 
0310     .auto_corr_max_ofdm = 120,
0311     .auto_corr_max_ofdm_mrc = 210,
0312     /* max = min for performance bug in 5150 DSP */
0313     .auto_corr_max_ofdm_x1 = 105,
0314     .auto_corr_max_ofdm_mrc_x1 = 220,
0315 
0316     .auto_corr_min_cck = 125,
0317     .auto_corr_max_cck = 200,
0318     .auto_corr_min_cck_mrc = 170,
0319     .auto_corr_max_cck_mrc = 400,
0320     .nrg_th_cck = 95,
0321     .nrg_th_ofdm = 95,
0322 
0323     .barker_corr_th_min = 190,
0324     .barker_corr_th_min_mrc = 390,
0325     .nrg_th_cca = 62,
0326 };
0327 
0328 #define IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF   (-5)
0329 
0330 static s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
0331 {
0332     u16 temperature, voltage;
0333 
0334     temperature = le16_to_cpu(priv->nvm_data->kelvin_temperature);
0335     voltage = le16_to_cpu(priv->nvm_data->kelvin_voltage);
0336 
0337     /* offset = temp - volt / coeff */
0338     return (s32)(temperature -
0339             voltage / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
0340 }
0341 
0342 static void iwl5150_set_ct_threshold(struct iwl_priv *priv)
0343 {
0344     const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF;
0345     s32 threshold = (s32)celsius_to_kelvin(CT_KILL_THRESHOLD_LEGACY) -
0346             iwl_temp_calib_to_offset(priv);
0347 
0348     priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef;
0349 }
0350 
0351 static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
0352 {
0353     /* want Celsius */
0354     priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
0355 }
0356 
0357 static void iwl5000_hw_set_hw_params(struct iwl_priv *priv)
0358 {
0359     iwl5000_set_ct_threshold(priv);
0360 
0361     /* Set initial sensitivity parameters */
0362     priv->hw_params.sens = &iwl5000_sensitivity;
0363 }
0364 
0365 static void iwl5150_hw_set_hw_params(struct iwl_priv *priv)
0366 {
0367     iwl5150_set_ct_threshold(priv);
0368 
0369     /* Set initial sensitivity parameters */
0370     priv->hw_params.sens = &iwl5150_sensitivity;
0371 }
0372 
0373 static void iwl5150_temperature(struct iwl_priv *priv)
0374 {
0375     u32 vt = 0;
0376     s32 offset =  iwl_temp_calib_to_offset(priv);
0377 
0378     vt = le32_to_cpu(priv->statistics.common.temperature);
0379     vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset;
0380     /* now vt hold the temperature in Kelvin */
0381     priv->temperature = kelvin_to_celsius(vt);
0382     iwl_tt_handler(priv);
0383 }
0384 
0385 static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
0386                      struct ieee80211_channel_switch *ch_switch)
0387 {
0388     /*
0389      * MULTI-FIXME
0390      * See iwlagn_mac_channel_switch.
0391      */
0392     struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
0393     struct iwl5000_channel_switch_cmd cmd;
0394     u32 switch_time_in_usec, ucode_switch_time;
0395     u16 ch;
0396     u32 tsf_low;
0397     u8 switch_count;
0398     u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
0399     struct ieee80211_vif *vif = ctx->vif;
0400     struct iwl_host_cmd hcmd = {
0401         .id = REPLY_CHANNEL_SWITCH,
0402         .len = { sizeof(cmd), },
0403         .data = { &cmd, },
0404     };
0405 
0406     cmd.band = priv->band == NL80211_BAND_2GHZ;
0407     ch = ch_switch->chandef.chan->hw_value;
0408     IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
0409               ctx->active.channel, ch);
0410     cmd.channel = cpu_to_le16(ch);
0411     cmd.rxon_flags = ctx->staging.flags;
0412     cmd.rxon_filter_flags = ctx->staging.filter_flags;
0413     switch_count = ch_switch->count;
0414     tsf_low = ch_switch->timestamp & 0x0ffffffff;
0415     /*
0416      * calculate the ucode channel switch time
0417      * adding TSF as one of the factor for when to switch
0418      */
0419     if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
0420         if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
0421             beacon_interval)) {
0422             switch_count -= (priv->ucode_beacon_time -
0423                 tsf_low) / beacon_interval;
0424         } else
0425             switch_count = 0;
0426     }
0427     if (switch_count <= 1)
0428         cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time);
0429     else {
0430         switch_time_in_usec =
0431             vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
0432         ucode_switch_time = iwl_usecs_to_beacons(priv,
0433                              switch_time_in_usec,
0434                              beacon_interval);
0435         cmd.switch_time = iwl_add_beacon_time(priv,
0436                               priv->ucode_beacon_time,
0437                               ucode_switch_time,
0438                               beacon_interval);
0439     }
0440     IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
0441               cmd.switch_time);
0442     cmd.expect_beacon =
0443         ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
0444 
0445     return iwl_dvm_send_cmd(priv, &hcmd);
0446 }
0447 
0448 const struct iwl_dvm_cfg iwl_dvm_5000_cfg = {
0449     .set_hw_params = iwl5000_hw_set_hw_params,
0450     .set_channel_switch = iwl5000_hw_channel_switch,
0451     .temperature = iwlagn_temperature,
0452     .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
0453     .chain_noise_scale = 1000,
0454     .no_idle_support = true,
0455 };
0456 
0457 const struct iwl_dvm_cfg iwl_dvm_5150_cfg = {
0458     .set_hw_params = iwl5150_hw_set_hw_params,
0459     .set_channel_switch = iwl5000_hw_channel_switch,
0460     .temperature = iwl5150_temperature,
0461     .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
0462     .chain_noise_scale = 1000,
0463     .no_idle_support = true,
0464     .no_xtal_calib = true,
0465 };
0466 
0467 
0468 
0469 /*
0470  * 6000 series
0471  * ===========
0472  */
0473 
0474 static void iwl6000_set_ct_threshold(struct iwl_priv *priv)
0475 {
0476     /* want Celsius */
0477     priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
0478     priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
0479 }
0480 
0481 /* NIC configuration for 6000 series */
0482 static void iwl6000_nic_config(struct iwl_priv *priv)
0483 {
0484     switch (priv->trans->trans_cfg->device_family) {
0485     case IWL_DEVICE_FAMILY_6005:
0486     case IWL_DEVICE_FAMILY_6030:
0487     case IWL_DEVICE_FAMILY_6000:
0488         break;
0489     case IWL_DEVICE_FAMILY_6000i:
0490         /* 2x2 IPA phy type */
0491         iwl_write32(priv->trans, CSR_GP_DRIVER_REG,
0492                  CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
0493         break;
0494     case IWL_DEVICE_FAMILY_6050:
0495         /* Indicate calibration version to uCode. */
0496         if (priv->nvm_data->calib_version >= 6)
0497             iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
0498                     CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
0499         break;
0500     case IWL_DEVICE_FAMILY_6150:
0501         /* Indicate calibration version to uCode. */
0502         if (priv->nvm_data->calib_version >= 6)
0503             iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
0504                     CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
0505         iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
0506                 CSR_GP_DRIVER_REG_BIT_6050_1x2);
0507         break;
0508     default:
0509         WARN_ON(1);
0510     }
0511 }
0512 
0513 static const struct iwl_sensitivity_ranges iwl6000_sensitivity = {
0514     .min_nrg_cck = 110,
0515     .auto_corr_min_ofdm = 80,
0516     .auto_corr_min_ofdm_mrc = 128,
0517     .auto_corr_min_ofdm_x1 = 105,
0518     .auto_corr_min_ofdm_mrc_x1 = 192,
0519 
0520     .auto_corr_max_ofdm = 145,
0521     .auto_corr_max_ofdm_mrc = 232,
0522     .auto_corr_max_ofdm_x1 = 110,
0523     .auto_corr_max_ofdm_mrc_x1 = 232,
0524 
0525     .auto_corr_min_cck = 125,
0526     .auto_corr_max_cck = 175,
0527     .auto_corr_min_cck_mrc = 160,
0528     .auto_corr_max_cck_mrc = 310,
0529     .nrg_th_cck = 110,
0530     .nrg_th_ofdm = 110,
0531 
0532     .barker_corr_th_min = 190,
0533     .barker_corr_th_min_mrc = 336,
0534     .nrg_th_cca = 62,
0535 };
0536 
0537 static void iwl6000_hw_set_hw_params(struct iwl_priv *priv)
0538 {
0539     iwl6000_set_ct_threshold(priv);
0540 
0541     /* Set initial sensitivity parameters */
0542     priv->hw_params.sens = &iwl6000_sensitivity;
0543 
0544 }
0545 
0546 static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
0547                      struct ieee80211_channel_switch *ch_switch)
0548 {
0549     /*
0550      * MULTI-FIXME
0551      * See iwlagn_mac_channel_switch.
0552      */
0553     struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
0554     struct iwl6000_channel_switch_cmd *cmd;
0555     u32 switch_time_in_usec, ucode_switch_time;
0556     u16 ch;
0557     u32 tsf_low;
0558     u8 switch_count;
0559     u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
0560     struct ieee80211_vif *vif = ctx->vif;
0561     struct iwl_host_cmd hcmd = {
0562         .id = REPLY_CHANNEL_SWITCH,
0563         .len = { sizeof(*cmd), },
0564         .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
0565     };
0566     int err;
0567 
0568     cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
0569     if (!cmd)
0570         return -ENOMEM;
0571 
0572     hcmd.data[0] = cmd;
0573 
0574     cmd->band = priv->band == NL80211_BAND_2GHZ;
0575     ch = ch_switch->chandef.chan->hw_value;
0576     IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
0577               ctx->active.channel, ch);
0578     cmd->channel = cpu_to_le16(ch);
0579     cmd->rxon_flags = ctx->staging.flags;
0580     cmd->rxon_filter_flags = ctx->staging.filter_flags;
0581     switch_count = ch_switch->count;
0582     tsf_low = ch_switch->timestamp & 0x0ffffffff;
0583     /*
0584      * calculate the ucode channel switch time
0585      * adding TSF as one of the factor for when to switch
0586      */
0587     if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
0588         if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
0589             beacon_interval)) {
0590             switch_count -= (priv->ucode_beacon_time -
0591                 tsf_low) / beacon_interval;
0592         } else
0593             switch_count = 0;
0594     }
0595     if (switch_count <= 1)
0596         cmd->switch_time = cpu_to_le32(priv->ucode_beacon_time);
0597     else {
0598         switch_time_in_usec =
0599             vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
0600         ucode_switch_time = iwl_usecs_to_beacons(priv,
0601                              switch_time_in_usec,
0602                              beacon_interval);
0603         cmd->switch_time = iwl_add_beacon_time(priv,
0604                                priv->ucode_beacon_time,
0605                                ucode_switch_time,
0606                                beacon_interval);
0607     }
0608     IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
0609               cmd->switch_time);
0610     cmd->expect_beacon =
0611         ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
0612 
0613     err = iwl_dvm_send_cmd(priv, &hcmd);
0614     kfree(cmd);
0615     return err;
0616 }
0617 
0618 const struct iwl_dvm_cfg iwl_dvm_6000_cfg = {
0619     .set_hw_params = iwl6000_hw_set_hw_params,
0620     .set_channel_switch = iwl6000_hw_channel_switch,
0621     .nic_config = iwl6000_nic_config,
0622     .temperature = iwlagn_temperature,
0623     .adv_thermal_throttle = true,
0624     .support_ct_kill_exit = true,
0625     .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
0626     .chain_noise_scale = 1000,
0627 };
0628 
0629 const struct iwl_dvm_cfg iwl_dvm_6005_cfg = {
0630     .set_hw_params = iwl6000_hw_set_hw_params,
0631     .set_channel_switch = iwl6000_hw_channel_switch,
0632     .nic_config = iwl6000_nic_config,
0633     .temperature = iwlagn_temperature,
0634     .adv_thermal_throttle = true,
0635     .support_ct_kill_exit = true,
0636     .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
0637     .chain_noise_scale = 1000,
0638     .need_temp_offset_calib = true,
0639 };
0640 
0641 const struct iwl_dvm_cfg iwl_dvm_6050_cfg = {
0642     .set_hw_params = iwl6000_hw_set_hw_params,
0643     .set_channel_switch = iwl6000_hw_channel_switch,
0644     .nic_config = iwl6000_nic_config,
0645     .temperature = iwlagn_temperature,
0646     .adv_thermal_throttle = true,
0647     .support_ct_kill_exit = true,
0648     .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
0649     .chain_noise_scale = 1500,
0650 };
0651 
0652 static const struct iwl_dvm_bt_params iwl6000_bt_params = {
0653     /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
0654     .advanced_bt_coexist = true,
0655     .agg_time_limit = BT_AGG_THRESHOLD_DEF,
0656     .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
0657     .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
0658     .bt_sco_disable = true,
0659 };
0660 
0661 const struct iwl_dvm_cfg iwl_dvm_6030_cfg = {
0662     .set_hw_params = iwl6000_hw_set_hw_params,
0663     .set_channel_switch = iwl6000_hw_channel_switch,
0664     .nic_config = iwl6000_nic_config,
0665     .temperature = iwlagn_temperature,
0666     .adv_thermal_throttle = true,
0667     .support_ct_kill_exit = true,
0668     .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
0669     .chain_noise_scale = 1000,
0670     .bt_params = &iwl6000_bt_params,
0671     .need_temp_offset_calib = true,
0672     .adv_pm = true,
0673 };