aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorWey-Yi Guy <wey-yi.w.guy@intel.com>2010-06-28 16:05:17 -0400
committerWey-Yi Guy <wey-yi.w.guy@intel.com>2010-07-02 14:11:17 -0400
commitc8312facd99b4cd05998fe3440926b667a896c9e (patch)
tree26414342ff20db9f6501346102e997a7ee1a84e9 /drivers/net
parentbf3c7fddf9dffb0e5c76da3a94b8f5817a72f92c (diff)
iwlwifi: adding enhance sensitivity table entries
For newer devices (6000g2a and 6000g2b), the sensitivity table send to uCode require additional table entries to help sensitivity calibration. All the additional entries has fix data for now, but do expect the value will be change in the future when device become more stable. Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.c133
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h43
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h3
4 files changed, 157 insertions, 28 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
index eb052b05e790..90033e8752bb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
@@ -409,46 +409,34 @@ static int iwl_sens_auto_corr_ofdm(struct iwl_priv *priv,
409 return 0; 409 return 0;
410} 410}
411 411
412/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ 412static void iwl_prepare_legacy_sensitivity_tbl(struct iwl_priv *priv,
413static int iwl_sensitivity_write(struct iwl_priv *priv) 413 struct iwl_sensitivity_data *data,
414 __le16 *tbl)
414{ 415{
415 struct iwl_sensitivity_cmd cmd ; 416 tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX] =
416 struct iwl_sensitivity_data *data = NULL;
417 struct iwl_host_cmd cmd_out = {
418 .id = SENSITIVITY_CMD,
419 .len = sizeof(struct iwl_sensitivity_cmd),
420 .flags = CMD_ASYNC,
421 .data = &cmd,
422 };
423
424 data = &(priv->sensitivity_data);
425
426 memset(&cmd, 0, sizeof(cmd));
427
428 cmd.table[HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX] =
429 cpu_to_le16((u16)data->auto_corr_ofdm); 417 cpu_to_le16((u16)data->auto_corr_ofdm);
430 cmd.table[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX] = 418 tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX] =
431 cpu_to_le16((u16)data->auto_corr_ofdm_mrc); 419 cpu_to_le16((u16)data->auto_corr_ofdm_mrc);
432 cmd.table[HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX] = 420 tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX] =
433 cpu_to_le16((u16)data->auto_corr_ofdm_x1); 421 cpu_to_le16((u16)data->auto_corr_ofdm_x1);
434 cmd.table[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX] = 422 tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX] =
435 cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1); 423 cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1);
436 424
437 cmd.table[HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX] = 425 tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX] =
438 cpu_to_le16((u16)data->auto_corr_cck); 426 cpu_to_le16((u16)data->auto_corr_cck);
439 cmd.table[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX] = 427 tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX] =
440 cpu_to_le16((u16)data->auto_corr_cck_mrc); 428 cpu_to_le16((u16)data->auto_corr_cck_mrc);
441 429
442 cmd.table[HD_MIN_ENERGY_CCK_DET_INDEX] = 430 tbl[HD_MIN_ENERGY_CCK_DET_INDEX] =
443 cpu_to_le16((u16)data->nrg_th_cck); 431 cpu_to_le16((u16)data->nrg_th_cck);
444 cmd.table[HD_MIN_ENERGY_OFDM_DET_INDEX] = 432 tbl[HD_MIN_ENERGY_OFDM_DET_INDEX] =
445 cpu_to_le16((u16)data->nrg_th_ofdm); 433 cpu_to_le16((u16)data->nrg_th_ofdm);
446 434
447 cmd.table[HD_BARKER_CORR_TH_ADD_MIN_INDEX] = 435 tbl[HD_BARKER_CORR_TH_ADD_MIN_INDEX] =
448 cpu_to_le16(data->barker_corr_th_min); 436 cpu_to_le16(data->barker_corr_th_min);
449 cmd.table[HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX] = 437 tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX] =
450 cpu_to_le16(data->barker_corr_th_min_mrc); 438 cpu_to_le16(data->barker_corr_th_min_mrc);
451 cmd.table[HD_OFDM_ENERGY_TH_IN_INDEX] = 439 tbl[HD_OFDM_ENERGY_TH_IN_INDEX] =
452 cpu_to_le16(data->nrg_th_cca); 440 cpu_to_le16(data->nrg_th_cca);
453 441
454 IWL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", 442 IWL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n",
@@ -459,6 +447,25 @@ static int iwl_sensitivity_write(struct iwl_priv *priv)
459 IWL_DEBUG_CALIB(priv, "cck: ac %u mrc %u thresh %u\n", 447 IWL_DEBUG_CALIB(priv, "cck: ac %u mrc %u thresh %u\n",
460 data->auto_corr_cck, data->auto_corr_cck_mrc, 448 data->auto_corr_cck, data->auto_corr_cck_mrc,
461 data->nrg_th_cck); 449 data->nrg_th_cck);
450}
451
452/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */
453static int iwl_sensitivity_write(struct iwl_priv *priv)
454{
455 struct iwl_sensitivity_cmd cmd;
456 struct iwl_sensitivity_data *data = NULL;
457 struct iwl_host_cmd cmd_out = {
458 .id = SENSITIVITY_CMD,
459 .len = sizeof(struct iwl_sensitivity_cmd),
460 .flags = CMD_ASYNC,
461 .data = &cmd,
462 };
463
464 data = &(priv->sensitivity_data);
465
466 memset(&cmd, 0, sizeof(cmd));
467
468 iwl_prepare_legacy_sensitivity_tbl(priv, data, &cmd.table[0]);
462 469
463 /* Update uCode's "work" table, and copy it to DSP */ 470 /* Update uCode's "work" table, and copy it to DSP */
464 cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE; 471 cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE;
@@ -477,6 +484,70 @@ static int iwl_sensitivity_write(struct iwl_priv *priv)
477 return iwl_send_cmd(priv, &cmd_out); 484 return iwl_send_cmd(priv, &cmd_out);
478} 485}
479 486
487/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */
488static int iwl_enhance_sensitivity_write(struct iwl_priv *priv)
489{
490 struct iwl_enhance_sensitivity_cmd cmd;
491 struct iwl_sensitivity_data *data = NULL;
492 struct iwl_host_cmd cmd_out = {
493 .id = SENSITIVITY_CMD,
494 .len = sizeof(struct iwl_enhance_sensitivity_cmd),
495 .flags = CMD_ASYNC,
496 .data = &cmd,
497 };
498
499 data = &(priv->sensitivity_data);
500
501 memset(&cmd, 0, sizeof(cmd));
502
503 iwl_prepare_legacy_sensitivity_tbl(priv, data, &cmd.enhance_table[0]);
504
505 cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX] =
506 HD_INA_NON_SQUARE_DET_OFDM_DATA;
507 cmd.enhance_table[HD_INA_NON_SQUARE_DET_CCK_INDEX] =
508 HD_INA_NON_SQUARE_DET_CCK_DATA;
509 cmd.enhance_table[HD_CORR_11_INSTEAD_OF_CORR_9_EN_INDEX] =
510 HD_CORR_11_INSTEAD_OF_CORR_9_EN_DATA;
511 cmd.enhance_table[HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_INDEX] =
512 HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_DATA;
513 cmd.enhance_table[HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_INDEX] =
514 HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_DATA;
515 cmd.enhance_table[HD_OFDM_NON_SQUARE_DET_SLOPE_INDEX] =
516 HD_OFDM_NON_SQUARE_DET_SLOPE_DATA;
517 cmd.enhance_table[HD_OFDM_NON_SQUARE_DET_INTERCEPT_INDEX] =
518 HD_OFDM_NON_SQUARE_DET_INTERCEPT_DATA;
519 cmd.enhance_table[HD_CCK_NON_SQUARE_DET_SLOPE_MRC_INDEX] =
520 HD_CCK_NON_SQUARE_DET_SLOPE_MRC_DATA;
521 cmd.enhance_table[HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_INDEX] =
522 HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_DATA;
523 cmd.enhance_table[HD_CCK_NON_SQUARE_DET_SLOPE_INDEX] =
524 HD_CCK_NON_SQUARE_DET_SLOPE_DATA;
525 cmd.enhance_table[HD_CCK_NON_SQUARE_DET_INTERCEPT_INDEX] =
526 HD_CCK_NON_SQUARE_DET_INTERCEPT_DATA;
527
528 /* Update uCode's "work" table, and copy it to DSP */
529 cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE;
530
531 /* Don't send command to uCode if nothing has changed */
532 if (!memcmp(&cmd.enhance_table[0], &(priv->sensitivity_tbl[0]),
533 sizeof(u16)*HD_TABLE_SIZE) &&
534 !memcmp(&cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX],
535 &(priv->enhance_sensitivity_tbl[0]),
536 sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES)) {
537 IWL_DEBUG_CALIB(priv, "No change in SENSITIVITY_CMD\n");
538 return 0;
539 }
540
541 /* Copy table for comparison next time */
542 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.enhance_table[0]),
543 sizeof(u16)*HD_TABLE_SIZE);
544 memcpy(&(priv->enhance_sensitivity_tbl[0]),
545 &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]),
546 sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES);
547
548 return iwl_send_cmd(priv, &cmd_out);
549}
550
480void iwl_init_sensitivity(struct iwl_priv *priv) 551void iwl_init_sensitivity(struct iwl_priv *priv)
481{ 552{
482 int ret = 0; 553 int ret = 0;
@@ -527,7 +598,10 @@ void iwl_init_sensitivity(struct iwl_priv *priv)
527 data->last_bad_plcp_cnt_cck = 0; 598 data->last_bad_plcp_cnt_cck = 0;
528 data->last_fa_cnt_cck = 0; 599 data->last_fa_cnt_cck = 0;
529 600
530 ret |= iwl_sensitivity_write(priv); 601 if (priv->enhance_sensitivity_table)
602 ret |= iwl_enhance_sensitivity_write(priv);
603 else
604 ret |= iwl_sensitivity_write(priv);
531 IWL_DEBUG_CALIB(priv, "<<return 0x%X\n", ret); 605 IWL_DEBUG_CALIB(priv, "<<return 0x%X\n", ret);
532} 606}
533 607
@@ -633,7 +707,10 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv,
633 707
634 iwl_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); 708 iwl_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time);
635 iwl_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); 709 iwl_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis);
636 iwl_sensitivity_write(priv); 710 if (priv->enhance_sensitivity_table)
711 iwl_enhance_sensitivity_write(priv);
712 else
713 iwl_sensitivity_write(priv);
637} 714}
638 715
639static inline u8 find_first_chain(u8 mask) 716static inline u8 find_first_chain(u8 mask)
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 60af54210f99..66c83b24884f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1961,6 +1961,12 @@ static int iwlagn_load_firmware(struct iwl_priv *priv,
1961 pieces->inst_errlog_ptr = 1961 pieces->inst_errlog_ptr =
1962 le32_to_cpup((__le32 *)tlv_data); 1962 le32_to_cpup((__le32 *)tlv_data);
1963 break; 1963 break;
1964 case IWL_UCODE_TLV_ENHANCE_SENS_TBL:
1965 if (tlv_len)
1966 ret = -EINVAL;
1967 else
1968 priv->enhance_sensitivity_table = true;
1969 break;
1964 default: 1970 default:
1965 IWL_WARN(priv, "unknown TLV: %d\n", tlv_type); 1971 IWL_WARN(priv, "unknown TLV: %d\n", tlv_type);
1966 break; 1972 break;
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index d887b5751190..a587999d07db 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -3490,6 +3490,41 @@ struct iwl_missed_beacon_notif {
3490#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9) 3490#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
3491#define HD_OFDM_ENERGY_TH_IN_INDEX (10) 3491#define HD_OFDM_ENERGY_TH_IN_INDEX (10)
3492 3492
3493/*
3494 * Additional table entries in enhance SENSITIVITY_CMD
3495 */
3496#define HD_INA_NON_SQUARE_DET_OFDM_INDEX (11)
3497#define HD_INA_NON_SQUARE_DET_CCK_INDEX (12)
3498#define HD_CORR_11_INSTEAD_OF_CORR_9_EN_INDEX (13)
3499#define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_INDEX (14)
3500#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (15)
3501#define HD_OFDM_NON_SQUARE_DET_SLOPE_INDEX (16)
3502#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_INDEX (17)
3503#define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_INDEX (18)
3504#define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (19)
3505#define HD_CCK_NON_SQUARE_DET_SLOPE_INDEX (20)
3506#define HD_CCK_NON_SQUARE_DET_INTERCEPT_INDEX (21)
3507#define HD_RESERVED (22)
3508
3509/* number of entries for enhanced tbl */
3510#define ENHANCE_HD_TABLE_SIZE (23)
3511
3512/* number of additional entries for enhanced tbl */
3513#define ENHANCE_HD_TABLE_ENTRIES (ENHANCE_HD_TABLE_SIZE - HD_TABLE_SIZE)
3514
3515#define HD_INA_NON_SQUARE_DET_OFDM_DATA cpu_to_le16(0)
3516#define HD_INA_NON_SQUARE_DET_CCK_DATA cpu_to_le16(0)
3517#define HD_CORR_11_INSTEAD_OF_CORR_9_EN_DATA cpu_to_le16(0)
3518#define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(668)
3519#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
3520#define HD_OFDM_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(486)
3521#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(37)
3522#define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(853)
3523#define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
3524#define HD_CCK_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(476)
3525#define HD_CCK_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(99)
3526
3527
3493/* Control field in struct iwl_sensitivity_cmd */ 3528/* Control field in struct iwl_sensitivity_cmd */
3494#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0) 3529#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0)
3495#define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1) 3530#define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1)
@@ -3506,6 +3541,14 @@ struct iwl_sensitivity_cmd {
3506 __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */ 3541 __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */
3507} __attribute__ ((packed)); 3542} __attribute__ ((packed));
3508 3543
3544/*
3545 *
3546 */
3547struct iwl_enhance_sensitivity_cmd {
3548 __le16 control; /* always use "1" */
3549 __le16 enhance_table[ENHANCE_HD_TABLE_SIZE]; /* use HD_* as index */
3550} __attribute__ ((packed));
3551
3509 3552
3510/** 3553/**
3511 * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response) 3554 * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index c637376a22db..dff1b17d5ea8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -570,6 +570,7 @@ enum iwl_ucode_tlv_type {
570 IWL_UCODE_TLV_INIT_EVTLOG_PTR = 11, 570 IWL_UCODE_TLV_INIT_EVTLOG_PTR = 11,
571 IWL_UCODE_TLV_INIT_EVTLOG_SIZE = 12, 571 IWL_UCODE_TLV_INIT_EVTLOG_SIZE = 12,
572 IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13, 572 IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13,
573 IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14,
573}; 574};
574 575
575struct iwl_ucode_tlv { 576struct iwl_ucode_tlv {
@@ -1193,7 +1194,9 @@ struct iwl_priv {
1193 u8 start_calib; 1194 u8 start_calib;
1194 struct iwl_sensitivity_data sensitivity_data; 1195 struct iwl_sensitivity_data sensitivity_data;
1195 struct iwl_chain_noise_data chain_noise_data; 1196 struct iwl_chain_noise_data chain_noise_data;
1197 bool enhance_sensitivity_table;
1196 __le16 sensitivity_tbl[HD_TABLE_SIZE]; 1198 __le16 sensitivity_tbl[HD_TABLE_SIZE];
1199 __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
1197 1200
1198 struct iwl_ht_config current_ht_config; 1201 struct iwl_ht_config current_ht_config;
1199 1202