You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/06/19 02:13:28 UTC

[incubator-nuttx] branch master updated: wireless/bcm43xxx: add customized MAC address support

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new fbddae8813 wireless/bcm43xxx: add customized MAC address support
fbddae8813 is described below

commit fbddae8813517b8195e94d916fca4e59f95259e1
Author: chao.an <an...@xiaomi.com>
AuthorDate: Sun Jun 19 02:10:33 2022 +0800

    wireless/bcm43xxx: add customized MAC address support
    
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 boards/arm/stm32/emw3162/src/stm32_wlan.c         |  9 +++++++++
 boards/arm/stm32/photon/src/stm32_wlan.c          |  9 +++++++++
 drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c | 12 ++++++++++++
 include/nuttx/wireless/ieee80211/bcmf_board.h     | 19 +++++++++++++++++++
 4 files changed, 49 insertions(+)

diff --git a/boards/arm/stm32/emw3162/src/stm32_wlan.c b/boards/arm/stm32/emw3162/src/stm32_wlan.c
index 15c2abeb97..b02afebf5b 100644
--- a/boards/arm/stm32/emw3162/src/stm32_wlan.c
+++ b/boards/arm/stm32/emw3162/src/stm32_wlan.c
@@ -126,6 +126,15 @@ void bcmf_board_setup_oob_irq(int minor, int (*func)(void *), void *arg)
     }
 }
 
+/****************************************************************************
+ * Name: bcmf_board_etheraddr
+ ****************************************************************************/
+
+bool bcmf_board_etheraddr(struct ether_addr *ethaddr)
+{
+  return false;
+}
+
 /****************************************************************************
  * Name: emw3162_wlan_initialize
  ****************************************************************************/
diff --git a/boards/arm/stm32/photon/src/stm32_wlan.c b/boards/arm/stm32/photon/src/stm32_wlan.c
index f5684296e4..c86394f050 100644
--- a/boards/arm/stm32/photon/src/stm32_wlan.c
+++ b/boards/arm/stm32/photon/src/stm32_wlan.c
@@ -108,6 +108,15 @@ void bcmf_board_setup_oob_irq(int minor, int (*func)(void *), void *arg)
     }
 }
 
+/****************************************************************************
+ * Name: bcmf_board_etheraddr
+ ****************************************************************************/
+
+bool bcmf_board_etheraddr(struct ether_addr *ethaddr)
+{
+  return false;
+}
+
 /****************************************************************************
  * Name: photon_wlan_initialize
  ****************************************************************************/
diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c b/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c
index acae29d492..07e14bce34 100644
--- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c
+++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c
@@ -41,6 +41,7 @@
 #include <nuttx/net/arp.h>
 #include <nuttx/net/netdev.h>
 #include <nuttx/wireless/wireless.h>
+#include <nuttx/wireless/ieee80211/bcmf_board.h>
 
 #ifdef CONFIG_NET_PKT
 #  include <nuttx/net/pkt.h>
@@ -1033,6 +1034,17 @@ int bcmf_netdev_register(FAR struct bcmf_dev_s *priv)
       return -EIO;
     }
 
+  /* Set customized MAC address */
+
+  if (bcmf_board_etheraddr(&priv->bc_dev.d_mac.ether))
+    {
+      out_len = ETHER_ADDR_LEN;
+      bcmf_cdc_iovar_request(priv, CHIP_STA_INTERFACE, true,
+                             IOVAR_STR_CUR_ETHERADDR,
+                             priv->bc_dev.d_mac.ether.ether_addr_octet,
+                             &out_len);
+    }
+
   /* Query MAC address */
 
   out_len = ETHER_ADDR_LEN;
diff --git a/include/nuttx/wireless/ieee80211/bcmf_board.h b/include/nuttx/wireless/ieee80211/bcmf_board.h
index 8c041f228a..18231f12cd 100644
--- a/include/nuttx/wireless/ieee80211/bcmf_board.h
+++ b/include/nuttx/wireless/ieee80211/bcmf_board.h
@@ -27,6 +27,7 @@
 
 #include <stdbool.h>
 #include <nuttx/irq.h>
+#include <net/ethernet.h>
 
 #ifdef __cplusplus
 #define EXTERN extern "C"
@@ -108,6 +109,24 @@ void bcmf_board_reset(int minor, bool reset);
 
 void bcmf_board_setup_oob_irq(int minor, int (*func)(void *), void *arg);
 
+/****************************************************************************
+ * Name: bcmf_board_etheraddr
+ *
+ * Description:
+ *   Board specific function called from Broadcom FullMAC driver
+ *   that must be implemented to get the customized MAC address
+ *
+ * Returned Value:
+ *   Return true if customized MAC address is set,
+ *   otherwise use firmware default MAC address
+ *
+ * Input Parameters:
+ *   ethaddr - Pointer to MAC address
+ *
+ ****************************************************************************/
+
+bool bcmf_board_etheraddr(FAR struct ether_addr *ethaddr);
+
 #undef EXTERN
 #ifdef __cplusplus
 }