* [PATCH V2 2/3] wifi: ath11k: look for DT node for each radio
2023-04-18 9:38 [PATCH V2 1/3] dt-bindings: net: wireless: qcom,ath11k: allow describing radios Rafał Miłecki
@ 2023-04-18 9:38 ` Rafał Miłecki
2023-04-18 9:38 ` [PATCH V2 3/3] wifi: ath11k: support reading radio MAC from DT Rafał Miłecki
2023-04-19 20:05 ` [PATCH V2 1/3] dt-bindings: net: wireless: qcom,ath11k: allow describing radios Krzysztof Kozlowski
2 siblings, 0 replies; 4+ messages in thread
From: Rafał Miłecki @ 2023-04-18 9:38 UTC (permalink / raw)
To: Kalle Valo, Rob Herring, Krzysztof Kozlowski
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
ath11k, linux-wireless, netdev, devicetree, linux-kernel,
Robert Marko, Rafał Miłecki
From: Rafał Miłecki <rafal@milecki.pl>
Updated DT binding allows describing each chip radio.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
drivers/net/wireless/ath/ath11k/core.h | 2 ++
drivers/net/wireless/ath/ath11k/mac.c | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index 0830276e5028..1a583adf2ab1 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -13,6 +13,7 @@
#include <linux/bitfield.h>
#include <linux/dmi.h>
#include <linux/ctype.h>
+#include <linux/of.h>
#include <linux/rhashtable.h>
#include <linux/average.h>
#include "qmi.h"
@@ -592,6 +593,7 @@ struct ath11k_per_peer_tx_stats {
struct ath11k {
struct ath11k_base *ab;
struct ath11k_pdev *pdev;
+ struct device_node *np;
struct ieee80211_hw *hw;
struct ieee80211_ops *ops;
struct ath11k_pdev_wmi *wmi;
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index cad832e0e6b8..ad5a22d12bd3 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -9344,6 +9344,25 @@ int ath11k_mac_register(struct ath11k_base *ab)
return ret;
}
+static struct device_node *ath11k_mac_find_radio_node(struct ath11k_base *ab, int i)
+{
+ struct device_node *np;
+
+ for_each_child_of_node(ab->dev->of_node, np) {
+ u32 reg;
+ int err;
+
+ if (strcmp(np->name, "radio"))
+ continue;
+
+ err = of_property_read_u32(np, "reg", ®);
+ if (!err && reg == i)
+ return np;
+ }
+
+ return NULL;
+}
+
int ath11k_mac_allocate(struct ath11k_base *ab)
{
struct ieee80211_hw *hw;
@@ -9369,6 +9388,7 @@ int ath11k_mac_allocate(struct ath11k_base *ab)
ar->ab = ab;
ar->pdev = pdev;
ar->pdev_idx = i;
+ ar->np = ath11k_mac_find_radio_node(ab, i);
ar->lmac_id = ath11k_hw_get_mac_from_pdev_id(&ab->hw_params, i);
ar->wmi = &ab->wmi_ab.wmi[i];
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH V2 3/3] wifi: ath11k: support reading radio MAC from DT
2023-04-18 9:38 [PATCH V2 1/3] dt-bindings: net: wireless: qcom,ath11k: allow describing radios Rafał Miłecki
2023-04-18 9:38 ` [PATCH V2 2/3] wifi: ath11k: look for DT node for each radio Rafał Miłecki
@ 2023-04-18 9:38 ` Rafał Miłecki
2023-04-19 20:05 ` [PATCH V2 1/3] dt-bindings: net: wireless: qcom,ath11k: allow describing radios Krzysztof Kozlowski
2 siblings, 0 replies; 4+ messages in thread
From: Rafał Miłecki @ 2023-04-18 9:38 UTC (permalink / raw)
To: Kalle Valo, Rob Herring, Krzysztof Kozlowski
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
ath11k, linux-wireless, netdev, devicetree, linux-kernel,
Robert Marko, Rafał Miłecki
From: Rafał Miłecki <rafal@milecki.pl>
On some devices (most routers) MAC is stored in an NVMEM cell. Support
reading it.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
drivers/net/wireless/ath/ath11k/mac.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index ad5a22d12bd3..6550bb5b2ece 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -8,6 +8,7 @@
#include <linux/etherdevice.h>
#include <linux/bitfield.h>
#include <linux/inetdevice.h>
+#include <linux/of_net.h>
#include <net/if_inet6.h>
#include <net/ipv6.h>
@@ -9292,7 +9293,7 @@ int ath11k_mac_register(struct ath11k_base *ab)
struct ath11k_pdev *pdev;
int i;
int ret;
- u8 mac_addr[ETH_ALEN] = {0};
+ u8 device_mac_addr[ETH_ALEN] = {0};
if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags))
return 0;
@@ -9305,18 +9306,22 @@ int ath11k_mac_register(struct ath11k_base *ab)
if (ret)
return ret;
- device_get_mac_address(ab->dev, mac_addr);
+ device_get_mac_address(ab->dev, device_mac_addr);
for (i = 0; i < ab->num_radios; i++) {
+ u8 radio_mac_addr[ETH_ALEN];
+
pdev = &ab->pdevs[i];
ar = pdev->ar;
- if (ab->pdevs_macaddr_valid) {
+ if (!of_get_mac_address(ar->np, radio_mac_addr)) {
+ ether_addr_copy(ar->mac_addr, radio_mac_addr);
+ } else if (ab->pdevs_macaddr_valid) {
ether_addr_copy(ar->mac_addr, pdev->mac_addr);
} else {
- if (is_zero_ether_addr(mac_addr))
+ if (is_zero_ether_addr(device_mac_addr))
ether_addr_copy(ar->mac_addr, ab->mac_addr);
else
- ether_addr_copy(ar->mac_addr, mac_addr);
+ ether_addr_copy(ar->mac_addr, device_mac_addr);
ar->mac_addr[4] += i;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH V2 1/3] dt-bindings: net: wireless: qcom,ath11k: allow describing radios
2023-04-18 9:38 [PATCH V2 1/3] dt-bindings: net: wireless: qcom,ath11k: allow describing radios Rafał Miłecki
2023-04-18 9:38 ` [PATCH V2 2/3] wifi: ath11k: look for DT node for each radio Rafał Miłecki
2023-04-18 9:38 ` [PATCH V2 3/3] wifi: ath11k: support reading radio MAC from DT Rafał Miłecki
@ 2023-04-19 20:05 ` Krzysztof Kozlowski
2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-04-19 20:05 UTC (permalink / raw)
To: Rafał Miłecki, Kalle Valo, Rob Herring,
Krzysztof Kozlowski
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
ath11k, linux-wireless, netdev, devicetree, linux-kernel,
Robert Marko, Rafał Miłecki
On 18/04/2023 11:38, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> Qualcomm ath11k chipsets can have up to 3 radios. Each radio may need to
> be additionally described by including its MAC or available frequency
> ranges.
The binding looks fine, but I wonder what is the radio here? It feels
like one antenna, e.g. 2.4 or 5 GHz, but you added $ref to
ieee80211.yaml which is used for entire device. What is the "radio" here?
>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
> V2: Fix dt_binding_check (add address + size cells & reg)
> ---
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread