From 4747c97c090a161b8d4240c1acd03502316d9269 Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Sat, 15 Dec 2018 10:56:14 +0100 Subject: [PATCH] ipq806x: R7800: mtd-mac-address test --- ...76-ath10k-implement-set-base-macaddr.patch | 172 ++++++++++++++++++ ...MAC-address-from-system-firmware-if-.patch | 48 +++++ 2 files changed, 220 insertions(+) create mode 100644 package/kernel/ath10k-ct/patches/976-ath10k-implement-set-base-macaddr.patch create mode 100644 package/kernel/ath10k-ct/patches/998-ath10k-retrieve-MAC-address-from-system-firmware-if-.patch 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..a9b9536c00 --- /dev/null +++ b/package/kernel/ath10k-ct/patches/976-ath10k-implement-set-base-macaddr.patch @@ -0,0 +1,172 @@ +--- a/ath10k-4.19/core.c ++++ b/ath10k-4.19/core.c +@@ -2944,6 +2944,13 @@ int ath10k_core_start(struct ath10k *ar, + 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.19/wmi-ops.h ++++ b/ath10k-4.19/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, +@@ -506,6 +508,22 @@ ath10k_wmi_pdev_set_regdomain(struct ath + } + + 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) + { + struct sk_buff *skb; +--- a/ath10k-4.19/wmi-tlv.c ++++ b/ath10k-4.19/wmi-tlv.c +@@ -2221,6 +2221,29 @@ ath10k_wmi_tlv_op_gen_peer_create(struct + } + + 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]) + { +@@ -3921,6 +3944,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.19/wmi.c ++++ b/ath10k-4.19/wmi.c +@@ -6582,6 +6582,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) +@@ -9608,6 +9627,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, +@@ -9685,6 +9705,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, +@@ -9741,6 +9762,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 */ +@@ -9812,6 +9834,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, +@@ -9954,6 +9977,7 @@ static const struct wmi_ops wmi_10_4_ops + .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info, + .gen_echo = ath10k_wmi_op_gen_echo, + .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config, ++ .gen_pdev_set_base_macaddr = ath10k_wmi_op_gen_pdev_set_base_macaddr, + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config, + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output, + }; +--- a/ath10k-4.19/wmi.h ++++ b/ath10k-4.19/wmi.h +@@ -4192,6 +4192,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..eb39750569 --- /dev/null +++ b/package/kernel/ath10k-ct/patches/998-ath10k-retrieve-MAC-address-from-system-firmware-if-.patch @@ -0,0 +1,48 @@ +From 9d5804662ce1f9bdde0a14c3c40940acbbf09538 Mon Sep 17 00:00:00 2001 +From: Brian Norris +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 +Signed-off-by: Kalle Valo +--- + +--- a/ath10k-4.19/core.c ++++ b/ath10k-4.19/core.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -3282,6 +3283,8 @@ static int ath10k_core_probe_fw(struct a + 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.19/wmi.c ++++ b/ath10k-4.19/wmi.c +@@ -5866,7 +5866,8 @@ int ath10k_wmi_event_ready(struct ath10k + 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.30.2