2024-01-12 09:29:46

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 00/10] wifi: ath12k: P2P support for WCN7850

Add P2P support for WCN7850.

Kang Yang (10):
wifi: ath12k: change interface combination for P2P mode
wifi: ath12k: add P2P IE in beacon template
wifi: ath12k: implement handling of P2P NoA event
wifi: ath12k: implement remain on channel for P2P mode
wifi: ath12k: change WLAN_SCAN_PARAMS_MAX_IE_LEN from 256 to 512
wifi: ath12k: allow specific mgmt frame tx while vdev is not up
wifi: ath12k: fix broken structure wmi_vdev_create_cmd
wifi: ath12k: move peer delete after vdev stop of station for WCN7850
wifi: ath12k: designating channel frequency for ROC scan
wifi: ath12k: advertise P2P dev support for WCN7850

v2:
1. add Tested-on tag of QCN9274.
2. update copyright in patch #1, #2, #4 and #10.

drivers/net/wireless/ath/ath12k/Makefile | 3 +-
drivers/net/wireless/ath/ath12k/core.c | 3 +-
drivers/net/wireless/ath/ath12k/hw.c | 7 +-
drivers/net/wireless/ath/ath12k/mac.c | 360 +++++++++++++++++++----
drivers/net/wireless/ath/ath12k/p2p.c | 142 +++++++++
drivers/net/wireless/ath/ath12k/p2p.h | 23 ++
drivers/net/wireless/ath/ath12k/wmi.c | 118 +++++++-
drivers/net/wireless/ath/ath12k/wmi.h | 50 +++-
8 files changed, 638 insertions(+), 68 deletions(-)
create mode 100644 drivers/net/wireless/ath/ath12k/p2p.c
create mode 100644 drivers/net/wireless/ath/ath12k/p2p.h


base-commit: dc1702f7b1340dd741bca1005ab52a2c92cc6c84
--
2.34.1



2024-01-12 09:29:50

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 01/10] wifi: ath12k: change interface combination for P2P mode

Current interface combination doesn't support P2P mode. Change the
combination for P2P mode.

Also, there is a bug that when mesh is enabled but ap is not enabled.
In this situation, the mesh's max_interface of interface combination
won't be set.

So assign the max_interfaces for mesh directly.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kang Yang <[email protected]>
---

v2:
1. add Tested-on tag of QCN9274.
2. update copyright.

---
drivers/net/wireless/ath/ath12k/mac.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 88cec54c6c2e..bbf7224087dc 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/

#include <net/mac80211.h>
@@ -7259,9 +7259,10 @@ static int ath12k_mac_setup_iface_combinations(struct ath12k *ar)
struct ieee80211_iface_combination *combinations;
struct ieee80211_iface_limit *limits;
int n_limits, max_interfaces;
- bool ap, mesh;
+ bool ap, mesh, p2p;

ap = ab->hw_params->interface_modes & BIT(NL80211_IFTYPE_AP);
+ p2p = ab->hw_params->interface_modes & BIT(NL80211_IFTYPE_P2P_DEVICE);

mesh = IS_ENABLED(CONFIG_MAC80211_MESH) &&
ab->hw_params->interface_modes & BIT(NL80211_IFTYPE_MESH_POINT);
@@ -7270,9 +7271,15 @@ static int ath12k_mac_setup_iface_combinations(struct ath12k *ar)
if (!combinations)
return -ENOMEM;

- if (ap || mesh) {
+ if ((ap || mesh) && !p2p) {
n_limits = 2;
max_interfaces = 16;
+ } else if (p2p) {
+ n_limits = 3;
+ if (ap || mesh)
+ max_interfaces = 16;
+ else
+ max_interfaces = 3;
} else {
n_limits = 1;
max_interfaces = 1;
@@ -7287,14 +7294,22 @@ static int ath12k_mac_setup_iface_combinations(struct ath12k *ar)
limits[0].max = 1;
limits[0].types |= BIT(NL80211_IFTYPE_STATION);

- if (ap) {
+ if (ap || mesh || p2p)
limits[1].max = max_interfaces;
+
+ if (ap)
limits[1].types |= BIT(NL80211_IFTYPE_AP);
- }

if (mesh)
limits[1].types |= BIT(NL80211_IFTYPE_MESH_POINT);

+ if (p2p) {
+ limits[1].types |= BIT(NL80211_IFTYPE_P2P_CLIENT) |
+ BIT(NL80211_IFTYPE_P2P_GO);
+ limits[2].max = 1;
+ limits[2].types |= BIT(NL80211_IFTYPE_P2P_DEVICE);
+ }
+
combinations[0].limits = limits;
combinations[0].n_limits = n_limits;
combinations[0].max_interfaces = max_interfaces;
--
2.34.1


2024-01-12 09:29:52

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 02/10] wifi: ath12k: add P2P IE in beacon template

P2P Element is a necessary component of P2P protocol communication.
It contains the Vendor Specific Information Element which includes
the WFA OUI and an OUI Type indicating P2P.

Add P2P IE in beacon template, and implement WMI interface for it.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kang Yang <[email protected]>
---

v2:
1. add Tested-on tag of QCN9274.
2. update copyright.

---
drivers/net/wireless/ath/ath12k/mac.c | 85 ++++++++++++++++++++++++++-
drivers/net/wireless/ath/ath12k/wmi.c | 41 ++++++++++++-
drivers/net/wireless/ath/ath12k/wmi.h | 10 +++-
3 files changed, 132 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index bbf7224087dc..70a54cc52e44 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -1122,6 +1122,64 @@ static int ath12k_mac_op_config(struct ieee80211_hw *hw, u32 changed)
return ret;
}

+static int ath12k_mac_setup_bcn_p2p_ie(struct ath12k_vif *arvif,
+ struct sk_buff *bcn)
+{
+ struct ath12k *ar = arvif->ar;
+ struct ieee80211_mgmt *mgmt;
+ const u8 *p2p_ie;
+ int ret;
+
+ mgmt = (void *)bcn->data;
+ p2p_ie = cfg80211_find_vendor_ie(WLAN_OUI_WFA, WLAN_OUI_TYPE_WFA_P2P,
+ mgmt->u.beacon.variable,
+ bcn->len - (mgmt->u.beacon.variable -
+ bcn->data));
+ if (!p2p_ie) {
+ ath12k_warn(ar->ab, "no P2P ie found in beacon\n");
+ return -ENOENT;
+ }
+
+ ret = ath12k_wmi_p2p_go_bcn_ie(ar, arvif->vdev_id, p2p_ie);
+ if (ret) {
+ ath12k_warn(ar->ab, "failed to submit P2P GO bcn ie for vdev %i: %d\n",
+ arvif->vdev_id, ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int ath12k_mac_remove_vendor_ie(struct sk_buff *skb, unsigned int oui,
+ u8 oui_type, size_t ie_offset)
+{
+ size_t len;
+ const u8 *next;
+ const u8 *end;
+ u8 *ie;
+
+ if (WARN_ON(skb->len < ie_offset))
+ return -EINVAL;
+
+ ie = (u8 *)cfg80211_find_vendor_ie(oui, oui_type,
+ skb->data + ie_offset,
+ skb->len - ie_offset);
+ if (!ie)
+ return -ENOENT;
+
+ len = ie[1] + 2;
+ end = skb->data + skb->len;
+ next = ie + len;
+
+ if (WARN_ON(next > end))
+ return -EINVAL;
+
+ memmove(ie, next, end - next);
+ skb_trim(skb, skb->len - len);
+
+ return 0;
+}
+
static int ath12k_mac_setup_bcn_tmpl(struct ath12k_vif *arvif)
{
struct ath12k *ar = arvif->ar;
@@ -1154,14 +1212,37 @@ static int ath12k_mac_setup_bcn_tmpl(struct ath12k_vif *arvif)
ies, (skb_tail_pointer(bcn) - ies)))
arvif->wpaie_present = true;

- ret = ath12k_wmi_bcn_tmpl(ar, arvif->vdev_id, &offs, bcn);
+ if (arvif->vif->type == NL80211_IFTYPE_AP && arvif->vif->p2p) {
+ ret = ath12k_mac_setup_bcn_p2p_ie(arvif, bcn);
+ if (ret) {
+ ath12k_warn(ab, "failed to setup P2P GO bcn ie: %d\n",
+ ret);
+ goto free_bcn_skb;
+ }

- kfree_skb(bcn);
+ /* P2P IE is inserted by firmware automatically (as
+ * configured above) so remove it from the base beacon
+ * template to avoid duplicate P2P IEs in beacon frames.
+ */
+ ret = ath12k_mac_remove_vendor_ie(bcn, WLAN_OUI_WFA,
+ WLAN_OUI_TYPE_WFA_P2P,
+ offsetof(struct ieee80211_mgmt,
+ u.beacon.variable));
+ if (ret) {
+ ath12k_warn(ab, "failed to remove P2P vendor ie: %d\n",
+ ret);
+ goto free_bcn_skb;
+ }
+ }
+
+ ret = ath12k_wmi_bcn_tmpl(ar, arvif->vdev_id, &offs, bcn);

if (ret)
ath12k_warn(ab, "failed to submit beacon template command: %d\n",
ret);

+free_bcn_skb:
+ kfree_skb(bcn);
return ret;
}

diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index 11cc3005c0f9..1618760f54af 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/skbuff.h>
#include <linux/ctype.h>
@@ -1710,6 +1710,45 @@ int ath12k_wmi_send_bcn_offload_control_cmd(struct ath12k *ar,
return ret;
}

+int ath12k_wmi_p2p_go_bcn_ie(struct ath12k *ar, u32 vdev_id,
+ const u8 *p2p_ie)
+{
+ struct ath12k_wmi_pdev *wmi = ar->wmi;
+ struct wmi_p2p_go_set_beacon_ie_cmd *cmd;
+ struct wmi_tlv *tlv;
+ struct sk_buff *skb;
+ void *ptr;
+ int ret, len;
+ size_t p2p_ie_len = p2p_ie[1] + 2;
+ size_t aligned_len = roundup(p2p_ie_len, sizeof(u32));
+
+ len = sizeof(*cmd) + TLV_HDR_SIZE + aligned_len;
+
+ skb = ath12k_wmi_alloc_skb(wmi->wmi_ab, len);
+ if (!skb)
+ return -ENOMEM;
+ ptr = skb->data;
+ cmd = ptr;
+ cmd->tlv_header = ath12k_wmi_tlv_cmd_hdr(WMI_TAG_P2P_GO_SET_BEACON_IE,
+ sizeof(*cmd));
+ cmd->vdev_id = cpu_to_le32(vdev_id);
+ cmd->ie_buf_len = cpu_to_le32(p2p_ie_len);
+
+ ptr = skb->data + sizeof(*cmd);
+ tlv = ptr;
+ tlv->header = ath12k_wmi_tlv_cmd_hdr(WMI_TAG_ARRAY_BYTE,
+ aligned_len);
+ memcpy(tlv->value, p2p_ie, p2p_ie_len);
+
+ ret = ath12k_wmi_cmd_send(wmi, skb, WMI_P2P_GO_SET_BEACON_IE);
+ if (ret) {
+ ath12k_warn(ar->ab, "failed to send WMI_P2P_GO_SET_BEACON_IE\n");
+ dev_kfree_skb(skb);
+ }
+
+ return ret;
+}
+
int ath12k_wmi_bcn_tmpl(struct ath12k *ar, u32 vdev_id,
struct ieee80211_mutable_offsets *offs,
struct sk_buff *bcn)
diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
index 06e5b9b4049b..b92b37784f09 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.h
+++ b/drivers/net/wireless/ath/ath12k/wmi.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause-Clear */
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/

#ifndef ATH12K_WMI_H
@@ -3503,6 +3503,12 @@ struct wmi_bcn_tmpl_cmd {
__le32 esp_ie_offset;
} __packed;

+struct wmi_p2p_go_set_beacon_ie_cmd {
+ __le32 tlv_header;
+ __le32 vdev_id;
+ __le32 ie_buf_len;
+} __packed;
+
struct wmi_vdev_install_key_cmd {
__le32 tlv_header;
__le32 vdev_id;
@@ -4806,6 +4812,8 @@ int ath12k_wmi_cmd_send(struct ath12k_wmi_pdev *wmi, struct sk_buff *skb,
struct sk_buff *ath12k_wmi_alloc_skb(struct ath12k_wmi_base *wmi_sc, u32 len);
int ath12k_wmi_mgmt_send(struct ath12k *ar, u32 vdev_id, u32 buf_id,
struct sk_buff *frame);
+int ath12k_wmi_p2p_go_bcn_ie(struct ath12k *ar, u32 vdev_id,
+ const u8 *p2p_ie);
int ath12k_wmi_bcn_tmpl(struct ath12k *ar, u32 vdev_id,
struct ieee80211_mutable_offsets *offs,
struct sk_buff *bcn);
--
2.34.1


2024-01-12 09:30:00

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 03/10] wifi: ath12k: implement handling of P2P NoA event

The NoA(Notice of Absence) attribute is used by the P2P Group Owner to
signal its absence due to power save timing, concurrent operation, or
off-channel scanning. It is also used in the P2P Presence Request-Response
mechanism.

The NoA attribute shall be present in the P2P IE in the beacon frames
transmitted by a P2P Group Owner when a NoA schedule is being advertised,
or when the CTWindow is non-zero.

So add support to update P2P information after P2P GO is up through
event WMI_P2P_NOA_EVENTID, and always put it in probe resp.

Create p2p.c and p2p.h for P2P related functions and definitions.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kang Yang <[email protected]>
---

v2: add Tested-on tag of QCN9274.

---
drivers/net/wireless/ath/ath12k/Makefile | 3 +-
drivers/net/wireless/ath/ath12k/mac.c | 25 +++-
drivers/net/wireless/ath/ath12k/p2p.c | 142 +++++++++++++++++++++++
drivers/net/wireless/ath/ath12k/p2p.h | 23 ++++
drivers/net/wireless/ath/ath12k/wmi.c | 51 +++++++-
drivers/net/wireless/ath/ath12k/wmi.h | 31 +++++
6 files changed, 272 insertions(+), 3 deletions(-)
create mode 100644 drivers/net/wireless/ath/ath12k/p2p.c
create mode 100644 drivers/net/wireless/ath/ath12k/p2p.h

diff --git a/drivers/net/wireless/ath/ath12k/Makefile b/drivers/net/wireless/ath/ath12k/Makefile
index 62c52e733b5e..e296fe7f8d64 100644
--- a/drivers/net/wireless/ath/ath12k/Makefile
+++ b/drivers/net/wireless/ath/ath12k/Makefile
@@ -19,7 +19,8 @@ ath12k-y += core.o \
hw.o \
mhi.o \
pci.o \
- dp_mon.o
+ dp_mon.o \
+ p2p.o

ath12k-$(CONFIG_ATH12K_TRACING) += trace.o

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 70a54cc52e44..a4a00a6606b4 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -5045,6 +5045,25 @@ static int ath12k_mac_mgmt_tx(struct ath12k *ar, struct sk_buff *skb,
return 0;
}

+static void ath12k_mac_add_p2p_noa_ie(struct ath12k *ar,
+ struct ieee80211_vif *vif,
+ struct sk_buff *skb,
+ bool is_prb_rsp)
+{
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
+
+ if (likely(!is_prb_rsp))
+ return;
+
+ spin_lock_bh(&ar->data_lock);
+ if (arvif->u.ap.noa_data)
+ if (!pskb_expand_head(skb, 0, arvif->u.ap.noa_len,
+ GFP_ATOMIC))
+ skb_put_data(skb, arvif->u.ap.noa_data,
+ arvif->u.ap.noa_len);
+ spin_unlock_bh(&ar->data_lock);
+}
+
static void ath12k_mac_op_tx(struct ieee80211_hw *hw,
struct ieee80211_tx_control *control,
struct sk_buff *skb)
@@ -5068,10 +5087,10 @@ static void ath12k_mac_op_tx(struct ieee80211_hw *hw,
skb_cb->flags |= ATH12K_SKB_CIPHER_SET;
}

+ is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control);
if (info_flags & IEEE80211_TX_CTL_HW_80211_ENCAP) {
skb_cb->flags |= ATH12K_SKB_HW_80211_ENCAP;
} else if (ieee80211_is_mgmt(hdr->frame_control)) {
- is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control);
ret = ath12k_mac_mgmt_tx(ar, skb, is_prb_rsp);
if (ret) {
ath12k_warn(ar->ab, "failed to queue management frame %d\n",
@@ -5081,6 +5100,10 @@ static void ath12k_mac_op_tx(struct ieee80211_hw *hw,
return;
}

+ /* This is case only for P2P_GO */
+ if (vif->type == NL80211_IFTYPE_AP && vif->p2p)
+ ath12k_mac_add_p2p_noa_ie(ar, vif, skb, is_prb_rsp);
+
ret = ath12k_dp_tx(ar, arvif, skb);
if (ret) {
ath12k_warn(ar->ab, "failed to transmit frame %d\n", ret);
diff --git a/drivers/net/wireless/ath/ath12k/p2p.c b/drivers/net/wireless/ath/ath12k/p2p.c
new file mode 100644
index 000000000000..9f067dbd54b0
--- /dev/null
+++ b/drivers/net/wireless/ath/ath12k/p2p.c
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: ISC
+/*
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#include <net/mac80211.h>
+#include "core.h"
+#include "mac.h"
+#include "p2p.h"
+
+static void ath12k_p2p_noa_ie_fill(u8 *data, size_t len,
+ const struct ath12k_wmi_p2p_noa_info *noa)
+{
+ struct ieee80211_p2p_noa_attr *noa_attr;
+ u8 ctwindow = le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_CTWIN_TU);
+ bool oppps = le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_OPP_PS);
+ __le16 *noa_attr_len;
+ u16 attr_len;
+ u8 noa_descriptors = le32_get_bits(noa->noa_attr,
+ WMI_P2P_NOA_INFO_DESC_NUM);
+ int i;
+
+ /* P2P IE */
+ data[0] = WLAN_EID_VENDOR_SPECIFIC;
+ data[1] = len - 2;
+ data[2] = (WLAN_OUI_WFA >> 16) & 0xff;
+ data[3] = (WLAN_OUI_WFA >> 8) & 0xff;
+ data[4] = (WLAN_OUI_WFA >> 0) & 0xff;
+ data[5] = WLAN_OUI_TYPE_WFA_P2P;
+
+ /* NOA ATTR */
+ data[6] = IEEE80211_P2P_ATTR_ABSENCE_NOTICE;
+ noa_attr_len = (__le16 *)&data[7]; /* 2 bytes */
+ noa_attr = (struct ieee80211_p2p_noa_attr *)&data[9];
+
+ noa_attr->index = le32_get_bits(noa->noa_attr,
+ WMI_P2P_NOA_INFO_INDEX);
+ noa_attr->oppps_ctwindow = ctwindow;
+ if (oppps)
+ noa_attr->oppps_ctwindow |= IEEE80211_P2P_OPPPS_ENABLE_BIT;
+
+ for (i = 0; i < noa_descriptors; i++) {
+ noa_attr->desc[i].count =
+ __le32_to_cpu(noa->descriptors[i].type_count);
+ noa_attr->desc[i].duration = noa->descriptors[i].duration;
+ noa_attr->desc[i].interval = noa->descriptors[i].interval;
+ noa_attr->desc[i].start_time = noa->descriptors[i].start_time;
+ }
+
+ attr_len = 2; /* index + oppps_ctwindow */
+ attr_len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc);
+ *noa_attr_len = __cpu_to_le16(attr_len);
+}
+
+static size_t ath12k_p2p_noa_ie_len_compute(const struct ath12k_wmi_p2p_noa_info *noa)
+{
+ size_t len = 0;
+
+ if (!(le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_DESC_NUM)) &&
+ !(le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_OPP_PS)))
+ return 0;
+
+ len += 1 + 1 + 4; /* EID + len + OUI */
+ len += 1 + 2; /* noa attr + attr len */
+ len += 1 + 1; /* index + oppps_ctwindow */
+ len += le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_DESC_NUM) *
+ sizeof(struct ieee80211_p2p_noa_desc);
+
+ return len;
+}
+
+static void ath12k_p2p_noa_ie_assign(struct ath12k_vif *arvif, void *ie,
+ size_t len)
+{
+ struct ath12k *ar = arvif->ar;
+
+ lockdep_assert_held(&ar->data_lock);
+
+ kfree(arvif->u.ap.noa_data);
+
+ arvif->u.ap.noa_data = ie;
+ arvif->u.ap.noa_len = len;
+}
+
+static void __ath12k_p2p_noa_update(struct ath12k_vif *arvif,
+ const struct ath12k_wmi_p2p_noa_info *noa)
+{
+ struct ath12k *ar = arvif->ar;
+ void *ie;
+ size_t len;
+
+ lockdep_assert_held(&ar->data_lock);
+
+ ath12k_p2p_noa_ie_assign(arvif, NULL, 0);
+
+ len = ath12k_p2p_noa_ie_len_compute(noa);
+ if (!len)
+ return;
+
+ ie = kmalloc(len, GFP_ATOMIC);
+ if (!ie)
+ return;
+
+ ath12k_p2p_noa_ie_fill(ie, len, noa);
+ ath12k_p2p_noa_ie_assign(arvif, ie, len);
+}
+
+void ath12k_p2p_noa_update(struct ath12k_vif *arvif,
+ const struct ath12k_wmi_p2p_noa_info *noa)
+{
+ struct ath12k *ar = arvif->ar;
+
+ spin_lock_bh(&ar->data_lock);
+ __ath12k_p2p_noa_update(arvif, noa);
+ spin_unlock_bh(&ar->data_lock);
+}
+
+static void ath12k_p2p_noa_update_vdev_iter(void *data, u8 *mac,
+ struct ieee80211_vif *vif)
+{
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
+ struct ath12k_p2p_noa_arg *arg = data;
+
+ if (arvif->vdev_id != arg->vdev_id)
+ return;
+
+ ath12k_p2p_noa_update(arvif, arg->noa);
+}
+
+void ath12k_p2p_noa_update_by_vdev_id(struct ath12k *ar, u32 vdev_id,
+ const struct ath12k_wmi_p2p_noa_info *noa)
+{
+ struct ath12k_p2p_noa_arg arg = {
+ .vdev_id = vdev_id,
+ .noa = noa,
+ };
+
+ ieee80211_iterate_active_interfaces_atomic(ar->hw,
+ IEEE80211_IFACE_ITER_NORMAL,
+ ath12k_p2p_noa_update_vdev_iter,
+ &arg);
+}
diff --git a/drivers/net/wireless/ath/ath12k/p2p.h b/drivers/net/wireless/ath/ath12k/p2p.h
new file mode 100644
index 000000000000..b6f177fe4ff4
--- /dev/null
+++ b/drivers/net/wireless/ath/ath12k/p2p.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: ISC */
+/*
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved..
+ */
+
+#ifndef ATH12K_P2P_H
+#define ATH12K_P2P_H
+
+#include "wmi.h"
+
+struct ath12k_wmi_p2p_noa_info;
+
+struct ath12k_p2p_noa_arg {
+ u32 vdev_id;
+ const struct ath12k_wmi_p2p_noa_info *noa;
+};
+
+void ath12k_p2p_noa_update(struct ath12k_vif *arvif,
+ const struct ath12k_wmi_p2p_noa_info *noa);
+void ath12k_p2p_noa_update_by_vdev_id(struct ath12k *ar, u32 vdev_id,
+ const struct ath12k_wmi_p2p_noa_info *noa);
+
+#endif
diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index 1618760f54af..861565eaab3d 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -19,6 +19,7 @@
#include "mac.h"
#include "hw.h"
#include "peer.h"
+#include "p2p.h"

struct ath12k_wmi_svc_ready_parse {
bool wmi_svc_bitmap_done;
@@ -162,6 +163,10 @@ static const struct ath12k_wmi_tlv_policy ath12k_wmi_tlv_policies[] = {
.min_len = sizeof(struct wmi_probe_resp_tx_status_event) },
[WMI_TAG_VDEV_DELETE_RESP_EVENT] = {
.min_len = sizeof(struct wmi_vdev_delete_resp_event) },
+ [WMI_TAG_P2P_NOA_INFO] = {
+ .min_len = sizeof(struct ath12k_wmi_p2p_noa_info) },
+ [WMI_TAG_P2P_NOA_EVENT] = {
+ .min_len = sizeof(struct wmi_p2p_noa_event) },
};

static __le32 ath12k_wmi_tlv_hdr(u32 cmd, u32 len)
@@ -1051,7 +1056,7 @@ int ath12k_wmi_vdev_start(struct ath12k *ar, struct wmi_vdev_start_req_arg *arg,
tlv->header = ath12k_wmi_tlv_hdr(WMI_TAG_ARRAY_STRUCT, 0);

/* Note: This is a nested TLV containing:
- * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv]..
+ * [wmi_tlv][ath12k_wmi_p2p_noa_descriptor][wmi_tlv]..
*/

ptr += sizeof(*tlv);
@@ -6667,6 +6672,47 @@ static void ath12k_probe_resp_tx_status_event(struct ath12k_base *ab,
kfree(tb);
}

+static int ath12k_wmi_p2p_noa_event(struct ath12k_base *ab,
+ struct sk_buff *skb)
+{
+ const void **tb;
+ const struct wmi_p2p_noa_event *ev;
+ const struct ath12k_wmi_p2p_noa_info *noa;
+ struct ath12k *ar;
+ int ret, vdev_id;
+
+ tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
+ if (IS_ERR(tb)) {
+ ret = PTR_ERR(tb);
+ ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
+ return ret;
+ }
+
+ ev = tb[WMI_TAG_P2P_NOA_EVENT];
+ noa = tb[WMI_TAG_P2P_NOA_INFO];
+
+ if (!ev || !noa) {
+ kfree(tb);
+ return -EPROTO;
+ }
+
+ vdev_id = __le32_to_cpu(ev->vdev_id);
+
+ ath12k_dbg(ab, ATH12K_DBG_WMI,
+ "wmi tlv p2p noa vdev_id %i descriptors %u\n",
+ vdev_id, le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_DESC_NUM));
+ ar = ath12k_mac_get_ar_by_vdev_id(ab, vdev_id);
+ if (!ar) {
+ ath12k_warn(ab, "invalid vdev id %d in P2P NoA event\n",
+ vdev_id);
+ return -EINVAL;
+ }
+
+ ath12k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa);
+ kfree(tb);
+ return 0;
+}
+
static void ath12k_rfkill_state_change_event(struct ath12k_base *ab,
struct sk_buff *skb)
{
@@ -6811,6 +6857,9 @@ static void ath12k_wmi_op_rx(struct ath12k_base *ab, struct sk_buff *skb)
case WMI_VDEV_DELETE_RESP_EVENTID:
ath12k_vdev_delete_resp_event(ab, skb);
break;
+ case WMI_P2P_NOA_EVENTID:
+ ath12k_wmi_p2p_noa_event(ab, skb);
+ break;
/* TODO: Add remaining events */
default:
ath12k_dbg(ab, ATH12K_DBG_WMI, "Unknown eventid: 0x%x\n", id);
diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
index b92b37784f09..0b8203bb5381 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.h
+++ b/drivers/net/wireless/ath/ath12k/wmi.h
@@ -3489,6 +3489,37 @@ struct wmi_get_pdev_temperature_cmd {
__le32 pdev_id;
} __packed;

+#define WMI_P2P_MAX_NOA_DESCRIPTORS 4
+
+struct wmi_p2p_noa_event {
+ __le32 vdev_id;
+} __packed;
+
+struct ath12k_wmi_p2p_noa_descriptor {
+ __le32 type_count; /* 255: continuous schedule, 0: reserved */
+ __le32 duration; /* Absent period duration in micro seconds */
+ __le32 interval; /* Absent period interval in micro seconds */
+ __le32 start_time; /* 32 bit tsf time when in starts */
+} __packed;
+
+#define WMI_P2P_NOA_INFO_CHANGED_FLAG BIT(0)
+#define WMI_P2P_NOA_INFO_INDEX GENMASK(15, 8)
+#define WMI_P2P_NOA_INFO_OPP_PS BIT(16)
+#define WMI_P2P_NOA_INFO_CTWIN_TU GENMASK(23, 17)
+#define WMI_P2P_NOA_INFO_DESC_NUM GENMASK(31, 24)
+
+struct ath12k_wmi_p2p_noa_info {
+ /* Bit 0 - Flag to indicate an update in NOA schedule
+ * Bits 7-1 - Reserved
+ * Bits 15-8 - Index (identifies the instance of NOA sub element)
+ * Bit 16 - Opp PS state of the AP
+ * Bits 23-17 - Ctwindow in TUs
+ * Bits 31-24 - Number of NOA descriptors
+ */
+ __le32 noa_attr;
+ struct ath12k_wmi_p2p_noa_descriptor descriptors[WMI_P2P_MAX_NOA_DESCRIPTORS];
+} __packed;
+
#define WMI_BEACON_TX_BUFFER_SIZE 512

struct wmi_bcn_tmpl_cmd {
--
2.34.1


2024-01-12 09:30:03

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 04/10] wifi: ath12k: implement remain on channel for P2P mode

Implement remain on channel for p2p mode in ath12k_ops:
ath12k_mac_op_remain_on_channel
ath12k_mac_op_cancel_remain_on_channel

P2P device can trigger ROC scan. Then keep listening or sending management
frames on particular channels.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kang Yang <[email protected]>
---

v2:
1. add Tested-on tag of QCN9274.
2. update copyright.

--
drivers/net/wireless/ath/ath12k/core.c | 3 +-
drivers/net/wireless/ath/ath12k/mac.c | 113 +++++++++++++++++++++++++
drivers/net/wireless/ath/ath12k/wmi.c | 4 +
3 files changed, 119 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index d73e2d33a41e..d030534a3ef0 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/

#include <linux/module.h>
@@ -942,6 +942,7 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
ath12k_mac_drain_tx(ar);
complete(&ar->scan.started);
complete(&ar->scan.completed);
+ complete(&ar->scan.on_channel);
complete(&ar->peer_assoc_done);
complete(&ar->peer_delete_done);
complete(&ar->install_key_done);
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index a4a00a6606b4..92ba88d5e4e9 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7193,6 +7193,116 @@ static void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
}

+static int ath12k_mac_op_cancel_remain_on_channel(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif)
+{
+ struct ath12k *ar = hw->priv;
+
+ mutex_lock(&ar->conf_mutex);
+
+ spin_lock_bh(&ar->data_lock);
+ ar->scan.roc_notify = false;
+ spin_unlock_bh(&ar->data_lock);
+
+ ath12k_scan_abort(ar);
+
+ mutex_unlock(&ar->conf_mutex);
+
+ cancel_delayed_work_sync(&ar->scan.timeout);
+
+ return 0;
+}
+
+static int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_channel *chan,
+ int duration,
+ enum ieee80211_roc_type type)
+{
+ struct ath12k *ar = hw->priv;
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
+ struct ath12k_wmi_scan_req_arg arg;
+ int ret;
+ u32 scan_time_msec;
+
+ mutex_lock(&ar->conf_mutex);
+ spin_lock_bh(&ar->data_lock);
+ switch (ar->scan.state) {
+ case ATH12K_SCAN_IDLE:
+ reinit_completion(&ar->scan.started);
+ reinit_completion(&ar->scan.completed);
+ reinit_completion(&ar->scan.on_channel);
+ ar->scan.state = ATH12K_SCAN_STARTING;
+ ar->scan.is_roc = true;
+ ar->scan.vdev_id = arvif->vdev_id;
+ ar->scan.roc_freq = chan->center_freq;
+ ar->scan.roc_notify = true;
+ ret = 0;
+ break;
+ case ATH12K_SCAN_STARTING:
+ case ATH12K_SCAN_RUNNING:
+ case ATH12K_SCAN_ABORTING:
+ ret = -EBUSY;
+ break;
+ }
+ spin_unlock_bh(&ar->data_lock);
+
+ if (ret)
+ goto exit;
+
+ scan_time_msec = ar->hw->wiphy->max_remain_on_channel_duration * 2;
+
+ memset(&arg, 0, sizeof(arg));
+ ath12k_wmi_start_scan_init(ar, &arg);
+ arg.num_chan = 1;
+ arg.chan_list = kcalloc(arg.num_chan, sizeof(*arg.chan_list),
+ GFP_KERNEL);
+ if (!arg.chan_list) {
+ ret = -ENOMEM;
+ goto exit;
+ }
+
+ arg.vdev_id = arvif->vdev_id;
+ arg.scan_id = ATH12K_SCAN_ID;
+ arg.chan_list[0] = chan->center_freq;
+ arg.dwell_time_active = scan_time_msec;
+ arg.dwell_time_passive = scan_time_msec;
+ arg.max_scan_time = scan_time_msec;
+ arg.scan_flags |= WMI_SCAN_FLAG_PASSIVE;
+ arg.burst_duration = duration;
+
+ ret = ath12k_start_scan(ar, &arg);
+ if (ret) {
+ ath12k_warn(ar->ab, "failed to start roc scan: %d\n", ret);
+
+ spin_lock_bh(&ar->data_lock);
+ ar->scan.state = ATH12K_SCAN_IDLE;
+ spin_unlock_bh(&ar->data_lock);
+ goto free_chan_list;
+ }
+
+ ret = wait_for_completion_timeout(&ar->scan.on_channel, 3 * HZ);
+ if (ret == 0) {
+ ath12k_warn(ar->ab, "failed to switch to channel for roc scan\n");
+ ret = ath12k_scan_stop(ar);
+ if (ret)
+ ath12k_warn(ar->ab, "failed to stop scan: %d\n", ret);
+ ret = -ETIMEDOUT;
+ goto free_chan_list;
+ }
+
+ ieee80211_queue_delayed_work(ar->hw, &ar->scan.timeout,
+ msecs_to_jiffies(duration));
+
+ ret = 0;
+
+free_chan_list:
+ kfree(arg.chan_list);
+exit:
+ mutex_unlock(&ar->conf_mutex);
+ return ret;
+}
+
static const struct ieee80211_ops ath12k_ops = {
.tx = ath12k_mac_op_tx,
.wake_tx_queue = ieee80211_handle_wake_tx_queue,
@@ -7227,6 +7337,8 @@ static const struct ieee80211_ops ath12k_ops = {
.get_survey = ath12k_mac_op_get_survey,
.flush = ath12k_mac_op_flush,
.sta_statistics = ath12k_mac_op_sta_statistics,
+ .remain_on_channel = ath12k_mac_op_remain_on_channel,
+ .cancel_remain_on_channel = ath12k_mac_op_cancel_remain_on_channel,
};

static void ath12k_mac_update_ch_list(struct ath12k *ar,
@@ -7777,6 +7889,7 @@ int ath12k_mac_allocate(struct ath12k_base *ab)
init_completion(&ar->bss_survey_done);
init_completion(&ar->scan.started);
init_completion(&ar->scan.completed);
+ init_completion(&ar->scan.on_channel);

INIT_DELAYED_WORK(&ar->scan.timeout, ath12k_scan_timeout_work);
INIT_WORK(&ar->regd_update_work, ath12k_regd_update_work);
diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index 861565eaab3d..e10289de84c1 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -5050,6 +5050,8 @@ static void ath12k_wmi_event_scan_started(struct ath12k *ar)
break;
case ATH12K_SCAN_STARTING:
ar->scan.state = ATH12K_SCAN_RUNNING;
+ if (ar->scan.is_roc)
+ ieee80211_ready_on_channel(ar->hw);
complete(&ar->scan.started);
break;
}
@@ -5132,6 +5134,8 @@ static void ath12k_wmi_event_scan_foreign_chan(struct ath12k *ar, u32 freq)
case ATH12K_SCAN_RUNNING:
case ATH12K_SCAN_ABORTING:
ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
+ if (ar->scan.is_roc && ar->scan.roc_freq == freq)
+ complete(&ar->scan.on_channel);
break;
}
}
--
2.34.1


2024-01-12 09:30:14

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 06/10] wifi: ath12k: allow specific mgmt frame tx while vdev is not up

In current code, the management frames must be sent after vdev is started.
But for P2P device, vdev won't start until P2P negotiation is done. So
this logic doesn't make sense for P2P device.

Also use ar->conf_mutex to synchronize vdev delete and mgmt, TX.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kang Yang <[email protected]>
---

v2: add Tested-on tag of QCN9274.

---
drivers/net/wireless/ath/ath12k/mac.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 92ba88d5e4e9..70726e810093 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -4995,8 +4995,8 @@ static void ath12k_mgmt_over_wmi_tx_work(struct work_struct *work)
}

arvif = ath12k_vif_to_arvif(skb_cb->vif);
- if (ar->allocated_vdev_map & (1LL << arvif->vdev_id) &&
- arvif->is_started) {
+ mutex_lock(&ar->conf_mutex);
+ if (ar->allocated_vdev_map & (1LL << arvif->vdev_id)) {
ret = ath12k_mac_mgmt_tx_wmi(ar, arvif, skb);
if (ret) {
ath12k_warn(ar->ab, "failed to tx mgmt frame, vdev_id %d :%d\n",
@@ -5010,6 +5010,7 @@ static void ath12k_mgmt_over_wmi_tx_work(struct work_struct *work)
arvif->is_started);
ath12k_mgmt_over_wmi_tx_drop(ar, skb);
}
+ mutex_unlock(&ar->conf_mutex);
}
}

--
2.34.1


2024-01-12 09:30:20

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 08/10] wifi: ath12k: move peer delete after vdev stop of station for WCN7850

In current code, when STA/P2P Client connect to AP/P2P GO, the WMI
command sequence is:

peer_create->vdev_start->vdev_up

And sequence of STA/P2P Client disconnect from AP/P2P GO is:

peer_delete->vdev_down->vdev_stop

This sequence of disconnect is not opposite of connect. For STA or P2P
GO, bss peer is not needed by firmware during handling vdev stop
command. So with this sequence, STA and P2P GO can work normally.

But for P2P Client, firmware needs bss peer in some functions during
handling vdev stop command. The opposite sequence of disconnect should
be:

vdev_down->vdev_stop->peer_delete

So change the sequence of disconnect as above opposite sequence for
WCN7850.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kang Yang <[email protected]>
---

v2: add Tested-on tag of QCN9274.

---
drivers/net/wireless/ath/ath12k/mac.c | 99 +++++++++++++++------------
1 file changed, 54 insertions(+), 45 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 70726e810093..717bb26df163 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -1083,6 +1083,46 @@ static int ath12k_mac_monitor_stop(struct ath12k *ar)
return ret;
}

+static int ath12k_mac_vdev_stop(struct ath12k_vif *arvif)
+{
+ struct ath12k *ar = arvif->ar;
+ int ret;
+
+ lockdep_assert_held(&ar->conf_mutex);
+
+ reinit_completion(&ar->vdev_setup_done);
+
+ ret = ath12k_wmi_vdev_stop(ar, arvif->vdev_id);
+ if (ret) {
+ ath12k_warn(ar->ab, "failed to stop WMI vdev %i: %d\n",
+ arvif->vdev_id, ret);
+ goto err;
+ }
+
+ ret = ath12k_mac_vdev_setup_sync(ar);
+ if (ret) {
+ ath12k_warn(ar->ab, "failed to synchronize setup for vdev %i: %d\n",
+ arvif->vdev_id, ret);
+ goto err;
+ }
+
+ WARN_ON(ar->num_started_vdevs == 0);
+
+ ar->num_started_vdevs--;
+ ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "vdev %pM stopped, vdev_id %d\n",
+ arvif->vif->addr, arvif->vdev_id);
+
+ if (test_bit(ATH12K_CAC_RUNNING, &ar->dev_flags)) {
+ clear_bit(ATH12K_CAC_RUNNING, &ar->dev_flags);
+ ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "CAC Stopped for vdev %d\n",
+ arvif->vdev_id);
+ }
+
+ return 0;
+err:
+ return ret;
+}
+
static int ath12k_mac_op_config(struct ieee80211_hw *hw, u32 changed)
{
struct ath12k *ar = hw->priv;
@@ -3856,6 +3896,13 @@ static int ath12k_mac_op_sta_state(struct ieee80211_hw *hw,
sta->addr, arvif->vdev_id);
} else if ((old_state == IEEE80211_STA_NONE &&
new_state == IEEE80211_STA_NOTEXIST)) {
+ if (arvif->vdev_type == WMI_VDEV_TYPE_STA) {
+ ath12k_bss_disassoc(hw, vif);
+ ret = ath12k_mac_vdev_stop(arvif);
+ if (ret)
+ ath12k_warn(ar->ab, "failed to stop vdev %i: %d\n",
+ arvif->vdev_id, ret);
+ }
ath12k_dp_peer_cleanup(ar, arvif->vdev_id, sta->addr);

ret = ath12k_peer_delete(ar, arvif->vdev_id, sta->addr);
@@ -6176,46 +6223,6 @@ ath12k_mac_vdev_start_restart(struct ath12k_vif *arvif,
return 0;
}

-static int ath12k_mac_vdev_stop(struct ath12k_vif *arvif)
-{
- struct ath12k *ar = arvif->ar;
- int ret;
-
- lockdep_assert_held(&ar->conf_mutex);
-
- reinit_completion(&ar->vdev_setup_done);
-
- ret = ath12k_wmi_vdev_stop(ar, arvif->vdev_id);
- if (ret) {
- ath12k_warn(ar->ab, "failed to stop WMI vdev %i: %d\n",
- arvif->vdev_id, ret);
- goto err;
- }
-
- ret = ath12k_mac_vdev_setup_sync(ar);
- if (ret) {
- ath12k_warn(ar->ab, "failed to synchronize setup for vdev %i: %d\n",
- arvif->vdev_id, ret);
- goto err;
- }
-
- WARN_ON(ar->num_started_vdevs == 0);
-
- ar->num_started_vdevs--;
- ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "vdev %pM stopped, vdev_id %d\n",
- arvif->vif->addr, arvif->vdev_id);
-
- if (test_bit(ATH12K_CAC_RUNNING, &ar->dev_flags)) {
- clear_bit(ATH12K_CAC_RUNNING, &ar->dev_flags);
- ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "CAC Stopped for vdev %d\n",
- arvif->vdev_id);
- }
-
- return 0;
-err:
- return ret;
-}
-
static int ath12k_mac_vdev_start(struct ath12k_vif *arvif,
struct ieee80211_chanctx_conf *ctx)
{
@@ -6571,11 +6578,13 @@ ath12k_mac_op_unassign_vif_chanctx(struct ieee80211_hw *hw,
arvif->is_started = false;
}

- ret = ath12k_mac_vdev_stop(arvif);
- if (ret)
- ath12k_warn(ab, "failed to stop vdev %i: %d\n",
- arvif->vdev_id, ret);
-
+ if (arvif->vdev_type != WMI_VDEV_TYPE_STA) {
+ ath12k_bss_disassoc(hw, vif);
+ ret = ath12k_mac_vdev_stop(arvif);
+ if (ret)
+ ath12k_warn(ab, "failed to stop vdev %i: %d\n",
+ arvif->vdev_id, ret);
+ }
arvif->is_started = false;

if (ab->hw_params->vdev_start_delay &&
--
2.34.1


2024-01-12 09:30:27

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 09/10] wifi: ath12k: designating channel frequency for ROC scan

For P2P mode, the WLAN interface may be requested to remain on a
specific channel and then to send some management frames on that
channel. Now chananel frequency of wmi_mgmt_send_cmd is set as 0. As
a result, firmware may choose a default but wrong channel.

Fix it by assigning chanfreq field with the ROC channel frequency.

This change only applies to WCN7850, other chips are not affected.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kang Yang <[email protected]>
---

v2: add Tested-on tag of QCN9274.

---
drivers/net/wireless/ath/ath12k/wmi.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index b036f0e07f69..88fb8222fa96 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -732,6 +732,20 @@ static int ath12k_service_ready_event(struct ath12k_base *ab, struct sk_buff *sk
return 0;
}

+static u32 ath12k_wmi_mgmt_get_freq(struct ath12k *ar,
+ struct ieee80211_tx_info *info)
+{
+ struct ath12k_base *ab = ar->ab;
+ u32 freq = 0;
+
+ if (ab->hw_params->single_pdev_only &&
+ ar->scan.is_roc &&
+ (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN))
+ freq = ar->scan.roc_freq;
+
+ return freq;
+}
+
struct sk_buff *ath12k_wmi_alloc_skb(struct ath12k_wmi_base *wmi_ab, u32 len)
{
struct sk_buff *skb;
@@ -757,6 +771,7 @@ int ath12k_wmi_mgmt_send(struct ath12k *ar, u32 vdev_id, u32 buf_id,
{
struct ath12k_wmi_pdev *wmi = ar->wmi;
struct wmi_mgmt_send_cmd *cmd;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(frame);
struct wmi_tlv *frame_tlv;
struct sk_buff *skb;
u32 buf_len;
@@ -775,7 +790,7 @@ int ath12k_wmi_mgmt_send(struct ath12k *ar, u32 vdev_id, u32 buf_id,
sizeof(*cmd));
cmd->vdev_id = cpu_to_le32(vdev_id);
cmd->desc_id = cpu_to_le32(buf_id);
- cmd->chanfreq = 0;
+ cmd->chanfreq = cpu_to_le32(ath12k_wmi_mgmt_get_freq(ar, info));
cmd->paddr_lo = cpu_to_le32(lower_32_bits(ATH12K_SKB_CB(frame)->paddr));
cmd->paddr_hi = cpu_to_le32(upper_32_bits(ATH12K_SKB_CB(frame)->paddr));
cmd->frame_len = cpu_to_le32(frame->len);
--
2.34.1


2024-01-12 09:30:31

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 10/10] wifi: ath12k: advertise P2P dev support for WCN7850

Now that all the necessary pieces are implemented we can enable P2P
support for WCN7850.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kang Yang <[email protected]>
---

v2:
1. add Tested-on tag of QCN9274.
2. update copyright.

---
drivers/net/wireless/ath/ath12k/hw.c | 7 +++++--
drivers/net/wireless/ath/ath12k/mac.c | 8 ++++++++
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/hw.c b/drivers/net/wireless/ath/ath12k/hw.c
index de60d988d860..b71854ae842f 100644
--- a/drivers/net/wireless/ath/ath12k/hw.c
+++ b/drivers/net/wireless/ath/ath12k/hw.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/

#include <linux/types.h>
@@ -950,7 +950,10 @@ static const struct ath12k_hw_params ath12k_hw_params[] = {
.vdev_start_delay = true,

.interface_modes = BIT(NL80211_IFTYPE_STATION) |
- BIT(NL80211_IFTYPE_AP),
+ BIT(NL80211_IFTYPE_AP) |
+ BIT(NL80211_IFTYPE_P2P_DEVICE) |
+ BIT(NL80211_IFTYPE_P2P_CLIENT) |
+ BIT(NL80211_IFTYPE_P2P_GO),
.supports_monitor = false,

.idle_ps = true,
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 717bb26df163..af36d43e9eec 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -5635,17 +5635,25 @@ static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
case NL80211_IFTYPE_UNSPECIFIED:
case NL80211_IFTYPE_STATION:
arvif->vdev_type = WMI_VDEV_TYPE_STA;
+ if (vif->p2p)
+ arvif->vdev_subtype = WMI_VDEV_SUBTYPE_P2P_CLIENT;
break;
case NL80211_IFTYPE_MESH_POINT:
arvif->vdev_subtype = WMI_VDEV_SUBTYPE_MESH_11S;
fallthrough;
case NL80211_IFTYPE_AP:
arvif->vdev_type = WMI_VDEV_TYPE_AP;
+ if (vif->p2p)
+ arvif->vdev_subtype = WMI_VDEV_SUBTYPE_P2P_GO;
break;
case NL80211_IFTYPE_MONITOR:
arvif->vdev_type = WMI_VDEV_TYPE_MONITOR;
ar->monitor_vdev_id = bit;
break;
+ case NL80211_IFTYPE_P2P_DEVICE:
+ arvif->vdev_type = WMI_VDEV_TYPE_STA;
+ arvif->vdev_subtype = WMI_VDEV_SUBTYPE_P2P_DEVICE;
+ break;
default:
WARN_ON(1);
break;
--
2.34.1


2024-01-12 09:30:39

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 07/10] wifi: ath12k: fix broken structure wmi_vdev_create_cmd

Current structure wmi_vdev_create_cmd is not matched to the firmware
definition. So update it.

And update vdev_stats_id_valid for vdev_stats_id.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kang Yang <[email protected]>
---

v2: add Tested-on tag of QCN9274.

---
drivers/net/wireless/ath/ath12k/wmi.c | 5 +++++
drivers/net/wireless/ath/ath12k/wmi.h | 3 +++
2 files changed, 8 insertions(+)

diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index e10289de84c1..b036f0e07f69 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -828,7 +828,12 @@ int ath12k_wmi_vdev_create(struct ath12k *ar, u8 *macaddr,
cmd->vdev_subtype = cpu_to_le32(args->subtype);
cmd->num_cfg_txrx_streams = cpu_to_le32(WMI_NUM_SUPPORTED_BAND_MAX);
cmd->pdev_id = cpu_to_le32(args->pdev_id);
+ if (args->if_stats_id != ATH12K_INVAL_VDEV_STATS_ID)
+ cmd->vdev_stats_id_valid = cpu_to_le32(true);
+ else
+ cmd->vdev_stats_id_valid = cpu_to_le32(false);
cmd->vdev_stats_id = cpu_to_le32(args->if_stats_id);
+
ether_addr_copy(cmd->vdev_macaddr.addr, macaddr);

ptr = skb->data + sizeof(*cmd);
diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
index 0efed12dd7ab..74b0ee9f86bf 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.h
+++ b/drivers/net/wireless/ath/ath12k/wmi.h
@@ -2712,6 +2712,9 @@ struct wmi_vdev_create_cmd {
struct ath12k_wmi_mac_addr_params vdev_macaddr;
__le32 num_cfg_txrx_streams;
__le32 pdev_id;
+ __le32 mbssid_flags;
+ __le32 mbssid_tx_vdev_id;
+ __le32 vdev_stats_id_valid;
__le32 vdev_stats_id;
} __packed;

--
2.34.1


2024-01-12 09:33:01

by Kang Yang

[permalink] [raw]
Subject: [PATCH v2 05/10] wifi: ath12k: change WLAN_SCAN_PARAMS_MAX_IE_LEN from 256 to 512

Mac80211 needs more space for P2P scan ie in P2P mode, 256 is not
enough, resize it to 512.

Also delete the duplicate macro definitions in wmi.h.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kang Yang <[email protected]>
---

v2: add Tested-on tag of QCN9274.

---
drivers/net/wireless/ath/ath12k/wmi.h | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
index 0b8203bb5381..0efed12dd7ab 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.h
+++ b/drivers/net/wireless/ath/ath12k/wmi.h
@@ -168,10 +168,6 @@ struct wmi_tlv {
#define WLAN_SCAN_MAX_HINT_BSSID 10
#define MAX_RNR_BSS 5

-#define WLAN_SCAN_PARAMS_MAX_SSID 16
-#define WLAN_SCAN_PARAMS_MAX_BSSID 4
-#define WLAN_SCAN_PARAMS_MAX_IE_LEN 256
-
#define WMI_APPEND_TO_EXISTING_CHAN_LIST_FLAG 1

#define WMI_BA_MODE_BUFFER_SIZE_256 3
@@ -3146,7 +3142,7 @@ struct ath12k_wmi_element_info_arg {

#define WLAN_SCAN_PARAMS_MAX_SSID 16
#define WLAN_SCAN_PARAMS_MAX_BSSID 4
-#define WLAN_SCAN_PARAMS_MAX_IE_LEN 256
+#define WLAN_SCAN_PARAMS_MAX_IE_LEN 512

/* Values lower than this may be refused by some firmware revisions with a scan
* completion with a timedout reason.
--
2.34.1


2024-01-13 01:15:52

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 01/10] wifi: ath12k: change interface combination for P2P mode

On 1/12/2024 1:28 AM, Kang Yang wrote:
> Current interface combination doesn't support P2P mode. Change the
> combination for P2P mode.
>
> Also, there is a bug that when mesh is enabled but ap is not enabled.
> In this situation, the mesh's max_interface of interface combination
> won't be set.
>
> So assign the max_interfaces for mesh directly.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-13 01:17:42

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 02/10] wifi: ath12k: add P2P IE in beacon template

On 1/12/2024 1:28 AM, Kang Yang wrote:
> P2P Element is a necessary component of P2P protocol communication.
> It contains the Vendor Specific Information Element which includes
> the WFA OUI and an OUI Type indicating P2P.
>
> Add P2P IE in beacon template, and implement WMI interface for it.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
Acked-by: Jeff Johnson <[email protected]>



2024-01-13 01:22:55

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 03/10] wifi: ath12k: implement handling of P2P NoA event

On 1/12/2024 1:28 AM, Kang Yang wrote:
> The NoA(Notice of Absence) attribute is used by the P2P Group Owner to
> signal its absence due to power save timing, concurrent operation, or
> off-channel scanning. It is also used in the P2P Presence Request-Response
> mechanism.
>
> The NoA attribute shall be present in the P2P IE in the beacon frames
> transmitted by a P2P Group Owner when a NoA schedule is being advertised,
> or when the CTWindow is non-zero.
>
> So add support to update P2P information after P2P GO is up through
> event WMI_P2P_NOA_EVENTID, and always put it in probe resp.
>
> Create p2p.c and p2p.h for P2P related functions and definitions.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
> ---
>
> v2: add Tested-on tag of QCN9274.
>
> ---
> drivers/net/wireless/ath/ath12k/Makefile | 3 +-
> drivers/net/wireless/ath/ath12k/mac.c | 25 +++-
> drivers/net/wireless/ath/ath12k/p2p.c | 142 +++++++++++++++++++++++
> drivers/net/wireless/ath/ath12k/p2p.h | 23 ++++
> drivers/net/wireless/ath/ath12k/wmi.c | 51 +++++++-
> drivers/net/wireless/ath/ath12k/wmi.h | 31 +++++
> 6 files changed, 272 insertions(+), 3 deletions(-)
> create mode 100644 drivers/net/wireless/ath/ath12k/p2p.c
> create mode 100644 drivers/net/wireless/ath/ath12k/p2p.h
>
...
> @@ -6667,6 +6672,47 @@ static void ath12k_probe_resp_tx_status_event(struct ath12k_base *ab,
> kfree(tb);
> }
>
> +static int ath12k_wmi_p2p_noa_event(struct ath12k_base *ab,
> + struct sk_buff *skb)
> +{
> + const void **tb;
> + const struct wmi_p2p_noa_event *ev;
> + const struct ath12k_wmi_p2p_noa_info *noa;
> + struct ath12k *ar;
> + int ret, vdev_id;
> +
> + tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
> + if (IS_ERR(tb)) {
> + ret = PTR_ERR(tb);
> + ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
> + return ret;
> + }
> +
> + ev = tb[WMI_TAG_P2P_NOA_EVENT];
> + noa = tb[WMI_TAG_P2P_NOA_INFO];
> +
> + if (!ev || !noa) {
> + kfree(tb);
> + return -EPROTO;
> + }
> +
> + vdev_id = __le32_to_cpu(ev->vdev_id);
> +
> + ath12k_dbg(ab, ATH12K_DBG_WMI,
> + "wmi tlv p2p noa vdev_id %i descriptors %u\n",
> + vdev_id, le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_DESC_NUM));
> + ar = ath12k_mac_get_ar_by_vdev_id(ab, vdev_id);
> + if (!ar) {

missing kfree(tb);

> + ath12k_warn(ab, "invalid vdev id %d in P2P NoA event\n",
> + vdev_id);
> + return -EINVAL;
> + }
> +
> + ath12k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa);
> + kfree(tb);
> + return 0;
> +}
> +
> static void ath12k_rfkill_state_change_event(struct ath12k_base *ab,
> struct sk_buff *skb)
> {


2024-01-13 01:23:58

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 04/10] wifi: ath12k: implement remain on channel for P2P mode

On 1/12/2024 1:28 AM, Kang Yang wrote:
> Implement remain on channel for p2p mode in ath12k_ops:
> ath12k_mac_op_remain_on_channel
> ath12k_mac_op_cancel_remain_on_channel
>
> P2P device can trigger ROC scan. Then keep listening or sending management
> frames on particular channels.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-13 01:25:16

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 05/10] wifi: ath12k: change WLAN_SCAN_PARAMS_MAX_IE_LEN from 256 to 512

On 1/12/2024 1:28 AM, Kang Yang wrote:
> Mac80211 needs more space for P2P scan ie in P2P mode, 256 is not
> enough, resize it to 512.
>
> Also delete the duplicate macro definitions in wmi.h.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-13 01:28:45

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 06/10] wifi: ath12k: allow specific mgmt frame tx while vdev is not up

On 1/12/2024 1:28 AM, Kang Yang wrote:
> In current code, the management frames must be sent after vdev is started.
> But for P2P device, vdev won't start until P2P negotiation is done. So
> this logic doesn't make sense for P2P device.
>
> Also use ar->conf_mutex to synchronize vdev delete and mgmt, TX.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-13 01:29:22

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 07/10] wifi: ath12k: fix broken structure wmi_vdev_create_cmd

On 1/12/2024 1:28 AM, Kang Yang wrote:
> Current structure wmi_vdev_create_cmd is not matched to the firmware
> definition. So update it.
>
> And update vdev_stats_id_valid for vdev_stats_id.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-13 01:30:32

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 08/10] wifi: ath12k: move peer delete after vdev stop of station for WCN7850

On 1/12/2024 1:28 AM, Kang Yang wrote:
> In current code, when STA/P2P Client connect to AP/P2P GO, the WMI
> command sequence is:
>
> peer_create->vdev_start->vdev_up
>
> And sequence of STA/P2P Client disconnect from AP/P2P GO is:
>
> peer_delete->vdev_down->vdev_stop
>
> This sequence of disconnect is not opposite of connect. For STA or P2P
> GO, bss peer is not needed by firmware during handling vdev stop
> command. So with this sequence, STA and P2P GO can work normally.
>
> But for P2P Client, firmware needs bss peer in some functions during
> handling vdev stop command. The opposite sequence of disconnect should
> be:
>
> vdev_down->vdev_stop->peer_delete
>
> So change the sequence of disconnect as above opposite sequence for
> WCN7850.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
Acked-by: Jeff Johnson <[email protected]>



2024-01-13 01:31:44

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 09/10] wifi: ath12k: designating channel frequency for ROC scan

On 1/12/2024 1:28 AM, Kang Yang wrote:
> For P2P mode, the WLAN interface may be requested to remain on a
> specific channel and then to send some management frames on that
> channel. Now chananel frequency of wmi_mgmt_send_cmd is set as 0. As
> a result, firmware may choose a default but wrong channel.
>
> Fix it by assigning chanfreq field with the ROC channel frequency.
>
> This change only applies to WCN7850, other chips are not affected.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-13 01:32:39

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 10/10] wifi: ath12k: advertise P2P dev support for WCN7850

On 1/12/2024 1:28 AM, Kang Yang wrote:
> Now that all the necessary pieces are implemented we can enable P2P
> support for WCN7850.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-13 01:35:31

by Karthikeyan Periyasamy

[permalink] [raw]
Subject: Re: [PATCH v2 03/10] wifi: ath12k: implement handling of P2P NoA event


On 1/12/2024 2:58 PM, Kang Yang wrote:
> The NoA(Notice of Absence) attribute is used by the P2P Group Owner to
> signal its absence due to power save timing, concurrent operation, or
> off-channel scanning. It is also used in the P2P Presence Request-Response
> mechanism.
>
> The NoA attribute shall be present in the P2P IE in the beacon frames
> transmitted by a P2P Group Owner when a NoA schedule is being advertised,
> or when the CTWindow is non-zero.
>
> So add support to update P2P information after P2P GO is up through
> event WMI_P2P_NOA_EVENTID, and always put it in probe resp.
>
> Create p2p.c and p2p.h for P2P related functions and definitions.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
> ---
>
> v2: add Tested-on tag of QCN9274.
>
> ---
> drivers/net/wireless/ath/ath12k/Makefile | 3 +-
> drivers/net/wireless/ath/ath12k/mac.c | 25 +++-
> drivers/net/wireless/ath/ath12k/p2p.c | 142 +++++++++++++++++++++++
> drivers/net/wireless/ath/ath12k/p2p.h | 23 ++++
> drivers/net/wireless/ath/ath12k/wmi.c | 51 +++++++-
> drivers/net/wireless/ath/ath12k/wmi.h | 31 +++++
> 6 files changed, 272 insertions(+), 3 deletions(-)
> create mode 100644 drivers/net/wireless/ath/ath12k/p2p.c
> create mode 100644 drivers/net/wireless/ath/ath12k/p2p.h
>
> diff --git a/drivers/net/wireless/ath/ath12k/Makefile b/drivers/net/wireless/ath/ath12k/Makefile
> index 62c52e733b5e..e296fe7f8d64 100644
> --- a/drivers/net/wireless/ath/ath12k/Makefile
> +++ b/drivers/net/wireless/ath/ath12k/Makefile
> @@ -19,7 +19,8 @@ ath12k-y += core.o \
> hw.o \
> mhi.o \
> pci.o \
> - dp_mon.o
> + dp_mon.o \
> + p2p.o
>
> ath12k-$(CONFIG_ATH12K_TRACING) += trace.o
>
> diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
> index 70a54cc52e44..a4a00a6606b4 100644
> --- a/drivers/net/wireless/ath/ath12k/mac.c
> +++ b/drivers/net/wireless/ath/ath12k/mac.c
> @@ -5045,6 +5045,25 @@ static int ath12k_mac_mgmt_tx(struct ath12k *ar, struct sk_buff *skb,
> return 0;
> }
>
> +static void ath12k_mac_add_p2p_noa_ie(struct ath12k *ar,
> + struct ieee80211_vif *vif,
> + struct sk_buff *skb,
> + bool is_prb_rsp)
> +{
> + struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
> +
> + if (likely(!is_prb_rsp))
> + return;
> +
> + spin_lock_bh(&ar->data_lock);
> + if (arvif->u.ap.noa_data)
> + if (!pskb_expand_head(skb, 0, arvif->u.ap.noa_len,
> + GFP_ATOMIC))
> + skb_put_data(skb, arvif->u.ap.noa_data,
> + arvif->u.ap.noa_len);
> + spin_unlock_bh(&ar->data_lock);
> +}
> +
> static void ath12k_mac_op_tx(struct ieee80211_hw *hw,
> struct ieee80211_tx_control *control,
> struct sk_buff *skb)
> @@ -5068,10 +5087,10 @@ static void ath12k_mac_op_tx(struct ieee80211_hw *hw,
> skb_cb->flags |= ATH12K_SKB_CIPHER_SET;
> }
>
> + is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control);
> if (info_flags & IEEE80211_TX_CTL_HW_80211_ENCAP) {
> skb_cb->flags |= ATH12K_SKB_HW_80211_ENCAP;
> } else if (ieee80211_is_mgmt(hdr->frame_control)) {
> - is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control);
> ret = ath12k_mac_mgmt_tx(ar, skb, is_prb_rsp);
> if (ret) {
> ath12k_warn(ar->ab, "failed to queue management frame %d\n",
> @@ -5081,6 +5100,10 @@ static void ath12k_mac_op_tx(struct ieee80211_hw *hw,
> return;
> }
>
> + /* This is case only for P2P_GO */
> + if (vif->type == NL80211_IFTYPE_AP && vif->p2p)
> + ath12k_mac_add_p2p_noa_ie(ar, vif, skb, is_prb_rsp);
> +
> ret = ath12k_dp_tx(ar, arvif, skb);
> if (ret) {
> ath12k_warn(ar->ab, "failed to transmit frame %d\n", ret);
> diff --git a/drivers/net/wireless/ath/ath12k/p2p.c b/drivers/net/wireless/ath/ath12k/p2p.c
> new file mode 100644
> index 000000000000..9f067dbd54b0
> --- /dev/null
> +++ b/drivers/net/wireless/ath/ath12k/p2p.c
> @@ -0,0 +1,142 @@
> +// SPDX-License-Identifier: ISC
> +/*
> + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
> + */
> +
> +#include <net/mac80211.h>
> +#include "core.h"
> +#include "mac.h"
> +#include "p2p.h"
> +
> +static void ath12k_p2p_noa_ie_fill(u8 *data, size_t len,
> + const struct ath12k_wmi_p2p_noa_info *noa)
> +{
> + struct ieee80211_p2p_noa_attr *noa_attr;
> + u8 ctwindow = le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_CTWIN_TU);
> + bool oppps = le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_OPP_PS);
> + __le16 *noa_attr_len;
> + u16 attr_len;
> + u8 noa_descriptors = le32_get_bits(noa->noa_attr,
> + WMI_P2P_NOA_INFO_DESC_NUM);
> + int i;
> +
> + /* P2P IE */
> + data[0] = WLAN_EID_VENDOR_SPECIFIC;
> + data[1] = len - 2;
> + data[2] = (WLAN_OUI_WFA >> 16) & 0xff;
> + data[3] = (WLAN_OUI_WFA >> 8) & 0xff;
> + data[4] = (WLAN_OUI_WFA >> 0) & 0xff;
> + data[5] = WLAN_OUI_TYPE_WFA_P2P;
> +
> + /* NOA ATTR */
> + data[6] = IEEE80211_P2P_ATTR_ABSENCE_NOTICE;
> + noa_attr_len = (__le16 *)&data[7]; /* 2 bytes */
> + noa_attr = (struct ieee80211_p2p_noa_attr *)&data[9];
> +
> + noa_attr->index = le32_get_bits(noa->noa_attr,
> + WMI_P2P_NOA_INFO_INDEX);
> + noa_attr->oppps_ctwindow = ctwindow;
> + if (oppps)
> + noa_attr->oppps_ctwindow |= IEEE80211_P2P_OPPPS_ENABLE_BIT;
> +
> + for (i = 0; i < noa_descriptors; i++) {
> + noa_attr->desc[i].count =
> + __le32_to_cpu(noa->descriptors[i].type_count);
> + noa_attr->desc[i].duration = noa->descriptors[i].duration;
> + noa_attr->desc[i].interval = noa->descriptors[i].interval;
> + noa_attr->desc[i].start_time = noa->descriptors[i].start_time;
> + }
> +
> + attr_len = 2; /* index + oppps_ctwindow */
> + attr_len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc);
> + *noa_attr_len = __cpu_to_le16(attr_len);
> +}
> +
> +static size_t ath12k_p2p_noa_ie_len_compute(const struct ath12k_wmi_p2p_noa_info *noa)
> +{
> + size_t len = 0;
> +
> + if (!(le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_DESC_NUM)) &&
> + !(le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_OPP_PS)))
> + return 0;
> +
> + len += 1 + 1 + 4; /* EID + len + OUI */
> + len += 1 + 2; /* noa attr + attr len */
> + len += 1 + 1; /* index + oppps_ctwindow */
> + len += le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_DESC_NUM) *
> + sizeof(struct ieee80211_p2p_noa_desc);
> +
> + return len;
> +}
> +
> +static void ath12k_p2p_noa_ie_assign(struct ath12k_vif *arvif, void *ie,
> + size_t len)
> +{
> + struct ath12k *ar = arvif->ar;
> +
> + lockdep_assert_held(&ar->data_lock);
> +
> + kfree(arvif->u.ap.noa_data);
> +
> + arvif->u.ap.noa_data = ie;
> + arvif->u.ap.noa_len = len;
> +}
> +
> +static void __ath12k_p2p_noa_update(struct ath12k_vif *arvif,
> + const struct ath12k_wmi_p2p_noa_info *noa)
> +{
> + struct ath12k *ar = arvif->ar;
> + void *ie;
> + size_t len;
> +
> + lockdep_assert_held(&ar->data_lock);
> +
> + ath12k_p2p_noa_ie_assign(arvif, NULL, 0);
> +
> + len = ath12k_p2p_noa_ie_len_compute(noa);
> + if (!len)
> + return;
> +
> + ie = kmalloc(len, GFP_ATOMIC);
> + if (!ie)
> + return;
> +
> + ath12k_p2p_noa_ie_fill(ie, len, noa);
> + ath12k_p2p_noa_ie_assign(arvif, ie, len);
> +}
> +
> +void ath12k_p2p_noa_update(struct ath12k_vif *arvif,
> + const struct ath12k_wmi_p2p_noa_info *noa)
> +{
> + struct ath12k *ar = arvif->ar;
> +
> + spin_lock_bh(&ar->data_lock);
> + __ath12k_p2p_noa_update(arvif, noa);
> + spin_unlock_bh(&ar->data_lock);
> +}
> +
> +static void ath12k_p2p_noa_update_vdev_iter(void *data, u8 *mac,
> + struct ieee80211_vif *vif)
> +{
> + struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
> + struct ath12k_p2p_noa_arg *arg = data;
> +
> + if (arvif->vdev_id != arg->vdev_id)
> + return;
> +
> + ath12k_p2p_noa_update(arvif, arg->noa);
> +}
> +
> +void ath12k_p2p_noa_update_by_vdev_id(struct ath12k *ar, u32 vdev_id,
> + const struct ath12k_wmi_p2p_noa_info *noa)
> +{
> + struct ath12k_p2p_noa_arg arg = {
> + .vdev_id = vdev_id,
> + .noa = noa,
> + };
> +
> + ieee80211_iterate_active_interfaces_atomic(ar->hw,
> + IEEE80211_IFACE_ITER_NORMAL,
> + ath12k_p2p_noa_update_vdev_iter,
> + &arg);


ath12k_ar_to_hw(ar) is introduced to avoid direct access of hw from radio (ie, ar->hw).

This new helper function introduced by the patchset "[PATCH v2 1/2] wifi: ath12k: Refactor the mac80211 hw access from link/radio"


@jeff

Any comments ?


> +}
> diff --git a/drivers/net/wireless/ath/ath12k/p2p.h b/drivers/net/wireless/ath/ath12k/p2p.h
> new file mode 100644
> index 000000000000..b6f177fe4ff4
> --- /dev/null
> +++ b/drivers/net/wireless/ath/ath12k/p2p.h
> @@ -0,0 +1,23 @@
> +/* SPDX-License-Identifier: ISC */
> +/*
> + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved..
> + */
> +
> +#ifndef ATH12K_P2P_H
> +#define ATH12K_P2P_H
> +
> +#include "wmi.h"
> +
> +struct ath12k_wmi_p2p_noa_info;
> +
> +struct ath12k_p2p_noa_arg {
> + u32 vdev_id;
> + const struct ath12k_wmi_p2p_noa_info *noa;
> +};
> +
> +void ath12k_p2p_noa_update(struct ath12k_vif *arvif,
> + const struct ath12k_wmi_p2p_noa_info *noa);
> +void ath12k_p2p_noa_update_by_vdev_id(struct ath12k *ar, u32 vdev_id,
> + const struct ath12k_wmi_p2p_noa_info *noa);
> +
> +#endif
> diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
> index 1618760f54af..861565eaab3d 100644
> --- a/drivers/net/wireless/ath/ath12k/wmi.c
> +++ b/drivers/net/wireless/ath/ath12k/wmi.c
> @@ -19,6 +19,7 @@
> #include "mac.h"
> #include "hw.h"
> #include "peer.h"
> +#include "p2p.h"
>
> struct ath12k_wmi_svc_ready_parse {
> bool wmi_svc_bitmap_done;
> @@ -162,6 +163,10 @@ static const struct ath12k_wmi_tlv_policy ath12k_wmi_tlv_policies[] = {
> .min_len = sizeof(struct wmi_probe_resp_tx_status_event) },
> [WMI_TAG_VDEV_DELETE_RESP_EVENT] = {
> .min_len = sizeof(struct wmi_vdev_delete_resp_event) },
> + [WMI_TAG_P2P_NOA_INFO] = {
> + .min_len = sizeof(struct ath12k_wmi_p2p_noa_info) },
> + [WMI_TAG_P2P_NOA_EVENT] = {
> + .min_len = sizeof(struct wmi_p2p_noa_event) },
> };
>
> static __le32 ath12k_wmi_tlv_hdr(u32 cmd, u32 len)
> @@ -1051,7 +1056,7 @@ int ath12k_wmi_vdev_start(struct ath12k *ar, struct wmi_vdev_start_req_arg *arg,
> tlv->header = ath12k_wmi_tlv_hdr(WMI_TAG_ARRAY_STRUCT, 0);
>
> /* Note: This is a nested TLV containing:
> - * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv]..
> + * [wmi_tlv][ath12k_wmi_p2p_noa_descriptor][wmi_tlv]..
> */
>
> ptr += sizeof(*tlv);
> @@ -6667,6 +6672,47 @@ static void ath12k_probe_resp_tx_status_event(struct ath12k_base *ab,
> kfree(tb);
> }
>
> +static int ath12k_wmi_p2p_noa_event(struct ath12k_base *ab,
> + struct sk_buff *skb)
> +{
> + const void **tb;
> + const struct wmi_p2p_noa_event *ev;
> + const struct ath12k_wmi_p2p_noa_info *noa;
> + struct ath12k *ar;
> + int ret, vdev_id;
> +
> + tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
> + if (IS_ERR(tb)) {
> + ret = PTR_ERR(tb);
> + ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
> + return ret;
> + }
> +
> + ev = tb[WMI_TAG_P2P_NOA_EVENT];
> + noa = tb[WMI_TAG_P2P_NOA_INFO];
> +
> + if (!ev || !noa) {
> + kfree(tb);
> + return -EPROTO;
> + }
> +
> + vdev_id = __le32_to_cpu(ev->vdev_id);
> +
> + ath12k_dbg(ab, ATH12K_DBG_WMI,
> + "wmi tlv p2p noa vdev_id %i descriptors %u\n",
> + vdev_id, le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_DESC_NUM));
> + ar = ath12k_mac_get_ar_by_vdev_id(ab, vdev_id);
> + if (!ar) {
> + ath12k_warn(ab, "invalid vdev id %d in P2P NoA event\n",
> + vdev_id);
> + return -EINVAL;
> + }
> +
> + ath12k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa);
> + kfree(tb);
> + return 0;
> +}
> +
> static void ath12k_rfkill_state_change_event(struct ath12k_base *ab,
> struct sk_buff *skb)
> {
> @@ -6811,6 +6857,9 @@ static void ath12k_wmi_op_rx(struct ath12k_base *ab, struct sk_buff *skb)
> case WMI_VDEV_DELETE_RESP_EVENTID:
> ath12k_vdev_delete_resp_event(ab, skb);
> break;
> + case WMI_P2P_NOA_EVENTID:
> + ath12k_wmi_p2p_noa_event(ab, skb);
> + break;
> /* TODO: Add remaining events */
> default:
> ath12k_dbg(ab, ATH12K_DBG_WMI, "Unknown eventid: 0x%x\n", id);
> diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
> index b92b37784f09..0b8203bb5381 100644
> --- a/drivers/net/wireless/ath/ath12k/wmi.h
> +++ b/drivers/net/wireless/ath/ath12k/wmi.h
> @@ -3489,6 +3489,37 @@ struct wmi_get_pdev_temperature_cmd {
> __le32 pdev_id;
> } __packed;
>
> +#define WMI_P2P_MAX_NOA_DESCRIPTORS 4
> +
> +struct wmi_p2p_noa_event {
> + __le32 vdev_id;
> +} __packed;
> +
> +struct ath12k_wmi_p2p_noa_descriptor {
> + __le32 type_count; /* 255: continuous schedule, 0: reserved */
> + __le32 duration; /* Absent period duration in micro seconds */
> + __le32 interval; /* Absent period interval in micro seconds */
> + __le32 start_time; /* 32 bit tsf time when in starts */
> +} __packed;
> +
> +#define WMI_P2P_NOA_INFO_CHANGED_FLAG BIT(0)
> +#define WMI_P2P_NOA_INFO_INDEX GENMASK(15, 8)
> +#define WMI_P2P_NOA_INFO_OPP_PS BIT(16)
> +#define WMI_P2P_NOA_INFO_CTWIN_TU GENMASK(23, 17)
> +#define WMI_P2P_NOA_INFO_DESC_NUM GENMASK(31, 24)
> +
> +struct ath12k_wmi_p2p_noa_info {
> + /* Bit 0 - Flag to indicate an update in NOA schedule
> + * Bits 7-1 - Reserved
> + * Bits 15-8 - Index (identifies the instance of NOA sub element)
> + * Bit 16 - Opp PS state of the AP
> + * Bits 23-17 - Ctwindow in TUs
> + * Bits 31-24 - Number of NOA descriptors
> + */
> + __le32 noa_attr;
> + struct ath12k_wmi_p2p_noa_descriptor descriptors[WMI_P2P_MAX_NOA_DESCRIPTORS];
> +} __packed;
> +
> #define WMI_BEACON_TX_BUFFER_SIZE 512
>
> struct wmi_bcn_tmpl_cmd


Thanks

Karthikeyan


2024-01-13 01:44:59

by Karthikeyan Periyasamy

[permalink] [raw]
Subject: Re: [PATCH v2 04/10] wifi: ath12k: implement remain on channel for P2P mode


On 1/12/2024 2:58 PM, Kang Yang wrote:
> Implement remain on channel for p2p mode in ath12k_ops:
> ath12k_mac_op_remain_on_channel
> ath12k_mac_op_cancel_remain_on_channel
>
> P2P device can trigger ROC scan. Then keep listening or sending management
> frames on particular channels.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>
> ---
>
> v2:
> 1. add Tested-on tag of QCN9274.
> 2. update copyright.
>
> --
> drivers/net/wireless/ath/ath12k/core.c | 3 +-
> drivers/net/wireless/ath/ath12k/mac.c | 113 +++++++++++++++++++++++++
> drivers/net/wireless/ath/ath12k/wmi.c | 4 +
> 3 files changed, 119 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
> index d73e2d33a41e..d030534a3ef0 100644
> --- a/drivers/net/wireless/ath/ath12k/core.c
> +++ b/drivers/net/wireless/ath/ath12k/core.c
> @@ -1,7 +1,7 @@
> // SPDX-License-Identifier: BSD-3-Clause-Clear
> /*
> * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
> - * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
> + * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
> */
>
> #include <linux/module.h>
> @@ -942,6 +942,7 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
> ath12k_mac_drain_tx(ar);
> complete(&ar->scan.started);
> complete(&ar->scan.completed);
> + complete(&ar->scan.on_channel);
> complete(&ar->peer_assoc_done);
> complete(&ar->peer_delete_done);
> complete(&ar->install_key_done);
> diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
> index a4a00a6606b4..92ba88d5e4e9 100644
> --- a/drivers/net/wireless/ath/ath12k/mac.c
> +++ b/drivers/net/wireless/ath/ath12k/mac.c
> @@ -7193,6 +7193,116 @@ static void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,
> sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
> }
>
> +static int ath12k_mac_op_cancel_remain_on_channel(struct ieee80211_hw *hw,
> + struct ieee80211_vif *vif)
> +{
> + struct ath12k *ar = hw->priv;


Accessing the radio (ar) from hw->priv is modified in the patchset
"[PATCH v2 2/2] wifi: ath12k: Introduce the container for mac80211 hw".

This change has conflict.

@jeff,

Any comments ?

> +
> + mutex_lock(&ar->conf_mutex);
> +
> + spin_lock_bh(&ar->data_lock);
> + ar->scan.roc_notify = false;
> + spin_unlock_bh(&ar->data_lock);
> +
> + ath12k_scan_abort(ar);
> +
> + mutex_unlock(&ar->conf_mutex);
> +
> + cancel_delayed_work_sync(&ar->scan.timeout);
> +
> + return 0;
> +}
> +
> +static int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw,
> + struct ieee80211_vif *vif,
> + struct ieee80211_channel *chan,
> + int duration,
> + enum ieee80211_roc_type type)
> +{
> + struct ath12k *ar = hw->priv;


Accessing the radio (ar) from hw->priv is modified in the patchset
"[PATCH v2 2/2] wifi: ath12k: Introduce the container for mac80211 hw".

This change has conflict.

@jeff,

Any comments ?


> + struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
> + struct ath12k_wmi_scan_req_arg arg;
> + int ret;
> + u32 scan_time_msec;
> +
> + mutex_lock(&ar->conf_mutex);
> + spin_lock_bh(&ar->data_lock);
> + switch (ar->scan.state) {
> + case ATH12K_SCAN_IDLE:
> + reinit_completion(&ar->scan.started);
> + reinit_completion(&ar->scan.completed);
> + reinit_completion(&ar->scan.on_channel);
> + ar->scan.state = ATH12K_SCAN_STARTING;
> + ar->scan.is_roc = true;
> + ar->scan.vdev_id = arvif->vdev_id;
> + ar->scan.roc_freq = chan->center_freq;
> + ar->scan.roc_notify = true;
> + ret = 0;
> + break;
> + case ATH12K_SCAN_STARTING:
> + case ATH12K_SCAN_RUNNING:
> + case ATH12K_SCAN_ABORTING:
> + ret = -EBUSY;
> + break;
> + }
> + spin_unlock_bh(&ar->data_lock);
> +
> + if (ret)
> + goto exit;
> +
> + scan_time_msec = ar->hw->wiphy->max_remain_on_channel_duration * 2;
> +
> + memset(&arg, 0, sizeof(arg));
> + ath12k_wmi_start_scan_init(ar, &arg);
> + arg.num_chan = 1;
> + arg.chan_list = kcalloc(arg.num_chan, sizeof(*arg.chan_list),
> + GFP_KERNEL);
> + if (!arg.chan_list) {
> + ret = -ENOMEM;
> + goto exit;
> + }
> +
> + arg.vdev_id = arvif->vdev_id;
> + arg.scan_id = ATH12K_SCAN_ID;
> + arg.chan_list[0] = chan->center_freq;
> + arg.dwell_time_active = scan_time_msec;
> + arg.dwell_time_passive = scan_time_msec;
> + arg.max_scan_time = scan_time_msec;
> + arg.scan_flags |= WMI_SCAN_FLAG_PASSIVE;
> + arg.burst_duration = duration;
> +
> + ret = ath12k_start_scan(ar, &arg);
> + if (ret) {
> + ath12k_warn(ar->ab, "failed to start roc scan: %d\n", ret);
> +
> + spin_lock_bh(&ar->data_lock);
> + ar->scan.state = ATH12K_SCAN_IDLE;
> + spin_unlock_bh(&ar->data_lock);
> + goto free_chan_list;
> + }
> +
> + ret = wait_for_completion_timeout(&ar->scan.on_channel, 3 * HZ);
> + if (ret == 0) {
> + ath12k_warn(ar->ab, "failed to switch to channel for roc scan\n");
> + ret = ath12k_scan_stop(ar);
> + if (ret)
> + ath12k_warn(ar->ab, "failed to stop scan: %d\n", ret);
> + ret = -ETIMEDOUT;
> + goto free_chan_list;
> + }
> +
> + ieee80211_queue_delayed_work(ar->hw, &ar->scan.timeout,
> + msecs_to_jiffies(duration));


ath12k_ar_to_hw(ar) is introduced to avoid direct access of hw from
radio (ie, ar->hw).

This new helper function introduced by the patchset "[PATCH v2 1/2]
wifi: ath12k: Refactor the mac80211 hw access from link/radio"


@jeff

Any comments ?

> +
> + ret = 0;
> +
> +free_chan_list:
> + kfree(arg.chan_list);
> +exit:
> + mutex_unlock(&ar->conf_mutex);
> + return ret;
> +}
> +
> static const struct ieee80211_ops ath12k_ops = {
> .tx = ath12k_mac_op_tx,
> .wake_tx_queue = ieee80211_handle_wake_tx_queue,
> @@ -7227,6 +7337,8 @@ static const struct ieee80211_ops ath12k_ops = {
> .get_survey = ath12k_mac_op_get_survey,
> .flush = ath12k_mac_op_flush,
> .sta_statistics = ath12k_mac_op_sta_statistics,
> + .remain_on_channel = ath12k_mac_op_remain_on_channel,
> + .cancel_remain_on_channel = ath12k_mac_op_cancel_remain_on_channel,


Both these new mac_op callback need to rework based on the patchset
"[PATCH v2 0/2] wifi: ath12k: Introduce hw abstraction"


> };
>
> static void ath12k_mac_update_ch_list(struct ath12k *ar,
> @@ -7777,6 +7889,7 @@ int ath12k_mac_allocate(struct ath12k_base *ab)
> init_completion(&ar->bss_survey_done);
> init_completion(&ar->scan.started);
> init_completion(&ar->scan.completed);
> + init_completion(&ar->scan.on_channel);
>
> INIT_DELAYED_WORK(&ar->scan.timeout, ath12k_scan_timeout_work);
> INIT_WORK(&ar->regd_update_work, ath12k_regd_update_work);
> diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
> index 861565eaab3d..e10289de84c1 100644
> --- a/drivers/net/wireless/ath/ath12k/wmi.c
> +++ b/drivers/net/wireless/ath/ath12k/wmi.c
> @@ -5050,6 +5050,8 @@ static void ath12k_wmi_event_scan_started(struct ath12k *ar)
> break;
> case ATH12K_SCAN_STARTING:
> ar->scan.state = ATH12K_SCAN_RUNNING;
> + if (ar->scan.is_roc)
> + ieee80211_ready_on_channel(ar->hw);
> complete(&ar->scan.started);
> break;
> }
> @@ -5132,6 +5134,8 @@ static void ath12k_wmi_event_scan_foreign_chan(struct ath12k *ar, u32 freq)
> case ATH12K_SCAN_RUNNING:
> case ATH12K_SCAN_ABORTING:
> ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
> + if (ar->scan.is_roc && ar->scan.roc_freq == freq)
> + complete(&ar->scan.on_channel);
> break;
> }
> }


Thanks,

Karthikeyan


2024-01-13 02:06:22

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 03/10] wifi: ath12k: implement handling of P2P NoA event

On 1/12/2024 5:35 PM, Karthikeyan Periyasamy wrote:
>
> On 1/12/2024 2:58 PM, Kang Yang wrote:
>> + ieee80211_iterate_active_interfaces_atomic(ar->hw,
>> + IEEE80211_IFACE_ITER_NORMAL,
>> + ath12k_p2p_noa_update_vdev_iter,
>> + &arg);
>
>
> ath12k_ar_to_hw(ar) is introduced to avoid direct access of hw from radio (ie, ar->hw).
>
> This new helper function introduced by the patchset "[PATCH v2 1/2] wifi: ath12k: Refactor the mac80211 hw access from link/radio"
>
>
> @jeff
>
> Any comments ?

you are correct, we should use the helper function
Please rebase on hw abstraction series

/jeff

2024-01-17 13:22:43

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v2 03/10] wifi: ath12k: implement handling of P2P NoA event

Kang Yang <[email protected]> writes:

> The NoA(Notice of Absence) attribute is used by the P2P Group Owner to
> signal its absence due to power save timing, concurrent operation, or
> off-channel scanning. It is also used in the P2P Presence Request-Response
> mechanism.
>
> The NoA attribute shall be present in the P2P IE in the beacon frames
> transmitted by a P2P Group Owner when a NoA schedule is being advertised,
> or when the CTWindow is non-zero.
>
> So add support to update P2P information after P2P GO is up through
> event WMI_P2P_NOA_EVENTID, and always put it in probe resp.
>
> Create p2p.c and p2p.h for P2P related functions and definitions.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Kang Yang <[email protected]>

[...]

> +static void ath12k_mac_add_p2p_noa_ie(struct ath12k *ar,
> + struct ieee80211_vif *vif,
> + struct sk_buff *skb,
> + bool is_prb_rsp)
> +{
> + struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
> +
> + if (likely(!is_prb_rsp))
> + return;
> +
> + spin_lock_bh(&ar->data_lock);
> + if (arvif->u.ap.noa_data)
> + if (!pskb_expand_head(skb, 0, arvif->u.ap.noa_len,
> + GFP_ATOMIC))
> + skb_put_data(skb, arvif->u.ap.noa_data,
> + arvif->u.ap.noa_len);
> + spin_unlock_bh(&ar->data_lock);
> +}

The if checks can be simplified and please add empty lines:

spin_lock_bh(&ar->data_lock);

if (arvif->u.ap.noa_data &&
!pskb_expand_head(skb, 0, arvif->u.ap.noa_len, GFP_ATOMIC))
skb_put_data(skb, arvif->u.ap.noa_data,
arvif->u.ap.noa_len);

spin_unlock_bh(&ar->data_lock);

Though I'm not really fond of the idea having pskb_expand_head() call
within the if check but I guess it's the cleanest option here.

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

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