Commit 5c36b99a authored by Arend van Spriel's avatar Arend van Spriel Committed by John W. Linville

brcmfmac: rework firmware event handling code

Handling of firmware event has been reworked into a seperate
code file. The change is needed as firmware event can be received
in interrupt context. Decoupling of the event handling has been
lowered to allow event processing to sleep.
Reviewed-by: default avatarHante Meuleman <meuleman@broadcom.com>
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarFranky Lin <frankyl@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 957708f1
......@@ -25,6 +25,7 @@ obj-$(CONFIG_BRCMFMAC) += brcmfmac.o
brcmfmac-objs += \
wl_cfg80211.o \
fwil.o \
fweh.o \
dhd_cdc.o \
dhd_common.o \
dhd_linux.o
......
......@@ -23,6 +23,8 @@
#define BRCMF_VERSION_STR "4.218.248.5"
#include "fweh.h"
/*******************************************************************************
* IO codes that are interpreted by dongle firmware
******************************************************************************/
......@@ -117,10 +119,6 @@
#define DOT11_BSSTYPE_ANY 2
#define DOT11_MAX_DEFAULT_KEYS 4
#define BRCMF_EVENT_MSG_LINK 0x01
#define BRCMF_EVENT_MSG_FLUSHTXQ 0x02
#define BRCMF_EVENT_MSG_GROUP 0x04
#define BRCMF_ESCAN_REQ_VERSION 1
#define WLC_BSS_RSSI_ON_CHANNEL 0x0002
......@@ -128,108 +126,6 @@
#define BRCMF_MAXRATES_IN_SET 16 /* max # of rates in rateset */
#define BRCMF_STA_ASSOC 0x10 /* Associated */
struct brcmf_event_msg {
__be16 version;
__be16 flags;
__be32 event_type;
__be32 status;
__be32 reason;
__be32 auth_type;
__be32 datalen;
u8 addr[ETH_ALEN];
char ifname[IFNAMSIZ];
u8 ifidx;
u8 bsscfgidx;
} __packed;
struct brcm_ethhdr {
u16 subtype;
u16 length;
u8 version;
u8 oui[3];
u16 usr_subtype;
} __packed;
struct brcmf_event {
struct ethhdr eth;
struct brcm_ethhdr hdr;
struct brcmf_event_msg msg;
} __packed;
/* event codes sent by the dongle to this driver */
#define BRCMF_E_SET_SSID 0
#define BRCMF_E_JOIN 1
#define BRCMF_E_START 2
#define BRCMF_E_AUTH 3
#define BRCMF_E_AUTH_IND 4
#define BRCMF_E_DEAUTH 5
#define BRCMF_E_DEAUTH_IND 6
#define BRCMF_E_ASSOC 7
#define BRCMF_E_ASSOC_IND 8
#define BRCMF_E_REASSOC 9
#define BRCMF_E_REASSOC_IND 10
#define BRCMF_E_DISASSOC 11
#define BRCMF_E_DISASSOC_IND 12
#define BRCMF_E_QUIET_START 13
#define BRCMF_E_QUIET_END 14
#define BRCMF_E_BEACON_RX 15
#define BRCMF_E_LINK 16
#define BRCMF_E_MIC_ERROR 17
#define BRCMF_E_NDIS_LINK 18
#define BRCMF_E_ROAM 19
#define BRCMF_E_TXFAIL 20
#define BRCMF_E_PMKID_CACHE 21
#define BRCMF_E_RETROGRADE_TSF 22
#define BRCMF_E_PRUNE 23
#define BRCMF_E_AUTOAUTH 24
#define BRCMF_E_EAPOL_MSG 25
#define BRCMF_E_SCAN_COMPLETE 26
#define BRCMF_E_ADDTS_IND 27
#define BRCMF_E_DELTS_IND 28
#define BRCMF_E_BCNSENT_IND 29
#define BRCMF_E_BCNRX_MSG 30
#define BRCMF_E_BCNLOST_MSG 31
#define BRCMF_E_ROAM_PREP 32
#define BRCMF_E_PFN_NET_FOUND 33
#define BRCMF_E_PFN_NET_LOST 34
#define BRCMF_E_RESET_COMPLETE 35
#define BRCMF_E_JOIN_START 36
#define BRCMF_E_ROAM_START 37
#define BRCMF_E_ASSOC_START 38
#define BRCMF_E_IBSS_ASSOC 39
#define BRCMF_E_RADIO 40
#define BRCMF_E_PSM_WATCHDOG 41
#define BRCMF_E_PROBREQ_MSG 44
#define BRCMF_E_SCAN_CONFIRM_IND 45
#define BRCMF_E_PSK_SUP 46
#define BRCMF_E_COUNTRY_CODE_CHANGED 47
#define BRCMF_E_EXCEEDED_MEDIUM_TIME 48
#define BRCMF_E_ICV_ERROR 49
#define BRCMF_E_UNICAST_DECODE_ERROR 50
#define BRCMF_E_MULTICAST_DECODE_ERROR 51
#define BRCMF_E_TRACE 52
#define BRCMF_E_IF 54
#define BRCMF_E_RSSI 56
#define BRCMF_E_PFN_SCAN_COMPLETE 57
#define BRCMF_E_EXTLOG_MSG 58
#define BRCMF_E_ACTION_FRAME 59
#define BRCMF_E_ACTION_FRAME_COMPLETE 60
#define BRCMF_E_PRE_ASSOC_IND 61
#define BRCMF_E_PRE_REASSOC_IND 62
#define BRCMF_E_CHANNEL_ADOPTED 63
#define BRCMF_E_AP_STARTED 64
#define BRCMF_E_DFS_AP_STOP 65
#define BRCMF_E_DFS_AP_RESUME 66
#define BRCMF_E_RESERVED1 67
#define BRCMF_E_RESERVED2 68
#define BRCMF_E_ESCAN_RESULT 69
#define BRCMF_E_ACTION_FRAME_OFF_CHAN_COMPLETE 70
#define BRCMF_E_DCS_REQUEST 73
#define BRCMF_E_FIFO_CREDIT_MAP 74
#define BRCMF_E_LAST 75
#define BRCMF_E_STATUS_SUCCESS 0
#define BRCMF_E_STATUS_FAIL 1
#define BRCMF_E_STATUS_TIMEOUT 2
......@@ -622,6 +518,8 @@ struct brcmf_pub {
u8 macvalue[ETH_ALEN];
atomic_t pend_8021x_cnt;
wait_queue_head_t pend_8021x_wait;
struct brcmf_fweh_info fweh;
#ifdef DEBUG
struct dentry *dbgfs_dir;
#endif
......
......@@ -85,7 +85,7 @@ extern bool brcmf_c_prec_enq(struct device *dev, struct pktq *q,
struct sk_buff *pkt, int prec);
/* Receive frame for delivery to OS. Callee disposes of rxp. */
extern void brcmf_rx_frame(struct device *dev, int ifidx,
extern void brcmf_rx_frame(struct device *dev, u8 ifidx,
struct sk_buff_head *rxlist);
static inline void brcmf_rx_packet(struct device *dev, int ifidx,
struct sk_buff *pkt)
......
......@@ -294,33 +294,13 @@ void brcmf_txflowblock(struct device *dev, bool state)
}
}
static int brcmf_host_event(struct brcmf_pub *drvr, int *ifidx,
void *pktdata, struct brcmf_event_msg *event,
void **data)
{
int bcmerror = 0;
bcmerror = brcmf_c_host_event(drvr, ifidx, pktdata, event, data);
if (bcmerror != 0)
return bcmerror;
/* only forward if interface has netdev */
if (drvr->iflist[*ifidx]->ndev)
brcmf_cfg80211_event(drvr->iflist[*ifidx],
event, *data);
return bcmerror;
}
void brcmf_rx_frame(struct device *dev, int ifidx,
void brcmf_rx_frame(struct device *dev, u8 ifidx,
struct sk_buff_head *skb_list)
{
unsigned char *eth;
uint len;
void *data;
struct sk_buff *skb, *pnext;
struct brcmf_if *ifp;
struct brcmf_event_msg event;
struct brcmf_bus *bus_if = dev_get_drvdata(dev);
struct brcmf_pub *drvr = bus_if->drvr;
......@@ -367,10 +347,7 @@ void brcmf_rx_frame(struct device *dev, int ifidx,
skb_pull(skb, ETH_HLEN);
/* Process special event packets and then discard them */
if (ntohs(skb->protocol) == ETH_P_LINK_CTL)
brcmf_host_event(drvr, &ifidx,
skb_mac_header(skb),
&event, &data);
brcmf_fweh_process_skb(drvr, skb, &ifidx);
if (drvr->iflist[ifidx]) {
ifp = drvr->iflist[ifidx];
......@@ -823,6 +800,9 @@ int brcmf_attach(uint bus_hdrlen, struct device *dev)
goto fail;
}
/* attach firmware event handler */
brcmf_fweh_attach(drvr);
INIT_WORK(&drvr->setmacaddr_work, _brcmf_set_mac_address);
INIT_WORK(&drvr->multicast_work, _brcmf_set_multicast_list);
......@@ -873,10 +853,14 @@ int brcmf_bus_start(struct device *dev)
goto fail;
}
ret = brcmf_fweh_activate_events(ifp);
if (ret < 0)
goto fail;
ret = brcmf_net_attach(ifp);
fail:
if (ret < 0) {
brcmf_dbg(ERROR, "brcmf_net_attach failed");
brcmf_dbg(ERROR, "failed: %d\n", ret);
if (drvr->config)
brcmf_cfg80211_detach(drvr->config);
free_netdev(drvr->iflist[0]->ndev);
......@@ -911,6 +895,9 @@ void brcmf_detach(struct device *dev)
if (drvr == NULL)
return;
/* stop firmware event handling */
brcmf_fweh_detach(drvr);
/* make sure primary interface removed last */
for (i = BRCMF_MAX_IFS-1; i > -1; i--)
if (drvr->iflist[i])
......
This diff is collapsed.
/*
* Copyright (c) 2012 Broadcom Corporation
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef FWEH_H_
#define FWEH_H_
#include <linux/unaligned/access_ok.h>
#include <linux/skbuff.h>
#include <linux/if_ether.h>
#include <linux/if.h>
/* formward declarations */
struct brcmf_pub;
struct brcmf_if;
struct brcmf_cfg80211_info;
struct brcmf_event;
/* firmware event codes sent by the dongle */
enum brcmf_fweh_event_code {
BRCMF_E_SET_SSID = 0,
BRCMF_E_JOIN = 1,
BRCMF_E_START = 2,
BRCMF_E_AUTH = 3,
BRCMF_E_AUTH_IND = 4,
BRCMF_E_DEAUTH = 5,
BRCMF_E_DEAUTH_IND = 6,
BRCMF_E_ASSOC = 7,
BRCMF_E_ASSOC_IND = 8,
BRCMF_E_REASSOC = 9,
BRCMF_E_REASSOC_IND = 10,
BRCMF_E_DISASSOC = 11,
BRCMF_E_DISASSOC_IND = 12,
BRCMF_E_QUIET_START = 13,
BRCMF_E_QUIET_END = 14,
BRCMF_E_BEACON_RX = 15,
BRCMF_E_LINK = 16,
BRCMF_E_MIC_ERROR = 17,
BRCMF_E_NDIS_LINK = 18,
BRCMF_E_ROAM = 19,
BRCMF_E_TXFAIL = 20,
BRCMF_E_PMKID_CACHE = 21,
BRCMF_E_RETROGRADE_TSF = 22,
BRCMF_E_PRUNE = 23,
BRCMF_E_AUTOAUTH = 24,
BRCMF_E_EAPOL_MSG = 25,
BRCMF_E_SCAN_COMPLETE = 26,
BRCMF_E_ADDTS_IND = 27,
BRCMF_E_DELTS_IND = 28,
BRCMF_E_BCNSENT_IND = 29,
BRCMF_E_BCNRX_MSG = 30,
BRCMF_E_BCNLOST_MSG = 31,
BRCMF_E_ROAM_PREP = 32,
BRCMF_E_PFN_NET_FOUND = 33,
BRCMF_E_PFN_NET_LOST = 34,
BRCMF_E_RESET_COMPLETE = 35,
BRCMF_E_JOIN_START = 36,
BRCMF_E_ROAM_START = 37,
BRCMF_E_ASSOC_START = 38,
BRCMF_E_IBSS_ASSOC = 39,
BRCMF_E_RADIO = 40,
BRCMF_E_PSM_WATCHDOG = 41,
BRCMF_E_PROBREQ_MSG = 44,
BRCMF_E_SCAN_CONFIRM_IND = 45,
BRCMF_E_PSK_SUP = 46,
BRCMF_E_COUNTRY_CODE_CHANGED = 47,
BRCMF_E_EXCEEDED_MEDIUM_TIME = 48,
BRCMF_E_ICV_ERROR = 49,
BRCMF_E_UNICAST_DECODE_ERROR = 50,
BRCMF_E_MULTICAST_DECODE_ERROR = 51,
BRCMF_E_TRACE = 52,
BRCMF_E_IF = 54,
BRCMF_E_RSSI = 56,
BRCMF_E_PFN_SCAN_COMPLETE = 57,
BRCMF_E_EXTLOG_MSG = 58,
BRCMF_E_ACTION_FRAME = 59,
BRCMF_E_ACTION_FRAME_COMPLETE = 60,
BRCMF_E_PRE_ASSOC_IND = 61,
BRCMF_E_PRE_REASSOC_IND = 62,
BRCMF_E_CHANNEL_ADOPTED = 63,
BRCMF_E_AP_STARTED = 64,
BRCMF_E_DFS_AP_STOP = 65,
BRCMF_E_DFS_AP_RESUME = 66,
BRCMF_E_ESCAN_RESULT = 69,
BRCMF_E_ACTION_FRAME_OFF_CHAN_COMPLETE = 70,
BRCMF_E_DCS_REQUEST = 73,
BRCMF_E_FIFO_CREDIT_MAP = 74,
BRCMF_E_LAST
};
/* flags field values in struct brcmf_event_msg */
#define BRCMF_EVENT_MSG_LINK 0x01
#define BRCMF_EVENT_MSG_FLUSHTXQ 0x02
#define BRCMF_EVENT_MSG_GROUP 0x04
/**
* definitions for event packet validation.
*/
#define BRCMF_EVENT_OUI_OFFSET 19
#define BRCM_OUI "\x00\x10\x18"
#define DOT11_OUI_LEN 3
#define BCMILCP_BCM_SUBTYPE_EVENT 1
/**
* struct brcmf_event_msg - firmware event message.
*
* @version: version information.
* @flags: event flags.
* @event_code: firmware event code.
* @status: status information.
* @reason: reason code.
* @auth_type: authentication type.
* @datalen: lenght of event data buffer.
* @addr: ether address.
* @ifname: interface name.
* @ifidx: interface index.
* @bsscfgidx: bsscfg index.
*/
struct brcmf_event_msg {
u16 version;
u16 flags;
u32 event_code;
u32 status;
u32 reason;
s32 auth_type;
u32 datalen;
u8 addr[ETH_ALEN];
char ifname[IFNAMSIZ];
u8 ifidx;
u8 bsscfgidx;
};
typedef int (*brcmf_fweh_handler_t)(struct brcmf_if *ifp,
const struct brcmf_event_msg *evtmsg,
void *data);
/**
* struct brcmf_fweh_info - firmware event handling information.
*
* @event_work: event worker.
* @evt_q_lock: lock for event queue protection.
* @event_q: event queue.
* @evt_handler: registered event handlers.
*/
struct brcmf_fweh_info {
struct work_struct event_work;
struct spinlock evt_q_lock;
struct list_head event_q;
int (*evt_handler[BRCMF_E_LAST])(struct brcmf_if *ifp,
const struct brcmf_event_msg *evtmsg,
void *data);
};
void brcmf_fweh_attach(struct brcmf_pub *drvr);
void brcmf_fweh_detach(struct brcmf_pub *drvr);
int brcmf_fweh_register(struct brcmf_pub *drvr, enum brcmf_fweh_event_code code,
int (*handler)(struct brcmf_if *ifp,
const struct brcmf_event_msg *evtmsg,
void *data));
void brcmf_fweh_unregister(struct brcmf_pub *drvr,
enum brcmf_fweh_event_code code);
int brcmf_fweh_activate_events(struct brcmf_if *ifp);
void brcmf_fweh_process_event(struct brcmf_pub *drvr,
struct brcmf_event *event_packet, u8 *ifidx);
static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr,
struct sk_buff *skb, u8 *ifidx)
{
struct brcmf_event *event_packet;
u8 *data;
u16 usr_stype;
/* only process events when protocol matches */
if (skb->protocol != cpu_to_be16(ETH_P_LINK_CTL))
return;
/* check for BRCM oui match */
event_packet = (struct brcmf_event *)skb_mac_header(skb);
data = (u8 *)event_packet;
data += BRCMF_EVENT_OUI_OFFSET;
if (memcmp(BRCM_OUI, data, DOT11_OUI_LEN))
return;
/* final match on usr_subtype */
data += DOT11_OUI_LEN;
usr_stype = get_unaligned_be16(data);
if (usr_stype != BCMILCP_BCM_SUBTYPE_EVENT)
return;
brcmf_fweh_process_event(drvr, event_packet, ifidx);
}
#endif /* FWEH_H_ */
......@@ -226,25 +226,6 @@ struct brcmf_cfg80211_vif {
struct list_head list;
};
/* forward declaration */
struct brcmf_cfg80211_info;
/* cfg80211 main event loop */
struct brcmf_cfg80211_event_loop {
s32(*handler[BRCMF_E_LAST]) (struct brcmf_if *ifp,
const struct brcmf_event_msg *e,
void *data);
};
/* event queue for cfg80211 main event */
struct brcmf_cfg80211_event_q {
struct list_head evt_q_list;
u32 etype;
struct brcmf_if *ifp;
struct brcmf_event_msg emsg;
s8 edata[1];
};
/* association inform */
struct brcmf_cfg80211_connect_info {
u8 *req_ie;
......@@ -365,9 +346,6 @@ struct brcmf_pno_scanresults_le {
* @wiphy: wiphy object for cfg80211 interface.
* @conf: dongle configuration.
* @scan_request: cfg80211 scan request object.
* @el: main event loop.
* @evt_q_list: used for event queue.
* @evt_q_lock: for event queue synchronization.
* @usr_sync: mainly for dongle up/down synchronization.
* @bss_list: bss_list holding scanned ap information.
* @scan_req_int: internal scan request object.
......@@ -375,7 +353,6 @@ struct brcmf_pno_scanresults_le {
* @ie: information element object for internal purpose.
* @conn_info: association info.
* @pmk_list: wpa2 pmk list.
* @event_work: event handler work struct.
* @scan_status: scan activity on the dongle.
* @pub: common driver information.
* @channel: current channel.
......@@ -401,9 +378,6 @@ struct brcmf_cfg80211_info {
struct wiphy *wiphy;
struct brcmf_cfg80211_conf *conf;
struct cfg80211_scan_request *scan_request;
struct brcmf_cfg80211_event_loop el;
struct list_head evt_q_list;
spinlock_t evt_q_lock;
struct mutex usr_sync;
struct brcmf_scan_results *bss_list;
struct brcmf_cfg80211_scan_req scan_req_int;
......@@ -411,7 +385,6 @@ struct brcmf_cfg80211_info {
struct brcmf_cfg80211_ie ie;
struct brcmf_cfg80211_connect_info conn_info;
struct brcmf_cfg80211_pmk_list *pmk_list;
struct work_struct event_work;
unsigned long scan_status;
struct brcmf_pub *pub;
u32 channel;
......@@ -482,10 +455,6 @@ brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr);
void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
/* event handler from dongle */
void brcmf_cfg80211_event(struct brcmf_if *ifp, const struct brcmf_event_msg *e,
void *data);
s32 brcmf_cfg80211_up(struct brcmf_cfg80211_info *cfg);
s32 brcmf_cfg80211_down(struct brcmf_cfg80211_info *cfg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment