Message ID | 20220914215408.372520-1-junyuu@chromium.org (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Kalle Valo |
Headers | show |
Series | wifi: ath11k: retrieve MAC address from system firmware if provided | expand |
Jun Yu <junyuu@chromium.org> wrote: > 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 > ahb WCN6750). > > Use the generic device helper to retrieve the MAC address, and (if > present) honor it above the MAC address advertised by the card. > > Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.1.0.1-00887-QCAMSLSWPLZ-1 > > Signed-off-by: Jun Yu <junyuu@chromium.org> Fails to build: drivers/net/wireless/ath/ath11k/mac.c: In function 'ath11k_mac_register': drivers/net/wireless/ath/ath11k/mac.c:8999:9: error: too many arguments to function 'device_get_mac_address' 8999 | device_get_mac_address(ab->dev, mac_addr, sizeof(ab->mac_addr)); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from ./include/linux/ieee80211.h:20, from ./include/net/mac80211.h:20, from drivers/net/wireless/ath/ath11k/mac.c:7: ./include/linux/etherdevice.h:35:5: note: declared here 35 | int device_get_mac_address(struct device *dev, char *addr); | ^~~~~~~~~~~~~~~~~~~~~~ make[5]: *** [scripts/Makefile.build:249: drivers/net/wireless/ath/ath11k/mac.o] Error 1 make[4]: *** [scripts/Makefile.build:465: drivers/net/wireless/ath/ath11k] Error 2 make[3]: *** [scripts/Makefile.build:465: drivers/net/wireless/ath] Error 2 make[2]: *** [scripts/Makefile.build:465: drivers/net/wireless] Error 2 make[1]: *** [scripts/Makefile.build:465: drivers/net] Error 2 make: *** [Makefile:1853: drivers] Error 2 Patch set to Changes Requested.
Hi Jun, Thank you for the patch! Yet something to improve: [auto build test ERROR on kvalo-ath/ath-next] [also build test ERROR on wireless/main wireless-next/main linus/master v6.0-rc5 next-20220916] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Jun-Yu/wifi-ath11k-retrieve-MAC-address-from-system-firmware-if-provided/20220915-055714 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next config: i386-randconfig-a005 (https://download.01.org/0day-ci/archive/20220917/202209170307.720C1Sx4-lkp@intel.com/config) compiler: gcc-11 (Debian 11.3.0-5) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/7a1539aed9ed31bd3b93c177abda0a2f4fea3945 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Jun-Yu/wifi-ath11k-retrieve-MAC-address-from-system-firmware-if-provided/20220915-055714 git checkout 7a1539aed9ed31bd3b93c177abda0a2f4fea3945 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/net/wireless/ath/ath11k/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): drivers/net/wireless/ath/ath11k/mac.c: In function 'ath11k_mac_register': >> drivers/net/wireless/ath/ath11k/mac.c:8999:9: error: too many arguments to function 'device_get_mac_address' 8999 | device_get_mac_address(ab->dev, mac_addr, sizeof(ab->mac_addr)); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from include/linux/ieee80211.h:20, from include/net/mac80211.h:20, from drivers/net/wireless/ath/ath11k/mac.c:7: include/linux/etherdevice.h:35:5: note: declared here 35 | int device_get_mac_address(struct device *dev, char *addr); | ^~~~~~~~~~~~~~~~~~~~~~ vim +/device_get_mac_address +8999 drivers/net/wireless/ath/ath11k/mac.c 8979 8980 int ath11k_mac_register(struct ath11k_base *ab) 8981 { 8982 struct ath11k *ar; 8983 struct ath11k_pdev *pdev; 8984 int i; 8985 int ret; 8986 u8 mac_addr[ETH_ALEN] = {0}; 8987 8988 if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) 8989 return 0; 8990 8991 /* Initialize channel counters frequency value in hertz */ 8992 ab->cc_freq_hz = IPQ8074_CC_FREQ_HERTZ; 8993 ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS(ab))) - 1; 8994 8995 ret = ath11k_peer_rhash_tbl_init(ab); 8996 if (ret) 8997 return ret; 8998 > 8999 device_get_mac_address(ab->dev, mac_addr, sizeof(ab->mac_addr)); 9000 9001 for (i = 0; i < ab->num_radios; i++) { 9002 pdev = &ab->pdevs[i]; 9003 ar = pdev->ar; 9004 if (ab->pdevs_macaddr_valid) { 9005 ether_addr_copy(ar->mac_addr, pdev->mac_addr); 9006 } else { 9007 if (is_zero_ether_addr(mac_addr)) 9008 ether_addr_copy(ar->mac_addr, ab->mac_addr); 9009 else 9010 ether_addr_copy(ar->mac_addr, mac_addr); 9011 ar->mac_addr[4] += i; 9012 } 9013 9014 idr_init(&ar->txmgmt_idr); 9015 spin_lock_init(&ar->txmgmt_idr_lock); 9016 9017 ret = __ath11k_mac_register(ar); 9018 if (ret) 9019 goto err_cleanup; 9020 9021 init_waitqueue_head(&ar->txmgmt_empty_waitq); 9022 } 9023 9024 return 0; 9025 9026 err_cleanup: 9027 for (i = i - 1; i >= 0; i--) { 9028 pdev = &ab->pdevs[i]; 9029 ar = pdev->ar; 9030 __ath11k_mac_unregister(ar); 9031 } 9032 9033 ath11k_peer_rhash_tbl_destroy(ab); 9034 9035 return ret; 9036 } 9037
Hi Jun, Thank you for the patch! Yet something to improve: [auto build test ERROR on kvalo-ath/ath-next] [also build test ERROR on wireless/main wireless-next/main linus/master v6.0-rc5 next-20220916] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Jun-Yu/wifi-ath11k-retrieve-MAC-address-from-system-firmware-if-provided/20220915-055714 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20220917/202209172236.KWe4R2Dm-lkp@intel.com/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/7a1539aed9ed31bd3b93c177abda0a2f4fea3945 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Jun-Yu/wifi-ath11k-retrieve-MAC-address-from-system-firmware-if-provided/20220915-055714 git checkout 7a1539aed9ed31bd3b93c177abda0a2f4fea3945 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> drivers/net/wireless/ath/ath11k/mac.c:8999:44: error: too many arguments to function call, expected 2, have 3 device_get_mac_address(ab->dev, mac_addr, sizeof(ab->mac_addr)); ~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~ include/linux/etherdevice.h:35:5: note: 'device_get_mac_address' declared here int device_get_mac_address(struct device *dev, char *addr); ^ 1 error generated. vim +8999 drivers/net/wireless/ath/ath11k/mac.c 8979 8980 int ath11k_mac_register(struct ath11k_base *ab) 8981 { 8982 struct ath11k *ar; 8983 struct ath11k_pdev *pdev; 8984 int i; 8985 int ret; 8986 u8 mac_addr[ETH_ALEN] = {0}; 8987 8988 if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) 8989 return 0; 8990 8991 /* Initialize channel counters frequency value in hertz */ 8992 ab->cc_freq_hz = IPQ8074_CC_FREQ_HERTZ; 8993 ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS(ab))) - 1; 8994 8995 ret = ath11k_peer_rhash_tbl_init(ab); 8996 if (ret) 8997 return ret; 8998 > 8999 device_get_mac_address(ab->dev, mac_addr, sizeof(ab->mac_addr)); 9000 9001 for (i = 0; i < ab->num_radios; i++) { 9002 pdev = &ab->pdevs[i]; 9003 ar = pdev->ar; 9004 if (ab->pdevs_macaddr_valid) { 9005 ether_addr_copy(ar->mac_addr, pdev->mac_addr); 9006 } else { 9007 if (is_zero_ether_addr(mac_addr)) 9008 ether_addr_copy(ar->mac_addr, ab->mac_addr); 9009 else 9010 ether_addr_copy(ar->mac_addr, mac_addr); 9011 ar->mac_addr[4] += i; 9012 } 9013 9014 idr_init(&ar->txmgmt_idr); 9015 spin_lock_init(&ar->txmgmt_idr_lock); 9016 9017 ret = __ath11k_mac_register(ar); 9018 if (ret) 9019 goto err_cleanup; 9020 9021 init_waitqueue_head(&ar->txmgmt_empty_waitq); 9022 } 9023 9024 return 0; 9025 9026 err_cleanup: 9027 for (i = i - 1; i >= 0; i--) { 9028 pdev = &ab->pdevs[i]; 9029 ar = pdev->ar; 9030 __ath11k_mac_unregister(ar); 9031 } 9032 9033 ath11k_peer_rhash_tbl_destroy(ab); 9034 9035 return ret; 9036 } 9037
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 7e91e347c9ff2..591b2b97ca818 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/property.h> #include <net/if_inet6.h> #include <net/ipv6.h> @@ -8967,6 +8968,7 @@ int ath11k_mac_register(struct ath11k_base *ab) struct ath11k_pdev *pdev; int i; int ret; + u8 mac_addr[ETH_ALEN] = {0}; if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) return 0; @@ -8979,13 +8981,18 @@ int ath11k_mac_register(struct ath11k_base *ab) if (ret) return ret; + device_get_mac_address(ab->dev, mac_addr, sizeof(ab->mac_addr)); + for (i = 0; i < ab->num_radios; i++) { pdev = &ab->pdevs[i]; ar = pdev->ar; if (ab->pdevs_macaddr_valid) { ether_addr_copy(ar->mac_addr, pdev->mac_addr); } else { - ether_addr_copy(ar->mac_addr, ab->mac_addr); + if (is_zero_ether_addr(mac_addr)) + ether_addr_copy(ar->mac_addr, ab->mac_addr); + else + ether_addr_copy(ar->mac_addr, mac_addr); ar->mac_addr[4] += i; }
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 ahb WCN6750). Use the generic device helper to retrieve the MAC address, and (if present) honor it above the MAC address advertised by the card. Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.1.0.1-00887-QCAMSLSWPLZ-1 Signed-off-by: Jun Yu <junyuu@chromium.org> --- drivers/net/wireless/ath/ath11k/mac.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)