debug.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Portions
  4. * Copyright (C) 2022 - 2025 Intel Corporation
  5. */
  6. #ifndef __MAC80211_DEBUG_H
  7. #define __MAC80211_DEBUG_H
  8. #include <linux/once_lite.h>
  9. #include <net/cfg80211.h>
  10. #ifdef CONFIG_MAC80211_OCB_DEBUG
  11. #define MAC80211_OCB_DEBUG 1
  12. #else
  13. #define MAC80211_OCB_DEBUG 0
  14. #endif
  15. #ifdef CONFIG_MAC80211_IBSS_DEBUG
  16. #define MAC80211_IBSS_DEBUG 1
  17. #else
  18. #define MAC80211_IBSS_DEBUG 0
  19. #endif
  20. #ifdef CONFIG_MAC80211_PS_DEBUG
  21. #define MAC80211_PS_DEBUG 1
  22. #else
  23. #define MAC80211_PS_DEBUG 0
  24. #endif
  25. #ifdef CONFIG_MAC80211_HT_DEBUG
  26. #define MAC80211_HT_DEBUG 1
  27. #else
  28. #define MAC80211_HT_DEBUG 0
  29. #endif
  30. #ifdef CONFIG_MAC80211_MPL_DEBUG
  31. #define MAC80211_MPL_DEBUG 1
  32. #else
  33. #define MAC80211_MPL_DEBUG 0
  34. #endif
  35. #ifdef CONFIG_MAC80211_MPATH_DEBUG
  36. #define MAC80211_MPATH_DEBUG 1
  37. #else
  38. #define MAC80211_MPATH_DEBUG 0
  39. #endif
  40. #ifdef CONFIG_MAC80211_MHWMP_DEBUG
  41. #define MAC80211_MHWMP_DEBUG 1
  42. #else
  43. #define MAC80211_MHWMP_DEBUG 0
  44. #endif
  45. #ifdef CONFIG_MAC80211_MESH_SYNC_DEBUG
  46. #define MAC80211_MESH_SYNC_DEBUG 1
  47. #else
  48. #define MAC80211_MESH_SYNC_DEBUG 0
  49. #endif
  50. #ifdef CONFIG_MAC80211_MESH_CSA_DEBUG
  51. #define MAC80211_MESH_CSA_DEBUG 1
  52. #else
  53. #define MAC80211_MESH_CSA_DEBUG 0
  54. #endif
  55. #ifdef CONFIG_MAC80211_MESH_PS_DEBUG
  56. #define MAC80211_MESH_PS_DEBUG 1
  57. #else
  58. #define MAC80211_MESH_PS_DEBUG 0
  59. #endif
  60. #ifdef CONFIG_MAC80211_TDLS_DEBUG
  61. #define MAC80211_TDLS_DEBUG 1
  62. #else
  63. #define MAC80211_TDLS_DEBUG 0
  64. #endif
  65. #ifdef CONFIG_MAC80211_STA_DEBUG
  66. #define MAC80211_STA_DEBUG 1
  67. #else
  68. #define MAC80211_STA_DEBUG 0
  69. #endif
  70. #ifdef CONFIG_MAC80211_MLME_DEBUG
  71. #define MAC80211_MLME_DEBUG 1
  72. #else
  73. #define MAC80211_MLME_DEBUG 0
  74. #endif
  75. #ifdef CONFIG_MAC80211_MESSAGE_TRACING
  76. void __sdata_info(const char *fmt, ...) __printf(1, 2);
  77. void __sdata_dbg(bool print, const char *fmt, ...) __printf(2, 3);
  78. void __sdata_err(const char *fmt, ...) __printf(1, 2);
  79. void __wiphy_dbg(struct wiphy *wiphy, bool print, const char *fmt, ...)
  80. __printf(3, 4);
  81. #define _sdata_info(sdata, fmt, ...) \
  82. __sdata_info("%s: " fmt, (sdata)->name, ##__VA_ARGS__)
  83. #define _sdata_dbg(print, sdata, fmt, ...) \
  84. __sdata_dbg(print, "%s: " fmt, (sdata)->name, ##__VA_ARGS__)
  85. #define _sdata_err(sdata, fmt, ...) \
  86. __sdata_err("%s: " fmt, (sdata)->name, ##__VA_ARGS__)
  87. #define _wiphy_dbg(print, wiphy, fmt, ...) \
  88. __wiphy_dbg(wiphy, print, fmt, ##__VA_ARGS__)
  89. #else
  90. #define _sdata_info(sdata, fmt, ...) \
  91. do { \
  92. pr_info("%s: " fmt, \
  93. (sdata)->name, ##__VA_ARGS__); \
  94. } while (0)
  95. #define _sdata_dbg(print, sdata, fmt, ...) \
  96. do { \
  97. if (print) \
  98. pr_debug("%s: " fmt, \
  99. (sdata)->name, ##__VA_ARGS__); \
  100. } while (0)
  101. #define _sdata_err(sdata, fmt, ...) \
  102. do { \
  103. pr_err("%s: " fmt, \
  104. (sdata)->name, ##__VA_ARGS__); \
  105. } while (0)
  106. #define _wiphy_dbg(print, wiphy, fmt, ...) \
  107. do { \
  108. if (print) \
  109. wiphy_dbg((wiphy), fmt, ##__VA_ARGS__); \
  110. } while (0)
  111. #endif
  112. #define sdata_info(sdata, fmt, ...) \
  113. _sdata_info(sdata, fmt, ##__VA_ARGS__)
  114. #define sdata_err(sdata, fmt, ...) \
  115. _sdata_err(sdata, fmt, ##__VA_ARGS__)
  116. #define sdata_dbg(sdata, fmt, ...) \
  117. _sdata_dbg(1, sdata, fmt, ##__VA_ARGS__)
  118. #define link_info(link, fmt, ...) \
  119. do { \
  120. if (ieee80211_vif_is_mld(&(link)->sdata->vif)) \
  121. _sdata_info((link)->sdata, "[link %d] " fmt, \
  122. (link)->link_id, \
  123. ##__VA_ARGS__); \
  124. else \
  125. _sdata_info((link)->sdata, fmt, ##__VA_ARGS__); \
  126. } while (0)
  127. #define link_err(link, fmt, ...) \
  128. do { \
  129. if (ieee80211_vif_is_mld(&(link)->sdata->vif)) \
  130. _sdata_err((link)->sdata, "[link %d] " fmt, \
  131. (link)->link_id, \
  132. ##__VA_ARGS__); \
  133. else \
  134. _sdata_err((link)->sdata, fmt, ##__VA_ARGS__); \
  135. } while (0)
  136. #define link_err_once(link, fmt, ...) \
  137. DO_ONCE_LITE(link_err, link, fmt, ##__VA_ARGS__)
  138. #define link_id_info(sdata, link_id, fmt, ...) \
  139. do { \
  140. if (ieee80211_vif_is_mld(&sdata->vif)) \
  141. _sdata_info(sdata, "[link %d] " fmt, link_id, \
  142. ##__VA_ARGS__); \
  143. else \
  144. _sdata_info(sdata, fmt, ##__VA_ARGS__); \
  145. } while (0)
  146. #define _link_id_dbg(print, sdata, link_id, fmt, ...) \
  147. do { \
  148. if (ieee80211_vif_is_mld(&(sdata)->vif)) \
  149. _sdata_dbg(print, sdata, "[link %d] " fmt, \
  150. link_id, ##__VA_ARGS__); \
  151. else \
  152. _sdata_dbg(print, sdata, fmt, ##__VA_ARGS__); \
  153. } while (0)
  154. #define link_dbg(link, fmt, ...) \
  155. _link_id_dbg(1, (link)->sdata, (link)->link_id, \
  156. fmt, ##__VA_ARGS__)
  157. #define ht_dbg(sdata, fmt, ...) \
  158. _sdata_dbg(MAC80211_HT_DEBUG, \
  159. sdata, fmt, ##__VA_ARGS__)
  160. #define ht_dbg_ratelimited(sdata, fmt, ...) \
  161. _sdata_dbg(MAC80211_HT_DEBUG && net_ratelimit(), \
  162. sdata, fmt, ##__VA_ARGS__)
  163. #define ocb_dbg(sdata, fmt, ...) \
  164. _sdata_dbg(MAC80211_OCB_DEBUG, \
  165. sdata, fmt, ##__VA_ARGS__)
  166. #define ibss_dbg(sdata, fmt, ...) \
  167. _sdata_dbg(MAC80211_IBSS_DEBUG, \
  168. sdata, fmt, ##__VA_ARGS__)
  169. #define ps_dbg(sdata, fmt, ...) \
  170. _sdata_dbg(MAC80211_PS_DEBUG, \
  171. sdata, fmt, ##__VA_ARGS__)
  172. #define ps_dbg_hw(hw, fmt, ...) \
  173. _wiphy_dbg(MAC80211_PS_DEBUG, \
  174. (hw)->wiphy, fmt, ##__VA_ARGS__)
  175. #define ps_dbg_ratelimited(sdata, fmt, ...) \
  176. _sdata_dbg(MAC80211_PS_DEBUG && net_ratelimit(), \
  177. sdata, fmt, ##__VA_ARGS__)
  178. #define mpl_dbg(sdata, fmt, ...) \
  179. _sdata_dbg(MAC80211_MPL_DEBUG, \
  180. sdata, fmt, ##__VA_ARGS__)
  181. #define mpath_dbg(sdata, fmt, ...) \
  182. _sdata_dbg(MAC80211_MPATH_DEBUG, \
  183. sdata, fmt, ##__VA_ARGS__)
  184. #define mhwmp_dbg(sdata, fmt, ...) \
  185. _sdata_dbg(MAC80211_MHWMP_DEBUG, \
  186. sdata, fmt, ##__VA_ARGS__)
  187. #define msync_dbg(sdata, fmt, ...) \
  188. _sdata_dbg(MAC80211_MESH_SYNC_DEBUG, \
  189. sdata, fmt, ##__VA_ARGS__)
  190. #define mcsa_dbg(sdata, fmt, ...) \
  191. _sdata_dbg(MAC80211_MESH_CSA_DEBUG, \
  192. sdata, fmt, ##__VA_ARGS__)
  193. #define mps_dbg(sdata, fmt, ...) \
  194. _sdata_dbg(MAC80211_MESH_PS_DEBUG, \
  195. sdata, fmt, ##__VA_ARGS__)
  196. #define tdls_dbg(sdata, fmt, ...) \
  197. _sdata_dbg(MAC80211_TDLS_DEBUG, \
  198. sdata, fmt, ##__VA_ARGS__)
  199. #define sta_dbg(sdata, fmt, ...) \
  200. _sdata_dbg(MAC80211_STA_DEBUG, \
  201. sdata, fmt, ##__VA_ARGS__)
  202. #define mlme_dbg(sdata, fmt, ...) \
  203. _sdata_dbg(MAC80211_MLME_DEBUG, \
  204. sdata, fmt, ##__VA_ARGS__)
  205. #define mlme_link_id_dbg(sdata, link_id, fmt, ...) \
  206. _link_id_dbg(MAC80211_MLME_DEBUG, sdata, link_id, \
  207. fmt, ##__VA_ARGS__)
  208. #define mlme_dbg_ratelimited(sdata, fmt, ...) \
  209. _sdata_dbg(MAC80211_MLME_DEBUG && net_ratelimit(), \
  210. sdata, fmt, ##__VA_ARGS__)
  211. #endif /* __MAC80211_DEBUG_H */