mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
bcmf: register network driver + update defconfig file
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
};
|
||||
@@ -45,6 +45,8 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -40,11 +40,15 @@
|
||||
#include <stdint.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#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 <nuttx/net/netdev.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
|
||||
#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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -61,6 +61,10 @@
|
||||
# include <nuttx/net/pkt.h>
|
||||
#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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user