51353fa3e480f104069fb87e8cbec10340f9e616
[openwrt/staging/hauke.git] / package / kernel / mac80211 / patches / ath11k / 0077-wifi-ath11k-EMA-beacon-support.patch
1 From 87bd401138161008fdb82fbca6e213af117bfeb9 Mon Sep 17 00:00:00 2001
2 From: Aloka Dixit <quic_alokad@quicinc.com>
3 Date: Fri, 5 May 2023 16:11:28 +0300
4 Subject: [PATCH 77/77] wifi: ath11k: EMA beacon support
5
6 Add new function ath11k_mac_setup_bcn_tmpl_ema() which invokes the new
7 API provided by MAC80211 to retrieve EMA beacons.
8
9 Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
10
11 Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com>
12 Co-developed-by: John Crispin <john@phrozen.org>
13 Signed-off-by: John Crispin <john@phrozen.org>
14 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
15 Link: https://lore.kernel.org/r/20230405221648.17950-8-quic_alokad@quicinc.com
16 ---
17 drivers/net/wireless/ath/ath11k/mac.c | 59 ++++++++++++++++++++++++++-
18 drivers/net/wireless/ath/ath11k/wmi.c | 3 +-
19 drivers/net/wireless/ath/ath11k/wmi.h | 11 ++++-
20 3 files changed, 70 insertions(+), 3 deletions(-)
21
22 --- a/drivers/net/wireless/ath/ath11k/mac.c
23 +++ b/drivers/net/wireless/ath/ath11k/mac.c
24 @@ -1452,6 +1452,60 @@ static void ath11k_mac_set_vif_params(st
25 arvif->wpaie_present = false;
26 }
27
28 +static int ath11k_mac_setup_bcn_tmpl_ema(struct ath11k_vif *arvif)
29 +{
30 + struct ath11k_vif *tx_arvif;
31 + struct ieee80211_ema_beacons *beacons;
32 + int ret = 0;
33 + bool nontx_vif_params_set = false;
34 + u32 params = 0;
35 + u8 i = 0;
36 +
37 + tx_arvif = (void *)arvif->vif->mbssid_tx_vif->drv_priv;
38 +
39 + beacons = ieee80211_beacon_get_template_ema_list(tx_arvif->ar->hw,
40 + tx_arvif->vif, 0);
41 + if (!beacons || !beacons->cnt) {
42 + ath11k_warn(arvif->ar->ab,
43 + "failed to get ema beacon templates from mac80211\n");
44 + return -EPERM;
45 + }
46 +
47 + if (tx_arvif == arvif)
48 + ath11k_mac_set_vif_params(tx_arvif, beacons->bcn[0].skb);
49 + else
50 + arvif->wpaie_present = tx_arvif->wpaie_present;
51 +
52 + for (i = 0; i < beacons->cnt; i++) {
53 + if (tx_arvif != arvif && !nontx_vif_params_set)
54 + nontx_vif_params_set =
55 + ath11k_mac_set_nontx_vif_params(tx_arvif, arvif,
56 + beacons->bcn[i].skb);
57 +
58 + params = beacons->cnt;
59 + params |= (i << WMI_EMA_TMPL_IDX_SHIFT);
60 + params |= ((!i ? 1 : 0) << WMI_EMA_FIRST_TMPL_SHIFT);
61 + params |= ((i + 1 == beacons->cnt ? 1 : 0) << WMI_EMA_LAST_TMPL_SHIFT);
62 +
63 + ret = ath11k_wmi_bcn_tmpl(tx_arvif->ar, tx_arvif->vdev_id,
64 + &beacons->bcn[i].offs,
65 + beacons->bcn[i].skb, params);
66 + if (ret) {
67 + ath11k_warn(tx_arvif->ar->ab,
68 + "failed to set ema beacon template id %i error %d\n",
69 + i, ret);
70 + break;
71 + }
72 + }
73 +
74 + ieee80211_beacon_free_ema_list(beacons);
75 +
76 + if (tx_arvif != arvif && !nontx_vif_params_set)
77 + return -EINVAL; /* Profile not found in the beacons */
78 +
79 + return ret;
80 +}
81 +
82 static int ath11k_mac_setup_bcn_tmpl_mbssid(struct ath11k_vif *arvif)
83 {
84 struct ath11k *ar = arvif->ar;
85 @@ -1484,7 +1538,7 @@ static int ath11k_mac_setup_bcn_tmpl_mbs
86 else if (!ath11k_mac_set_nontx_vif_params(tx_arvif, arvif, bcn))
87 return -EINVAL;
88
89 - ret = ath11k_wmi_bcn_tmpl(ar, arvif->vdev_id, &offs, bcn);
90 + ret = ath11k_wmi_bcn_tmpl(ar, arvif->vdev_id, &offs, bcn, 0);
91 kfree_skb(bcn);
92
93 if (ret)
94 @@ -1508,6 +1562,9 @@ static int ath11k_mac_setup_bcn_tmpl(str
95 arvif != (void *)vif->mbssid_tx_vif->drv_priv && arvif->is_up)
96 return 0;
97
98 + if (vif->bss_conf.ema_ap && vif->mbssid_tx_vif)
99 + return ath11k_mac_setup_bcn_tmpl_ema(arvif);
100 +
101 return ath11k_mac_setup_bcn_tmpl_mbssid(arvif);
102 }
103
104 --- a/drivers/net/wireless/ath/ath11k/wmi.c
105 +++ b/drivers/net/wireless/ath/ath11k/wmi.c
106 @@ -1699,7 +1699,7 @@ int ath11k_wmi_send_bcn_offload_control_
107
108 int ath11k_wmi_bcn_tmpl(struct ath11k *ar, u32 vdev_id,
109 struct ieee80211_mutable_offsets *offs,
110 - struct sk_buff *bcn)
111 + struct sk_buff *bcn, u32 ema_params)
112 {
113 struct ath11k_pdev_wmi *wmi = ar->wmi;
114 struct wmi_bcn_tmpl_cmd *cmd;
115 @@ -1738,6 +1738,7 @@ int ath11k_wmi_bcn_tmpl(struct ath11k *a
116
117 cmd->buf_len = bcn->len;
118 cmd->mbssid_ie_offset = offs->mbssid_off;
119 + cmd->ema_params = ema_params;
120
121 ptr = skb->data + sizeof(*cmd);
122
123 --- a/drivers/net/wireless/ath/ath11k/wmi.h
124 +++ b/drivers/net/wireless/ath/ath11k/wmi.h
125 @@ -3566,6 +3566,10 @@ struct wmi_get_pdev_temperature_cmd {
126
127 #define WMI_BEACON_TX_BUFFER_SIZE 512
128
129 +#define WMI_EMA_TMPL_IDX_SHIFT 8
130 +#define WMI_EMA_FIRST_TMPL_SHIFT 16
131 +#define WMI_EMA_LAST_TMPL_SHIFT 24
132 +
133 struct wmi_bcn_tmpl_cmd {
134 u32 tlv_header;
135 u32 vdev_id;
136 @@ -3576,6 +3580,11 @@ struct wmi_bcn_tmpl_cmd {
137 u32 csa_event_bitmap;
138 u32 mbssid_ie_offset;
139 u32 esp_ie_offset;
140 + u32 csc_switch_count_offset;
141 + u32 csc_event_bitmap;
142 + u32 mu_edca_ie_offset;
143 + u32 feature_enable_bitmap;
144 + u32 ema_params;
145 } __packed;
146
147 struct wmi_key_seq_counter {
148 @@ -6298,7 +6307,7 @@ int ath11k_wmi_mgmt_send(struct ath11k *
149 struct sk_buff *frame);
150 int ath11k_wmi_bcn_tmpl(struct ath11k *ar, u32 vdev_id,
151 struct ieee80211_mutable_offsets *offs,
152 - struct sk_buff *bcn);
153 + struct sk_buff *bcn, u32 ema_param);
154 int ath11k_wmi_vdev_down(struct ath11k *ar, u8 vdev_id);
155 int ath11k_wmi_vdev_up(struct ath11k *ar, u32 vdev_id, u32 aid,
156 const u8 *bssid, u8 *tx_bssid, u32 nontx_profile_idx,