0046-wifi-ath11k-Replace-fake-flex-array-with-flexible-ar.patch 9.6 KB

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