ath10k: implement handling of p2p noa event
[deliverable/linux.git] / drivers / net / wireless / ath / ath10k / wmi-tlv.c
index 138d80a6d3b0dd9a0693c6d3befc403f4cc2d638..939d86bf6ca12289278325f729959cbd325add5b 100644 (file)
@@ -21,6 +21,7 @@
 #include "wmi.h"
 #include "wmi-ops.h"
 #include "wmi-tlv.h"
+#include "p2p.h"
 
 /***************/
 /* TLV helpers */
@@ -63,6 +64,8 @@ static const struct wmi_tlv_policy wmi_tlv_policies[] = {
                = { .min_len = sizeof(struct wmi_tlv_bcn_tx_status_ev) },
        [WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT]
                = { .min_len = sizeof(struct wmi_tlv_diag_data_ev) },
+       [WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT]
+               = { .min_len = sizeof(struct wmi_tlv_p2p_noa_ev) },
 };
 
 static int
@@ -304,6 +307,41 @@ static int ath10k_wmi_tlv_event_diag(struct ath10k *ar,
        return 0;
 }
 
+static int ath10k_wmi_tlv_event_p2p_noa(struct ath10k *ar,
+                                       struct sk_buff *skb)
+{
+       const void **tb;
+       const struct wmi_tlv_p2p_noa_ev *ev;
+       const struct wmi_p2p_noa_info *noa;
+       int ret, vdev_id;
+
+       tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
+       if (IS_ERR(tb)) {
+               ret = PTR_ERR(tb);
+               ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
+               return ret;
+       }
+
+       ev = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT];
+       noa = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_INFO];
+
+       if (!ev || !noa) {
+               kfree(tb);
+               return -EPROTO;
+       }
+
+       vdev_id = __le32_to_cpu(ev->vdev_id);
+
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
+                  "wmi tlv p2p noa vdev_id %i descriptors %hhu\n",
+                  vdev_id, noa->num_descriptors);
+
+       ath10k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa);
+
+       kfree(tb);
+       return 0;
+}
+
 /***********/
 /* TLV ops */
 /***********/
@@ -425,6 +463,9 @@ static void ath10k_wmi_tlv_op_rx(struct ath10k *ar, struct sk_buff *skb)
        case WMI_TLV_DIAG_EVENTID:
                ath10k_wmi_tlv_event_diag(ar, skb);
                break;
+       case WMI_TLV_P2P_NOA_EVENTID:
+               ath10k_wmi_tlv_event_p2p_noa(ar, skb);
+               break;
        default:
                ath10k_warn(ar, "Unknown eventid: %d\n", id);
                break;
This page took 0.029492 seconds and 5 git commands to generate.