blob: 3921dcf8820c62446d69d1fb26363f7cb0bf1e09 [file] [log] [blame]
/*
* bcmevent read-only data shared by kernel or app layers
*
* Copyright 1999-2016, Broadcom Corporation
* All rights reserved,
*
* 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.
*
* This software is provided by the copyright holder "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 copyright holder 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
*
*
* <<Broadcom-WL-IPTag/Open:>>
*
* $Id: bcmevent.c 530174 2015-01-29 09:47:55Z $
*/
#include <typedefs.h>
#include <bcmutils.h>
#include <bcmendian.h>
#include <proto/ethernet.h>
#include <proto/bcmeth.h>
#include <proto/bcmevent.h>
/* Table of event name strings for UIs and debugging dumps */
typedef struct {
uint event;
const char *name;
} bcmevent_name_str_t;
/* Use the actual name for event tracing */
#define BCMEVENT_NAME(_event) {(_event), #_event}
static const bcmevent_name_str_t bcmevent_names[] = {
BCMEVENT_NAME(WLC_E_SET_SSID),
BCMEVENT_NAME(WLC_E_JOIN),
BCMEVENT_NAME(WLC_E_START),
BCMEVENT_NAME(WLC_E_AUTH),
BCMEVENT_NAME(WLC_E_AUTH_IND),
BCMEVENT_NAME(WLC_E_DEAUTH),
BCMEVENT_NAME(WLC_E_DEAUTH_IND),
BCMEVENT_NAME(WLC_E_ASSOC),
BCMEVENT_NAME(WLC_E_ASSOC_IND),
BCMEVENT_NAME(WLC_E_REASSOC),
BCMEVENT_NAME(WLC_E_REASSOC_IND),
BCMEVENT_NAME(WLC_E_DISASSOC),
BCMEVENT_NAME(WLC_E_DISASSOC_IND),
BCMEVENT_NAME(WLC_E_QUIET_START),
BCMEVENT_NAME(WLC_E_QUIET_END),
BCMEVENT_NAME(WLC_E_BEACON_RX),
BCMEVENT_NAME(WLC_E_LINK),
BCMEVENT_NAME(WLC_E_MIC_ERROR),
BCMEVENT_NAME(WLC_E_NDIS_LINK),
BCMEVENT_NAME(WLC_E_ROAM),
BCMEVENT_NAME(WLC_E_TXFAIL),
BCMEVENT_NAME(WLC_E_PMKID_CACHE),
BCMEVENT_NAME(WLC_E_RETROGRADE_TSF),
BCMEVENT_NAME(WLC_E_PRUNE),
BCMEVENT_NAME(WLC_E_AUTOAUTH),
BCMEVENT_NAME(WLC_E_EAPOL_MSG),
BCMEVENT_NAME(WLC_E_SCAN_COMPLETE),
BCMEVENT_NAME(WLC_E_ADDTS_IND),
BCMEVENT_NAME(WLC_E_DELTS_IND),
BCMEVENT_NAME(WLC_E_BCNSENT_IND),
BCMEVENT_NAME(WLC_E_BCNRX_MSG),
BCMEVENT_NAME(WLC_E_BCNLOST_MSG),
BCMEVENT_NAME(WLC_E_ROAM_PREP),
BCMEVENT_NAME(WLC_E_PFN_NET_FOUND),
BCMEVENT_NAME(WLC_E_PFN_SCAN_ALLGONE),
BCMEVENT_NAME(WLC_E_PFN_NET_LOST),
#if defined(IBSS_PEER_DISCOVERY_EVENT)
BCMEVENT_NAME(WLC_E_IBSS_ASSOC),
#endif /* defined(IBSS_PEER_DISCOVERY_EVENT) */
BCMEVENT_NAME(WLC_E_RADIO),
BCMEVENT_NAME(WLC_E_PSM_WATCHDOG),
BCMEVENT_NAME(WLC_E_PROBREQ_MSG),
BCMEVENT_NAME(WLC_E_SCAN_CONFIRM_IND),
BCMEVENT_NAME(WLC_E_PSK_SUP),
BCMEVENT_NAME(WLC_E_COUNTRY_CODE_CHANGED),
BCMEVENT_NAME(WLC_E_EXCEEDED_MEDIUM_TIME),
BCMEVENT_NAME(WLC_E_ICV_ERROR),
BCMEVENT_NAME(WLC_E_UNICAST_DECODE_ERROR),
BCMEVENT_NAME(WLC_E_MULTICAST_DECODE_ERROR),
BCMEVENT_NAME(WLC_E_TRACE),
#ifdef GWIFI_SUPPORT
BCMEVENT_NAME(WLC_E_MCS_METRIC_UPD),
#endif /* GWIFI_SUPPORT */
#ifdef WL_THERMAL_PROT_EVENT
BCMEVENT_NAME(WLC_E_THERMAL_PROT_EVENT),
#endif /* WL_THERMAL_PROT_EVENT */
BCMEVENT_NAME(WLC_E_IF),
#ifdef WLP2P
BCMEVENT_NAME(WLC_E_P2P_DISC_LISTEN_COMPLETE),
#endif
BCMEVENT_NAME(WLC_E_RSSI),
BCMEVENT_NAME(WLC_E_EXTLOG_MSG),
BCMEVENT_NAME(WLC_E_ACTION_FRAME),
BCMEVENT_NAME(WLC_E_ACTION_FRAME_RX),
BCMEVENT_NAME(WLC_E_ACTION_FRAME_COMPLETE),
BCMEVENT_NAME(WLC_E_ESCAN_RESULT),
BCMEVENT_NAME(WLC_E_ACTION_FRAME_OFF_CHAN_COMPLETE),
#ifdef WLP2P
BCMEVENT_NAME(WLC_E_PROBRESP_MSG),
BCMEVENT_NAME(WLC_E_P2P_PROBREQ_MSG),
#endif
#ifdef PROP_TXSTATUS
BCMEVENT_NAME(WLC_E_FIFO_CREDIT_MAP),
#endif
BCMEVENT_NAME(WLC_E_WAKE_EVENT),
BCMEVENT_NAME(WLC_E_DCS_REQUEST),
BCMEVENT_NAME(WLC_E_RM_COMPLETE),
#ifdef WLMEDIA_HTSF
BCMEVENT_NAME(WLC_E_HTSFSYNC),
#endif
BCMEVENT_NAME(WLC_E_OVERLAY_REQ),
BCMEVENT_NAME(WLC_E_CSA_COMPLETE_IND),
BCMEVENT_NAME(WLC_E_EXCESS_PM_WAKE_EVENT),
BCMEVENT_NAME(WLC_E_PFN_SCAN_NONE),
BCMEVENT_NAME(WLC_E_PFN_SCAN_ALLGONE),
#ifdef SOFTAP
BCMEVENT_NAME(WLC_E_GTK_PLUMBED),
#endif
BCMEVENT_NAME(WLC_E_WNM_REQ_IND),
BCMEVENT_NAME(WLC_E_ASSOC_REQ_IE),
BCMEVENT_NAME(WLC_E_ASSOC_RESP_IE),
BCMEVENT_NAME(WLC_E_BEACON_FRAME_RX),
#ifdef WLTDLS
BCMEVENT_NAME(WLC_E_TDLS_PEER_EVENT),
#endif /* WLTDLS */
BCMEVENT_NAME(WLC_E_NATIVE),
#ifdef WLPKTDLYSTAT
BCMEVENT_NAME(WLC_E_PKTDELAY_IND),
#endif /* WLPKTDLYSTAT */
BCMEVENT_NAME(WLC_E_SERVICE_FOUND),
BCMEVENT_NAME(WLC_E_GAS_FRAGMENT_RX),
BCMEVENT_NAME(WLC_E_GAS_COMPLETE),
BCMEVENT_NAME(WLC_E_P2PO_ADD_DEVICE),
BCMEVENT_NAME(WLC_E_P2PO_DEL_DEVICE),
#ifdef WLWNM
BCMEVENT_NAME(WLC_E_WNM_STA_SLEEP),
#endif /* WLWNM */
#if defined(WL_PROXDETECT)
BCMEVENT_NAME(WLC_E_PROXD),
#endif
BCMEVENT_NAME(WLC_E_CCA_CHAN_QUAL),
BCMEVENT_NAME(WLC_E_BSSID),
#ifdef PROP_TXSTATUS
BCMEVENT_NAME(WLC_E_BCMC_CREDIT_SUPPORT),
#endif
BCMEVENT_NAME(WLC_E_PSTA_PRIMARY_INTF_IND),
BCMEVENT_NAME(WLC_E_TXFAIL_THRESH),
#ifdef GSCAN_SUPPORT
BCMEVENT_NAME(WLC_E_PFN_GSCAN_FULL_RESULT),
BCMEVENT_NAME(WLC_E_PFN_SWC),
#endif /* GSCAN_SUPPORT */
#ifdef WLBSSLOAD_REPORT
BCMEVENT_NAME(WLC_E_BSS_LOAD),
#endif
#if defined(BT_WIFI_HANDOVER) || defined(WL_TBOW)
BCMEVENT_NAME(WLC_E_BT_WIFI_HANDOVER_REQ),
#endif
BCMEVENT_NAME(WLC_E_AUTHORIZED),
BCMEVENT_NAME(WLC_E_PROBREQ_MSG_RX),
BCMEVENT_NAME(WLC_E_CSA_START_IND),
BCMEVENT_NAME(WLC_E_CSA_DONE_IND),
BCMEVENT_NAME(WLC_E_CSA_FAILURE_IND),
BCMEVENT_NAME(WLC_E_RMC_EVENT),
BCMEVENT_NAME(WLC_E_DPSTA_INTF_IND),
};
const char *bcmevent_get_name(uint event_type)
{
/* note: first coded this as a static const but some
* ROMs already have something called event_name so
* changed it so we don't have a variable for the
* 'unknown string
*/
const char *event_name = NULL;
uint idx;
for (idx = 0; idx < (uint)ARRAYSIZE(bcmevent_names); idx++) {
if (bcmevent_names[idx].event == event_type) {
event_name = bcmevent_names[idx].name;
break;
}
}
/* if we find an event name in the array, return it.
* otherwise return unknown string.
*/
return ((event_name) ? event_name : "Unknown Event");
}
void
wl_event_to_host_order(wl_event_msg_t * evt)
{
/* Event struct members passed from dongle to host are stored in network
* byte order. Convert all members to host-order.
*/
evt->event_type = ntoh32(evt->event_type);
evt->flags = ntoh16(evt->flags);
evt->status = ntoh32(evt->status);
evt->reason = ntoh32(evt->reason);
evt->auth_type = ntoh32(evt->auth_type);
evt->datalen = ntoh32(evt->datalen);
evt->version = ntoh16(evt->version);
}
void
wl_event_to_network_order(wl_event_msg_t * evt)
{
/* Event struct members passed from dongle to host are stored in network
* byte order. Convert all members to host-order.
*/
evt->event_type = hton32(evt->event_type);
evt->flags = hton16(evt->flags);
evt->status = hton32(evt->status);
evt->reason = hton32(evt->reason);
evt->auth_type = hton32(evt->auth_type);
evt->datalen = hton32(evt->datalen);
evt->version = hton16(evt->version);
}