aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath10k/wmi.c
diff options
context:
space:
mode:
authorMichal Kazior <michal.kazior@tieto.com>2014-12-03 03:10:54 -0500
committerKalle Valo <kvalo@qca.qualcomm.com>2014-12-08 10:39:08 -0500
commitd7579d12c33f87de9975d17880d708b50e959bbb (patch)
treef5d453ed9a3397b6c7d43f2faaa2f430307691b2 /drivers/net/wireless/ath/ath10k/wmi.c
parent32653cf19554ddb77e9528851df3eed3ea35619d (diff)
ath10k: introduce wmi ops
Since the 10.x fw branch support was introduced it became apparent ath10k will need to be able to deal with different fw ABIs eventually. The patch creates an abstraction for dealing with command and event structures across different ABIs and mostly gets rid of the ATH10K_FW_FEATURE_WMI_10X flag usage. Signed-off-by: Michal Kazior <michal.kazior@tieto.com> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath10k/wmi.c')
-rw-r--r--drivers/net/wireless/ath/ath10k/wmi.c906
1 files changed, 530 insertions, 376 deletions
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
index 4a9468e1573d..24bb97face30 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -24,6 +24,7 @@
24#include "wmi.h" 24#include "wmi.h"
25#include "mac.h" 25#include "mac.h"
26#include "testmode.h" 26#include "testmode.h"
27#include "wmi-ops.h"
27 28
28/* MAIN WMI cmd track */ 29/* MAIN WMI cmd track */
29static struct wmi_cmd_map wmi_cmd_map = { 30static struct wmi_cmd_map wmi_cmd_map = {
@@ -685,8 +686,8 @@ static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
685 dev_kfree_skb(skb); 686 dev_kfree_skb(skb);
686} 687}
687 688
688static int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb, 689int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb,
689 u32 cmd_id) 690 u32 cmd_id)
690{ 691{
691 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb); 692 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
692 struct wmi_cmd_hdr *cmd_hdr; 693 struct wmi_cmd_hdr *cmd_hdr;
@@ -792,24 +793,23 @@ int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id)
792 return ret; 793 return ret;
793} 794}
794 795
795int ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *skb) 796static struct sk_buff *
797ath10k_wmi_op_gen_mgmt_tx(struct ath10k *ar, struct sk_buff *msdu)
796{ 798{
797 int ret = 0;
798 struct wmi_mgmt_tx_cmd *cmd; 799 struct wmi_mgmt_tx_cmd *cmd;
799 struct ieee80211_hdr *hdr; 800 struct ieee80211_hdr *hdr;
800 struct sk_buff *wmi_skb; 801 struct sk_buff *skb;
801 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
802 int len; 802 int len;
803 u32 buf_len = skb->len; 803 u32 buf_len = msdu->len;
804 u16 fc; 804 u16 fc;
805 805
806 hdr = (struct ieee80211_hdr *)skb->data; 806 hdr = (struct ieee80211_hdr *)msdu->data;
807 fc = le16_to_cpu(hdr->frame_control); 807 fc = le16_to_cpu(hdr->frame_control);
808 808
809 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control))) 809 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control)))
810 return -EINVAL; 810 return ERR_PTR(-EINVAL);
811 811
812 len = sizeof(cmd->hdr) + skb->len; 812 len = sizeof(cmd->hdr) + msdu->len;
813 813
814 if ((ieee80211_is_action(hdr->frame_control) || 814 if ((ieee80211_is_action(hdr->frame_control) ||
815 ieee80211_is_deauth(hdr->frame_control) || 815 ieee80211_is_deauth(hdr->frame_control) ||
@@ -821,36 +821,27 @@ int ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *skb)
821 821
822 len = round_up(len, 4); 822 len = round_up(len, 4);
823 823
824 wmi_skb = ath10k_wmi_alloc_skb(ar, len); 824 skb = ath10k_wmi_alloc_skb(ar, len);
825 if (!wmi_skb) 825 if (!skb)
826 return -ENOMEM; 826 return ERR_PTR(-ENOMEM);
827 827
828 cmd = (struct wmi_mgmt_tx_cmd *)wmi_skb->data; 828 cmd = (struct wmi_mgmt_tx_cmd *)skb->data;
829 829
830 cmd->hdr.vdev_id = __cpu_to_le32(ATH10K_SKB_CB(skb)->vdev_id); 830 cmd->hdr.vdev_id = __cpu_to_le32(ATH10K_SKB_CB(msdu)->vdev_id);
831 cmd->hdr.tx_rate = 0; 831 cmd->hdr.tx_rate = 0;
832 cmd->hdr.tx_power = 0; 832 cmd->hdr.tx_power = 0;
833 cmd->hdr.buf_len = __cpu_to_le32(buf_len); 833 cmd->hdr.buf_len = __cpu_to_le32(buf_len);
834 834
835 ether_addr_copy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr)); 835 ether_addr_copy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr));
836 memcpy(cmd->buf, skb->data, skb->len); 836 memcpy(cmd->buf, msdu->data, msdu->len);
837 837
838 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n", 838 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n",
839 wmi_skb, wmi_skb->len, fc & IEEE80211_FCTL_FTYPE, 839 msdu, skb->len, fc & IEEE80211_FCTL_FTYPE,
840 fc & IEEE80211_FCTL_STYPE); 840 fc & IEEE80211_FCTL_STYPE);
841 trace_ath10k_tx_hdr(ar, skb->data, skb->len); 841 trace_ath10k_tx_hdr(ar, skb->data, skb->len);
842 trace_ath10k_tx_payload(ar, skb->data, skb->len); 842 trace_ath10k_tx_payload(ar, skb->data, skb->len);
843 843
844 /* Send the management frame buffer to the target */ 844 return skb;
845 ret = ath10k_wmi_cmd_send(ar, wmi_skb, ar->wmi.cmd->mgmt_tx_cmdid);
846 if (ret)
847 return ret;
848
849 /* TODO: report tx status to mac80211 - temporary just ACK */
850 info->flags |= IEEE80211_TX_STAT_ACK;
851 ieee80211_tx_status_irqsafe(ar->hw, skb);
852
853 return ret;
854} 845}
855 846
856static void ath10k_wmi_event_scan_started(struct ath10k *ar) 847static void ath10k_wmi_event_scan_started(struct ath10k *ar)
@@ -977,8 +968,8 @@ ath10k_wmi_event_scan_type_str(enum wmi_scan_event_type type,
977 } 968 }
978} 969}
979 970
980static int ath10k_wmi_pull_scan_ev(struct sk_buff *skb, 971static int ath10k_wmi_op_pull_scan_ev(struct ath10k *ar, struct sk_buff *skb,
981 struct wmi_scan_ev_arg *arg) 972 struct wmi_scan_ev_arg *arg)
982{ 973{
983 struct wmi_scan_event *ev = (void *)skb->data; 974 struct wmi_scan_event *ev = (void *)skb->data;
984 975
@@ -1007,7 +998,7 @@ static int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
1007 u32 vdev_id; 998 u32 vdev_id;
1008 int ret; 999 int ret;
1009 1000
1010 ret = ath10k_wmi_pull_scan_ev(skb, &arg); 1001 ret = ath10k_wmi_pull_scan(ar, skb, &arg);
1011 if (ret) { 1002 if (ret) {
1012 ath10k_warn(ar, "failed to parse scan event: %d\n", ret); 1003 ath10k_warn(ar, "failed to parse scan event: %d\n", ret);
1013 return ret; 1004 return ret;
@@ -1173,9 +1164,8 @@ static void ath10k_wmi_handle_wep_reauth(struct ath10k *ar,
1173 } 1164 }
1174} 1165}
1175 1166
1176static int ath10k_wmi_pull_mgmt_rx_ev(struct sk_buff *skb, 1167static int ath10k_wmi_op_pull_mgmt_rx_ev(struct ath10k *ar, struct sk_buff *skb,
1177 struct wmi_mgmt_rx_ev_arg *arg, 1168 struct wmi_mgmt_rx_ev_arg *arg)
1178 struct ath10k *ar)
1179{ 1169{
1180 struct wmi_mgmt_rx_event_v1 *ev_v1; 1170 struct wmi_mgmt_rx_event_v1 *ev_v1;
1181 struct wmi_mgmt_rx_event_v2 *ev_v2; 1171 struct wmi_mgmt_rx_event_v2 *ev_v2;
@@ -1230,7 +1220,7 @@ static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
1230 u16 fc; 1220 u16 fc;
1231 int ret; 1221 int ret;
1232 1222
1233 ret = ath10k_wmi_pull_mgmt_rx_ev(skb, &arg, ar); 1223 ret = ath10k_wmi_pull_mgmt_rx(ar, skb, &arg);
1234 if (ret) { 1224 if (ret) {
1235 ath10k_warn(ar, "failed to parse mgmt rx event: %d\n", ret); 1225 ath10k_warn(ar, "failed to parse mgmt rx event: %d\n", ret);
1236 return ret; 1226 return ret;
@@ -1350,8 +1340,8 @@ exit:
1350 return idx; 1340 return idx;
1351} 1341}
1352 1342
1353static int ath10k_wmi_pull_ch_info_ev(struct sk_buff *skb, 1343static int ath10k_wmi_op_pull_ch_info_ev(struct ath10k *ar, struct sk_buff *skb,
1354 struct wmi_ch_info_ev_arg *arg) 1344 struct wmi_ch_info_ev_arg *arg)
1355{ 1345{
1356 struct wmi_chan_info_event *ev = (void *)skb->data; 1346 struct wmi_chan_info_event *ev = (void *)skb->data;
1357 1347
@@ -1376,7 +1366,7 @@ static void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb)
1376 u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count; 1366 u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count;
1377 int idx, ret; 1367 int idx, ret;
1378 1368
1379 ret = ath10k_wmi_pull_ch_info_ev(skb, &arg); 1369 ret = ath10k_wmi_pull_ch_info(ar, skb, &arg);
1380 if (ret) { 1370 if (ret) {
1381 ath10k_warn(ar, "failed to parse chan info event: %d\n", ret); 1371 ath10k_warn(ar, "failed to parse chan info event: %d\n", ret);
1382 return; 1372 return;
@@ -1513,9 +1503,9 @@ static void ath10k_wmi_pull_peer_stats(const struct wmi_peer_stats *src,
1513 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate); 1503 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
1514} 1504}
1515 1505
1516static int ath10k_wmi_main_pull_fw_stats(struct ath10k *ar, 1506static int ath10k_wmi_main_op_pull_fw_stats(struct ath10k *ar,
1517 struct sk_buff *skb, 1507 struct sk_buff *skb,
1518 struct ath10k_fw_stats *stats) 1508 struct ath10k_fw_stats *stats)
1519{ 1509{
1520 const struct wmi_stats_event *ev = (void *)skb->data; 1510 const struct wmi_stats_event *ev = (void *)skb->data;
1521 u32 num_pdev_stats, num_vdev_stats, num_peer_stats; 1511 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
@@ -1565,9 +1555,9 @@ static int ath10k_wmi_main_pull_fw_stats(struct ath10k *ar,
1565 return 0; 1555 return 0;
1566} 1556}
1567 1557
1568static int ath10k_wmi_10x_pull_fw_stats(struct ath10k *ar, 1558static int ath10k_wmi_10x_op_pull_fw_stats(struct ath10k *ar,
1569 struct sk_buff *skb, 1559 struct sk_buff *skb,
1570 struct ath10k_fw_stats *stats) 1560 struct ath10k_fw_stats *stats)
1571{ 1561{
1572 const struct wmi_stats_event *ev = (void *)skb->data; 1562 const struct wmi_stats_event *ev = (void *)skb->data;
1573 u32 num_pdev_stats, num_vdev_stats, num_peer_stats; 1563 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
@@ -1628,15 +1618,6 @@ static int ath10k_wmi_10x_pull_fw_stats(struct ath10k *ar,
1628 return 0; 1618 return 0;
1629} 1619}
1630 1620
1631int ath10k_wmi_pull_fw_stats(struct ath10k *ar, struct sk_buff *skb,
1632 struct ath10k_fw_stats *stats)
1633{
1634 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features))
1635 return ath10k_wmi_10x_pull_fw_stats(ar, skb, stats);
1636 else
1637 return ath10k_wmi_main_pull_fw_stats(ar, skb, stats);
1638}
1639
1640static void ath10k_wmi_event_update_stats(struct ath10k *ar, 1621static void ath10k_wmi_event_update_stats(struct ath10k *ar,
1641 struct sk_buff *skb) 1622 struct sk_buff *skb)
1642{ 1623{
@@ -1644,8 +1625,9 @@ static void ath10k_wmi_event_update_stats(struct ath10k *ar,
1644 ath10k_debug_fw_stats_process(ar, skb); 1625 ath10k_debug_fw_stats_process(ar, skb);
1645} 1626}
1646 1627
1647static int ath10k_wmi_pull_vdev_start_ev(struct sk_buff *skb, 1628static int
1648 struct wmi_vdev_start_ev_arg *arg) 1629ath10k_wmi_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
1630 struct wmi_vdev_start_ev_arg *arg)
1649{ 1631{
1650 struct wmi_vdev_start_response_event *ev = (void *)skb->data; 1632 struct wmi_vdev_start_response_event *ev = (void *)skb->data;
1651 1633
@@ -1669,7 +1651,7 @@ static void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar,
1669 1651
1670 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n"); 1652 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n");
1671 1653
1672 ret = ath10k_wmi_pull_vdev_start_ev(skb, &arg); 1654 ret = ath10k_wmi_pull_vdev_start(ar, skb, &arg);
1673 if (ret) { 1655 if (ret) {
1674 ath10k_warn(ar, "failed to parse vdev start event: %d\n", ret); 1656 ath10k_warn(ar, "failed to parse vdev start event: %d\n", ret);
1675 return; 1657 return;
@@ -1688,8 +1670,9 @@ static void ath10k_wmi_event_vdev_stopped(struct ath10k *ar,
1688 complete(&ar->vdev_setup_done); 1670 complete(&ar->vdev_setup_done);
1689} 1671}
1690 1672
1691static int ath10k_wmi_pull_peer_kick_ev(struct sk_buff *skb, 1673static int
1692 struct wmi_peer_kick_ev_arg *arg) 1674ath10k_wmi_op_pull_peer_kick_ev(struct ath10k *ar, struct sk_buff *skb,
1675 struct wmi_peer_kick_ev_arg *arg)
1693{ 1676{
1694 struct wmi_peer_sta_kickout_event *ev = (void *)skb->data; 1677 struct wmi_peer_sta_kickout_event *ev = (void *)skb->data;
1695 1678
@@ -1709,7 +1692,7 @@ static void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar,
1709 struct ieee80211_sta *sta; 1692 struct ieee80211_sta *sta;
1710 int ret; 1693 int ret;
1711 1694
1712 ret = ath10k_wmi_pull_peer_kick_ev(skb, &arg); 1695 ret = ath10k_wmi_pull_peer_kick(ar, skb, &arg);
1713 if (ret) { 1696 if (ret) {
1714 ath10k_warn(ar, "failed to parse peer kickout event: %d\n", 1697 ath10k_warn(ar, "failed to parse peer kickout event: %d\n",
1715 ret); 1698 ret);
@@ -1951,8 +1934,8 @@ cleanup:
1951 kfree(old_data); 1934 kfree(old_data);
1952} 1935}
1953 1936
1954static int ath10k_wmi_pull_swba_ev(struct sk_buff *skb, 1937static int ath10k_wmi_op_pull_swba_ev(struct ath10k *ar, struct sk_buff *skb,
1955 struct wmi_swba_ev_arg *arg) 1938 struct wmi_swba_ev_arg *arg)
1956{ 1939{
1957 struct wmi_host_swba_event *ev = (void *)skb->data; 1940 struct wmi_host_swba_event *ev = (void *)skb->data;
1958 u32 map; 1941 u32 map;
@@ -1994,7 +1977,7 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
1994 dma_addr_t paddr; 1977 dma_addr_t paddr;
1995 int ret, vdev_id = 0; 1978 int ret, vdev_id = 0;
1996 1979
1997 ret = ath10k_wmi_pull_swba_ev(skb, &arg); 1980 ret = ath10k_wmi_pull_swba(ar, skb, &arg);
1998 if (ret) { 1981 if (ret) {
1999 ath10k_warn(ar, "failed to parse swba event: %d\n", ret); 1982 ath10k_warn(ar, "failed to parse swba event: %d\n", ret);
2000 return; 1983 return;
@@ -2345,8 +2328,8 @@ ath10k_wmi_event_spectral_scan(struct ath10k *ar,
2345 } 2328 }
2346} 2329}
2347 2330
2348static int ath10k_wmi_pull_phyerr_ev(struct sk_buff *skb, 2331static int ath10k_wmi_op_pull_phyerr_ev(struct ath10k *ar, struct sk_buff *skb,
2349 struct wmi_phyerr_ev_arg *arg) 2332 struct wmi_phyerr_ev_arg *arg)
2350{ 2333{
2351 struct wmi_phyerr_event *ev = (void *)skb->data; 2334 struct wmi_phyerr_event *ev = (void *)skb->data;
2352 2335
@@ -2372,7 +2355,7 @@ static void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
2372 2355
2373 ATH10K_DFS_STAT_INC(ar, phy_errors); 2356 ATH10K_DFS_STAT_INC(ar, phy_errors);
2374 2357
2375 ret = ath10k_wmi_pull_phyerr_ev(skb, &arg); 2358 ret = ath10k_wmi_pull_phyerr(ar, skb, &arg);
2376 if (ret) { 2359 if (ret) {
2377 ath10k_warn(ar, "failed to parse phyerr event: %d\n", ret); 2360 ath10k_warn(ar, "failed to parse phyerr event: %d\n", ret);
2378 return; 2361 return;
@@ -2608,8 +2591,9 @@ static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id,
2608 return 0; 2591 return 0;
2609} 2592}
2610 2593
2611static int ath10k_wmi_main_pull_svc_rdy_ev(struct sk_buff *skb, 2594static int
2612 struct wmi_svc_rdy_ev_arg *arg) 2595ath10k_wmi_main_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
2596 struct wmi_svc_rdy_ev_arg *arg)
2613{ 2597{
2614 struct wmi_service_ready_event *ev; 2598 struct wmi_service_ready_event *ev;
2615 size_t i, n; 2599 size_t i, n;
@@ -2644,8 +2628,9 @@ static int ath10k_wmi_main_pull_svc_rdy_ev(struct sk_buff *skb,
2644 return 0; 2628 return 0;
2645} 2629}
2646 2630
2647static int ath10k_wmi_10x_pull_svc_rdy_ev(struct sk_buff *skb, 2631static int
2648 struct wmi_svc_rdy_ev_arg *arg) 2632ath10k_wmi_10x_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
2633 struct wmi_svc_rdy_ev_arg *arg)
2649{ 2634{
2650 struct wmi_10x_service_ready_event *ev; 2635 struct wmi_10x_service_ready_event *ev;
2651 int i, n; 2636 int i, n;
@@ -2686,23 +2671,16 @@ static void ath10k_wmi_event_service_ready(struct ath10k *ar,
2686 u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i; 2671 u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i;
2687 int ret; 2672 int ret;
2688 2673
2689 memset(&ar->wmi.svc_map, 0, sizeof(ar->wmi.svc_map)); 2674 ret = ath10k_wmi_pull_svc_rdy(ar, skb, &arg);
2690
2691 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) {
2692 ret = ath10k_wmi_10x_pull_svc_rdy_ev(skb, &arg);
2693 wmi_10x_svc_map(arg.service_map, ar->wmi.svc_map,
2694 arg.service_map_len);
2695 } else {
2696 ret = ath10k_wmi_main_pull_svc_rdy_ev(skb, &arg);
2697 wmi_main_svc_map(arg.service_map, ar->wmi.svc_map,
2698 arg.service_map_len);
2699 }
2700
2701 if (ret) { 2675 if (ret) {
2702 ath10k_warn(ar, "failed to parse service ready: %d\n", ret); 2676 ath10k_warn(ar, "failed to parse service ready: %d\n", ret);
2703 return; 2677 return;
2704 } 2678 }
2705 2679
2680 memset(&ar->wmi.svc_map, 0, sizeof(ar->wmi.svc_map));
2681 ath10k_wmi_map_svc(ar, arg.service_map, ar->wmi.svc_map,
2682 arg.service_map_len);
2683
2706 ar->hw_min_tx_power = __le32_to_cpu(arg.min_tx_power); 2684 ar->hw_min_tx_power = __le32_to_cpu(arg.min_tx_power);
2707 ar->hw_max_tx_power = __le32_to_cpu(arg.max_tx_power); 2685 ar->hw_max_tx_power = __le32_to_cpu(arg.max_tx_power);
2708 ar->ht_cap_info = __le32_to_cpu(arg.ht_cap); 2686 ar->ht_cap_info = __le32_to_cpu(arg.ht_cap);
@@ -2795,8 +2773,8 @@ static void ath10k_wmi_event_service_ready(struct ath10k *ar,
2795 complete(&ar->wmi.service_ready); 2773 complete(&ar->wmi.service_ready);
2796} 2774}
2797 2775
2798static int ath10k_wmi_pull_rdy_ev(struct sk_buff *skb, 2776static int ath10k_wmi_op_pull_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
2799 struct wmi_rdy_ev_arg *arg) 2777 struct wmi_rdy_ev_arg *arg)
2800{ 2778{
2801 struct wmi_ready_event *ev = (void *)skb->data; 2779 struct wmi_ready_event *ev = (void *)skb->data;
2802 2780
@@ -2817,7 +2795,7 @@ static int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb)
2817 struct wmi_rdy_ev_arg arg = {}; 2795 struct wmi_rdy_ev_arg arg = {};
2818 int ret; 2796 int ret;
2819 2797
2820 ret = ath10k_wmi_pull_rdy_ev(skb, &arg); 2798 ret = ath10k_wmi_pull_rdy(ar, skb, &arg);
2821 if (ret) { 2799 if (ret) {
2822 ath10k_warn(ar, "failed to parse ready event: %d\n", ret); 2800 ath10k_warn(ar, "failed to parse ready event: %d\n", ret);
2823 return ret; 2801 return ret;
@@ -2835,7 +2813,7 @@ static int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb)
2835 return 0; 2813 return 0;
2836} 2814}
2837 2815
2838static void ath10k_wmi_main_process_rx(struct ath10k *ar, struct sk_buff *skb) 2816static void ath10k_wmi_op_rx(struct ath10k *ar, struct sk_buff *skb)
2839{ 2817{
2840 struct wmi_cmd_hdr *cmd_hdr; 2818 struct wmi_cmd_hdr *cmd_hdr;
2841 enum wmi_event_id id; 2819 enum wmi_event_id id;
@@ -2951,7 +2929,7 @@ static void ath10k_wmi_main_process_rx(struct ath10k *ar, struct sk_buff *skb)
2951 dev_kfree_skb(skb); 2929 dev_kfree_skb(skb);
2952} 2930}
2953 2931
2954static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb) 2932static void ath10k_wmi_10_1_op_rx(struct ath10k *ar, struct sk_buff *skb)
2955{ 2933{
2956 struct wmi_cmd_hdr *cmd_hdr; 2934 struct wmi_cmd_hdr *cmd_hdr;
2957 enum wmi_10x_event_id id; 2935 enum wmi_10x_event_id id;
@@ -3075,7 +3053,7 @@ out:
3075 dev_kfree_skb(skb); 3053 dev_kfree_skb(skb);
3076} 3054}
3077 3055
3078static void ath10k_wmi_10_2_process_rx(struct ath10k *ar, struct sk_buff *skb) 3056static void ath10k_wmi_10_2_op_rx(struct ath10k *ar, struct sk_buff *skb)
3079{ 3057{
3080 struct wmi_cmd_hdr *cmd_hdr; 3058 struct wmi_cmd_hdr *cmd_hdr;
3081 enum wmi_10_2_event_id id; 3059 enum wmi_10_2_event_id id;
@@ -3194,14 +3172,11 @@ static void ath10k_wmi_10_2_process_rx(struct ath10k *ar, struct sk_buff *skb)
3194 3172
3195static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb) 3173static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb)
3196{ 3174{
3197 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { 3175 int ret;
3198 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) 3176
3199 ath10k_wmi_10_2_process_rx(ar, skb); 3177 ret = ath10k_wmi_rx(ar, skb);
3200 else 3178 if (ret)
3201 ath10k_wmi_10x_process_rx(ar, skb); 3179 ath10k_warn(ar, "failed to process wmi rx: %d\n", ret);
3202 } else {
3203 ath10k_wmi_main_process_rx(ar, skb);
3204 }
3205} 3180}
3206 3181
3207int ath10k_wmi_connect(struct ath10k *ar) 3182int ath10k_wmi_connect(struct ath10k *ar)
@@ -3232,16 +3207,17 @@ int ath10k_wmi_connect(struct ath10k *ar)
3232 return 0; 3207 return 0;
3233} 3208}
3234 3209
3235static int ath10k_wmi_main_pdev_set_regdomain(struct ath10k *ar, u16 rd, 3210static struct sk_buff *
3236 u16 rd2g, u16 rd5g, u16 ctl2g, 3211ath10k_wmi_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
3237 u16 ctl5g) 3212 u16 ctl2g, u16 ctl5g,
3213 enum wmi_dfs_region dfs_reg)
3238{ 3214{
3239 struct wmi_pdev_set_regdomain_cmd *cmd; 3215 struct wmi_pdev_set_regdomain_cmd *cmd;
3240 struct sk_buff *skb; 3216 struct sk_buff *skb;
3241 3217
3242 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3218 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
3243 if (!skb) 3219 if (!skb)
3244 return -ENOMEM; 3220 return ERR_PTR(-ENOMEM);
3245 3221
3246 cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data; 3222 cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data;
3247 cmd->reg_domain = __cpu_to_le32(rd); 3223 cmd->reg_domain = __cpu_to_le32(rd);
@@ -3253,22 +3229,20 @@ static int ath10k_wmi_main_pdev_set_regdomain(struct ath10k *ar, u16 rd,
3253 ath10k_dbg(ar, ATH10K_DBG_WMI, 3229 ath10k_dbg(ar, ATH10K_DBG_WMI,
3254 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n", 3230 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n",
3255 rd, rd2g, rd5g, ctl2g, ctl5g); 3231 rd, rd2g, rd5g, ctl2g, ctl5g);
3256 3232 return skb;
3257 return ath10k_wmi_cmd_send(ar, skb,
3258 ar->wmi.cmd->pdev_set_regdomain_cmdid);
3259} 3233}
3260 3234
3261static int ath10k_wmi_10x_pdev_set_regdomain(struct ath10k *ar, u16 rd, 3235static struct sk_buff *
3262 u16 rd2g, u16 rd5g, 3236ath10k_wmi_10x_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16
3263 u16 ctl2g, u16 ctl5g, 3237 rd5g, u16 ctl2g, u16 ctl5g,
3264 enum wmi_dfs_region dfs_reg) 3238 enum wmi_dfs_region dfs_reg)
3265{ 3239{
3266 struct wmi_pdev_set_regdomain_cmd_10x *cmd; 3240 struct wmi_pdev_set_regdomain_cmd_10x *cmd;
3267 struct sk_buff *skb; 3241 struct sk_buff *skb;
3268 3242
3269 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3243 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
3270 if (!skb) 3244 if (!skb)
3271 return -ENOMEM; 3245 return ERR_PTR(-ENOMEM);
3272 3246
3273 cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data; 3247 cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data;
3274 cmd->reg_domain = __cpu_to_le32(rd); 3248 cmd->reg_domain = __cpu_to_le32(rd);
@@ -3281,50 +3255,39 @@ static int ath10k_wmi_10x_pdev_set_regdomain(struct ath10k *ar, u16 rd,
3281 ath10k_dbg(ar, ATH10K_DBG_WMI, 3255 ath10k_dbg(ar, ATH10K_DBG_WMI,
3282 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n", 3256 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n",
3283 rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg); 3257 rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg);
3284 3258 return skb;
3285 return ath10k_wmi_cmd_send(ar, skb,
3286 ar->wmi.cmd->pdev_set_regdomain_cmdid);
3287}
3288
3289int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g,
3290 u16 rd5g, u16 ctl2g, u16 ctl5g,
3291 enum wmi_dfs_region dfs_reg)
3292{
3293 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features))
3294 return ath10k_wmi_10x_pdev_set_regdomain(ar, rd, rd2g, rd5g,
3295 ctl2g, ctl5g, dfs_reg);
3296 else
3297 return ath10k_wmi_main_pdev_set_regdomain(ar, rd, rd2g, rd5g,
3298 ctl2g, ctl5g);
3299} 3259}
3300 3260
3301int ath10k_wmi_pdev_suspend_target(struct ath10k *ar, u32 suspend_opt) 3261static struct sk_buff *
3262ath10k_wmi_op_gen_pdev_suspend(struct ath10k *ar, u32 suspend_opt)
3302{ 3263{
3303 struct wmi_pdev_suspend_cmd *cmd; 3264 struct wmi_pdev_suspend_cmd *cmd;
3304 struct sk_buff *skb; 3265 struct sk_buff *skb;
3305 3266
3306 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3267 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
3307 if (!skb) 3268 if (!skb)
3308 return -ENOMEM; 3269 return ERR_PTR(-ENOMEM);
3309 3270
3310 cmd = (struct wmi_pdev_suspend_cmd *)skb->data; 3271 cmd = (struct wmi_pdev_suspend_cmd *)skb->data;
3311 cmd->suspend_opt = __cpu_to_le32(suspend_opt); 3272 cmd->suspend_opt = __cpu_to_le32(suspend_opt);
3312 3273
3313 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_suspend_cmdid); 3274 return skb;
3314} 3275}
3315 3276
3316int ath10k_wmi_pdev_resume_target(struct ath10k *ar) 3277static struct sk_buff *
3278ath10k_wmi_op_gen_pdev_resume(struct ath10k *ar)
3317{ 3279{
3318 struct sk_buff *skb; 3280 struct sk_buff *skb;
3319 3281
3320 skb = ath10k_wmi_alloc_skb(ar, 0); 3282 skb = ath10k_wmi_alloc_skb(ar, 0);
3321 if (skb == NULL) 3283 if (!skb)
3322 return -ENOMEM; 3284 return ERR_PTR(-ENOMEM);
3323 3285
3324 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_resume_cmdid); 3286 return skb;
3325} 3287}
3326 3288
3327int ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value) 3289static struct sk_buff *
3290ath10k_wmi_op_gen_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
3328{ 3291{
3329 struct wmi_pdev_set_param_cmd *cmd; 3292 struct wmi_pdev_set_param_cmd *cmd;
3330 struct sk_buff *skb; 3293 struct sk_buff *skb;
@@ -3332,12 +3295,12 @@ int ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
3332 if (id == WMI_PDEV_PARAM_UNSUPPORTED) { 3295 if (id == WMI_PDEV_PARAM_UNSUPPORTED) {
3333 ath10k_warn(ar, "pdev param %d not supported by firmware\n", 3296 ath10k_warn(ar, "pdev param %d not supported by firmware\n",
3334 id); 3297 id);
3335 return -EOPNOTSUPP; 3298 return ERR_PTR(-EOPNOTSUPP);
3336 } 3299 }
3337 3300
3338 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3301 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
3339 if (!skb) 3302 if (!skb)
3340 return -ENOMEM; 3303 return ERR_PTR(-ENOMEM);
3341 3304
3342 cmd = (struct wmi_pdev_set_param_cmd *)skb->data; 3305 cmd = (struct wmi_pdev_set_param_cmd *)skb->data;
3343 cmd->param_id = __cpu_to_le32(id); 3306 cmd->param_id = __cpu_to_le32(id);
@@ -3345,7 +3308,7 @@ int ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
3345 3308
3346 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n", 3309 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n",
3347 id, value); 3310 id, value);
3348 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_set_param_cmdid); 3311 return skb;
3349} 3312}
3350 3313
3351static void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar, 3314static void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar,
@@ -3370,7 +3333,7 @@ static void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar,
3370 } 3333 }
3371} 3334}
3372 3335
3373static int ath10k_wmi_main_cmd_init(struct ath10k *ar) 3336static struct sk_buff *ath10k_wmi_op_gen_init(struct ath10k *ar)
3374{ 3337{
3375 struct wmi_init_cmd *cmd; 3338 struct wmi_init_cmd *cmd;
3376 struct sk_buff *buf; 3339 struct sk_buff *buf;
@@ -3433,7 +3396,7 @@ static int ath10k_wmi_main_cmd_init(struct ath10k *ar)
3433 3396
3434 buf = ath10k_wmi_alloc_skb(ar, len); 3397 buf = ath10k_wmi_alloc_skb(ar, len);
3435 if (!buf) 3398 if (!buf)
3436 return -ENOMEM; 3399 return ERR_PTR(-ENOMEM);
3437 3400
3438 cmd = (struct wmi_init_cmd *)buf->data; 3401 cmd = (struct wmi_init_cmd *)buf->data;
3439 3402
@@ -3441,10 +3404,10 @@ static int ath10k_wmi_main_cmd_init(struct ath10k *ar)
3441 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); 3404 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
3442 3405
3443 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n"); 3406 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n");
3444 return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); 3407 return buf;
3445} 3408}
3446 3409
3447static int ath10k_wmi_10x_cmd_init(struct ath10k *ar) 3410static struct sk_buff *ath10k_wmi_10_1_op_gen_init(struct ath10k *ar)
3448{ 3411{
3449 struct wmi_init_cmd_10x *cmd; 3412 struct wmi_init_cmd_10x *cmd;
3450 struct sk_buff *buf; 3413 struct sk_buff *buf;
@@ -3499,7 +3462,7 @@ static int ath10k_wmi_10x_cmd_init(struct ath10k *ar)
3499 3462
3500 buf = ath10k_wmi_alloc_skb(ar, len); 3463 buf = ath10k_wmi_alloc_skb(ar, len);
3501 if (!buf) 3464 if (!buf)
3502 return -ENOMEM; 3465 return ERR_PTR(-ENOMEM);
3503 3466
3504 cmd = (struct wmi_init_cmd_10x *)buf->data; 3467 cmd = (struct wmi_init_cmd_10x *)buf->data;
3505 3468
@@ -3507,10 +3470,10 @@ static int ath10k_wmi_10x_cmd_init(struct ath10k *ar)
3507 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); 3470 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
3508 3471
3509 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n"); 3472 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n");
3510 return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); 3473 return buf;
3511} 3474}
3512 3475
3513static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar) 3476static struct sk_buff *ath10k_wmi_10_2_op_gen_init(struct ath10k *ar)
3514{ 3477{
3515 struct wmi_init_cmd_10_2 *cmd; 3478 struct wmi_init_cmd_10_2 *cmd;
3516 struct sk_buff *buf; 3479 struct sk_buff *buf;
@@ -3565,7 +3528,7 @@ static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar)
3565 3528
3566 buf = ath10k_wmi_alloc_skb(ar, len); 3529 buf = ath10k_wmi_alloc_skb(ar, len);
3567 if (!buf) 3530 if (!buf)
3568 return -ENOMEM; 3531 return ERR_PTR(-ENOMEM);
3569 3532
3570 cmd = (struct wmi_init_cmd_10_2 *)buf->data; 3533 cmd = (struct wmi_init_cmd_10_2 *)buf->data;
3571 3534
@@ -3573,23 +3536,7 @@ static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar)
3573 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); 3536 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
3574 3537
3575 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n"); 3538 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n");
3576 return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); 3539 return buf;
3577}
3578
3579int ath10k_wmi_cmd_init(struct ath10k *ar)
3580{
3581 int ret;
3582
3583 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) {
3584 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features))
3585 ret = ath10k_wmi_10_2_cmd_init(ar);
3586 else
3587 ret = ath10k_wmi_10x_cmd_init(ar);
3588 } else {
3589 ret = ath10k_wmi_main_cmd_init(ar);
3590 }
3591
3592 return ret;
3593} 3540}
3594 3541
3595static int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg) 3542static int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg)
@@ -3739,46 +3686,60 @@ ath10k_wmi_put_start_scan_tlvs(struct wmi_start_scan_tlvs *tlvs,
3739 } 3686 }
3740} 3687}
3741 3688
3742int ath10k_wmi_start_scan(struct ath10k *ar, 3689static struct sk_buff *
3743 const struct wmi_start_scan_arg *arg) 3690ath10k_wmi_op_gen_start_scan(struct ath10k *ar,
3691 const struct wmi_start_scan_arg *arg)
3744{ 3692{
3693 struct wmi_start_scan_cmd *cmd;
3745 struct sk_buff *skb; 3694 struct sk_buff *skb;
3746 size_t len; 3695 size_t len;
3747 int ret; 3696 int ret;
3748 3697
3749 ret = ath10k_wmi_start_scan_verify(arg); 3698 ret = ath10k_wmi_start_scan_verify(arg);
3750 if (ret) 3699 if (ret)
3751 return ret; 3700 return ERR_PTR(ret);
3752
3753 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features))
3754 len = sizeof(struct wmi_10x_start_scan_cmd) +
3755 ath10k_wmi_start_scan_tlvs_len(arg);
3756 else
3757 len = sizeof(struct wmi_start_scan_cmd) +
3758 ath10k_wmi_start_scan_tlvs_len(arg);
3759 3701
3702 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
3760 skb = ath10k_wmi_alloc_skb(ar, len); 3703 skb = ath10k_wmi_alloc_skb(ar, len);
3761 if (!skb) 3704 if (!skb)
3762 return -ENOMEM; 3705 return ERR_PTR(-ENOMEM);
3763 3706
3764 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { 3707 cmd = (struct wmi_start_scan_cmd *)skb->data;
3765 struct wmi_10x_start_scan_cmd *cmd;
3766
3767 cmd = (struct wmi_10x_start_scan_cmd *)skb->data;
3768 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
3769 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
3770 } else {
3771 struct wmi_start_scan_cmd *cmd;
3772 3708
3773 cmd = (struct wmi_start_scan_cmd *)skb->data; 3709 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
3774 cmd->burst_duration_ms = __cpu_to_le32(0); 3710 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
3775 3711
3776 ath10k_wmi_put_start_scan_common(&cmd->common, arg); 3712 cmd->burst_duration_ms = __cpu_to_le32(0);
3777 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
3778 }
3779 3713
3780 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n"); 3714 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n");
3781 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->start_scan_cmdid); 3715 return skb;
3716}
3717
3718static struct sk_buff *
3719ath10k_wmi_10x_op_gen_start_scan(struct ath10k *ar,
3720 const struct wmi_start_scan_arg *arg)
3721{
3722 struct wmi_10x_start_scan_cmd *cmd;
3723 struct sk_buff *skb;
3724 size_t len;
3725 int ret;
3726
3727 ret = ath10k_wmi_start_scan_verify(arg);
3728 if (ret)
3729 return ERR_PTR(ret);
3730
3731 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
3732 skb = ath10k_wmi_alloc_skb(ar, len);
3733 if (!skb)
3734 return ERR_PTR(-ENOMEM);
3735
3736 cmd = (struct wmi_10x_start_scan_cmd *)skb->data;
3737
3738 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
3739 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
3740
3741 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi 10x start scan\n");
3742 return skb;
3782} 3743}
3783 3744
3784void ath10k_wmi_start_scan_init(struct ath10k *ar, 3745void ath10k_wmi_start_scan_init(struct ath10k *ar,
@@ -3807,7 +3768,9 @@ void ath10k_wmi_start_scan_init(struct ath10k *ar,
3807 arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF"; 3768 arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF";
3808} 3769}
3809 3770
3810int ath10k_wmi_stop_scan(struct ath10k *ar, const struct wmi_stop_scan_arg *arg) 3771static struct sk_buff *
3772ath10k_wmi_op_gen_stop_scan(struct ath10k *ar,
3773 const struct wmi_stop_scan_arg *arg)
3811{ 3774{
3812 struct wmi_stop_scan_cmd *cmd; 3775 struct wmi_stop_scan_cmd *cmd;
3813 struct sk_buff *skb; 3776 struct sk_buff *skb;
@@ -3815,13 +3778,13 @@ int ath10k_wmi_stop_scan(struct ath10k *ar, const struct wmi_stop_scan_arg *arg)
3815 u32 req_id; 3778 u32 req_id;
3816 3779
3817 if (arg->req_id > 0xFFF) 3780 if (arg->req_id > 0xFFF)
3818 return -EINVAL; 3781 return ERR_PTR(-EINVAL);
3819 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF) 3782 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
3820 return -EINVAL; 3783 return ERR_PTR(-EINVAL);
3821 3784
3822 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3785 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
3823 if (!skb) 3786 if (!skb)
3824 return -ENOMEM; 3787 return ERR_PTR(-ENOMEM);
3825 3788
3826 scan_id = arg->u.scan_id; 3789 scan_id = arg->u.scan_id;
3827 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX; 3790 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
@@ -3838,20 +3801,21 @@ int ath10k_wmi_stop_scan(struct ath10k *ar, const struct wmi_stop_scan_arg *arg)
3838 ath10k_dbg(ar, ATH10K_DBG_WMI, 3801 ath10k_dbg(ar, ATH10K_DBG_WMI,
3839 "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n", 3802 "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n",
3840 arg->req_id, arg->req_type, arg->u.scan_id); 3803 arg->req_id, arg->req_type, arg->u.scan_id);
3841 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->stop_scan_cmdid); 3804 return skb;
3842} 3805}
3843 3806
3844int ath10k_wmi_vdev_create(struct ath10k *ar, u32 vdev_id, 3807static struct sk_buff *
3845 enum wmi_vdev_type type, 3808ath10k_wmi_op_gen_vdev_create(struct ath10k *ar, u32 vdev_id,
3846 enum wmi_vdev_subtype subtype, 3809 enum wmi_vdev_type type,
3847 const u8 macaddr[ETH_ALEN]) 3810 enum wmi_vdev_subtype subtype,
3811 const u8 macaddr[ETH_ALEN])
3848{ 3812{
3849 struct wmi_vdev_create_cmd *cmd; 3813 struct wmi_vdev_create_cmd *cmd;
3850 struct sk_buff *skb; 3814 struct sk_buff *skb;
3851 3815
3852 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3816 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
3853 if (!skb) 3817 if (!skb)
3854 return -ENOMEM; 3818 return ERR_PTR(-ENOMEM);
3855 3819
3856 cmd = (struct wmi_vdev_create_cmd *)skb->data; 3820 cmd = (struct wmi_vdev_create_cmd *)skb->data;
3857 cmd->vdev_id = __cpu_to_le32(vdev_id); 3821 cmd->vdev_id = __cpu_to_le32(vdev_id);
@@ -3862,58 +3826,52 @@ int ath10k_wmi_vdev_create(struct ath10k *ar, u32 vdev_id,
3862 ath10k_dbg(ar, ATH10K_DBG_WMI, 3826 ath10k_dbg(ar, ATH10K_DBG_WMI,
3863 "WMI vdev create: id %d type %d subtype %d macaddr %pM\n", 3827 "WMI vdev create: id %d type %d subtype %d macaddr %pM\n",
3864 vdev_id, type, subtype, macaddr); 3828 vdev_id, type, subtype, macaddr);
3865 3829 return skb;
3866 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_create_cmdid);
3867} 3830}
3868 3831
3869int ath10k_wmi_vdev_delete(struct ath10k *ar, u32 vdev_id) 3832static struct sk_buff *
3833ath10k_wmi_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
3870{ 3834{
3871 struct wmi_vdev_delete_cmd *cmd; 3835 struct wmi_vdev_delete_cmd *cmd;
3872 struct sk_buff *skb; 3836 struct sk_buff *skb;
3873 3837
3874 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3838 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
3875 if (!skb) 3839 if (!skb)
3876 return -ENOMEM; 3840 return ERR_PTR(-ENOMEM);
3877 3841
3878 cmd = (struct wmi_vdev_delete_cmd *)skb->data; 3842 cmd = (struct wmi_vdev_delete_cmd *)skb->data;
3879 cmd->vdev_id = __cpu_to_le32(vdev_id); 3843 cmd->vdev_id = __cpu_to_le32(vdev_id);
3880 3844
3881 ath10k_dbg(ar, ATH10K_DBG_WMI, 3845 ath10k_dbg(ar, ATH10K_DBG_WMI,
3882 "WMI vdev delete id %d\n", vdev_id); 3846 "WMI vdev delete id %d\n", vdev_id);
3883 3847 return skb;
3884 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_delete_cmdid);
3885} 3848}
3886 3849
3887static int 3850static struct sk_buff *
3888ath10k_wmi_vdev_start_restart(struct ath10k *ar, 3851ath10k_wmi_op_gen_vdev_start(struct ath10k *ar,
3889 const struct wmi_vdev_start_request_arg *arg, 3852 const struct wmi_vdev_start_request_arg *arg,
3890 u32 cmd_id) 3853 bool restart)
3891{ 3854{
3892 struct wmi_vdev_start_request_cmd *cmd; 3855 struct wmi_vdev_start_request_cmd *cmd;
3893 struct sk_buff *skb; 3856 struct sk_buff *skb;
3894 const char *cmdname; 3857 const char *cmdname;
3895 u32 flags = 0; 3858 u32 flags = 0;
3896 3859
3897 if (cmd_id != ar->wmi.cmd->vdev_start_request_cmdid &&
3898 cmd_id != ar->wmi.cmd->vdev_restart_request_cmdid)
3899 return -EINVAL;
3900 if (WARN_ON(arg->ssid && arg->ssid_len == 0)) 3860 if (WARN_ON(arg->ssid && arg->ssid_len == 0))
3901 return -EINVAL; 3861 return ERR_PTR(-EINVAL);
3902 if (WARN_ON(arg->hidden_ssid && !arg->ssid)) 3862 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
3903 return -EINVAL; 3863 return ERR_PTR(-EINVAL);
3904 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid))) 3864 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
3905 return -EINVAL; 3865 return ERR_PTR(-EINVAL);
3906 3866
3907 if (cmd_id == ar->wmi.cmd->vdev_start_request_cmdid) 3867 if (restart)
3908 cmdname = "start";
3909 else if (cmd_id == ar->wmi.cmd->vdev_restart_request_cmdid)
3910 cmdname = "restart"; 3868 cmdname = "restart";
3911 else 3869 else
3912 return -EINVAL; /* should not happen, we already check cmd_id */ 3870 cmdname = "start";
3913 3871
3914 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3872 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
3915 if (!skb) 3873 if (!skb)
3916 return -ENOMEM; 3874 return ERR_PTR(-ENOMEM);
3917 3875
3918 if (arg->hidden_ssid) 3876 if (arg->hidden_ssid)
3919 flags |= WMI_VDEV_START_HIDDEN_SSID; 3877 flags |= WMI_VDEV_START_HIDDEN_SSID;
@@ -3942,50 +3900,36 @@ ath10k_wmi_vdev_start_restart(struct ath10k *ar,
3942 flags, arg->channel.freq, arg->channel.mode, 3900 flags, arg->channel.freq, arg->channel.mode,
3943 cmd->chan.flags, arg->channel.max_power); 3901 cmd->chan.flags, arg->channel.max_power);
3944 3902
3945 return ath10k_wmi_cmd_send(ar, skb, cmd_id); 3903 return skb;
3946}
3947
3948int ath10k_wmi_vdev_start(struct ath10k *ar,
3949 const struct wmi_vdev_start_request_arg *arg)
3950{
3951 u32 cmd_id = ar->wmi.cmd->vdev_start_request_cmdid;
3952
3953 return ath10k_wmi_vdev_start_restart(ar, arg, cmd_id);
3954}
3955
3956int ath10k_wmi_vdev_restart(struct ath10k *ar,
3957 const struct wmi_vdev_start_request_arg *arg)
3958{
3959 u32 cmd_id = ar->wmi.cmd->vdev_restart_request_cmdid;
3960
3961 return ath10k_wmi_vdev_start_restart(ar, arg, cmd_id);
3962} 3904}
3963 3905
3964int ath10k_wmi_vdev_stop(struct ath10k *ar, u32 vdev_id) 3906static struct sk_buff *
3907ath10k_wmi_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
3965{ 3908{
3966 struct wmi_vdev_stop_cmd *cmd; 3909 struct wmi_vdev_stop_cmd *cmd;
3967 struct sk_buff *skb; 3910 struct sk_buff *skb;
3968 3911
3969 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3912 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
3970 if (!skb) 3913 if (!skb)
3971 return -ENOMEM; 3914 return ERR_PTR(-ENOMEM);
3972 3915
3973 cmd = (struct wmi_vdev_stop_cmd *)skb->data; 3916 cmd = (struct wmi_vdev_stop_cmd *)skb->data;
3974 cmd->vdev_id = __cpu_to_le32(vdev_id); 3917 cmd->vdev_id = __cpu_to_le32(vdev_id);
3975 3918
3976 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id); 3919 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id);
3977 3920 return skb;
3978 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_stop_cmdid);
3979} 3921}
3980 3922
3981int ath10k_wmi_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid, const u8 *bssid) 3923static struct sk_buff *
3924ath10k_wmi_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
3925 const u8 *bssid)
3982{ 3926{
3983 struct wmi_vdev_up_cmd *cmd; 3927 struct wmi_vdev_up_cmd *cmd;
3984 struct sk_buff *skb; 3928 struct sk_buff *skb;
3985 3929
3986 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3930 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
3987 if (!skb) 3931 if (!skb)
3988 return -ENOMEM; 3932 return ERR_PTR(-ENOMEM);
3989 3933
3990 cmd = (struct wmi_vdev_up_cmd *)skb->data; 3934 cmd = (struct wmi_vdev_up_cmd *)skb->data;
3991 cmd->vdev_id = __cpu_to_le32(vdev_id); 3935 cmd->vdev_id = __cpu_to_le32(vdev_id);
@@ -3995,30 +3939,30 @@ int ath10k_wmi_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid, const u8 *bssid)
3995 ath10k_dbg(ar, ATH10K_DBG_WMI, 3939 ath10k_dbg(ar, ATH10K_DBG_WMI,
3996 "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n", 3940 "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
3997 vdev_id, aid, bssid); 3941 vdev_id, aid, bssid);
3998 3942 return skb;
3999 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_up_cmdid);
4000} 3943}
4001 3944
4002int ath10k_wmi_vdev_down(struct ath10k *ar, u32 vdev_id) 3945static struct sk_buff *
3946ath10k_wmi_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
4003{ 3947{
4004 struct wmi_vdev_down_cmd *cmd; 3948 struct wmi_vdev_down_cmd *cmd;
4005 struct sk_buff *skb; 3949 struct sk_buff *skb;
4006 3950
4007 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3951 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4008 if (!skb) 3952 if (!skb)
4009 return -ENOMEM; 3953 return ERR_PTR(-ENOMEM);
4010 3954
4011 cmd = (struct wmi_vdev_down_cmd *)skb->data; 3955 cmd = (struct wmi_vdev_down_cmd *)skb->data;
4012 cmd->vdev_id = __cpu_to_le32(vdev_id); 3956 cmd->vdev_id = __cpu_to_le32(vdev_id);
4013 3957
4014 ath10k_dbg(ar, ATH10K_DBG_WMI, 3958 ath10k_dbg(ar, ATH10K_DBG_WMI,
4015 "wmi mgmt vdev down id 0x%x\n", vdev_id); 3959 "wmi mgmt vdev down id 0x%x\n", vdev_id);
4016 3960 return skb;
4017 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_down_cmdid);
4018} 3961}
4019 3962
4020int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id, 3963static struct sk_buff *
4021 u32 param_id, u32 param_value) 3964ath10k_wmi_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
3965 u32 param_id, u32 param_value)
4022{ 3966{
4023 struct wmi_vdev_set_param_cmd *cmd; 3967 struct wmi_vdev_set_param_cmd *cmd;
4024 struct sk_buff *skb; 3968 struct sk_buff *skb;
@@ -4027,12 +3971,12 @@ int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id,
4027 ath10k_dbg(ar, ATH10K_DBG_WMI, 3971 ath10k_dbg(ar, ATH10K_DBG_WMI,
4028 "vdev param %d not supported by firmware\n", 3972 "vdev param %d not supported by firmware\n",
4029 param_id); 3973 param_id);
4030 return -EOPNOTSUPP; 3974 return ERR_PTR(-EOPNOTSUPP);
4031 } 3975 }
4032 3976
4033 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 3977 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4034 if (!skb) 3978 if (!skb)
4035 return -ENOMEM; 3979 return ERR_PTR(-ENOMEM);
4036 3980
4037 cmd = (struct wmi_vdev_set_param_cmd *)skb->data; 3981 cmd = (struct wmi_vdev_set_param_cmd *)skb->data;
4038 cmd->vdev_id = __cpu_to_le32(vdev_id); 3982 cmd->vdev_id = __cpu_to_le32(vdev_id);
@@ -4042,24 +3986,24 @@ int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id,
4042 ath10k_dbg(ar, ATH10K_DBG_WMI, 3986 ath10k_dbg(ar, ATH10K_DBG_WMI,
4043 "wmi vdev id 0x%x set param %d value %d\n", 3987 "wmi vdev id 0x%x set param %d value %d\n",
4044 vdev_id, param_id, param_value); 3988 vdev_id, param_id, param_value);
4045 3989 return skb;
4046 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_set_param_cmdid);
4047} 3990}
4048 3991
4049int ath10k_wmi_vdev_install_key(struct ath10k *ar, 3992static struct sk_buff *
4050 const struct wmi_vdev_install_key_arg *arg) 3993ath10k_wmi_op_gen_vdev_install_key(struct ath10k *ar,
3994 const struct wmi_vdev_install_key_arg *arg)
4051{ 3995{
4052 struct wmi_vdev_install_key_cmd *cmd; 3996 struct wmi_vdev_install_key_cmd *cmd;
4053 struct sk_buff *skb; 3997 struct sk_buff *skb;
4054 3998
4055 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL) 3999 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
4056 return -EINVAL; 4000 return ERR_PTR(-EINVAL);
4057 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL) 4001 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
4058 return -EINVAL; 4002 return ERR_PTR(-EINVAL);
4059 4003
4060 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len); 4004 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len);
4061 if (!skb) 4005 if (!skb)
4062 return -ENOMEM; 4006 return ERR_PTR(-ENOMEM);
4063 4007
4064 cmd = (struct wmi_vdev_install_key_cmd *)skb->data; 4008 cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
4065 cmd->vdev_id = __cpu_to_le32(arg->vdev_id); 4009 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
@@ -4078,20 +4022,19 @@ int ath10k_wmi_vdev_install_key(struct ath10k *ar,
4078 ath10k_dbg(ar, ATH10K_DBG_WMI, 4022 ath10k_dbg(ar, ATH10K_DBG_WMI,
4079 "wmi vdev install key idx %d cipher %d len %d\n", 4023 "wmi vdev install key idx %d cipher %d len %d\n",
4080 arg->key_idx, arg->key_cipher, arg->key_len); 4024 arg->key_idx, arg->key_cipher, arg->key_len);
4081 return ath10k_wmi_cmd_send(ar, skb, 4025 return skb;
4082 ar->wmi.cmd->vdev_install_key_cmdid);
4083} 4026}
4084 4027
4085int ath10k_wmi_vdev_spectral_conf(struct ath10k *ar, 4028static struct sk_buff *
4086 const struct wmi_vdev_spectral_conf_arg *arg) 4029ath10k_wmi_op_gen_vdev_spectral_conf(struct ath10k *ar,
4030 const struct wmi_vdev_spectral_conf_arg *arg)
4087{ 4031{
4088 struct wmi_vdev_spectral_conf_cmd *cmd; 4032 struct wmi_vdev_spectral_conf_cmd *cmd;
4089 struct sk_buff *skb; 4033 struct sk_buff *skb;
4090 u32 cmdid;
4091 4034
4092 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4035 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4093 if (!skb) 4036 if (!skb)
4094 return -ENOMEM; 4037 return ERR_PTR(-ENOMEM);
4095 4038
4096 cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data; 4039 cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data;
4097 cmd->vdev_id = __cpu_to_le32(arg->vdev_id); 4040 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
@@ -4114,39 +4057,38 @@ int ath10k_wmi_vdev_spectral_conf(struct ath10k *ar,
4114 cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj); 4057 cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj);
4115 cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask); 4058 cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask);
4116 4059
4117 cmdid = ar->wmi.cmd->vdev_spectral_scan_configure_cmdid; 4060 return skb;
4118 return ath10k_wmi_cmd_send(ar, skb, cmdid);
4119} 4061}
4120 4062
4121int ath10k_wmi_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, u32 trigger, 4063static struct sk_buff *
4122 u32 enable) 4064ath10k_wmi_op_gen_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id,
4065 u32 trigger, u32 enable)
4123{ 4066{
4124 struct wmi_vdev_spectral_enable_cmd *cmd; 4067 struct wmi_vdev_spectral_enable_cmd *cmd;
4125 struct sk_buff *skb; 4068 struct sk_buff *skb;
4126 u32 cmdid;
4127 4069
4128 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4070 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4129 if (!skb) 4071 if (!skb)
4130 return -ENOMEM; 4072 return ERR_PTR(-ENOMEM);
4131 4073
4132 cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data; 4074 cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data;
4133 cmd->vdev_id = __cpu_to_le32(vdev_id); 4075 cmd->vdev_id = __cpu_to_le32(vdev_id);
4134 cmd->trigger_cmd = __cpu_to_le32(trigger); 4076 cmd->trigger_cmd = __cpu_to_le32(trigger);
4135 cmd->enable_cmd = __cpu_to_le32(enable); 4077 cmd->enable_cmd = __cpu_to_le32(enable);
4136 4078
4137 cmdid = ar->wmi.cmd->vdev_spectral_scan_enable_cmdid; 4079 return skb;
4138 return ath10k_wmi_cmd_send(ar, skb, cmdid);
4139} 4080}
4140 4081
4141int ath10k_wmi_peer_create(struct ath10k *ar, u32 vdev_id, 4082static struct sk_buff *
4142 const u8 peer_addr[ETH_ALEN]) 4083ath10k_wmi_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
4084 const u8 peer_addr[ETH_ALEN])
4143{ 4085{
4144 struct wmi_peer_create_cmd *cmd; 4086 struct wmi_peer_create_cmd *cmd;
4145 struct sk_buff *skb; 4087 struct sk_buff *skb;
4146 4088
4147 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4089 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4148 if (!skb) 4090 if (!skb)
4149 return -ENOMEM; 4091 return ERR_PTR(-ENOMEM);
4150 4092
4151 cmd = (struct wmi_peer_create_cmd *)skb->data; 4093 cmd = (struct wmi_peer_create_cmd *)skb->data;
4152 cmd->vdev_id = __cpu_to_le32(vdev_id); 4094 cmd->vdev_id = __cpu_to_le32(vdev_id);
@@ -4155,18 +4097,19 @@ int ath10k_wmi_peer_create(struct ath10k *ar, u32 vdev_id,
4155 ath10k_dbg(ar, ATH10K_DBG_WMI, 4097 ath10k_dbg(ar, ATH10K_DBG_WMI,
4156 "wmi peer create vdev_id %d peer_addr %pM\n", 4098 "wmi peer create vdev_id %d peer_addr %pM\n",
4157 vdev_id, peer_addr); 4099 vdev_id, peer_addr);
4158 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_create_cmdid); 4100 return skb;
4159} 4101}
4160 4102
4161int ath10k_wmi_peer_delete(struct ath10k *ar, u32 vdev_id, 4103static struct sk_buff *
4162 const u8 peer_addr[ETH_ALEN]) 4104ath10k_wmi_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
4105 const u8 peer_addr[ETH_ALEN])
4163{ 4106{
4164 struct wmi_peer_delete_cmd *cmd; 4107 struct wmi_peer_delete_cmd *cmd;
4165 struct sk_buff *skb; 4108 struct sk_buff *skb;
4166 4109
4167 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4110 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4168 if (!skb) 4111 if (!skb)
4169 return -ENOMEM; 4112 return ERR_PTR(-ENOMEM);
4170 4113
4171 cmd = (struct wmi_peer_delete_cmd *)skb->data; 4114 cmd = (struct wmi_peer_delete_cmd *)skb->data;
4172 cmd->vdev_id = __cpu_to_le32(vdev_id); 4115 cmd->vdev_id = __cpu_to_le32(vdev_id);
@@ -4175,18 +4118,19 @@ int ath10k_wmi_peer_delete(struct ath10k *ar, u32 vdev_id,
4175 ath10k_dbg(ar, ATH10K_DBG_WMI, 4118 ath10k_dbg(ar, ATH10K_DBG_WMI,
4176 "wmi peer delete vdev_id %d peer_addr %pM\n", 4119 "wmi peer delete vdev_id %d peer_addr %pM\n",
4177 vdev_id, peer_addr); 4120 vdev_id, peer_addr);
4178 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_delete_cmdid); 4121 return skb;
4179} 4122}
4180 4123
4181int ath10k_wmi_peer_flush(struct ath10k *ar, u32 vdev_id, 4124static struct sk_buff *
4182 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap) 4125ath10k_wmi_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
4126 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
4183{ 4127{
4184 struct wmi_peer_flush_tids_cmd *cmd; 4128 struct wmi_peer_flush_tids_cmd *cmd;
4185 struct sk_buff *skb; 4129 struct sk_buff *skb;
4186 4130
4187 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4131 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4188 if (!skb) 4132 if (!skb)
4189 return -ENOMEM; 4133 return ERR_PTR(-ENOMEM);
4190 4134
4191 cmd = (struct wmi_peer_flush_tids_cmd *)skb->data; 4135 cmd = (struct wmi_peer_flush_tids_cmd *)skb->data;
4192 cmd->vdev_id = __cpu_to_le32(vdev_id); 4136 cmd->vdev_id = __cpu_to_le32(vdev_id);
@@ -4196,19 +4140,21 @@ int ath10k_wmi_peer_flush(struct ath10k *ar, u32 vdev_id,
4196 ath10k_dbg(ar, ATH10K_DBG_WMI, 4140 ath10k_dbg(ar, ATH10K_DBG_WMI,
4197 "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n", 4141 "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n",
4198 vdev_id, peer_addr, tid_bitmap); 4142 vdev_id, peer_addr, tid_bitmap);
4199 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_flush_tids_cmdid); 4143 return skb;
4200} 4144}
4201 4145
4202int ath10k_wmi_peer_set_param(struct ath10k *ar, u32 vdev_id, 4146static struct sk_buff *
4203 const u8 *peer_addr, enum wmi_peer_param param_id, 4147ath10k_wmi_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
4204 u32 param_value) 4148 const u8 *peer_addr,
4149 enum wmi_peer_param param_id,
4150 u32 param_value)
4205{ 4151{
4206 struct wmi_peer_set_param_cmd *cmd; 4152 struct wmi_peer_set_param_cmd *cmd;
4207 struct sk_buff *skb; 4153 struct sk_buff *skb;
4208 4154
4209 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4155 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4210 if (!skb) 4156 if (!skb)
4211 return -ENOMEM; 4157 return ERR_PTR(-ENOMEM);
4212 4158
4213 cmd = (struct wmi_peer_set_param_cmd *)skb->data; 4159 cmd = (struct wmi_peer_set_param_cmd *)skb->data;
4214 cmd->vdev_id = __cpu_to_le32(vdev_id); 4160 cmd->vdev_id = __cpu_to_le32(vdev_id);
@@ -4219,19 +4165,19 @@ int ath10k_wmi_peer_set_param(struct ath10k *ar, u32 vdev_id,
4219 ath10k_dbg(ar, ATH10K_DBG_WMI, 4165 ath10k_dbg(ar, ATH10K_DBG_WMI,
4220 "wmi vdev %d peer 0x%pM set param %d value %d\n", 4166 "wmi vdev %d peer 0x%pM set param %d value %d\n",
4221 vdev_id, peer_addr, param_id, param_value); 4167 vdev_id, peer_addr, param_id, param_value);
4222 4168 return skb;
4223 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_set_param_cmdid);
4224} 4169}
4225 4170
4226int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id, 4171static struct sk_buff *
4227 enum wmi_sta_ps_mode psmode) 4172ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
4173 enum wmi_sta_ps_mode psmode)
4228{ 4174{
4229 struct wmi_sta_powersave_mode_cmd *cmd; 4175 struct wmi_sta_powersave_mode_cmd *cmd;
4230 struct sk_buff *skb; 4176 struct sk_buff *skb;
4231 4177
4232 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4178 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4233 if (!skb) 4179 if (!skb)
4234 return -ENOMEM; 4180 return ERR_PTR(-ENOMEM);
4235 4181
4236 cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data; 4182 cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data;
4237 cmd->vdev_id = __cpu_to_le32(vdev_id); 4183 cmd->vdev_id = __cpu_to_le32(vdev_id);
@@ -4240,21 +4186,20 @@ int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id,
4240 ath10k_dbg(ar, ATH10K_DBG_WMI, 4186 ath10k_dbg(ar, ATH10K_DBG_WMI,
4241 "wmi set powersave id 0x%x mode %d\n", 4187 "wmi set powersave id 0x%x mode %d\n",
4242 vdev_id, psmode); 4188 vdev_id, psmode);
4243 4189 return skb;
4244 return ath10k_wmi_cmd_send(ar, skb,
4245 ar->wmi.cmd->sta_powersave_mode_cmdid);
4246} 4190}
4247 4191
4248int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id, 4192static struct sk_buff *
4249 enum wmi_sta_powersave_param param_id, 4193ath10k_wmi_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
4250 u32 value) 4194 enum wmi_sta_powersave_param param_id,
4195 u32 value)
4251{ 4196{
4252 struct wmi_sta_powersave_param_cmd *cmd; 4197 struct wmi_sta_powersave_param_cmd *cmd;
4253 struct sk_buff *skb; 4198 struct sk_buff *skb;
4254 4199
4255 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4200 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4256 if (!skb) 4201 if (!skb)
4257 return -ENOMEM; 4202 return ERR_PTR(-ENOMEM);
4258 4203
4259 cmd = (struct wmi_sta_powersave_param_cmd *)skb->data; 4204 cmd = (struct wmi_sta_powersave_param_cmd *)skb->data;
4260 cmd->vdev_id = __cpu_to_le32(vdev_id); 4205 cmd->vdev_id = __cpu_to_le32(vdev_id);
@@ -4264,22 +4209,22 @@ int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
4264 ath10k_dbg(ar, ATH10K_DBG_WMI, 4209 ath10k_dbg(ar, ATH10K_DBG_WMI,
4265 "wmi sta ps param vdev_id 0x%x param %d value %d\n", 4210 "wmi sta ps param vdev_id 0x%x param %d value %d\n",
4266 vdev_id, param_id, value); 4211 vdev_id, param_id, value);
4267 return ath10k_wmi_cmd_send(ar, skb, 4212 return skb;
4268 ar->wmi.cmd->sta_powersave_param_cmdid);
4269} 4213}
4270 4214
4271int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac, 4215static struct sk_buff *
4272 enum wmi_ap_ps_peer_param param_id, u32 value) 4216ath10k_wmi_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
4217 enum wmi_ap_ps_peer_param param_id, u32 value)
4273{ 4218{
4274 struct wmi_ap_ps_peer_cmd *cmd; 4219 struct wmi_ap_ps_peer_cmd *cmd;
4275 struct sk_buff *skb; 4220 struct sk_buff *skb;
4276 4221
4277 if (!mac) 4222 if (!mac)
4278 return -EINVAL; 4223 return ERR_PTR(-EINVAL);
4279 4224
4280 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4225 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4281 if (!skb) 4226 if (!skb)
4282 return -ENOMEM; 4227 return ERR_PTR(-ENOMEM);
4283 4228
4284 cmd = (struct wmi_ap_ps_peer_cmd *)skb->data; 4229 cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
4285 cmd->vdev_id = __cpu_to_le32(vdev_id); 4230 cmd->vdev_id = __cpu_to_le32(vdev_id);
@@ -4290,13 +4235,12 @@ int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
4290 ath10k_dbg(ar, ATH10K_DBG_WMI, 4235 ath10k_dbg(ar, ATH10K_DBG_WMI,
4291 "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n", 4236 "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
4292 vdev_id, param_id, value, mac); 4237 vdev_id, param_id, value, mac);
4293 4238 return skb;
4294 return ath10k_wmi_cmd_send(ar, skb,
4295 ar->wmi.cmd->ap_ps_peer_param_cmdid);
4296} 4239}
4297 4240
4298int ath10k_wmi_scan_chan_list(struct ath10k *ar, 4241static struct sk_buff *
4299 const struct wmi_scan_chan_list_arg *arg) 4242ath10k_wmi_op_gen_scan_chan_list(struct ath10k *ar,
4243 const struct wmi_scan_chan_list_arg *arg)
4300{ 4244{
4301 struct wmi_scan_chan_list_cmd *cmd; 4245 struct wmi_scan_chan_list_cmd *cmd;
4302 struct sk_buff *skb; 4246 struct sk_buff *skb;
@@ -4309,7 +4253,7 @@ int ath10k_wmi_scan_chan_list(struct ath10k *ar,
4309 4253
4310 skb = ath10k_wmi_alloc_skb(ar, len); 4254 skb = ath10k_wmi_alloc_skb(ar, len);
4311 if (!skb) 4255 if (!skb)
4312 return -EINVAL; 4256 return ERR_PTR(-EINVAL);
4313 4257
4314 cmd = (struct wmi_scan_chan_list_cmd *)skb->data; 4258 cmd = (struct wmi_scan_chan_list_cmd *)skb->data;
4315 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels); 4259 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
@@ -4321,7 +4265,7 @@ int ath10k_wmi_scan_chan_list(struct ath10k *ar,
4321 ath10k_wmi_put_wmi_channel(ci, ch); 4265 ath10k_wmi_put_wmi_channel(ci, ch);
4322 } 4266 }
4323 4267
4324 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->scan_chan_list_cmdid); 4268 return skb;
4325} 4269}
4326 4270
4327static void 4271static void
@@ -4402,12 +4346,9 @@ ath10k_wmi_peer_assoc_fill_10_2(struct ath10k *ar, void *buf,
4402 cmd->info0 = __cpu_to_le32(info0); 4346 cmd->info0 = __cpu_to_le32(info0);
4403} 4347}
4404 4348
4405int ath10k_wmi_peer_assoc(struct ath10k *ar, 4349static int
4406 const struct wmi_peer_assoc_complete_arg *arg) 4350ath10k_wmi_peer_assoc_check_arg(const struct wmi_peer_assoc_complete_arg *arg)
4407{ 4351{
4408 struct sk_buff *skb;
4409 int len;
4410
4411 if (arg->peer_mpdu_density > 16) 4352 if (arg->peer_mpdu_density > 16)
4412 return -EINVAL; 4353 return -EINVAL;
4413 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES) 4354 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
@@ -4415,49 +4356,98 @@ int ath10k_wmi_peer_assoc(struct ath10k *ar,
4415 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES) 4356 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
4416 return -EINVAL; 4357 return -EINVAL;
4417 4358
4418 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { 4359 return 0;
4419 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) 4360}
4420 len = sizeof(struct wmi_10_2_peer_assoc_complete_cmd); 4361
4421 else 4362static struct sk_buff *
4422 len = sizeof(struct wmi_10_1_peer_assoc_complete_cmd); 4363ath10k_wmi_op_gen_peer_assoc(struct ath10k *ar,
4423 } else { 4364 const struct wmi_peer_assoc_complete_arg *arg)
4424 len = sizeof(struct wmi_main_peer_assoc_complete_cmd); 4365{
4425 } 4366 size_t len = sizeof(struct wmi_main_peer_assoc_complete_cmd);
4367 struct sk_buff *skb;
4368 int ret;
4369
4370 ret = ath10k_wmi_peer_assoc_check_arg(arg);
4371 if (ret)
4372 return ERR_PTR(ret);
4426 4373
4427 skb = ath10k_wmi_alloc_skb(ar, len); 4374 skb = ath10k_wmi_alloc_skb(ar, len);
4428 if (!skb) 4375 if (!skb)
4429 return -ENOMEM; 4376 return ERR_PTR(-ENOMEM);
4430 4377
4431 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { 4378 ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg);
4432 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) 4379
4433 ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg); 4380 ath10k_dbg(ar, ATH10K_DBG_WMI,
4434 else 4381 "wmi peer assoc vdev %d addr %pM (%s)\n",
4435 ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg); 4382 arg->vdev_id, arg->addr,
4436 } else { 4383 arg->peer_reassoc ? "reassociate" : "new");
4437 ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg); 4384 return skb;
4438 } 4385}
4386
4387static struct sk_buff *
4388ath10k_wmi_10_1_op_gen_peer_assoc(struct ath10k *ar,
4389 const struct wmi_peer_assoc_complete_arg *arg)
4390{
4391 size_t len = sizeof(struct wmi_10_1_peer_assoc_complete_cmd);
4392 struct sk_buff *skb;
4393 int ret;
4394
4395 ret = ath10k_wmi_peer_assoc_check_arg(arg);
4396 if (ret)
4397 return ERR_PTR(ret);
4398
4399 skb = ath10k_wmi_alloc_skb(ar, len);
4400 if (!skb)
4401 return ERR_PTR(-ENOMEM);
4402
4403 ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg);
4404
4405 ath10k_dbg(ar, ATH10K_DBG_WMI,
4406 "wmi peer assoc vdev %d addr %pM (%s)\n",
4407 arg->vdev_id, arg->addr,
4408 arg->peer_reassoc ? "reassociate" : "new");
4409 return skb;
4410}
4411
4412static struct sk_buff *
4413ath10k_wmi_10_2_op_gen_peer_assoc(struct ath10k *ar,
4414 const struct wmi_peer_assoc_complete_arg *arg)
4415{
4416 size_t len = sizeof(struct wmi_10_2_peer_assoc_complete_cmd);
4417 struct sk_buff *skb;
4418 int ret;
4419
4420 ret = ath10k_wmi_peer_assoc_check_arg(arg);
4421 if (ret)
4422 return ERR_PTR(ret);
4423
4424 skb = ath10k_wmi_alloc_skb(ar, len);
4425 if (!skb)
4426 return ERR_PTR(-ENOMEM);
4427
4428 ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg);
4439 4429
4440 ath10k_dbg(ar, ATH10K_DBG_WMI, 4430 ath10k_dbg(ar, ATH10K_DBG_WMI,
4441 "wmi peer assoc vdev %d addr %pM (%s)\n", 4431 "wmi peer assoc vdev %d addr %pM (%s)\n",
4442 arg->vdev_id, arg->addr, 4432 arg->vdev_id, arg->addr,
4443 arg->peer_reassoc ? "reassociate" : "new"); 4433 arg->peer_reassoc ? "reassociate" : "new");
4444 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_assoc_cmdid); 4434 return skb;
4445} 4435}
4446 4436
4447/* This function assumes the beacon is already DMA mapped */ 4437/* This function assumes the beacon is already DMA mapped */
4448int ath10k_wmi_beacon_send_ref_nowait(struct ath10k_vif *arvif) 4438static struct sk_buff *
4439ath10k_wmi_op_gen_beacon_dma(struct ath10k_vif *arvif)
4449{ 4440{
4441 struct ath10k *ar = arvif->ar;
4450 struct wmi_bcn_tx_ref_cmd *cmd; 4442 struct wmi_bcn_tx_ref_cmd *cmd;
4451 struct sk_buff *skb; 4443 struct sk_buff *skb;
4452 struct sk_buff *beacon = arvif->beacon; 4444 struct sk_buff *beacon = arvif->beacon;
4453 struct ath10k *ar = arvif->ar;
4454 struct ieee80211_hdr *hdr; 4445 struct ieee80211_hdr *hdr;
4455 int ret;
4456 u16 fc; 4446 u16 fc;
4457 4447
4458 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4448 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4459 if (!skb) 4449 if (!skb)
4460 return -ENOMEM; 4450 return ERR_PTR(-ENOMEM);
4461 4451
4462 hdr = (struct ieee80211_hdr *)beacon->data; 4452 hdr = (struct ieee80211_hdr *)beacon->data;
4463 fc = le16_to_cpu(hdr->frame_control); 4453 fc = le16_to_cpu(hdr->frame_control);
@@ -4477,13 +4467,7 @@ int ath10k_wmi_beacon_send_ref_nowait(struct ath10k_vif *arvif)
4477 if (ATH10K_SKB_CB(beacon)->bcn.deliver_cab) 4467 if (ATH10K_SKB_CB(beacon)->bcn.deliver_cab)
4478 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB); 4468 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
4479 4469
4480 ret = ath10k_wmi_cmd_send_nowait(ar, skb, 4470 return skb;
4481 ar->wmi.cmd->pdev_send_bcn_cmdid);
4482
4483 if (ret)
4484 dev_kfree_skb(skb);
4485
4486 return ret;
4487} 4471}
4488 4472
4489static void ath10k_wmi_pdev_set_wmm_param(struct wmi_wmm_params *params, 4473static void ath10k_wmi_pdev_set_wmm_param(struct wmi_wmm_params *params,
@@ -4497,15 +4481,16 @@ static void ath10k_wmi_pdev_set_wmm_param(struct wmi_wmm_params *params,
4497 params->no_ack = __cpu_to_le32(arg->no_ack); 4481 params->no_ack = __cpu_to_le32(arg->no_ack);
4498} 4482}
4499 4483
4500int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar, 4484static struct sk_buff *
4501 const struct wmi_pdev_set_wmm_params_arg *arg) 4485ath10k_wmi_op_gen_pdev_set_wmm(struct ath10k *ar,
4486 const struct wmi_pdev_set_wmm_params_arg *arg)
4502{ 4487{
4503 struct wmi_pdev_set_wmm_params *cmd; 4488 struct wmi_pdev_set_wmm_params *cmd;
4504 struct sk_buff *skb; 4489 struct sk_buff *skb;
4505 4490
4506 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4491 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4507 if (!skb) 4492 if (!skb)
4508 return -ENOMEM; 4493 return ERR_PTR(-ENOMEM);
4509 4494
4510 cmd = (struct wmi_pdev_set_wmm_params *)skb->data; 4495 cmd = (struct wmi_pdev_set_wmm_params *)skb->data;
4511 ath10k_wmi_pdev_set_wmm_param(&cmd->ac_be, &arg->ac_be); 4496 ath10k_wmi_pdev_set_wmm_param(&cmd->ac_be, &arg->ac_be);
@@ -4514,35 +4499,36 @@ int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar,
4514 ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vo, &arg->ac_vo); 4499 ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vo, &arg->ac_vo);
4515 4500
4516 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n"); 4501 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n");
4517 return ath10k_wmi_cmd_send(ar, skb, 4502 return skb;
4518 ar->wmi.cmd->pdev_set_wmm_params_cmdid);
4519} 4503}
4520 4504
4521int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id) 4505static struct sk_buff *
4506ath10k_wmi_op_gen_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id)
4522{ 4507{
4523 struct wmi_request_stats_cmd *cmd; 4508 struct wmi_request_stats_cmd *cmd;
4524 struct sk_buff *skb; 4509 struct sk_buff *skb;
4525 4510
4526 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4511 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4527 if (!skb) 4512 if (!skb)
4528 return -ENOMEM; 4513 return ERR_PTR(-ENOMEM);
4529 4514
4530 cmd = (struct wmi_request_stats_cmd *)skb->data; 4515 cmd = (struct wmi_request_stats_cmd *)skb->data;
4531 cmd->stats_id = __cpu_to_le32(stats_id); 4516 cmd->stats_id = __cpu_to_le32(stats_id);
4532 4517
4533 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi request stats %d\n", (int)stats_id); 4518 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi request stats %d\n", (int)stats_id);
4534 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->request_stats_cmdid); 4519 return skb;
4535} 4520}
4536 4521
4537int ath10k_wmi_force_fw_hang(struct ath10k *ar, 4522static struct sk_buff *
4538 enum wmi_force_fw_hang_type type, u32 delay_ms) 4523ath10k_wmi_op_gen_force_fw_hang(struct ath10k *ar,
4524 enum wmi_force_fw_hang_type type, u32 delay_ms)
4539{ 4525{
4540 struct wmi_force_fw_hang_cmd *cmd; 4526 struct wmi_force_fw_hang_cmd *cmd;
4541 struct sk_buff *skb; 4527 struct sk_buff *skb;
4542 4528
4543 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4529 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4544 if (!skb) 4530 if (!skb)
4545 return -ENOMEM; 4531 return ERR_PTR(-ENOMEM);
4546 4532
4547 cmd = (struct wmi_force_fw_hang_cmd *)skb->data; 4533 cmd = (struct wmi_force_fw_hang_cmd *)skb->data;
4548 cmd->type = __cpu_to_le32(type); 4534 cmd->type = __cpu_to_le32(type);
@@ -4550,10 +4536,11 @@ int ath10k_wmi_force_fw_hang(struct ath10k *ar,
4550 4536
4551 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n", 4537 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n",
4552 type, delay_ms); 4538 type, delay_ms);
4553 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid); 4539 return skb;
4554} 4540}
4555 4541
4556int ath10k_wmi_dbglog_cfg(struct ath10k *ar, u32 module_enable) 4542static struct sk_buff *
4543ath10k_wmi_op_gen_dbglog_cfg(struct ath10k *ar, u32 module_enable)
4557{ 4544{
4558 struct wmi_dbglog_cfg_cmd *cmd; 4545 struct wmi_dbglog_cfg_cmd *cmd;
4559 struct sk_buff *skb; 4546 struct sk_buff *skb;
@@ -4561,7 +4548,7 @@ int ath10k_wmi_dbglog_cfg(struct ath10k *ar, u32 module_enable)
4561 4548
4562 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4549 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4563 if (!skb) 4550 if (!skb)
4564 return -ENOMEM; 4551 return ERR_PTR(-ENOMEM);
4565 4552
4566 cmd = (struct wmi_dbglog_cfg_cmd *)skb->data; 4553 cmd = (struct wmi_dbglog_cfg_cmd *)skb->data;
4567 4554
@@ -4586,57 +4573,224 @@ int ath10k_wmi_dbglog_cfg(struct ath10k *ar, u32 module_enable)
4586 __le32_to_cpu(cmd->module_valid), 4573 __le32_to_cpu(cmd->module_valid),
4587 __le32_to_cpu(cmd->config_enable), 4574 __le32_to_cpu(cmd->config_enable),
4588 __le32_to_cpu(cmd->config_valid)); 4575 __le32_to_cpu(cmd->config_valid));
4589 4576 return skb;
4590 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->dbglog_cfg_cmdid);
4591} 4577}
4592 4578
4593int ath10k_wmi_pdev_pktlog_enable(struct ath10k *ar, u32 ev_bitmap) 4579static struct sk_buff *
4580ath10k_wmi_op_gen_pktlog_enable(struct ath10k *ar, u32 ev_bitmap)
4594{ 4581{
4595 struct wmi_pdev_pktlog_enable_cmd *cmd; 4582 struct wmi_pdev_pktlog_enable_cmd *cmd;
4596 struct sk_buff *skb; 4583 struct sk_buff *skb;
4597 4584
4598 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 4585 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
4599 if (!skb) 4586 if (!skb)
4600 return -ENOMEM; 4587 return ERR_PTR(-ENOMEM);
4601 4588
4602 ev_bitmap &= ATH10K_PKTLOG_ANY; 4589 ev_bitmap &= ATH10K_PKTLOG_ANY;
4603 ath10k_dbg(ar, ATH10K_DBG_WMI,
4604 "wmi enable pktlog filter:%x\n", ev_bitmap);
4605 4590
4606 cmd = (struct wmi_pdev_pktlog_enable_cmd *)skb->data; 4591 cmd = (struct wmi_pdev_pktlog_enable_cmd *)skb->data;
4607 cmd->ev_bitmap = __cpu_to_le32(ev_bitmap); 4592 cmd->ev_bitmap = __cpu_to_le32(ev_bitmap);
4608 return ath10k_wmi_cmd_send(ar, skb, 4593
4609 ar->wmi.cmd->pdev_pktlog_enable_cmdid); 4594 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi enable pktlog filter 0x%08x\n",
4595 ev_bitmap);
4596 return skb;
4610} 4597}
4611 4598
4612int ath10k_wmi_pdev_pktlog_disable(struct ath10k *ar) 4599static struct sk_buff *
4600ath10k_wmi_op_gen_pktlog_disable(struct ath10k *ar)
4613{ 4601{
4614 struct sk_buff *skb; 4602 struct sk_buff *skb;
4615 4603
4616 skb = ath10k_wmi_alloc_skb(ar, 0); 4604 skb = ath10k_wmi_alloc_skb(ar, 0);
4617 if (!skb) 4605 if (!skb)
4618 return -ENOMEM; 4606 return ERR_PTR(-ENOMEM);
4619 4607
4620 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi disable pktlog\n"); 4608 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi disable pktlog\n");
4621 4609 return skb;
4622 return ath10k_wmi_cmd_send(ar, skb,
4623 ar->wmi.cmd->pdev_pktlog_disable_cmdid);
4624} 4610}
4625 4611
4612static const struct wmi_ops wmi_ops = {
4613 .rx = ath10k_wmi_op_rx,
4614 .map_svc = wmi_main_svc_map,
4615
4616 .pull_scan = ath10k_wmi_op_pull_scan_ev,
4617 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
4618 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
4619 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
4620 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
4621 .pull_swba = ath10k_wmi_op_pull_swba_ev,
4622 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
4623 .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
4624 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
4625 .pull_fw_stats = ath10k_wmi_main_op_pull_fw_stats,
4626
4627 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
4628 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
4629 .gen_pdev_set_rd = ath10k_wmi_op_gen_pdev_set_rd,
4630 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
4631 .gen_init = ath10k_wmi_op_gen_init,
4632 .gen_start_scan = ath10k_wmi_op_gen_start_scan,
4633 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
4634 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
4635 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
4636 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
4637 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
4638 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
4639 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
4640 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
4641 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
4642 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
4643 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
4644 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
4645 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
4646 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
4647 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
4648 .gen_peer_assoc = ath10k_wmi_op_gen_peer_assoc,
4649 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
4650 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
4651 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
4652 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
4653 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
4654 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
4655 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
4656 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
4657 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
4658 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
4659 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
4660 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
4661};
4662
4663static const struct wmi_ops wmi_10_1_ops = {
4664 .rx = ath10k_wmi_10_1_op_rx,
4665 .map_svc = wmi_10x_svc_map,
4666 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
4667 .pull_fw_stats = ath10k_wmi_10x_op_pull_fw_stats,
4668 .gen_init = ath10k_wmi_10_1_op_gen_init,
4669 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
4670 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
4671 .gen_peer_assoc = ath10k_wmi_10_1_op_gen_peer_assoc,
4672
4673 /* shared with main branch */
4674 .pull_scan = ath10k_wmi_op_pull_scan_ev,
4675 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
4676 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
4677 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
4678 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
4679 .pull_swba = ath10k_wmi_op_pull_swba_ev,
4680 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
4681 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
4682
4683 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
4684 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
4685 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
4686 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
4687 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
4688 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
4689 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
4690 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
4691 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
4692 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
4693 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
4694 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
4695 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
4696 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
4697 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
4698 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
4699 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
4700 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
4701 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
4702 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
4703 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
4704 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
4705 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
4706 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
4707 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
4708 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
4709 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
4710 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
4711 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
4712 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
4713};
4714
4715static const struct wmi_ops wmi_10_2_ops = {
4716 .rx = ath10k_wmi_10_2_op_rx,
4717 .gen_init = ath10k_wmi_10_2_op_gen_init,
4718 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
4719
4720 /* shared with 10.1 */
4721 .map_svc = wmi_10x_svc_map,
4722 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
4723 .pull_fw_stats = ath10k_wmi_10x_op_pull_fw_stats,
4724 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
4725 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
4726
4727 .pull_scan = ath10k_wmi_op_pull_scan_ev,
4728 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
4729 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
4730 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
4731 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
4732 .pull_swba = ath10k_wmi_op_pull_swba_ev,
4733 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
4734 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
4735
4736 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
4737 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
4738 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
4739 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
4740 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
4741 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
4742 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
4743 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
4744 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
4745 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
4746 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
4747 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
4748 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
4749 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
4750 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
4751 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
4752 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
4753 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
4754 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
4755 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
4756 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
4757 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
4758 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
4759 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
4760 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
4761 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
4762 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
4763 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
4764 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
4765 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
4766};
4767
4626int ath10k_wmi_attach(struct ath10k *ar) 4768int ath10k_wmi_attach(struct ath10k *ar)
4627{ 4769{
4628 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { 4770 switch (ar->wmi.op_version) {
4629 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) 4771 case ATH10K_FW_WMI_OP_VERSION_10_2:
4630 ar->wmi.cmd = &wmi_10_2_cmd_map; 4772 ar->wmi.cmd = &wmi_10_2_cmd_map;
4631 else 4773 ar->wmi.ops = &wmi_10_2_ops;
4632 ar->wmi.cmd = &wmi_10x_cmd_map;
4633
4634 ar->wmi.vdev_param = &wmi_10x_vdev_param_map; 4774 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
4635 ar->wmi.pdev_param = &wmi_10x_pdev_param_map; 4775 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
4636 } else { 4776 break;
4777 case ATH10K_FW_WMI_OP_VERSION_10_1:
4778 ar->wmi.cmd = &wmi_10x_cmd_map;
4779 ar->wmi.ops = &wmi_10_1_ops;
4780 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
4781 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
4782 break;
4783 case ATH10K_FW_WMI_OP_VERSION_MAIN:
4637 ar->wmi.cmd = &wmi_cmd_map; 4784 ar->wmi.cmd = &wmi_cmd_map;
4785 ar->wmi.ops = &wmi_ops;
4638 ar->wmi.vdev_param = &wmi_vdev_param_map; 4786 ar->wmi.vdev_param = &wmi_vdev_param_map;
4639 ar->wmi.pdev_param = &wmi_pdev_param_map; 4787 ar->wmi.pdev_param = &wmi_pdev_param_map;
4788 break;
4789 case ATH10K_FW_WMI_OP_VERSION_UNSET:
4790 case ATH10K_FW_WMI_OP_VERSION_MAX:
4791 ath10k_err(ar, "unsupported WMI op version: %d\n",
4792 ar->wmi.op_version);
4793 return -EINVAL;
4640 } 4794 }
4641 4795
4642 init_completion(&ar->wmi.service_ready); 4796 init_completion(&ar->wmi.service_ready);