[OpenWrt-Devel] [PATCH] ipq806x: add ath10k calibration data MAC addresses patching
Christian Lamparter
chunkeey at gmail.com
Sat Dec 15 15:10:39 EST 2018
On Wednesday, November 14, 2018 8:39:22 PM CET Ben Greear wrote:
> On 11/01/2018 03:18 AM, Felix Fietkau wrote:
> > On 2018-10-28 17:39, Christian Lamparter wrote:
> >> Ben Greear reported in his patch:
> >> |Subject: netgear r7800: Fix mac address of radios.
> >> |
> >> |Reloading the driver causes the phyX to change, and that
> >> |caused the MAC address to change.
> >>
> >> This is because all ODM/OEMs except QCA bothered to write
> >> the correct MAC address for the ath10k wifi into the
> >> calibration data.
> > I don't think that's a strong enough reason to further propagate the
> > messy calibration data patching.
> > How about checking the sysfs device path in the hotplug script instead
> > to make sure we're changing the MAC for the right wifi device?
>
> Would this mean that the NIC is loaded with one (potentially bogus)
> MAC, and then hotplug would very soon after set the proper MAC?
>
> If so, that is liable to mess up stock ath10k firmware since it will not
> properly calculate its rx-bssid mask.
Let's test it then.
Ben, Felix: I've prepared a big, one in all, test patch for the R7800 -
that if viable will be split up, upstreamed and merged accordingly.
This patch contains:
0. ath10k and ath10k-ct fixes that implement Felix request to
"call pdev_set_base_macaddr_cmdid before bringing up the first vif".
This is in the "976-ath10k-implement-set-base-macaddr" patch.
(Note: the ath10k driver had no support code for this function, nor
does it mention what the data the pdev_set_base_macaddr_cmdid takes.
I assume it's just 6-bytes for the base MAC.)
Ben: Can you please comment if this is all right, or if something
needs to be changed?
1. 998-ath10k-retrieve-MAC-address-from-system-firmware-if-.patch
This is an upstream patch
2. 950-call-of_get_mac_address-from-device.patch
A hack that makes it work. This could be a point of conflict.
3. R7800 dts changes
I hope they are correct enough. I don't have the hardware to test
it.
4. (userspace code).
In the mean time, because this is so much new, experimental stuff. I'll go
ahead with the ugly firmware patching for now until this is ready for
prime time.
Regards,
Christian
---
commit ef013d0f30d406a5378d21832562c1ffc0f0f29f
Author: Christian Lamparter <chunkeey at gmail.com>
Date: Sat Dec 15 10:56:14 2018 +0100
ipq806x: R7800: mtd-mac-address test
diff --git a/package/kernel/ath10k-ct/patches/976-ath10k-implement-set-base-macaddr.patch b/package/kernel/ath10k-ct/patches/976-ath10k-implement-set-base-macaddr.patch
new file mode 100644
index 0000000000..46dba87a93
--- /dev/null
+++ b/package/kernel/ath10k-ct/patches/976-ath10k-implement-set-base-macaddr.patch
@@ -0,0 +1,172 @@
+--- a/ath10k-4.16/core.c
++++ b/ath10k-4.16/core.c
+@@ -2621,6 +2621,13 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
+ goto err_hif_stop;
+ }
+
++ status = ath10k_wmi_pdev_set_base_macaddr(ar, ar->mac_addr);
++ if (status) {
++ ath10k_err(ar,
++ "failed to set base mac address: %d\n", status);
++ goto err_hif_stop;
++ }
++
+ /* Some firmware revisions do not properly set up hardware rx filter
+ * registers.
+ *
+--- a/ath10k-4.16/wmi-ops.h
++++ b/ath10k-4.16/wmi-ops.h
+@@ -64,6 +64,8 @@ struct wmi_ops {
+
+ enum wmi_txbf_conf (*get_txbf_conf_scheme)(struct ath10k *ar);
+
++ struct sk_buff *(*gen_pdev_set_base_macaddr)(struct ath10k *ar,
++ const u8 macaddr[ETH_ALEN]);
+ struct sk_buff *(*gen_pdev_suspend)(struct ath10k *ar, u32 suspend_opt);
+ struct sk_buff *(*gen_pdev_resume)(struct ath10k *ar);
+ struct sk_buff *(*gen_pdev_set_rd)(struct ath10k *ar, u16 rd, u16 rd2g,
+@@ -503,6 +505,22 @@ ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
+ ar->wmi.cmd->pdev_set_regdomain_cmdid);
+ }
+
++static inline int
++ath10k_wmi_pdev_set_base_macaddr(struct ath10k *ar, const u8 macaddr[ETH_ALEN])
++{
++ struct sk_buff *skb;
++
++ if (!ar->wmi.ops->gen_pdev_set_base_macaddr)
++ return -EOPNOTSUPP;
++
++ skb = ar->wmi.ops->gen_pdev_set_base_macaddr(ar, macaddr);
++ if (IS_ERR(skb))
++ return PTR_ERR(skb);
++
++ return ath10k_wmi_cmd_send(ar, skb,
++ ar->wmi.cmd->pdev_set_base_macaddr_cmdid);
++}
++
+ static inline int
+ ath10k_wmi_pdev_suspend_target(struct ath10k *ar, u32 suspend_opt)
+ {
+--- a/ath10k-4.16/wmi-tlv.c
++++ b/ath10k-4.16/wmi-tlv.c
+@@ -2228,6 +2228,29 @@ ath10k_wmi_tlv_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
+ return skb;
+ }
+
++static struct sk_buff *
++ath10k_wmi_tlv_op_gen_pdev_set_base_macaddr(struct ath10k *ar,
++ const u8 addr[ETH_ALEN])
++{
++ struct wmi_pdev_set_base_macaddr_cmd *cmd;
++ struct wmi_tlv *tlv;
++ struct sk_buff *skb;
++
++ skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
++ if (!skb)
++ return ERR_PTR(-ENOMEM);
++
++ tlv = (void *)skb->data;
++ tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_BASE_MACADDR_CMD);
++ tlv->len = __cpu_to_le16(sizeof(*cmd));
++ cmd = (void *)tlv->value;
++ ether_addr_copy(cmd->mac_addr.addr, addr);
++
++ ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set base macaddr\n");
++ return skb;
++}
++
++
+ static struct sk_buff *
+ ath10k_wmi_tlv_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
+ const u8 peer_addr[ETH_ALEN])
+@@ -4112,6 +4135,8 @@ static const struct wmi_ops wmi_tlv_ops = {
+ .gen_pdev_resume = ath10k_wmi_tlv_op_gen_pdev_resume,
+ .gen_pdev_set_rd = ath10k_wmi_tlv_op_gen_pdev_set_rd,
+ .gen_pdev_set_param = ath10k_wmi_tlv_op_gen_pdev_set_param,
++ .gen_pdev_set_base_macaddr =
++ ath10k_wmi_tlv_op_gen_pdev_set_base_macaddr,
+ .gen_init = ath10k_wmi_tlv_op_gen_init,
+ .gen_start_scan = ath10k_wmi_tlv_op_gen_start_scan,
+ .gen_stop_scan = ath10k_wmi_tlv_op_gen_stop_scan,
+--- a/ath10k-4.16/wmi.c
++++ b/ath10k-4.16/wmi.c
+@@ -6012,6 +6012,25 @@ int ath10k_wmi_connect(struct ath10k *ar
+ }
+
+ static struct sk_buff *
++ath10k_wmi_op_gen_pdev_set_base_macaddr(struct ath10k *ar,
++ const u8 macaddr[ETH_ALEN])
++{
++ struct wmi_pdev_set_base_macaddr_cmd *cmd;
++ struct sk_buff *skb;
++
++ skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
++ if (!skb)
++ return ERR_PTR(-ENOMEM);
++
++ cmd = (struct wmi_pdev_set_base_macaddr_cmd *)skb->data;
++ ether_addr_copy(cmd->mac_addr.addr, macaddr);
++
++ ath10k_dbg(ar, ATH10K_DBG_WMI,
++ "wmi pdev basemac %pM\n", macaddr);
++ return skb;
++}
++
++static struct sk_buff *
+ ath10k_wmi_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
+ u16 ctl2g, u16 ctl5g,
+ enum wmi_dfs_region dfs_reg)
+@@ -8919,6 +8938,7 @@ static const struct wmi_ops wmi_ops = {
+ .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
+ .gen_pdev_set_rd = ath10k_wmi_op_gen_pdev_set_rd,
+ .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr,
+ .gen_init = ath10k_wmi_op_gen_init,
+ .gen_start_scan = ath10k_wmi_op_gen_start_scan,
+ .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
+@@ -8996,6 +9016,7 @@ static const struct wmi_ops wmi_10_1_ops
+ .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
+ .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
+ .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr,
+ .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
+ .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
+ .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
+@@ -9052,6 +9073,7 @@ static const struct wmi_ops wmi_10_2_ops
+ .pull_fw_stats = ath10k_wmi_10_2_op_pull_fw_stats,
+ .gen_init = ath10k_wmi_10_2_op_gen_init,
+ .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr,
+ /* .gen_pdev_get_temperature not implemented */
+
+ /* shared with 10.1 */
+@@ -9123,6 +9145,7 @@ static const struct wmi_ops wmi_10_2_4_o
+ .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
+ .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
+ .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr,
+
+ /* shared with 10.1 */
+ .map_svc = wmi_10x_svc_map,
+@@ -9252,6 +9275,7 @@ static const struct wmi_ops wmi_10_4_ops
+ .ext_resource_config = ath10k_wmi_10_4_ext_resource_config,
+ .gen_update_fw_tdls_state = ath10k_wmi_10_4_gen_update_fw_tdls_state,
+ .gen_tdls_peer_update = ath10k_wmi_10_4_gen_tdls_peer_update,
++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr,
+
+ /* shared with 10.2 */
+ .pull_echo_ev = ath10k_wmi_op_pull_echo_ev,
+--- a/ath10k-4.16/wmi.h
++++ b/ath10k-4.16/wmi.h
+@@ -4067,6 +4067,10 @@ struct wmi_pdev_set_param_cmd {
+ __le32 param_value;
+ } __packed;
+
++struct wmi_pdev_set_base_macaddr_cmd {
++ struct wmi_mac_addr mac_addr;
++} __packed;
++
+ /* valid period is 1 ~ 60000ms, unit in millisecond */
+ #define WMI_PDEV_PARAM_CAL_PERIOD_MAX 60000
+
diff --git a/package/kernel/ath10k-ct/patches/998-ath10k-retrieve-MAC-address-from-system-firmware-if-.patch b/package/kernel/ath10k-ct/patches/998-ath10k-retrieve-MAC-address-from-system-firmware-if-.patch
new file mode 100644
index 0000000000..162536d6a4
--- /dev/null
+++ b/package/kernel/ath10k-ct/patches/998-ath10k-retrieve-MAC-address-from-system-firmware-if-.patch
@@ -0,0 +1,50 @@
+From 9d5804662ce1f9bdde0a14c3c40940acbbf09538 Mon Sep 17 00:00:00 2001
+From: Brian Norris <briannorris at chromium.org>
+Date: Tue, 28 Aug 2018 19:48:17 +0300
+Subject: [PATCH] ath10k: retrieve MAC address from system firmware if provided
+
+Devices may provide their own MAC address via system firmware (e.g.,
+device tree), especially in the case where the device doesn't have a
+useful EEPROM on which to store its MAC address (e.g., for integrated
+Wifi).
+
+Use the generic device helper to retrieve the MAC address, and (if
+present) honor it above the MAC address advertised by the card.
+
+Signed-off-by: Brian Norris <briannorris at chromium.org>
+Signed-off-by: Kalle Valo <kvalo at codeaurora.org>
+---
+--- a/ath10k-4.16/core.c
++++ b/ath10k-4.16/core.c
+@@ -19,6 +19,7 @@
+ #include <linux/module.h>
+ #include <linux/firmware.h>
+ #include <linux/of.h>
++#include <linux/property.h>
+ #include <linux/dmi.h>
+ #include <linux/ctype.h>
+ #include <asm/byteorder.h>
+@@ -2617,6 +2618,8 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
+ ath10k_debug_print_board_info(ar);
+ }
+
++ device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr));
++
+ ret = ath10k_core_init_firmware_features(ar);
+ if (ret) {
+ ath10k_err(ar, "fatal problem with firmware features: %d\n",
+--- a/ath10k-4.16/wmi.c
++++ b/ath10k-4.16/wmi.c
+@@ -5455,7 +5455,8 @@ int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb)
+ arg.mac_addr,
+ __le32_to_cpu(arg.status));
+
+- ether_addr_copy(ar->mac_addr, arg.mac_addr);
++ if (is_zero_ether_addr(ar->mac_addr))
++ ether_addr_copy(ar->mac_addr, arg.mac_addr);
+ complete(&ar->wmi.unified_ready);
+ return 0;
+ }
+--
+2.20.0
+
diff --git a/package/kernel/mac80211/patches/ath/977-ath10k-implement-set-base-macaddr.patch b/package/kernel/mac80211/patches/ath/977-ath10k-implement-set-base-macaddr.patch
new file mode 100644
index 0000000000..864972090f
--- /dev/null
+++ b/package/kernel/mac80211/patches/ath/977-ath10k-implement-set-base-macaddr.patch
@@ -0,0 +1,182 @@
+diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
+index 22cbe9a2e646..33c767b903bc 100644
+--- a/drivers/net/wireless/ath/ath10k/core.c
++++ b/drivers/net/wireless/ath/ath10k/core.c
+@@ -2621,6 +2621,13 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
+ goto err_hif_stop;
+ }
+
++ status = ath10k_wmi_pdev_set_base_macaddr(ar, ar->mac_addr);
++ if (status) {
++ ath10k_err(ar,
++ "failed to set base mac address: %d\n", status);
++ goto err_hif_stop;
++ }
++
+ /* Some firmware revisions do not properly set up hardware rx filter
+ * registers.
+ *
+diff --git a/drivers/net/wireless/ath/ath10k/wmi-ops.h b/drivers/net/wireless/ath/ath10k/wmi-ops.h
+index 7978a7783f90..6c87b35cde4e 100644
+--- a/drivers/net/wireless/ath/ath10k/wmi-ops.h
++++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h
+@@ -64,6 +64,8 @@ struct wmi_ops {
+
+ enum wmi_txbf_conf (*get_txbf_conf_scheme)(struct ath10k *ar);
+
++ struct sk_buff *(*gen_pdev_set_base_macaddr)(struct ath10k *ar,
++ const u8 macaddr[ETH_ALEN]);
+ struct sk_buff *(*gen_pdev_suspend)(struct ath10k *ar, u32 suspend_opt);
+ struct sk_buff *(*gen_pdev_resume)(struct ath10k *ar);
+ struct sk_buff *(*gen_pdev_set_rd)(struct ath10k *ar, u16 rd, u16 rd2g,
+@@ -503,6 +505,22 @@ ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
+ ar->wmi.cmd->pdev_set_regdomain_cmdid);
+ }
+
++static inline int
++ath10k_wmi_pdev_set_base_macaddr(struct ath10k *ar, const u8 macaddr[ETH_ALEN])
++{
++ struct sk_buff *skb;
++
++ if (!ar->wmi.ops->gen_pdev_set_base_macaddr)
++ return -EOPNOTSUPP;
++
++ skb = ar->wmi.ops->gen_pdev_set_base_macaddr(ar, macaddr);
++ if (IS_ERR(skb))
++ return PTR_ERR(skb);
++
++ return ath10k_wmi_cmd_send(ar, skb,
++ ar->wmi.cmd->pdev_set_base_macaddr_cmdid);
++}
++
+ static inline int
+ ath10k_wmi_pdev_suspend_target(struct ath10k *ar, u32 suspend_opt)
+ {
+diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+index ad4114a88170..60beb8283e30 100644
+--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
++++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+@@ -2228,6 +2228,29 @@ ath10k_wmi_tlv_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
+ return skb;
+ }
+
++static struct sk_buff *
++ath10k_wmi_tlv_op_gen_pdev_set_base_macaddr(struct ath10k *ar,
++ const u8 addr[ETH_ALEN])
++{
++ struct wmi_pdev_set_base_macaddr_cmd *cmd;
++ struct wmi_tlv *tlv;
++ struct sk_buff *skb;
++
++ skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
++ if (!skb)
++ return ERR_PTR(-ENOMEM);
++
++ tlv = (void *)skb->data;
++ tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_BASE_MACADDR_CMD);
++ tlv->len = __cpu_to_le16(sizeof(*cmd));
++ cmd = (void *)tlv->value;
++ ether_addr_copy(cmd->mac_addr.addr, addr);
++
++ ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set base macaddr\n");
++ return skb;
++}
++
++
+ static struct sk_buff *
+ ath10k_wmi_tlv_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
+ const u8 peer_addr[ETH_ALEN])
+@@ -4112,6 +4135,8 @@ static const struct wmi_ops wmi_tlv_ops = {
+ .gen_pdev_resume = ath10k_wmi_tlv_op_gen_pdev_resume,
+ .gen_pdev_set_rd = ath10k_wmi_tlv_op_gen_pdev_set_rd,
+ .gen_pdev_set_param = ath10k_wmi_tlv_op_gen_pdev_set_param,
++ .gen_pdev_set_base_macaddr =
++ ath10k_wmi_tlv_op_gen_pdev_set_base_macaddr,
+ .gen_init = ath10k_wmi_tlv_op_gen_init,
+ .gen_start_scan = ath10k_wmi_tlv_op_gen_start_scan,
+ .gen_stop_scan = ath10k_wmi_tlv_op_gen_stop_scan,
+diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
+index 659513bf4ddc..d1a021e1c784 100644
+--- a/drivers/net/wireless/ath/ath10k/wmi.c
++++ b/drivers/net/wireless/ath/ath10k/wmi.c
+@@ -6234,6 +6234,25 @@ int ath10k_wmi_connect(struct ath10k *ar)
+ return 0;
+ }
+
++static struct sk_buff *
++ath10k_wmi_op_gen_pdev_set_base_macaddr(struct ath10k *ar,
++ const u8 macaddr[ETH_ALEN])
++{
++ struct wmi_pdev_set_base_macaddr_cmd *cmd;
++ struct sk_buff *skb;
++
++ skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
++ if (!skb)
++ return ERR_PTR(-ENOMEM);
++
++ cmd = (struct wmi_pdev_set_base_macaddr_cmd *)skb->data;
++ ether_addr_copy(cmd->mac_addr.addr, macaddr);
++
++ ath10k_dbg(ar, ATH10K_DBG_WMI,
++ "wmi pdev basemac %pM\n", macaddr);
++ return skb;
++}
++
+ static struct sk_buff *
+ ath10k_wmi_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
+ u16 ctl2g, u16 ctl5g,
+@@ -8861,6 +8880,7 @@ static const struct wmi_ops wmi_ops = {
+ .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
+ .gen_pdev_set_rd = ath10k_wmi_op_gen_pdev_set_rd,
+ .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr,
+ .gen_init = ath10k_wmi_op_gen_init,
+ .gen_start_scan = ath10k_wmi_op_gen_start_scan,
+ .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
+@@ -8917,6 +8937,7 @@ static const struct wmi_ops wmi_10_1_ops = {
+ .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
+ .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
+ .gen_peer_assoc = ath10k_wmi_10_1_op_gen_peer_assoc,
++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr,
+ /* .gen_pdev_get_temperature not implemented */
+
+ /* shared with main branch */
+@@ -8983,6 +9004,7 @@ static const struct wmi_ops wmi_10_2_ops = {
+ .pull_fw_stats = ath10k_wmi_10_2_op_pull_fw_stats,
+ .gen_init = ath10k_wmi_10_2_op_gen_init,
+ .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr,
+ /* .gen_pdev_get_temperature not implemented */
+
+ /* shared with 10.1 */
+@@ -9052,6 +9074,7 @@ static const struct wmi_ops wmi_10_2_4_ops = {
+ .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
+ .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
+ .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr,
+
+ /* shared with 10.1 */
+ .map_svc = wmi_10x_svc_map,
+@@ -9141,6 +9164,7 @@ static const struct wmi_ops wmi_10_4_ops = {
+ .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
+ .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
+ .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr,
+ .gen_init = ath10k_wmi_10_4_op_gen_init,
+ .gen_start_scan = ath10k_wmi_op_gen_start_scan,
+ .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
+diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
+index 58e33ab9e0e9..e0cc0c3a384f 100644
+--- a/drivers/net/wireless/ath/ath10k/wmi.h
++++ b/drivers/net/wireless/ath/ath10k/wmi.h
+@@ -4067,6 +4067,10 @@ struct wmi_pdev_set_param_cmd {
+ __le32 param_value;
+ } __packed;
+
++struct wmi_pdev_set_base_macaddr_cmd {
++ struct wmi_mac_addr mac_addr;
++} __packed;
++
+ /* valid period is 1 ~ 60000ms, unit in millisecond */
+ #define WMI_PDEV_PARAM_CAL_PERIOD_MAX 60000
+
diff --git a/package/kernel/mac80211/patches/ath/998-ath10k-retrieve-MAC-address-from-system-firmware-if-.patch b/package/kernel/mac80211/patches/ath/998-ath10k-retrieve-MAC-address-from-system-firmware-if-.patch
new file mode 100644
index 0000000000..d4f9c64a44
--- /dev/null
+++ b/package/kernel/mac80211/patches/ath/998-ath10k-retrieve-MAC-address-from-system-firmware-if-.patch
@@ -0,0 +1,58 @@
+From 9d5804662ce1f9bdde0a14c3c40940acbbf09538 Mon Sep 17 00:00:00 2001
+From: Brian Norris <briannorris at chromium.org>
+Date: Tue, 28 Aug 2018 19:48:17 +0300
+Subject: [PATCH] ath10k: retrieve MAC address from system firmware if provided
+
+Devices may provide their own MAC address via system firmware (e.g.,
+device tree), especially in the case where the device doesn't have a
+useful EEPROM on which to store its MAC address (e.g., for integrated
+Wifi).
+
+Use the generic device helper to retrieve the MAC address, and (if
+present) honor it above the MAC address advertised by the card.
+
+Signed-off-by: Brian Norris <briannorris at chromium.org>
+Signed-off-by: Kalle Valo <kvalo at codeaurora.org>
+---
+ drivers/net/wireless/ath/ath10k/core.c | 3 +++
+ drivers/net/wireless/ath/ath10k/wmi.c | 3 ++-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
+index ebc213884a9a..f5f71c02fc2b 100644
+--- a/drivers/net/wireless/ath/ath10k/core.c
++++ b/drivers/net/wireless/ath/ath10k/core.c
+@@ -19,6 +19,7 @@
+ #include <linux/module.h>
+ #include <linux/firmware.h>
+ #include <linux/of.h>
++#include <linux/property.h>
+ #include <linux/dmi.h>
+ #include <linux/ctype.h>
+ #include <asm/byteorder.h>
+@@ -2617,6 +2618,8 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
+ ath10k_debug_print_board_info(ar);
+ }
+
++ device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr));
++
+ ret = ath10k_core_init_firmware_features(ar);
+ if (ret) {
+ ath10k_err(ar, "fatal problem with firmware features: %d\n",
+diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
+index 40ce0e4006bc..212005cd0646 100644
+--- a/drivers/net/wireless/ath/ath10k/wmi.c
++++ b/drivers/net/wireless/ath/ath10k/wmi.c
+@@ -5455,7 +5455,8 @@ int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb)
+ arg.mac_addr,
+ __le32_to_cpu(arg.status));
+
+- ether_addr_copy(ar->mac_addr, arg.mac_addr);
++ if (is_zero_ether_addr(ar->mac_addr))
++ ether_addr_copy(ar->mac_addr, arg.mac_addr);
+ complete(&ar->wmi.unified_ready);
+ return 0;
+ }
+--
+2.20.0
+
diff --git a/target/linux/generic/hack-4.14/950-call-of_get_mac_address-from-device.patch b/target/linux/generic/hack-4.14/950-call-of_get_mac_address-from-device.patch
new file mode 100644
index 0000000000..7e78ceea64
--- /dev/null
+++ b/target/linux/generic/hack-4.14/950-call-of_get_mac_address-from-device.patch
@@ -0,0 +1,23 @@
+--- a/drivers/base/property.c 2018-11-21 09:24:18.000000000 +0100
++++ b/drivers/base/property.c 2018-12-15 13:59:16.894896732 +0100
+@@ -19,6 +19,7 @@
+ #include <linux/property.h>
+ #include <linux/etherdevice.h>
+ #include <linux/phy.h>
++#include <linux/of_net.h>
+
+ struct property_set {
+ struct device *dev;
+@@ -1186,6 +1187,12 @@ void *device_get_mac_address(struct devi
+ {
+ char *res;
+
++ res = of_get_mac_address(dev->of_node);
++ if (res && (alen >= ETH_ALEN)) {
++ ether_addr_copy(addr, res);
++ return addr;
++ }
++
+ res = device_get_mac_addr(dev, "mac-address", addr, alen);
+ if (res)
+ return res;
diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
index 8956bbd74a..ad98339540 100644
--- a/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
+++ b/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
@@ -19,8 +19,7 @@ case "$board" in
echo $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 12) $((1 - $PHYNBR)) ) > /sys${DEVPATH}/macaddress
;;
netgear,d7800 |\
- netgear,r7500v2 |\
- netgear,r7800)
+ netgear,r7500v2)
echo $(macaddr_add $(mtd_get_mac_binary art 6) $(($PHYNBR + 1)) ) > /sys${DEVPATH}/macaddress
;;
tplink,c2600)
diff --git a/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8065-r7800.dts b/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8065-r7800.dts
index c4c9287942..614ab15df6 100644
--- a/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8065-r7800.dts
+++ b/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8065-r7800.dts
@@ -255,12 +255,42 @@
};
pcie0: pci at 1b500000 {
- status = "ok";
+ status = "okay";
+
+ bridge at 0,0 {
+ reg = <0x00000000 0 0 0 0>;
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+
+ wifi at 1,0 {
+ compatible = "pci168c,0046";
+ reg = <0x00010000 0 0 0 0>;
+
+ mtd-mac-address = <&art 6>;
+ mtd-mac-address-increment = <(1)>;
+ };
+ };
};
pcie1: pci at 1b700000 {
- status = "ok";
+ status = "okay";
force_gen1 = <1>;
+
+ bridge at 0,0 {
+ reg = <0x00000000 0 0 0 0>;
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+
+ wifi at 1,0 {
+ compatible = "pci168c,0046";
+ reg = <0x00010000 0 0 0 0>;
+
+ mtd-mac-address = <&art 6>;
+ mtd-mac-address-increment = <(2)>;
+ };
+ };
};
nand at 1ac00000 {
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list