1
0

0043-wifi-ath11k-use-proper-regulatory-reference-for-band.patch 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. From 25e289e1f52e1f4fb1d07622c6a24f8d8a8e420d Mon Sep 17 00:00:00 2001
  2. From: Aditya Kumar Singh <quic_adisi@quicinc.com>
  3. Date: Wed, 1 Mar 2023 16:20:58 +0200
  4. Subject: [PATCH] wifi: ath11k: use proper regulatory reference for bands
  5. Currently, during regulatory event, 2 GHz/5 GHz is referred
  6. to as 2G/5G including variable names. However, there is no
  7. such entity as 2G or 5G.
  8. Re-name such occurences to its proper name. No functional changes.
  9. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
  10. Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
  11. Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1
  12. Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
  13. Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
  14. Link: https://lore.kernel.org/r/20230110121024.14051-2-quic_adisi@quicinc.com
  15. ---
  16. drivers/net/wireless/ath/ath11k/reg.c | 20 ++++-----
  17. drivers/net/wireless/ath/ath11k/wmi.c | 58 ++++++++++++++-------------
  18. drivers/net/wireless/ath/ath11k/wmi.h | 28 ++++++-------
  19. 3 files changed, 54 insertions(+), 52 deletions(-)
  20. --- a/drivers/net/wireless/ath/ath11k/reg.c
  21. +++ b/drivers/net/wireless/ath/ath11k/reg.c
  22. @@ -619,7 +619,7 @@ ath11k_reg_build_regd(struct ath11k_base
  23. u32 flags;
  24. char alpha2[3];
  25. - num_rules = reg_info->num_5g_reg_rules + reg_info->num_2g_reg_rules;
  26. + num_rules = reg_info->num_5ghz_reg_rules + reg_info->num_2ghz_reg_rules;
  27. if (!num_rules)
  28. goto ret;
  29. @@ -644,20 +644,20 @@ ath11k_reg_build_regd(struct ath11k_base
  30. alpha2, ath11k_reg_get_regdom_str(tmp_regd->dfs_region),
  31. reg_info->dfs_region, num_rules);
  32. /* Update reg_rules[] below. Firmware is expected to
  33. - * send these rules in order(2G rules first and then 5G)
  34. + * send these rules in order(2 GHz rules first and then 5 GHz)
  35. */
  36. for (; i < num_rules; i++) {
  37. - if (reg_info->num_2g_reg_rules &&
  38. - (i < reg_info->num_2g_reg_rules)) {
  39. - reg_rule = reg_info->reg_rules_2g_ptr + i;
  40. + if (reg_info->num_2ghz_reg_rules &&
  41. + (i < reg_info->num_2ghz_reg_rules)) {
  42. + reg_rule = reg_info->reg_rules_2ghz_ptr + i;
  43. max_bw = min_t(u16, reg_rule->max_bw,
  44. - reg_info->max_bw_2g);
  45. + reg_info->max_bw_2ghz);
  46. flags = 0;
  47. - } else if (reg_info->num_5g_reg_rules &&
  48. - (j < reg_info->num_5g_reg_rules)) {
  49. - reg_rule = reg_info->reg_rules_5g_ptr + j++;
  50. + } else if (reg_info->num_5ghz_reg_rules &&
  51. + (j < reg_info->num_5ghz_reg_rules)) {
  52. + reg_rule = reg_info->reg_rules_5ghz_ptr + j++;
  53. max_bw = min_t(u16, reg_rule->max_bw,
  54. - reg_info->max_bw_5g);
  55. + reg_info->max_bw_5ghz);
  56. /* FW doesn't pass NL80211_RRF_AUTO_BW flag for
  57. * BW Auto correction, we can enable this by default
  58. --- a/drivers/net/wireless/ath/ath11k/wmi.c
  59. +++ b/drivers/net/wireless/ath/ath11k/wmi.c
  60. @@ -4959,7 +4959,7 @@ static int ath11k_pull_reg_chan_list_upd
  61. const void **tb;
  62. const struct wmi_reg_chan_list_cc_event *chan_list_event_hdr;
  63. struct wmi_regulatory_rule_struct *wmi_reg_rule;
  64. - u32 num_2g_reg_rules, num_5g_reg_rules;
  65. + u32 num_2ghz_reg_rules, num_5ghz_reg_rules;
  66. int ret;
  67. ath11k_dbg(ab, ATH11K_DBG_WMI, "processing regulatory channel list\n");
  68. @@ -4978,10 +4978,10 @@ static int ath11k_pull_reg_chan_list_upd
  69. return -EPROTO;
  70. }
  71. - reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
  72. - reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
  73. + reg_info->num_2ghz_reg_rules = chan_list_event_hdr->num_2ghz_reg_rules;
  74. + reg_info->num_5ghz_reg_rules = chan_list_event_hdr->num_5ghz_reg_rules;
  75. - if (!(reg_info->num_2g_reg_rules + reg_info->num_5g_reg_rules)) {
  76. + if (!(reg_info->num_2ghz_reg_rules + reg_info->num_5ghz_reg_rules)) {
  77. ath11k_warn(ab, "No regulatory rules available in the event info\n");
  78. kfree(tb);
  79. return -EINVAL;
  80. @@ -5008,46 +5008,48 @@ static int ath11k_pull_reg_chan_list_upd
  81. else if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_FAIL)
  82. reg_info->status_code = REG_SET_CC_STATUS_FAIL;
  83. - reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
  84. - reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
  85. - reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
  86. - reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
  87. + reg_info->min_bw_2ghz = chan_list_event_hdr->min_bw_2ghz;
  88. + reg_info->max_bw_2ghz = chan_list_event_hdr->max_bw_2ghz;
  89. + reg_info->min_bw_5ghz = chan_list_event_hdr->min_bw_5ghz;
  90. + reg_info->max_bw_5ghz = chan_list_event_hdr->max_bw_5ghz;
  91. - num_2g_reg_rules = reg_info->num_2g_reg_rules;
  92. - num_5g_reg_rules = reg_info->num_5g_reg_rules;
  93. + num_2ghz_reg_rules = reg_info->num_2ghz_reg_rules;
  94. + num_5ghz_reg_rules = reg_info->num_5ghz_reg_rules;
  95. ath11k_dbg(ab, ATH11K_DBG_WMI,
  96. - "%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
  97. + "%s:cc %s dsf %d BW: min_2ghz %d max_2ghz %d min_5ghz %d max_5ghz %d",
  98. __func__, reg_info->alpha2, reg_info->dfs_region,
  99. - reg_info->min_bw_2g, reg_info->max_bw_2g,
  100. - reg_info->min_bw_5g, reg_info->max_bw_5g);
  101. + reg_info->min_bw_2ghz, reg_info->max_bw_2ghz,
  102. + reg_info->min_bw_5ghz, reg_info->max_bw_5ghz);
  103. ath11k_dbg(ab, ATH11K_DBG_WMI,
  104. - "%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
  105. - num_2g_reg_rules, num_5g_reg_rules);
  106. + "%s: num_2ghz_reg_rules %d num_5ghz_reg_rules %d", __func__,
  107. + num_2ghz_reg_rules, num_5ghz_reg_rules);
  108. wmi_reg_rule =
  109. (struct wmi_regulatory_rule_struct *)((u8 *)chan_list_event_hdr
  110. + sizeof(*chan_list_event_hdr)
  111. + sizeof(struct wmi_tlv));
  112. - if (num_2g_reg_rules) {
  113. - reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
  114. - wmi_reg_rule);
  115. - if (!reg_info->reg_rules_2g_ptr) {
  116. + if (num_2ghz_reg_rules) {
  117. + reg_info->reg_rules_2ghz_ptr =
  118. + create_reg_rules_from_wmi(num_2ghz_reg_rules,
  119. + wmi_reg_rule);
  120. + if (!reg_info->reg_rules_2ghz_ptr) {
  121. kfree(tb);
  122. - ath11k_warn(ab, "Unable to Allocate memory for 2g rules\n");
  123. + ath11k_warn(ab, "Unable to Allocate memory for 2 GHz rules\n");
  124. return -ENOMEM;
  125. }
  126. }
  127. - if (num_5g_reg_rules) {
  128. - wmi_reg_rule += num_2g_reg_rules;
  129. - reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
  130. - wmi_reg_rule);
  131. - if (!reg_info->reg_rules_5g_ptr) {
  132. + if (num_5ghz_reg_rules) {
  133. + wmi_reg_rule += num_2ghz_reg_rules;
  134. + reg_info->reg_rules_5ghz_ptr =
  135. + create_reg_rules_from_wmi(num_5ghz_reg_rules,
  136. + wmi_reg_rule);
  137. + if (!reg_info->reg_rules_5ghz_ptr) {
  138. kfree(tb);
  139. - ath11k_warn(ab, "Unable to Allocate memory for 5g rules\n");
  140. + ath11k_warn(ab, "Unable to Allocate memory for 5 GHz rules\n");
  141. return -ENOMEM;
  142. }
  143. }
  144. @@ -6619,8 +6621,8 @@ fallback:
  145. WARN_ON(1);
  146. mem_free:
  147. if (reg_info) {
  148. - kfree(reg_info->reg_rules_2g_ptr);
  149. - kfree(reg_info->reg_rules_5g_ptr);
  150. + kfree(reg_info->reg_rules_2ghz_ptr);
  151. + kfree(reg_info->reg_rules_5ghz_ptr);
  152. kfree(reg_info);
  153. }
  154. return ret;
  155. --- a/drivers/net/wireless/ath/ath11k/wmi.h
  156. +++ b/drivers/net/wireless/ath/ath11k/wmi.h
  157. @@ -4129,14 +4129,14 @@ struct cur_regulatory_info {
  158. u8 alpha2[REG_ALPHA2_LEN + 1];
  159. u32 dfs_region;
  160. u32 phybitmap;
  161. - u32 min_bw_2g;
  162. - u32 max_bw_2g;
  163. - u32 min_bw_5g;
  164. - u32 max_bw_5g;
  165. - u32 num_2g_reg_rules;
  166. - u32 num_5g_reg_rules;
  167. - struct cur_reg_rule *reg_rules_2g_ptr;
  168. - struct cur_reg_rule *reg_rules_5g_ptr;
  169. + u32 min_bw_2ghz;
  170. + u32 max_bw_2ghz;
  171. + u32 min_bw_5ghz;
  172. + u32 max_bw_5ghz;
  173. + u32 num_2ghz_reg_rules;
  174. + u32 num_5ghz_reg_rules;
  175. + struct cur_reg_rule *reg_rules_2ghz_ptr;
  176. + struct cur_reg_rule *reg_rules_5ghz_ptr;
  177. };
  178. struct wmi_reg_chan_list_cc_event {
  179. @@ -4148,12 +4148,12 @@ struct wmi_reg_chan_list_cc_event {
  180. u32 domain_code;
  181. u32 dfs_region;
  182. u32 phybitmap;
  183. - u32 min_bw_2g;
  184. - u32 max_bw_2g;
  185. - u32 min_bw_5g;
  186. - u32 max_bw_5g;
  187. - u32 num_2g_reg_rules;
  188. - u32 num_5g_reg_rules;
  189. + u32 min_bw_2ghz;
  190. + u32 max_bw_2ghz;
  191. + u32 min_bw_5ghz;
  192. + u32 max_bw_5ghz;
  193. + u32 num_2ghz_reg_rules;
  194. + u32 num_5ghz_reg_rules;
  195. } __packed;
  196. struct wmi_regulatory_rule_struct {