2022-04-01 14:04:02

by Baochen Qiang

[permalink] [raw]
Subject: [PATCH v4 0/2] ath11k: Add support for SAR

This is to add support for SAR, currently it is only enabled
for WCN6855.

v4:
1. rebased on latest ath.git
2. add my own s-o-b in Wen'spatch

v3:
1. rebased on latest ath.git
2. add Wen's patch to this patch set so that
there is no dependency.

Baochen Qiang (1):
ath11k: Add support for SAR

Wen Gong (1):
ath11k: add support for extended wmi service bit

drivers/net/wireless/ath/ath11k/core.c | 6 +
drivers/net/wireless/ath/ath11k/hw.c | 20 ++++
drivers/net/wireless/ath/ath11k/hw.h | 2 +
drivers/net/wireless/ath/ath11k/mac.c | 66 +++++++++++
drivers/net/wireless/ath/ath11k/wmi.c | 151 +++++++++++++++++++------
drivers/net/wireless/ath/ath11k/wmi.h | 36 +++++-
6 files changed, 247 insertions(+), 34 deletions(-)


base-commit: 57b7042c114767b7330b14a260f61732e556742e
--
2.25.1


2022-04-01 14:52:00

by Baochen Qiang

[permalink] [raw]
Subject: [PATCH v4 2/2] ath11k: Add support for SAR

ath11k assigns ath11k_mac_op_set_bios_sar_specs to ath11k_ops,
and this function is called when user space application
calls NL80211_CMD_SET_SAR_SPECS. ath11k also registers SAR
type and frequency ranges to wiphy so user space can query
SAR capabilities.

This feature is currently enabled for WCN6855.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-02431-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1

Signed-off-by: Baochen Qiang <[email protected]>
---
drivers/net/wireless/ath/ath11k/core.c | 6 +++
drivers/net/wireless/ath/ath11k/hw.c | 20 ++++++++
drivers/net/wireless/ath/ath11k/hw.h | 2 +
drivers/net/wireless/ath/ath11k/mac.c | 66 ++++++++++++++++++++++++
drivers/net/wireless/ath/ath11k/wmi.c | 70 ++++++++++++++++++++++++++
drivers/net/wireless/ath/ath11k/wmi.h | 27 ++++++++++
6 files changed, 191 insertions(+)

diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c
index 7f4462cf5787..41a57312d4e6 100644
--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -102,6 +102,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.current_cc_support = false,
.dbr_debug_support = true,
.global_reset = false,
+ .bios_sar_capa = NULL,
},
{
.hw_rev = ATH11K_HW_IPQ6018_HW10,
@@ -169,6 +170,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.current_cc_support = false,
.dbr_debug_support = true,
.global_reset = false,
+ .bios_sar_capa = NULL,
},
{
.name = "qca6390 hw2.0",
@@ -235,6 +237,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.current_cc_support = true,
.dbr_debug_support = false,
.global_reset = true,
+ .bios_sar_capa = NULL,
},
{
.name = "qcn9074 hw1.0",
@@ -301,6 +304,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.current_cc_support = false,
.dbr_debug_support = true,
.global_reset = false,
+ .bios_sar_capa = NULL,
},
{
.name = "wcn6855 hw2.0",
@@ -367,6 +371,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.current_cc_support = true,
.dbr_debug_support = false,
.global_reset = true,
+ .bios_sar_capa = &ath11k_hw_sar_capa_wcn6855,
},
{
.name = "wcn6855 hw2.1",
@@ -432,6 +437,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.current_cc_support = true,
.dbr_debug_support = false,
.global_reset = true,
+ .bios_sar_capa = &ath11k_hw_sar_capa_wcn6855,
},
};

diff --git a/drivers/net/wireless/ath/ath11k/hw.c b/drivers/net/wireless/ath/ath11k/hw.c
index d1b0e76d9ec2..46449a18b5cb 100644
--- a/drivers/net/wireless/ath/ath11k/hw.c
+++ b/drivers/net/wireless/ath/ath11k/hw.c
@@ -2154,3 +2154,23 @@ const struct ath11k_hw_hal_params ath11k_hw_hal_params_ipq8074 = {
const struct ath11k_hw_hal_params ath11k_hw_hal_params_qca6390 = {
.rx_buf_rbm = HAL_RX_BUF_RBM_SW1_BM,
};
+
+static const struct cfg80211_sar_freq_ranges ath11k_hw_sar_freq_ranges_wcn6855[] = {
+ {.start_freq = 2402, .end_freq = 2482 }, /* 2G ch1~ch13 */
+ {.start_freq = 5150, .end_freq = 5250 }, /* 5G UNII-1 ch32~ch48 */
+ {.start_freq = 5250, .end_freq = 5725 }, /* 5G UNII-2 ch50~ch144 */
+ {.start_freq = 5725, .end_freq = 5810 }, /* 5G UNII-3 ch149~ch161 */
+ {.start_freq = 5815, .end_freq = 5895 }, /* 5G UNII-4 ch163~ch177 */
+ {.start_freq = 5925, .end_freq = 6165 }, /* 6G UNII-5 Ch1, Ch2 ~ Ch41 */
+ {.start_freq = 6165, .end_freq = 6425 }, /* 6G UNII-5 ch45~ch93 */
+ {.start_freq = 6425, .end_freq = 6525 }, /* 6G UNII-6 ch97~ch113 */
+ {.start_freq = 6525, .end_freq = 6705 }, /* 6G UNII-7 ch117~ch149 */
+ {.start_freq = 6705, .end_freq = 6875 }, /* 6G UNII-7 ch153~ch185 */
+ {.start_freq = 6875, .end_freq = 7125 }, /* 6G UNII-8 ch189~ch233 */
+};
+
+const struct cfg80211_sar_capa ath11k_hw_sar_capa_wcn6855 = {
+ .type = NL80211_SAR_TYPE_POWER,
+ .num_freq_ranges = (ARRAY_SIZE(ath11k_hw_sar_freq_ranges_wcn6855)),
+ .freq_ranges = ath11k_hw_sar_freq_ranges_wcn6855,
+};
diff --git a/drivers/net/wireless/ath/ath11k/hw.h b/drivers/net/wireless/ath/ath11k/hw.h
index 44025bc5d082..29546d8de738 100644
--- a/drivers/net/wireless/ath/ath11k/hw.h
+++ b/drivers/net/wireless/ath/ath11k/hw.h
@@ -195,6 +195,7 @@ struct ath11k_hw_params {
bool current_cc_support;
bool dbr_debug_support;
bool global_reset;
+ const struct cfg80211_sar_capa *bios_sar_capa;
};

struct ath11k_hw_ops {
@@ -380,4 +381,5 @@ static inline const char *ath11k_bd_ie_type_str(enum ath11k_bd_ie_type type)
return "unknown";
}

+extern const struct cfg80211_sar_capa ath11k_hw_sar_capa_wcn6855;
#endif
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 175a4ae752f3..2b243458ff5d 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -8273,6 +8273,67 @@ static void ath11k_mac_op_set_rekey_data(struct ieee80211_hw *hw,
mutex_unlock(&ar->conf_mutex);
}

+static int ath11k_mac_op_set_bios_sar_specs(struct ieee80211_hw *hw,
+ const struct cfg80211_sar_specs *sar)
+{
+ struct ath11k *ar = hw->priv;
+ const struct cfg80211_sar_sub_specs *sspec = sar->sub_specs;
+ u8 *sar_tbl;
+ u32 i;
+ int ret;
+
+ mutex_lock(&ar->conf_mutex);
+
+ if (!test_bit(WMI_TLV_SERVICE_BIOS_SAR_SUPPORT, ar->ab->wmi_ab.svc_map) ||
+ !ar->ab->hw_params.bios_sar_capa) {
+ ret = -EOPNOTSUPP;
+ goto exit;
+ }
+
+ if (!sar || sar->type != NL80211_SAR_TYPE_POWER ||
+ sar->num_sub_specs == 0) {
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ ret = ath11k_wmi_pdev_set_bios_geo_table_param(ar);
+ if (ret) {
+ ath11k_warn(ar->ab, "failed to set geo table: %d\n", ret);
+ goto exit;
+ }
+
+ sar_tbl = kzalloc(BIOS_SAR_TABLE_LEN, GFP_KERNEL);
+ if (!sar_tbl) {
+ ret = -ENOMEM;
+ goto exit;
+ }
+
+ for (i = 0; i < sar->num_sub_specs; i++) {
+ if (sspec->freq_range_index >= (BIOS_SAR_TABLE_LEN >> 1)) {
+ ath11k_warn(ar->ab, "Ignore bad frequency index %u, max allowed %u\n",
+ sspec->freq_range_index, BIOS_SAR_TABLE_LEN >> 1);
+ continue;
+ }
+
+ /* chain0 and chain1 share same power setting */
+ sar_tbl[sspec->freq_range_index] = sspec->power;
+ sar_tbl[sspec->freq_range_index + (BIOS_SAR_TABLE_LEN >> 1)] = sspec->power;
+ ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "sar tbl[%d] = %d\n",
+ sspec->freq_range_index, sar_tbl[sspec->freq_range_index]);
+ sspec++;
+ }
+
+ ret = ath11k_wmi_pdev_set_bios_sar_table_param(ar, sar_tbl);
+ if (ret)
+ ath11k_warn(ar->ab, "failed to set sar power: %d", ret);
+
+ kfree(sar_tbl);
+exit:
+ mutex_unlock(&ar->conf_mutex);
+
+ return ret;
+}
+
static const struct ieee80211_ops ath11k_ops = {
.tx = ath11k_mac_op_tx,
.start = ath11k_mac_op_start,
@@ -8324,6 +8385,7 @@ static const struct ieee80211_ops ath11k_ops = {
.ipv6_addr_change = ath11k_mac_op_ipv6_changed,
#endif

+ .set_sar_specs = ath11k_mac_op_set_bios_sar_specs,
};

static void ath11k_mac_update_ch_list(struct ath11k *ar,
@@ -8746,6 +8808,10 @@ static int __ath11k_mac_register(struct ath11k *ar)
ieee80211_hw_set(ar->hw, SUPPORT_FAST_XMIT);
}

+ if (test_bit(WMI_TLV_SERVICE_BIOS_SAR_SUPPORT, ar->ab->wmi_ab.svc_map) &&
+ ab->hw_params.bios_sar_capa)
+ ar->hw->wiphy->sar_capa = ab->hw_params.bios_sar_capa;
+
ret = ieee80211_register_hw(ar->hw);
if (ret) {
ath11k_err(ar->ab, "ieee80211 registration failed: %d\n", ret);
diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index a5876e0378fe..60e6e3a41453 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -8883,3 +8883,73 @@ int ath11k_wmi_gtk_rekey_getinfo(struct ath11k *ar,
arvif->vdev_id);
return ath11k_wmi_cmd_send(ar->wmi, skb, WMI_GTK_OFFLOAD_CMDID);
}
+
+int ath11k_wmi_pdev_set_bios_sar_table_param(struct ath11k *ar, const u8 *sar_val)
+{ struct ath11k_pdev_wmi *wmi = ar->wmi;
+ struct wmi_pdev_set_sar_table_cmd *cmd;
+ struct wmi_tlv *tlv;
+ struct sk_buff *skb;
+ u8 *buf_ptr;
+ u32 len, sar_len_aligned, rsvd_len_aligned;
+
+ sar_len_aligned = roundup(BIOS_SAR_TABLE_LEN, sizeof(u32));
+ rsvd_len_aligned = roundup(BIOS_SAR_RSVD1_LEN, sizeof(u32));
+ len = sizeof(*cmd) +
+ TLV_HDR_SIZE + sar_len_aligned +
+ TLV_HDR_SIZE + rsvd_len_aligned;
+
+ skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
+ if (!skb)
+ return -ENOMEM;
+
+ cmd = (struct wmi_pdev_set_sar_table_cmd *)skb->data;
+ cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_SET_BIOS_SAR_TABLE_CMD) |
+ FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
+ cmd->pdev_id = ar->pdev->pdev_id;
+ cmd->sar_len = BIOS_SAR_TABLE_LEN;
+ cmd->rsvd_len = BIOS_SAR_RSVD1_LEN;
+
+ buf_ptr = skb->data + sizeof(*cmd);
+ tlv = (struct wmi_tlv *) buf_ptr;
+ tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
+ FIELD_PREP(WMI_TLV_LEN, sar_len_aligned);
+ buf_ptr += TLV_HDR_SIZE;
+ memcpy(buf_ptr, sar_val, BIOS_SAR_TABLE_LEN);
+
+ buf_ptr += sar_len_aligned;
+ tlv = (struct wmi_tlv *) buf_ptr;
+ tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
+ FIELD_PREP(WMI_TLV_LEN, rsvd_len_aligned);
+
+ return ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_SET_BIOS_SAR_TABLE_CMDID);
+}
+
+int ath11k_wmi_pdev_set_bios_geo_table_param(struct ath11k *ar)
+{
+ struct ath11k_pdev_wmi *wmi = ar->wmi;
+ struct wmi_pdev_set_geo_table_cmd *cmd;
+ struct wmi_tlv *tlv;
+ struct sk_buff *skb;
+ u8 *buf_ptr;
+ u32 len, rsvd_len_aligned;
+
+ rsvd_len_aligned = roundup(BIOS_SAR_RSVD2_LEN, sizeof(u32));
+ len = sizeof(*cmd) + TLV_HDR_SIZE + rsvd_len_aligned;
+
+ skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
+ if (!skb)
+ return -ENOMEM;
+
+ cmd = (struct wmi_pdev_set_geo_table_cmd *)skb->data;
+ cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_SET_BIOS_GEO_TABLE_CMD) |
+ FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
+ cmd->pdev_id = ar->pdev->pdev_id;
+ cmd->rsvd_len = BIOS_SAR_RSVD2_LEN;
+
+ buf_ptr = skb->data + sizeof(*cmd);
+ tlv = (struct wmi_tlv *) buf_ptr;
+ tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
+ FIELD_PREP(WMI_TLV_LEN, rsvd_len_aligned);
+
+ return ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_SET_BIOS_GEO_TABLE_CMDID);
+}
diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h
index da9b0a90fd70..c9c6faee45c1 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.h
+++ b/drivers/net/wireless/ath/ath11k/wmi.h
@@ -285,6 +285,11 @@ enum wmi_tlv_cmd_id {
WMI_PDEV_SET_SRG_OBSS_BSSID_ENABLE_BITMAP_CMDID,
WMI_PDEV_SET_NON_SRG_OBSS_COLOR_ENABLE_BITMAP_CMDID,
WMI_PDEV_SET_NON_SRG_OBSS_BSSID_ENABLE_BITMAP_CMDID,
+ WMI_PDEV_GET_TPC_STATS_CMDID,
+ WMI_PDEV_ENABLE_DURATION_BASED_TX_MODE_SELECTION_CMDID,
+ WMI_PDEV_GET_DPD_STATUS_CMDID,
+ WMI_PDEV_SET_BIOS_SAR_TABLE_CMDID,
+ WMI_PDEV_SET_BIOS_GEO_TABLE_CMDID,
WMI_VDEV_CREATE_CMDID = WMI_TLV_CMD(WMI_GRP_VDEV),
WMI_VDEV_DELETE_CMDID,
WMI_VDEV_START_REQUEST_CMDID,
@@ -1859,6 +1864,8 @@ enum wmi_tlv_tag {
WMI_TAG_PDEV_SRG_OBSS_BSSID_ENABLE_BITMAP_CMD,
WMI_TAG_PDEV_NON_SRG_OBSS_COLOR_ENABLE_BITMAP_CMD,
WMI_TAG_PDEV_NON_SRG_OBSS_BSSID_ENABLE_BITMAP_CMD,
+ WMI_TAG_PDEV_SET_BIOS_SAR_TABLE_CMD = 0x3D8,
+ WMI_TAG_PDEV_SET_BIOS_GEO_TABLE_CMD,
WMI_TAG_MAX
};

@@ -2087,6 +2094,7 @@ enum wmi_tlv_service {

/* The second 128 bits */
WMI_MAX_EXT_SERVICE = 256,
+ WMI_TLV_SERVICE_BIOS_SAR_SUPPORT = 326,

/* The third 128 bits */
WMI_MAX_EXT2_SERVICE = 384
@@ -5890,6 +5898,23 @@ struct wmi_gtk_rekey_offload_cmd {
u8 replay_ctr[GTK_REPLAY_COUNTER_BYTES];
} __packed;

+#define BIOS_SAR_TABLE_LEN (22)
+#define BIOS_SAR_RSVD1_LEN (6)
+#define BIOS_SAR_RSVD2_LEN (18)
+
+struct wmi_pdev_set_sar_table_cmd {
+ u32 tlv_header;
+ u32 pdev_id;
+ u32 sar_len;
+ u32 rsvd_len;
+} __packed;
+
+struct wmi_pdev_set_geo_table_cmd {
+ u32 tlv_header;
+ u32 pdev_id;
+ u32 rsvd_len;
+} __packed;
+
int ath11k_wmi_cmd_send(struct ath11k_pdev_wmi *wmi, struct sk_buff *skb,
u32 cmd_id);
struct sk_buff *ath11k_wmi_alloc_skb(struct ath11k_wmi_base *wmi_sc, u32 len);
@@ -6068,5 +6093,7 @@ int ath11k_wmi_gtk_rekey_offload(struct ath11k *ar,
struct ath11k_vif *arvif, bool enable);
int ath11k_wmi_gtk_rekey_getinfo(struct ath11k *ar,
struct ath11k_vif *arvif);
+int ath11k_wmi_pdev_set_bios_sar_table_param(struct ath11k *ar, const u8 *sar_val);
+int ath11k_wmi_pdev_set_bios_geo_table_param(struct ath11k *ar);

#endif
--
2.25.1

2022-04-01 15:28:17

by Baochen Qiang

[permalink] [raw]
Subject: [PATCH v4 1/2] ath11k: add support for extended wmi service bit

From: Wen Gong <[email protected]>

Currently the wmi service bis is report from firmware, it is divided
to 128 bits for each segment. The first segment is processed by
ath11k_wmi_service_bitmap_copy(), the second segment is processed by
ath11k_service_available_event() with WMI_TAG_SERVICE_AVAILABLE_EVENT,
When the service bit exceed 256 bits, then firmware report it by tag
WMI_TAG_ARRAY_UINT32 in WMI_SERVICE_AVAILABLE_EVENTID.

ath11k does not process the third segment, this is to extend the wmi
service bits from 256 to 384 for the third 128 bits. The 3 enum value
WMI_MAX_SERVICE(128)/WMI_MAX_EXT_SERVICE(256)/WMI_MAX_EXT2_SERVICE(384)
are convenient to process the service bits.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1

Signed-off-by: Wen Gong <[email protected]>
Signed-off-by: Baochen Qiang <[email protected]>
---
drivers/net/wireless/ath/ath11k/wmi.c | 81 ++++++++++++++++-----------
drivers/net/wireless/ath/ath11k/wmi.h | 9 ++-
2 files changed, 56 insertions(+), 34 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index 3af24b18204e..a5876e0378fe 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -7297,47 +7297,64 @@ static void ath11k_vdev_install_key_compl_event(struct ath11k_base *ab,
rcu_read_unlock();
}

-static void ath11k_service_available_event(struct ath11k_base *ab, struct sk_buff *skb)
+static int ath11k_wmi_tlv_services_parser(struct ath11k_base *ab,
+ u16 tag, u16 len,
+ const void *ptr, void *data)
{
- const void **tb;
const struct wmi_service_available_event *ev;
- int ret;
+ u32 *wmi_ext2_service_bitmap;
int i, j;

- tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
- if (IS_ERR(tb)) {
- ret = PTR_ERR(tb);
- ath11k_warn(ab, "failed to parse tlv: %d\n", ret);
- return;
- }
+ switch (tag) {
+ case WMI_TAG_SERVICE_AVAILABLE_EVENT:
+ ev = (struct wmi_service_available_event *)ptr;
+ for (i = 0, j = WMI_MAX_SERVICE;
+ i < WMI_SERVICE_SEGMENT_BM_SIZE32 && j < WMI_MAX_EXT_SERVICE;
+ i++) {
+ do {
+ if (ev->wmi_service_segment_bitmap[i] &
+ BIT(j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32))
+ set_bit(j, ab->wmi_ab.svc_map);
+ } while (++j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32);
+ }

- ev = tb[WMI_TAG_SERVICE_AVAILABLE_EVENT];
- if (!ev) {
- ath11k_warn(ab, "failed to fetch svc available ev");
- kfree(tb);
- return;
- }
+ ath11k_dbg(ab, ATH11K_DBG_WMI,
+ "wmi_ext_service_bitmap 0:0x%04x, 1:0x%04x, 2:0x%04x, 3:0x%04x",
+ ev->wmi_service_segment_bitmap[0],
+ ev->wmi_service_segment_bitmap[1],
+ ev->wmi_service_segment_bitmap[2],
+ ev->wmi_service_segment_bitmap[3]);
+ break;
+ case WMI_TAG_ARRAY_UINT32:
+ wmi_ext2_service_bitmap = (u32 *)ptr;
+ for (i = 0, j = WMI_MAX_EXT_SERVICE;
+ i < WMI_SERVICE_SEGMENT_BM_SIZE32 && j < WMI_MAX_EXT2_SERVICE;
+ i++) {
+ do {
+ if (wmi_ext2_service_bitmap[i] &
+ BIT(j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32))
+ set_bit(j, ab->wmi_ab.svc_map);
+ } while (++j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32);
+ }

- /* TODO: Use wmi_service_segment_offset information to get the service
- * especially when more services are advertised in multiple sevice
- * available events.
- */
- for (i = 0, j = WMI_MAX_SERVICE;
- i < WMI_SERVICE_SEGMENT_BM_SIZE32 && j < WMI_MAX_EXT_SERVICE;
- i++) {
- do {
- if (ev->wmi_service_segment_bitmap[i] &
- BIT(j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32))
- set_bit(j, ab->wmi_ab.svc_map);
- } while (++j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32);
+ ath11k_dbg(ab, ATH11K_DBG_WMI,
+ "wmi_ext2_service__bitmap 0:0x%04x, 1:0x%04x, 2:0x%04x, 3:0x%04x",
+ wmi_ext2_service_bitmap[0], wmi_ext2_service_bitmap[1],
+ wmi_ext2_service_bitmap[2], wmi_ext2_service_bitmap[3]);
+ break;
}
+ return 0;
+}

- ath11k_dbg(ab, ATH11K_DBG_WMI,
- "wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x",
- ev->wmi_service_segment_bitmap[0], ev->wmi_service_segment_bitmap[1],
- ev->wmi_service_segment_bitmap[2], ev->wmi_service_segment_bitmap[3]);
+static void ath11k_service_available_event(struct ath11k_base *ab, struct sk_buff *skb)
+{
+ int ret;

- kfree(tb);
+ ret = ath11k_wmi_tlv_iter(ab, skb->data, skb->len,
+ ath11k_wmi_tlv_services_parser,
+ NULL);
+ if (ret)
+ ath11k_warn(ab, "failed to parse services available tlv %d\n", ret);
}

static void ath11k_peer_assoc_conf_event(struct ath11k_base *ab, struct sk_buff *skb)
diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h
index 925b8003feae..da9b0a90fd70 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.h
+++ b/drivers/net/wireless/ath/ath11k/wmi.h
@@ -1992,6 +1992,7 @@ enum wmi_tlv_service {
WMI_TLV_SERVICE_ACK_TIMEOUT = 126,
WMI_TLV_SERVICE_PDEV_BSS_CHANNEL_INFO_64 = 127,

+ /* The first 128 bits */
WMI_MAX_SERVICE = 128,

WMI_TLV_SERVICE_CHAN_LOAD_INFO = 128,
@@ -2084,7 +2085,11 @@ enum wmi_tlv_service {
WMI_TLV_SERVICE_EXT2_MSG = 220,
WMI_TLV_SERVICE_SRG_SRP_SPATIAL_REUSE_SUPPORT = 249,

- WMI_MAX_EXT_SERVICE
+ /* The second 128 bits */
+ WMI_MAX_EXT_SERVICE = 256,
+
+ /* The third 128 bits */
+ WMI_MAX_EXT2_SERVICE = 384
};

enum {
@@ -5378,7 +5383,7 @@ struct ath11k_wmi_base {

struct completion service_ready;
struct completion unified_ready;
- DECLARE_BITMAP(svc_map, WMI_MAX_EXT_SERVICE);
+ DECLARE_BITMAP(svc_map, WMI_MAX_EXT2_SERVICE);
wait_queue_head_t tx_credits_wq;
const struct wmi_peer_flags_map *peer_flags;
u32 num_mem_chunks;
--
2.25.1

2022-04-01 15:41:00

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v4 2/2] ath11k: Add support for SAR

Baochen Qiang <[email protected]> wrote:

> ath11k assigns ath11k_mac_op_set_bios_sar_specs to ath11k_ops,
> and this function is called when user space application
> calls NL80211_CMD_SET_SAR_SPECS. ath11k also registers SAR
> type and frequency ranges to wiphy so user space can query
> SAR capabilities.
>
> This feature is currently enabled for WCN6855.
>
> Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-02431-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
>
> Signed-off-by: Baochen Qiang <[email protected]>
> Signed-off-by: Kalle Valo <[email protected]>

This introduced new warnings:

drivers/net/wireless/ath/ath11k/mac.c:8326: line length of 92 exceeds 90 columns
drivers/net/wireless/ath/ath11k/wmi.c:8913: No space is necessary after a cast
drivers/net/wireless/ath/ath11k/wmi.c:8920: No space is necessary after a cast
drivers/net/wireless/ath/ath11k/wmi.c:8950: No space is necessary after a cast

Fixed in the pending branch.

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2022-04-02 16:12:09

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] ath11k: add support for extended wmi service bit

On 4/1/2022 5:09 AM, Baochen Qiang wrote:
> From: Wen Gong <[email protected]>
>
> Currently the wmi service bis is report from firmware, it is divided

"bis" is a typo?
Also use of "Currently" here is confusing since it seems you are
changing that behavior. But the firmware reporting isn't changing, only
the host processing is changing.

So perhaps:
When the WMI service bits are reported from firmware they are divided
into multiple segments, with 128 bits in each segment.

> to 128 bits for each segment. The first segment is processed by
> ath11k_wmi_service_bitmap_copy(), the second segment is processed by
> ath11k_service_available_event() with WMI_TAG_SERVICE_AVAILABLE_EVENT,
> When the service bit exceed 256 bits, then firmware report it by tag
> WMI_TAG_ARRAY_UINT32 in WMI_SERVICE_AVAILABLE_EVENTID.
>
> ath11k does not process the third segment, this is to extend the wmi

Here is where you can use "currently". And this is also a good place to
say why the change is needed since that is also missing from the commit
text. So consider:
Currently ath11k does not process the third segment. Upcoming features
need to know if firmware support is available for the features, so add
processing of the third segment.

Also IMO the implementation details below do not need to be in the
commit text.

I suspect Kalle can just apply these comments to his pending branch.

> service bits from 256 to 384 for the third 128 bits. The 3 enum value
> WMI_MAX_SERVICE(128)/WMI_MAX_EXT_SERVICE(256)/WMI_MAX_EXT2_SERVICE(384)
> are convenient to process the service bits.
>
> Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
>
> Signed-off-by: Wen Gong <[email protected]>
> Signed-off-by: Baochen Qiang <[email protected]>
> ---
> drivers/net/wireless/ath/ath11k/wmi.c | 81 ++++++++++++++++-----------
> drivers/net/wireless/ath/ath11k/wmi.h | 9 ++-
> 2 files changed, 56 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
> index 3af24b18204e..a5876e0378fe 100644
> --- a/drivers/net/wireless/ath/ath11k/wmi.c
> +++ b/drivers/net/wireless/ath/ath11k/wmi.c
> @@ -7297,47 +7297,64 @@ static void ath11k_vdev_install_key_compl_event(struct ath11k_base *ab,
> rcu_read_unlock();
> }
>
> -static void ath11k_service_available_event(struct ath11k_base *ab, struct sk_buff *skb)
> +static int ath11k_wmi_tlv_services_parser(struct ath11k_base *ab,
> + u16 tag, u16 len,
> + const void *ptr, void *data)
> {
> - const void **tb;
> const struct wmi_service_available_event *ev;
> - int ret;
> + u32 *wmi_ext2_service_bitmap;
> int i, j;
>
> - tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
> - if (IS_ERR(tb)) {
> - ret = PTR_ERR(tb);
> - ath11k_warn(ab, "failed to parse tlv: %d\n", ret);
> - return;
> - }
> + switch (tag) {
> + case WMI_TAG_SERVICE_AVAILABLE_EVENT:
> + ev = (struct wmi_service_available_event *)ptr;
> + for (i = 0, j = WMI_MAX_SERVICE;
> + i < WMI_SERVICE_SEGMENT_BM_SIZE32 && j < WMI_MAX_EXT_SERVICE;
> + i++) {
> + do {
> + if (ev->wmi_service_segment_bitmap[i] &
> + BIT(j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32))
> + set_bit(j, ab->wmi_ab.svc_map);
> + } while (++j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32);
> + }
>
> - ev = tb[WMI_TAG_SERVICE_AVAILABLE_EVENT];
> - if (!ev) {
> - ath11k_warn(ab, "failed to fetch svc available ev");
> - kfree(tb);
> - return;
> - }
> + ath11k_dbg(ab, ATH11K_DBG_WMI,
> + "wmi_ext_service_bitmap 0:0x%04x, 1:0x%04x, 2:0x%04x, 3:0x%04x",
> + ev->wmi_service_segment_bitmap[0],
> + ev->wmi_service_segment_bitmap[1],
> + ev->wmi_service_segment_bitmap[2],
> + ev->wmi_service_segment_bitmap[3]);
> + break;
> + case WMI_TAG_ARRAY_UINT32:
> + wmi_ext2_service_bitmap = (u32 *)ptr;
> + for (i = 0, j = WMI_MAX_EXT_SERVICE;
> + i < WMI_SERVICE_SEGMENT_BM_SIZE32 && j < WMI_MAX_EXT2_SERVICE;
> + i++) {
> + do {
> + if (wmi_ext2_service_bitmap[i] &
> + BIT(j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32))
> + set_bit(j, ab->wmi_ab.svc_map);
> + } while (++j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32);
> + }
>
> - /* TODO: Use wmi_service_segment_offset information to get the service
> - * especially when more services are advertised in multiple sevice
> - * available events.
> - */
> - for (i = 0, j = WMI_MAX_SERVICE;
> - i < WMI_SERVICE_SEGMENT_BM_SIZE32 && j < WMI_MAX_EXT_SERVICE;
> - i++) {
> - do {
> - if (ev->wmi_service_segment_bitmap[i] &
> - BIT(j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32))
> - set_bit(j, ab->wmi_ab.svc_map);
> - } while (++j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32);
> + ath11k_dbg(ab, ATH11K_DBG_WMI,
> + "wmi_ext2_service__bitmap 0:0x%04x, 1:0x%04x, 2:0x%04x, 3:0x%04x",
> + wmi_ext2_service_bitmap[0], wmi_ext2_service_bitmap[1],
> + wmi_ext2_service_bitmap[2], wmi_ext2_service_bitmap[3]);
> + break;
> }
> + return 0;
> +}
>
> - ath11k_dbg(ab, ATH11K_DBG_WMI,
> - "wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x",
> - ev->wmi_service_segment_bitmap[0], ev->wmi_service_segment_bitmap[1],
> - ev->wmi_service_segment_bitmap[2], ev->wmi_service_segment_bitmap[3]);
> +static void ath11k_service_available_event(struct ath11k_base *ab, struct sk_buff *skb)
> +{
> + int ret;
>
> - kfree(tb);
> + ret = ath11k_wmi_tlv_iter(ab, skb->data, skb->len,
> + ath11k_wmi_tlv_services_parser,
> + NULL);
> + if (ret)
> + ath11k_warn(ab, "failed to parse services available tlv %d\n", ret);
> }
>
> static void ath11k_peer_assoc_conf_event(struct ath11k_base *ab, struct sk_buff *skb)
> diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h
> index 925b8003feae..da9b0a90fd70 100644
> --- a/drivers/net/wireless/ath/ath11k/wmi.h
> +++ b/drivers/net/wireless/ath/ath11k/wmi.h
> @@ -1992,6 +1992,7 @@ enum wmi_tlv_service {
> WMI_TLV_SERVICE_ACK_TIMEOUT = 126,
> WMI_TLV_SERVICE_PDEV_BSS_CHANNEL_INFO_64 = 127,
>
> + /* The first 128 bits */
> WMI_MAX_SERVICE = 128,
>
> WMI_TLV_SERVICE_CHAN_LOAD_INFO = 128,
> @@ -2084,7 +2085,11 @@ enum wmi_tlv_service {
> WMI_TLV_SERVICE_EXT2_MSG = 220,
> WMI_TLV_SERVICE_SRG_SRP_SPATIAL_REUSE_SUPPORT = 249,
>
> - WMI_MAX_EXT_SERVICE
> + /* The second 128 bits */
> + WMI_MAX_EXT_SERVICE = 256,
> +
> + /* The third 128 bits */
> + WMI_MAX_EXT2_SERVICE = 384
> };
>
> enum {
> @@ -5378,7 +5383,7 @@ struct ath11k_wmi_base {
>
> struct completion service_ready;
> struct completion unified_ready;
> - DECLARE_BITMAP(svc_map, WMI_MAX_EXT_SERVICE);
> + DECLARE_BITMAP(svc_map, WMI_MAX_EXT2_SERVICE);
> wait_queue_head_t tx_credits_wq;
> const struct wmi_peer_flags_map *peer_flags;
> u32 num_mem_chunks;

2022-04-04 09:00:36

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v4 2/2] ath11k: Add support for SAR

On 4/1/2022 5:09 AM, Baochen Qiang wrote:
> ath11k assigns ath11k_mac_op_set_bios_sar_specs to ath11k_ops,
> and this function is called when user space application
> calls NL80211_CMD_SET_SAR_SPECS. ath11k also registers SAR
> type and frequency ranges to wiphy so user space can query
> SAR capabilities.

I find this commit text very confusing since it uses "present simple"
tense instead of "imperative" tense so it comes across as describing
what the driver did prior to the patch instead of what the driver is
supposed to do after the patch is applied.

The patch itself LGTM.

2022-04-21 09:44:25

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] ath11k: add support for extended wmi service bit

Jeff Johnson <[email protected]> writes:

> On 4/1/2022 5:09 AM, Baochen Qiang wrote:
>> From: Wen Gong <[email protected]>
>>
>> Currently the wmi service bis is report from firmware, it is divided
>
> "bis" is a typo?
> Also use of "Currently" here is confusing since it seems you are
> changing that behavior. But the firmware reporting isn't changing,
> only the host processing is changing.
>
> So perhaps:
> When the WMI service bits are reported from firmware they are divided
> into multiple segments, with 128 bits in each segment.
>
>> to 128 bits for each segment. The first segment is processed by
>> ath11k_wmi_service_bitmap_copy(), the second segment is processed by
>> ath11k_service_available_event() with WMI_TAG_SERVICE_AVAILABLE_EVENT,
>> When the service bit exceed 256 bits, then firmware report it by tag
>> WMI_TAG_ARRAY_UINT32 in WMI_SERVICE_AVAILABLE_EVENTID.
>>
>> ath11k does not process the third segment, this is to extend the wmi
>
> Here is where you can use "currently". And this is also a good place
> to say why the change is needed since that is also missing from the
> commit text. So consider:
> Currently ath11k does not process the third segment. Upcoming features
> need to know if firmware support is available for the features, so add
> processing of the third segment.
>
> Also IMO the implementation details below do not need to be in the
> commit text.
>
> I suspect Kalle can just apply these comments to his pending branch.

Did that now, please check:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=d98a4c9bd0b32824ad9ee2d24ecabb345edfaafe

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2022-04-22 15:12:47

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v4 2/2] ath11k: Add support for SAR

Jeff Johnson <[email protected]> writes:

> On 4/1/2022 5:09 AM, Baochen Qiang wrote:
>> ath11k assigns ath11k_mac_op_set_bios_sar_specs to ath11k_ops,
>> and this function is called when user space application
>> calls NL80211_CMD_SET_SAR_SPECS. ath11k also registers SAR
>> type and frequency ranges to wiphy so user space can query
>> SAR capabilities.
>
> I find this commit text very confusing since it uses "present simple"
> tense instead of "imperative" tense so it comes across as describing
> what the driver did prior to the patch instead of what the driver is
> supposed to do after the patch is applied.
>
> The patch itself LGTM.

I tried to improve the commit log, please check:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=6b0778eaea60533a8b48df2d890543a48b590f55

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2022-04-22 20:51:15

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v4 2/2] ath11k: Add support for SAR

On 4/20/2022 9:35 AM, Kalle Valo wrote:
> Jeff Johnson <[email protected]> writes:
>
>> On 4/1/2022 5:09 AM, Baochen Qiang wrote:
>>> ath11k assigns ath11k_mac_op_set_bios_sar_specs to ath11k_ops,
>>> and this function is called when user space application
>>> calls NL80211_CMD_SET_SAR_SPECS. ath11k also registers SAR
>>> type and frequency ranges to wiphy so user space can query
>>> SAR capabilities.
>>
>> I find this commit text very confusing since it uses "present simple"
>> tense instead of "imperative" tense so it comes across as describing
>> what the driver did prior to the patch instead of what the driver is
>> supposed to do after the patch is applied.
>>
>> The patch itself LGTM.
>
> I tried to improve the commit log, please check:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=6b0778eaea60533a8b48df2d890543a48b590f55
>

LGTM!

2022-04-22 21:53:48

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] ath11k: add support for extended wmi service bit

On 4/20/2022 9:35 AM, Kalle Valo wrote:
>> I suspect Kalle can just apply these comments to his pending branch.
>
> Did that now, please check:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=d98a4c9bd0b32824ad9ee2d24ecabb345edfaafe
>

LGTM!

2022-04-23 10:02:53

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] ath11k: add support for extended wmi service bit

Baochen Qiang <[email protected]> wrote:

> When the WMI service bits are reported from firmware they are divided into
> multiple segments, with 128 bits in each segment. The first segment is
> processed by ath11k_wmi_service_bitmap_copy(), the second segment is processed
> by ath11k_service_available_event() with WMI_TAG_SERVICE_AVAILABLE_EVENT. When
> the service bit exceed 256 bits, then firmware reports it by tag
> WMI_TAG_ARRAY_UINT32 in WMI_SERVICE_AVAILABLE_EVENTID.
>
> Currently ath11k does not process the third segment. Upcoming features
> need to know if firmware support is available for the features, so add
> processing of the third segment.
>
> Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
>
> Signed-off-by: Wen Gong <[email protected]>
> Signed-off-by: Baochen Qiang <[email protected]>
> Signed-off-by: Kalle Valo <[email protected]>

2 patches applied to ath-next branch of ath.git, thanks.

e2e23a791745 ath11k: add support for extended wmi service bit
652f69ed9c1b ath11k: Add support for SAR

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches