/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2009, Intel Corporation
* All rights reserved.
*/
/*
* Copyright (c) 2006
* Copyright (c) 2007
* Damien Bergamini <damien.bergamini@free.fr>
*
* Permission to use, copy, modify, and 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.
*/
/*
* Intel(R) WiFi Link 5100/5300 Driver
*/
#include <sys/byteorder.h>
#include <sys/ethernet.h>
#include <sys/mac_provider.h>
#include <sys/mac_wifi.h>
#include <sys/net80211.h>
#include <sys/net80211_proto.h>
#include <sys/net80211_ht.h>
#include "iwh_calibration.h"
#include "iwh_hw.h"
#include "iwh_eeprom.h"
#include "iwh_var.h"
#include <inet/wifi_ioctl.h>
#ifdef DEBUG
/*
* if want to see debug message of a given section,
* please set this flag to one of above values
*/
#define IWH_DBG(x) \
iwh_dbg x
#else
#define IWH_DBG(x)
#endif
/*
* ucode will be compiled into driver image
*/
#include "fw-iw/fw_5000/iwh_5000.ucode"
};
#include "fw-iw/fw_5150/iwh_5150.ucode"
};
/*
* DMA attributes for a shared page
*/
DMA_ATTR_V0, /* version of this structure */
0, /* lowest usable address */
0xffffffffU, /* highest usable address */
0xffffffffU, /* maximum DMAable byte count */
0x1000, /* alignment in bytes */
0x1000, /* burst sizes (any?) */
1, /* minimum transfer */
0xffffffffU, /* maximum transfer */
0xffffffffU, /* maximum segment length */
1, /* maximum number of segments */
1, /* granularity */
0, /* flags (reserved) */
};
/*
* DMA attributes for a keep warm DRAM descriptor
*/
DMA_ATTR_V0, /* version of this structure */
0, /* lowest usable address */
0xffffffffU, /* highest usable address */
0xffffffffU, /* maximum DMAable byte count */
0x1000, /* alignment in bytes */
0x1000, /* burst sizes (any?) */
1, /* minimum transfer */
0xffffffffU, /* maximum transfer */
0xffffffffU, /* maximum segment length */
1, /* maximum number of segments */
1, /* granularity */
0, /* flags (reserved) */
};
/*
* DMA attributes for a ring descriptor
*/
DMA_ATTR_V0, /* version of this structure */
0, /* lowest usable address */
0xffffffffU, /* highest usable address */
0xffffffffU, /* maximum DMAable byte count */
0x100, /* alignment in bytes */
0x100, /* burst sizes (any?) */
1, /* minimum transfer */
0xffffffffU, /* maximum transfer */
0xffffffffU, /* maximum segment length */
1, /* maximum number of segments */
1, /* granularity */
0, /* flags (reserved) */
};
/*
* DMA attributes for a cmd
*/
DMA_ATTR_V0, /* version of this structure */
0, /* lowest usable address */
0xffffffffU, /* highest usable address */
0xffffffffU, /* maximum DMAable byte count */
4, /* alignment in bytes */
0x100, /* burst sizes (any?) */
1, /* minimum transfer */
0xffffffffU, /* maximum transfer */
0xffffffffU, /* maximum segment length */
1, /* maximum number of segments */
1, /* granularity */
0, /* flags (reserved) */
};
/*
* DMA attributes for a rx buffer
*/
DMA_ATTR_V0, /* version of this structure */
0, /* lowest usable address */
0xffffffffU, /* highest usable address */
0xffffffffU, /* maximum DMAable byte count */
0x100, /* alignment in bytes */
0x100, /* burst sizes (any?) */
1, /* minimum transfer */
0xffffffffU, /* maximum transfer */
0xffffffffU, /* maximum segment length */
1, /* maximum number of segments */
1, /* granularity */
0, /* flags (reserved) */
};
/*
* DMA attributes for a tx buffer.
* the maximum number of segments is 4 for the hardware.
* now all the wifi drivers put the whole frame in a single
* descriptor, so we define the maximum number of segments 1,
* just the same as the rx_buffer. we consider leverage the HW
* ability in the future, that is why we don't define rx and tx
* buffer_dma_attr as the same.
*/
DMA_ATTR_V0, /* version of this structure */
0, /* lowest usable address */
0xffffffffU, /* highest usable address */
0xffffffffU, /* maximum DMAable byte count */
4, /* alignment in bytes */
0x100, /* burst sizes (any?) */
1, /* minimum transfer */
0xffffffffU, /* maximum transfer */
0xffffffffU, /* maximum segment length */
1, /* maximum number of segments */
1, /* granularity */
0, /* flags (reserved) */
};
/*
* DMA attributes for text and data part in the firmware
*/
DMA_ATTR_V0, /* version of this structure */
0, /* lowest usable address */
0xffffffffU, /* highest usable address */
0x7fffffff, /* maximum DMAable byte count */
0x10, /* alignment in bytes */
0x100, /* burst sizes (any?) */
1, /* minimum transfer */
0xffffffffU, /* maximum transfer */
0xffffffffU, /* maximum segment length */
1, /* maximum number of segments */
1, /* granularity */
0, /* flags (reserved) */
};
/*
* regs access attributes
*/
};
/*
* DMA access attributes for descriptor
*/
};
/*
* DMA access attributes
*/
};
static int iwh_ring_init(iwh_sc_t *);
static void iwh_ring_free(iwh_sc_t *);
static int iwh_alloc_shared(iwh_sc_t *);
static void iwh_free_shared(iwh_sc_t *);
static int iwh_alloc_kw(iwh_sc_t *);
static void iwh_free_kw(iwh_sc_t *);
static int iwh_alloc_fw_dma(iwh_sc_t *);
static void iwh_free_fw_dma(iwh_sc_t *);
static int iwh_alloc_rx_ring(iwh_sc_t *);
static void iwh_reset_rx_ring(iwh_sc_t *);
static void iwh_free_rx_ring(iwh_sc_t *);
int, int);
static void iwh_free_tx_ring(iwh_tx_ring_t *);
static void iwh_node_free(ieee80211_node_t *);
static void iwh_mac_access_enter(iwh_sc_t *);
static void iwh_mac_access_exit(iwh_sc_t *);
static int iwh_load_init_firmware(iwh_sc_t *);
static int iwh_load_run_firmware(iwh_sc_t *);
static int iwh_eep_load(iwh_sc_t *);
static void iwh_get_mac_from_eep(iwh_sc_t *);
static int iwh_eep_sem_down(iwh_sc_t *);
static void iwh_eep_sem_up(iwh_sc_t *);
static uint8_t iwh_rate_to_plcp(int);
static int iwh_hw_set_before_auth(iwh_sc_t *);
static int iwh_config(iwh_sc_t *);
static void iwh_stop_master(iwh_sc_t *);
static int iwh_power_up(iwh_sc_t *);
static int iwh_preinit(iwh_sc_t *);
static int iwh_quiesce(dev_info_t *t);
static void iwh_amrr_init(iwh_amrr_t *);
static void iwh_amrr_timeout(iwh_sc_t *);
static void iwh_amrr_ratectl(void *, ieee80211_node_t *);
static void iwh_release_calib_buffer(iwh_sc_t *);
static int iwh_init_common(iwh_sc_t *);
static int iwh_alive_common(iwh_sc_t *);
static int iwh_tx_power_table(iwh_sc_t *, int);
static void iwh_destroy_locks(iwh_sc_t *);
static void iwh_thread(iwh_sc_t *);
static int iwh_run_state_config(iwh_sc_t *);
static int iwh_fast_recover(iwh_sc_t *);
static int iwh_wme_update(ieee80211com_t *);
static int iwh_qosparam_to_hw(iwh_sc_t *, int);
static int iwh_wme_to_qos_ac(int);
static int iwh_wmeparam_check(struct wmeParams *);
static inline int iwh_wme_tid_qos_ac(int);
static inline int iwh_qos_ac_to_txq(int);
static int iwh_wme_tid_to_txq(int);
static void iwh_init_ht_conf(iwh_sc_t *);
static void iwh_overwrite_11n_rateset(iwh_sc_t *);
static void iwh_overwrite_ic_default(iwh_sc_t *);
static void iwh_config_rxon_chain(iwh_sc_t *);
static int iwh_add_ap_sta(iwh_sc_t *);
static void iwh_recv_action(struct ieee80211_node *,
static int iwh_send_action(struct ieee80211_node *,
int, int, uint16_t[4]);
static int iwh_is_max_rate(ieee80211_node_t *);
static int iwh_is_min_rate(ieee80211_node_t *);
static void iwh_increase_rate(ieee80211_node_t *);
static void iwh_decrease_rate(ieee80211_node_t *);
static void iwh_free_dma_mem(iwh_dma_t *);
static int iwh_reset_hw(iwh_sc_t *);
/*
* GLD specific operations
*/
static int iwh_m_start(void *);
static void iwh_m_stop(void *);
static int iwh_m_unicst(void *, const uint8_t *);
static int iwh_m_promisc(void *, boolean_t);
void *wldp_buf);
/*
* Supported rates for 802.11b/g modes (in 500Kbps unit).
*/
{ 4, { 2, 4, 11, 22 } };
{ 12, { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 } };
/*
* Default 11n reates supported by this station.
*/
extern struct ieee80211_htrateset ieee80211_rateset_11n;
/*
* For mfthread only
*/
extern pri_t minclsyspri;
/*
* Module Loading Data & Entry Points
*/
"Intel(R) ShirleyPeak/EchoPeak driver(N)",
};
};
int
_init(void)
{
int status;
sizeof (iwh_sc_t), 1);
if (status != DDI_SUCCESS) {
return (status);
}
if (status != DDI_SUCCESS) {
}
return (status);
}
int
_fini(void)
{
int status;
if (DDI_SUCCESS == status) {
}
return (status);
}
int
{
}
/*
* Mac Call Back entries
*/
NULL,
NULL,
NULL,
NULL,
};
#ifdef DEBUG
void
{
if (flags & iwh_dbg_flags) {
}
}
#endif /* DEBUG */
/*
* device operations
*/
int
{
int instance, i;
int intr_type;
int intr_count;
int intr_actual;
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
instance);
}
"resume\n"));
return (DDI_SUCCESS);
default:
goto attach_fail1;
}
if (err != DDI_SUCCESS) {
"failed to allocate soft state\n");
goto attach_fail1;
}
/*
* map configure space
*/
if (err != DDI_SUCCESS) {
"failed to map config spaces regs\n");
goto attach_fail2;
}
"Do not support this device\n");
goto attach_fail3;
}
/*
* keep from disturbing C3 state of CPU
*/
PCI_CFG_RETRY_TIMEOUT), 0);
/*
* determine the size of buffer for frame and command to ucode
*/
}
/*
* Map operating registers
*/
if (err != DDI_SUCCESS) {
"failed to map device regs\n");
goto attach_fail3;
}
/*
* this is used to differentiate type of hardware
*/
"fixed type interrupt is not supported\n");
goto attach_fail4;
}
"no fixed interrupts\n");
goto attach_fail4;
}
intr_count, &intr_actual, 0);
"ddi_intr_alloc() failed 0x%x\n", err);
goto attach_fail5;
}
if (err != DDI_SUCCESS) {
"ddi_intr_get_pri() failed 0x%x\n", err);
goto attach_fail6;
}
/*
* initialize the mfthread
*/
sc->sc_mf_thread_switch = 0;
/*
* Allocate shared buffer for communication between driver and ucode.
*/
if (err != DDI_SUCCESS) {
"failed to allocate shared page\n");
goto attach_fail7;
}
/*
* Allocate keep warm page.
*/
if (err != DDI_SUCCESS) {
"failed to allocate keep warm page\n");
goto attach_fail8;
}
if (err != IWH_SUCCESS) {
"failed to reset hardware\n");
goto attach_fail9;
}
/*
* Do some necessary hardware initializations.
*/
if (err != IWH_SUCCESS) {
"failed to initialize hardware\n");
goto attach_fail9;
}
/*
* get hardware configurations from eeprom
*/
if (err != IWH_SUCCESS) {
"failed to load eeprom\n");
goto attach_fail9;
}
"unsupported eeprom detected\n"));
goto attach_fail9;
}
/*
* get MAC address of this chipset
*/
/*
* calibration information from EEPROM
*/
/*
* initialize TX and RX ring buffers
*/
if (err != DDI_SUCCESS) {
"failed to allocate and initialize ring\n");
goto attach_fail9;
}
} else {
}
/*
* copy ucode to dma buffer
*/
if (err != DDI_SUCCESS) {
"failed to allocate firmware dma\n");
goto attach_fail10;
}
/*
* Initialize the wifi part, which will be used by
* 802.11 module
*/
/*
*/
/*
*/
/*
*/
}
/*
* set supported .11b and .11g rates
*/
/*
* set supported .11b and .11g channels (1 through 11)
*/
for (i = 1; i <= 11; i++) {
} else {
}
}
/*
* attach to 802.11 module
*/
/*
* different instance has different WPA door
*/
/*
* Overwrite 80211 default configurations.
*/
/*
* initialize 802.11 module
*/
/*
* initialize default tx key
*/
ic->ic_def_txkey = 0;
if (err != DDI_SUCCESS) {
"add soft interrupt failed\n");
goto attach_fail12;
}
if (err != DDI_SUCCESS) {
"ddi_intr_add_handle() failed\n");
goto attach_fail13;
}
if (err != DDI_SUCCESS) {
"ddi_intr_enable() failed\n");
goto attach_fail14;
}
/*
* Initialize pointer to device specific functions
*/
/*
* create relation to GLD
*/
"failed to do mac_alloc()\n");
goto attach_fail15;
}
/*
* Register the macp to mac
*/
if (err != DDI_SUCCESS) {
"failed to do mac_register()\n");
goto attach_fail15;
}
/*
* Create minor node of type DDI_NT_NET_WIFI
*/
if (err != DDI_SUCCESS) {
"failed to do ddi_create_minor_node()\n");
}
/*
* Notify link is down now
*/
/*
* create the mf thread to handle the link status,
* recovery fatal error, etc.
*/
}
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
int
{
int err;
switch (cmd) {
case DDI_DETACH:
break;
case DDI_SUSPEND:
}
"suspend\n"));
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
/*
* Destroy the mf_thread
*/
sc->sc_mf_thread_switch = 0;
break;
}
}
if (err != DDI_SUCCESS) {
return (err);
}
/*
* stop chipset
*/
DELAY(500000);
/*
* release buffer for calibration
*/
/*
* Unregiste from GLD
*/
/*
* detach from 80211 module
*/
return (DDI_SUCCESS);
}
/*
* destroy all locks
*/
static void
{
}
/*
* Allocate an area of memory and a DMA handle for accessing it
*/
static int
{
/*
* Allocate handle
*/
if (err != DDI_SUCCESS) {
return (DDI_FAILURE);
}
/*
* Allocate memory
*/
if (err != DDI_SUCCESS) {
return (DDI_FAILURE);
}
/*
* Bind the two together
*/
if (err != DDI_DMA_MAPPED) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* Free one allocated area of DMAable memory
*/
static void
{
}
}
}
}
/*
* copy ucode into dma buffers
*/
static int
{
char *t;
/*
* firmware image layout:
* |HDR|<-TEXT->|<-DATA->|<-INIT_TEXT->|<-INIT_DATA->|<-BOOT->|
*/
/*
* copy text of runtime ucode
*/
&sc->sc_dma_fw_text);
if (err != DDI_SUCCESS) {
"failed to allocate text dma memory.\n");
goto fail;
}
"text[ncookies:%d addr:%lx size:%lx]\n",
/*
* copy data and bak-data of runtime ucode
*/
&sc->sc_dma_fw_data);
if (err != DDI_SUCCESS) {
"failed to allocate data dma memory\n");
goto fail;
}
"data[ncookies:%d addr:%lx size:%lx]\n",
&sc->sc_dma_fw_data_bak);
if (err != DDI_SUCCESS) {
"failed to allocate data bakup dma memory\n");
goto fail;
}
"data_bak[ncookies:%d addr:%lx "
"size:%lx]\n",
/*
* copy text of init ucode
*/
if (err != DDI_SUCCESS) {
"failed to allocate init text dma memory\n");
goto fail;
}
"init_text[ncookies:%d addr:%lx "
"size:%lx]\n",
/*
* copy data of init ucode
*/
if (err != DDI_SUCCESS) {
"failed to allocate init data dma memory\n");
goto fail;
}
"init_data[ncookies:%d addr:%lx "
"size:%lx]\n",
fail:
return (err);
}
static void
{
}
/*
* Allocate a shared buffer between host and NIC.
*/
static int
{
#ifdef DEBUG
#endif
/*
* must be aligned on a 4K-page boundary
*/
if (err != DDI_SUCCESS) {
goto fail;
}
#ifdef DEBUG
#endif
"sh[ncookies:%d addr:%lx size:%lx]\n",
return (err);
fail:
return (err);
}
static void
{
}
/*
* Allocate a keep warm page.
*/
static int
{
#ifdef DEBUG
#endif
/*
* must be aligned on a 4K-page boundary
*/
if (err != DDI_SUCCESS) {
goto fail;
}
#ifdef DEBUG
#endif
"kw[ncookies:%d addr:%lx size:%lx]\n",
return (err);
fail:
return (err);
}
static void
{
}
/*
* initialize RX ring buffers
*/
static int
{
#ifdef DEBUG
#endif
/*
* allocate RX description ring buffer
*/
if (err != DDI_SUCCESS) {
"dma alloc rx ring desc "
"failed\n"));
goto fail;
}
#ifdef DEBUG
#endif
"rx bd[ncookies:%d addr:%lx size:%lx]\n",
/*
* Allocate Rx frame buffers.
*/
for (i = 0; i < RX_QUEUE_SIZE; i++) {
if (err != DDI_SUCCESS) {
"dma alloc rx ring "
"buf[%d] failed\n", i));
goto fail;
}
/*
* the physical address bit [8-36] are used,
* instead of bit [0-31] in 3945.
*/
}
#ifdef DEBUG
#endif
"rx buffer[0][ncookies:%d addr:%lx "
"size:%lx]\n",
return (err);
fail:
return (err);
}
/*
* disable RX ring
*/
static void
{
int n;
for (n = 0; n < 2000; n++) {
break;
}
DELAY(1000);
}
#ifdef DEBUG
if (2000 == n) {
"timeout resetting Rx ring\n"));
}
#endif
}
static void
{
int i;
for (i = 0; i < RX_QUEUE_SIZE; i++) {
}
}
}
}
/*
* initialize TX ring buffers
*/
static int
{
#ifdef DEBUG
#endif
/*
* allocate buffer for TX descriptor ring
*/
TFD_QUEUE_SIZE_MAX * sizeof (iwh_tx_desc_t),
if (err != DDI_SUCCESS) {
"dma alloc tx ring desc[%d] "
"failed\n", qid));
goto fail;
}
#ifdef DEBUG
#endif
"tx bd[ncookies:%d addr:%lx size:%lx]\n",
/*
* allocate buffer for ucode command
*/
TFD_QUEUE_SIZE_MAX * sizeof (iwh_cmd_t),
if (err != DDI_SUCCESS) {
"dma alloc tx ring cmd[%d]"
" failed\n", qid));
goto fail;
}
#ifdef DEBUG
#endif
"tx cmd[ncookies:%d addr:%lx size:%lx]\n",
/*
* Allocate Tx frame buffers.
*/
"could not allocate "
"tx data slots\n"));
goto fail;
}
for (i = 0; i < TFD_QUEUE_SIZE_MAX; i++) {
if (err != DDI_SUCCESS) {
"dma alloc tx "
"ring buf[%d] failed\n", i));
goto fail;
}
}
#ifdef DEBUG
#endif
"tx buffer[0][ncookies:%d addr:%lx "
"size:%lx]\n",
return (err);
fail:
return (err);
}
/*
* disable TX ring
*/
static void
{
int i, n;
for (n = 0; n < 200; n++) {
break;
}
DELAY(10);
}
#ifdef DEBUG
if (200 == n) {
"timeout reset tx ring %d\n",
}
#endif
/*
* by pass, if it's quiesce
*/
}
}
}
static void
{
int i;
}
}
}
}
}
}
/*
* initialize TX and RX ring
*/
static int
{
for (i = 0; i < IWH_NUM_QUEUES; i++) {
if (IWH_CMD_QUEUE_NUM == i) {
continue;
}
i);
if (err != DDI_SUCCESS) {
goto fail;
}
}
/*
* initialize command queue
*/
if (err != DDI_SUCCESS) {
goto fail;
}
if (err != DDI_SUCCESS) {
goto fail;
}
fail:
return (err);
}
static void
{
int i = IWH_NUM_QUEUES;
while (--i >= 0) {
}
}
/* ARGSUSED */
static ieee80211_node_t *
{
"failed to allocate memory for amrr structure\n");
return (NULL);
}
}
static void
{
"Got a NULL point from Net80211 module\n");
return;
}
}
}
}
}
}
/*
* change station's state. this function will be invoked by 80211 module
* when need to change staton's state.
*/
static int
{
uint8_t r;
return (err);
}
switch (nstate) {
case IEEE80211_S_SCAN:
switch (ostate) {
case IEEE80211_S_INIT:
/*
* clear association to receive beacons from
* all BSS'es
*/
"config chan %d "
"flags %x filter_flags %x\n",
sizeof (iwh_rxon_cmd_t), 1);
if (err != IWH_SUCCESS) {
"could not clear association\n");
return (err);
}
/*
* add broadcast node to send probe request
*/
sizeof (node), 1);
if (err != IWH_SUCCESS) {
"could not add broadcast node\n");
return (err);
}
break;
case IEEE80211_S_SCAN:
/* step to next channel before actual FW scan */
"could not initiate scan\n");
}
return (err);
default:
break;
}
break;
case IEEE80211_S_AUTH:
if (ostate == IEEE80211_S_SCAN) {
}
/*
* reset state to handle reassociations correctly
*/
/*
* before sending authentication and association request frame,
* we need do something in the hardware, such as setting the
* channel same to the target AP...
*/
"could not send authentication request\n"));
return (err);
}
break;
case IEEE80211_S_RUN:
if (ostate == IEEE80211_S_SCAN) {
}
/*
* let LED blink when monitoring
*/
break;
}
"associated.\n"));
if (err != IWH_SUCCESS) {
"failed to set up association\n");
return (err);
}
/*
* start automatic rate control
*/
if ((r != 0) && (r <= 0xd) &&
(1 << (r%8)))) {
amrr->ht_mcs_idx = r;
break;
}
}
} else {
/*
* set rate to some reasonable initial value
*/
while (i > 0 && IEEE80211_RATE(i) > 72) {
i--;
}
} else {
}
}
/*
* set LED on after associated
*/
break;
case IEEE80211_S_INIT:
if (ostate == IEEE80211_S_SCAN) {
}
/*
* set LED off after init
*/
break;
case IEEE80211_S_ASSOC:
if (ostate == IEEE80211_S_SCAN) {
}
break;
}
}
/*
* exclusive access to mac begin.
*/
static void
{
int n;
/*
* wait until we succeed
*/
for (n = 0; n < 1000; n++) {
break;
}
DELAY(10);
}
#ifdef DEBUG
if (1000 == n) {
"could not lock memory\n"));
}
#endif
}
/*
* exclusive access to mac end.
*/
static void
{
}
/*
* this function defined here for future use.
* static uint32_t
* iwh_mem_read(iwh_sc_t *sc, uint32_t addr)
* {
* IWH_WRITE(sc, HBUS_TARG_MEM_RADDR, addr);
* return (IWH_READ(sc, HBUS_TARG_MEM_RDAT));
* }
*/
/*
* write mac memory
*/
static void
{
}
/*
* read mac register
*/
static uint32_t
{
}
/*
* write mac register
*/
static void
{
}
/*
* steps of loading ucode:
* load init ucode=>init alive=>calibrate=>
* receive calibration result=>reinitialize NIC=>
* load runtime ucode=>runtime alive=>
* send calibration result=>running.
*/
static int
{
/*
* load init_text section of uCode to hardware
*/
if (err != IWH_SUCCESS) {
"failed to write init uCode.\n");
return (err);
}
/*
* wait loading init_text until completed or timeout
*/
break;
}
}
"timeout waiting for init uCode load.\n");
return (IWH_FAIL);
}
/*
* load init_data section of uCode to hardware
*/
if (err != IWH_SUCCESS) {
"failed to write init_data uCode.\n");
return (err);
}
/*
* wait loading init_data until completed or timeout
*/
break;
}
}
"timeout waiting for init_data uCode load.\n");
return (IWH_FAIL);
}
return (err);
}
static int
{
/*
* load init_text section of uCode to hardware
*/
if (err != IWH_SUCCESS) {
"failed to write run uCode.\n");
return (err);
}
/*
* wait loading run_text until completed or timeout
*/
break;
}
}
"timeout waiting for run uCode load.\n");
return (IWH_FAIL);
}
/*
* load run_data section of uCode to hardware
*/
if (err != IWH_SUCCESS) {
"failed to write run_data uCode.\n");
return (err);
}
/*
* wait loading run_data until completed or timeout
*/
break;
}
}
"timeout waiting for run_data uCode load.\n");
return (IWH_FAIL);
}
return (err);
}
/*
* this function will be invoked to receive phy information
* when a frame is received.
*/
static void
{
sizeof (iwh_rx_phy_res_t));
}
/*
* this function will be invoked to receive body of frame when
* a frame is received.
*/
static void
{
#ifdef DEBUG
#endif
int16_t t;
/*
* assuming not 11n here. cope with 11n in phase-II
*/
return;
}
/*
* convert dBm to percentage
*/
/ (75 * 75);
if (rssi > 100) {
rssi = 100;
}
if (rssi < 1) {
rssi = 1;
}
/*
* size of frame, not include FCS
*/
sizeof (struct iwh_rx_mpdu_body_size) + len);
"rx intr: idx=%d phy_len=%x len=%d "
"rate=%x chan=%d tstamp=%x non_cfg_phy_count=%x "
"rx frame oversize\n"));
return;
}
/*
* discard Rx frames with bad CRC
*/
"rx crc error tail: %x\n",
return;
}
wh = (struct ieee80211_frame *)
"rx : association id = %x\n",
sc->sc_assoc_id));
}
#ifdef DEBUG
if (iwh_dbg_flags & IWH_DEBUG_RX) {
}
#endif
if (mp) {
/*
* send the frame to the 802.11 layer
*/
} else {
sc->sc_rx_nobuf++;
"alloc rx buf failed\n"));
}
/*
* release node reference
*/
}
/*
* process correlative affairs after a frame is sent.
*/
static void
{
return;
}
sc->sc_tx_retries++;
"tx: %d retries\n",
sc->sc_tx_retries));
}
sc->sc_tx_timer = 0;
}
sc->sc_need_reschedule = 0;
}
}
/*
* inform a given command has been executed
*/
static void
{
return;
}
if (sc->sc_cmd_accum > 0) {
sc->sc_cmd_accum--;
return;
}
"qid=%x idx=%d flags=%x type=0x%x\n",
}
/*
* this function will be invoked when alive notification occur.
*/
static void
{
/*
* the microcontroller is ready
*/
"microcode alive notification minor: %x major: %x type: "
"%x subtype: %x\n",
#ifdef DEBUG
"microcontroller initialization failed\n"));
}
#endif
/*
* determine if init alive or runtime alive.
*/
"initialization alive received.\n"));
sizeof (struct iwh_init_alive_resp));
/*
* necessary configuration to NIC
*/
if (rv != IWH_SUCCESS) {
"common alive process failed in init alive.\n");
return;
}
/*
* require ucode execute calibration
*/
if (rv != IWH_SUCCESS) {
"failed to send calibration configure command.\n");
return;
}
} else { /* runtime alive */
"runtime alive received.\n"));
sizeof (struct iwh_alive_resp));
/*
* necessary configuration to NIC
*/
if (rv != IWH_SUCCESS) {
"common alive process failed in run alive.\n");
return;
}
/*
* send the result of local oscilator calibration to uCode.
*/
if (rv != IWH_SUCCESS) {
"failed to send local"
"oscilator calibration command.\n");
return;
}
DELAY(1000);
}
/*
* send the result of TX IQ calibration to uCode.
*/
if (rv != IWH_SUCCESS) {
"failed to send TX IQ"
"calibration command.\n");
return;
}
DELAY(1000);
}
/*
* sned the result of TX IQ perd calibration to uCode.
*/
if (rv != IWH_SUCCESS) {
"failed to send TX IQ perd"
"calibration command.\n");
return;
}
DELAY(1000);
}
/*
* send the result of DC calibration to uCode.
*/
if (rv != IWH_SUCCESS) {
"failed to send DC"
"calibration command.\n");
return;
}
DELAY(1000);
}
/*
* send the result of BASE BAND calibration to uCode.
*/
if (rv != IWH_SUCCESS) {
"failed to send BASE BAND"
"calibration command.\n");
return;
}
DELAY(1000);
}
}
}
/*
* deal with receiving frames, command response
* and all notifications from ucode.
*/
/* ARGSUSED */
static uint_t
{
return (DDI_INTR_UNCLAIMED);
}
/*
* firmware has moved the index of the rx queue, driver get it,
* and deal with it.
*/
"rx notification index = %d"
" cur = %d qid=%x idx=%d flags=%x type=%x len=%d\n",
/*
* a command other than a tx need to be replied
*/
}
case REPLY_RX_PHY_CMD:
break;
case REPLY_RX_MPDU_CMD:
break;
case REPLY_TX:
break;
case REPLY_ALIVE:
break;
case CARD_STATE_NOTIFICATION:
{
"state changed to %x\n",
/*
* the radio button has to be pushed(OFF). It
* is considered as a hw error, the
* iwh_thread() tries to recover it after the
* button is pushed again(ON)
*/
"radio transmitter is off\n");
IEEE80211_S_INIT, -1);
}
break;
}
case SCAN_START_NOTIFICATION:
{
"scanning channel %d status %x\n",
break;
}
{
#ifdef DEBUG
"completed channel %d (burst of %d) status %02x\n",
#endif
sc->sc_scan_pending++;
break;
}
case STATISTICS_NOTIFICATION:
{
/*
* handle statistics notification
*/
break;
}
break;
break;
/* handle beacon miss by software mechanism */
break;
}
}
/*
* driver dealt with what received in rx queue and tell the information
* to the firmware.
*/
/*
* re-enable interrupts
*/
return (DDI_INTR_CLAIMED);
}
/*
* the handle of interrupt
*/
/* ARGSUSED */
static uint_t
{
return (DDI_INTR_UNCLAIMED);
}
if (0 == r || 0xffffffff == r) {
return (DDI_INTR_UNCLAIMED);
}
"interrupt reg %x\n", r));
"FH interrupt reg %x\n", rfh));
/*
* disable interrupts
*/
/*
* ack interrupts
*/
if (r & (BIT_INT_SWERROR | BIT_INT_ERR)) {
"fatal firmware error\n"));
/*
* notify upper layer
*/
if (!IWH_CHK_FAST_RECOVER(sc)) {
}
return (DDI_INTR_CLAIMED);
}
if (r & BIT_INT_RF_KILL) {
}
}
if ((r & (BIT_INT_FH_RX | BIT_INT_SW_RX)) ||
(rfh & FH_INT_RX_MASK)) {
return (DDI_INTR_CLAIMED);
}
if (r & BIT_INT_FH_TX) {
}
#ifdef DEBUG
if (r & BIT_INT_ALIVE) {
"firmware initialized.\n"));
}
#endif
/*
* re-enable interrupts
*/
return (DDI_INTR_CLAIMED);
}
static uint8_t
{
switch (rate) {
/*
* CCK rates
*/
case 2:
ret = 0xa;
break;
case 4:
ret = 0x14;
break;
case 11:
ret = 0x37;
break;
case 22:
ret = 0x6e;
break;
/*
* OFDM rates
*/
case 12:
ret = 0xd;
break;
case 18:
ret = 0xf;
break;
case 24:
ret = 0x5;
break;
case 36:
ret = 0x7;
break;
case 48:
ret = 0x9;
break;
case 72:
ret = 0xb;
break;
case 96:
ret = 0x1;
break;
case 108:
ret = 0x3;
break;
default:
ret = 0;
break;
}
return (ret);
}
/*
* invoked by GLD send frames
*/
static mblk_t *
{
return (NULL);
}
return (NULL);
}
return (NULL);
}
"hold queue\n"));
return (mp);
}
break;
}
}
return (mp);
}
/*
* send frames
*/
static int
{
struct ieee80211_key *k = NULL;
return (IWH_FAIL);
}
if ((type & IEEE80211_FC0_TYPE_MASK) !=
}
goto exit;
}
return (IWH_FAIL);
}
/*
* Determine send which AP or station in IBSS
*/
"failed to find tx node\n");
err = IWH_SUCCESS;
goto exit;
}
/*
* Determine TX queue according to traffic ID in frame
* if working in QoS mode.
*/
if ((type & IEEE80211_FC0_TYPE_MASK) ==
if (txq_id < TXQ_FOR_AC_MIN ||
(txq_id > TXQ_FOR_AC_MAX)) {
err = IWH_SUCCESS;
goto exit;
}
} else {
}
} else if ((type & IEEE80211_FC0_TYPE_MASK) ==
} else {
}
} else {
}
/*
* Need reschedule TX if TX buffer is full.
*/
"no txbuf\n"));
if ((type & IEEE80211_FC0_TYPE_MASK) !=
}
sc->sc_tx_nobuf++;
goto exit;
}
if (NULL == m) { /* can not alloc buf, drop this package */
"failed to allocate msgbuf\n");
sc->sc_need_reschedule = 0;
}
err = IWH_SUCCESS;
goto exit;
}
}
/*
* Net80211 module encapsulate outbound data frames.
* Add some feilds of 80211 frame.
*/
if ((type & IEEE80211_FC0_TYPE_MASK) ==
}
} else {
}
k = ieee80211_crypto_encap(ic, m);
if (NULL == k) {
freemsg(m);
sc->sc_need_reschedule = 0;
}
err = IWH_SUCCESS;
goto exit;
}
/*
* packet header may have moved, reset our local pointer
*/
}
#ifdef DEBUG
if (iwh_dbg_flags & IWH_DEBUG_TX) {
}
#endif
/*
* specific TX parameters for management frames
*/
/*
* mgmt frames are sent at 1M
*/
IEEE80211_RATE_VAL) != 0) {
} else {
rate = 2;
}
/*
* tell h/w to set timestamp in probe responses
*/
}
}
} else {
}
} else {
/*
* do it here for the software way rate scaling.
* later for rate scaling in hardware.
*
* now the txrate is determined in tx cmd flags, set to the
* max value 54M for 11g and 11M for 11b and 96M for 11n
* originally.
*/
} else {
} else {
IEEE80211_RATE_VAL) != 0) {
}
}
}
if (tid != WME_TID_INVALID) {
} else {
}
}
"tx rate[%d of %d] = %x",
}
/*
* retrieve destination node's id
*/
} else {
}
if (rate >= HT_2CHAIN_RATE_MIN_IDX) {
} else {
}
} else {
}
}
"tx flag = %x",
tx->dram_lsb_ptr =
tx->dram_msb_ptr = 0;
tx->driver_txop = 0;
tx->next_frame_len = 0;
"sending data: qid=%d idx=%d len=%d",
/*
* first segment includes the tx cmd plus the 802.11 header,
* the second includes the remaining of the 802.11 frame.
*/
"phy addr1 = 0x%x phy addr2 = 0x%x "
"len1 = 0x%x, len2 = 0x%x val1 = 0x%x val2 = 0x%x",
/*
* kick ring
*/
}
freemsg(m);
/*
* release node reference
*/
if (0 == sc->sc_tx_timer) {
}
exit:
return (err);
}
/*
* invoked by GLD to deal with IOCTL affaires
*/
static void
{
return;
}
/*
* This is special for the hidden AP connection.
* In any case, we should make sure only one 'scan'
* in the driver for a 'connect' CLI command. So
* when connecting to a hidden AP, the scan is just
* sent out to the air when we know the desired
* essid of the AP we want to connect.
*/
if (ic->ic_des_esslen) {
iwh_m_stop(sc);
(void) iwh_m_start(sc);
(void) ieee80211_new_state(ic,
IEEE80211_S_SCAN, -1);
}
}
}
}
/*
*/
static int
{
return (EINVAL);
}
return (err);
}
static void
{
}
static int
{
return (EINVAL);
}
wldp_buf);
if (ic->ic_des_esslen) {
iwh_m_stop(sc);
(void) iwh_m_start(sc);
(void) ieee80211_new_state(ic,
IEEE80211_S_SCAN, -1);
}
}
err = 0;
}
return (err);
}
/*
* invoked by GLD supply statistics NIC and driver
*/
static int
{
return (EINVAL);
}
switch (stat) {
case MAC_STAT_IFSPEED:
break;
case MAC_STAT_NOXMTBUF:
break;
case MAC_STAT_NORCVBUF:
break;
case MAC_STAT_IERRORS:
break;
case MAC_STAT_RBYTES:
break;
case MAC_STAT_IPACKETS:
break;
case MAC_STAT_OBYTES:
break;
case MAC_STAT_OPACKETS:
break;
case MAC_STAT_OERRORS:
case WIFI_STAT_TX_FAILED:
break;
case WIFI_STAT_TX_RETRANS:
break;
case WIFI_STAT_FCS_ERRORS:
case WIFI_STAT_WEP_ERRORS:
case WIFI_STAT_TX_FRAGS:
case WIFI_STAT_MCAST_TX:
case WIFI_STAT_RTS_SUCCESS:
case WIFI_STAT_RTS_FAILURE:
case WIFI_STAT_ACK_FAILURE:
case WIFI_STAT_RX_FRAGS:
case WIFI_STAT_MCAST_RX:
case WIFI_STAT_RX_DUPS:
default:
return (ENOTSUP);
}
return (IWH_SUCCESS);
}
/*
* invoked by GLD to start or open NIC
*/
static int
{
return (EINVAL);
}
if (err != IWH_SUCCESS) {
/*
* The hw init err(eg. RF is OFF). Return Success to make
* the 'plumb' succeed. The iwh_thread() tries to re-init
* background.
*/
return (IWH_SUCCESS);
}
return (IWH_SUCCESS);
}
/*
* invoked by GLD to stop or down NIC
*/
static void
{
return;
}
/*
* release buffer for calibration
*/
}
/*
* invoked by GLD to configure NIC
*/
static int
{
return (EINVAL);
}
if (err != IWH_SUCCESS) {
"failed to configure device\n");
goto fail;
}
}
fail:
return (err);
}
/* ARGSUSED */
static int
{
return (IWH_SUCCESS);
}
/* ARGSUSED */
static int
{
return (IWH_SUCCESS);
}
/*
* kernel thread to deal with exceptional situation
*/
static void
{
#ifdef DEBUG
int times = 0;
#endif
while (sc->sc_mf_thread_switch) {
if (tmp & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) {
} else {
}
/*
* If in SUSPEND or the RF is OFF, do nothing.
*/
continue;
}
/*
* recovery fatal error
*/
"try to recover fatal hw error: %d\n", times++));
if (IWH_CHK_FAST_RECOVER(sc)) {
/*
* save runtime configuration
*/
} else {
}
if (err != IWH_SUCCESS) {
n++;
if (n < 20) {
continue;
}
}
n = 0;
if (!err) {
}
if (!IWH_CHK_FAST_RECOVER(sc) ||
IEEE80211_S_SCAN, 0);
}
}
}
"wait for probe response\n"));
sc->sc_scan_pending--;
}
/*
* rate ctl
*/
clk = ddi_get_lbolt();
}
}
(void) ieee80211_new_state(ic,
IEEE80211_S_INIT, -1);
}
if (sc->sc_tx_timer) {
timeout++;
if (10 == timeout) {
sc->sc_tx_timer--;
if (0 == sc->sc_tx_timer) {
"try to recover from "
"send fail\n"));
}
timeout = 0;
}
}
}
}
/*
* Send a command to the ucode.
*/
static int
{
"code[%d]", code));
if (async) {
sc->sc_cmd_accum++;
}
/*
* kick cmd ring XXX
*/
}
if (async) {
return (IWH_SUCCESS);
} else {
break;
}
}
return (IWH_SUCCESS);
} else {
return (IWH_FAIL);
}
}
}
/*
* require ucode seting led of NIC
*/
static void
{
}
/*
* necessary setting to NIC before authentication
*/
static int
{
/*
* update adapter's configuration according
* the info of target AP
*/
} else { /* assume 802.11b/g */
}
}
} else {
}
} else {
}
"config chan %d flags %x "
"filter_flags %x cck %x ofdm %x"
" bssid:%02x:%02x:%02x:%02x:%02x:%2x\n",
sizeof (iwh_rxon_cmd_t), 1);
if (err != IWH_SUCCESS) {
return (err);
}
if (err != IWH_SUCCESS) {
return (err);
}
}
/*
* add default AP node
*/
if (err != IWH_SUCCESS) {
return (err);
}
/*
* set up retry rate table for AP node
*/
if (err != IWH_SUCCESS) {
return (err);
}
}
return (err);
}
/*
* Send a scan request(assembly scan cmd) to the firmware.
*/
static int
{
(0x7 << RXON_RX_CHAIN_VALID_POS) |
(0x2 << RXON_RX_CHAIN_FORCE_SEL_POS) |
(0x2 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS));
if (ic->ic_des_esslen) {
"directed scan %s\n", essid));
ic->ic_des_esslen);
} else {
}
/*
* a probe request frame is required after the REPLY_SCAN_CMD
*/
/*
* essid IE
*/
"probe with ESSID %s\n",
essid));
}
*frm++ = IEEE80211_ELEMID_SSID;
/*
* supported rates IE
*/
*frm++ = IEEE80211_ELEMID_RATES;
if (nrates > IEEE80211_RATE_SIZE) {
}
/*
* supported xrates IE
*/
*frm++ = IEEE80211_ELEMID_XRATES;
}
/*
* optionnal IE (usually for wpa)
*/
}
/* setup length of probe request */
/*
* the attribute of the scan channels are required after the probe
* request frame.
*/
if (ic->ic_des_esslen) {
} else {
}
frm += sizeof (iwh_scan_chan_t);
}
/*
* maybe for cmd, filling the byte cnt table is not necessary.
* anyway, we fill it here.
*/
}
/*
* kick cmd ring
*/
return (IWH_SUCCESS);
}
/*
* configure NIC by using ucode commands after loading ucode.
*/
static int
{
/*
* set power mode. Disable power management at present, do it later
*/
sizeof (powertable), 0);
if (err != IWH_SUCCESS) {
"failed to set power mode\n");
return (err);
}
/*
* configure bt coexistence
*/
sizeof (bt), 0);
if (err != IWH_SUCCESS) {
"failed to configurate bt coexistence\n");
return (err);
}
/*
* configure rxon
*/
case IEEE80211_M_STA:
break;
case IEEE80211_M_IBSS:
case IEEE80211_M_AHDEMO:
break;
case IEEE80211_M_HOSTAP:
break;
case IEEE80211_M_MONITOR:
break;
}
/*
* Support all CCK rates.
*/
/*
* Support all OFDM rates.
*/
/*
* Determine HT supported rates.
*/
case 3:
break;
case 2:
break;
case 1:
break;
default:
"RX stream count %d is not in suitable range\n",
return (IWH_FAIL);
}
/*
*/
sizeof (iwh_rxon_cmd_t), 0);
if (err != IWH_SUCCESS) {
"failed to set configure command\n");
return (err);
}
/*
* remove all nodes in NIC
*/
if (err != IWH_SUCCESS) {
"failed to remove broadcast node in hardware.\n");
return (err);
}
/*
* configure TX power table
*/
if (err != IWH_SUCCESS) {
return (err);
}
}
/*
* add broadcast node so that we can send broadcast frame
*/
node.station_flags = 0;
if (err != IWH_SUCCESS) {
"failed to add broadcast node\n");
return (err);
}
/*
* TX_LINK_QUALITY cmd
*/
for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
masks &= ~RATE_MCS_ANT_A_MSK;
link_quality.rate_n_flags[i] =
}
sizeof (link_quality), 0);
if (err != IWH_SUCCESS) {
"failed to config link quality table\n");
return (err);
}
}
return (err);
}
/*
* quiesce(9E) entry point.
* This function is called when the system is single-threaded at high
* PIL with preemption disabled. Therefore, this function must not be
* blocked.
* This function returns DDI_SUCCESS on success, or DDI_FAILURE on failure.
* DDI_FAILURE indicates an error condition and should almost never happen.
*/
static int
{
return (DDI_FAILURE);
}
#ifdef DEBUG
/*
* by pass any messages, if it's quiesce
*/
iwh_dbg_flags = 0;
#endif
/*
* No more blocking is allowed while we are in the
* quiesce(9E) entry point.
*/
/*
* Disable and mask all interrupts.
*/
return (DDI_SUCCESS);
}
static void
{
int n;
if ((tmp & CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE) ==
return;
}
for (n = 0; n < 2000; n++) {
break;
}
DELAY(1000);
}
#ifdef DEBUG
if (2000 == n) {
"timeout waiting for master stop\n"));
}
#endif
}
static int
{
DELAY(5000);
return (IWH_SUCCESS);
}
/*
* hardware initialization
*/
static int
{
int n;
/*
* clear any pending interrupts
*/
/*
* wait for clock ready
*/
for (n = 0; n < 1000; n++) {
break;
}
DELAY(10);
}
if (1000 == n) {
return (ETIMEDOUT);
}
DELAY(20);
} else {
"radio configuration information in eeprom is wrong\n");
return (IWH_FAIL);
}
(void) iwh_power_up(sc);
}
vlink & ~2);
/*
* make sure power supply on each part of the hardware
*/
DELAY(5);
return (IWH_SUCCESS);
}
/*
* set up semphore flag to own EEPROM
*/
static int
{
return (IWH_SUCCESS);
}
DELAY(10000);
}
}
return (IWH_FAIL);
}
/*
* reset semphore flag to release EEPROM
*/
static void
{
tmp & (~CSR_HW_IF_CONFIG_REG_EEP_SEM));
}
/*
* This function read all infomation from eeprom
*/
static int
{
int i, rr;
/*
* read eeprom gp register in CSR
*/
if ((eep_gp & CSR_EEPROM_GP_VALID_MSK) ==
"not find eeprom\n"));
return (IWH_FAIL);
}
if (rr != 0) {
"driver failed to own EEPROM\n"));
return (IWH_FAIL);
}
for (i = 0; i < 10; i++) {
if (rv & 1) {
break;
}
DELAY(10);
}
if (!(rv & 1)) {
"time out when read eeprome\n"));
return (IWH_FAIL);
}
}
return (IWH_SUCCESS);
}
/*
* initialize mac address in ieee80211com_t struct
*/
static void
{
"mac:%2x:%2x:%2x:%2x:%2x:%2x\n",
}
/*
* main initialization function
*/
static int
{
/*
* release buffer for calibration
*/
if (err != IWH_SUCCESS) {
return (IWH_FAIL);
}
/*
* backup ucode data part for future use.
*/
/* load firmware init segment into NIC */
if (err != IWH_SUCCESS) {
"failed to setup init firmware\n");
return (IWH_FAIL);
}
/*
* now press "execute" start running
*/
break;
}
}
"failed to process init alive.\n");
return (IWH_FAIL);
}
/*
* stop chipset for initializing chipset again
*/
if (err != IWH_SUCCESS) {
return (IWH_FAIL);
}
/*
* load firmware run segment into NIC
*/
if (err != IWH_SUCCESS) {
"failed to setup run firmware\n");
return (IWH_FAIL);
}
/*
* now press "execute" start running
*/
break;
}
}
"failed to process runtime alive.\n");
return (IWH_FAIL);
}
DELAY(1000);
/*
* at this point, the firmware is loaded OK, then config the hardware
* with the ucode API, including rxon, txpower, etc.
*/
if (err) {
"failed to configure device\n");
return (IWH_FAIL);
}
/*
* at this point, hardware may receive beacons :)
*/
return (IWH_SUCCESS);
}
/*
* stop or disable NIC
*/
static void
{
int i;
/*
* by pass if it's quiesced
*/
}
/*
* disable interrupts
*/
/*
* reset all Tx rings
*/
for (i = 0; i < IWH_NUM_QUEUES; i++) {
}
/*
* reset Rx ring
*/
DELAY(5);
sc->sc_tx_timer = 0;
/*
* by pass if it's quiesced
*/
}
}
/*
* Naive implementation of the Adaptive Multi Rate Retry algorithm:
* "IEEE 802.11 Rate Adaptation: A Practical Approach"
* Mathieu Lacage, Hossein Manshaei, Thierry Turletti
* INRIA Sophia - Projet Planete
*/
static void
{
}
static void
{
"enter\n"));
} else {
}
}
static int
{
int i;
(1 << (r%8))) {
break;
}
}
} else {
return (is_max_rate(in));
}
}
static int
{
int i;
uint8_t r = 0;
(1 << (r%8))) {
break;
}
}
} else {
return (is_min_rate(in));
}
}
static void
{
int i;
uint8_t r;
amrr->ht_mcs_idx++;
(1 << (r%8)))) {
break;
}
}
goto again;
}
} else {
}
}
static void
{
int i;
uint8_t r;
amrr->ht_mcs_idx--;
(1 << (r%8)))) {
break;
}
}
goto again;
}
} else {
}
}
/* ARGSUSED */
static void
{
int need_change = 0;
!iwh_is_max_rate(in)) {
"AMRR increasing rate %d "
"(txcnt=%d retrycnt=%d), mcs_idx=%d\n",
need_change = 1;
} else {
}
if (!iwh_is_min_rate(in)) {
if (amrr->success_threshold >
}
} else {
}
"AMRR decreasing rate %d "
"(txcnt=%d retrycnt=%d), mcs_idx=%d\n",
need_change = 1;
}
}
}
}
/*
* translate indirect address in eeprom to direct address
* in eeprom and return address of entry whos indirect address
* is indi_addr
*/
static uint8_t *
{
if (!(indi_addr & INDIRECT_ADDRESS)) {
}
switch (indi_addr & INDIRECT_TYPE_MSK) {
case INDIRECT_GENERAL:
break;
case INDIRECT_HOST:
break;
case INDIRECT_REGULATORY:
break;
case INDIRECT_CALIBRATION:
break;
case INDIRECT_PROCESS_ADJST:
break;
case INDIRECT_OTHERS:
break;
default:
temp = 0;
"incorrect indirect eeprom address.\n");
break;
}
}
/*
* loade a section of ucode into NIC
*/
static int
{
return (IWH_SUCCESS);
}
/*
* necessary setting during alive notification
*/
static int
{
uint32_t i;
/*
* initialize SCD related registers to make TX work.
*/
/*
* read sram address of data base.
*/
base += 4) {
}
base += 4) {
}
}
for (i = 0; i < IWH_NUM_QUEUES; i++) {
IWH_SCD_CONTEXT_QUEUE_OFFSET(i), 0);
sizeof (uint32_t),
((SCD_FRAME_LIMIT <<
}
SCD_TXFACT_REG_TXFIFO_MASK(0, 7));
/*
* queue 0-7 map to FIFO 0-7 and
* all queues work under FIFO mode(none-scheduler_ack)
*/
for (i = 0; i < 4; i++) {
(1 << IWH_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
((3-i) << IWH_SCD_QUEUE_STTS_REG_POS_TXF) |
(1 << IWH_SCD_QUEUE_STTS_REG_POS_WSL) |
}
(1 << IWH_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
(1 << IWH_SCD_QUEUE_STTS_REG_POS_WSL) |
for (i = 5; i < 7; i++) {
(1 << IWH_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
(i << IWH_SCD_QUEUE_STTS_REG_POS_TXF) |
(1 << IWH_SCD_QUEUE_STTS_REG_POS_WSL) |
}
if (rv != IWH_SUCCESS) {
"failed to send wimax coexist command.\n");
return (rv);
}
if (rv != IWH_SUCCESS) {
"failed to send crystal"
"frq calibration command.\n");
return (rv);
}
/*
* make sure crystal frequency calibration ready
* before next operations.
*/
DELAY(1000);
}
return (IWH_SUCCESS);
}
/*
* save results of calibration from ucode
*/
static void
{
/*
* ensure the size of buffer is not too big
*/
case PHY_CALIBRATE_LO_CMD:
}
"failed to allocate memory.\n");
return;
}
break;
case PHY_CALIBRATE_TX_IQ_CMD:
}
"failed to allocate memory.\n");
return;
}
break;
}
"failed to allocate memory.\n");
return;
}
break;
case PHY_CALIBRATE_DC_CMD:
}
"failed to allocate memory.\n");
return;
}
break;
}
"failed to allocate memory.\n");
return;
}
break;
default:
break;
}
}
/*
* configure TX pwoer table
*/
static int
{
for (i = 0; i < 24; i++) {
}
for (i = 0; i < 2; i++) {
}
if (err != IWH_SUCCESS) {
"failed to set tx power table.\n");
return (err);
}
return (err);
}
static void
{
}
}
}
}
}
}
/*
* common section of intialization
*/
static int
{
"failed to reset hardware\n");
return (IWH_FAIL);
}
(void) iwh_preinit(sc);
if (!(tmp & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) {
"radio transmitter is off\n");
return (IWH_FAIL);
}
/*
* init Rx ring
*/
/*
* init Tx rings
*/
/*
* keep warm page
*/
}
/*
* clear "radio off" and "disable command" bits
*/
/*
* clear any pending interrupts
*/
/*
* enable interrupts
*/
return (IWH_SUCCESS);
}
static int
{
/*
* restore runtime configuration
*/
"could not setup authentication\n");
return (err);
}
/*
* update adapter's configuration
*/
if (err != IWH_SUCCESS) {
"failed to setup association\n");
return (err);
}
/*
* set LED on
*/
/*
* start queue
*/
"resume xmit\n"));
return (IWH_SUCCESS);
}
static int
{
/*
* update adapter's configuration
*/
/*
* negotiated when associating
*/
}
}
if (ht_protec > 3) {
"HT protection mode is not correct.\n");
return (IWH_FAIL);
} else if (NO_HT_PROT == ht_protec) {
}
}
/*
*/
}
"config chan %d flags %x"
" filter_flags %x\n",
sizeof (iwh_rxon_cmd_t), 1);
if (err != IWH_SUCCESS) {
"could not update configuration\n");
return (err);
}
/*
* send tx power table command
*/
if (err != IWH_SUCCESS) {
return (err);
}
}
/*
* Not need to update retry rate table for AP node
*/
if (err != IWH_SUCCESS) {
return (err);
}
return (err);
}
/*
* This function is only for compatibility with Net80211 module.
* iwh_qosparam_to_hw() is the actual function updating EDCA
* parameters to hardware.
*/
/* ARGSUSED */
static int
{
return (0);
}
static int
{
"WME AC index is not in suitable range.\n");
return (qos_ac);
}
switch (wme_ac) {
case WME_AC_BE:
break;
case WME_AC_BK:
break;
case WME_AC_VI:
break;
case WME_AC_VO:
break;
}
return (qos_ac);
}
static uint16_t
{
while (cw_e > 0) {
cw <<= 1;
cw_e--;
}
cw -= 1;
return (cw);
}
static int
{
int i;
for (i = 0; i < WME_NUM_AC; i++) {
"Contention window is not in suitable range.\n");
return (IWH_FAIL);
}
"Arbitration interframe space number"
"is not in suitable range.\n");
return (IWH_FAIL);
}
}
return (IWH_SUCCESS);
}
/*
* This function updates EDCA parameters into hardware.
* FIFO0-background, FIFO1-best effort, FIFO2-viedo, FIFO3-voice.
*/
static int
{
int i, j;
} else {
return (IWH_SUCCESS);
}
if (err != IWH_SUCCESS) {
return (err);
}
}
}
for (i = 0; i < WME_NUM_AC; i++) {
j = iwh_wme_to_qos_ac(i);
return (IWH_FAIL);
}
wmeparam[i].wmep_aifsn;
}
sizeof (qosparam_cmd), async);
if (err != IWH_SUCCESS) {
"failed to update QoS parameters into hardware.\n");
return (err);
}
#ifdef DEBUG
"EDCA parameters are as follows:\n"));
"cw_min = %d, cw_max = %d, aifsn = %d, txop = %d\n",
"cw_min = %d, cw_max = %d, aifsn = %d, txop = %d\n",
"cw_min = %d, cw_max = %d, aifsn = %d, txop = %d\n",
"cw_min = %d, cw_max = %d, aifsn = %d, txop = %d\n",
#endif
return (err);
}
static inline int
{
switch (tid) {
case 1:
case 2:
return (QOS_AC_BK);
case 0:
case 3:
return (QOS_AC_BE);
case 4:
case 5:
return (QOS_AC_VI);
case 6:
case 7:
return (QOS_AC_VO);
}
return (QOS_AC_BE);
}
static inline int
{
switch (qos_ac) {
case QOS_AC_BK:
return (QOS_AC_BK_TO_TXQ);
case QOS_AC_BE:
return (QOS_AC_BE_TO_TXQ);
case QOS_AC_VI:
return (QOS_AC_VI_TO_TXQ);
case QOS_AC_VO:
return (QOS_AC_VO_TO_TXQ);
}
return (QOS_AC_BE_TO_TXQ);
}
static int
{
int qos_ac;
if (tid < WME_TID_MIN ||
tid > WME_TID_MAX) {
"TID is not in suitable range.\n");
return (queue_n);
}
return (queue_n);
}
/*
* This function is used for intializing HT relevant configurations.
*/
static void
{
} else {
}
/* should disable MIMO */
}
}
/*
* This function overwrites default ieee80211_rateset_11n struc.
*/
static void
{
int i, j;
for (i = 0; i < HT_RATESET_NUM; i++) {
for (j = 0; j < 8; j++) {
if (ht_rs[i] & (1 << j)) {
mcs_idx = i * 8 + j;
if (mcs_idx >= IEEE80211_HTRATE_MAXSIZE) {
break;
}
mcs_count++;
}
}
}
#ifdef DEBUG
"HT rates supported by this station is as follows:\n"));
for (i = 0; i < ieee80211_rateset_11n.rs_nrates; i++) {
i, ieee80211_rateset_11n.rs_rates[i]));
}
#endif
}
/*
* This function overwrites default configurations of
* ieee80211com structure in Net80211 module.
*/
static void
{
}
}
/*
* This function sets "RX chain selection" feild
* in RXON command during plumb driver.
*/
static void
{
} else {
}
} else {
}
}
}
/*
* This function adds AP station into hardware.
*/
static int
{
/*
* Add AP node into hardware.
*/
(in->in_htparam != 0)) {
== HT_CAP_MIMO_PS_DYNAMIC) {
}
}
}
if (err != IWH_SUCCESS) {
"failed to add AP node\n");
return (err);
}
return (err);
}
/*
* Each station in the Shirley Peak's internal station table has
* its own table of 16 TX rates and modulation modes for retrying
* TX when an ACK is not received. This function replaces the entire
* table for one station.Station must already be in Shirley Peak's
* station talbe.
*/
static int
{
/*
* TX_LINK_QUALITY cmd
*/
return (err);
for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
} else {
rate = 2;
}
}
link_quality.rate_n_flags[i] =
}
sizeof (link_quality), 1);
if (err != IWH_SUCCESS) {
"failed to config link quality table\n");
return (err);
}
#ifdef DEBUG
"Rates in HW are as follows:\n"));
for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
}
#endif
return (err);
}
/*
* When block ACK agreement has been set up between station and AP,
* Net80211 module will call this function to inform hardware about
* informations of this BA agreement.
* When AP wants to delete BA agreement that was originated by it,
* Net80211 modele will call this function to clean up relevant
* information in hardware.
*/
static void
{
return;
}
return;
}
return;
}
node.station_flags_msk = 0;
if (err != IWH_SUCCESS) {
"failed to setup RX block ACK\n");
return;
}
"RX block ACK "
return;
if ((baparamset & IEEE80211_DELBAPS_INIT) == 0) {
return;
}
node.station_flags_msk = 0;
if (err != IWH_SUCCESS) {
"failed to delete RX block ACK\n");
return;
}
"RX block ACK "
"was deleted on TID %d.\n", tid));
return;
}
}
/*
* When local station wants to delete BA agreement that was originated by AP,
* Net80211 module will call this function to clean up relevant information
* in hardware.
*/
static int
{
return (ret);
}
return (ret);
}
if (category != IEEE80211_ACTION_CAT_BA) {
return (ret);
}
switch (action) {
return (ret);
}
node.station_flags_msk = 0;
if (err != IWH_SUCCESS) {
"failed to delete RX balock ACK\n");
return (EIO);
}
"RX block ACK "
"was deleted on TID %d.\n", tid));
break;
}
return (ret);
}
static int
{
int n;
/*
* wait for HW ready
*/
for (n = 0; n < 5; n++) {
break;
}
DELAY(10);
}
if (n != 5) {
return (IWH_SUCCESS);
}
for (n = 0; n < 15000; n++) {
break;
}
DELAY(10);
}
if (15000 == n) {
return (ETIMEDOUT);
}
/*
* wait for HW ready
*/
for (n = 0; n < 5; n++) {
break;
}
DELAY(10);
}
if (n != 5) {
return (IWH_SUCCESS);
} else {
return (ETIMEDOUT);
}
}