ATH11K Archive mirror
 help / color / mirror / Atom feed
From: Carl Huang <quic_cjhuang@quicinc.com>
To: <ath11k@lists.infradead.org>
Cc: <linux-wireless@vger.kernel.org>, <quic_cjhuang@quicinc.com>
Subject: [PATCH 2/2] wifi: ath11k: reports address list if chip supports 2 stations
Date: Fri, 14 Jul 2023 10:38:01 +0800	[thread overview]
Message-ID: <20230714023801.2621802-3-quic_cjhuang@quicinc.com> (raw)
In-Reply-To: <20230714023801.2621802-1-quic_cjhuang@quicinc.com>

Report address list to mac80211 layer so user doesn't need to specify
address when an interface is added because the address can be allocated
from the list by mac80211.

The derived addresses have LAA(Local Administered Address) bit set, and
only the first byte is changed. Take the 00:03:7f:xx:xx:xx as example to
derive:
addresses[0] is unchanged, it's siill 00:03:7f:xx:xx:xx,
addresses[1] is 02:03:7f:xx:xx:xx,
addresses[2] is 12:03:7f:xx:xx:xx,
addresses[3] is 22:03:7f:xx:xx:xx,
addresses[4] is 32:03:7f:xx:xx:xx.
However as only 3 addresses are reported now, so addresses[3] and addresses[4]
aren't actually derived.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3

Signed-off-by: Carl Huang <quic_cjhuang@quicinc.com>
---
 drivers/net/wireless/ath/ath11k/mac.c | 30 +++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 3a9494bc944c..f3cc6f140c8a 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -9268,6 +9268,33 @@ static int ath11k_mac_setup_channels_rates(struct ath11k *ar,
 	return 0;
 }
 
+static void ath11k_mac_setup_mac_address_list(struct ath11k *ar)
+{
+	struct mac_address *addresses;
+	u16 n_addresses;
+	int i;
+
+	if (!ar->ab->hw_params.support_dual_stations)
+		return;
+
+	n_addresses = ar->ab->hw_params.num_vdevs;
+	addresses = kcalloc(n_addresses, sizeof(*addresses), GFP_KERNEL);
+	if (!addresses)
+		return;
+
+	memcpy(addresses[0].addr, ar->mac_addr, ETH_ALEN);
+	for (i = 1; i < n_addresses; i++) {
+		memcpy(addresses[i].addr, ar->mac_addr, ETH_ALEN);
+		/* set Local Administered Address bit */
+		addresses[i].addr[0] |= 0x2;
+
+		addresses[i].addr[0] += (i - 1) << 4;
+	}
+
+	ar->hw->wiphy->addresses = addresses;
+	ar->hw->wiphy->n_addresses = n_addresses;
+}
+
 static int ath11k_mac_setup_iface_combinations(struct ath11k *ar)
 {
 	struct ath11k_base *ab = ar->ab;
@@ -9391,6 +9418,8 @@ static void __ath11k_mac_unregister(struct ath11k *ar)
 	kfree(ar->hw->wiphy->iface_combinations[0].limits);
 	kfree(ar->hw->wiphy->iface_combinations);
 
+	kfree(ar->hw->wiphy->addresses);
+
 	SET_IEEE80211_DEV(ar->hw, NULL);
 }
 
@@ -9433,6 +9462,7 @@ static int __ath11k_mac_register(struct ath11k *ar)
 	ath11k_pdev_caps_update(ar);
 
 	SET_IEEE80211_PERM_ADDR(ar->hw, ar->mac_addr);
+	ath11k_mac_setup_mac_address_list(ar);
 
 	SET_IEEE80211_DEV(ar->hw, ab->dev);
 
-- 
2.34.1


-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

      parent reply	other threads:[~2023-07-14  2:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-14  2:37 [PATCH 0/2] wifi: ath11k: support 2 station interfaces Carl Huang
2023-07-14  2:38 ` [PATCH 1/2] wifi: ath11k: supports " Carl Huang
2024-02-13 16:17   ` Kalle Valo
2024-02-15 11:23   ` Kalle Valo
2024-05-10  8:22   ` Luca Weiss
2024-05-10 10:18     ` Kalle Valo
2024-05-10 12:03       ` Carl Huang
2024-05-10 13:04         ` Carl Huang
2024-05-10 13:26           ` Luca Weiss
2024-05-11  2:50             ` Carl Huang
2024-05-10 13:57         ` Kalle Valo
2024-05-11  3:12           ` Carl Huang
2024-05-16 11:45             ` Linux regression tracking (Thorsten Leemhuis)
2024-05-16 14:11               ` Jeff Johnson
2024-05-17  5:25                 ` Kalle Valo
2024-05-17  6:04                   ` Thorsten Leemhuis
2024-05-17  7:39                     ` Kalle Valo
2024-05-19 17:51                       ` Linux regression tracking (Thorsten Leemhuis)
2024-05-10 11:35     ` Carl Huang
2024-05-10 12:58       ` Luca Weiss
2023-07-14  2:38 ` Carl Huang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230714023801.2621802-3-quic_cjhuang@quicinc.com \
    --to=quic_cjhuang@quicinc.com \
    --cc=ath11k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).