001-05-v6.9-wifi-rtl8xxxu-support-setting-mac-address-register-f.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. From 00add60cad3c9690ac0f9d4f6685f96ccd607670 Mon Sep 17 00:00:00 2001
  2. From: Martin Kaistra <[email protected]>
  3. Date: Fri, 22 Dec 2023 11:14:26 +0100
  4. Subject: [PATCH 05/21] wifi: rtl8xxxu: support setting mac address register
  5. for both interfaces
  6. To prepare for concurrent mode, enhance rtl8xxxu_set_mac() to write the
  7. mac address of the respective interface to REG_MACID or REG_MACID1.
  8. Remove the call to rtl8xxxu_set_mac() from the init function as we set
  9. it in rtl8xxxu_add_interface() later anyway.
  10. Until rtl8xxxu_add_interface() can handle both interfaces, call
  11. rtl8xxxu_set_mac() with port_num = 0.
  12. Signed-off-by: Martin Kaistra <[email protected]>
  13. Reviewed-by: Ping-Ke Shih <[email protected]>
  14. Signed-off-by: Kalle Valo <[email protected]>
  15. Link: https://msgid.link/[email protected]
  16. ---
  17. .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 20 +++++++++++++------
  18. 1 file changed, 14 insertions(+), 6 deletions(-)
  19. --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
  20. +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
  21. @@ -3580,15 +3580,25 @@ void rtl8723a_phy_lc_calibrate(struct rt
  22. rtl8xxxu_write8(priv, REG_TXPAUSE, 0x00);
  23. }
  24. -static int rtl8xxxu_set_mac(struct rtl8xxxu_priv *priv)
  25. +static int rtl8xxxu_set_mac(struct rtl8xxxu_priv *priv, int port_num)
  26. {
  27. int i;
  28. u16 reg;
  29. - reg = REG_MACID;
  30. + switch (port_num) {
  31. + case 0:
  32. + reg = REG_MACID;
  33. + break;
  34. + case 1:
  35. + reg = REG_MACID1;
  36. + break;
  37. + default:
  38. + WARN_ONCE("%s: invalid port_num\n", __func__);
  39. + return -EINVAL;
  40. + }
  41. for (i = 0; i < ETH_ALEN; i++)
  42. - rtl8xxxu_write8(priv, reg + i, priv->mac_addr[i]);
  43. + rtl8xxxu_write8(priv, reg + i, priv->vifs[port_num]->addr[i]);
  44. return 0;
  45. }
  46. @@ -4243,8 +4253,6 @@ static int rtl8xxxu_init_device(struct i
  47. rtl8xxxu_write32(priv, REG_HIMR, 0xffffffff);
  48. }
  49. - rtl8xxxu_set_mac(priv);
  50. -
  51. /*
  52. * Configure initial WMAC settings
  53. */
  54. @@ -6619,7 +6627,7 @@ static int rtl8xxxu_add_interface(struct
  55. rtl8xxxu_set_linktype(priv, vif->type, 0);
  56. ether_addr_copy(priv->mac_addr, vif->addr);
  57. - rtl8xxxu_set_mac(priv);
  58. + rtl8xxxu_set_mac(priv, 0);
  59. return ret;
  60. }