30 #include <linux/kernel.h>
31 #include <linux/module.h>
33 #include <linux/sched.h>
56 "TX Power requested while scanning!\n"))
86 sizeof(tx_power_cmd), &tx_power_cmd);
105 idx = (rate_n_flags & 0xff);
112 if (
iwl_rates[idx].plcp == (rate_n_flags & 0xFF))
113 return idx - band_offset;
146 .data = { &flush_cmd, },
151 memset(&flush_cmd, 0,
sizeof(flush_cmd));
178 IWL_ERR(priv,
"flush request fail\n");
182 iwl_trans_wait_tx_queue_empty(priv->
trans);
255 if (priv->
cfg->bt_params) {
262 if (priv->
cfg->bt_params->bt_session_2) {
264 priv->
cfg->bt_params->bt_prio_boost);
269 WARN_ON(priv->
cfg->bt_params->bt_prio_boost & ~0xFF);
271 priv->
cfg->bt_params->bt_prio_boost;
276 IWL_ERR(priv,
"failed to construct BT Coex Config\n");
321 sizeof(iwlagn_concurrent_lookup));
324 sizeof(iwlagn_def_3w_lookup));
327 basic.
flags ?
"active" :
"disabled",
329 "full concurrency" :
"3-wire");
331 if (priv->
cfg->bt_params->bt_session_2) {
335 CMD_SYNC,
sizeof(bt_cmd_v2), &bt_cmd_v2);
340 CMD_SYNC,
sizeof(bt_cmd_v1), &bt_cmd_v1);
343 IWL_ERR(priv,
"failed to send BT Coex Config\n");
350 bool found_ap =
false;
358 iwl_is_associated_ctx(ctx)) {
369 if (!rssi_ena || found_ap) {
384 iwl_is_associated_ctx(ctx)) {
430 int smps_request = -1;
460 IWL_ERR(priv,
"Invalid BT traffic load: %d\n",
479 if (smps_request != -1) {
510 static void iwlagn_print_uartmsg(
struct iwl_priv *priv,
514 "Update Req = 0x%X\n",
522 IWL_DEBUG_COEX(priv,
"Open connections = 0x%X, Traffic load = 0x%X, "
523 "Chl_SeqN = 0x%X, In band = 0x%X\n",
533 IWL_DEBUG_COEX(priv,
"SCO/eSCO = 0x%X, Sniff = 0x%X, A2DP = 0x%X, "
534 "ACL = 0x%X, Master = 0x%X, OBEX = 0x%X\n",
553 "eSCO Retransmissions = 0x%X\n",
561 IWL_DEBUG_COEX(priv,
"Sniff Interval = 0x%X, Discoverable = 0x%X\n",
568 "0x%X, Inquiry = 0x%X, Connectable = 0x%X\n",
579 static bool iwlagn_set_kill_msk(
struct iwl_priv *priv,
582 bool need_update =
false;
584 static const __le32 bt_kill_ack_msg[3] = {
588 static const __le32 bt_kill_cts_msg[3] = {
616 static bool iwlagn_fill_txpower_mode(
struct iwl_priv *priv,
619 bool need_update =
false;
679 iwlagn_print_uartmsg(priv, uart_msg);
682 priv->
bt_is_sco = iwlagn_bt_traffic_is_sco(uart_msg);
708 if (iwlagn_fill_txpower_mode(priv, uart_msg) ||
709 iwlagn_set_kill_msk(priv, uart_msg))
728 iwlagn_bt_traffic_change_work);
736 static bool is_single_rx_stream(
struct iwl_priv *priv)
742 #define IWL_NUM_RX_CHAINS_MULTIPLE 3
743 #define IWL_NUM_RX_CHAINS_SINGLE 2
744 #define IWL_NUM_IDLE_CHAINS_DUAL 2
745 #define IWL_NUM_IDLE_CHAINS_SINGLE 1
757 static int iwl_get_active_rx_chain_count(
struct iwl_priv *priv)
759 if (priv->
cfg->bt_params &&
760 priv->
cfg->bt_params->advanced_bt_coexist &&
770 if (is_single_rx_stream(priv))
780 static int iwl_get_idle_rx_chain_count(
struct iwl_priv *priv,
int active_cnt)
791 WARN(1,
"invalid SMPS mode %d",
798 static u8 iwl_count_chain_bitmap(
u32 chain_bitmap)
801 res = (chain_bitmap &
BIT(0)) >> 0;
802 res += (chain_bitmap &
BIT(1)) >> 1;
803 res += (chain_bitmap &
BIT(2)) >> 2;
804 res += (chain_bitmap &
BIT(3)) >> 3;
816 bool is_single = is_single_rx_stream(priv);
818 u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt;
831 if (priv->
cfg->bt_params &&
832 priv->
cfg->bt_params->advanced_bt_coexist &&
839 active_chains = first_antenna(active_chains);
845 active_rx_cnt = iwl_get_active_rx_chain_count(priv);
846 idle_rx_cnt = iwl_get_idle_rx_chain_count(priv, active_rx_cnt);
852 valid_rx_cnt = iwl_count_chain_bitmap(active_chains);
853 if (valid_rx_cnt < active_rx_cnt)
854 active_rx_cnt = valid_rx_cnt;
856 if (valid_rx_cnt < idle_rx_cnt)
857 idle_rx_cnt = valid_rx_cnt;
871 active_rx_cnt, idle_rx_cnt);
873 WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 ||
874 active_rx_cnt < idle_rx_cnt);
887 ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0;
888 if (valid &
BIT(ind))
894 #ifdef CONFIG_PM_SLEEP
903 struct wowlan_key_data {
908 bool error, use_rsc_tsc, use_tkip;
919 struct wowlan_key_data *
data = _data;
940 IWL_ERR(priv,
"Error setting key during suspend!\n");
947 tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc;
948 tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc;
950 rx_p1ks = data->tkip->rx_uni;
957 iwlagn_convert_p1k(p1k, data->tkip->tx.p1k);
959 memcpy(data->tkip->mic_keys.tx,
963 rx_mic_key = data->tkip->mic_keys.rx_unicast;
966 data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc;
967 rx_p1ks = data->tkip->rx_multi;
968 rx_mic_key = data->tkip->mic_keys.rx_mcast;
981 if (
seq.tkip.iv32 > cur_rx_iv32)
982 cur_rx_iv32 =
seq.tkip.iv32;
986 iwlagn_convert_p1k(p1k, rx_p1ks[0].p1k);
988 cur_rx_iv32 + 1, p1k);
989 iwlagn_convert_p1k(p1k, rx_p1ks[1].p1k);
995 data->use_tkip =
true;
996 data->use_rsc_tsc =
true;
1002 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc;
1003 aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc;
1009 ((
u64)pn[3] << 16) |
1010 ((
u64)pn[2] << 24) |
1011 ((
u64)pn[1] << 32) |
1012 ((
u64)pn[0] << 40));
1014 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc;
1021 u8 *pn =
seq.ccmp.pn;
1027 ((
u64)pn[3] << 16) |
1028 ((
u64)pn[2] << 24) |
1029 ((
u64)pn[1] << 32) |
1030 ((
u64)pn[0] << 40));
1032 data->use_rsc_tsc =
true;
1039 int iwlagn_send_patterns(
struct iwl_priv *priv,
1053 cmd.
len[0] =
sizeof(*pattern_cmd) +
1066 wowlan->
patterns[i].mask, mask_len);
1070 pattern_cmd->
patterns[
i].mask_size = mask_len;
1075 cmd.
data[0] = pattern_cmd;
1089 struct wowlan_key_data key_data = {
1091 .bssid = ctx->
active.bssid_addr,
1092 .use_rsc_tsc =
false,
1099 key_data.rsc_tsc = kzalloc(
sizeof(*key_data.rsc_tsc),
GFP_KERNEL);
1100 if (!key_data.rsc_tsc)
1103 memset(&wakeup_filter_cmd, 0,
sizeof(wakeup_filter_cmd));
1123 wakeup_filter_cmd.enabled |=
1127 wakeup_filter_cmd.enabled |=
1130 wakeup_filter_cmd.enabled |=
1133 wakeup_filter_cmd.enabled |=
1136 wakeup_filter_cmd.enabled |=
1139 wakeup_filter_cmd.enabled |=
1151 iwl_trans_stop_device(priv->
trans);
1185 iwlagn_wowlan_program_keys,
1188 if (key_data.error) {
1193 if (key_data.use_rsc_tsc) {
1197 .data[0] = key_data.rsc_tsc,
1199 .len[0] =
sizeof(*key_data.rsc_tsc),
1207 if (key_data.use_tkip) {
1217 memset(&kek_kck_cmd, 0,
sizeof(kek_kck_cmd));
1234 sizeof(d3_cfg_cmd), &d3_cfg_cmd);
1239 CMD_SYNC,
sizeof(wakeup_filter_cmd),
1240 &wakeup_filter_cmd);
1244 ret = iwlagn_send_patterns(priv, wowlan);
1246 kfree(key_data.rsc_tsc);
1253 if (iwl_is_rfkill(priv) || iwl_is_ctkill(priv)) {
1254 IWL_WARN(priv,
"Not sending command - %s KILL\n",
1255 iwl_is_rfkill(priv) ?
"RF" :
"CT");
1260 IWL_ERR(priv,
"Command %s failed: FW Error\n",
1261 iwl_dvm_get_cmd_string(cmd->
id));
1275 IWL_DEBUG_HC(priv,
"tm own the uCode, no regular hcmd send\n");
1279 return iwl_trans_send_cmd(priv->
trans, cmd);