/drivers/staging/ath6kl/os/linux/ar6000_drv.c
C | 6260 lines | 4727 code | 967 blank | 566 comment | 955 complexity | ec75dce87d28aa6f7e4b128a4c77e336 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
Large files files are truncated, but you can click here to view the full file
- //------------------------------------------------------------------------------
- // Copyright (c) 2004-2010 Atheros Communications Inc.
- // All rights reserved.
- //
- //
- //
- // 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.
- //
- //
- //
- // Author(s): ="Atheros"
- //------------------------------------------------------------------------------
- /*
- * This driver is a pseudo ethernet driver to access the Atheros AR6000
- * WLAN Device
- */
- #include "ar6000_drv.h"
- #include "cfg80211.h"
- #include "htc.h"
- #include "wmi_filter_linux.h"
- #include "epping_test.h"
- #include "wlan_config.h"
- #include "ar3kconfig.h"
- #include "ar6k_pal.h"
- #include "AR6002/addrs.h"
- /* LINUX_HACK_FUDGE_FACTOR -- this is used to provide a workaround for linux behavior. When
- * the meta data was added to the header it was found that linux did not correctly provide
- * enough headroom. However when more headroom was requested beyond what was truly needed
- * Linux gave the requested headroom. Therefore to get the necessary headroom from Linux
- * the driver requests more than is needed by the amount = LINUX_HACK_FUDGE_FACTOR */
- #define LINUX_HACK_FUDGE_FACTOR 16
- #define BDATA_BDADDR_OFFSET 28
- u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
- u8 null_mac[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
- #ifdef DEBUG
- #define ATH_DEBUG_DBG_LOG ATH_DEBUG_MAKE_MODULE_MASK(0)
- #define ATH_DEBUG_WLAN_CONNECT ATH_DEBUG_MAKE_MODULE_MASK(1)
- #define ATH_DEBUG_WLAN_SCAN ATH_DEBUG_MAKE_MODULE_MASK(2)
- #define ATH_DEBUG_WLAN_TX ATH_DEBUG_MAKE_MODULE_MASK(3)
- #define ATH_DEBUG_WLAN_RX ATH_DEBUG_MAKE_MODULE_MASK(4)
- #define ATH_DEBUG_HTC_RAW ATH_DEBUG_MAKE_MODULE_MASK(5)
- #define ATH_DEBUG_HCI_BRIDGE ATH_DEBUG_MAKE_MODULE_MASK(6)
- static struct ath_debug_mask_description driver_debug_desc[] = {
- { ATH_DEBUG_DBG_LOG , "Target Debug Logs"},
- { ATH_DEBUG_WLAN_CONNECT , "WLAN connect"},
- { ATH_DEBUG_WLAN_SCAN , "WLAN scan"},
- { ATH_DEBUG_WLAN_TX , "WLAN Tx"},
- { ATH_DEBUG_WLAN_RX , "WLAN Rx"},
- { ATH_DEBUG_HTC_RAW , "HTC Raw IF tracing"},
- { ATH_DEBUG_HCI_BRIDGE , "HCI Bridge Setup"},
- { ATH_DEBUG_HCI_RECV , "HCI Recv tracing"},
- { ATH_DEBUG_HCI_DUMP , "HCI Packet dumps"},
- };
- ATH_DEBUG_INSTANTIATE_MODULE_VAR(driver,
- "driver",
- "Linux Driver Interface",
- ATH_DEBUG_MASK_DEFAULTS | ATH_DEBUG_WLAN_SCAN |
- ATH_DEBUG_HCI_BRIDGE,
- ATH_DEBUG_DESCRIPTION_COUNT(driver_debug_desc),
- driver_debug_desc);
- #endif
- #define IS_MAC_NULL(mac) (mac[0]==0 && mac[1]==0 && mac[2]==0 && mac[3]==0 && mac[4]==0 && mac[5]==0)
- #define IS_MAC_BCAST(mac) (*mac==0xff)
- #define DESCRIPTION "Driver to access the Atheros AR600x Device, version " __stringify(__VER_MAJOR_) "." __stringify(__VER_MINOR_) "." __stringify(__VER_PATCH_) "." __stringify(__BUILD_NUMBER_)
- MODULE_AUTHOR("Atheros Communications, Inc.");
- MODULE_DESCRIPTION(DESCRIPTION);
- MODULE_LICENSE("Dual BSD/GPL");
- #ifndef REORG_APTC_HEURISTICS
- #undef ADAPTIVE_POWER_THROUGHPUT_CONTROL
- #endif /* REORG_APTC_HEURISTICS */
- #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
- #define APTC_TRAFFIC_SAMPLING_INTERVAL 100 /* msec */
- #define APTC_UPPER_THROUGHPUT_THRESHOLD 3000 /* Kbps */
- #define APTC_LOWER_THROUGHPUT_THRESHOLD 2000 /* Kbps */
- typedef struct aptc_traffic_record {
- bool timerScheduled;
- struct timeval samplingTS;
- unsigned long bytesReceived;
- unsigned long bytesTransmitted;
- } APTC_TRAFFIC_RECORD;
- A_TIMER aptcTimer;
- APTC_TRAFFIC_RECORD aptcTR;
- #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
- #ifdef EXPORT_HCI_BRIDGE_INTERFACE
- // callbacks registered by HCI transport driver
- struct hci_transport_callbacks ar6kHciTransCallbacks = { NULL };
- #endif
- unsigned int processDot11Hdr = 0;
- char ifname[IFNAMSIZ] = {0,};
- int wlaninitmode = WLAN_INIT_MODE_DEFAULT;
- static bool bypasswmi;
- unsigned int debuglevel = 0;
- int tspecCompliance = ATHEROS_COMPLIANCE;
- unsigned int busspeedlow = 0;
- unsigned int onebitmode = 0;
- unsigned int skipflash = 0;
- unsigned int wmitimeout = 2;
- unsigned int wlanNodeCaching = 1;
- unsigned int enableuartprint = ENABLEUARTPRINT_DEFAULT;
- unsigned int logWmiRawMsgs = 0;
- unsigned int enabletimerwar = 0;
- unsigned int num_device = 1;
- unsigned int regscanmode;
- unsigned int fwmode = 1;
- unsigned int mbox_yield_limit = 99;
- unsigned int enablerssicompensation = 0;
- int reduce_credit_dribble = 1 + HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_HALF;
- int allow_trace_signal = 0;
- #ifdef CONFIG_HOST_TCMD_SUPPORT
- unsigned int testmode =0;
- #endif
- unsigned int irqprocmode = HIF_DEVICE_IRQ_SYNC_ONLY;//HIF_DEVICE_IRQ_ASYNC_SYNC;
- unsigned int panic_on_assert = 1;
- unsigned int nohifscattersupport = NOHIFSCATTERSUPPORT_DEFAULT;
- unsigned int setuphci = SETUPHCI_DEFAULT;
- unsigned int loghci = 0;
- unsigned int setupbtdev = SETUPBTDEV_DEFAULT;
- #ifndef EXPORT_HCI_BRIDGE_INTERFACE
- unsigned int ar3khcibaud = AR3KHCIBAUD_DEFAULT;
- unsigned int hciuartscale = HCIUARTSCALE_DEFAULT;
- unsigned int hciuartstep = HCIUARTSTEP_DEFAULT;
- #endif
- unsigned int csumOffload=0;
- unsigned int csumOffloadTest=0;
- unsigned int eppingtest=0;
- unsigned int mac_addr_method;
- unsigned int firmware_bridge;
- module_param_string(ifname, ifname, sizeof(ifname), 0644);
- module_param(wlaninitmode, int, 0644);
- module_param(bypasswmi, bool, 0644);
- module_param(debuglevel, uint, 0644);
- module_param(tspecCompliance, int, 0644);
- module_param(onebitmode, uint, 0644);
- module_param(busspeedlow, uint, 0644);
- module_param(skipflash, uint, 0644);
- module_param(wmitimeout, uint, 0644);
- module_param(wlanNodeCaching, uint, 0644);
- module_param(logWmiRawMsgs, uint, 0644);
- module_param(enableuartprint, uint, 0644);
- module_param(enabletimerwar, uint, 0644);
- module_param(fwmode, uint, 0644);
- module_param(mbox_yield_limit, uint, 0644);
- module_param(reduce_credit_dribble, int, 0644);
- module_param(allow_trace_signal, int, 0644);
- module_param(enablerssicompensation, uint, 0644);
- module_param(processDot11Hdr, uint, 0644);
- module_param(csumOffload, uint, 0644);
- #ifdef CONFIG_HOST_TCMD_SUPPORT
- module_param(testmode, uint, 0644);
- #endif
- module_param(irqprocmode, uint, 0644);
- module_param(nohifscattersupport, uint, 0644);
- module_param(panic_on_assert, uint, 0644);
- module_param(setuphci, uint, 0644);
- module_param(loghci, uint, 0644);
- module_param(setupbtdev, uint, 0644);
- #ifndef EXPORT_HCI_BRIDGE_INTERFACE
- module_param(ar3khcibaud, uint, 0644);
- module_param(hciuartscale, uint, 0644);
- module_param(hciuartstep, uint, 0644);
- #endif
- module_param(eppingtest, uint, 0644);
- /* in 2.6.10 and later this is now a pointer to a uint */
- unsigned int _mboxnum = HTC_MAILBOX_NUM_MAX;
- #define mboxnum &_mboxnum
- #ifdef DEBUG
- u32 g_dbg_flags = DBG_DEFAULTS;
- unsigned int debugflags = 0;
- int debugdriver = 0;
- unsigned int debughtc = 0;
- unsigned int debugbmi = 0;
- unsigned int debughif = 0;
- unsigned int txcreditsavailable[HTC_MAILBOX_NUM_MAX] = {0};
- unsigned int txcreditsconsumed[HTC_MAILBOX_NUM_MAX] = {0};
- unsigned int txcreditintrenable[HTC_MAILBOX_NUM_MAX] = {0};
- unsigned int txcreditintrenableaggregate[HTC_MAILBOX_NUM_MAX] = {0};
- module_param(debugflags, uint, 0644);
- module_param(debugdriver, int, 0644);
- module_param(debughtc, uint, 0644);
- module_param(debugbmi, uint, 0644);
- module_param(debughif, uint, 0644);
- module_param_array(txcreditsavailable, uint, mboxnum, 0644);
- module_param_array(txcreditsconsumed, uint, mboxnum, 0644);
- module_param_array(txcreditintrenable, uint, mboxnum, 0644);
- module_param_array(txcreditintrenableaggregate, uint, mboxnum, 0644);
- #endif /* DEBUG */
- unsigned int resetok = 1;
- unsigned int tx_attempt[HTC_MAILBOX_NUM_MAX] = {0};
- unsigned int tx_post[HTC_MAILBOX_NUM_MAX] = {0};
- unsigned int tx_complete[HTC_MAILBOX_NUM_MAX] = {0};
- unsigned int hifBusRequestNumMax = 40;
- unsigned int war23838_disabled = 0;
- #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
- unsigned int enableAPTCHeuristics = 1;
- #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
- module_param_array(tx_attempt, uint, mboxnum, 0644);
- module_param_array(tx_post, uint, mboxnum, 0644);
- module_param_array(tx_complete, uint, mboxnum, 0644);
- module_param(hifBusRequestNumMax, uint, 0644);
- module_param(war23838_disabled, uint, 0644);
- module_param(resetok, uint, 0644);
- #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
- module_param(enableAPTCHeuristics, uint, 0644);
- #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
- #ifdef BLOCK_TX_PATH_FLAG
- int blocktx = 0;
- module_param(blocktx, int, 0644);