diff --git a/config_wlan b/config_wlan index 0e606cb11f..51e7d92989 100644 --- a/config_wlan +++ b/config_wlan @@ -65,7 +65,11 @@ CONFIG_DEBUG_INFO=y # CONFIG_DEBUG_GRAPHICS is not set # CONFIG_DEBUG_LIB is not set # CONFIG_DEBUG_MM is not set -# CONFIG_DEBUG_WIRELESS is not set +# CONFIG_DEBUG_NET is not set +CONFIG_DEBUG_WIRELESS=y +CONFIG_DEBUG_WIRELESS_ERROR=y +CONFIG_DEBUG_WIRELESS_WARN=y +CONFIG_DEBUG_WIRELESS_INFO=y # CONFIG_DEBUG_SCHED is not set # @@ -78,10 +82,7 @@ CONFIG_DEBUG_INFO=y # # CONFIG_DEBUG_LEDS is not set # CONFIG_DEBUG_GPIO is not set -CONFIG_DEBUG_MEMCARD=y -CONFIG_DEBUG_MEMCARD_ERROR=y -CONFIG_DEBUG_MEMCARD_WARN=y -CONFIG_DEBUG_MEMCARD_INFO=y +# CONFIG_DEBUG_MEMCARD is not set # CONFIG_DEBUG_TIMER is not set # CONFIG_DEBUG_WATCHDOG is not set CONFIG_ARCH_HAVE_STACKCHECK=y @@ -859,6 +860,26 @@ CONFIG_SDIO_BLOCKSETUP=y # CONFIG_MODEM is not set # CONFIG_MTD is not set # CONFIG_EEPROM is not set +CONFIG_NETDEVICES=y + +# +# General Ethernet MAC Driver Options +# +# CONFIG_NETDEV_LOOPBACK is not set +# CONFIG_NETDEV_MULTINIC is not set +# CONFIG_ARCH_HAVE_NETDEV_STATISTICS is not set +CONFIG_NETDEV_LATEINIT=y +# CONFIG_NET_DUMPPACKET is not set + +# +# External Ethernet MAC Device Support +# +# CONFIG_NET_DM90x0 is not set +# CONFIG_NET_CS89x0 is not set +# CONFIG_ENC28J60 is not set +# CONFIG_ENCX24J600 is not set +# CONFIG_NET_SLIP is not set +# CONFIG_NET_FTMAC100 is not set # CONFIG_PIPES is not set # CONFIG_PM is not set # CONFIG_POWER is not set @@ -926,6 +947,8 @@ CONFIG_DRIVERS_IEEE80211=y CONFIG_IEEE80211_BROADCOM_FULLMAC=y CONFIG_IEEE80211_BROADCOM_BCM43362=y CONFIG_IEEE80211_BROADCOM_FULLMAC_SDIO=y +CONFIG_IEEE80211_BROADCOM_HPWORK=y +CONFIG_IEEE80211_BROADCOM_NINTERFACES=1 # CONFIG_WL_NRF24L01 is not set # CONFIG_DRIVERS_CONTACTLESS is not set @@ -946,9 +969,100 @@ CONFIG_SYSLOG_CONSOLE=y # # Networking Support # -# CONFIG_ARCH_HAVE_NET is not set +CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set -# CONFIG_NET is not set +CONFIG_NET=y +# CONFIG_NET_PROMISCUOUS is not set + +# +# Driver buffer configuration +# +CONFIG_NET_ETH_MTU=590 +CONFIG_NET_GUARDSIZE=2 + +# +# Data link support +# +# CONFIG_NET_MULTILINK is not set +# CONFIG_NET_USER_DEVFMT is not set +CONFIG_NET_ETHERNET=y +# CONFIG_NET_LOOPBACK is not set +# CONFIG_NET_TUN is not set +# CONFIG_NET_USRSOCK is not set + +# +# Network Device Operations +# +# CONFIG_NETDEV_IOCTL is not set +# CONFIG_NETDEV_PHY_IOCTL is not set +# CONFIG_NETDEV_WIRELESS_IOCTL is not set + +# +# Internet Protocol Selection +# +CONFIG_NET_IPv4=y +# CONFIG_NET_IPv6 is not set + +# +# Socket Support +# +CONFIG_NSOCKET_DESCRIPTORS=8 +CONFIG_NET_NACTIVESOCKETS=16 +# CONFIG_NET_SOCKOPTS is not set + +# +# Raw Socket Support +# +# CONFIG_NET_PKT is not set + +# +# Unix Domain Socket Support +# +# CONFIG_NET_LOCAL is not set + +# +# TCP/IP Networking +# +# CONFIG_NET_TCP is not set +# CONFIG_NET_TCP_NO_STACK is not set + +# +# UDP Networking +# +# CONFIG_NET_UDP is not set +# CONFIG_NET_UDP_NO_STACK is not set + +# +# ICMP Networking Support +# +# CONFIG_NET_ICMP is not set + +# +# IGMPv2 Client Support +# +# CONFIG_NET_IGMP is not set + +# +# ARP Configuration +# +CONFIG_NET_ARP=y +CONFIG_NET_ARPTAB_SIZE=16 +CONFIG_NET_ARP_MAXAGE=120 +# CONFIG_NET_ARP_IPIN is not set +# CONFIG_NET_ARP_SEND is not set + +# +# User-space networking stack API +# +# CONFIG_NET_ARCH_INCR32 is not set +# CONFIG_NET_ARCH_CHKSUM is not set +# CONFIG_NET_STATISTICS is not set + +# +# Routing Table Configuration +# +# CONFIG_NET_ROUTE is not set +CONFIG_NET_HOSTNAME="" # # Crypto API @@ -986,6 +1100,7 @@ CONFIG_FS_PROCFS=y # CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set # CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set # CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set +# CONFIG_FS_PROCFS_EXCLUDE_NET is not set # CONFIG_FS_UNIONFS is not set # @@ -1109,9 +1224,8 @@ CONFIG_ARCH_HAVE_TLS=y # # Network-Related Options # -# CONFIG_LIBC_IPv4_ADDRCONV is not set # CONFIG_LIBC_IPv6_ADDRCONV is not set -# CONFIG_LIBC_NETDB is not set +CONFIG_LIBC_NETDB=y # # NETDB Support @@ -1259,6 +1373,7 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_NETUTILS_ESP8266 is not set # CONFIG_NETUTILS_FTPC is not set # CONFIG_NETUTILS_JSON is not set +CONFIG_NETUTILS_NETLIB=y # CONFIG_NETUTILS_SMTP is not set # @@ -1285,6 +1400,7 @@ CONFIG_NSH_BUILTIN_APPS=y # Disable Individual commands # # CONFIG_NSH_DISABLE_ADDROUTE is not set +# CONFIG_NSH_DISABLE_ARP is not set # CONFIG_NSH_DISABLE_BASENAME is not set # CONFIG_NSH_DISABLE_CAT is not set # CONFIG_NSH_DISABLE_CD is not set @@ -1358,6 +1474,26 @@ CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_CONSOLE=y # CONFIG_NSH_ALTCONDEV is not set CONFIG_NSH_ARCHINIT=y + +# +# Networking Configuration +# +CONFIG_NSH_NETINIT=y +# CONFIG_NSH_NETINIT_THREAD is not set +# CONFIG_NSH_NETINIT_DEBUG is not set + +# +# IP Address Configuration +# + +# +# IPv4 Addresses +# +CONFIG_NSH_IPADDR=0x0a000002 +CONFIG_NSH_DRIPADDR=0x0a000001 +CONFIG_NSH_NETMASK=0xffffff00 +# CONFIG_NSH_NOMAC is not set +CONFIG_NSH_MAX_ROUNDTRIP=20 # CONFIG_NSH_LOGIN is not set # CONFIG_NSH_CONSOLE_LOGIN is not set @@ -1375,6 +1511,7 @@ CONFIG_NSH_ARCHINIT=y # CONFIG_SYSTEM_HEX2BIN is not set # CONFIG_SYSTEM_HEXED is not set # CONFIG_SYSTEM_INSTALL is not set +# CONFIG_SYSTEM_NETDB is not set # CONFIG_SYSTEM_RAMTEST is not set CONFIG_READLINE_HAVE_EXTMATCH=y CONFIG_SYSTEM_READLINE=y @@ -1387,3 +1524,8 @@ CONFIG_READLINE_ECHO=y # CONFIG_SYSTEM_UBLOXMODEM is not set # CONFIG_SYSTEM_VI is not set # CONFIG_SYSTEM_ZMODEM is not set + +# +# Wireless Libraries and NSH Add-Ons +# +# CONFIG_WIRELESS_WAPI is not set diff --git a/drivers/wireless/ieee80211/Make.defs b/drivers/wireless/ieee80211/Make.defs index eebfb9f821..0586e423da 100644 --- a/drivers/wireless/ieee80211/Make.defs +++ b/drivers/wireless/ieee80211/Make.defs @@ -44,6 +44,7 @@ ifeq ($(CONFIG_IEEE80211_BROADCOM_FULLMAC),y) CSRCS += bcmf_driver.c CSRCS += bcmf_cdc.c CSRCS += bcmf_utils.c + CSRCS += bcmf_netdev.c ifeq ($(CONFIG_IEEE80211_BROADCOM_FULLMAC_SDIO),y) CSRCS += mmc_sdio.c diff --git a/drivers/wireless/ieee80211/bcmf_chip_43362.c b/drivers/wireless/ieee80211/bcmf_chip_43362.c index f53fb06b8e..5637173c95 100644 --- a/drivers/wireless/ieee80211/bcmf_chip_43362.c +++ b/drivers/wireless/ieee80211/bcmf_chip_43362.c @@ -65,9 +65,9 @@ const struct bcmf_sdio_chip bcmf_43362_config_sdio = { // TODO find something smarter than using image_len references - .firmware_image = bcm43362_firmware_image, + .firmware_image = (uint8_t*)bcm43362_firmware_image, .firmware_image_size = (unsigned int*)&bcm43362_firmware_image_len, - .nvram_image = bcm43362_nvram_image, + .nvram_image = (uint8_t*)bcm43362_nvram_image, .nvram_image_size = (unsigned int*)&bcm43362_nvram_image_len }; \ No newline at end of file diff --git a/drivers/wireless/ieee80211/bcmf_driver.c b/drivers/wireless/ieee80211/bcmf_driver.c index 828de645f0..5294e5a781 100644 --- a/drivers/wireless/ieee80211/bcmf_driver.c +++ b/drivers/wireless/ieee80211/bcmf_driver.c @@ -45,6 +45,8 @@ #include #include +#include + #include #include "bcmf_driver.h" @@ -64,11 +66,6 @@ #define WL_SCAN_UNASSOC_TIME 40 #define WL_SCAN_PASSIVE_TIME 120 -/* Chip interfaces */ -#define CHIP_STA_INTERFACE 0 -#define CHIP_AP_INTERFACE 1 -#define CHIP_P2P_INTERFACE 2 - /**************************************************************************** * Private Types ****************************************************************************/ @@ -80,6 +77,11 @@ static FAR struct bcmf_dev_s* bcmf_allocate_device(void); static void bcmf_free_device(FAR struct bcmf_dev_s *priv); +static int bcmf_driver_initialize(FAR struct bcmf_dev_s *priv); + +// FIXME add bcmf_netdev.h file +int bcmf_netdev_register(FAR struct bcmf_dev_s *priv); + #if 0 static int bcmf_run_escan(FAR struct bcmf_dev_s *priv); #endif @@ -154,30 +156,11 @@ int bcmf_wl_set_mac_address(FAR struct bcmf_dev_s *priv, uint8_t *addr) wlinfo("MAC address updated %02X:%02X:%02X:%02X:%02X:%02X\n", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); - memcpy(priv->mac_addr, addr, 6); + memcpy(priv->bc_dev.d_mac.ether.ether_addr_octet, addr, ETHER_ADDR_LEN); return OK; } -int bcmf_wl_enable(FAR struct bcmf_dev_s *priv, bool enable) -{ - int ret; - uint32_t out_len; - - /* TODO chek device state */ - - out_len = 0; - ret = bcmf_cdc_ioctl(priv, CHIP_STA_INTERFACE, true, - enable ? WLC_UP : WLC_DOWN, NULL, &out_len); - - if (ret == OK) - { - /* TODO update device state */ - } - - return ret; -} - int bcmf_dongle_scantime(FAR struct bcmf_dev_s *priv, int32_t scan_assoc_time, int32_t scan_unassoc_time, int32_t scan_passive_time) { @@ -220,8 +203,6 @@ int bcmf_dongle_scantime(FAR struct bcmf_dev_s *priv, int32_t scan_assoc_time, int bcmf_dongle_initialize(FAR struct bcmf_dev_s *priv) { int ret; - uint32_t out_len; - uint32_t value; ret = bcmf_wl_enable(priv, true); if (ret) @@ -236,36 +217,6 @@ int bcmf_dongle_initialize(FAR struct bcmf_dev_s *priv) return ret; } - /* FIXME disable power save mode */ - - out_len = 4; - value = 0; - ret = bcmf_cdc_ioctl(priv, CHIP_STA_INTERFACE, true, - WLC_SET_PM, (uint8_t*)&value, &out_len); - if (ret != OK) - { - return ret; - } - - /* Set the GMode */ - - out_len = 4; - value = GMODE_AUTO; - ret = bcmf_cdc_ioctl(priv, CHIP_STA_INTERFACE, true, - WLC_SET_GMODE, (uint8_t*)&value, &out_len); - if (ret != OK) - { - return ret; - } - - /* TODO configure roaming if needed. Disable for now */ - - out_len = 4; - value = 1; - ret = bcmf_cdc_iovar_request(priv, CHIP_STA_INTERFACE, true, - IOVAR_STR_ROAM_OFF, (uint8_t*)&value, - &out_len); - // FIXME remove #if 0 /* Try scan */ @@ -330,14 +281,10 @@ int bcmf_run_escan(FAR struct bcmf_dev_s *priv) } #endif -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -int bcmf_wl_initialize(FAR struct bcmf_dev_s *priv) +int bcmf_driver_initialize(FAR struct bcmf_dev_s *priv) { int ret; - uint32_t out_len; + uint32_t out_len, value; uint8_t tmp_buf[64]; /* Disable TX Gloming feature */ @@ -352,22 +299,35 @@ int bcmf_wl_initialize(FAR struct bcmf_dev_s *priv) return -EIO; } - /* Query MAC address */ + /* FIXME disable power save mode */ - out_len = 6; - ret = bcmf_cdc_iovar_request(priv, CHIP_STA_INTERFACE, false, - IOVAR_STR_CUR_ETHERADDR, tmp_buf, - &out_len); + out_len = 4; + value = 0; + ret = bcmf_cdc_ioctl(priv, CHIP_STA_INTERFACE, true, + WLC_SET_PM, (uint8_t*)&value, &out_len); if (ret != OK) { - return -EIO; + return ret; } - memcpy(priv->mac_addr, tmp_buf, 6); + /* Set the GMode to auto */ - wlinfo("MAC address is %02X:%02X:%02X:%02X:%02X:%02X\n", - tmp_buf[0], tmp_buf[1], tmp_buf[2], - tmp_buf[3], tmp_buf[4], tmp_buf[5]); + out_len = 4; + value = GMODE_AUTO; + ret = bcmf_cdc_ioctl(priv, CHIP_STA_INTERFACE, true, + WLC_SET_GMODE, (uint8_t*)&value, &out_len); + if (ret != OK) + { + return ret; + } + + /* TODO configure roaming if needed. Disable for now */ + + out_len = 4; + value = 1; + ret = bcmf_cdc_iovar_request(priv, CHIP_STA_INTERFACE, true, + IOVAR_STR_ROAM_OFF, (uint8_t*)&value, + &out_len); /* Query firmware version string */ @@ -402,11 +362,16 @@ int bcmf_wl_initialize(FAR struct bcmf_dev_s *priv) { return -EIO; } - // TODO Create a wlan device name and register network driver - return bcmf_dongle_initialize(priv); + /* Register network driver */ + + return bcmf_netdev_register(priv); } +/**************************************************************************** + * Public Functions + ****************************************************************************/ + int bcmf_sdio_initialize(int minor, FAR struct sdio_dev_s *dev) { int ret; @@ -431,9 +396,28 @@ int bcmf_sdio_initialize(int minor, FAR struct sdio_dev_s *dev) /* Bus initialized, register network driver */ - return bcmf_wl_initialize(priv); + return bcmf_driver_initialize(priv); exit_free_device: bcmf_free_device(priv); return ret; +} + +int bcmf_wl_enable(FAR struct bcmf_dev_s *priv, bool enable) +{ + int ret; + uint32_t out_len; + + /* TODO chek device state */ + + out_len = 0; + ret = bcmf_cdc_ioctl(priv, CHIP_STA_INTERFACE, true, + enable ? WLC_UP : WLC_DOWN, NULL, &out_len); + + if (ret == OK) + { + /* TODO update device state */ + } + + return ret; } \ No newline at end of file diff --git a/drivers/wireless/ieee80211/bcmf_driver.h b/drivers/wireless/ieee80211/bcmf_driver.h index d121fc2a95..346b2e15fd 100644 --- a/drivers/wireless/ieee80211/bcmf_driver.h +++ b/drivers/wireless/ieee80211/bcmf_driver.h @@ -40,11 +40,15 @@ #include #include -#define BCMF_STATUS_BUS_UP (1<<0) /* Chip is flashed and running */ -#define BCMF_STATUS_READY (1<<1) /* Chip is ready to receive requests */ +#include +#include +#include -#define BCMF_STATUS_SLEEP (1<<2) /* Chip is in low power mode */ -#define BCMF_STATUS_WAIT_CONTROL (1<<3) /* Waiting for control response */ +/* Chip interfaces */ + +#define CHIP_STA_INTERFACE 0 +#define CHIP_AP_INTERFACE 1 +#define CHIP_P2P_INTERFACE 2 struct bcmf_bus_dev_s; struct bcmf_frame_s; @@ -53,7 +57,18 @@ struct bcmf_frame_s; struct bcmf_dev_s { - FAR struct bcmf_bus_dev_s *bus; /* Bus interface structure */ + FAR struct bcmf_bus_dev_s *bus; /* Bus interface structure */ + + bool bc_bifup; /* true:ifup false:ifdown */ + WDOG_ID bc_txpoll; /* TX poll timer */ + WDOG_ID bc_txtimeout; /* TX timeout timer */ + struct work_s bc_irqwork; /* For deferring interrupt work to the work queue */ + struct work_s bc_pollwork; /* For deferring poll work to the work queue */ + + /* This holds the information visible to the NuttX network */ + + struct net_driver_s bc_dev; /* Network interface structure */ + // FIXME use mutex instead of semaphore sem_t control_mutex; /* Cannot handle multiple control requests */ @@ -62,8 +77,6 @@ struct bcmf_dev_s uint16_t control_rxdata_len; /* Received control frame out buffer length */ uint8_t *control_rxdata; /* Received control frame out buffer */ uint32_t control_status; /* Last received frame status */ - - uint8_t mac_addr[6]; /* Current mac address */ }; /* Default bus interface structure */ @@ -89,13 +102,6 @@ struct bcmf_frame_s { unsigned int len; /* Frame buffer size */ }; -/* Notify driver frame is available */ - -void bcmf_notify_rxframe(FAR struct bcmf_dev_s *priv, - struct bcmf_frame_s *frame); - -/* Notify driver bus is ready */ - -int brcmf_bus_start(FAR struct bcmf_dev_s *priv); +int bcmf_wl_enable(FAR struct bcmf_dev_s *priv, bool enable); #endif /* __DRIVERS_WIRELESS_IEEE80211_BCMF_DRIVER_H */ diff --git a/drivers/wireless/ieee80211/bcmf_ioctl.h b/drivers/wireless/ieee80211/bcmf_ioctl.h index 6940a5d344..d1936bb7ff 100644 --- a/drivers/wireless/ieee80211/bcmf_ioctl.h +++ b/drivers/wireless/ieee80211/bcmf_ioctl.h @@ -49,7 +49,7 @@ extern "C" { typedef uint16_t wl_chanspec_t; typedef uint16_t chanspec_t; #define ETHER_ADDR_LEN 6 -typedef struct ether_addr +typedef struct ether_addr_dup { uint8_t octet[ETHER_ADDR_LEN]; } wl_ether_addr_t; diff --git a/drivers/wireless/ieee80211/bcmf_netdev.c b/drivers/wireless/ieee80211/bcmf_netdev.c index 96ffed609f..5d94d9e583 100644 --- a/drivers/wireless/ieee80211/bcmf_netdev.c +++ b/drivers/wireless/ieee80211/bcmf_netdev.c @@ -61,6 +61,10 @@ # include #endif +#include "bcmf_driver.h" +#include "bcmf_cdc.h" +#include "bcmf_ioctl.h" + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -108,23 +112,6 @@ * Private Types ****************************************************************************/ -/* The bcmf_driver_s encapsulates all state information for a single hardware - * interface - */ - -struct bcmf_driver_s -{ - bool bc_bifup; /* true:ifup false:ifdown */ - WDOG_ID bc_txpoll; /* TX poll timer */ - WDOG_ID bc_txtimeout; /* TX timeout timer */ - struct work_s bc_irqwork; /* For deferring interupt work to the work queue */ - struct work_s bc_pollwork; /* For deferring poll work to the work queue */ - - /* This holds the information visible to the NuttX network */ - - struct net_driver_s bc_dev; /* Interface understood by the network */ -}; - /**************************************************************************** * Private Data ****************************************************************************/ @@ -144,23 +131,19 @@ struct bcmf_driver_s static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE]; -/* Driver state structure */ - -static struct bcmf_driver_s g_bcmf_interface[CONFIG_IEEE80211_BROADCOM_NINTERFACES]; - /**************************************************************************** * Private Function Prototypes ****************************************************************************/ /* Common TX logic */ -static int bcmf_transmit(FAR struct bcmf_driver_s *priv); +static int bcmf_transmit(FAR struct bcmf_dev_s *priv); static int bcmf_txpoll(FAR struct net_driver_s *dev); /* Interrupt handling */ -static void bcmf_receive(FAR struct bcmf_driver_s *priv); -static void bcmf_txdone(FAR struct bcmf_driver_s *priv); +static void bcmf_receive(FAR struct bcmf_dev_s *priv); +static void bcmf_txdone(FAR struct bcmf_dev_s *priv); static void bcmf_interrupt_work(FAR void *arg); static int bcmf_interrupt(int irq, FAR void *context, FAR void *arg); @@ -189,7 +172,7 @@ static int bcmf_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac); #endif #ifdef CONFIG_NET_ICMPv6 -static void bcmf_ipv6multicast(FAR struct bcmf_driver_s *priv); +static void bcmf_ipv6multicast(FAR struct bcmf_dev_s *priv); #endif #endif #ifdef CONFIG_NETDEV_IOCTL @@ -220,7 +203,7 @@ static int bcmf_ioctl(FAR struct net_driver_s *dev, int cmd, * ****************************************************************************/ -static int bcmf_transmit(FAR struct bcmf_driver_s *priv) +static int bcmf_transmit(FAR struct bcmf_dev_s *priv) { /* Verify that the hardware is ready to send another packet. If we get * here, then we are committed to sending a packet; Higher level logic @@ -268,7 +251,7 @@ static int bcmf_transmit(FAR struct bcmf_driver_s *priv) static int bcmf_txpoll(FAR struct net_driver_s *dev) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)dev->d_private; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; /* If the polling resulted in data that should be sent out on the network, * the field d_len is set to a value > 0. @@ -331,7 +314,7 @@ static int bcmf_txpoll(FAR struct net_driver_s *dev) * ****************************************************************************/ -static void bcmf_receive(FAR struct bcmf_driver_s *priv) +static void bcmf_receive(FAR struct bcmf_dev_s *priv) { do { @@ -453,7 +436,7 @@ static void bcmf_receive(FAR struct bcmf_driver_s *priv) NETDEV_RXDROPPED(&priv->bc_dev); } } - while (); /* While there are more packets to be processed */ + while (1); /* While there are more packets to be processed */ } /**************************************************************************** @@ -473,7 +456,7 @@ static void bcmf_receive(FAR struct bcmf_driver_s *priv) * ****************************************************************************/ -static void bcmf_txdone(FAR struct bcmf_driver_s *priv) +static void bcmf_txdone(FAR struct bcmf_dev_s *priv) { int delay; @@ -515,7 +498,7 @@ static void bcmf_txdone(FAR struct bcmf_driver_s *priv) static void bcmf_interrupt_work(FAR void *arg) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)arg; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; /* Lock the network and serialize driver operations if necessary. * NOTE: Serialization is only required in the case where the driver work @@ -566,7 +549,7 @@ static void bcmf_interrupt_work(FAR void *arg) static int bcmf_interrupt(int irq, FAR void *context, FAR void *arg) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)arg; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; DEBUGASSERT(priv != NULL); @@ -612,7 +595,7 @@ static int bcmf_interrupt(int irq, FAR void *context, FAR void *arg) static void bcmf_txtimeout_work(FAR void *arg) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)arg; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; /* Lock the network and serialize driver operations if necessary. * NOTE: Serialization is only required in the case where the driver work @@ -655,7 +638,7 @@ static void bcmf_txtimeout_work(FAR void *arg) static void bcmf_txtimeout_expiry(int argc, wdparm_t arg, ...) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)arg; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; /* Disable further Ethernet interrupts. This will prevent some race * conditions with interrupt work. There is still a potential race @@ -685,7 +668,7 @@ static void bcmf_txtimeout_expiry(int argc, wdparm_t arg, ...) * ****************************************************************************/ -static inline void bcmf_poll_process(FAR struct bcmf_driver_s *priv) +static inline void bcmf_poll_process(FAR struct bcmf_dev_s *priv) { } @@ -708,7 +691,7 @@ static inline void bcmf_poll_process(FAR struct bcmf_driver_s *priv) static void bcmf_poll_work(FAR void *arg) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)arg; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; /* Lock the network and serialize driver operations if necessary. * NOTE: Serialization is only required in the case where the driver work @@ -758,7 +741,7 @@ static void bcmf_poll_work(FAR void *arg) static void bcmf_poll_expiry(int argc, wdparm_t arg, ...) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)arg; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; /* Schedule to perform the interrupt processing on the worker thread. */ @@ -784,7 +767,7 @@ static void bcmf_poll_expiry(int argc, wdparm_t arg, ...) static int bcmf_ifup(FAR struct net_driver_s *dev) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)dev->d_private; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 ninfo("Bringing up: %d.%d.%d.%d\n", @@ -838,7 +821,7 @@ static int bcmf_ifup(FAR struct net_driver_s *dev) static int bcmf_ifdown(FAR struct net_driver_s *dev) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)dev->d_private; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; irqstate_t flags; /* Disable the hardware interrupt */ @@ -882,7 +865,7 @@ static int bcmf_ifdown(FAR struct net_driver_s *dev) static void bcmf_txavail_work(FAR void *arg) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)arg; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg; /* Lock the network and serialize driver operations if necessary. * NOTE: Serialization is only required in the case where the driver work @@ -927,7 +910,7 @@ static void bcmf_txavail_work(FAR void *arg) static int bcmf_txavail(FAR struct net_driver_s *dev) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)dev->d_private; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; /* Is our single work structure available? It may not be if there are * pending interrupt actions and we will have to ignore the Tx @@ -965,7 +948,7 @@ static int bcmf_txavail(FAR struct net_driver_s *dev) #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) static int bcmf_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)dev->d_private; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; /* Add the MAC address to the hardware multicast routing table */ @@ -994,7 +977,7 @@ static int bcmf_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) #ifdef CONFIG_NET_IGMP static int bcmf_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)dev->d_private; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; /* Add the MAC address to the hardware multicast routing table */ @@ -1019,7 +1002,7 @@ static int bcmf_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) ****************************************************************************/ #ifdef CONFIG_NET_ICMPv6 -static void bcmf_ipv6multicast(FAR struct bcmf_driver_s *priv) +static void bcmf_ipv6multicast(FAR struct bcmf_dev_s *priv) { FAR struct net_driver_s *dev; uint16_t tmp16; @@ -1098,7 +1081,7 @@ static void bcmf_ipv6multicast(FAR struct bcmf_driver_s *priv) static int bcmf_ioctl(FAR struct net_driver_s *dev, int cmd, unsigned long arg) { - FAR struct bcmf_driver_s *priv = (FAR struct bcmf_driver_s *)dev->d_private; + FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private; int ret; /* Decode and dispatch the driver-specific IOCTL command */ @@ -1124,11 +1107,10 @@ static int bcmf_ioctl(FAR struct net_driver_s *dev, int cmd, * Name: bcmf_netdev_register * * Description: - * Initialize the Broadcom 43362 controller and driver + * Register a network driver and set Broadcom chip in a proper state * * Parameters: - * intf - In the case where there are multiple EMACs, this value - * identifies which EMAC is to be initialized. + * priv - Broadcom driver device * * Returned Value: * OK on success; Negated errno on failure. @@ -1137,21 +1119,14 @@ static int bcmf_ioctl(FAR struct net_driver_s *dev, int cmd, * ****************************************************************************/ -int bcmf_netdev_register(int intf) +int bcmf_netdev_register(FAR struct bcmf_dev_s *priv) { - FAR struct bcmf_driver_s *priv; + int ret; + uint32_t out_len; - /* Get the interface structure associated with this interface number. */ + /* Initialize network driver structure */ - DEBUGASSERT(intf < CONFIG_IEEE80211_BROADCOM_NINTERFACES); - priv = &g_bcmf_interface[intf]; - - /* Attach the IRQ to the driver */ -#warning Missing logic - - /* Initialize the driver structure */ - - memset(priv, 0, sizeof(struct bcmf_driver_s)); + memset(&priv->bc_dev, 0, sizeof(priv->bc_dev)); priv->bc_dev.d_buf = g_pktbuf; /* Single packet buffer */ priv->bc_dev.d_ifup = bcmf_ifup; /* I/F up (new IP address) callback */ priv->bc_dev.d_ifdown = bcmf_ifdown; /* I/F down callback */ @@ -1163,7 +1138,7 @@ int bcmf_netdev_register(int intf) #ifdef CONFIG_NETDEV_IOCTL priv->bc_dev.d_ioctl = bcmf_ioctl; /* Handle network IOCTL commands */ #endif - priv->bc_dev.d_private = (FAR void *)g_bcmf_interface; /* Used to recover private state from dev */ + priv->bc_dev.d_private = (FAR void *)priv; /* Used to recover private state from dev */ /* Create a watchdog for timing polling for and timing of transmisstions */ @@ -1176,7 +1151,31 @@ int bcmf_netdev_register(int intf) * the device and/or calling bcmf_ifdown(). */ - /* Read the MAC address from the hardware into priv->bc_dev.d_mac.ether.ether_addr_octet */ + ret = bcmf_wl_enable(priv, false); + if (ret != OK) + { + return -EIO; + } + + /* Query MAC address */ + + out_len = ETHER_ADDR_LEN; + ret = bcmf_cdc_iovar_request(priv, CHIP_STA_INTERFACE, false, + IOVAR_STR_CUR_ETHERADDR, + priv->bc_dev.d_mac.ether.ether_addr_octet, + &out_len); + if (ret != OK) + { + return -EIO; + } + + wlinfo("MAC address is %02X:%02X:%02X:%02X:%02X:%02X\n", + priv->bc_dev.d_mac.ether.ether_addr_octet[0], + priv->bc_dev.d_mac.ether.ether_addr_octet[1], + priv->bc_dev.d_mac.ether.ether_addr_octet[2], + priv->bc_dev.d_mac.ether.ether_addr_octet[3], + priv->bc_dev.d_mac.ether.ether_addr_octet[4], + priv->bc_dev.d_mac.ether.ether_addr_octet[5]); /* Register the device with the OS so that socket IOCTLs can be performed */