Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2011 Atheros Communications Inc. |
| 3 | * Copyright (c) 2011-2013 Qualcomm Atheros, Inc. |
| 4 | * |
| 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 6 | * purpose with or without fee is hereby granted, provided that the above |
| 7 | * copyright notice and this permission notice appear in all copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/skbuff.h> |
| 19 | |
| 20 | #include "core.h" |
| 21 | #include "htc.h" |
| 22 | #include "debug.h" |
| 23 | #include "wmi.h" |
| 24 | #include "mac.h" |
| 25 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 26 | /* MAIN WMI cmd track */ |
| 27 | static struct wmi_cmd_map wmi_cmd_map = { |
| 28 | .init_cmdid = WMI_INIT_CMDID, |
| 29 | .start_scan_cmdid = WMI_START_SCAN_CMDID, |
| 30 | .stop_scan_cmdid = WMI_STOP_SCAN_CMDID, |
| 31 | .scan_chan_list_cmdid = WMI_SCAN_CHAN_LIST_CMDID, |
| 32 | .scan_sch_prio_tbl_cmdid = WMI_SCAN_SCH_PRIO_TBL_CMDID, |
| 33 | .pdev_set_regdomain_cmdid = WMI_PDEV_SET_REGDOMAIN_CMDID, |
| 34 | .pdev_set_channel_cmdid = WMI_PDEV_SET_CHANNEL_CMDID, |
| 35 | .pdev_set_param_cmdid = WMI_PDEV_SET_PARAM_CMDID, |
| 36 | .pdev_pktlog_enable_cmdid = WMI_PDEV_PKTLOG_ENABLE_CMDID, |
| 37 | .pdev_pktlog_disable_cmdid = WMI_PDEV_PKTLOG_DISABLE_CMDID, |
| 38 | .pdev_set_wmm_params_cmdid = WMI_PDEV_SET_WMM_PARAMS_CMDID, |
| 39 | .pdev_set_ht_cap_ie_cmdid = WMI_PDEV_SET_HT_CAP_IE_CMDID, |
| 40 | .pdev_set_vht_cap_ie_cmdid = WMI_PDEV_SET_VHT_CAP_IE_CMDID, |
| 41 | .pdev_set_dscp_tid_map_cmdid = WMI_PDEV_SET_DSCP_TID_MAP_CMDID, |
| 42 | .pdev_set_quiet_mode_cmdid = WMI_PDEV_SET_QUIET_MODE_CMDID, |
| 43 | .pdev_green_ap_ps_enable_cmdid = WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID, |
| 44 | .pdev_get_tpc_config_cmdid = WMI_PDEV_GET_TPC_CONFIG_CMDID, |
| 45 | .pdev_set_base_macaddr_cmdid = WMI_PDEV_SET_BASE_MACADDR_CMDID, |
| 46 | .vdev_create_cmdid = WMI_VDEV_CREATE_CMDID, |
| 47 | .vdev_delete_cmdid = WMI_VDEV_DELETE_CMDID, |
| 48 | .vdev_start_request_cmdid = WMI_VDEV_START_REQUEST_CMDID, |
| 49 | .vdev_restart_request_cmdid = WMI_VDEV_RESTART_REQUEST_CMDID, |
| 50 | .vdev_up_cmdid = WMI_VDEV_UP_CMDID, |
| 51 | .vdev_stop_cmdid = WMI_VDEV_STOP_CMDID, |
| 52 | .vdev_down_cmdid = WMI_VDEV_DOWN_CMDID, |
| 53 | .vdev_set_param_cmdid = WMI_VDEV_SET_PARAM_CMDID, |
| 54 | .vdev_install_key_cmdid = WMI_VDEV_INSTALL_KEY_CMDID, |
| 55 | .peer_create_cmdid = WMI_PEER_CREATE_CMDID, |
| 56 | .peer_delete_cmdid = WMI_PEER_DELETE_CMDID, |
| 57 | .peer_flush_tids_cmdid = WMI_PEER_FLUSH_TIDS_CMDID, |
| 58 | .peer_set_param_cmdid = WMI_PEER_SET_PARAM_CMDID, |
| 59 | .peer_assoc_cmdid = WMI_PEER_ASSOC_CMDID, |
| 60 | .peer_add_wds_entry_cmdid = WMI_PEER_ADD_WDS_ENTRY_CMDID, |
| 61 | .peer_remove_wds_entry_cmdid = WMI_PEER_REMOVE_WDS_ENTRY_CMDID, |
| 62 | .peer_mcast_group_cmdid = WMI_PEER_MCAST_GROUP_CMDID, |
| 63 | .bcn_tx_cmdid = WMI_BCN_TX_CMDID, |
| 64 | .pdev_send_bcn_cmdid = WMI_PDEV_SEND_BCN_CMDID, |
| 65 | .bcn_tmpl_cmdid = WMI_BCN_TMPL_CMDID, |
| 66 | .bcn_filter_rx_cmdid = WMI_BCN_FILTER_RX_CMDID, |
| 67 | .prb_req_filter_rx_cmdid = WMI_PRB_REQ_FILTER_RX_CMDID, |
| 68 | .mgmt_tx_cmdid = WMI_MGMT_TX_CMDID, |
| 69 | .prb_tmpl_cmdid = WMI_PRB_TMPL_CMDID, |
| 70 | .addba_clear_resp_cmdid = WMI_ADDBA_CLEAR_RESP_CMDID, |
| 71 | .addba_send_cmdid = WMI_ADDBA_SEND_CMDID, |
| 72 | .addba_status_cmdid = WMI_ADDBA_STATUS_CMDID, |
| 73 | .delba_send_cmdid = WMI_DELBA_SEND_CMDID, |
| 74 | .addba_set_resp_cmdid = WMI_ADDBA_SET_RESP_CMDID, |
| 75 | .send_singleamsdu_cmdid = WMI_SEND_SINGLEAMSDU_CMDID, |
| 76 | .sta_powersave_mode_cmdid = WMI_STA_POWERSAVE_MODE_CMDID, |
| 77 | .sta_powersave_param_cmdid = WMI_STA_POWERSAVE_PARAM_CMDID, |
| 78 | .sta_mimo_ps_mode_cmdid = WMI_STA_MIMO_PS_MODE_CMDID, |
| 79 | .pdev_dfs_enable_cmdid = WMI_PDEV_DFS_ENABLE_CMDID, |
| 80 | .pdev_dfs_disable_cmdid = WMI_PDEV_DFS_DISABLE_CMDID, |
| 81 | .roam_scan_mode = WMI_ROAM_SCAN_MODE, |
| 82 | .roam_scan_rssi_threshold = WMI_ROAM_SCAN_RSSI_THRESHOLD, |
| 83 | .roam_scan_period = WMI_ROAM_SCAN_PERIOD, |
| 84 | .roam_scan_rssi_change_threshold = WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, |
| 85 | .roam_ap_profile = WMI_ROAM_AP_PROFILE, |
| 86 | .ofl_scan_add_ap_profile = WMI_ROAM_AP_PROFILE, |
| 87 | .ofl_scan_remove_ap_profile = WMI_OFL_SCAN_REMOVE_AP_PROFILE, |
| 88 | .ofl_scan_period = WMI_OFL_SCAN_PERIOD, |
| 89 | .p2p_dev_set_device_info = WMI_P2P_DEV_SET_DEVICE_INFO, |
| 90 | .p2p_dev_set_discoverability = WMI_P2P_DEV_SET_DISCOVERABILITY, |
| 91 | .p2p_go_set_beacon_ie = WMI_P2P_GO_SET_BEACON_IE, |
| 92 | .p2p_go_set_probe_resp_ie = WMI_P2P_GO_SET_PROBE_RESP_IE, |
| 93 | .p2p_set_vendor_ie_data_cmdid = WMI_P2P_SET_VENDOR_IE_DATA_CMDID, |
| 94 | .ap_ps_peer_param_cmdid = WMI_AP_PS_PEER_PARAM_CMDID, |
| 95 | .ap_ps_peer_uapsd_coex_cmdid = WMI_AP_PS_PEER_UAPSD_COEX_CMDID, |
| 96 | .peer_rate_retry_sched_cmdid = WMI_PEER_RATE_RETRY_SCHED_CMDID, |
| 97 | .wlan_profile_trigger_cmdid = WMI_WLAN_PROFILE_TRIGGER_CMDID, |
| 98 | .wlan_profile_set_hist_intvl_cmdid = |
| 99 | WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID, |
| 100 | .wlan_profile_get_profile_data_cmdid = |
| 101 | WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID, |
| 102 | .wlan_profile_enable_profile_id_cmdid = |
| 103 | WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID, |
| 104 | .wlan_profile_list_profile_id_cmdid = |
| 105 | WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID, |
| 106 | .pdev_suspend_cmdid = WMI_PDEV_SUSPEND_CMDID, |
| 107 | .pdev_resume_cmdid = WMI_PDEV_RESUME_CMDID, |
| 108 | .add_bcn_filter_cmdid = WMI_ADD_BCN_FILTER_CMDID, |
| 109 | .rmv_bcn_filter_cmdid = WMI_RMV_BCN_FILTER_CMDID, |
| 110 | .wow_add_wake_pattern_cmdid = WMI_WOW_ADD_WAKE_PATTERN_CMDID, |
| 111 | .wow_del_wake_pattern_cmdid = WMI_WOW_DEL_WAKE_PATTERN_CMDID, |
| 112 | .wow_enable_disable_wake_event_cmdid = |
| 113 | WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID, |
| 114 | .wow_enable_cmdid = WMI_WOW_ENABLE_CMDID, |
| 115 | .wow_hostwakeup_from_sleep_cmdid = WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID, |
| 116 | .rtt_measreq_cmdid = WMI_RTT_MEASREQ_CMDID, |
| 117 | .rtt_tsf_cmdid = WMI_RTT_TSF_CMDID, |
| 118 | .vdev_spectral_scan_configure_cmdid = |
| 119 | WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID, |
| 120 | .vdev_spectral_scan_enable_cmdid = WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID, |
| 121 | .request_stats_cmdid = WMI_REQUEST_STATS_CMDID, |
| 122 | .set_arp_ns_offload_cmdid = WMI_SET_ARP_NS_OFFLOAD_CMDID, |
| 123 | .network_list_offload_config_cmdid = |
| 124 | WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID, |
| 125 | .gtk_offload_cmdid = WMI_GTK_OFFLOAD_CMDID, |
| 126 | .csa_offload_enable_cmdid = WMI_CSA_OFFLOAD_ENABLE_CMDID, |
| 127 | .csa_offload_chanswitch_cmdid = WMI_CSA_OFFLOAD_CHANSWITCH_CMDID, |
| 128 | .chatter_set_mode_cmdid = WMI_CHATTER_SET_MODE_CMDID, |
| 129 | .peer_tid_addba_cmdid = WMI_PEER_TID_ADDBA_CMDID, |
| 130 | .peer_tid_delba_cmdid = WMI_PEER_TID_DELBA_CMDID, |
| 131 | .sta_dtim_ps_method_cmdid = WMI_STA_DTIM_PS_METHOD_CMDID, |
| 132 | .sta_uapsd_auto_trig_cmdid = WMI_STA_UAPSD_AUTO_TRIG_CMDID, |
| 133 | .sta_keepalive_cmd = WMI_STA_KEEPALIVE_CMD, |
| 134 | .echo_cmdid = WMI_ECHO_CMDID, |
| 135 | .pdev_utf_cmdid = WMI_PDEV_UTF_CMDID, |
| 136 | .dbglog_cfg_cmdid = WMI_DBGLOG_CFG_CMDID, |
| 137 | .pdev_qvit_cmdid = WMI_PDEV_QVIT_CMDID, |
| 138 | .pdev_ftm_intg_cmdid = WMI_PDEV_FTM_INTG_CMDID, |
| 139 | .vdev_set_keepalive_cmdid = WMI_VDEV_SET_KEEPALIVE_CMDID, |
| 140 | .vdev_get_keepalive_cmdid = WMI_VDEV_GET_KEEPALIVE_CMDID, |
| 141 | .force_fw_hang_cmdid = WMI_FORCE_FW_HANG_CMDID, |
| 142 | .gpio_config_cmdid = WMI_GPIO_CONFIG_CMDID, |
| 143 | .gpio_output_cmdid = WMI_GPIO_OUTPUT_CMDID, |
| 144 | }; |
| 145 | |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 146 | /* 10.X WMI cmd track */ |
| 147 | static struct wmi_cmd_map wmi_10x_cmd_map = { |
| 148 | .init_cmdid = WMI_10X_INIT_CMDID, |
| 149 | .start_scan_cmdid = WMI_10X_START_SCAN_CMDID, |
| 150 | .stop_scan_cmdid = WMI_10X_STOP_SCAN_CMDID, |
| 151 | .scan_chan_list_cmdid = WMI_10X_SCAN_CHAN_LIST_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 152 | .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 153 | .pdev_set_regdomain_cmdid = WMI_10X_PDEV_SET_REGDOMAIN_CMDID, |
| 154 | .pdev_set_channel_cmdid = WMI_10X_PDEV_SET_CHANNEL_CMDID, |
| 155 | .pdev_set_param_cmdid = WMI_10X_PDEV_SET_PARAM_CMDID, |
| 156 | .pdev_pktlog_enable_cmdid = WMI_10X_PDEV_PKTLOG_ENABLE_CMDID, |
| 157 | .pdev_pktlog_disable_cmdid = WMI_10X_PDEV_PKTLOG_DISABLE_CMDID, |
| 158 | .pdev_set_wmm_params_cmdid = WMI_10X_PDEV_SET_WMM_PARAMS_CMDID, |
| 159 | .pdev_set_ht_cap_ie_cmdid = WMI_10X_PDEV_SET_HT_CAP_IE_CMDID, |
| 160 | .pdev_set_vht_cap_ie_cmdid = WMI_10X_PDEV_SET_VHT_CAP_IE_CMDID, |
| 161 | .pdev_set_dscp_tid_map_cmdid = WMI_10X_PDEV_SET_DSCP_TID_MAP_CMDID, |
| 162 | .pdev_set_quiet_mode_cmdid = WMI_10X_PDEV_SET_QUIET_MODE_CMDID, |
| 163 | .pdev_green_ap_ps_enable_cmdid = WMI_10X_PDEV_GREEN_AP_PS_ENABLE_CMDID, |
| 164 | .pdev_get_tpc_config_cmdid = WMI_10X_PDEV_GET_TPC_CONFIG_CMDID, |
| 165 | .pdev_set_base_macaddr_cmdid = WMI_10X_PDEV_SET_BASE_MACADDR_CMDID, |
| 166 | .vdev_create_cmdid = WMI_10X_VDEV_CREATE_CMDID, |
| 167 | .vdev_delete_cmdid = WMI_10X_VDEV_DELETE_CMDID, |
| 168 | .vdev_start_request_cmdid = WMI_10X_VDEV_START_REQUEST_CMDID, |
| 169 | .vdev_restart_request_cmdid = WMI_10X_VDEV_RESTART_REQUEST_CMDID, |
| 170 | .vdev_up_cmdid = WMI_10X_VDEV_UP_CMDID, |
| 171 | .vdev_stop_cmdid = WMI_10X_VDEV_STOP_CMDID, |
| 172 | .vdev_down_cmdid = WMI_10X_VDEV_DOWN_CMDID, |
| 173 | .vdev_set_param_cmdid = WMI_10X_VDEV_SET_PARAM_CMDID, |
| 174 | .vdev_install_key_cmdid = WMI_10X_VDEV_INSTALL_KEY_CMDID, |
| 175 | .peer_create_cmdid = WMI_10X_PEER_CREATE_CMDID, |
| 176 | .peer_delete_cmdid = WMI_10X_PEER_DELETE_CMDID, |
| 177 | .peer_flush_tids_cmdid = WMI_10X_PEER_FLUSH_TIDS_CMDID, |
| 178 | .peer_set_param_cmdid = WMI_10X_PEER_SET_PARAM_CMDID, |
| 179 | .peer_assoc_cmdid = WMI_10X_PEER_ASSOC_CMDID, |
| 180 | .peer_add_wds_entry_cmdid = WMI_10X_PEER_ADD_WDS_ENTRY_CMDID, |
| 181 | .peer_remove_wds_entry_cmdid = WMI_10X_PEER_REMOVE_WDS_ENTRY_CMDID, |
| 182 | .peer_mcast_group_cmdid = WMI_10X_PEER_MCAST_GROUP_CMDID, |
| 183 | .bcn_tx_cmdid = WMI_10X_BCN_TX_CMDID, |
| 184 | .pdev_send_bcn_cmdid = WMI_10X_PDEV_SEND_BCN_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 185 | .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 186 | .bcn_filter_rx_cmdid = WMI_10X_BCN_FILTER_RX_CMDID, |
| 187 | .prb_req_filter_rx_cmdid = WMI_10X_PRB_REQ_FILTER_RX_CMDID, |
| 188 | .mgmt_tx_cmdid = WMI_10X_MGMT_TX_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 189 | .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 190 | .addba_clear_resp_cmdid = WMI_10X_ADDBA_CLEAR_RESP_CMDID, |
| 191 | .addba_send_cmdid = WMI_10X_ADDBA_SEND_CMDID, |
| 192 | .addba_status_cmdid = WMI_10X_ADDBA_STATUS_CMDID, |
| 193 | .delba_send_cmdid = WMI_10X_DELBA_SEND_CMDID, |
| 194 | .addba_set_resp_cmdid = WMI_10X_ADDBA_SET_RESP_CMDID, |
| 195 | .send_singleamsdu_cmdid = WMI_10X_SEND_SINGLEAMSDU_CMDID, |
| 196 | .sta_powersave_mode_cmdid = WMI_10X_STA_POWERSAVE_MODE_CMDID, |
| 197 | .sta_powersave_param_cmdid = WMI_10X_STA_POWERSAVE_PARAM_CMDID, |
| 198 | .sta_mimo_ps_mode_cmdid = WMI_10X_STA_MIMO_PS_MODE_CMDID, |
| 199 | .pdev_dfs_enable_cmdid = WMI_10X_PDEV_DFS_ENABLE_CMDID, |
| 200 | .pdev_dfs_disable_cmdid = WMI_10X_PDEV_DFS_DISABLE_CMDID, |
| 201 | .roam_scan_mode = WMI_10X_ROAM_SCAN_MODE, |
| 202 | .roam_scan_rssi_threshold = WMI_10X_ROAM_SCAN_RSSI_THRESHOLD, |
| 203 | .roam_scan_period = WMI_10X_ROAM_SCAN_PERIOD, |
| 204 | .roam_scan_rssi_change_threshold = |
| 205 | WMI_10X_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, |
| 206 | .roam_ap_profile = WMI_10X_ROAM_AP_PROFILE, |
| 207 | .ofl_scan_add_ap_profile = WMI_10X_OFL_SCAN_ADD_AP_PROFILE, |
| 208 | .ofl_scan_remove_ap_profile = WMI_10X_OFL_SCAN_REMOVE_AP_PROFILE, |
| 209 | .ofl_scan_period = WMI_10X_OFL_SCAN_PERIOD, |
| 210 | .p2p_dev_set_device_info = WMI_10X_P2P_DEV_SET_DEVICE_INFO, |
| 211 | .p2p_dev_set_discoverability = WMI_10X_P2P_DEV_SET_DISCOVERABILITY, |
| 212 | .p2p_go_set_beacon_ie = WMI_10X_P2P_GO_SET_BEACON_IE, |
| 213 | .p2p_go_set_probe_resp_ie = WMI_10X_P2P_GO_SET_PROBE_RESP_IE, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 214 | .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED, |
| 215 | .ap_ps_peer_param_cmdid = WMI_CMD_UNSUPPORTED, |
| 216 | .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 217 | .peer_rate_retry_sched_cmdid = WMI_10X_PEER_RATE_RETRY_SCHED_CMDID, |
| 218 | .wlan_profile_trigger_cmdid = WMI_10X_WLAN_PROFILE_TRIGGER_CMDID, |
| 219 | .wlan_profile_set_hist_intvl_cmdid = |
| 220 | WMI_10X_WLAN_PROFILE_SET_HIST_INTVL_CMDID, |
| 221 | .wlan_profile_get_profile_data_cmdid = |
| 222 | WMI_10X_WLAN_PROFILE_GET_PROFILE_DATA_CMDID, |
| 223 | .wlan_profile_enable_profile_id_cmdid = |
| 224 | WMI_10X_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID, |
| 225 | .wlan_profile_list_profile_id_cmdid = |
| 226 | WMI_10X_WLAN_PROFILE_LIST_PROFILE_ID_CMDID, |
| 227 | .pdev_suspend_cmdid = WMI_10X_PDEV_SUSPEND_CMDID, |
| 228 | .pdev_resume_cmdid = WMI_10X_PDEV_RESUME_CMDID, |
| 229 | .add_bcn_filter_cmdid = WMI_10X_ADD_BCN_FILTER_CMDID, |
| 230 | .rmv_bcn_filter_cmdid = WMI_10X_RMV_BCN_FILTER_CMDID, |
| 231 | .wow_add_wake_pattern_cmdid = WMI_10X_WOW_ADD_WAKE_PATTERN_CMDID, |
| 232 | .wow_del_wake_pattern_cmdid = WMI_10X_WOW_DEL_WAKE_PATTERN_CMDID, |
| 233 | .wow_enable_disable_wake_event_cmdid = |
| 234 | WMI_10X_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID, |
| 235 | .wow_enable_cmdid = WMI_10X_WOW_ENABLE_CMDID, |
| 236 | .wow_hostwakeup_from_sleep_cmdid = |
| 237 | WMI_10X_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID, |
| 238 | .rtt_measreq_cmdid = WMI_10X_RTT_MEASREQ_CMDID, |
| 239 | .rtt_tsf_cmdid = WMI_10X_RTT_TSF_CMDID, |
| 240 | .vdev_spectral_scan_configure_cmdid = |
| 241 | WMI_10X_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID, |
| 242 | .vdev_spectral_scan_enable_cmdid = |
| 243 | WMI_10X_VDEV_SPECTRAL_SCAN_ENABLE_CMDID, |
| 244 | .request_stats_cmdid = WMI_10X_REQUEST_STATS_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 245 | .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED, |
| 246 | .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED, |
| 247 | .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED, |
| 248 | .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED, |
| 249 | .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED, |
| 250 | .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED, |
| 251 | .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED, |
| 252 | .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED, |
| 253 | .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED, |
| 254 | .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED, |
| 255 | .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 256 | .echo_cmdid = WMI_10X_ECHO_CMDID, |
| 257 | .pdev_utf_cmdid = WMI_10X_PDEV_UTF_CMDID, |
| 258 | .dbglog_cfg_cmdid = WMI_10X_DBGLOG_CFG_CMDID, |
| 259 | .pdev_qvit_cmdid = WMI_10X_PDEV_QVIT_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 260 | .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED, |
| 261 | .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED, |
| 262 | .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED, |
| 263 | .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 264 | .gpio_config_cmdid = WMI_10X_GPIO_CONFIG_CMDID, |
| 265 | .gpio_output_cmdid = WMI_10X_GPIO_OUTPUT_CMDID, |
| 266 | }; |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 267 | |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 268 | /* MAIN WMI VDEV param map */ |
| 269 | static struct wmi_vdev_param_map wmi_vdev_param_map = { |
| 270 | .rts_threshold = WMI_VDEV_PARAM_RTS_THRESHOLD, |
| 271 | .fragmentation_threshold = WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD, |
| 272 | .beacon_interval = WMI_VDEV_PARAM_BEACON_INTERVAL, |
| 273 | .listen_interval = WMI_VDEV_PARAM_LISTEN_INTERVAL, |
| 274 | .multicast_rate = WMI_VDEV_PARAM_MULTICAST_RATE, |
| 275 | .mgmt_tx_rate = WMI_VDEV_PARAM_MGMT_TX_RATE, |
| 276 | .slot_time = WMI_VDEV_PARAM_SLOT_TIME, |
| 277 | .preamble = WMI_VDEV_PARAM_PREAMBLE, |
| 278 | .swba_time = WMI_VDEV_PARAM_SWBA_TIME, |
| 279 | .wmi_vdev_stats_update_period = WMI_VDEV_STATS_UPDATE_PERIOD, |
| 280 | .wmi_vdev_pwrsave_ageout_time = WMI_VDEV_PWRSAVE_AGEOUT_TIME, |
| 281 | .wmi_vdev_host_swba_interval = WMI_VDEV_HOST_SWBA_INTERVAL, |
| 282 | .dtim_period = WMI_VDEV_PARAM_DTIM_PERIOD, |
| 283 | .wmi_vdev_oc_scheduler_air_time_limit = |
| 284 | WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT, |
| 285 | .wds = WMI_VDEV_PARAM_WDS, |
| 286 | .atim_window = WMI_VDEV_PARAM_ATIM_WINDOW, |
| 287 | .bmiss_count_max = WMI_VDEV_PARAM_BMISS_COUNT_MAX, |
| 288 | .bmiss_first_bcnt = WMI_VDEV_PARAM_BMISS_FIRST_BCNT, |
| 289 | .bmiss_final_bcnt = WMI_VDEV_PARAM_BMISS_FINAL_BCNT, |
| 290 | .feature_wmm = WMI_VDEV_PARAM_FEATURE_WMM, |
| 291 | .chwidth = WMI_VDEV_PARAM_CHWIDTH, |
| 292 | .chextoffset = WMI_VDEV_PARAM_CHEXTOFFSET, |
| 293 | .disable_htprotection = WMI_VDEV_PARAM_DISABLE_HTPROTECTION, |
| 294 | .sta_quickkickout = WMI_VDEV_PARAM_STA_QUICKKICKOUT, |
| 295 | .mgmt_rate = WMI_VDEV_PARAM_MGMT_RATE, |
| 296 | .protection_mode = WMI_VDEV_PARAM_PROTECTION_MODE, |
| 297 | .fixed_rate = WMI_VDEV_PARAM_FIXED_RATE, |
| 298 | .sgi = WMI_VDEV_PARAM_SGI, |
| 299 | .ldpc = WMI_VDEV_PARAM_LDPC, |
| 300 | .tx_stbc = WMI_VDEV_PARAM_TX_STBC, |
| 301 | .rx_stbc = WMI_VDEV_PARAM_RX_STBC, |
| 302 | .intra_bss_fwd = WMI_VDEV_PARAM_INTRA_BSS_FWD, |
| 303 | .def_keyid = WMI_VDEV_PARAM_DEF_KEYID, |
| 304 | .nss = WMI_VDEV_PARAM_NSS, |
| 305 | .bcast_data_rate = WMI_VDEV_PARAM_BCAST_DATA_RATE, |
| 306 | .mcast_data_rate = WMI_VDEV_PARAM_MCAST_DATA_RATE, |
| 307 | .mcast_indicate = WMI_VDEV_PARAM_MCAST_INDICATE, |
| 308 | .dhcp_indicate = WMI_VDEV_PARAM_DHCP_INDICATE, |
| 309 | .unknown_dest_indicate = WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE, |
| 310 | .ap_keepalive_min_idle_inactive_time_secs = |
| 311 | WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS, |
| 312 | .ap_keepalive_max_idle_inactive_time_secs = |
| 313 | WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS, |
| 314 | .ap_keepalive_max_unresponsive_time_secs = |
| 315 | WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS, |
| 316 | .ap_enable_nawds = WMI_VDEV_PARAM_AP_ENABLE_NAWDS, |
| 317 | .mcast2ucast_set = WMI_VDEV_PARAM_UNSUPPORTED, |
| 318 | .enable_rtscts = WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 319 | .txbf = WMI_VDEV_PARAM_TXBF, |
| 320 | .packet_powersave = WMI_VDEV_PARAM_PACKET_POWERSAVE, |
| 321 | .drop_unencry = WMI_VDEV_PARAM_DROP_UNENCRY, |
| 322 | .tx_encap_type = WMI_VDEV_PARAM_TX_ENCAP_TYPE, |
| 323 | .ap_detect_out_of_sync_sleeping_sta_time_secs = |
| 324 | WMI_VDEV_PARAM_UNSUPPORTED, |
| 325 | }; |
| 326 | |
| 327 | /* 10.X WMI VDEV param map */ |
| 328 | static struct wmi_vdev_param_map wmi_10x_vdev_param_map = { |
| 329 | .rts_threshold = WMI_10X_VDEV_PARAM_RTS_THRESHOLD, |
| 330 | .fragmentation_threshold = WMI_10X_VDEV_PARAM_FRAGMENTATION_THRESHOLD, |
| 331 | .beacon_interval = WMI_10X_VDEV_PARAM_BEACON_INTERVAL, |
| 332 | .listen_interval = WMI_10X_VDEV_PARAM_LISTEN_INTERVAL, |
| 333 | .multicast_rate = WMI_10X_VDEV_PARAM_MULTICAST_RATE, |
| 334 | .mgmt_tx_rate = WMI_10X_VDEV_PARAM_MGMT_TX_RATE, |
| 335 | .slot_time = WMI_10X_VDEV_PARAM_SLOT_TIME, |
| 336 | .preamble = WMI_10X_VDEV_PARAM_PREAMBLE, |
| 337 | .swba_time = WMI_10X_VDEV_PARAM_SWBA_TIME, |
| 338 | .wmi_vdev_stats_update_period = WMI_10X_VDEV_STATS_UPDATE_PERIOD, |
| 339 | .wmi_vdev_pwrsave_ageout_time = WMI_10X_VDEV_PWRSAVE_AGEOUT_TIME, |
| 340 | .wmi_vdev_host_swba_interval = WMI_10X_VDEV_HOST_SWBA_INTERVAL, |
| 341 | .dtim_period = WMI_10X_VDEV_PARAM_DTIM_PERIOD, |
| 342 | .wmi_vdev_oc_scheduler_air_time_limit = |
| 343 | WMI_10X_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT, |
| 344 | .wds = WMI_10X_VDEV_PARAM_WDS, |
| 345 | .atim_window = WMI_10X_VDEV_PARAM_ATIM_WINDOW, |
| 346 | .bmiss_count_max = WMI_10X_VDEV_PARAM_BMISS_COUNT_MAX, |
| 347 | .bmiss_first_bcnt = WMI_VDEV_PARAM_UNSUPPORTED, |
| 348 | .bmiss_final_bcnt = WMI_VDEV_PARAM_UNSUPPORTED, |
| 349 | .feature_wmm = WMI_10X_VDEV_PARAM_FEATURE_WMM, |
| 350 | .chwidth = WMI_10X_VDEV_PARAM_CHWIDTH, |
| 351 | .chextoffset = WMI_10X_VDEV_PARAM_CHEXTOFFSET, |
| 352 | .disable_htprotection = WMI_10X_VDEV_PARAM_DISABLE_HTPROTECTION, |
| 353 | .sta_quickkickout = WMI_10X_VDEV_PARAM_STA_QUICKKICKOUT, |
| 354 | .mgmt_rate = WMI_10X_VDEV_PARAM_MGMT_RATE, |
| 355 | .protection_mode = WMI_10X_VDEV_PARAM_PROTECTION_MODE, |
| 356 | .fixed_rate = WMI_10X_VDEV_PARAM_FIXED_RATE, |
| 357 | .sgi = WMI_10X_VDEV_PARAM_SGI, |
| 358 | .ldpc = WMI_10X_VDEV_PARAM_LDPC, |
| 359 | .tx_stbc = WMI_10X_VDEV_PARAM_TX_STBC, |
| 360 | .rx_stbc = WMI_10X_VDEV_PARAM_RX_STBC, |
| 361 | .intra_bss_fwd = WMI_10X_VDEV_PARAM_INTRA_BSS_FWD, |
| 362 | .def_keyid = WMI_10X_VDEV_PARAM_DEF_KEYID, |
| 363 | .nss = WMI_10X_VDEV_PARAM_NSS, |
| 364 | .bcast_data_rate = WMI_10X_VDEV_PARAM_BCAST_DATA_RATE, |
| 365 | .mcast_data_rate = WMI_10X_VDEV_PARAM_MCAST_DATA_RATE, |
| 366 | .mcast_indicate = WMI_10X_VDEV_PARAM_MCAST_INDICATE, |
| 367 | .dhcp_indicate = WMI_10X_VDEV_PARAM_DHCP_INDICATE, |
| 368 | .unknown_dest_indicate = WMI_10X_VDEV_PARAM_UNKNOWN_DEST_INDICATE, |
| 369 | .ap_keepalive_min_idle_inactive_time_secs = |
| 370 | WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS, |
| 371 | .ap_keepalive_max_idle_inactive_time_secs = |
| 372 | WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS, |
| 373 | .ap_keepalive_max_unresponsive_time_secs = |
| 374 | WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS, |
| 375 | .ap_enable_nawds = WMI_10X_VDEV_PARAM_AP_ENABLE_NAWDS, |
| 376 | .mcast2ucast_set = WMI_10X_VDEV_PARAM_MCAST2UCAST_SET, |
| 377 | .enable_rtscts = WMI_10X_VDEV_PARAM_ENABLE_RTSCTS, |
| 378 | .txbf = WMI_VDEV_PARAM_UNSUPPORTED, |
| 379 | .packet_powersave = WMI_VDEV_PARAM_UNSUPPORTED, |
| 380 | .drop_unencry = WMI_VDEV_PARAM_UNSUPPORTED, |
| 381 | .tx_encap_type = WMI_VDEV_PARAM_UNSUPPORTED, |
| 382 | .ap_detect_out_of_sync_sleeping_sta_time_secs = |
| 383 | WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS, |
| 384 | }; |
| 385 | |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 386 | static struct wmi_pdev_param_map wmi_pdev_param_map = { |
| 387 | .tx_chain_mask = WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 388 | .rx_chain_mask = WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 389 | .txpower_limit2g = WMI_PDEV_PARAM_TXPOWER_LIMIT2G, |
| 390 | .txpower_limit5g = WMI_PDEV_PARAM_TXPOWER_LIMIT5G, |
| 391 | .txpower_scale = WMI_PDEV_PARAM_TXPOWER_SCALE, |
| 392 | .beacon_gen_mode = WMI_PDEV_PARAM_BEACON_GEN_MODE, |
| 393 | .beacon_tx_mode = WMI_PDEV_PARAM_BEACON_TX_MODE, |
| 394 | .resmgr_offchan_mode = WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE, |
| 395 | .protection_mode = WMI_PDEV_PARAM_PROTECTION_MODE, |
| 396 | .dynamic_bw = WMI_PDEV_PARAM_DYNAMIC_BW, |
| 397 | .non_agg_sw_retry_th = WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH, |
| 398 | .agg_sw_retry_th = WMI_PDEV_PARAM_AGG_SW_RETRY_TH, |
| 399 | .sta_kickout_th = WMI_PDEV_PARAM_STA_KICKOUT_TH, |
| 400 | .ac_aggrsize_scaling = WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING, |
| 401 | .ltr_enable = WMI_PDEV_PARAM_LTR_ENABLE, |
| 402 | .ltr_ac_latency_be = WMI_PDEV_PARAM_LTR_AC_LATENCY_BE, |
| 403 | .ltr_ac_latency_bk = WMI_PDEV_PARAM_LTR_AC_LATENCY_BK, |
| 404 | .ltr_ac_latency_vi = WMI_PDEV_PARAM_LTR_AC_LATENCY_VI, |
| 405 | .ltr_ac_latency_vo = WMI_PDEV_PARAM_LTR_AC_LATENCY_VO, |
| 406 | .ltr_ac_latency_timeout = WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT, |
| 407 | .ltr_sleep_override = WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE, |
| 408 | .ltr_rx_override = WMI_PDEV_PARAM_LTR_RX_OVERRIDE, |
| 409 | .ltr_tx_activity_timeout = WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT, |
| 410 | .l1ss_enable = WMI_PDEV_PARAM_L1SS_ENABLE, |
| 411 | .dsleep_enable = WMI_PDEV_PARAM_DSLEEP_ENABLE, |
| 412 | .pcielp_txbuf_flush = WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH, |
| 413 | .pcielp_txbuf_watermark = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN, |
| 414 | .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN, |
| 415 | .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE, |
| 416 | .pdev_stats_update_period = WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD, |
| 417 | .vdev_stats_update_period = WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD, |
| 418 | .peer_stats_update_period = WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD, |
| 419 | .bcnflt_stats_update_period = WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD, |
| 420 | .pmf_qos = WMI_PDEV_PARAM_PMF_QOS, |
| 421 | .arp_ac_override = WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
| 422 | .arpdhcp_ac_override = WMI_PDEV_PARAM_UNSUPPORTED, |
| 423 | .dcs = WMI_PDEV_PARAM_DCS, |
| 424 | .ani_enable = WMI_PDEV_PARAM_ANI_ENABLE, |
| 425 | .ani_poll_period = WMI_PDEV_PARAM_ANI_POLL_PERIOD, |
| 426 | .ani_listen_period = WMI_PDEV_PARAM_ANI_LISTEN_PERIOD, |
| 427 | .ani_ofdm_level = WMI_PDEV_PARAM_ANI_OFDM_LEVEL, |
| 428 | .ani_cck_level = WMI_PDEV_PARAM_ANI_CCK_LEVEL, |
| 429 | .dyntxchain = WMI_PDEV_PARAM_DYNTXCHAIN, |
| 430 | .proxy_sta = WMI_PDEV_PARAM_PROXY_STA, |
| 431 | .idle_ps_config = WMI_PDEV_PARAM_IDLE_PS_CONFIG, |
| 432 | .power_gating_sleep = WMI_PDEV_PARAM_POWER_GATING_SLEEP, |
| 433 | .fast_channel_reset = WMI_PDEV_PARAM_UNSUPPORTED, |
| 434 | .burst_dur = WMI_PDEV_PARAM_UNSUPPORTED, |
| 435 | .burst_enable = WMI_PDEV_PARAM_UNSUPPORTED, |
| 436 | }; |
| 437 | |
| 438 | static struct wmi_pdev_param_map wmi_10x_pdev_param_map = { |
| 439 | .tx_chain_mask = WMI_10X_PDEV_PARAM_TX_CHAIN_MASK, |
| 440 | .rx_chain_mask = WMI_10X_PDEV_PARAM_RX_CHAIN_MASK, |
| 441 | .txpower_limit2g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT2G, |
| 442 | .txpower_limit5g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT5G, |
| 443 | .txpower_scale = WMI_10X_PDEV_PARAM_TXPOWER_SCALE, |
| 444 | .beacon_gen_mode = WMI_10X_PDEV_PARAM_BEACON_GEN_MODE, |
| 445 | .beacon_tx_mode = WMI_10X_PDEV_PARAM_BEACON_TX_MODE, |
| 446 | .resmgr_offchan_mode = WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE, |
| 447 | .protection_mode = WMI_10X_PDEV_PARAM_PROTECTION_MODE, |
| 448 | .dynamic_bw = WMI_10X_PDEV_PARAM_DYNAMIC_BW, |
| 449 | .non_agg_sw_retry_th = WMI_10X_PDEV_PARAM_NON_AGG_SW_RETRY_TH, |
| 450 | .agg_sw_retry_th = WMI_10X_PDEV_PARAM_AGG_SW_RETRY_TH, |
| 451 | .sta_kickout_th = WMI_10X_PDEV_PARAM_STA_KICKOUT_TH, |
| 452 | .ac_aggrsize_scaling = WMI_10X_PDEV_PARAM_AC_AGGRSIZE_SCALING, |
| 453 | .ltr_enable = WMI_10X_PDEV_PARAM_LTR_ENABLE, |
| 454 | .ltr_ac_latency_be = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BE, |
| 455 | .ltr_ac_latency_bk = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BK, |
| 456 | .ltr_ac_latency_vi = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VI, |
| 457 | .ltr_ac_latency_vo = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VO, |
| 458 | .ltr_ac_latency_timeout = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT, |
| 459 | .ltr_sleep_override = WMI_10X_PDEV_PARAM_LTR_SLEEP_OVERRIDE, |
| 460 | .ltr_rx_override = WMI_10X_PDEV_PARAM_LTR_RX_OVERRIDE, |
| 461 | .ltr_tx_activity_timeout = WMI_10X_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT, |
| 462 | .l1ss_enable = WMI_10X_PDEV_PARAM_L1SS_ENABLE, |
| 463 | .dsleep_enable = WMI_10X_PDEV_PARAM_DSLEEP_ENABLE, |
| 464 | .pcielp_txbuf_flush = WMI_PDEV_PARAM_UNSUPPORTED, |
| 465 | .pcielp_txbuf_watermark = WMI_PDEV_PARAM_UNSUPPORTED, |
| 466 | .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_UNSUPPORTED, |
| 467 | .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_UNSUPPORTED, |
| 468 | .pdev_stats_update_period = WMI_10X_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD, |
| 469 | .vdev_stats_update_period = WMI_10X_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD, |
| 470 | .peer_stats_update_period = WMI_10X_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD, |
| 471 | .bcnflt_stats_update_period = |
| 472 | WMI_10X_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD, |
| 473 | .pmf_qos = WMI_10X_PDEV_PARAM_PMF_QOS, |
| 474 | .arp_ac_override = WMI_PDEV_PARAM_UNSUPPORTED, |
| 475 | .arpdhcp_ac_override = WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE, |
| 476 | .dcs = WMI_10X_PDEV_PARAM_DCS, |
| 477 | .ani_enable = WMI_10X_PDEV_PARAM_ANI_ENABLE, |
| 478 | .ani_poll_period = WMI_10X_PDEV_PARAM_ANI_POLL_PERIOD, |
| 479 | .ani_listen_period = WMI_10X_PDEV_PARAM_ANI_LISTEN_PERIOD, |
| 480 | .ani_ofdm_level = WMI_10X_PDEV_PARAM_ANI_OFDM_LEVEL, |
| 481 | .ani_cck_level = WMI_10X_PDEV_PARAM_ANI_CCK_LEVEL, |
| 482 | .dyntxchain = WMI_10X_PDEV_PARAM_DYNTXCHAIN, |
| 483 | .proxy_sta = WMI_PDEV_PARAM_UNSUPPORTED, |
| 484 | .idle_ps_config = WMI_PDEV_PARAM_UNSUPPORTED, |
| 485 | .power_gating_sleep = WMI_PDEV_PARAM_UNSUPPORTED, |
| 486 | .fast_channel_reset = WMI_10X_PDEV_PARAM_FAST_CHANNEL_RESET, |
| 487 | .burst_dur = WMI_10X_PDEV_PARAM_BURST_DUR, |
| 488 | .burst_enable = WMI_10X_PDEV_PARAM_BURST_ENABLE, |
| 489 | }; |
| 490 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 491 | int ath10k_wmi_wait_for_service_ready(struct ath10k *ar) |
| 492 | { |
| 493 | int ret; |
| 494 | ret = wait_for_completion_timeout(&ar->wmi.service_ready, |
| 495 | WMI_SERVICE_READY_TIMEOUT_HZ); |
| 496 | return ret; |
| 497 | } |
| 498 | |
| 499 | int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar) |
| 500 | { |
| 501 | int ret; |
| 502 | ret = wait_for_completion_timeout(&ar->wmi.unified_ready, |
| 503 | WMI_UNIFIED_READY_TIMEOUT_HZ); |
| 504 | return ret; |
| 505 | } |
| 506 | |
| 507 | static struct sk_buff *ath10k_wmi_alloc_skb(u32 len) |
| 508 | { |
| 509 | struct sk_buff *skb; |
| 510 | u32 round_len = roundup(len, 4); |
| 511 | |
| 512 | skb = ath10k_htc_alloc_skb(WMI_SKB_HEADROOM + round_len); |
| 513 | if (!skb) |
| 514 | return NULL; |
| 515 | |
| 516 | skb_reserve(skb, WMI_SKB_HEADROOM); |
| 517 | if (!IS_ALIGNED((unsigned long)skb->data, 4)) |
| 518 | ath10k_warn("Unaligned WMI skb\n"); |
| 519 | |
| 520 | skb_put(skb, round_len); |
| 521 | memset(skb->data, 0, round_len); |
| 522 | |
| 523 | return skb; |
| 524 | } |
| 525 | |
| 526 | static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb) |
| 527 | { |
| 528 | dev_kfree_skb(skb); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 529 | } |
| 530 | |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 531 | static int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb, |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 532 | u32 cmd_id) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 533 | { |
| 534 | struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb); |
| 535 | struct wmi_cmd_hdr *cmd_hdr; |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 536 | int ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 537 | u32 cmd = 0; |
| 538 | |
| 539 | if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL) |
| 540 | return -ENOMEM; |
| 541 | |
| 542 | cmd |= SM(cmd_id, WMI_CMD_HDR_CMD_ID); |
| 543 | |
| 544 | cmd_hdr = (struct wmi_cmd_hdr *)skb->data; |
| 545 | cmd_hdr->cmd_id = __cpu_to_le32(cmd); |
| 546 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 547 | memset(skb_cb, 0, sizeof(*skb_cb)); |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 548 | ret = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb); |
| 549 | trace_ath10k_wmi_cmd(cmd_id, skb->data, skb->len, ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 550 | |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 551 | if (ret) |
| 552 | goto err_pull; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 553 | |
| 554 | return 0; |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 555 | |
| 556 | err_pull: |
| 557 | skb_pull(skb, sizeof(struct wmi_cmd_hdr)); |
| 558 | return ret; |
| 559 | } |
| 560 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 561 | static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif *arvif) |
| 562 | { |
| 563 | struct wmi_bcn_tx_arg arg = {0}; |
| 564 | int ret; |
| 565 | |
| 566 | lockdep_assert_held(&arvif->ar->data_lock); |
| 567 | |
| 568 | if (arvif->beacon == NULL) |
| 569 | return; |
| 570 | |
| 571 | arg.vdev_id = arvif->vdev_id; |
| 572 | arg.tx_rate = 0; |
| 573 | arg.tx_power = 0; |
| 574 | arg.bcn = arvif->beacon->data; |
| 575 | arg.bcn_len = arvif->beacon->len; |
| 576 | |
| 577 | ret = ath10k_wmi_beacon_send_nowait(arvif->ar, &arg); |
| 578 | if (ret) |
| 579 | return; |
| 580 | |
| 581 | dev_kfree_skb_any(arvif->beacon); |
| 582 | arvif->beacon = NULL; |
| 583 | } |
| 584 | |
| 585 | static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac, |
| 586 | struct ieee80211_vif *vif) |
| 587 | { |
| 588 | struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); |
| 589 | |
| 590 | ath10k_wmi_tx_beacon_nowait(arvif); |
| 591 | } |
| 592 | |
| 593 | static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar) |
| 594 | { |
| 595 | spin_lock_bh(&ar->data_lock); |
| 596 | ieee80211_iterate_active_interfaces_atomic(ar->hw, |
| 597 | IEEE80211_IFACE_ITER_NORMAL, |
| 598 | ath10k_wmi_tx_beacons_iter, |
| 599 | NULL); |
| 600 | spin_unlock_bh(&ar->data_lock); |
| 601 | } |
| 602 | |
Michal Kazior | 12acbc4 | 2013-09-13 14:16:55 +0200 | [diff] [blame] | 603 | static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar) |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 604 | { |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 605 | /* try to send pending beacons first. they take priority */ |
| 606 | ath10k_wmi_tx_beacons_nowait(ar); |
| 607 | |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 608 | wake_up(&ar->wmi.tx_credits_wq); |
| 609 | } |
| 610 | |
| 611 | static int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 612 | u32 cmd_id) |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 613 | { |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 614 | int ret = -EOPNOTSUPP; |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 615 | |
Kalle Valo | 56b8428 | 2013-10-16 15:44:47 +0300 | [diff] [blame] | 616 | might_sleep(); |
| 617 | |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 618 | if (cmd_id == WMI_CMD_UNSUPPORTED) { |
Bartosz Markowski | 5532155 | 2013-09-26 17:47:07 +0200 | [diff] [blame] | 619 | ath10k_warn("wmi command %d is not supported by firmware\n", |
| 620 | cmd_id); |
| 621 | return ret; |
| 622 | } |
| 623 | |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 624 | wait_event_timeout(ar->wmi.tx_credits_wq, ({ |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 625 | /* try to send pending beacons first. they take priority */ |
| 626 | ath10k_wmi_tx_beacons_nowait(ar); |
| 627 | |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 628 | ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id); |
| 629 | (ret != -EAGAIN); |
| 630 | }), 3*HZ); |
| 631 | |
| 632 | if (ret) |
| 633 | dev_kfree_skb_any(skb); |
| 634 | |
| 635 | return ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 636 | } |
| 637 | |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 638 | int ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *skb) |
| 639 | { |
| 640 | int ret = 0; |
| 641 | struct wmi_mgmt_tx_cmd *cmd; |
| 642 | struct ieee80211_hdr *hdr; |
| 643 | struct sk_buff *wmi_skb; |
| 644 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 645 | int len; |
| 646 | u16 fc; |
| 647 | |
| 648 | hdr = (struct ieee80211_hdr *)skb->data; |
| 649 | fc = le16_to_cpu(hdr->frame_control); |
| 650 | |
| 651 | if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control))) |
| 652 | return -EINVAL; |
| 653 | |
| 654 | len = sizeof(cmd->hdr) + skb->len; |
| 655 | len = round_up(len, 4); |
| 656 | |
| 657 | wmi_skb = ath10k_wmi_alloc_skb(len); |
| 658 | if (!wmi_skb) |
| 659 | return -ENOMEM; |
| 660 | |
| 661 | cmd = (struct wmi_mgmt_tx_cmd *)wmi_skb->data; |
| 662 | |
| 663 | cmd->hdr.vdev_id = __cpu_to_le32(ATH10K_SKB_CB(skb)->vdev_id); |
| 664 | cmd->hdr.tx_rate = 0; |
| 665 | cmd->hdr.tx_power = 0; |
| 666 | cmd->hdr.buf_len = __cpu_to_le32((u32)(skb->len)); |
| 667 | |
| 668 | memcpy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr), ETH_ALEN); |
| 669 | memcpy(cmd->buf, skb->data, skb->len); |
| 670 | |
| 671 | ath10k_dbg(ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n", |
| 672 | wmi_skb, wmi_skb->len, fc & IEEE80211_FCTL_FTYPE, |
| 673 | fc & IEEE80211_FCTL_STYPE); |
| 674 | |
| 675 | /* Send the management frame buffer to the target */ |
| 676 | ret = ath10k_wmi_cmd_send(ar, wmi_skb, ar->wmi.cmd->mgmt_tx_cmdid); |
| 677 | if (ret) { |
| 678 | dev_kfree_skb_any(skb); |
| 679 | return ret; |
| 680 | } |
| 681 | |
| 682 | /* TODO: report tx status to mac80211 - temporary just ACK */ |
| 683 | info->flags |= IEEE80211_TX_STAT_ACK; |
| 684 | ieee80211_tx_status_irqsafe(ar->hw, skb); |
| 685 | |
| 686 | return ret; |
| 687 | } |
| 688 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 689 | static int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb) |
| 690 | { |
| 691 | struct wmi_scan_event *event = (struct wmi_scan_event *)skb->data; |
| 692 | enum wmi_scan_event_type event_type; |
| 693 | enum wmi_scan_completion_reason reason; |
| 694 | u32 freq; |
| 695 | u32 req_id; |
| 696 | u32 scan_id; |
| 697 | u32 vdev_id; |
| 698 | |
| 699 | event_type = __le32_to_cpu(event->event_type); |
| 700 | reason = __le32_to_cpu(event->reason); |
| 701 | freq = __le32_to_cpu(event->channel_freq); |
| 702 | req_id = __le32_to_cpu(event->scan_req_id); |
| 703 | scan_id = __le32_to_cpu(event->scan_id); |
| 704 | vdev_id = __le32_to_cpu(event->vdev_id); |
| 705 | |
| 706 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_SCAN_EVENTID\n"); |
| 707 | ath10k_dbg(ATH10K_DBG_WMI, |
| 708 | "scan event type %d reason %d freq %d req_id %d " |
| 709 | "scan_id %d vdev_id %d\n", |
| 710 | event_type, reason, freq, req_id, scan_id, vdev_id); |
| 711 | |
| 712 | spin_lock_bh(&ar->data_lock); |
| 713 | |
| 714 | switch (event_type) { |
| 715 | case WMI_SCAN_EVENT_STARTED: |
| 716 | ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_STARTED\n"); |
| 717 | if (ar->scan.in_progress && ar->scan.is_roc) |
| 718 | ieee80211_ready_on_channel(ar->hw); |
| 719 | |
| 720 | complete(&ar->scan.started); |
| 721 | break; |
| 722 | case WMI_SCAN_EVENT_COMPLETED: |
| 723 | ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_COMPLETED\n"); |
| 724 | switch (reason) { |
| 725 | case WMI_SCAN_REASON_COMPLETED: |
| 726 | ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_COMPLETED\n"); |
| 727 | break; |
| 728 | case WMI_SCAN_REASON_CANCELLED: |
| 729 | ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_CANCELED\n"); |
| 730 | break; |
| 731 | case WMI_SCAN_REASON_PREEMPTED: |
| 732 | ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_PREEMPTED\n"); |
| 733 | break; |
| 734 | case WMI_SCAN_REASON_TIMEDOUT: |
| 735 | ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_TIMEDOUT\n"); |
| 736 | break; |
| 737 | default: |
| 738 | break; |
| 739 | } |
| 740 | |
| 741 | ar->scan_channel = NULL; |
| 742 | if (!ar->scan.in_progress) { |
| 743 | ath10k_warn("no scan requested, ignoring\n"); |
| 744 | break; |
| 745 | } |
| 746 | |
| 747 | if (ar->scan.is_roc) { |
| 748 | ath10k_offchan_tx_purge(ar); |
| 749 | |
| 750 | if (!ar->scan.aborting) |
| 751 | ieee80211_remain_on_channel_expired(ar->hw); |
| 752 | } else { |
| 753 | ieee80211_scan_completed(ar->hw, ar->scan.aborting); |
| 754 | } |
| 755 | |
| 756 | del_timer(&ar->scan.timeout); |
| 757 | complete_all(&ar->scan.completed); |
| 758 | ar->scan.in_progress = false; |
| 759 | break; |
| 760 | case WMI_SCAN_EVENT_BSS_CHANNEL: |
| 761 | ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_BSS_CHANNEL\n"); |
| 762 | ar->scan_channel = NULL; |
| 763 | break; |
| 764 | case WMI_SCAN_EVENT_FOREIGN_CHANNEL: |
| 765 | ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_FOREIGN_CHANNEL\n"); |
| 766 | ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq); |
| 767 | if (ar->scan.in_progress && ar->scan.is_roc && |
| 768 | ar->scan.roc_freq == freq) { |
| 769 | complete(&ar->scan.on_channel); |
| 770 | } |
| 771 | break; |
| 772 | case WMI_SCAN_EVENT_DEQUEUED: |
| 773 | ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_DEQUEUED\n"); |
| 774 | break; |
| 775 | case WMI_SCAN_EVENT_PREEMPTED: |
| 776 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_SCAN_EVENT_PREEMPTED\n"); |
| 777 | break; |
| 778 | case WMI_SCAN_EVENT_START_FAILED: |
| 779 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_SCAN_EVENT_START_FAILED\n"); |
| 780 | break; |
| 781 | default: |
| 782 | break; |
| 783 | } |
| 784 | |
| 785 | spin_unlock_bh(&ar->data_lock); |
| 786 | return 0; |
| 787 | } |
| 788 | |
| 789 | static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode) |
| 790 | { |
| 791 | enum ieee80211_band band; |
| 792 | |
| 793 | switch (phy_mode) { |
| 794 | case MODE_11A: |
| 795 | case MODE_11NA_HT20: |
| 796 | case MODE_11NA_HT40: |
| 797 | case MODE_11AC_VHT20: |
| 798 | case MODE_11AC_VHT40: |
| 799 | case MODE_11AC_VHT80: |
| 800 | band = IEEE80211_BAND_5GHZ; |
| 801 | break; |
| 802 | case MODE_11G: |
| 803 | case MODE_11B: |
| 804 | case MODE_11GONLY: |
| 805 | case MODE_11NG_HT20: |
| 806 | case MODE_11NG_HT40: |
| 807 | case MODE_11AC_VHT20_2G: |
| 808 | case MODE_11AC_VHT40_2G: |
| 809 | case MODE_11AC_VHT80_2G: |
| 810 | default: |
| 811 | band = IEEE80211_BAND_2GHZ; |
| 812 | } |
| 813 | |
| 814 | return band; |
| 815 | } |
| 816 | |
| 817 | static inline u8 get_rate_idx(u32 rate, enum ieee80211_band band) |
| 818 | { |
| 819 | u8 rate_idx = 0; |
| 820 | |
| 821 | /* rate in Kbps */ |
| 822 | switch (rate) { |
| 823 | case 1000: |
| 824 | rate_idx = 0; |
| 825 | break; |
| 826 | case 2000: |
| 827 | rate_idx = 1; |
| 828 | break; |
| 829 | case 5500: |
| 830 | rate_idx = 2; |
| 831 | break; |
| 832 | case 11000: |
| 833 | rate_idx = 3; |
| 834 | break; |
| 835 | case 6000: |
| 836 | rate_idx = 4; |
| 837 | break; |
| 838 | case 9000: |
| 839 | rate_idx = 5; |
| 840 | break; |
| 841 | case 12000: |
| 842 | rate_idx = 6; |
| 843 | break; |
| 844 | case 18000: |
| 845 | rate_idx = 7; |
| 846 | break; |
| 847 | case 24000: |
| 848 | rate_idx = 8; |
| 849 | break; |
| 850 | case 36000: |
| 851 | rate_idx = 9; |
| 852 | break; |
| 853 | case 48000: |
| 854 | rate_idx = 10; |
| 855 | break; |
| 856 | case 54000: |
| 857 | rate_idx = 11; |
| 858 | break; |
| 859 | default: |
| 860 | break; |
| 861 | } |
| 862 | |
| 863 | if (band == IEEE80211_BAND_5GHZ) { |
| 864 | if (rate_idx > 3) |
| 865 | /* Omit CCK rates */ |
| 866 | rate_idx -= 4; |
| 867 | else |
| 868 | rate_idx = 0; |
| 869 | } |
| 870 | |
| 871 | return rate_idx; |
| 872 | } |
| 873 | |
| 874 | static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb) |
| 875 | { |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 876 | struct wmi_mgmt_rx_event_v1 *ev_v1; |
| 877 | struct wmi_mgmt_rx_event_v2 *ev_v2; |
| 878 | struct wmi_mgmt_rx_hdr_v1 *ev_hdr; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 879 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); |
| 880 | struct ieee80211_hdr *hdr; |
| 881 | u32 rx_status; |
| 882 | u32 channel; |
| 883 | u32 phy_mode; |
| 884 | u32 snr; |
| 885 | u32 rate; |
| 886 | u32 buf_len; |
| 887 | u16 fc; |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 888 | int pull_len; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 889 | |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 890 | if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features)) { |
| 891 | ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data; |
| 892 | ev_hdr = &ev_v2->hdr.v1; |
| 893 | pull_len = sizeof(*ev_v2); |
| 894 | } else { |
| 895 | ev_v1 = (struct wmi_mgmt_rx_event_v1 *)skb->data; |
| 896 | ev_hdr = &ev_v1->hdr; |
| 897 | pull_len = sizeof(*ev_v1); |
| 898 | } |
| 899 | |
| 900 | channel = __le32_to_cpu(ev_hdr->channel); |
| 901 | buf_len = __le32_to_cpu(ev_hdr->buf_len); |
| 902 | rx_status = __le32_to_cpu(ev_hdr->status); |
| 903 | snr = __le32_to_cpu(ev_hdr->snr); |
| 904 | phy_mode = __le32_to_cpu(ev_hdr->phy_mode); |
| 905 | rate = __le32_to_cpu(ev_hdr->rate); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 906 | |
| 907 | memset(status, 0, sizeof(*status)); |
| 908 | |
| 909 | ath10k_dbg(ATH10K_DBG_MGMT, |
| 910 | "event mgmt rx status %08x\n", rx_status); |
| 911 | |
| 912 | if (rx_status & WMI_RX_STATUS_ERR_DECRYPT) { |
| 913 | dev_kfree_skb(skb); |
| 914 | return 0; |
| 915 | } |
| 916 | |
| 917 | if (rx_status & WMI_RX_STATUS_ERR_KEY_CACHE_MISS) { |
| 918 | dev_kfree_skb(skb); |
| 919 | return 0; |
| 920 | } |
| 921 | |
| 922 | if (rx_status & WMI_RX_STATUS_ERR_CRC) |
| 923 | status->flag |= RX_FLAG_FAILED_FCS_CRC; |
| 924 | if (rx_status & WMI_RX_STATUS_ERR_MIC) |
| 925 | status->flag |= RX_FLAG_MMIC_ERROR; |
| 926 | |
| 927 | status->band = phy_mode_to_band(phy_mode); |
| 928 | status->freq = ieee80211_channel_to_frequency(channel, status->band); |
| 929 | status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR; |
| 930 | status->rate_idx = get_rate_idx(rate, status->band); |
| 931 | |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 932 | skb_pull(skb, pull_len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 933 | |
| 934 | hdr = (struct ieee80211_hdr *)skb->data; |
| 935 | fc = le16_to_cpu(hdr->frame_control); |
| 936 | |
| 937 | if (fc & IEEE80211_FCTL_PROTECTED) { |
| 938 | status->flag |= RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED | |
| 939 | RX_FLAG_MMIC_STRIPPED; |
| 940 | hdr->frame_control = __cpu_to_le16(fc & |
| 941 | ~IEEE80211_FCTL_PROTECTED); |
| 942 | } |
| 943 | |
| 944 | ath10k_dbg(ATH10K_DBG_MGMT, |
| 945 | "event mgmt rx skb %p len %d ftype %02x stype %02x\n", |
| 946 | skb, skb->len, |
| 947 | fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE); |
| 948 | |
| 949 | ath10k_dbg(ATH10K_DBG_MGMT, |
| 950 | "event mgmt rx freq %d band %d snr %d, rate_idx %d\n", |
| 951 | status->freq, status->band, status->signal, |
| 952 | status->rate_idx); |
| 953 | |
| 954 | /* |
| 955 | * packets from HTC come aligned to 4byte boundaries |
| 956 | * because they can originally come in along with a trailer |
| 957 | */ |
| 958 | skb_trim(skb, buf_len); |
| 959 | |
| 960 | ieee80211_rx(ar->hw, skb); |
| 961 | return 0; |
| 962 | } |
| 963 | |
Michal Kazior | 2e1dea4 | 2013-07-31 10:32:40 +0200 | [diff] [blame] | 964 | static int freq_to_idx(struct ath10k *ar, int freq) |
| 965 | { |
| 966 | struct ieee80211_supported_band *sband; |
| 967 | int band, ch, idx = 0; |
| 968 | |
| 969 | for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { |
| 970 | sband = ar->hw->wiphy->bands[band]; |
| 971 | if (!sband) |
| 972 | continue; |
| 973 | |
| 974 | for (ch = 0; ch < sband->n_channels; ch++, idx++) |
| 975 | if (sband->channels[ch].center_freq == freq) |
| 976 | goto exit; |
| 977 | } |
| 978 | |
| 979 | exit: |
| 980 | return idx; |
| 981 | } |
| 982 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 983 | static void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb) |
| 984 | { |
Michal Kazior | 2e1dea4 | 2013-07-31 10:32:40 +0200 | [diff] [blame] | 985 | struct wmi_chan_info_event *ev; |
| 986 | struct survey_info *survey; |
| 987 | u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count; |
| 988 | int idx; |
| 989 | |
| 990 | ev = (struct wmi_chan_info_event *)skb->data; |
| 991 | |
| 992 | err_code = __le32_to_cpu(ev->err_code); |
| 993 | freq = __le32_to_cpu(ev->freq); |
| 994 | cmd_flags = __le32_to_cpu(ev->cmd_flags); |
| 995 | noise_floor = __le32_to_cpu(ev->noise_floor); |
| 996 | rx_clear_count = __le32_to_cpu(ev->rx_clear_count); |
| 997 | cycle_count = __le32_to_cpu(ev->cycle_count); |
| 998 | |
| 999 | ath10k_dbg(ATH10K_DBG_WMI, |
| 1000 | "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n", |
| 1001 | err_code, freq, cmd_flags, noise_floor, rx_clear_count, |
| 1002 | cycle_count); |
| 1003 | |
| 1004 | spin_lock_bh(&ar->data_lock); |
| 1005 | |
| 1006 | if (!ar->scan.in_progress) { |
| 1007 | ath10k_warn("chan info event without a scan request?\n"); |
| 1008 | goto exit; |
| 1009 | } |
| 1010 | |
| 1011 | idx = freq_to_idx(ar, freq); |
| 1012 | if (idx >= ARRAY_SIZE(ar->survey)) { |
| 1013 | ath10k_warn("chan info: invalid frequency %d (idx %d out of bounds)\n", |
| 1014 | freq, idx); |
| 1015 | goto exit; |
| 1016 | } |
| 1017 | |
| 1018 | if (cmd_flags & WMI_CHAN_INFO_FLAG_COMPLETE) { |
| 1019 | /* During scanning chan info is reported twice for each |
| 1020 | * visited channel. The reported cycle count is global |
| 1021 | * and per-channel cycle count must be calculated */ |
| 1022 | |
| 1023 | cycle_count -= ar->survey_last_cycle_count; |
| 1024 | rx_clear_count -= ar->survey_last_rx_clear_count; |
| 1025 | |
| 1026 | survey = &ar->survey[idx]; |
| 1027 | survey->channel_time = WMI_CHAN_INFO_MSEC(cycle_count); |
| 1028 | survey->channel_time_rx = WMI_CHAN_INFO_MSEC(rx_clear_count); |
| 1029 | survey->noise = noise_floor; |
| 1030 | survey->filled = SURVEY_INFO_CHANNEL_TIME | |
| 1031 | SURVEY_INFO_CHANNEL_TIME_RX | |
| 1032 | SURVEY_INFO_NOISE_DBM; |
| 1033 | } |
| 1034 | |
| 1035 | ar->survey_last_rx_clear_count = rx_clear_count; |
| 1036 | ar->survey_last_cycle_count = cycle_count; |
| 1037 | |
| 1038 | exit: |
| 1039 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1040 | } |
| 1041 | |
| 1042 | static void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb) |
| 1043 | { |
| 1044 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n"); |
| 1045 | } |
| 1046 | |
| 1047 | static void ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb) |
| 1048 | { |
| 1049 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_DEBUG_MESG_EVENTID\n"); |
| 1050 | } |
| 1051 | |
| 1052 | static void ath10k_wmi_event_update_stats(struct ath10k *ar, |
| 1053 | struct sk_buff *skb) |
| 1054 | { |
| 1055 | struct wmi_stats_event *ev = (struct wmi_stats_event *)skb->data; |
| 1056 | |
| 1057 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n"); |
| 1058 | |
| 1059 | ath10k_debug_read_target_stats(ar, ev); |
| 1060 | } |
| 1061 | |
| 1062 | static void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar, |
| 1063 | struct sk_buff *skb) |
| 1064 | { |
| 1065 | struct wmi_vdev_start_response_event *ev; |
| 1066 | |
| 1067 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n"); |
| 1068 | |
| 1069 | ev = (struct wmi_vdev_start_response_event *)skb->data; |
| 1070 | |
| 1071 | if (WARN_ON(__le32_to_cpu(ev->status))) |
| 1072 | return; |
| 1073 | |
| 1074 | complete(&ar->vdev_setup_done); |
| 1075 | } |
| 1076 | |
| 1077 | static void ath10k_wmi_event_vdev_stopped(struct ath10k *ar, |
| 1078 | struct sk_buff *skb) |
| 1079 | { |
| 1080 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n"); |
| 1081 | complete(&ar->vdev_setup_done); |
| 1082 | } |
| 1083 | |
| 1084 | static void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar, |
| 1085 | struct sk_buff *skb) |
| 1086 | { |
| 1087 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_PEER_STA_KICKOUT_EVENTID\n"); |
| 1088 | } |
| 1089 | |
| 1090 | /* |
| 1091 | * FIXME |
| 1092 | * |
| 1093 | * We don't report to mac80211 sleep state of connected |
| 1094 | * stations. Due to this mac80211 can't fill in TIM IE |
| 1095 | * correctly. |
| 1096 | * |
| 1097 | * I know of no way of getting nullfunc frames that contain |
| 1098 | * sleep transition from connected stations - these do not |
| 1099 | * seem to be sent from the target to the host. There also |
| 1100 | * doesn't seem to be a dedicated event for that. So the |
| 1101 | * only way left to do this would be to read tim_bitmap |
| 1102 | * during SWBA. |
| 1103 | * |
| 1104 | * We could probably try using tim_bitmap from SWBA to tell |
| 1105 | * mac80211 which stations are asleep and which are not. The |
| 1106 | * problem here is calling mac80211 functions so many times |
| 1107 | * could take too long and make us miss the time to submit |
| 1108 | * the beacon to the target. |
| 1109 | * |
| 1110 | * So as a workaround we try to extend the TIM IE if there |
| 1111 | * is unicast buffered for stations with aid > 7 and fill it |
| 1112 | * in ourselves. |
| 1113 | */ |
| 1114 | static void ath10k_wmi_update_tim(struct ath10k *ar, |
| 1115 | struct ath10k_vif *arvif, |
| 1116 | struct sk_buff *bcn, |
| 1117 | struct wmi_bcn_info *bcn_info) |
| 1118 | { |
| 1119 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)bcn->data; |
| 1120 | struct ieee80211_tim_ie *tim; |
| 1121 | u8 *ies, *ie; |
| 1122 | u8 ie_len, pvm_len; |
| 1123 | |
| 1124 | /* if next SWBA has no tim_changed the tim_bitmap is garbage. |
| 1125 | * we must copy the bitmap upon change and reuse it later */ |
| 1126 | if (__le32_to_cpu(bcn_info->tim_info.tim_changed)) { |
| 1127 | int i; |
| 1128 | |
| 1129 | BUILD_BUG_ON(sizeof(arvif->u.ap.tim_bitmap) != |
| 1130 | sizeof(bcn_info->tim_info.tim_bitmap)); |
| 1131 | |
| 1132 | for (i = 0; i < sizeof(arvif->u.ap.tim_bitmap); i++) { |
| 1133 | __le32 t = bcn_info->tim_info.tim_bitmap[i / 4]; |
| 1134 | u32 v = __le32_to_cpu(t); |
| 1135 | arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF; |
| 1136 | } |
| 1137 | |
| 1138 | /* FW reports either length 0 or 16 |
| 1139 | * so we calculate this on our own */ |
| 1140 | arvif->u.ap.tim_len = 0; |
| 1141 | for (i = 0; i < sizeof(arvif->u.ap.tim_bitmap); i++) |
| 1142 | if (arvif->u.ap.tim_bitmap[i]) |
| 1143 | arvif->u.ap.tim_len = i; |
| 1144 | |
| 1145 | arvif->u.ap.tim_len++; |
| 1146 | } |
| 1147 | |
| 1148 | ies = bcn->data; |
| 1149 | ies += ieee80211_hdrlen(hdr->frame_control); |
| 1150 | ies += 12; /* fixed parameters */ |
| 1151 | |
| 1152 | ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies, |
| 1153 | (u8 *)skb_tail_pointer(bcn) - ies); |
| 1154 | if (!ie) { |
Michal Kazior | 09af8f8 | 2013-07-05 16:15:08 +0300 | [diff] [blame] | 1155 | if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS) |
| 1156 | ath10k_warn("no tim ie found;\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1157 | return; |
| 1158 | } |
| 1159 | |
| 1160 | tim = (void *)ie + 2; |
| 1161 | ie_len = ie[1]; |
| 1162 | pvm_len = ie_len - 3; /* exclude dtim count, dtim period, bmap ctl */ |
| 1163 | |
| 1164 | if (pvm_len < arvif->u.ap.tim_len) { |
| 1165 | int expand_size = sizeof(arvif->u.ap.tim_bitmap) - pvm_len; |
| 1166 | int move_size = skb_tail_pointer(bcn) - (ie + 2 + ie_len); |
| 1167 | void *next_ie = ie + 2 + ie_len; |
| 1168 | |
| 1169 | if (skb_put(bcn, expand_size)) { |
| 1170 | memmove(next_ie + expand_size, next_ie, move_size); |
| 1171 | |
| 1172 | ie[1] += expand_size; |
| 1173 | ie_len += expand_size; |
| 1174 | pvm_len += expand_size; |
| 1175 | } else { |
| 1176 | ath10k_warn("tim expansion failed\n"); |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | if (pvm_len > sizeof(arvif->u.ap.tim_bitmap)) { |
| 1181 | ath10k_warn("tim pvm length is too great (%d)\n", pvm_len); |
| 1182 | return; |
| 1183 | } |
| 1184 | |
| 1185 | tim->bitmap_ctrl = !!__le32_to_cpu(bcn_info->tim_info.tim_mcast); |
| 1186 | memcpy(tim->virtual_map, arvif->u.ap.tim_bitmap, pvm_len); |
| 1187 | |
| 1188 | ath10k_dbg(ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n", |
| 1189 | tim->dtim_count, tim->dtim_period, |
| 1190 | tim->bitmap_ctrl, pvm_len); |
| 1191 | } |
| 1192 | |
| 1193 | static void ath10k_p2p_fill_noa_ie(u8 *data, u32 len, |
| 1194 | struct wmi_p2p_noa_info *noa) |
| 1195 | { |
| 1196 | struct ieee80211_p2p_noa_attr *noa_attr; |
| 1197 | u8 ctwindow_oppps = noa->ctwindow_oppps; |
| 1198 | u8 ctwindow = ctwindow_oppps >> WMI_P2P_OPPPS_CTWINDOW_OFFSET; |
| 1199 | bool oppps = !!(ctwindow_oppps & WMI_P2P_OPPPS_ENABLE_BIT); |
| 1200 | __le16 *noa_attr_len; |
| 1201 | u16 attr_len; |
| 1202 | u8 noa_descriptors = noa->num_descriptors; |
| 1203 | int i; |
| 1204 | |
| 1205 | /* P2P IE */ |
| 1206 | data[0] = WLAN_EID_VENDOR_SPECIFIC; |
| 1207 | data[1] = len - 2; |
| 1208 | data[2] = (WLAN_OUI_WFA >> 16) & 0xff; |
| 1209 | data[3] = (WLAN_OUI_WFA >> 8) & 0xff; |
| 1210 | data[4] = (WLAN_OUI_WFA >> 0) & 0xff; |
| 1211 | data[5] = WLAN_OUI_TYPE_WFA_P2P; |
| 1212 | |
| 1213 | /* NOA ATTR */ |
| 1214 | data[6] = IEEE80211_P2P_ATTR_ABSENCE_NOTICE; |
| 1215 | noa_attr_len = (__le16 *)&data[7]; /* 2 bytes */ |
| 1216 | noa_attr = (struct ieee80211_p2p_noa_attr *)&data[9]; |
| 1217 | |
| 1218 | noa_attr->index = noa->index; |
| 1219 | noa_attr->oppps_ctwindow = ctwindow; |
| 1220 | if (oppps) |
| 1221 | noa_attr->oppps_ctwindow |= IEEE80211_P2P_OPPPS_ENABLE_BIT; |
| 1222 | |
| 1223 | for (i = 0; i < noa_descriptors; i++) { |
| 1224 | noa_attr->desc[i].count = |
| 1225 | __le32_to_cpu(noa->descriptors[i].type_count); |
| 1226 | noa_attr->desc[i].duration = noa->descriptors[i].duration; |
| 1227 | noa_attr->desc[i].interval = noa->descriptors[i].interval; |
| 1228 | noa_attr->desc[i].start_time = noa->descriptors[i].start_time; |
| 1229 | } |
| 1230 | |
| 1231 | attr_len = 2; /* index + oppps_ctwindow */ |
| 1232 | attr_len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc); |
| 1233 | *noa_attr_len = __cpu_to_le16(attr_len); |
| 1234 | } |
| 1235 | |
| 1236 | static u32 ath10k_p2p_calc_noa_ie_len(struct wmi_p2p_noa_info *noa) |
| 1237 | { |
| 1238 | u32 len = 0; |
| 1239 | u8 noa_descriptors = noa->num_descriptors; |
| 1240 | u8 opp_ps_info = noa->ctwindow_oppps; |
| 1241 | bool opps_enabled = !!(opp_ps_info & WMI_P2P_OPPPS_ENABLE_BIT); |
| 1242 | |
| 1243 | |
| 1244 | if (!noa_descriptors && !opps_enabled) |
| 1245 | return len; |
| 1246 | |
| 1247 | len += 1 + 1 + 4; /* EID + len + OUI */ |
| 1248 | len += 1 + 2; /* noa attr + attr len */ |
| 1249 | len += 1 + 1; /* index + oppps_ctwindow */ |
| 1250 | len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc); |
| 1251 | |
| 1252 | return len; |
| 1253 | } |
| 1254 | |
| 1255 | static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif, |
| 1256 | struct sk_buff *bcn, |
| 1257 | struct wmi_bcn_info *bcn_info) |
| 1258 | { |
| 1259 | struct wmi_p2p_noa_info *noa = &bcn_info->p2p_noa_info; |
| 1260 | u8 *new_data, *old_data = arvif->u.ap.noa_data; |
| 1261 | u32 new_len; |
| 1262 | |
| 1263 | if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO) |
| 1264 | return; |
| 1265 | |
| 1266 | ath10k_dbg(ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed); |
| 1267 | if (noa->changed & WMI_P2P_NOA_CHANGED_BIT) { |
| 1268 | new_len = ath10k_p2p_calc_noa_ie_len(noa); |
| 1269 | if (!new_len) |
| 1270 | goto cleanup; |
| 1271 | |
| 1272 | new_data = kmalloc(new_len, GFP_ATOMIC); |
| 1273 | if (!new_data) |
| 1274 | goto cleanup; |
| 1275 | |
| 1276 | ath10k_p2p_fill_noa_ie(new_data, new_len, noa); |
| 1277 | |
| 1278 | spin_lock_bh(&ar->data_lock); |
| 1279 | arvif->u.ap.noa_data = new_data; |
| 1280 | arvif->u.ap.noa_len = new_len; |
| 1281 | spin_unlock_bh(&ar->data_lock); |
| 1282 | kfree(old_data); |
| 1283 | } |
| 1284 | |
| 1285 | if (arvif->u.ap.noa_data) |
| 1286 | if (!pskb_expand_head(bcn, 0, arvif->u.ap.noa_len, GFP_ATOMIC)) |
| 1287 | memcpy(skb_put(bcn, arvif->u.ap.noa_len), |
| 1288 | arvif->u.ap.noa_data, |
| 1289 | arvif->u.ap.noa_len); |
| 1290 | return; |
| 1291 | |
| 1292 | cleanup: |
| 1293 | spin_lock_bh(&ar->data_lock); |
| 1294 | arvif->u.ap.noa_data = NULL; |
| 1295 | arvif->u.ap.noa_len = 0; |
| 1296 | spin_unlock_bh(&ar->data_lock); |
| 1297 | kfree(old_data); |
| 1298 | } |
| 1299 | |
| 1300 | |
| 1301 | static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb) |
| 1302 | { |
| 1303 | struct wmi_host_swba_event *ev; |
| 1304 | u32 map; |
| 1305 | int i = -1; |
| 1306 | struct wmi_bcn_info *bcn_info; |
| 1307 | struct ath10k_vif *arvif; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1308 | struct sk_buff *bcn; |
| 1309 | int vdev_id = 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1310 | |
| 1311 | ath10k_dbg(ATH10K_DBG_MGMT, "WMI_HOST_SWBA_EVENTID\n"); |
| 1312 | |
| 1313 | ev = (struct wmi_host_swba_event *)skb->data; |
| 1314 | map = __le32_to_cpu(ev->vdev_map); |
| 1315 | |
| 1316 | ath10k_dbg(ATH10K_DBG_MGMT, "host swba:\n" |
| 1317 | "-vdev map 0x%x\n", |
| 1318 | ev->vdev_map); |
| 1319 | |
| 1320 | for (; map; map >>= 1, vdev_id++) { |
| 1321 | if (!(map & 0x1)) |
| 1322 | continue; |
| 1323 | |
| 1324 | i++; |
| 1325 | |
| 1326 | if (i >= WMI_MAX_AP_VDEV) { |
| 1327 | ath10k_warn("swba has corrupted vdev map\n"); |
| 1328 | break; |
| 1329 | } |
| 1330 | |
| 1331 | bcn_info = &ev->bcn_info[i]; |
| 1332 | |
| 1333 | ath10k_dbg(ATH10K_DBG_MGMT, |
| 1334 | "-bcn_info[%d]:\n" |
| 1335 | "--tim_len %d\n" |
| 1336 | "--tim_mcast %d\n" |
| 1337 | "--tim_changed %d\n" |
| 1338 | "--tim_num_ps_pending %d\n" |
| 1339 | "--tim_bitmap 0x%08x%08x%08x%08x\n", |
| 1340 | i, |
| 1341 | __le32_to_cpu(bcn_info->tim_info.tim_len), |
| 1342 | __le32_to_cpu(bcn_info->tim_info.tim_mcast), |
| 1343 | __le32_to_cpu(bcn_info->tim_info.tim_changed), |
| 1344 | __le32_to_cpu(bcn_info->tim_info.tim_num_ps_pending), |
| 1345 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[3]), |
| 1346 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[2]), |
| 1347 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[1]), |
| 1348 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[0])); |
| 1349 | |
| 1350 | arvif = ath10k_get_arvif(ar, vdev_id); |
| 1351 | if (arvif == NULL) { |
| 1352 | ath10k_warn("no vif for vdev_id %d found\n", vdev_id); |
| 1353 | continue; |
| 1354 | } |
| 1355 | |
| 1356 | bcn = ieee80211_beacon_get(ar->hw, arvif->vif); |
| 1357 | if (!bcn) { |
| 1358 | ath10k_warn("could not get mac80211 beacon\n"); |
| 1359 | continue; |
| 1360 | } |
| 1361 | |
| 1362 | ath10k_tx_h_seq_no(bcn); |
| 1363 | ath10k_wmi_update_tim(ar, arvif, bcn, bcn_info); |
| 1364 | ath10k_wmi_update_noa(ar, arvif, bcn, bcn_info); |
| 1365 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1366 | spin_lock_bh(&ar->data_lock); |
| 1367 | if (arvif->beacon) { |
| 1368 | ath10k_warn("SWBA overrun on vdev %d\n", |
| 1369 | arvif->vdev_id); |
| 1370 | dev_kfree_skb_any(arvif->beacon); |
| 1371 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1372 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1373 | arvif->beacon = bcn; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1374 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1375 | ath10k_wmi_tx_beacon_nowait(arvif); |
| 1376 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1377 | } |
| 1378 | } |
| 1379 | |
| 1380 | static void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, |
| 1381 | struct sk_buff *skb) |
| 1382 | { |
| 1383 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n"); |
| 1384 | } |
| 1385 | |
| 1386 | static void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb) |
| 1387 | { |
| 1388 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_PHYERR_EVENTID\n"); |
| 1389 | } |
| 1390 | |
| 1391 | static void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb) |
| 1392 | { |
| 1393 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_ROAM_EVENTID\n"); |
| 1394 | } |
| 1395 | |
| 1396 | static void ath10k_wmi_event_profile_match(struct ath10k *ar, |
| 1397 | struct sk_buff *skb) |
| 1398 | { |
| 1399 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n"); |
| 1400 | } |
| 1401 | |
| 1402 | static void ath10k_wmi_event_debug_print(struct ath10k *ar, |
| 1403 | struct sk_buff *skb) |
| 1404 | { |
| 1405 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_DEBUG_PRINT_EVENTID\n"); |
| 1406 | } |
| 1407 | |
| 1408 | static void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb) |
| 1409 | { |
| 1410 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n"); |
| 1411 | } |
| 1412 | |
| 1413 | static void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar, |
| 1414 | struct sk_buff *skb) |
| 1415 | { |
| 1416 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n"); |
| 1417 | } |
| 1418 | |
| 1419 | static void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar, |
| 1420 | struct sk_buff *skb) |
| 1421 | { |
| 1422 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n"); |
| 1423 | } |
| 1424 | |
| 1425 | static void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar, |
| 1426 | struct sk_buff *skb) |
| 1427 | { |
| 1428 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n"); |
| 1429 | } |
| 1430 | |
| 1431 | static void ath10k_wmi_event_rtt_error_report(struct ath10k *ar, |
| 1432 | struct sk_buff *skb) |
| 1433 | { |
| 1434 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n"); |
| 1435 | } |
| 1436 | |
| 1437 | static void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, |
| 1438 | struct sk_buff *skb) |
| 1439 | { |
| 1440 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_WOW_WAKEUP_HOST_EVENTID\n"); |
| 1441 | } |
| 1442 | |
| 1443 | static void ath10k_wmi_event_dcs_interference(struct ath10k *ar, |
| 1444 | struct sk_buff *skb) |
| 1445 | { |
| 1446 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n"); |
| 1447 | } |
| 1448 | |
| 1449 | static void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, |
| 1450 | struct sk_buff *skb) |
| 1451 | { |
| 1452 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_PDEV_TPC_CONFIG_EVENTID\n"); |
| 1453 | } |
| 1454 | |
| 1455 | static void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar, |
| 1456 | struct sk_buff *skb) |
| 1457 | { |
| 1458 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n"); |
| 1459 | } |
| 1460 | |
| 1461 | static void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar, |
| 1462 | struct sk_buff *skb) |
| 1463 | { |
| 1464 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n"); |
| 1465 | } |
| 1466 | |
| 1467 | static void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar, |
| 1468 | struct sk_buff *skb) |
| 1469 | { |
| 1470 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n"); |
| 1471 | } |
| 1472 | |
| 1473 | static void ath10k_wmi_event_delba_complete(struct ath10k *ar, |
| 1474 | struct sk_buff *skb) |
| 1475 | { |
| 1476 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n"); |
| 1477 | } |
| 1478 | |
| 1479 | static void ath10k_wmi_event_addba_complete(struct ath10k *ar, |
| 1480 | struct sk_buff *skb) |
| 1481 | { |
| 1482 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n"); |
| 1483 | } |
| 1484 | |
| 1485 | static void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar, |
| 1486 | struct sk_buff *skb) |
| 1487 | { |
| 1488 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n"); |
| 1489 | } |
| 1490 | |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 1491 | static void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar, |
| 1492 | struct sk_buff *skb) |
| 1493 | { |
| 1494 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n"); |
| 1495 | } |
| 1496 | |
| 1497 | static void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar, |
| 1498 | struct sk_buff *skb) |
| 1499 | { |
| 1500 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n"); |
| 1501 | } |
| 1502 | |
| 1503 | static void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar, |
| 1504 | struct sk_buff *skb) |
| 1505 | { |
| 1506 | ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n"); |
| 1507 | } |
| 1508 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 1509 | static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id, |
| 1510 | u32 num_units, u32 unit_len) |
| 1511 | { |
| 1512 | dma_addr_t paddr; |
| 1513 | u32 pool_size; |
| 1514 | int idx = ar->wmi.num_mem_chunks; |
| 1515 | |
| 1516 | pool_size = num_units * round_up(unit_len, 4); |
| 1517 | |
| 1518 | if (!pool_size) |
| 1519 | return -EINVAL; |
| 1520 | |
| 1521 | ar->wmi.mem_chunks[idx].vaddr = dma_alloc_coherent(ar->dev, |
| 1522 | pool_size, |
| 1523 | &paddr, |
| 1524 | GFP_ATOMIC); |
| 1525 | if (!ar->wmi.mem_chunks[idx].vaddr) { |
| 1526 | ath10k_warn("failed to allocate memory chunk\n"); |
| 1527 | return -ENOMEM; |
| 1528 | } |
| 1529 | |
| 1530 | memset(ar->wmi.mem_chunks[idx].vaddr, 0, pool_size); |
| 1531 | |
| 1532 | ar->wmi.mem_chunks[idx].paddr = paddr; |
| 1533 | ar->wmi.mem_chunks[idx].len = pool_size; |
| 1534 | ar->wmi.mem_chunks[idx].req_id = req_id; |
| 1535 | ar->wmi.num_mem_chunks++; |
| 1536 | |
| 1537 | return 0; |
| 1538 | } |
| 1539 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1540 | static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar, |
| 1541 | struct sk_buff *skb) |
| 1542 | { |
| 1543 | struct wmi_service_ready_event *ev = (void *)skb->data; |
| 1544 | |
| 1545 | if (skb->len < sizeof(*ev)) { |
| 1546 | ath10k_warn("Service ready event was %d B but expected %zu B. Wrong firmware version?\n", |
| 1547 | skb->len, sizeof(*ev)); |
| 1548 | return; |
| 1549 | } |
| 1550 | |
| 1551 | ar->hw_min_tx_power = __le32_to_cpu(ev->hw_min_tx_power); |
| 1552 | ar->hw_max_tx_power = __le32_to_cpu(ev->hw_max_tx_power); |
| 1553 | ar->ht_cap_info = __le32_to_cpu(ev->ht_cap_info); |
| 1554 | ar->vht_cap_info = __le32_to_cpu(ev->vht_cap_info); |
| 1555 | ar->fw_version_major = |
| 1556 | (__le32_to_cpu(ev->sw_version) & 0xff000000) >> 24; |
| 1557 | ar->fw_version_minor = (__le32_to_cpu(ev->sw_version) & 0x00ffffff); |
| 1558 | ar->fw_version_release = |
| 1559 | (__le32_to_cpu(ev->sw_version_1) & 0xffff0000) >> 16; |
| 1560 | ar->fw_version_build = (__le32_to_cpu(ev->sw_version_1) & 0x0000ffff); |
| 1561 | ar->phy_capability = __le32_to_cpu(ev->phy_capability); |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 1562 | ar->num_rf_chains = __le32_to_cpu(ev->num_rf_chains); |
| 1563 | |
Kalle Valo | 1a22243 | 2013-09-27 19:55:07 +0300 | [diff] [blame] | 1564 | /* only manually set fw features when not using FW IE format */ |
| 1565 | if (ar->fw_api == 1 && ar->fw_version_build > 636) |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 1566 | set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features); |
| 1567 | |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 1568 | if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) { |
| 1569 | ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n", |
| 1570 | ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM); |
| 1571 | ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM; |
| 1572 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1573 | |
| 1574 | ar->ath_common.regulatory.current_rd = |
| 1575 | __le32_to_cpu(ev->hal_reg_capabilities.eeprom_rd); |
| 1576 | |
| 1577 | ath10k_debug_read_service_map(ar, ev->wmi_service_bitmap, |
| 1578 | sizeof(ev->wmi_service_bitmap)); |
| 1579 | |
| 1580 | if (strlen(ar->hw->wiphy->fw_version) == 0) { |
| 1581 | snprintf(ar->hw->wiphy->fw_version, |
| 1582 | sizeof(ar->hw->wiphy->fw_version), |
| 1583 | "%u.%u.%u.%u", |
| 1584 | ar->fw_version_major, |
| 1585 | ar->fw_version_minor, |
| 1586 | ar->fw_version_release, |
| 1587 | ar->fw_version_build); |
| 1588 | } |
| 1589 | |
| 1590 | /* FIXME: it probably should be better to support this */ |
| 1591 | if (__le32_to_cpu(ev->num_mem_reqs) > 0) { |
| 1592 | ath10k_warn("target requested %d memory chunks; ignoring\n", |
| 1593 | __le32_to_cpu(ev->num_mem_reqs)); |
| 1594 | } |
| 1595 | |
| 1596 | ath10k_dbg(ATH10K_DBG_WMI, |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 1597 | "wmi event service ready sw_ver 0x%08x sw_ver1 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1598 | __le32_to_cpu(ev->sw_version), |
| 1599 | __le32_to_cpu(ev->sw_version_1), |
| 1600 | __le32_to_cpu(ev->abi_version), |
| 1601 | __le32_to_cpu(ev->phy_capability), |
| 1602 | __le32_to_cpu(ev->ht_cap_info), |
| 1603 | __le32_to_cpu(ev->vht_cap_info), |
| 1604 | __le32_to_cpu(ev->vht_supp_mcs), |
| 1605 | __le32_to_cpu(ev->sys_cap_info), |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 1606 | __le32_to_cpu(ev->num_mem_reqs), |
| 1607 | __le32_to_cpu(ev->num_rf_chains)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1608 | |
| 1609 | complete(&ar->wmi.service_ready); |
| 1610 | } |
| 1611 | |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 1612 | static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar, |
| 1613 | struct sk_buff *skb) |
| 1614 | { |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 1615 | u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i; |
| 1616 | int ret; |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 1617 | struct wmi_service_ready_event_10x *ev = (void *)skb->data; |
| 1618 | |
| 1619 | if (skb->len < sizeof(*ev)) { |
| 1620 | ath10k_warn("Service ready event was %d B but expected %zu B. Wrong firmware version?\n", |
| 1621 | skb->len, sizeof(*ev)); |
| 1622 | return; |
| 1623 | } |
| 1624 | |
| 1625 | ar->hw_min_tx_power = __le32_to_cpu(ev->hw_min_tx_power); |
| 1626 | ar->hw_max_tx_power = __le32_to_cpu(ev->hw_max_tx_power); |
| 1627 | ar->ht_cap_info = __le32_to_cpu(ev->ht_cap_info); |
| 1628 | ar->vht_cap_info = __le32_to_cpu(ev->vht_cap_info); |
| 1629 | ar->fw_version_major = |
| 1630 | (__le32_to_cpu(ev->sw_version) & 0xff000000) >> 24; |
| 1631 | ar->fw_version_minor = (__le32_to_cpu(ev->sw_version) & 0x00ffffff); |
| 1632 | ar->phy_capability = __le32_to_cpu(ev->phy_capability); |
| 1633 | ar->num_rf_chains = __le32_to_cpu(ev->num_rf_chains); |
| 1634 | |
| 1635 | if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) { |
| 1636 | ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n", |
| 1637 | ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM); |
| 1638 | ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM; |
| 1639 | } |
| 1640 | |
| 1641 | ar->ath_common.regulatory.current_rd = |
| 1642 | __le32_to_cpu(ev->hal_reg_capabilities.eeprom_rd); |
| 1643 | |
| 1644 | ath10k_debug_read_service_map(ar, ev->wmi_service_bitmap, |
| 1645 | sizeof(ev->wmi_service_bitmap)); |
| 1646 | |
| 1647 | if (strlen(ar->hw->wiphy->fw_version) == 0) { |
| 1648 | snprintf(ar->hw->wiphy->fw_version, |
| 1649 | sizeof(ar->hw->wiphy->fw_version), |
| 1650 | "%u.%u", |
| 1651 | ar->fw_version_major, |
| 1652 | ar->fw_version_minor); |
| 1653 | } |
| 1654 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 1655 | num_mem_reqs = __le32_to_cpu(ev->num_mem_reqs); |
| 1656 | |
| 1657 | if (num_mem_reqs > ATH10K_MAX_MEM_REQS) { |
| 1658 | ath10k_warn("requested memory chunks number (%d) exceeds the limit\n", |
| 1659 | num_mem_reqs); |
| 1660 | return; |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 1661 | } |
| 1662 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 1663 | if (!num_mem_reqs) |
| 1664 | goto exit; |
| 1665 | |
| 1666 | ath10k_dbg(ATH10K_DBG_WMI, "firmware has requested %d memory chunks\n", |
| 1667 | num_mem_reqs); |
| 1668 | |
| 1669 | for (i = 0; i < num_mem_reqs; ++i) { |
| 1670 | req_id = __le32_to_cpu(ev->mem_reqs[i].req_id); |
| 1671 | num_units = __le32_to_cpu(ev->mem_reqs[i].num_units); |
| 1672 | unit_size = __le32_to_cpu(ev->mem_reqs[i].unit_size); |
| 1673 | num_unit_info = __le32_to_cpu(ev->mem_reqs[i].num_unit_info); |
| 1674 | |
| 1675 | if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) |
| 1676 | /* number of units to allocate is number of |
| 1677 | * peers, 1 extra for self peer on target */ |
| 1678 | /* this needs to be tied, host and target |
| 1679 | * can get out of sync */ |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 1680 | num_units = TARGET_10X_NUM_PEERS + 1; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 1681 | else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 1682 | num_units = TARGET_10X_NUM_VDEVS + 1; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 1683 | |
| 1684 | ath10k_dbg(ATH10K_DBG_WMI, |
| 1685 | "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n", |
| 1686 | req_id, |
| 1687 | __le32_to_cpu(ev->mem_reqs[i].num_units), |
| 1688 | num_unit_info, |
| 1689 | unit_size, |
| 1690 | num_units); |
| 1691 | |
| 1692 | ret = ath10k_wmi_alloc_host_mem(ar, req_id, num_units, |
| 1693 | unit_size); |
| 1694 | if (ret) |
| 1695 | return; |
| 1696 | } |
| 1697 | |
| 1698 | exit: |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 1699 | ath10k_dbg(ATH10K_DBG_WMI, |
| 1700 | "wmi event service ready sw_ver 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n", |
| 1701 | __le32_to_cpu(ev->sw_version), |
| 1702 | __le32_to_cpu(ev->abi_version), |
| 1703 | __le32_to_cpu(ev->phy_capability), |
| 1704 | __le32_to_cpu(ev->ht_cap_info), |
| 1705 | __le32_to_cpu(ev->vht_cap_info), |
| 1706 | __le32_to_cpu(ev->vht_supp_mcs), |
| 1707 | __le32_to_cpu(ev->sys_cap_info), |
| 1708 | __le32_to_cpu(ev->num_mem_reqs), |
| 1709 | __le32_to_cpu(ev->num_rf_chains)); |
| 1710 | |
| 1711 | complete(&ar->wmi.service_ready); |
| 1712 | } |
| 1713 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1714 | static int ath10k_wmi_ready_event_rx(struct ath10k *ar, struct sk_buff *skb) |
| 1715 | { |
| 1716 | struct wmi_ready_event *ev = (struct wmi_ready_event *)skb->data; |
| 1717 | |
| 1718 | if (WARN_ON(skb->len < sizeof(*ev))) |
| 1719 | return -EINVAL; |
| 1720 | |
| 1721 | memcpy(ar->mac_addr, ev->mac_addr.addr, ETH_ALEN); |
| 1722 | |
| 1723 | ath10k_dbg(ATH10K_DBG_WMI, |
| 1724 | "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d\n", |
| 1725 | __le32_to_cpu(ev->sw_version), |
| 1726 | __le32_to_cpu(ev->abi_version), |
| 1727 | ev->mac_addr.addr, |
| 1728 | __le32_to_cpu(ev->status)); |
| 1729 | |
| 1730 | complete(&ar->wmi.unified_ready); |
| 1731 | return 0; |
| 1732 | } |
| 1733 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 1734 | static void ath10k_wmi_main_process_rx(struct ath10k *ar, struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1735 | { |
| 1736 | struct wmi_cmd_hdr *cmd_hdr; |
| 1737 | enum wmi_event_id id; |
| 1738 | u16 len; |
| 1739 | |
| 1740 | cmd_hdr = (struct wmi_cmd_hdr *)skb->data; |
| 1741 | id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID); |
| 1742 | |
| 1743 | if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL) |
| 1744 | return; |
| 1745 | |
| 1746 | len = skb->len; |
| 1747 | |
| 1748 | trace_ath10k_wmi_event(id, skb->data, skb->len); |
| 1749 | |
| 1750 | switch (id) { |
| 1751 | case WMI_MGMT_RX_EVENTID: |
| 1752 | ath10k_wmi_event_mgmt_rx(ar, skb); |
| 1753 | /* mgmt_rx() owns the skb now! */ |
| 1754 | return; |
| 1755 | case WMI_SCAN_EVENTID: |
| 1756 | ath10k_wmi_event_scan(ar, skb); |
| 1757 | break; |
| 1758 | case WMI_CHAN_INFO_EVENTID: |
| 1759 | ath10k_wmi_event_chan_info(ar, skb); |
| 1760 | break; |
| 1761 | case WMI_ECHO_EVENTID: |
| 1762 | ath10k_wmi_event_echo(ar, skb); |
| 1763 | break; |
| 1764 | case WMI_DEBUG_MESG_EVENTID: |
| 1765 | ath10k_wmi_event_debug_mesg(ar, skb); |
| 1766 | break; |
| 1767 | case WMI_UPDATE_STATS_EVENTID: |
| 1768 | ath10k_wmi_event_update_stats(ar, skb); |
| 1769 | break; |
| 1770 | case WMI_VDEV_START_RESP_EVENTID: |
| 1771 | ath10k_wmi_event_vdev_start_resp(ar, skb); |
| 1772 | break; |
| 1773 | case WMI_VDEV_STOPPED_EVENTID: |
| 1774 | ath10k_wmi_event_vdev_stopped(ar, skb); |
| 1775 | break; |
| 1776 | case WMI_PEER_STA_KICKOUT_EVENTID: |
| 1777 | ath10k_wmi_event_peer_sta_kickout(ar, skb); |
| 1778 | break; |
| 1779 | case WMI_HOST_SWBA_EVENTID: |
| 1780 | ath10k_wmi_event_host_swba(ar, skb); |
| 1781 | break; |
| 1782 | case WMI_TBTTOFFSET_UPDATE_EVENTID: |
| 1783 | ath10k_wmi_event_tbttoffset_update(ar, skb); |
| 1784 | break; |
| 1785 | case WMI_PHYERR_EVENTID: |
| 1786 | ath10k_wmi_event_phyerr(ar, skb); |
| 1787 | break; |
| 1788 | case WMI_ROAM_EVENTID: |
| 1789 | ath10k_wmi_event_roam(ar, skb); |
| 1790 | break; |
| 1791 | case WMI_PROFILE_MATCH: |
| 1792 | ath10k_wmi_event_profile_match(ar, skb); |
| 1793 | break; |
| 1794 | case WMI_DEBUG_PRINT_EVENTID: |
| 1795 | ath10k_wmi_event_debug_print(ar, skb); |
| 1796 | break; |
| 1797 | case WMI_PDEV_QVIT_EVENTID: |
| 1798 | ath10k_wmi_event_pdev_qvit(ar, skb); |
| 1799 | break; |
| 1800 | case WMI_WLAN_PROFILE_DATA_EVENTID: |
| 1801 | ath10k_wmi_event_wlan_profile_data(ar, skb); |
| 1802 | break; |
| 1803 | case WMI_RTT_MEASUREMENT_REPORT_EVENTID: |
| 1804 | ath10k_wmi_event_rtt_measurement_report(ar, skb); |
| 1805 | break; |
| 1806 | case WMI_TSF_MEASUREMENT_REPORT_EVENTID: |
| 1807 | ath10k_wmi_event_tsf_measurement_report(ar, skb); |
| 1808 | break; |
| 1809 | case WMI_RTT_ERROR_REPORT_EVENTID: |
| 1810 | ath10k_wmi_event_rtt_error_report(ar, skb); |
| 1811 | break; |
| 1812 | case WMI_WOW_WAKEUP_HOST_EVENTID: |
| 1813 | ath10k_wmi_event_wow_wakeup_host(ar, skb); |
| 1814 | break; |
| 1815 | case WMI_DCS_INTERFERENCE_EVENTID: |
| 1816 | ath10k_wmi_event_dcs_interference(ar, skb); |
| 1817 | break; |
| 1818 | case WMI_PDEV_TPC_CONFIG_EVENTID: |
| 1819 | ath10k_wmi_event_pdev_tpc_config(ar, skb); |
| 1820 | break; |
| 1821 | case WMI_PDEV_FTM_INTG_EVENTID: |
| 1822 | ath10k_wmi_event_pdev_ftm_intg(ar, skb); |
| 1823 | break; |
| 1824 | case WMI_GTK_OFFLOAD_STATUS_EVENTID: |
| 1825 | ath10k_wmi_event_gtk_offload_status(ar, skb); |
| 1826 | break; |
| 1827 | case WMI_GTK_REKEY_FAIL_EVENTID: |
| 1828 | ath10k_wmi_event_gtk_rekey_fail(ar, skb); |
| 1829 | break; |
| 1830 | case WMI_TX_DELBA_COMPLETE_EVENTID: |
| 1831 | ath10k_wmi_event_delba_complete(ar, skb); |
| 1832 | break; |
| 1833 | case WMI_TX_ADDBA_COMPLETE_EVENTID: |
| 1834 | ath10k_wmi_event_addba_complete(ar, skb); |
| 1835 | break; |
| 1836 | case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID: |
| 1837 | ath10k_wmi_event_vdev_install_key_complete(ar, skb); |
| 1838 | break; |
| 1839 | case WMI_SERVICE_READY_EVENTID: |
| 1840 | ath10k_wmi_service_ready_event_rx(ar, skb); |
| 1841 | break; |
| 1842 | case WMI_READY_EVENTID: |
| 1843 | ath10k_wmi_ready_event_rx(ar, skb); |
| 1844 | break; |
| 1845 | default: |
| 1846 | ath10k_warn("Unknown eventid: %d\n", id); |
| 1847 | break; |
| 1848 | } |
| 1849 | |
| 1850 | dev_kfree_skb(skb); |
| 1851 | } |
| 1852 | |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 1853 | static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb) |
| 1854 | { |
| 1855 | struct wmi_cmd_hdr *cmd_hdr; |
| 1856 | enum wmi_10x_event_id id; |
| 1857 | u16 len; |
| 1858 | |
| 1859 | cmd_hdr = (struct wmi_cmd_hdr *)skb->data; |
| 1860 | id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID); |
| 1861 | |
| 1862 | if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL) |
| 1863 | return; |
| 1864 | |
| 1865 | len = skb->len; |
| 1866 | |
| 1867 | trace_ath10k_wmi_event(id, skb->data, skb->len); |
| 1868 | |
| 1869 | switch (id) { |
| 1870 | case WMI_10X_MGMT_RX_EVENTID: |
| 1871 | ath10k_wmi_event_mgmt_rx(ar, skb); |
| 1872 | /* mgmt_rx() owns the skb now! */ |
| 1873 | return; |
| 1874 | case WMI_10X_SCAN_EVENTID: |
| 1875 | ath10k_wmi_event_scan(ar, skb); |
| 1876 | break; |
| 1877 | case WMI_10X_CHAN_INFO_EVENTID: |
| 1878 | ath10k_wmi_event_chan_info(ar, skb); |
| 1879 | break; |
| 1880 | case WMI_10X_ECHO_EVENTID: |
| 1881 | ath10k_wmi_event_echo(ar, skb); |
| 1882 | break; |
| 1883 | case WMI_10X_DEBUG_MESG_EVENTID: |
| 1884 | ath10k_wmi_event_debug_mesg(ar, skb); |
| 1885 | break; |
| 1886 | case WMI_10X_UPDATE_STATS_EVENTID: |
| 1887 | ath10k_wmi_event_update_stats(ar, skb); |
| 1888 | break; |
| 1889 | case WMI_10X_VDEV_START_RESP_EVENTID: |
| 1890 | ath10k_wmi_event_vdev_start_resp(ar, skb); |
| 1891 | break; |
| 1892 | case WMI_10X_VDEV_STOPPED_EVENTID: |
| 1893 | ath10k_wmi_event_vdev_stopped(ar, skb); |
| 1894 | break; |
| 1895 | case WMI_10X_PEER_STA_KICKOUT_EVENTID: |
| 1896 | ath10k_wmi_event_peer_sta_kickout(ar, skb); |
| 1897 | break; |
| 1898 | case WMI_10X_HOST_SWBA_EVENTID: |
| 1899 | ath10k_wmi_event_host_swba(ar, skb); |
| 1900 | break; |
| 1901 | case WMI_10X_TBTTOFFSET_UPDATE_EVENTID: |
| 1902 | ath10k_wmi_event_tbttoffset_update(ar, skb); |
| 1903 | break; |
| 1904 | case WMI_10X_PHYERR_EVENTID: |
| 1905 | ath10k_wmi_event_phyerr(ar, skb); |
| 1906 | break; |
| 1907 | case WMI_10X_ROAM_EVENTID: |
| 1908 | ath10k_wmi_event_roam(ar, skb); |
| 1909 | break; |
| 1910 | case WMI_10X_PROFILE_MATCH: |
| 1911 | ath10k_wmi_event_profile_match(ar, skb); |
| 1912 | break; |
| 1913 | case WMI_10X_DEBUG_PRINT_EVENTID: |
| 1914 | ath10k_wmi_event_debug_print(ar, skb); |
| 1915 | break; |
| 1916 | case WMI_10X_PDEV_QVIT_EVENTID: |
| 1917 | ath10k_wmi_event_pdev_qvit(ar, skb); |
| 1918 | break; |
| 1919 | case WMI_10X_WLAN_PROFILE_DATA_EVENTID: |
| 1920 | ath10k_wmi_event_wlan_profile_data(ar, skb); |
| 1921 | break; |
| 1922 | case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID: |
| 1923 | ath10k_wmi_event_rtt_measurement_report(ar, skb); |
| 1924 | break; |
| 1925 | case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID: |
| 1926 | ath10k_wmi_event_tsf_measurement_report(ar, skb); |
| 1927 | break; |
| 1928 | case WMI_10X_RTT_ERROR_REPORT_EVENTID: |
| 1929 | ath10k_wmi_event_rtt_error_report(ar, skb); |
| 1930 | break; |
| 1931 | case WMI_10X_WOW_WAKEUP_HOST_EVENTID: |
| 1932 | ath10k_wmi_event_wow_wakeup_host(ar, skb); |
| 1933 | break; |
| 1934 | case WMI_10X_DCS_INTERFERENCE_EVENTID: |
| 1935 | ath10k_wmi_event_dcs_interference(ar, skb); |
| 1936 | break; |
| 1937 | case WMI_10X_PDEV_TPC_CONFIG_EVENTID: |
| 1938 | ath10k_wmi_event_pdev_tpc_config(ar, skb); |
| 1939 | break; |
| 1940 | case WMI_10X_INST_RSSI_STATS_EVENTID: |
| 1941 | ath10k_wmi_event_inst_rssi_stats(ar, skb); |
| 1942 | break; |
| 1943 | case WMI_10X_VDEV_STANDBY_REQ_EVENTID: |
| 1944 | ath10k_wmi_event_vdev_standby_req(ar, skb); |
| 1945 | break; |
| 1946 | case WMI_10X_VDEV_RESUME_REQ_EVENTID: |
| 1947 | ath10k_wmi_event_vdev_resume_req(ar, skb); |
| 1948 | break; |
| 1949 | case WMI_10X_SERVICE_READY_EVENTID: |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 1950 | ath10k_wmi_10x_service_ready_event_rx(ar, skb); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 1951 | break; |
| 1952 | case WMI_10X_READY_EVENTID: |
| 1953 | ath10k_wmi_ready_event_rx(ar, skb); |
| 1954 | break; |
| 1955 | default: |
| 1956 | ath10k_warn("Unknown eventid: %d\n", id); |
| 1957 | break; |
| 1958 | } |
| 1959 | |
| 1960 | dev_kfree_skb(skb); |
| 1961 | } |
| 1962 | |
| 1963 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 1964 | static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb) |
| 1965 | { |
| 1966 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 1967 | ath10k_wmi_10x_process_rx(ar, skb); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 1968 | else |
| 1969 | ath10k_wmi_main_process_rx(ar, skb); |
| 1970 | } |
| 1971 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1972 | /* WMI Initialization functions */ |
| 1973 | int ath10k_wmi_attach(struct ath10k *ar) |
| 1974 | { |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 1975 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 1976 | ar->wmi.cmd = &wmi_10x_cmd_map; |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 1977 | ar->wmi.vdev_param = &wmi_10x_vdev_param_map; |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 1978 | ar->wmi.pdev_param = &wmi_10x_pdev_param_map; |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 1979 | } else { |
| 1980 | ar->wmi.cmd = &wmi_cmd_map; |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 1981 | ar->wmi.vdev_param = &wmi_vdev_param_map; |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 1982 | ar->wmi.pdev_param = &wmi_pdev_param_map; |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 1983 | } |
| 1984 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1985 | init_completion(&ar->wmi.service_ready); |
| 1986 | init_completion(&ar->wmi.unified_ready); |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 1987 | init_waitqueue_head(&ar->wmi.tx_credits_wq); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1988 | |
Bartosz Markowski | 8acd3c9 | 2013-10-02 08:48:51 +0200 | [diff] [blame] | 1989 | return 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1990 | } |
| 1991 | |
| 1992 | void ath10k_wmi_detach(struct ath10k *ar) |
| 1993 | { |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 1994 | int i; |
| 1995 | |
| 1996 | /* free the host memory chunks requested by firmware */ |
| 1997 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { |
| 1998 | dma_free_coherent(ar->dev, |
| 1999 | ar->wmi.mem_chunks[i].len, |
| 2000 | ar->wmi.mem_chunks[i].vaddr, |
| 2001 | ar->wmi.mem_chunks[i].paddr); |
| 2002 | } |
| 2003 | |
| 2004 | ar->wmi.num_mem_chunks = 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2005 | } |
| 2006 | |
| 2007 | int ath10k_wmi_connect_htc_service(struct ath10k *ar) |
| 2008 | { |
| 2009 | int status; |
| 2010 | struct ath10k_htc_svc_conn_req conn_req; |
| 2011 | struct ath10k_htc_svc_conn_resp conn_resp; |
| 2012 | |
| 2013 | memset(&conn_req, 0, sizeof(conn_req)); |
| 2014 | memset(&conn_resp, 0, sizeof(conn_resp)); |
| 2015 | |
| 2016 | /* these fields are the same for all service endpoints */ |
| 2017 | conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete; |
| 2018 | conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx; |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 2019 | conn_req.ep_ops.ep_tx_credits = ath10k_wmi_op_ep_tx_credits; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2020 | |
| 2021 | /* connect to control service */ |
| 2022 | conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL; |
| 2023 | |
Michal Kazior | cd003fa | 2013-07-05 16:15:13 +0300 | [diff] [blame] | 2024 | status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2025 | if (status) { |
| 2026 | ath10k_warn("failed to connect to WMI CONTROL service status: %d\n", |
| 2027 | status); |
| 2028 | return status; |
| 2029 | } |
| 2030 | |
| 2031 | ar->wmi.eid = conn_resp.eid; |
| 2032 | return 0; |
| 2033 | } |
| 2034 | |
| 2035 | int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g, |
| 2036 | u16 rd5g, u16 ctl2g, u16 ctl5g) |
| 2037 | { |
| 2038 | struct wmi_pdev_set_regdomain_cmd *cmd; |
| 2039 | struct sk_buff *skb; |
| 2040 | |
| 2041 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2042 | if (!skb) |
| 2043 | return -ENOMEM; |
| 2044 | |
| 2045 | cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data; |
| 2046 | cmd->reg_domain = __cpu_to_le32(rd); |
| 2047 | cmd->reg_domain_2G = __cpu_to_le32(rd2g); |
| 2048 | cmd->reg_domain_5G = __cpu_to_le32(rd5g); |
| 2049 | cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g); |
| 2050 | cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g); |
| 2051 | |
| 2052 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2053 | "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n", |
| 2054 | rd, rd2g, rd5g, ctl2g, ctl5g); |
| 2055 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2056 | return ath10k_wmi_cmd_send(ar, skb, |
| 2057 | ar->wmi.cmd->pdev_set_regdomain_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2058 | } |
| 2059 | |
| 2060 | int ath10k_wmi_pdev_set_channel(struct ath10k *ar, |
| 2061 | const struct wmi_channel_arg *arg) |
| 2062 | { |
| 2063 | struct wmi_set_channel_cmd *cmd; |
| 2064 | struct sk_buff *skb; |
| 2065 | |
| 2066 | if (arg->passive) |
| 2067 | return -EINVAL; |
| 2068 | |
| 2069 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2070 | if (!skb) |
| 2071 | return -ENOMEM; |
| 2072 | |
| 2073 | cmd = (struct wmi_set_channel_cmd *)skb->data; |
| 2074 | cmd->chan.mhz = __cpu_to_le32(arg->freq); |
| 2075 | cmd->chan.band_center_freq1 = __cpu_to_le32(arg->freq); |
| 2076 | cmd->chan.mode = arg->mode; |
| 2077 | cmd->chan.min_power = arg->min_power; |
| 2078 | cmd->chan.max_power = arg->max_power; |
| 2079 | cmd->chan.reg_power = arg->max_reg_power; |
| 2080 | cmd->chan.reg_classid = arg->reg_class_id; |
| 2081 | cmd->chan.antenna_max = arg->max_antenna_gain; |
| 2082 | |
| 2083 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2084 | "wmi set channel mode %d freq %d\n", |
| 2085 | arg->mode, arg->freq); |
| 2086 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2087 | return ath10k_wmi_cmd_send(ar, skb, |
| 2088 | ar->wmi.cmd->pdev_set_channel_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2089 | } |
| 2090 | |
| 2091 | int ath10k_wmi_pdev_suspend_target(struct ath10k *ar) |
| 2092 | { |
| 2093 | struct wmi_pdev_suspend_cmd *cmd; |
| 2094 | struct sk_buff *skb; |
| 2095 | |
| 2096 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2097 | if (!skb) |
| 2098 | return -ENOMEM; |
| 2099 | |
| 2100 | cmd = (struct wmi_pdev_suspend_cmd *)skb->data; |
| 2101 | cmd->suspend_opt = WMI_PDEV_SUSPEND; |
| 2102 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2103 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_suspend_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2104 | } |
| 2105 | |
| 2106 | int ath10k_wmi_pdev_resume_target(struct ath10k *ar) |
| 2107 | { |
| 2108 | struct sk_buff *skb; |
| 2109 | |
| 2110 | skb = ath10k_wmi_alloc_skb(0); |
| 2111 | if (skb == NULL) |
| 2112 | return -ENOMEM; |
| 2113 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2114 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_resume_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2115 | } |
| 2116 | |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 2117 | int ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2118 | { |
| 2119 | struct wmi_pdev_set_param_cmd *cmd; |
| 2120 | struct sk_buff *skb; |
| 2121 | |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 2122 | if (id == WMI_PDEV_PARAM_UNSUPPORTED) { |
| 2123 | ath10k_warn("pdev param %d not supported by firmware\n", id); |
Bartosz Markowski | d544943 | 2013-10-15 09:55:32 +0200 | [diff] [blame] | 2124 | return -EOPNOTSUPP; |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 2125 | } |
| 2126 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2127 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2128 | if (!skb) |
| 2129 | return -ENOMEM; |
| 2130 | |
| 2131 | cmd = (struct wmi_pdev_set_param_cmd *)skb->data; |
| 2132 | cmd->param_id = __cpu_to_le32(id); |
| 2133 | cmd->param_value = __cpu_to_le32(value); |
| 2134 | |
| 2135 | ath10k_dbg(ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n", |
| 2136 | id, value); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2137 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_set_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2138 | } |
| 2139 | |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2140 | static int ath10k_wmi_main_cmd_init(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2141 | { |
| 2142 | struct wmi_init_cmd *cmd; |
| 2143 | struct sk_buff *buf; |
| 2144 | struct wmi_resource_config config = {}; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2145 | u32 len, val; |
| 2146 | int i; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2147 | |
| 2148 | config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS); |
| 2149 | config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS + TARGET_NUM_VDEVS); |
| 2150 | config.num_offload_peers = __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS); |
| 2151 | |
| 2152 | config.num_offload_reorder_bufs = |
| 2153 | __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS); |
| 2154 | |
| 2155 | config.num_peer_keys = __cpu_to_le32(TARGET_NUM_PEER_KEYS); |
| 2156 | config.num_tids = __cpu_to_le32(TARGET_NUM_TIDS); |
| 2157 | config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT); |
| 2158 | config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK); |
| 2159 | config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK); |
| 2160 | config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI); |
| 2161 | config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI); |
| 2162 | config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI); |
| 2163 | config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI); |
| 2164 | config.rx_decap_mode = __cpu_to_le32(TARGET_RX_DECAP_MODE); |
| 2165 | |
| 2166 | config.scan_max_pending_reqs = |
| 2167 | __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS); |
| 2168 | |
| 2169 | config.bmiss_offload_max_vdev = |
| 2170 | __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV); |
| 2171 | |
| 2172 | config.roam_offload_max_vdev = |
| 2173 | __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV); |
| 2174 | |
| 2175 | config.roam_offload_max_ap_profiles = |
| 2176 | __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES); |
| 2177 | |
| 2178 | config.num_mcast_groups = __cpu_to_le32(TARGET_NUM_MCAST_GROUPS); |
| 2179 | config.num_mcast_table_elems = |
| 2180 | __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS); |
| 2181 | |
| 2182 | config.mcast2ucast_mode = __cpu_to_le32(TARGET_MCAST2UCAST_MODE); |
| 2183 | config.tx_dbg_log_size = __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE); |
| 2184 | config.num_wds_entries = __cpu_to_le32(TARGET_NUM_WDS_ENTRIES); |
| 2185 | config.dma_burst_size = __cpu_to_le32(TARGET_DMA_BURST_SIZE); |
| 2186 | config.mac_aggr_delim = __cpu_to_le32(TARGET_MAC_AGGR_DELIM); |
| 2187 | |
| 2188 | val = TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK; |
| 2189 | config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val); |
| 2190 | |
| 2191 | config.vow_config = __cpu_to_le32(TARGET_VOW_CONFIG); |
| 2192 | |
| 2193 | config.gtk_offload_max_vdev = |
| 2194 | __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV); |
| 2195 | |
| 2196 | config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC); |
| 2197 | config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES); |
| 2198 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2199 | len = sizeof(*cmd) + |
| 2200 | (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks); |
| 2201 | |
| 2202 | buf = ath10k_wmi_alloc_skb(len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2203 | if (!buf) |
| 2204 | return -ENOMEM; |
| 2205 | |
| 2206 | cmd = (struct wmi_init_cmd *)buf->data; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2207 | |
| 2208 | if (ar->wmi.num_mem_chunks == 0) { |
| 2209 | cmd->num_host_mem_chunks = 0; |
| 2210 | goto out; |
| 2211 | } |
| 2212 | |
| 2213 | ath10k_dbg(ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n", |
Michal Kazior | 5c54a7b | 2013-10-16 16:45:53 +0300 | [diff] [blame] | 2214 | ar->wmi.num_mem_chunks); |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2215 | |
| 2216 | cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks); |
| 2217 | |
| 2218 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { |
| 2219 | cmd->host_mem_chunks[i].ptr = |
| 2220 | __cpu_to_le32(ar->wmi.mem_chunks[i].paddr); |
| 2221 | cmd->host_mem_chunks[i].size = |
| 2222 | __cpu_to_le32(ar->wmi.mem_chunks[i].len); |
| 2223 | cmd->host_mem_chunks[i].req_id = |
| 2224 | __cpu_to_le32(ar->wmi.mem_chunks[i].req_id); |
| 2225 | |
| 2226 | ath10k_dbg(ATH10K_DBG_WMI, |
Michal Kazior | 5c54a7b | 2013-10-16 16:45:53 +0300 | [diff] [blame] | 2227 | "wmi chunk %d len %d requested, addr 0x%llx\n", |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2228 | i, |
Michal Kazior | 5c54a7b | 2013-10-16 16:45:53 +0300 | [diff] [blame] | 2229 | ar->wmi.mem_chunks[i].len, |
| 2230 | (unsigned long long)ar->wmi.mem_chunks[i].paddr); |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2231 | } |
| 2232 | out: |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2233 | memcpy(&cmd->resource_config, &config, sizeof(config)); |
| 2234 | |
| 2235 | ath10k_dbg(ATH10K_DBG_WMI, "wmi init\n"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2236 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2237 | } |
| 2238 | |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2239 | static int ath10k_wmi_10x_cmd_init(struct ath10k *ar) |
| 2240 | { |
| 2241 | struct wmi_init_cmd_10x *cmd; |
| 2242 | struct sk_buff *buf; |
| 2243 | struct wmi_resource_config_10x config = {}; |
| 2244 | u32 len, val; |
| 2245 | int i; |
| 2246 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2247 | config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS); |
| 2248 | config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS); |
| 2249 | config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS); |
| 2250 | config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS); |
| 2251 | config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT); |
| 2252 | config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK); |
| 2253 | config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK); |
| 2254 | config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 2255 | config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 2256 | config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 2257 | config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI); |
| 2258 | config.rx_decap_mode = __cpu_to_le32(TARGET_10X_RX_DECAP_MODE); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2259 | |
| 2260 | config.scan_max_pending_reqs = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2261 | __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2262 | |
| 2263 | config.bmiss_offload_max_vdev = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2264 | __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2265 | |
| 2266 | config.roam_offload_max_vdev = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2267 | __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2268 | |
| 2269 | config.roam_offload_max_ap_profiles = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2270 | __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2271 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2272 | config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2273 | config.num_mcast_table_elems = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2274 | __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2275 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2276 | config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE); |
| 2277 | config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE); |
| 2278 | config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES); |
| 2279 | config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE); |
| 2280 | config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2281 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2282 | val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK; |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2283 | config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val); |
| 2284 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2285 | config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2286 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2287 | config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC); |
| 2288 | config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2289 | |
| 2290 | len = sizeof(*cmd) + |
| 2291 | (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks); |
| 2292 | |
| 2293 | buf = ath10k_wmi_alloc_skb(len); |
| 2294 | if (!buf) |
| 2295 | return -ENOMEM; |
| 2296 | |
| 2297 | cmd = (struct wmi_init_cmd_10x *)buf->data; |
| 2298 | |
| 2299 | if (ar->wmi.num_mem_chunks == 0) { |
| 2300 | cmd->num_host_mem_chunks = 0; |
| 2301 | goto out; |
| 2302 | } |
| 2303 | |
| 2304 | ath10k_dbg(ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n", |
Michal Kazior | 5c54a7b | 2013-10-16 16:45:53 +0300 | [diff] [blame] | 2305 | ar->wmi.num_mem_chunks); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2306 | |
| 2307 | cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks); |
| 2308 | |
| 2309 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { |
| 2310 | cmd->host_mem_chunks[i].ptr = |
| 2311 | __cpu_to_le32(ar->wmi.mem_chunks[i].paddr); |
| 2312 | cmd->host_mem_chunks[i].size = |
| 2313 | __cpu_to_le32(ar->wmi.mem_chunks[i].len); |
| 2314 | cmd->host_mem_chunks[i].req_id = |
| 2315 | __cpu_to_le32(ar->wmi.mem_chunks[i].req_id); |
| 2316 | |
| 2317 | ath10k_dbg(ATH10K_DBG_WMI, |
Michal Kazior | 5c54a7b | 2013-10-16 16:45:53 +0300 | [diff] [blame] | 2318 | "wmi chunk %d len %d requested, addr 0x%llx\n", |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2319 | i, |
Michal Kazior | 5c54a7b | 2013-10-16 16:45:53 +0300 | [diff] [blame] | 2320 | ar->wmi.mem_chunks[i].len, |
| 2321 | (unsigned long long)ar->wmi.mem_chunks[i].paddr); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2322 | } |
| 2323 | out: |
| 2324 | memcpy(&cmd->resource_config, &config, sizeof(config)); |
| 2325 | |
| 2326 | ath10k_dbg(ATH10K_DBG_WMI, "wmi init 10x\n"); |
| 2327 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |
| 2328 | } |
| 2329 | |
| 2330 | int ath10k_wmi_cmd_init(struct ath10k *ar) |
| 2331 | { |
| 2332 | int ret; |
| 2333 | |
| 2334 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
| 2335 | ret = ath10k_wmi_10x_cmd_init(ar); |
| 2336 | else |
| 2337 | ret = ath10k_wmi_main_cmd_init(ar); |
| 2338 | |
| 2339 | return ret; |
| 2340 | } |
| 2341 | |
Bartosz Markowski | 89b7e76 | 2013-09-26 17:47:17 +0200 | [diff] [blame] | 2342 | static int ath10k_wmi_start_scan_calc_len(struct ath10k *ar, |
| 2343 | const struct wmi_start_scan_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2344 | { |
| 2345 | int len; |
| 2346 | |
Bartosz Markowski | 89b7e76 | 2013-09-26 17:47:17 +0200 | [diff] [blame] | 2347 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
| 2348 | len = sizeof(struct wmi_start_scan_cmd_10x); |
| 2349 | else |
| 2350 | len = sizeof(struct wmi_start_scan_cmd); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2351 | |
| 2352 | if (arg->ie_len) { |
| 2353 | if (!arg->ie) |
| 2354 | return -EINVAL; |
| 2355 | if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN) |
| 2356 | return -EINVAL; |
| 2357 | |
| 2358 | len += sizeof(struct wmi_ie_data); |
| 2359 | len += roundup(arg->ie_len, 4); |
| 2360 | } |
| 2361 | |
| 2362 | if (arg->n_channels) { |
| 2363 | if (!arg->channels) |
| 2364 | return -EINVAL; |
| 2365 | if (arg->n_channels > ARRAY_SIZE(arg->channels)) |
| 2366 | return -EINVAL; |
| 2367 | |
| 2368 | len += sizeof(struct wmi_chan_list); |
| 2369 | len += sizeof(__le32) * arg->n_channels; |
| 2370 | } |
| 2371 | |
| 2372 | if (arg->n_ssids) { |
| 2373 | if (!arg->ssids) |
| 2374 | return -EINVAL; |
| 2375 | if (arg->n_ssids > WLAN_SCAN_PARAMS_MAX_SSID) |
| 2376 | return -EINVAL; |
| 2377 | |
| 2378 | len += sizeof(struct wmi_ssid_list); |
| 2379 | len += sizeof(struct wmi_ssid) * arg->n_ssids; |
| 2380 | } |
| 2381 | |
| 2382 | if (arg->n_bssids) { |
| 2383 | if (!arg->bssids) |
| 2384 | return -EINVAL; |
| 2385 | if (arg->n_bssids > WLAN_SCAN_PARAMS_MAX_BSSID) |
| 2386 | return -EINVAL; |
| 2387 | |
| 2388 | len += sizeof(struct wmi_bssid_list); |
| 2389 | len += sizeof(struct wmi_mac_addr) * arg->n_bssids; |
| 2390 | } |
| 2391 | |
| 2392 | return len; |
| 2393 | } |
| 2394 | |
| 2395 | int ath10k_wmi_start_scan(struct ath10k *ar, |
| 2396 | const struct wmi_start_scan_arg *arg) |
| 2397 | { |
| 2398 | struct wmi_start_scan_cmd *cmd; |
| 2399 | struct sk_buff *skb; |
| 2400 | struct wmi_ie_data *ie; |
| 2401 | struct wmi_chan_list *channels; |
| 2402 | struct wmi_ssid_list *ssids; |
| 2403 | struct wmi_bssid_list *bssids; |
| 2404 | u32 scan_id; |
| 2405 | u32 scan_req_id; |
| 2406 | int off; |
| 2407 | int len = 0; |
| 2408 | int i; |
| 2409 | |
Bartosz Markowski | 89b7e76 | 2013-09-26 17:47:17 +0200 | [diff] [blame] | 2410 | len = ath10k_wmi_start_scan_calc_len(ar, arg); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2411 | if (len < 0) |
| 2412 | return len; /* len contains error code here */ |
| 2413 | |
| 2414 | skb = ath10k_wmi_alloc_skb(len); |
| 2415 | if (!skb) |
| 2416 | return -ENOMEM; |
| 2417 | |
| 2418 | scan_id = WMI_HOST_SCAN_REQ_ID_PREFIX; |
| 2419 | scan_id |= arg->scan_id; |
| 2420 | |
| 2421 | scan_req_id = WMI_HOST_SCAN_REQUESTOR_ID_PREFIX; |
| 2422 | scan_req_id |= arg->scan_req_id; |
| 2423 | |
| 2424 | cmd = (struct wmi_start_scan_cmd *)skb->data; |
| 2425 | cmd->scan_id = __cpu_to_le32(scan_id); |
| 2426 | cmd->scan_req_id = __cpu_to_le32(scan_req_id); |
| 2427 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 2428 | cmd->scan_priority = __cpu_to_le32(arg->scan_priority); |
| 2429 | cmd->notify_scan_events = __cpu_to_le32(arg->notify_scan_events); |
| 2430 | cmd->dwell_time_active = __cpu_to_le32(arg->dwell_time_active); |
| 2431 | cmd->dwell_time_passive = __cpu_to_le32(arg->dwell_time_passive); |
| 2432 | cmd->min_rest_time = __cpu_to_le32(arg->min_rest_time); |
| 2433 | cmd->max_rest_time = __cpu_to_le32(arg->max_rest_time); |
| 2434 | cmd->repeat_probe_time = __cpu_to_le32(arg->repeat_probe_time); |
| 2435 | cmd->probe_spacing_time = __cpu_to_le32(arg->probe_spacing_time); |
| 2436 | cmd->idle_time = __cpu_to_le32(arg->idle_time); |
| 2437 | cmd->max_scan_time = __cpu_to_le32(arg->max_scan_time); |
| 2438 | cmd->probe_delay = __cpu_to_le32(arg->probe_delay); |
| 2439 | cmd->scan_ctrl_flags = __cpu_to_le32(arg->scan_ctrl_flags); |
| 2440 | |
| 2441 | /* TLV list starts after fields included in the struct */ |
Bartosz Markowski | 89b7e76 | 2013-09-26 17:47:17 +0200 | [diff] [blame] | 2442 | /* There's just one filed that differes the two start_scan |
| 2443 | * structures - burst_duration, which we are not using btw, |
| 2444 | no point to make the split here, just shift the buffer to fit with |
| 2445 | given FW */ |
| 2446 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
| 2447 | off = sizeof(struct wmi_start_scan_cmd_10x); |
| 2448 | else |
| 2449 | off = sizeof(struct wmi_start_scan_cmd); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2450 | |
| 2451 | if (arg->n_channels) { |
| 2452 | channels = (void *)skb->data + off; |
| 2453 | channels->tag = __cpu_to_le32(WMI_CHAN_LIST_TAG); |
| 2454 | channels->num_chan = __cpu_to_le32(arg->n_channels); |
| 2455 | |
| 2456 | for (i = 0; i < arg->n_channels; i++) |
| 2457 | channels->channel_list[i] = |
| 2458 | __cpu_to_le32(arg->channels[i]); |
| 2459 | |
| 2460 | off += sizeof(*channels); |
| 2461 | off += sizeof(__le32) * arg->n_channels; |
| 2462 | } |
| 2463 | |
| 2464 | if (arg->n_ssids) { |
| 2465 | ssids = (void *)skb->data + off; |
| 2466 | ssids->tag = __cpu_to_le32(WMI_SSID_LIST_TAG); |
| 2467 | ssids->num_ssids = __cpu_to_le32(arg->n_ssids); |
| 2468 | |
| 2469 | for (i = 0; i < arg->n_ssids; i++) { |
| 2470 | ssids->ssids[i].ssid_len = |
| 2471 | __cpu_to_le32(arg->ssids[i].len); |
| 2472 | memcpy(&ssids->ssids[i].ssid, |
| 2473 | arg->ssids[i].ssid, |
| 2474 | arg->ssids[i].len); |
| 2475 | } |
| 2476 | |
| 2477 | off += sizeof(*ssids); |
| 2478 | off += sizeof(struct wmi_ssid) * arg->n_ssids; |
| 2479 | } |
| 2480 | |
| 2481 | if (arg->n_bssids) { |
| 2482 | bssids = (void *)skb->data + off; |
| 2483 | bssids->tag = __cpu_to_le32(WMI_BSSID_LIST_TAG); |
| 2484 | bssids->num_bssid = __cpu_to_le32(arg->n_bssids); |
| 2485 | |
| 2486 | for (i = 0; i < arg->n_bssids; i++) |
| 2487 | memcpy(&bssids->bssid_list[i], |
| 2488 | arg->bssids[i].bssid, |
| 2489 | ETH_ALEN); |
| 2490 | |
| 2491 | off += sizeof(*bssids); |
| 2492 | off += sizeof(struct wmi_mac_addr) * arg->n_bssids; |
| 2493 | } |
| 2494 | |
| 2495 | if (arg->ie_len) { |
| 2496 | ie = (void *)skb->data + off; |
| 2497 | ie->tag = __cpu_to_le32(WMI_IE_TAG); |
| 2498 | ie->ie_len = __cpu_to_le32(arg->ie_len); |
| 2499 | memcpy(ie->ie_data, arg->ie, arg->ie_len); |
| 2500 | |
| 2501 | off += sizeof(*ie); |
| 2502 | off += roundup(arg->ie_len, 4); |
| 2503 | } |
| 2504 | |
| 2505 | if (off != skb->len) { |
| 2506 | dev_kfree_skb(skb); |
| 2507 | return -EINVAL; |
| 2508 | } |
| 2509 | |
| 2510 | ath10k_dbg(ATH10K_DBG_WMI, "wmi start scan\n"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2511 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->start_scan_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2512 | } |
| 2513 | |
| 2514 | void ath10k_wmi_start_scan_init(struct ath10k *ar, |
| 2515 | struct wmi_start_scan_arg *arg) |
| 2516 | { |
| 2517 | /* setup commonly used values */ |
| 2518 | arg->scan_req_id = 1; |
| 2519 | arg->scan_priority = WMI_SCAN_PRIORITY_LOW; |
| 2520 | arg->dwell_time_active = 50; |
| 2521 | arg->dwell_time_passive = 150; |
| 2522 | arg->min_rest_time = 50; |
| 2523 | arg->max_rest_time = 500; |
| 2524 | arg->repeat_probe_time = 0; |
| 2525 | arg->probe_spacing_time = 0; |
| 2526 | arg->idle_time = 0; |
Bartosz Markowski | c322892 | 2013-10-02 08:48:52 +0200 | [diff] [blame] | 2527 | arg->max_scan_time = 20000; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2528 | arg->probe_delay = 5; |
| 2529 | arg->notify_scan_events = WMI_SCAN_EVENT_STARTED |
| 2530 | | WMI_SCAN_EVENT_COMPLETED |
| 2531 | | WMI_SCAN_EVENT_BSS_CHANNEL |
| 2532 | | WMI_SCAN_EVENT_FOREIGN_CHANNEL |
| 2533 | | WMI_SCAN_EVENT_DEQUEUED; |
| 2534 | arg->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES; |
| 2535 | arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT; |
| 2536 | arg->n_bssids = 1; |
| 2537 | arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF"; |
| 2538 | } |
| 2539 | |
| 2540 | int ath10k_wmi_stop_scan(struct ath10k *ar, const struct wmi_stop_scan_arg *arg) |
| 2541 | { |
| 2542 | struct wmi_stop_scan_cmd *cmd; |
| 2543 | struct sk_buff *skb; |
| 2544 | u32 scan_id; |
| 2545 | u32 req_id; |
| 2546 | |
| 2547 | if (arg->req_id > 0xFFF) |
| 2548 | return -EINVAL; |
| 2549 | if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF) |
| 2550 | return -EINVAL; |
| 2551 | |
| 2552 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2553 | if (!skb) |
| 2554 | return -ENOMEM; |
| 2555 | |
| 2556 | scan_id = arg->u.scan_id; |
| 2557 | scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX; |
| 2558 | |
| 2559 | req_id = arg->req_id; |
| 2560 | req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX; |
| 2561 | |
| 2562 | cmd = (struct wmi_stop_scan_cmd *)skb->data; |
| 2563 | cmd->req_type = __cpu_to_le32(arg->req_type); |
| 2564 | cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id); |
| 2565 | cmd->scan_id = __cpu_to_le32(scan_id); |
| 2566 | cmd->scan_req_id = __cpu_to_le32(req_id); |
| 2567 | |
| 2568 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2569 | "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n", |
| 2570 | arg->req_id, arg->req_type, arg->u.scan_id); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2571 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->stop_scan_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2572 | } |
| 2573 | |
| 2574 | int ath10k_wmi_vdev_create(struct ath10k *ar, u32 vdev_id, |
| 2575 | enum wmi_vdev_type type, |
| 2576 | enum wmi_vdev_subtype subtype, |
| 2577 | const u8 macaddr[ETH_ALEN]) |
| 2578 | { |
| 2579 | struct wmi_vdev_create_cmd *cmd; |
| 2580 | struct sk_buff *skb; |
| 2581 | |
| 2582 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2583 | if (!skb) |
| 2584 | return -ENOMEM; |
| 2585 | |
| 2586 | cmd = (struct wmi_vdev_create_cmd *)skb->data; |
| 2587 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2588 | cmd->vdev_type = __cpu_to_le32(type); |
| 2589 | cmd->vdev_subtype = __cpu_to_le32(subtype); |
| 2590 | memcpy(cmd->vdev_macaddr.addr, macaddr, ETH_ALEN); |
| 2591 | |
| 2592 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2593 | "WMI vdev create: id %d type %d subtype %d macaddr %pM\n", |
| 2594 | vdev_id, type, subtype, macaddr); |
| 2595 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2596 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_create_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2597 | } |
| 2598 | |
| 2599 | int ath10k_wmi_vdev_delete(struct ath10k *ar, u32 vdev_id) |
| 2600 | { |
| 2601 | struct wmi_vdev_delete_cmd *cmd; |
| 2602 | struct sk_buff *skb; |
| 2603 | |
| 2604 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2605 | if (!skb) |
| 2606 | return -ENOMEM; |
| 2607 | |
| 2608 | cmd = (struct wmi_vdev_delete_cmd *)skb->data; |
| 2609 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2610 | |
| 2611 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2612 | "WMI vdev delete id %d\n", vdev_id); |
| 2613 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2614 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_delete_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2615 | } |
| 2616 | |
| 2617 | static int ath10k_wmi_vdev_start_restart(struct ath10k *ar, |
| 2618 | const struct wmi_vdev_start_request_arg *arg, |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2619 | u32 cmd_id) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2620 | { |
| 2621 | struct wmi_vdev_start_request_cmd *cmd; |
| 2622 | struct sk_buff *skb; |
| 2623 | const char *cmdname; |
| 2624 | u32 flags = 0; |
| 2625 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2626 | if (cmd_id != ar->wmi.cmd->vdev_start_request_cmdid && |
| 2627 | cmd_id != ar->wmi.cmd->vdev_restart_request_cmdid) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2628 | return -EINVAL; |
| 2629 | if (WARN_ON(arg->ssid && arg->ssid_len == 0)) |
| 2630 | return -EINVAL; |
| 2631 | if (WARN_ON(arg->hidden_ssid && !arg->ssid)) |
| 2632 | return -EINVAL; |
| 2633 | if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid))) |
| 2634 | return -EINVAL; |
| 2635 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2636 | if (cmd_id == ar->wmi.cmd->vdev_start_request_cmdid) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2637 | cmdname = "start"; |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2638 | else if (cmd_id == ar->wmi.cmd->vdev_restart_request_cmdid) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2639 | cmdname = "restart"; |
| 2640 | else |
| 2641 | return -EINVAL; /* should not happen, we already check cmd_id */ |
| 2642 | |
| 2643 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2644 | if (!skb) |
| 2645 | return -ENOMEM; |
| 2646 | |
| 2647 | if (arg->hidden_ssid) |
| 2648 | flags |= WMI_VDEV_START_HIDDEN_SSID; |
| 2649 | if (arg->pmf_enabled) |
| 2650 | flags |= WMI_VDEV_START_PMF_ENABLED; |
| 2651 | |
| 2652 | cmd = (struct wmi_vdev_start_request_cmd *)skb->data; |
| 2653 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 2654 | cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack); |
| 2655 | cmd->beacon_interval = __cpu_to_le32(arg->bcn_intval); |
| 2656 | cmd->dtim_period = __cpu_to_le32(arg->dtim_period); |
| 2657 | cmd->flags = __cpu_to_le32(flags); |
| 2658 | cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate); |
| 2659 | cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power); |
| 2660 | |
| 2661 | if (arg->ssid) { |
| 2662 | cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len); |
| 2663 | memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len); |
| 2664 | } |
| 2665 | |
| 2666 | cmd->chan.mhz = __cpu_to_le32(arg->channel.freq); |
| 2667 | |
| 2668 | cmd->chan.band_center_freq1 = |
| 2669 | __cpu_to_le32(arg->channel.band_center_freq1); |
| 2670 | |
| 2671 | cmd->chan.mode = arg->channel.mode; |
| 2672 | cmd->chan.min_power = arg->channel.min_power; |
| 2673 | cmd->chan.max_power = arg->channel.max_power; |
| 2674 | cmd->chan.reg_power = arg->channel.max_reg_power; |
| 2675 | cmd->chan.reg_classid = arg->channel.reg_class_id; |
| 2676 | cmd->chan.antenna_max = arg->channel.max_antenna_gain; |
| 2677 | |
| 2678 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2679 | "wmi vdev %s id 0x%x freq %d, mode %d, ch_flags: 0x%0X," |
| 2680 | "max_power: %d\n", cmdname, arg->vdev_id, arg->channel.freq, |
| 2681 | arg->channel.mode, flags, arg->channel.max_power); |
| 2682 | |
| 2683 | return ath10k_wmi_cmd_send(ar, skb, cmd_id); |
| 2684 | } |
| 2685 | |
| 2686 | int ath10k_wmi_vdev_start(struct ath10k *ar, |
| 2687 | const struct wmi_vdev_start_request_arg *arg) |
| 2688 | { |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2689 | u32 cmd_id = ar->wmi.cmd->vdev_start_request_cmdid; |
| 2690 | |
| 2691 | return ath10k_wmi_vdev_start_restart(ar, arg, cmd_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2692 | } |
| 2693 | |
| 2694 | int ath10k_wmi_vdev_restart(struct ath10k *ar, |
| 2695 | const struct wmi_vdev_start_request_arg *arg) |
| 2696 | { |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2697 | u32 cmd_id = ar->wmi.cmd->vdev_restart_request_cmdid; |
| 2698 | |
| 2699 | return ath10k_wmi_vdev_start_restart(ar, arg, cmd_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2700 | } |
| 2701 | |
| 2702 | int ath10k_wmi_vdev_stop(struct ath10k *ar, u32 vdev_id) |
| 2703 | { |
| 2704 | struct wmi_vdev_stop_cmd *cmd; |
| 2705 | struct sk_buff *skb; |
| 2706 | |
| 2707 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2708 | if (!skb) |
| 2709 | return -ENOMEM; |
| 2710 | |
| 2711 | cmd = (struct wmi_vdev_stop_cmd *)skb->data; |
| 2712 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2713 | |
| 2714 | ath10k_dbg(ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id); |
| 2715 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2716 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_stop_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2717 | } |
| 2718 | |
| 2719 | int ath10k_wmi_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid, const u8 *bssid) |
| 2720 | { |
| 2721 | struct wmi_vdev_up_cmd *cmd; |
| 2722 | struct sk_buff *skb; |
| 2723 | |
| 2724 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2725 | if (!skb) |
| 2726 | return -ENOMEM; |
| 2727 | |
| 2728 | cmd = (struct wmi_vdev_up_cmd *)skb->data; |
| 2729 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2730 | cmd->vdev_assoc_id = __cpu_to_le32(aid); |
| 2731 | memcpy(&cmd->vdev_bssid.addr, bssid, 6); |
| 2732 | |
| 2733 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2734 | "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n", |
| 2735 | vdev_id, aid, bssid); |
| 2736 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2737 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_up_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2738 | } |
| 2739 | |
| 2740 | int ath10k_wmi_vdev_down(struct ath10k *ar, u32 vdev_id) |
| 2741 | { |
| 2742 | struct wmi_vdev_down_cmd *cmd; |
| 2743 | struct sk_buff *skb; |
| 2744 | |
| 2745 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2746 | if (!skb) |
| 2747 | return -ENOMEM; |
| 2748 | |
| 2749 | cmd = (struct wmi_vdev_down_cmd *)skb->data; |
| 2750 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2751 | |
| 2752 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2753 | "wmi mgmt vdev down id 0x%x\n", vdev_id); |
| 2754 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2755 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_down_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2756 | } |
| 2757 | |
| 2758 | int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id, |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 2759 | u32 param_id, u32 param_value) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2760 | { |
| 2761 | struct wmi_vdev_set_param_cmd *cmd; |
| 2762 | struct sk_buff *skb; |
| 2763 | |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 2764 | if (param_id == WMI_VDEV_PARAM_UNSUPPORTED) { |
| 2765 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2766 | "vdev param %d not supported by firmware\n", |
| 2767 | param_id); |
Bartosz Markowski | ebc9abd | 2013-10-15 09:26:20 +0200 | [diff] [blame] | 2768 | return -EOPNOTSUPP; |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 2769 | } |
| 2770 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2771 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2772 | if (!skb) |
| 2773 | return -ENOMEM; |
| 2774 | |
| 2775 | cmd = (struct wmi_vdev_set_param_cmd *)skb->data; |
| 2776 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2777 | cmd->param_id = __cpu_to_le32(param_id); |
| 2778 | cmd->param_value = __cpu_to_le32(param_value); |
| 2779 | |
| 2780 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2781 | "wmi vdev id 0x%x set param %d value %d\n", |
| 2782 | vdev_id, param_id, param_value); |
| 2783 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2784 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_set_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2785 | } |
| 2786 | |
| 2787 | int ath10k_wmi_vdev_install_key(struct ath10k *ar, |
| 2788 | const struct wmi_vdev_install_key_arg *arg) |
| 2789 | { |
| 2790 | struct wmi_vdev_install_key_cmd *cmd; |
| 2791 | struct sk_buff *skb; |
| 2792 | |
| 2793 | if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL) |
| 2794 | return -EINVAL; |
| 2795 | if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL) |
| 2796 | return -EINVAL; |
| 2797 | |
| 2798 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd) + arg->key_len); |
| 2799 | if (!skb) |
| 2800 | return -ENOMEM; |
| 2801 | |
| 2802 | cmd = (struct wmi_vdev_install_key_cmd *)skb->data; |
| 2803 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 2804 | cmd->key_idx = __cpu_to_le32(arg->key_idx); |
| 2805 | cmd->key_flags = __cpu_to_le32(arg->key_flags); |
| 2806 | cmd->key_cipher = __cpu_to_le32(arg->key_cipher); |
| 2807 | cmd->key_len = __cpu_to_le32(arg->key_len); |
| 2808 | cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len); |
| 2809 | cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len); |
| 2810 | |
| 2811 | if (arg->macaddr) |
| 2812 | memcpy(cmd->peer_macaddr.addr, arg->macaddr, ETH_ALEN); |
| 2813 | if (arg->key_data) |
| 2814 | memcpy(cmd->key_data, arg->key_data, arg->key_len); |
| 2815 | |
Michal Kazior | e0c508a | 2013-07-05 16:15:17 +0300 | [diff] [blame] | 2816 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2817 | "wmi vdev install key idx %d cipher %d len %d\n", |
| 2818 | arg->key_idx, arg->key_cipher, arg->key_len); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2819 | return ath10k_wmi_cmd_send(ar, skb, |
| 2820 | ar->wmi.cmd->vdev_install_key_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2821 | } |
| 2822 | |
| 2823 | int ath10k_wmi_peer_create(struct ath10k *ar, u32 vdev_id, |
| 2824 | const u8 peer_addr[ETH_ALEN]) |
| 2825 | { |
| 2826 | struct wmi_peer_create_cmd *cmd; |
| 2827 | struct sk_buff *skb; |
| 2828 | |
| 2829 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2830 | if (!skb) |
| 2831 | return -ENOMEM; |
| 2832 | |
| 2833 | cmd = (struct wmi_peer_create_cmd *)skb->data; |
| 2834 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2835 | memcpy(cmd->peer_macaddr.addr, peer_addr, ETH_ALEN); |
| 2836 | |
| 2837 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2838 | "wmi peer create vdev_id %d peer_addr %pM\n", |
| 2839 | vdev_id, peer_addr); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2840 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_create_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2841 | } |
| 2842 | |
| 2843 | int ath10k_wmi_peer_delete(struct ath10k *ar, u32 vdev_id, |
| 2844 | const u8 peer_addr[ETH_ALEN]) |
| 2845 | { |
| 2846 | struct wmi_peer_delete_cmd *cmd; |
| 2847 | struct sk_buff *skb; |
| 2848 | |
| 2849 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2850 | if (!skb) |
| 2851 | return -ENOMEM; |
| 2852 | |
| 2853 | cmd = (struct wmi_peer_delete_cmd *)skb->data; |
| 2854 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2855 | memcpy(cmd->peer_macaddr.addr, peer_addr, ETH_ALEN); |
| 2856 | |
| 2857 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2858 | "wmi peer delete vdev_id %d peer_addr %pM\n", |
| 2859 | vdev_id, peer_addr); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2860 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_delete_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2861 | } |
| 2862 | |
| 2863 | int ath10k_wmi_peer_flush(struct ath10k *ar, u32 vdev_id, |
| 2864 | const u8 peer_addr[ETH_ALEN], u32 tid_bitmap) |
| 2865 | { |
| 2866 | struct wmi_peer_flush_tids_cmd *cmd; |
| 2867 | struct sk_buff *skb; |
| 2868 | |
| 2869 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2870 | if (!skb) |
| 2871 | return -ENOMEM; |
| 2872 | |
| 2873 | cmd = (struct wmi_peer_flush_tids_cmd *)skb->data; |
| 2874 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2875 | cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap); |
| 2876 | memcpy(cmd->peer_macaddr.addr, peer_addr, ETH_ALEN); |
| 2877 | |
| 2878 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2879 | "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n", |
| 2880 | vdev_id, peer_addr, tid_bitmap); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2881 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_flush_tids_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2882 | } |
| 2883 | |
| 2884 | int ath10k_wmi_peer_set_param(struct ath10k *ar, u32 vdev_id, |
| 2885 | const u8 *peer_addr, enum wmi_peer_param param_id, |
| 2886 | u32 param_value) |
| 2887 | { |
| 2888 | struct wmi_peer_set_param_cmd *cmd; |
| 2889 | struct sk_buff *skb; |
| 2890 | |
| 2891 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2892 | if (!skb) |
| 2893 | return -ENOMEM; |
| 2894 | |
| 2895 | cmd = (struct wmi_peer_set_param_cmd *)skb->data; |
| 2896 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2897 | cmd->param_id = __cpu_to_le32(param_id); |
| 2898 | cmd->param_value = __cpu_to_le32(param_value); |
| 2899 | memcpy(&cmd->peer_macaddr.addr, peer_addr, 6); |
| 2900 | |
| 2901 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2902 | "wmi vdev %d peer 0x%pM set param %d value %d\n", |
| 2903 | vdev_id, peer_addr, param_id, param_value); |
| 2904 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2905 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_set_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2906 | } |
| 2907 | |
| 2908 | int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id, |
| 2909 | enum wmi_sta_ps_mode psmode) |
| 2910 | { |
| 2911 | struct wmi_sta_powersave_mode_cmd *cmd; |
| 2912 | struct sk_buff *skb; |
| 2913 | |
| 2914 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2915 | if (!skb) |
| 2916 | return -ENOMEM; |
| 2917 | |
| 2918 | cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data; |
| 2919 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2920 | cmd->sta_ps_mode = __cpu_to_le32(psmode); |
| 2921 | |
| 2922 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2923 | "wmi set powersave id 0x%x mode %d\n", |
| 2924 | vdev_id, psmode); |
| 2925 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2926 | return ath10k_wmi_cmd_send(ar, skb, |
| 2927 | ar->wmi.cmd->sta_powersave_mode_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2928 | } |
| 2929 | |
| 2930 | int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id, |
| 2931 | enum wmi_sta_powersave_param param_id, |
| 2932 | u32 value) |
| 2933 | { |
| 2934 | struct wmi_sta_powersave_param_cmd *cmd; |
| 2935 | struct sk_buff *skb; |
| 2936 | |
| 2937 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2938 | if (!skb) |
| 2939 | return -ENOMEM; |
| 2940 | |
| 2941 | cmd = (struct wmi_sta_powersave_param_cmd *)skb->data; |
| 2942 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2943 | cmd->param_id = __cpu_to_le32(param_id); |
| 2944 | cmd->param_value = __cpu_to_le32(value); |
| 2945 | |
| 2946 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2947 | "wmi sta ps param vdev_id 0x%x param %d value %d\n", |
| 2948 | vdev_id, param_id, value); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2949 | return ath10k_wmi_cmd_send(ar, skb, |
| 2950 | ar->wmi.cmd->sta_powersave_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2951 | } |
| 2952 | |
| 2953 | int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac, |
| 2954 | enum wmi_ap_ps_peer_param param_id, u32 value) |
| 2955 | { |
| 2956 | struct wmi_ap_ps_peer_cmd *cmd; |
| 2957 | struct sk_buff *skb; |
| 2958 | |
| 2959 | if (!mac) |
| 2960 | return -EINVAL; |
| 2961 | |
| 2962 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 2963 | if (!skb) |
| 2964 | return -ENOMEM; |
| 2965 | |
| 2966 | cmd = (struct wmi_ap_ps_peer_cmd *)skb->data; |
| 2967 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 2968 | cmd->param_id = __cpu_to_le32(param_id); |
| 2969 | cmd->param_value = __cpu_to_le32(value); |
| 2970 | memcpy(&cmd->peer_macaddr, mac, ETH_ALEN); |
| 2971 | |
| 2972 | ath10k_dbg(ATH10K_DBG_WMI, |
| 2973 | "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n", |
| 2974 | vdev_id, param_id, value, mac); |
| 2975 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2976 | return ath10k_wmi_cmd_send(ar, skb, |
| 2977 | ar->wmi.cmd->ap_ps_peer_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2978 | } |
| 2979 | |
| 2980 | int ath10k_wmi_scan_chan_list(struct ath10k *ar, |
| 2981 | const struct wmi_scan_chan_list_arg *arg) |
| 2982 | { |
| 2983 | struct wmi_scan_chan_list_cmd *cmd; |
| 2984 | struct sk_buff *skb; |
| 2985 | struct wmi_channel_arg *ch; |
| 2986 | struct wmi_channel *ci; |
| 2987 | int len; |
| 2988 | int i; |
| 2989 | |
| 2990 | len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel); |
| 2991 | |
| 2992 | skb = ath10k_wmi_alloc_skb(len); |
| 2993 | if (!skb) |
| 2994 | return -EINVAL; |
| 2995 | |
| 2996 | cmd = (struct wmi_scan_chan_list_cmd *)skb->data; |
| 2997 | cmd->num_scan_chans = __cpu_to_le32(arg->n_channels); |
| 2998 | |
| 2999 | for (i = 0; i < arg->n_channels; i++) { |
| 3000 | u32 flags = 0; |
| 3001 | |
| 3002 | ch = &arg->channels[i]; |
| 3003 | ci = &cmd->chan_info[i]; |
| 3004 | |
| 3005 | if (ch->passive) |
| 3006 | flags |= WMI_CHAN_FLAG_PASSIVE; |
| 3007 | if (ch->allow_ibss) |
| 3008 | flags |= WMI_CHAN_FLAG_ADHOC_ALLOWED; |
| 3009 | if (ch->allow_ht) |
| 3010 | flags |= WMI_CHAN_FLAG_ALLOW_HT; |
| 3011 | if (ch->allow_vht) |
| 3012 | flags |= WMI_CHAN_FLAG_ALLOW_VHT; |
| 3013 | if (ch->ht40plus) |
| 3014 | flags |= WMI_CHAN_FLAG_HT40_PLUS; |
| 3015 | |
| 3016 | ci->mhz = __cpu_to_le32(ch->freq); |
| 3017 | ci->band_center_freq1 = __cpu_to_le32(ch->freq); |
| 3018 | ci->band_center_freq2 = 0; |
| 3019 | ci->min_power = ch->min_power; |
| 3020 | ci->max_power = ch->max_power; |
| 3021 | ci->reg_power = ch->max_reg_power; |
| 3022 | ci->antenna_max = ch->max_antenna_gain; |
| 3023 | ci->antenna_max = 0; |
| 3024 | |
| 3025 | /* mode & flags share storage */ |
| 3026 | ci->mode = ch->mode; |
| 3027 | ci->flags |= __cpu_to_le32(flags); |
| 3028 | } |
| 3029 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3030 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->scan_chan_list_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3031 | } |
| 3032 | |
| 3033 | int ath10k_wmi_peer_assoc(struct ath10k *ar, |
| 3034 | const struct wmi_peer_assoc_complete_arg *arg) |
| 3035 | { |
| 3036 | struct wmi_peer_assoc_complete_cmd *cmd; |
| 3037 | struct sk_buff *skb; |
| 3038 | |
| 3039 | if (arg->peer_mpdu_density > 16) |
| 3040 | return -EINVAL; |
| 3041 | if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES) |
| 3042 | return -EINVAL; |
| 3043 | if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES) |
| 3044 | return -EINVAL; |
| 3045 | |
| 3046 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 3047 | if (!skb) |
| 3048 | return -ENOMEM; |
| 3049 | |
| 3050 | cmd = (struct wmi_peer_assoc_complete_cmd *)skb->data; |
| 3051 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3052 | cmd->peer_new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1); |
| 3053 | cmd->peer_associd = __cpu_to_le32(arg->peer_aid); |
| 3054 | cmd->peer_flags = __cpu_to_le32(arg->peer_flags); |
| 3055 | cmd->peer_caps = __cpu_to_le32(arg->peer_caps); |
| 3056 | cmd->peer_listen_intval = __cpu_to_le32(arg->peer_listen_intval); |
| 3057 | cmd->peer_ht_caps = __cpu_to_le32(arg->peer_ht_caps); |
| 3058 | cmd->peer_max_mpdu = __cpu_to_le32(arg->peer_max_mpdu); |
| 3059 | cmd->peer_mpdu_density = __cpu_to_le32(arg->peer_mpdu_density); |
| 3060 | cmd->peer_rate_caps = __cpu_to_le32(arg->peer_rate_caps); |
| 3061 | cmd->peer_nss = __cpu_to_le32(arg->peer_num_spatial_streams); |
| 3062 | cmd->peer_vht_caps = __cpu_to_le32(arg->peer_vht_caps); |
| 3063 | cmd->peer_phymode = __cpu_to_le32(arg->peer_phymode); |
| 3064 | |
| 3065 | memcpy(cmd->peer_macaddr.addr, arg->addr, ETH_ALEN); |
| 3066 | |
| 3067 | cmd->peer_legacy_rates.num_rates = |
| 3068 | __cpu_to_le32(arg->peer_legacy_rates.num_rates); |
| 3069 | memcpy(cmd->peer_legacy_rates.rates, arg->peer_legacy_rates.rates, |
| 3070 | arg->peer_legacy_rates.num_rates); |
| 3071 | |
| 3072 | cmd->peer_ht_rates.num_rates = |
| 3073 | __cpu_to_le32(arg->peer_ht_rates.num_rates); |
| 3074 | memcpy(cmd->peer_ht_rates.rates, arg->peer_ht_rates.rates, |
| 3075 | arg->peer_ht_rates.num_rates); |
| 3076 | |
| 3077 | cmd->peer_vht_rates.rx_max_rate = |
| 3078 | __cpu_to_le32(arg->peer_vht_rates.rx_max_rate); |
| 3079 | cmd->peer_vht_rates.rx_mcs_set = |
| 3080 | __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set); |
| 3081 | cmd->peer_vht_rates.tx_max_rate = |
| 3082 | __cpu_to_le32(arg->peer_vht_rates.tx_max_rate); |
| 3083 | cmd->peer_vht_rates.tx_mcs_set = |
| 3084 | __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set); |
| 3085 | |
Michal Kazior | e0c508a | 2013-07-05 16:15:17 +0300 | [diff] [blame] | 3086 | ath10k_dbg(ATH10K_DBG_WMI, |
| 3087 | "wmi peer assoc vdev %d addr %pM\n", |
| 3088 | arg->vdev_id, arg->addr); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3089 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_assoc_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3090 | } |
| 3091 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 3092 | int ath10k_wmi_beacon_send_nowait(struct ath10k *ar, |
| 3093 | const struct wmi_bcn_tx_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3094 | { |
| 3095 | struct wmi_bcn_tx_cmd *cmd; |
| 3096 | struct sk_buff *skb; |
| 3097 | |
| 3098 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd) + arg->bcn_len); |
| 3099 | if (!skb) |
| 3100 | return -ENOMEM; |
| 3101 | |
| 3102 | cmd = (struct wmi_bcn_tx_cmd *)skb->data; |
| 3103 | cmd->hdr.vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3104 | cmd->hdr.tx_rate = __cpu_to_le32(arg->tx_rate); |
| 3105 | cmd->hdr.tx_power = __cpu_to_le32(arg->tx_power); |
| 3106 | cmd->hdr.bcn_len = __cpu_to_le32(arg->bcn_len); |
| 3107 | memcpy(cmd->bcn, arg->bcn, arg->bcn_len); |
| 3108 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3109 | return ath10k_wmi_cmd_send_nowait(ar, skb, ar->wmi.cmd->bcn_tx_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3110 | } |
| 3111 | |
| 3112 | static void ath10k_wmi_pdev_set_wmm_param(struct wmi_wmm_params *params, |
| 3113 | const struct wmi_wmm_params_arg *arg) |
| 3114 | { |
| 3115 | params->cwmin = __cpu_to_le32(arg->cwmin); |
| 3116 | params->cwmax = __cpu_to_le32(arg->cwmax); |
| 3117 | params->aifs = __cpu_to_le32(arg->aifs); |
| 3118 | params->txop = __cpu_to_le32(arg->txop); |
| 3119 | params->acm = __cpu_to_le32(arg->acm); |
| 3120 | params->no_ack = __cpu_to_le32(arg->no_ack); |
| 3121 | } |
| 3122 | |
| 3123 | int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar, |
| 3124 | const struct wmi_pdev_set_wmm_params_arg *arg) |
| 3125 | { |
| 3126 | struct wmi_pdev_set_wmm_params *cmd; |
| 3127 | struct sk_buff *skb; |
| 3128 | |
| 3129 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 3130 | if (!skb) |
| 3131 | return -ENOMEM; |
| 3132 | |
| 3133 | cmd = (struct wmi_pdev_set_wmm_params *)skb->data; |
| 3134 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_be, &arg->ac_be); |
| 3135 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_bk, &arg->ac_bk); |
| 3136 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vi, &arg->ac_vi); |
| 3137 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vo, &arg->ac_vo); |
| 3138 | |
| 3139 | ath10k_dbg(ATH10K_DBG_WMI, "wmi pdev set wmm params\n"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3140 | return ath10k_wmi_cmd_send(ar, skb, |
| 3141 | ar->wmi.cmd->pdev_set_wmm_params_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3142 | } |
| 3143 | |
| 3144 | int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id) |
| 3145 | { |
| 3146 | struct wmi_request_stats_cmd *cmd; |
| 3147 | struct sk_buff *skb; |
| 3148 | |
| 3149 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 3150 | if (!skb) |
| 3151 | return -ENOMEM; |
| 3152 | |
| 3153 | cmd = (struct wmi_request_stats_cmd *)skb->data; |
| 3154 | cmd->stats_id = __cpu_to_le32(stats_id); |
| 3155 | |
| 3156 | ath10k_dbg(ATH10K_DBG_WMI, "wmi request stats %d\n", (int)stats_id); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3157 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->request_stats_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3158 | } |
Michal Kazior | 9cfbce7 | 2013-07-16 09:54:36 +0200 | [diff] [blame] | 3159 | |
| 3160 | int ath10k_wmi_force_fw_hang(struct ath10k *ar, |
| 3161 | enum wmi_force_fw_hang_type type, u32 delay_ms) |
| 3162 | { |
| 3163 | struct wmi_force_fw_hang_cmd *cmd; |
| 3164 | struct sk_buff *skb; |
| 3165 | |
| 3166 | skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); |
| 3167 | if (!skb) |
| 3168 | return -ENOMEM; |
| 3169 | |
| 3170 | cmd = (struct wmi_force_fw_hang_cmd *)skb->data; |
| 3171 | cmd->type = __cpu_to_le32(type); |
| 3172 | cmd->delay_ms = __cpu_to_le32(delay_ms); |
| 3173 | |
| 3174 | ath10k_dbg(ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n", |
| 3175 | type, delay_ms); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3176 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid); |
Michal Kazior | 9cfbce7 | 2013-07-16 09:54:36 +0200 | [diff] [blame] | 3177 | } |