mac80211: ath11k: sync with ath-next
[openwrt/staging/jow.git] / package / kernel / mac80211 / patches / ath11k / 0046-wifi-ath11k-Replace-fake-flex-array-with-flexible-ar.patch
1 From 3b1088a09ec9438523c251d8435e78988824bc0d Mon Sep 17 00:00:00 2001
2 From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
3 Date: Tue, 7 Mar 2023 16:22:39 -0600
4 Subject: [PATCH] wifi: ath11k: Replace fake flex-array with flexible-array
5 member
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Zero-length arrays as fake flexible arrays are deprecated and we are
11 moving towards adopting C99 flexible-array members instead.
12
13 Address 25 of the following warnings found with GCC-13 and
14 -fstrict-flex-arrays=3 enabled:
15 drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c:30:51: warning: array subscript <unknown> is outside array bounds of ‘const u32[0]’ {aka ‘const unsigned int[]’} [-Warray-bounds=]
16
17 This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
18 routines on memcpy() and help us make progress towards globally
19 enabling -fstrict-flex-arrays=3 [1].
20
21 Link: https://github.com/KSPP/linux/issues/21
22 Link: https://github.com/KSPP/linux/issues/266
23 Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
24 Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
25 Reviewed-by: Simon Horman <simon.horman@corigine.com>
26 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
27 Link: https://lore.kernel.org/r/ZAe5L5DtmsQxzqRH@work
28 ---
29 .../wireless/ath/ath11k/debugfs_htt_stats.h | 73 +++++++++++--------
30 1 file changed, 43 insertions(+), 30 deletions(-)
31
32 --- a/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.h
33 +++ b/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.h
34 @@ -143,7 +143,8 @@ enum htt_tx_pdev_underrun_enum {
35 /* Bytes stored in little endian order */
36 /* Length should be multiple of DWORD */
37 struct htt_stats_string_tlv {
38 - u32 data[0]; /* Can be variable length */
39 + /* Can be variable length */
40 + DECLARE_FLEX_ARRAY(u32, data);
41 } __packed;
42
43 #define HTT_STATS_MAC_ID GENMASK(7, 0)
44 @@ -205,27 +206,32 @@ struct htt_tx_pdev_stats_cmn_tlv {
45
46 /* NOTE: Variable length TLV, use length spec to infer array size */
47 struct htt_tx_pdev_stats_urrn_tlv_v {
48 - u32 urrn_stats[0]; /* HTT_TX_PDEV_MAX_URRN_STATS */
49 + /* HTT_TX_PDEV_MAX_URRN_STATS */
50 + DECLARE_FLEX_ARRAY(u32, urrn_stats);
51 };
52
53 /* NOTE: Variable length TLV, use length spec to infer array size */
54 struct htt_tx_pdev_stats_flush_tlv_v {
55 - u32 flush_errs[0]; /* HTT_TX_PDEV_MAX_FLUSH_REASON_STATS */
56 + /* HTT_TX_PDEV_MAX_FLUSH_REASON_STATS */
57 + DECLARE_FLEX_ARRAY(u32, flush_errs);
58 };
59
60 /* NOTE: Variable length TLV, use length spec to infer array size */
61 struct htt_tx_pdev_stats_sifs_tlv_v {
62 - u32 sifs_status[0]; /* HTT_TX_PDEV_MAX_SIFS_BURST_STATS */
63 + /* HTT_TX_PDEV_MAX_SIFS_BURST_STATS */
64 + DECLARE_FLEX_ARRAY(u32, sifs_status);
65 };
66
67 /* NOTE: Variable length TLV, use length spec to infer array size */
68 struct htt_tx_pdev_stats_phy_err_tlv_v {
69 - u32 phy_errs[0]; /* HTT_TX_PDEV_MAX_PHY_ERR_STATS */
70 + /* HTT_TX_PDEV_MAX_PHY_ERR_STATS */
71 + DECLARE_FLEX_ARRAY(u32, phy_errs);
72 };
73
74 /* NOTE: Variable length TLV, use length spec to infer array size */
75 struct htt_tx_pdev_stats_sifs_hist_tlv_v {
76 - u32 sifs_hist_status[0]; /* HTT_TX_PDEV_SIFS_BURST_HIST_STATS */
77 + /* HTT_TX_PDEV_SIFS_BURST_HIST_STATS */
78 + DECLARE_FLEX_ARRAY(u32, sifs_hist_status);
79 };
80
81 struct htt_tx_pdev_stats_tx_ppdu_stats_tlv_v {
82 @@ -590,20 +596,20 @@ struct htt_tx_hwq_difs_latency_stats_tlv
83
84 /* NOTE: Variable length TLV, use length spec to infer array size */
85 struct htt_tx_hwq_cmd_result_stats_tlv_v {
86 - /* Histogram of sched cmd result */
87 - u32 cmd_result[0]; /* HTT_TX_HWQ_MAX_CMD_RESULT_STATS */
88 + /* Histogram of sched cmd result, HTT_TX_HWQ_MAX_CMD_RESULT_STATS */
89 + DECLARE_FLEX_ARRAY(u32, cmd_result);
90 };
91
92 /* NOTE: Variable length TLV, use length spec to infer array size */
93 struct htt_tx_hwq_cmd_stall_stats_tlv_v {
94 - /* Histogram of various pause conitions */
95 - u32 cmd_stall_status[0]; /* HTT_TX_HWQ_MAX_CMD_STALL_STATS */
96 + /* Histogram of various pause conitions, HTT_TX_HWQ_MAX_CMD_STALL_STATS */
97 + DECLARE_FLEX_ARRAY(u32, cmd_stall_status);
98 };
99
100 /* NOTE: Variable length TLV, use length spec to infer array size */
101 struct htt_tx_hwq_fes_result_stats_tlv_v {
102 - /* Histogram of number of user fes result */
103 - u32 fes_result[0]; /* HTT_TX_HWQ_MAX_FES_RESULT_STATS */
104 + /* Histogram of number of user fes result, HTT_TX_HWQ_MAX_FES_RESULT_STATS */
105 + DECLARE_FLEX_ARRAY(u32, fes_result);
106 };
107
108 /* NOTE: Variable length TLV, use length spec to infer array size
109 @@ -635,8 +641,8 @@ struct htt_tx_hwq_tried_mpdu_cnt_hist_tl
110 * #define WAL_TXOP_USED_HISTOGRAM_INTERVAL 1000 ( 1 ms )
111 */
112 struct htt_tx_hwq_txop_used_cnt_hist_tlv_v {
113 - /* Histogram of txop used cnt */
114 - u32 txop_used_cnt_hist[0]; /* HTT_TX_HWQ_TXOP_USED_CNT_HIST */
115 + /* Histogram of txop used cnt, HTT_TX_HWQ_TXOP_USED_CNT_HIST */
116 + DECLARE_FLEX_ARRAY(u32, txop_used_cnt_hist);
117 };
118
119 /* == TX SELFGEN STATS == */
120 @@ -804,17 +810,20 @@ struct htt_tx_pdev_mpdu_stats_tlv {
121 /* == TX SCHED STATS == */
122 /* NOTE: Variable length TLV, use length spec to infer array size */
123 struct htt_sched_txq_cmd_posted_tlv_v {
124 - u32 sched_cmd_posted[0]; /* HTT_TX_PDEV_SCHED_TX_MODE_MAX */
125 + /* HTT_TX_PDEV_SCHED_TX_MODE_MAX */
126 + DECLARE_FLEX_ARRAY(u32, sched_cmd_posted);
127 };
128
129 /* NOTE: Variable length TLV, use length spec to infer array size */
130 struct htt_sched_txq_cmd_reaped_tlv_v {
131 - u32 sched_cmd_reaped[0]; /* HTT_TX_PDEV_SCHED_TX_MODE_MAX */
132 + /* HTT_TX_PDEV_SCHED_TX_MODE_MAX */
133 + DECLARE_FLEX_ARRAY(u32, sched_cmd_reaped);
134 };
135
136 /* NOTE: Variable length TLV, use length spec to infer array size */
137 struct htt_sched_txq_sched_order_su_tlv_v {
138 - u32 sched_order_su[0]; /* HTT_TX_PDEV_NUM_SCHED_ORDER_LOG */
139 + /* HTT_TX_PDEV_NUM_SCHED_ORDER_LOG */
140 + DECLARE_FLEX_ARRAY(u32, sched_order_su);
141 };
142
143 enum htt_sched_txq_sched_ineligibility_tlv_enum {
144 @@ -842,7 +851,7 @@ enum htt_sched_txq_sched_ineligibility_t
145 /* NOTE: Variable length TLV, use length spec to infer array size */
146 struct htt_sched_txq_sched_ineligibility_tlv_v {
147 /* indexed by htt_sched_txq_sched_ineligibility_tlv_enum */
148 - u32 sched_ineligibility[0];
149 + DECLARE_FLEX_ARRAY(u32, sched_ineligibility);
150 };
151
152 #define HTT_TX_PDEV_STATS_SCHED_PER_TXQ_MAC_ID GENMASK(7, 0)
153 @@ -888,18 +897,20 @@ struct htt_stats_tx_sched_cmn_tlv {
154
155 /* NOTE: Variable length TLV, use length spec to infer array size */
156 struct htt_tx_tqm_gen_mpdu_stats_tlv_v {
157 - u32 gen_mpdu_end_reason[0]; /* HTT_TX_TQM_MAX_GEN_MPDU_END_REASON */
158 + /* HTT_TX_TQM_MAX_GEN_MPDU_END_REASON */
159 + DECLARE_FLEX_ARRAY(u32, gen_mpdu_end_reason);
160 };
161
162 /* NOTE: Variable length TLV, use length spec to infer array size */
163 struct htt_tx_tqm_list_mpdu_stats_tlv_v {
164 - u32 list_mpdu_end_reason[0]; /* HTT_TX_TQM_MAX_LIST_MPDU_END_REASON */
165 + /* HTT_TX_TQM_MAX_LIST_MPDU_END_REASON */
166 + DECLARE_FLEX_ARRAY(u32, list_mpdu_end_reason);
167 };
168
169 /* NOTE: Variable length TLV, use length spec to infer array size */
170 struct htt_tx_tqm_list_mpdu_cnt_tlv_v {
171 - u32 list_mpdu_cnt_hist[0];
172 - /* HTT_TX_TQM_MAX_LIST_MPDU_CNT_HISTOGRAM_BINS */
173 + /* HTT_TX_TQM_MAX_LIST_MPDU_CNT_HISTOGRAM_BINS */
174 + DECLARE_FLEX_ARRAY(u32, list_mpdu_cnt_hist);
175 };
176
177 struct htt_tx_tqm_pdev_stats_tlv_v {
178 @@ -1098,7 +1109,7 @@ struct htt_tx_de_compl_stats_tlv {
179 * ENTRIES_PER_BIN_COUNT)
180 */
181 struct htt_tx_de_fw2wbm_ring_full_hist_tlv {
182 - u32 fw2wbm_ring_full_hist[0];
183 + DECLARE_FLEX_ARRAY(u32, fw2wbm_ring_full_hist);
184 };
185
186 struct htt_tx_de_cmn_stats_tlv {
187 @@ -1151,7 +1162,7 @@ struct htt_ring_if_cmn_tlv {
188 /* NOTE: Variable length TLV, use length spec to infer array size */
189 struct htt_sfm_client_user_tlv_v {
190 /* Number of DWORDS used per user and per client */
191 - u32 dwords_used_by_user_n[0];
192 + DECLARE_FLEX_ARRAY(u32, dwords_used_by_user_n);
193 };
194
195 struct htt_sfm_client_tlv {
196 @@ -1436,12 +1447,14 @@ struct htt_rx_soc_fw_stats_tlv {
197
198 /* NOTE: Variable length TLV, use length spec to infer array size */
199 struct htt_rx_soc_fw_refill_ring_empty_tlv_v {
200 - u32 refill_ring_empty_cnt[0]; /* HTT_RX_STATS_REFILL_MAX_RING */
201 + /* HTT_RX_STATS_REFILL_MAX_RING */
202 + DECLARE_FLEX_ARRAY(u32, refill_ring_empty_cnt);
203 };
204
205 /* NOTE: Variable length TLV, use length spec to infer array size */
206 struct htt_rx_soc_fw_refill_ring_num_refill_tlv_v {
207 - u32 refill_ring_num_refill[0]; /* HTT_RX_STATS_REFILL_MAX_RING */
208 + /* HTT_RX_STATS_REFILL_MAX_RING */
209 + DECLARE_FLEX_ARRAY(u32, refill_ring_num_refill);
210 };
211
212 /* RXDMA error code from WBM released packets */
213 @@ -1473,7 +1486,7 @@ enum htt_rx_rxdma_error_code_enum {
214
215 /* NOTE: Variable length TLV, use length spec to infer array size */
216 struct htt_rx_soc_fw_refill_ring_num_rxdma_err_tlv_v {
217 - u32 rxdma_err[0]; /* HTT_RX_RXDMA_MAX_ERR_CODE */
218 + DECLARE_FLEX_ARRAY(u32, rxdma_err); /* HTT_RX_RXDMA_MAX_ERR_CODE */
219 };
220
221 /* REO error code from WBM released packets */
222 @@ -1505,7 +1518,7 @@ enum htt_rx_reo_error_code_enum {
223
224 /* NOTE: Variable length TLV, use length spec to infer array size */
225 struct htt_rx_soc_fw_refill_ring_num_reo_err_tlv_v {
226 - u32 reo_err[0]; /* HTT_RX_REO_MAX_ERR_CODE */
227 + DECLARE_FLEX_ARRAY(u32, reo_err); /* HTT_RX_REO_MAX_ERR_CODE */
228 };
229
230 /* == RX PDEV STATS == */
231 @@ -1622,13 +1635,13 @@ struct htt_rx_pdev_fw_stats_phy_err_tlv
232 /* NOTE: Variable length TLV, use length spec to infer array size */
233 struct htt_rx_pdev_fw_ring_mpdu_err_tlv_v {
234 /* Num error MPDU for each RxDMA error type */
235 - u32 fw_ring_mpdu_err[0]; /* HTT_RX_STATS_RXDMA_MAX_ERR */
236 + DECLARE_FLEX_ARRAY(u32, fw_ring_mpdu_err); /* HTT_RX_STATS_RXDMA_MAX_ERR */
237 };
238
239 /* NOTE: Variable length TLV, use length spec to infer array size */
240 struct htt_rx_pdev_fw_mpdu_drop_tlv_v {
241 /* Num MPDU dropped */
242 - u32 fw_mpdu_drop[0]; /* HTT_RX_STATS_FW_DROP_REASON_MAX */
243 + DECLARE_FLEX_ARRAY(u32, fw_mpdu_drop); /* HTT_RX_STATS_FW_DROP_REASON_MAX */
244 };
245
246 #define HTT_PDEV_CCA_STATS_TX_FRAME_INFO_PRESENT (0x1)