wifi: ath12k: add configure country code for WCN7850
authorWen Gong <quic_wgong@quicinc.com>
Tue, 1 Apr 2025 02:08:37 +0000 (10:08 +0800)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Wed, 2 Apr 2025 15:04:31 +0000 (08:04 -0700)
Currently, WMI_SET_INIT_COUNTRY_CMDID is used to set country code for
WCN7850 and QCN9274.

But WMI_SET_INIT_COUNTRY_CMDID is not the correct command for WCN7850.

Add handler to send WMI_SET_CURRENT_COUNTRY_CMDID to firmware, which
is used for WCN7850 to update country code.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
Signed-off-by: Kang Yang <quic_kangyang@quicinc.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Link: https://patch.msgid.link/20250401020840.357-2-quic_kangyang@quicinc.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/wmi.c
drivers/net/wireless/ath/ath12k/wmi.h

index c8248675354c92f5d0c4b03049388ad2975810fc..b2eb3054cbe8d235df2ff5747ebb71da399ca2ff 100644 (file)
@@ -3332,6 +3332,42 @@ out:
        return ret;
 }
 
+int ath12k_wmi_send_set_current_country_cmd(struct ath12k *ar,
+                                           struct wmi_set_current_country_arg *arg)
+{
+       struct ath12k_wmi_pdev *wmi = ar->wmi;
+       struct wmi_set_current_country_cmd *cmd;
+       struct sk_buff *skb;
+       int ret;
+
+       skb = ath12k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
+       if (!skb)
+               return -ENOMEM;
+
+       cmd = (struct wmi_set_current_country_cmd *)skb->data;
+       cmd->tlv_header =
+               ath12k_wmi_tlv_cmd_hdr(WMI_TAG_SET_CURRENT_COUNTRY_CMD,
+                                      sizeof(*cmd));
+
+       cmd->pdev_id = cpu_to_le32(ar->pdev->pdev_id);
+       memcpy(&cmd->new_alpha2, &arg->alpha2, sizeof(arg->alpha2));
+       ret = ath12k_wmi_cmd_send(wmi, skb, WMI_SET_CURRENT_COUNTRY_CMDID);
+
+       ath12k_dbg(ar->ab, ATH12K_DBG_WMI,
+                  "set current country pdev id %d alpha2 %c%c\n",
+                  ar->pdev->pdev_id,
+                  arg->alpha2[0],
+                  arg->alpha2[1]);
+
+       if (ret) {
+               ath12k_warn(ar->ab,
+                           "failed to send WMI_SET_CURRENT_COUNTRY_CMDID: %d\n", ret);
+               dev_kfree_skb(skb);
+       }
+
+       return ret;
+}
+
 int
 ath12k_wmi_send_twt_enable_cmd(struct ath12k *ar, u32 pdev_id)
 {
index be4ac91dd34f504bbd6728dafd41daec52a138d6..7fdc3dd497a1b6729b5ad67435eaee20a9941c87 100644 (file)
@@ -4110,6 +4110,16 @@ struct ath12k_wmi_eht_rate_set_params {
 #define REG_ALPHA2_LEN 2
 #define MAX_6GHZ_REG_RULES 5
 
+struct wmi_set_current_country_arg {
+       u8 alpha2[REG_ALPHA2_LEN];
+};
+
+struct wmi_set_current_country_cmd {
+       __le32 tlv_header;
+       __le32 pdev_id;
+       __le32 new_alpha2;
+} __packed;
+
 enum wmi_start_event_param {
        WMI_VDEV_START_RESP_EVENT = 0,
        WMI_VDEV_RESTART_RESP_EVENT,
@@ -5990,6 +6000,9 @@ int ath12k_wmi_send_bcn_offload_control_cmd(struct ath12k *ar,
                                            u32 vdev_id, u32 bcn_ctrl_op);
 int ath12k_wmi_send_init_country_cmd(struct ath12k *ar,
                                     struct ath12k_wmi_init_country_arg *arg);
+int
+ath12k_wmi_send_set_current_country_cmd(struct ath12k *ar,
+                                       struct wmi_set_current_country_arg *arg);
 int ath12k_wmi_peer_rx_reorder_queue_setup(struct ath12k *ar,
                                           int vdev_id, const u8 *addr,
                                           dma_addr_t paddr, u8 tid,