2017-03-26 17:42:53 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/wireless/ieee80211/bcmf_driver.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
|
|
|
* Author: Simon Piriou <spiriou31@gmail.com>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __DRIVERS_WIRELESS_IEEE80211_BCMF_DRIVER_H
|
|
|
|
#define __DRIVERS_WIRELESS_IEEE80211_BCMF_DRIVER_H
|
|
|
|
|
2017-04-13 20:31:39 +02:00
|
|
|
#include <stdbool.h>
|
2017-04-23 22:17:43 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <semaphore.h>
|
2017-03-26 17:42:53 +02:00
|
|
|
|
2017-04-24 20:04:47 +02:00
|
|
|
#include <nuttx/net/netdev.h>
|
2017-04-30 20:29:48 +02:00
|
|
|
#include <net/if.h>
|
2017-04-24 20:04:47 +02:00
|
|
|
#include <nuttx/wdog.h>
|
|
|
|
#include <nuttx/wqueue.h>
|
2017-04-16 13:13:11 +02:00
|
|
|
|
2017-05-03 23:19:28 +02:00
|
|
|
#include "bcmf_ioctl.h"
|
|
|
|
|
2017-04-28 19:28:29 +02:00
|
|
|
struct bcmf_dev_s;
|
|
|
|
struct bcmf_frame_s;
|
|
|
|
|
|
|
|
#include "bcmf_bdc.h"
|
|
|
|
|
|
|
|
struct bcmf_bus_dev_s;
|
|
|
|
|
2017-04-24 20:04:47 +02:00
|
|
|
/* Chip interfaces */
|
|
|
|
|
|
|
|
#define CHIP_STA_INTERFACE 0
|
|
|
|
#define CHIP_AP_INTERFACE 1
|
|
|
|
#define CHIP_P2P_INTERFACE 2
|
2017-04-16 13:13:11 +02:00
|
|
|
|
2017-03-26 17:42:53 +02:00
|
|
|
/* This structure contains the unique state of the Broadcom FullMAC driver */
|
|
|
|
|
|
|
|
struct bcmf_dev_s
|
|
|
|
{
|
2017-04-24 20:04:47 +02:00
|
|
|
FAR struct bcmf_bus_dev_s *bus; /* Bus interface structure */
|
|
|
|
|
|
|
|
bool bc_bifup; /* true:ifup false:ifdown */
|
|
|
|
WDOG_ID bc_txpoll; /* TX poll 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 */
|
|
|
|
|
2017-04-30 20:29:48 +02:00
|
|
|
struct net_driver_s bc_dev; /* Network interface structure */
|
|
|
|
struct bcmf_frame_s *cur_tx_frame; /* Frame used to interface network layer */
|
2017-04-24 20:04:47 +02:00
|
|
|
|
2017-04-28 19:28:29 +02:00
|
|
|
/* Event registration array */
|
|
|
|
|
|
|
|
event_handler_t event_handlers[BCMF_EVENT_COUNT];
|
2017-03-26 17:42:53 +02:00
|
|
|
|
2017-04-23 22:17:43 +02:00
|
|
|
// FIXME use mutex instead of semaphore
|
|
|
|
sem_t control_mutex; /* Cannot handle multiple control requests */
|
|
|
|
sem_t control_timeout; /* Semaphore to wait for control frame rsp */
|
|
|
|
uint16_t control_reqid; /* Current control request id */
|
|
|
|
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 */
|
2017-04-28 19:28:29 +02:00
|
|
|
|
|
|
|
/* AP Scan state machine.
|
|
|
|
* During scan, control_mutex is locked to prevent control requests */
|
|
|
|
|
|
|
|
int scan_status; /* Current scan status */
|
|
|
|
WDOG_ID scan_timeout; /* Scan timeout timer */
|
2017-05-20 22:13:15 +02:00
|
|
|
FAR uint8_t *scan_result; /* Temp buffer that holds results */
|
|
|
|
unsigned int scan_result_size; /* Current size of temp buffer */
|
2017-04-30 20:29:48 +02:00
|
|
|
|
|
|
|
sem_t auth_signal; /* Authentication notification signal */
|
2017-05-02 16:48:13 +02:00
|
|
|
int auth_status; /* Authentication status */
|
2017-04-23 22:17:43 +02:00
|
|
|
};
|
2017-04-13 20:31:39 +02:00
|
|
|
|
2017-04-23 22:17:43 +02:00
|
|
|
/* Default bus interface structure */
|
2017-04-13 20:31:39 +02:00
|
|
|
|
2017-04-30 20:29:48 +02:00
|
|
|
struct bcmf_bus_dev_s
|
|
|
|
{
|
2017-04-23 22:17:43 +02:00
|
|
|
void (*stop)(FAR struct bcmf_dev_s *priv);
|
2017-04-30 20:29:48 +02:00
|
|
|
int (*txframe)(FAR struct bcmf_dev_s *priv, struct bcmf_frame_s *frame,
|
|
|
|
bool control);
|
2017-05-04 02:20:57 +02:00
|
|
|
struct bcmf_frame_s *(*rxframe)(FAR struct bcmf_dev_s *priv);
|
2017-04-16 11:28:08 +02:00
|
|
|
|
2017-04-30 20:29:48 +02:00
|
|
|
/* Frame buffer allocation primitives
|
2017-04-23 22:17:43 +02:00
|
|
|
* len - requested payload length
|
|
|
|
* control - true if control frame else false
|
|
|
|
* block - true to block until free frame is available
|
|
|
|
*/
|
2017-05-04 02:20:57 +02:00
|
|
|
struct bcmf_frame_s *(*allocate_frame)(FAR struct bcmf_dev_s *priv,
|
2017-04-30 20:29:48 +02:00
|
|
|
unsigned int len, bool block,
|
|
|
|
bool control);
|
|
|
|
|
2017-05-04 02:20:57 +02:00
|
|
|
void (*free_frame)(FAR struct bcmf_dev_s *priv, struct bcmf_frame_s *frame);
|
2017-04-23 22:17:43 +02:00
|
|
|
};
|
2017-04-16 11:28:08 +02:00
|
|
|
|
2017-04-23 22:17:43 +02:00
|
|
|
/* bcmf frame definition */
|
2017-04-22 15:57:51 +02:00
|
|
|
|
2017-04-30 20:29:48 +02:00
|
|
|
struct bcmf_frame_s
|
|
|
|
{
|
|
|
|
uint8_t *base; /* Frame base buffer used by low level layer (SDIO) */
|
|
|
|
uint8_t *data; /* Payload data (Control, data and event messages) */
|
|
|
|
uint16_t len; /* Frame buffer size */
|
2017-03-26 17:42:53 +02:00
|
|
|
};
|
|
|
|
|
2017-05-02 16:48:13 +02:00
|
|
|
/* IOCTLs network interface implementation */
|
|
|
|
|
2017-04-30 20:29:48 +02:00
|
|
|
int bcmf_wl_set_mac_address(FAR struct bcmf_dev_s *priv, struct ifreq *req);
|
|
|
|
|
2017-04-24 20:04:47 +02:00
|
|
|
int bcmf_wl_enable(FAR struct bcmf_dev_s *priv, bool enable);
|
2017-04-22 20:55:22 +02:00
|
|
|
|
2017-05-02 16:48:13 +02:00
|
|
|
/* IOCTLs AP scan interface implementation */
|
|
|
|
|
2017-05-03 23:19:28 +02:00
|
|
|
int bcmf_wl_start_scan(FAR struct bcmf_dev_s *priv, struct iwreq *iwr);
|
2017-04-28 19:28:29 +02:00
|
|
|
|
2017-05-03 23:19:28 +02:00
|
|
|
int bcmf_wl_get_scan_results(FAR struct bcmf_dev_s *priv, struct iwreq *iwr);
|
2017-04-28 19:28:29 +02:00
|
|
|
|
2017-05-02 16:48:13 +02:00
|
|
|
/* IOCTLs authentication interface implementation */
|
|
|
|
|
|
|
|
int bcmf_wl_set_auth_param(FAR struct bcmf_dev_s *priv, struct iwreq *iwr);
|
|
|
|
|
|
|
|
int bcmf_wl_set_encode_ext(FAR struct bcmf_dev_s *priv, struct iwreq *iwr);
|
|
|
|
|
|
|
|
int bcmf_wl_set_mode(FAR struct bcmf_dev_s *priv, struct iwreq *iwr);
|
|
|
|
|
|
|
|
int bcmf_wl_set_ssid(FAR struct bcmf_dev_s *priv, struct iwreq *iwr);
|
2017-04-30 20:29:48 +02:00
|
|
|
|
2017-03-26 17:42:53 +02:00
|
|
|
#endif /* __DRIVERS_WIRELESS_IEEE80211_BCMF_DRIVER_H */
|