From fbddae8813517b8195e94d916fca4e59f95259e1 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Sun, 19 Jun 2022 02:10:33 +0800 Subject: [PATCH] wireless/bcm43xxx: add customized MAC address support Signed-off-by: chao.an --- boards/arm/stm32/emw3162/src/stm32_wlan.c | 9 +++++++++ boards/arm/stm32/photon/src/stm32_wlan.c | 9 +++++++++ .../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 #include #include +#include #ifdef CONFIG_NET_PKT # include @@ -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 #include +#include #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 }