2011-02-22 02:27:26 +07:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* Portions of this file are derived from the ipw3945 project, as well
|
|
|
|
* as portions of the ieee80211 subsystem header files.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
* The full GNU General Public License is included in this distribution in the
|
|
|
|
* file called LICENSE.
|
|
|
|
*
|
|
|
|
* Contact Information:
|
|
|
|
* Intel Linux Wireless <ilw@linux.intel.com>
|
|
|
|
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/pci-aspm.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/firmware.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
|
|
|
|
#include <net/mac80211.h>
|
|
|
|
|
|
|
|
#include <asm/div64.h>
|
|
|
|
|
|
|
|
#define DRV_NAME "iwl4965"
|
|
|
|
|
|
|
|
#include "iwl-eeprom.h"
|
|
|
|
#include "iwl-dev.h"
|
|
|
|
#include "iwl-core.h"
|
|
|
|
#include "iwl-io.h"
|
|
|
|
#include "iwl-helpers.h"
|
|
|
|
#include "iwl-sta.h"
|
|
|
|
#include "iwl-4965-calib.h"
|
|
|
|
#include "iwl-4965.h"
|
|
|
|
#include "iwl-4965-led.h"
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* module boiler plate
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* module name, copyright, version, etc.
|
|
|
|
*/
|
|
|
|
#define DRV_DESCRIPTION "Intel(R) Wireless WiFi 4965 driver for Linux"
|
|
|
|
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
|
|
|
#define VD "d"
|
|
|
|
#else
|
|
|
|
#define VD
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DRV_VERSION IWLWIFI_VERSION VD
|
|
|
|
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION(DRV_DESCRIPTION);
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|
|
|
|
MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_ALIAS("iwl4965");
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_update_chain_flags(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rxon_context *ctx;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (priv->cfg->ops->hcmd->set_rxon_chain) {
|
|
|
|
for_each_context(priv, ctx) {
|
|
|
|
priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
|
|
|
|
if (ctx->active.rx_chain != ctx->staging.rx_chain)
|
2011-10-24 20:41:30 +07:00
|
|
|
il_commit_rxon(priv, ctx);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_clear_free_frames(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
struct list_head *element;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->frames_count);
|
|
|
|
|
|
|
|
while (!list_empty(&priv->free_frames)) {
|
|
|
|
element = priv->free_frames.next;
|
|
|
|
list_del(element);
|
2011-10-24 20:41:30 +07:00
|
|
|
kfree(list_entry(element, struct il_frame, list));
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->frames_count--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->frames_count) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, "%d frames still in use. Did we lose one?\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->frames_count);
|
|
|
|
priv->frames_count = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static struct il_frame *il4965_get_free_frame(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_frame *frame;
|
2011-02-22 02:27:26 +07:00
|
|
|
struct list_head *element;
|
|
|
|
if (list_empty(&priv->free_frames)) {
|
|
|
|
frame = kzalloc(sizeof(*frame), GFP_KERNEL);
|
|
|
|
if (!frame) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Could not allocate frame!\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->frames_count++;
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
element = priv->free_frames.next;
|
|
|
|
list_del(element);
|
2011-10-24 20:41:30 +07:00
|
|
|
return list_entry(element, struct il_frame, list);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_free_frame(struct il_priv *priv, struct il_frame *frame)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
memset(frame, 0, sizeof(*frame));
|
|
|
|
list_add(&frame->list, &priv->free_frames);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static u32 il4965_fill_beacon_frame(struct il_priv *priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct ieee80211_hdr *hdr,
|
|
|
|
int left)
|
|
|
|
{
|
|
|
|
lockdep_assert_held(&priv->mutex);
|
|
|
|
|
|
|
|
if (!priv->beacon_skb)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (priv->beacon_skb->len > left)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
memcpy(hdr, priv->beacon_skb->data, priv->beacon_skb->len);
|
|
|
|
|
|
|
|
return priv->beacon_skb->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_set_beacon_tim(struct il_priv *priv,
|
|
|
|
struct il_tx_beacon_cmd *tx_beacon_cmd,
|
2011-02-22 02:27:26 +07:00
|
|
|
u8 *beacon, u32 frame_size)
|
|
|
|
{
|
|
|
|
u16 tim_idx;
|
|
|
|
struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The index is relative to frame start but we start looking at the
|
|
|
|
* variable-length part of the beacon.
|
|
|
|
*/
|
|
|
|
tim_idx = mgmt->u.beacon.variable - beacon;
|
|
|
|
|
|
|
|
/* Parse variable-length elements of beacon to find WLAN_EID_TIM */
|
|
|
|
while ((tim_idx < (frame_size - 2)) &&
|
|
|
|
(beacon[tim_idx] != WLAN_EID_TIM))
|
|
|
|
tim_idx += beacon[tim_idx+1] + 2;
|
|
|
|
|
|
|
|
/* If TIM field was found, set variables */
|
|
|
|
if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) {
|
|
|
|
tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx);
|
|
|
|
tx_beacon_cmd->tim_size = beacon[tim_idx+1];
|
|
|
|
} else
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, "Unable to find TIM Element in beacon\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv,
|
|
|
|
struct il_frame *frame)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_tx_beacon_cmd *tx_beacon_cmd;
|
2011-02-22 02:27:26 +07:00
|
|
|
u32 frame_size;
|
|
|
|
u32 rate_flags;
|
|
|
|
u32 rate;
|
|
|
|
/*
|
|
|
|
* We have to set up the TX command, the TX Beacon command, and the
|
|
|
|
* beacon contents.
|
|
|
|
*/
|
|
|
|
|
|
|
|
lockdep_assert_held(&priv->mutex);
|
|
|
|
|
|
|
|
if (!priv->beacon_ctx) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "trying to build beacon w/o beacon context!\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize memory */
|
|
|
|
tx_beacon_cmd = &frame->u.beacon;
|
|
|
|
memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd));
|
|
|
|
|
|
|
|
/* Set up TX beacon contents */
|
2011-10-24 20:41:30 +07:00
|
|
|
frame_size = il4965_fill_beacon_frame(priv, tx_beacon_cmd->frame,
|
2011-02-22 02:27:26 +07:00
|
|
|
sizeof(frame->u) - sizeof(*tx_beacon_cmd));
|
|
|
|
if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE))
|
|
|
|
return 0;
|
|
|
|
if (!frame_size)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Set up TX command fields */
|
|
|
|
tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size);
|
|
|
|
tx_beacon_cmd->tx.sta_id = priv->beacon_ctx->bcast_sta_id;
|
|
|
|
tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
|
|
|
|
tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK |
|
|
|
|
TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK;
|
|
|
|
|
|
|
|
/* Set up TX beacon command fields */
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame,
|
2011-02-22 02:27:26 +07:00
|
|
|
frame_size);
|
|
|
|
|
|
|
|
/* Set up packet rate and flags */
|
2011-10-24 20:41:30 +07:00
|
|
|
rate = il_get_lowest_plcp(priv, priv->beacon_ctx);
|
|
|
|
priv->mgmt_tx_ant = il4965_toggle_tx_ant(priv, priv->mgmt_tx_ant,
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->hw_params.valid_tx_ant);
|
2011-10-24 20:41:30 +07:00
|
|
|
rate_flags = il4965_ant_idx_to_flags(priv->mgmt_tx_ant);
|
|
|
|
if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE))
|
2011-02-22 02:27:26 +07:00
|
|
|
rate_flags |= RATE_MCS_CCK_MSK;
|
2011-10-24 20:41:30 +07:00
|
|
|
tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate,
|
2011-02-22 02:27:26 +07:00
|
|
|
rate_flags);
|
|
|
|
|
|
|
|
return sizeof(*tx_beacon_cmd) + frame_size;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
int il4965_send_beacon_cmd(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_frame *frame;
|
2011-02-22 02:27:26 +07:00
|
|
|
unsigned int frame_size;
|
|
|
|
int rc;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
frame = il4965_get_free_frame(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (!frame) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Could not obtain free frame buffer for beacon "
|
2011-02-22 02:27:26 +07:00
|
|
|
"command.\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
frame_size = il4965_hw_get_beacon_cmd(priv, frame);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (!frame_size) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Error configuring the beacon command\n");
|
|
|
|
il4965_free_frame(priv, frame);
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
rc = il_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size,
|
2011-02-22 02:27:26 +07:00
|
|
|
&frame->u.cmd[0]);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_free_frame(priv, frame);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_tfd_tb *tb = &tfd->tbs[idx];
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
dma_addr_t addr = get_unaligned_le32(&tb->lo);
|
|
|
|
if (sizeof(dma_addr_t) > sizeof(u32))
|
|
|
|
addr |=
|
|
|
|
((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16;
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_tfd_tb *tb = &tfd->tbs[idx];
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
return le16_to_cpu(tb->hi_n_len) >> 4;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx,
|
2011-02-22 02:27:26 +07:00
|
|
|
dma_addr_t addr, u16 len)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_tfd_tb *tb = &tfd->tbs[idx];
|
2011-02-22 02:27:26 +07:00
|
|
|
u16 hi_n_len = len << 4;
|
|
|
|
|
|
|
|
put_unaligned_le32(addr, &tb->lo);
|
|
|
|
if (sizeof(dma_addr_t) > sizeof(u32))
|
|
|
|
hi_n_len |= ((addr >> 16) >> 16) & 0xF;
|
|
|
|
|
|
|
|
tb->hi_n_len = cpu_to_le16(hi_n_len);
|
|
|
|
|
|
|
|
tfd->num_tbs = idx + 1;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
return tfd->num_tbs & 0x1f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 20:41:30 +07:00
|
|
|
* il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr]
|
2011-02-22 02:27:26 +07:00
|
|
|
* @priv - driver private data
|
|
|
|
* @txq - tx queue
|
|
|
|
*
|
|
|
|
* Does NOT advance any TFD circular buffer read/write indexes
|
|
|
|
* Does NOT free the TFD itself (which is within circular buffer)
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds;
|
|
|
|
struct il_tfd *tfd;
|
2011-02-22 02:27:26 +07:00
|
|
|
struct pci_dev *dev = priv->pci_dev;
|
|
|
|
int index = txq->q.read_ptr;
|
|
|
|
int i;
|
|
|
|
int num_tbs;
|
|
|
|
|
|
|
|
tfd = &tfd_tmp[index];
|
|
|
|
|
|
|
|
/* Sanity check on number of chunks */
|
2011-10-24 20:41:30 +07:00
|
|
|
num_tbs = il4965_tfd_get_num_tbs(tfd);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (num_tbs >= IL_NUM_OF_TBS) {
|
|
|
|
IL_ERR(priv, "Too many chunks: %i\n", num_tbs);
|
2011-02-22 02:27:26 +07:00
|
|
|
/* @todo issue fatal error, it is quite serious situation */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unmap tx_cmd */
|
|
|
|
if (num_tbs)
|
|
|
|
pci_unmap_single(dev,
|
|
|
|
dma_unmap_addr(&txq->meta[index], mapping),
|
|
|
|
dma_unmap_len(&txq->meta[index], len),
|
|
|
|
PCI_DMA_BIDIRECTIONAL);
|
|
|
|
|
|
|
|
/* Unmap chunks, if any. */
|
|
|
|
for (i = 1; i < num_tbs; i++)
|
2011-10-24 20:41:30 +07:00
|
|
|
pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i),
|
|
|
|
il4965_tfd_tb_get_len(tfd, i),
|
2011-02-22 02:27:26 +07:00
|
|
|
PCI_DMA_TODEVICE);
|
|
|
|
|
|
|
|
/* free SKB */
|
|
|
|
if (txq->txb) {
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
skb = txq->txb[txq->q.read_ptr].skb;
|
|
|
|
|
|
|
|
/* can be called from irqs-disabled context */
|
|
|
|
if (skb) {
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
txq->txb[txq->q.read_ptr].skb = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv,
|
|
|
|
struct il_tx_queue *txq,
|
2011-02-22 02:27:26 +07:00
|
|
|
dma_addr_t addr, u16 len,
|
|
|
|
u8 reset, u8 pad)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_queue *q;
|
|
|
|
struct il_tfd *tfd, *tfd_tmp;
|
2011-02-22 02:27:26 +07:00
|
|
|
u32 num_tbs;
|
|
|
|
|
|
|
|
q = &txq->q;
|
2011-10-24 20:41:30 +07:00
|
|
|
tfd_tmp = (struct il_tfd *)txq->tfds;
|
2011-02-22 02:27:26 +07:00
|
|
|
tfd = &tfd_tmp[q->write_ptr];
|
|
|
|
|
|
|
|
if (reset)
|
|
|
|
memset(tfd, 0, sizeof(*tfd));
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
num_tbs = il4965_tfd_get_num_tbs(tfd);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Each TFD can point to a maximum 20 Tx buffers */
|
2011-10-24 20:41:30 +07:00
|
|
|
if (num_tbs >= IL_NUM_OF_TBS) {
|
|
|
|
IL_ERR(priv, "Error can not send more than %d chunks\n",
|
|
|
|
IL_NUM_OF_TBS);
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BUG_ON(addr & ~DMA_BIT_MASK(36));
|
2011-10-24 20:41:30 +07:00
|
|
|
if (unlikely(addr & ~IL_TX_DMA_MASK))
|
|
|
|
IL_ERR(priv, "Unaligned address = %llx\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
(unsigned long long)addr);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_tfd_set_tb(tfd, num_tbs, addr, len);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Tell nic where to find circular buffer of Tx Frame Descriptors for
|
|
|
|
* given Tx queue, and enable the DMA channel used for that queue.
|
|
|
|
*
|
|
|
|
* 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA
|
|
|
|
* channels supported in hardware.
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
int il4965_hw_tx_queue_init(struct il_priv *priv,
|
|
|
|
struct il_tx_queue *txq)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
int txq_id = txq->q.id;
|
|
|
|
|
|
|
|
/* Circular buffer (TFD queue in DRAM) physical base address */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id),
|
2011-02-22 02:27:26 +07:00
|
|
|
txq->q.dma_addr >> 8);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Generic RX handler implementations
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_rx_reply_alive(struct il_priv *priv,
|
|
|
|
struct il_rx_mem_buffer *rxb)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rx_packet *pkt = rxb_addr(rxb);
|
|
|
|
struct il_alive_resp *palive;
|
2011-02-22 02:27:26 +07:00
|
|
|
struct delayed_work *pwork;
|
|
|
|
|
|
|
|
palive = &pkt->u.alive_frame;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision "
|
2011-02-22 02:27:26 +07:00
|
|
|
"0x%01X 0x%01X\n",
|
|
|
|
palive->is_valid, palive->ver_type,
|
|
|
|
palive->ver_subtype);
|
|
|
|
|
|
|
|
if (palive->ver_subtype == INITIALIZE_SUBTYPE) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Initialization Alive received.\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
memcpy(&priv->card_alive_init,
|
|
|
|
&pkt->u.alive_frame,
|
2011-10-24 20:41:30 +07:00
|
|
|
sizeof(struct il_init_alive_resp));
|
2011-02-22 02:27:26 +07:00
|
|
|
pwork = &priv->init_alive_start;
|
|
|
|
} else {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Runtime Alive received.\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
memcpy(&priv->card_alive, &pkt->u.alive_frame,
|
2011-10-24 20:41:30 +07:00
|
|
|
sizeof(struct il_alive_resp));
|
2011-02-22 02:27:26 +07:00
|
|
|
pwork = &priv->alive_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We delay the ALIVE response by 5ms to
|
|
|
|
* give the HW RF Kill time to activate... */
|
|
|
|
if (palive->is_valid == UCODE_VALID_OK)
|
|
|
|
queue_delayed_work(priv->workqueue, pwork,
|
|
|
|
msecs_to_jiffies(5));
|
|
|
|
else
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, "uCode did not respond OK.\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 20:41:30 +07:00
|
|
|
* il4965_bg_statistics_periodic - Timer callback to queue statistics
|
2011-02-22 02:27:26 +07:00
|
|
|
*
|
|
|
|
* This callback is provided in order to send a statistics request.
|
|
|
|
*
|
|
|
|
* This timer function is continually reset to execute within
|
|
|
|
* REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION
|
|
|
|
* was received. We need to ensure we receive the statistics in order
|
|
|
|
* to update the temperature used for calibrating the TXPOWER.
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_bg_statistics_periodic(unsigned long data)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = (struct il_priv *)data;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* dont send host command if rf-kill is on */
|
2011-10-24 20:41:30 +07:00
|
|
|
if (!il_is_ready_rf(priv))
|
2011-02-22 02:27:26 +07:00
|
|
|
return;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_send_statistics_request(priv, CMD_ASYNC, false);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_rx_beacon_notif(struct il_priv *priv,
|
|
|
|
struct il_rx_mem_buffer *rxb)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rx_packet *pkt = rxb_addr(rxb);
|
|
|
|
struct il4965_beacon_notif *beacon =
|
|
|
|
(struct il4965_beacon_notif *)pkt->u.raw;
|
2011-02-22 02:27:26 +07:00
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
2011-10-24 20:41:30 +07:00
|
|
|
u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_RX(priv, "beacon status %x retries %d iss %d "
|
2011-02-22 02:27:26 +07:00
|
|
|
"tsf %d %d rate %d\n",
|
|
|
|
le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK,
|
|
|
|
beacon->beacon_notify_hdr.failure_frame,
|
|
|
|
le32_to_cpu(beacon->ibss_mgr_status),
|
|
|
|
le32_to_cpu(beacon->high_tsf),
|
|
|
|
le32_to_cpu(beacon->low_tsf), rate);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_perform_ct_kill_task(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_POWER(priv, "Stop all queues\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (priv->mac80211_registered)
|
|
|
|
ieee80211_stop_queues(priv->hw);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_UCODE_DRV_GP1_SET,
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
|
2011-10-24 20:41:30 +07:00
|
|
|
il_read32(priv, CSR_UCODE_DRV_GP1);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->reg_lock, flags);
|
2011-10-24 20:41:30 +07:00
|
|
|
if (!il_grab_nic_access(priv))
|
|
|
|
il_release_nic_access(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
spin_unlock_irqrestore(&priv->reg_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle notification from uCode that card's power state is changing
|
|
|
|
* due to software, hardware, or critical temperature RFKILL */
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_rx_card_state_notif(struct il_priv *priv,
|
|
|
|
struct il_rx_mem_buffer *rxb)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rx_packet *pkt = rxb_addr(rxb);
|
2011-02-22 02:27:26 +07:00
|
|
|
u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);
|
|
|
|
unsigned long status = priv->status;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
(flags & HW_CARD_DISABLED) ? "Kill" : "On",
|
|
|
|
(flags & SW_CARD_DISABLED) ? "Kill" : "On",
|
|
|
|
(flags & CT_CARD_DISABLED) ?
|
|
|
|
"Reached" : "Not reached");
|
|
|
|
|
|
|
|
if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED |
|
|
|
|
CT_CARD_DISABLED)) {
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_UCODE_DRV_GP1_SET,
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_direct32(priv, HBUS_TARG_MBX_C,
|
2011-02-22 02:27:26 +07:00
|
|
|
HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
|
|
|
|
|
|
|
|
if (!(flags & RXON_CARD_DISABLED)) {
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_UCODE_DRV_GP1_CLR,
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_direct32(priv, HBUS_TARG_MBX_C,
|
2011-02-22 02:27:26 +07:00
|
|
|
HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & CT_CARD_DISABLED)
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_perform_ct_kill_task(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (flags & HW_CARD_DISABLED)
|
|
|
|
set_bit(STATUS_RF_KILL_HW, &priv->status);
|
|
|
|
else
|
|
|
|
clear_bit(STATUS_RF_KILL_HW, &priv->status);
|
|
|
|
|
|
|
|
if (!(flags & RXON_CARD_DISABLED))
|
2011-10-24 20:41:30 +07:00
|
|
|
il_scan_cancel(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if ((test_bit(STATUS_RF_KILL_HW, &status) !=
|
|
|
|
test_bit(STATUS_RF_KILL_HW, &priv->status)))
|
|
|
|
wiphy_rfkill_set_hw_state(priv->hw->wiphy,
|
|
|
|
test_bit(STATUS_RF_KILL_HW, &priv->status));
|
|
|
|
else
|
2011-09-20 21:49:03 +07:00
|
|
|
wake_up(&priv->wait_command_queue);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 20:41:30 +07:00
|
|
|
* il4965_setup_rx_handlers - Initialize Rx handler callbacks
|
2011-02-22 02:27:26 +07:00
|
|
|
*
|
|
|
|
* Setup the RX handlers for each of the reply types sent from the uCode
|
|
|
|
* to the host.
|
|
|
|
*
|
|
|
|
* This function chains into the hardware specific files for them to setup
|
|
|
|
* any hardware specific handlers as well.
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_setup_rx_handlers(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive;
|
|
|
|
priv->rx_handlers[REPLY_ERROR] = il_rx_reply_error;
|
|
|
|
priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa;
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] =
|
2011-10-24 20:41:30 +07:00
|
|
|
il_rx_spectrum_measure_notif;
|
|
|
|
priv->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif;
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] =
|
2011-10-24 20:41:30 +07:00
|
|
|
il_rx_pm_debug_statistics_notif;
|
|
|
|
priv->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The same handler is used for both the REPLY to a discrete
|
|
|
|
* statistics request from the host as well as for the periodic
|
|
|
|
* statistics notifications (after received beacons) from the uCode.
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_statistics;
|
|
|
|
priv->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_statistics;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_setup_rx_scan_handlers(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* status change handler */
|
|
|
|
priv->rx_handlers[CARD_STATE_NOTIFICATION] =
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rx_card_state_notif;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] =
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rx_missed_beacon_notif;
|
2011-02-22 02:27:26 +07:00
|
|
|
/* Rx handlers */
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy;
|
|
|
|
priv->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx;
|
2011-02-22 02:27:26 +07:00
|
|
|
/* block ack */
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba;
|
2011-02-22 02:27:26 +07:00
|
|
|
/* Set up hardware specific Rx handlers */
|
|
|
|
priv->cfg->ops->lib->rx_handler_setup(priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 20:41:30 +07:00
|
|
|
* il4965_rx_handle - Main entry function for receiving responses from uCode
|
2011-02-22 02:27:26 +07:00
|
|
|
*
|
|
|
|
* Uses the priv->rx_handlers callback function array to invoke
|
|
|
|
* the appropriate handlers, including command responses,
|
|
|
|
* frame-received notifications, and other notifications.
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_rx_handle(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rx_mem_buffer *rxb;
|
|
|
|
struct il_rx_packet *pkt;
|
|
|
|
struct il_rx_queue *rxq = &priv->rxq;
|
2011-02-22 02:27:26 +07:00
|
|
|
u32 r, i;
|
|
|
|
int reclaim;
|
|
|
|
unsigned long flags;
|
|
|
|
u8 fill_rx = 0;
|
|
|
|
u32 count = 8;
|
|
|
|
int total_empty;
|
|
|
|
|
|
|
|
/* uCode's read index (stored in shared DRAM) indicates the last Rx
|
|
|
|
* buffer that the driver may process (last buffer filled by ucode). */
|
|
|
|
r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF;
|
|
|
|
i = rxq->read;
|
|
|
|
|
|
|
|
/* Rx interrupt, but nothing sent from uCode */
|
|
|
|
if (i == r)
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* calculate total frames need to be restock after handling RX */
|
|
|
|
total_empty = r - rxq->write_actual;
|
|
|
|
if (total_empty < 0)
|
|
|
|
total_empty += RX_QUEUE_SIZE;
|
|
|
|
|
|
|
|
if (total_empty > (RX_QUEUE_SIZE / 2))
|
|
|
|
fill_rx = 1;
|
|
|
|
|
|
|
|
while (i != r) {
|
|
|
|
int len;
|
|
|
|
|
|
|
|
rxb = rxq->queue[i];
|
|
|
|
|
|
|
|
/* If an RXB doesn't have a Rx queue slot associated with it,
|
|
|
|
* then a bug has been introduced in the queue refilling
|
|
|
|
* routines -- catch it here */
|
|
|
|
BUG_ON(rxb == NULL);
|
|
|
|
|
|
|
|
rxq->queue[i] = NULL;
|
|
|
|
|
|
|
|
pci_unmap_page(priv->pci_dev, rxb->page_dma,
|
|
|
|
PAGE_SIZE << priv->hw_params.rx_page_order,
|
|
|
|
PCI_DMA_FROMDEVICE);
|
|
|
|
pkt = rxb_addr(rxb);
|
|
|
|
|
|
|
|
len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
|
|
|
|
len += sizeof(u32); /* account for status word */
|
|
|
|
|
|
|
|
/* Reclaim a command buffer only if this packet is a response
|
|
|
|
* to a (driver-originated) command.
|
|
|
|
* If the packet (e.g. Rx frame) originated from uCode,
|
|
|
|
* there is no command buffer to reclaim.
|
|
|
|
* Ucode should set SEQ_RX_FRAME bit if ucode-originated,
|
|
|
|
* but apparently a few don't get set; catch them here. */
|
|
|
|
reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) &&
|
|
|
|
(pkt->hdr.cmd != REPLY_RX_PHY_CMD) &&
|
|
|
|
(pkt->hdr.cmd != REPLY_RX) &&
|
|
|
|
(pkt->hdr.cmd != REPLY_RX_MPDU_CMD) &&
|
|
|
|
(pkt->hdr.cmd != REPLY_COMPRESSED_BA) &&
|
|
|
|
(pkt->hdr.cmd != STATISTICS_NOTIFICATION) &&
|
|
|
|
(pkt->hdr.cmd != REPLY_TX);
|
|
|
|
|
|
|
|
/* Based on type of command response or notification,
|
|
|
|
* handle those that need handling via function in
|
2011-10-24 20:41:30 +07:00
|
|
|
* rx_handlers table. See il4965_setup_rx_handlers() */
|
2011-02-22 02:27:26 +07:00
|
|
|
if (priv->rx_handlers[pkt->hdr.cmd]) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r,
|
|
|
|
i, il_get_cmd_string(pkt->hdr.cmd),
|
2011-02-22 02:27:26 +07:00
|
|
|
pkt->hdr.cmd);
|
|
|
|
priv->isr_stats.rx_handlers[pkt->hdr.cmd]++;
|
|
|
|
priv->rx_handlers[pkt->hdr.cmd] (priv, rxb);
|
|
|
|
} else {
|
|
|
|
/* No handling needed */
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_RX(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"r %d i %d No handler needed for %s, 0x%02x\n",
|
2011-10-24 20:41:30 +07:00
|
|
|
r, i, il_get_cmd_string(pkt->hdr.cmd),
|
2011-02-22 02:27:26 +07:00
|
|
|
pkt->hdr.cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: After here, we should always check rxb->page
|
|
|
|
* against NULL before touching it or its virtual
|
|
|
|
* memory (pkt). Because some rx_handler might have
|
|
|
|
* already taken or freed the pages.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (reclaim) {
|
|
|
|
/* Invoke any callbacks, transfer the buffer to caller,
|
2011-10-24 20:41:30 +07:00
|
|
|
* and fire off the (possibly) blocking il_send_cmd()
|
2011-02-22 02:27:26 +07:00
|
|
|
* as we reclaim the driver command queue */
|
|
|
|
if (rxb->page)
|
2011-10-24 20:41:30 +07:00
|
|
|
il_tx_cmd_complete(priv, rxb);
|
2011-02-22 02:27:26 +07:00
|
|
|
else
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, "Claim null rxb?\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Reuse the page if possible. For notification packets and
|
|
|
|
* SKBs that fail to Rx correctly, add them back into the
|
|
|
|
* rx_free list for reuse later. */
|
|
|
|
spin_lock_irqsave(&rxq->lock, flags);
|
|
|
|
if (rxb->page != NULL) {
|
|
|
|
rxb->page_dma = pci_map_page(priv->pci_dev, rxb->page,
|
|
|
|
0, PAGE_SIZE << priv->hw_params.rx_page_order,
|
|
|
|
PCI_DMA_FROMDEVICE);
|
|
|
|
list_add_tail(&rxb->list, &rxq->rx_free);
|
|
|
|
rxq->free_count++;
|
|
|
|
} else
|
|
|
|
list_add_tail(&rxb->list, &rxq->rx_used);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&rxq->lock, flags);
|
|
|
|
|
|
|
|
i = (i + 1) & RX_QUEUE_MASK;
|
|
|
|
/* If there are a lot of unused frames,
|
|
|
|
* restock the Rx queue so ucode wont assert. */
|
|
|
|
if (fill_rx) {
|
|
|
|
count++;
|
|
|
|
if (count >= 8) {
|
|
|
|
rxq->read = i;
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rx_replenish_now(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
count = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Backtrack one entry */
|
|
|
|
rxq->read = i;
|
|
|
|
if (fill_rx)
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rx_replenish_now(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
else
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rx_queue_restock(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* call this function to flush any scheduled tasklet */
|
2011-10-24 20:41:30 +07:00
|
|
|
static inline void il4965_synchronize_irq(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
/* wait to make sure we flush pending tasklet*/
|
|
|
|
synchronize_irq(priv->pci_dev->irq);
|
|
|
|
tasklet_kill(&priv->irq_tasklet);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_irq_tasklet(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
u32 inta, handled = 0;
|
|
|
|
u32 inta_fh;
|
|
|
|
unsigned long flags;
|
|
|
|
u32 i;
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
|
|
|
u32 inta_mask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
|
|
|
|
|
|
/* Ack/clear/reset pending uCode interrupts.
|
|
|
|
* Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS,
|
|
|
|
* and will clear only when CSR_FH_INT_STATUS gets cleared. */
|
2011-10-24 20:41:30 +07:00
|
|
|
inta = il_read32(priv, CSR_INT);
|
|
|
|
il_write32(priv, CSR_INT, inta);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Ack/clear/reset pending flow-handler (DMA) interrupts.
|
|
|
|
* Any new interrupts that happen after this, either while we're
|
|
|
|
* in this tasklet, or later, will show up in next ISR/tasklet. */
|
2011-10-24 20:41:30 +07:00
|
|
|
inta_fh = il_read32(priv, CSR_FH_INT_STATUS);
|
|
|
|
il_write32(priv, CSR_FH_INT_STATUS, inta_fh);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_get_debug_level(priv) & IL_DL_ISR) {
|
2011-02-22 02:27:26 +07:00
|
|
|
/* just for debug */
|
2011-10-24 20:41:30 +07:00
|
|
|
inta_mask = il_read32(priv, CSR_INT_MASK);
|
|
|
|
IL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
inta, inta_mask, inta_fh);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
|
|
/* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not
|
|
|
|
* atomic, make sure that inta covers all the interrupts that
|
|
|
|
* we've discovered, even if FH interrupt came in just after
|
|
|
|
* reading CSR_INT. */
|
|
|
|
if (inta_fh & CSR49_FH_INT_RX_MASK)
|
|
|
|
inta |= CSR_INT_BIT_FH_RX;
|
|
|
|
if (inta_fh & CSR49_FH_INT_TX_MASK)
|
|
|
|
inta |= CSR_INT_BIT_FH_TX;
|
|
|
|
|
|
|
|
/* Now service all interrupt bits discovered above. */
|
|
|
|
if (inta & CSR_INT_BIT_HW_ERR) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Hardware error detected. Restarting.\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Tell the device to stop sending interrupts */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_disable_interrupts(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
priv->isr_stats.hw++;
|
2011-10-24 20:41:30 +07:00
|
|
|
il_irq_handle_error(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
handled |= CSR_INT_BIT_HW_ERR;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_get_debug_level(priv) & (IL_DL_ISR)) {
|
2011-02-22 02:27:26 +07:00
|
|
|
/* NIC fires this, but we don't use it, redundant with WAKEUP */
|
|
|
|
if (inta & CSR_INT_BIT_SCD) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_ISR(priv, "Scheduler finished to transmit "
|
2011-02-22 02:27:26 +07:00
|
|
|
"the frame/frames.\n");
|
|
|
|
priv->isr_stats.sch++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Alive notification via Rx interrupt will do the real work */
|
|
|
|
if (inta & CSR_INT_BIT_ALIVE) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_ISR(priv, "Alive interrupt\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->isr_stats.alive++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* Safely ignore these bits for debug checks below */
|
|
|
|
inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE);
|
|
|
|
|
|
|
|
/* HW RF KILL switch toggled */
|
|
|
|
if (inta & CSR_INT_BIT_RF_KILL) {
|
|
|
|
int hw_rf_kill = 0;
|
2011-10-24 20:41:30 +07:00
|
|
|
if (!(il_read32(priv, CSR_GP_CNTRL) &
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
|
|
|
|
hw_rf_kill = 1;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, "RF_KILL bit toggled to %s.\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
hw_rf_kill ? "disable radio" : "enable radio");
|
|
|
|
|
|
|
|
priv->isr_stats.rfkill++;
|
|
|
|
|
|
|
|
/* driver only loads ucode once setting the interface up.
|
|
|
|
* the driver allows loading the ucode even if the radio
|
|
|
|
* is killed. Hence update the killswitch state here. The
|
|
|
|
* rfkill handler will care about restarting if needed.
|
|
|
|
*/
|
|
|
|
if (!test_bit(STATUS_ALIVE, &priv->status)) {
|
|
|
|
if (hw_rf_kill)
|
|
|
|
set_bit(STATUS_RF_KILL_HW, &priv->status);
|
|
|
|
else
|
|
|
|
clear_bit(STATUS_RF_KILL_HW, &priv->status);
|
|
|
|
wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rf_kill);
|
|
|
|
}
|
|
|
|
|
|
|
|
handled |= CSR_INT_BIT_RF_KILL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Chip got too hot and stopped itself */
|
|
|
|
if (inta & CSR_INT_BIT_CT_KILL) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Microcode CT kill error detected.\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->isr_stats.ctkill++;
|
|
|
|
handled |= CSR_INT_BIT_CT_KILL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Error detected by uCode */
|
|
|
|
if (inta & CSR_INT_BIT_SW_ERR) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Microcode SW error detected. "
|
2011-02-22 02:27:26 +07:00
|
|
|
" Restarting 0x%X.\n", inta);
|
|
|
|
priv->isr_stats.sw++;
|
2011-10-24 20:41:30 +07:00
|
|
|
il_irq_handle_error(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
handled |= CSR_INT_BIT_SW_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* uCode wakes up after power-down sleep.
|
|
|
|
* Tell device about any new tx or host commands enqueued,
|
|
|
|
* and about any Rx buffers made available while asleep.
|
|
|
|
*/
|
|
|
|
if (inta & CSR_INT_BIT_WAKEUP) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_ISR(priv, "Wakeup interrupt\n");
|
|
|
|
il_rx_queue_update_write_ptr(priv, &priv->rxq);
|
2011-02-22 02:27:26 +07:00
|
|
|
for (i = 0; i < priv->hw_params.max_txq_num; i++)
|
2011-10-24 20:41:30 +07:00
|
|
|
il_txq_update_write_ptr(priv, &priv->txq[i]);
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->isr_stats.wakeup++;
|
|
|
|
handled |= CSR_INT_BIT_WAKEUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All uCode command responses, including Tx command responses,
|
|
|
|
* Rx "responses" (frame-received notification), and other
|
|
|
|
* notifications from uCode come through here*/
|
|
|
|
if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) {
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rx_handle(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->isr_stats.rx++;
|
|
|
|
handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This "Tx" DMA channel is used only for loading uCode */
|
|
|
|
if (inta & CSR_INT_BIT_FH_TX) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_ISR(priv, "uCode load interrupt\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->isr_stats.tx++;
|
|
|
|
handled |= CSR_INT_BIT_FH_TX;
|
|
|
|
/* Wake up uCode load routine, now that load is complete */
|
|
|
|
priv->ucode_write_complete = 1;
|
2011-09-20 21:49:03 +07:00
|
|
|
wake_up(&priv->wait_command_queue);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (inta & ~handled) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled);
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->isr_stats.unhandled++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inta & ~(priv->inta_mask)) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
inta & ~priv->inta_mask);
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Re-enable all interrupts */
|
2011-04-28 16:51:30 +07:00
|
|
|
/* only Re-enable if disabled by irq */
|
2011-02-22 02:27:26 +07:00
|
|
|
if (test_bit(STATUS_INT_ENABLED, &priv->status))
|
2011-10-24 20:41:30 +07:00
|
|
|
il_enable_interrupts(priv);
|
2011-04-28 16:51:25 +07:00
|
|
|
/* Re-enable RF_KILL if it occurred */
|
|
|
|
else if (handled & CSR_INT_BIT_RF_KILL)
|
2011-10-24 20:41:30 +07:00
|
|
|
il_enable_rfkill_int(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_get_debug_level(priv) & (IL_DL_ISR)) {
|
|
|
|
inta = il_read32(priv, CSR_INT);
|
|
|
|
inta_mask = il_read32(priv, CSR_INT_MASK);
|
|
|
|
inta_fh = il_read32(priv, CSR_FH_INT_STATUS);
|
|
|
|
IL_DEBUG_ISR(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"End inta 0x%08x, enabled 0x%08x, fh 0x%08x, "
|
|
|
|
"flags 0x%08lx\n", inta, inta_mask, inta_fh, flags);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* sysfs attributes
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following adds a new attribute to the sysfs representation
|
|
|
|
* of this device driver (i.e. a new file in /sys/class/net/wlan0/device/)
|
|
|
|
* used for controlling the debug level.
|
|
|
|
*
|
|
|
|
* See the level definitions in iwl for details.
|
|
|
|
*
|
|
|
|
* The debug_level being managed using sysfs below is a per device debug
|
|
|
|
* level that is used instead of the global debug level if it (the per
|
|
|
|
* device debug level) is set.
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
static ssize_t il4965_show_debug_level(struct device *d,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = dev_get_drvdata(d);
|
|
|
|
return sprintf(buf, "0x%08X\n", il_get_debug_level(priv));
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
2011-10-24 20:41:30 +07:00
|
|
|
static ssize_t il4965_store_debug_level(struct device *d,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = dev_get_drvdata(d);
|
2011-02-22 02:27:26 +07:00
|
|
|
unsigned long val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = strict_strtoul(buf, 0, &val);
|
|
|
|
if (ret)
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "%s is not in hex or decimal form.\n", buf);
|
2011-02-22 02:27:26 +07:00
|
|
|
else {
|
|
|
|
priv->debug_level = val;
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_alloc_traffic_mem(priv))
|
|
|
|
IL_ERR(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"Not enough memory to generate traffic log\n");
|
|
|
|
}
|
|
|
|
return strnlen(buf, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_show_debug_level, il4965_store_debug_level);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */
|
|
|
|
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static ssize_t il4965_show_temperature(struct device *d,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = dev_get_drvdata(d);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (!il_is_alive(priv))
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EAGAIN;
|
|
|
|
|
|
|
|
return sprintf(buf, "%d\n", priv->temperature);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static ssize_t il4965_show_tx_power(struct device *d,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = dev_get_drvdata(d);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (!il_is_ready_rf(priv))
|
2011-02-22 02:27:26 +07:00
|
|
|
return sprintf(buf, "off\n");
|
|
|
|
else
|
|
|
|
return sprintf(buf, "%d\n", priv->tx_power_user_lmt);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static ssize_t il4965_store_tx_power(struct device *d,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = dev_get_drvdata(d);
|
2011-02-22 02:27:26 +07:00
|
|
|
unsigned long val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = strict_strtoul(buf, 10, &val);
|
|
|
|
if (ret)
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_INFO(priv, "%s is not in decimal form.\n", buf);
|
2011-02-22 02:27:26 +07:00
|
|
|
else {
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il_set_tx_power(priv, val, false);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (ret)
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "failed setting tx power (0x%d).\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
ret);
|
|
|
|
else
|
|
|
|
ret = count;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO,
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_show_tx_power, il4965_store_tx_power);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static struct attribute *il_sysfs_entries[] = {
|
2011-02-22 02:27:26 +07:00
|
|
|
&dev_attr_temperature.attr,
|
|
|
|
&dev_attr_tx_power.attr,
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
|
|
|
&dev_attr_debug_level.attr,
|
|
|
|
#endif
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static struct attribute_group il_attribute_group = {
|
2011-02-22 02:27:26 +07:00
|
|
|
.name = NULL, /* put in device directory */
|
2011-10-24 20:41:30 +07:00
|
|
|
.attrs = il_sysfs_entries,
|
2011-02-22 02:27:26 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* uCode download functions
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_dealloc_ucode_pci(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
il_free_fw_desc(priv->pci_dev, &priv->ucode_code);
|
|
|
|
il_free_fw_desc(priv->pci_dev, &priv->ucode_data);
|
|
|
|
il_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup);
|
|
|
|
il_free_fw_desc(priv->pci_dev, &priv->ucode_init);
|
|
|
|
il_free_fw_desc(priv->pci_dev, &priv->ucode_init_data);
|
|
|
|
il_free_fw_desc(priv->pci_dev, &priv->ucode_boot);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_nic_start(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
/* Remove all resets to allow NIC to operate */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_RESET, 0);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_ucode_callback(const struct firmware *ucode_raw,
|
2011-02-22 02:27:26 +07:00
|
|
|
void *context);
|
2011-10-24 20:41:30 +07:00
|
|
|
static int il4965_mac_setup_register(struct il_priv *priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
u32 max_probe_length);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static int __must_check il4965_request_firmware(struct il_priv *priv, bool first)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
const char *name_pre = priv->cfg->fw_name_pre;
|
|
|
|
char tag[8];
|
|
|
|
|
|
|
|
if (first) {
|
|
|
|
priv->fw_index = priv->cfg->ucode_api_max;
|
|
|
|
sprintf(tag, "%d", priv->fw_index);
|
|
|
|
} else {
|
|
|
|
priv->fw_index--;
|
|
|
|
sprintf(tag, "%d", priv->fw_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->fw_index < priv->cfg->ucode_api_min) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "no suitable firmware found!\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(priv->firmware_name, "%s%s%s", name_pre, tag, ".ucode");
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "attempting to load firmware '%s'\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->firmware_name);
|
|
|
|
|
|
|
|
return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name,
|
|
|
|
&priv->pci_dev->dev, GFP_KERNEL, priv,
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_ucode_callback);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il4965_firmware_pieces {
|
2011-02-22 02:27:26 +07:00
|
|
|
const void *inst, *data, *init, *init_data, *boot;
|
|
|
|
size_t inst_size, data_size, init_size, init_data_size, boot_size;
|
|
|
|
};
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static int il4965_load_firmware(struct il_priv *priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
const struct firmware *ucode_raw,
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il4965_firmware_pieces *pieces)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_ucode_header *ucode = (void *)ucode_raw->data;
|
2011-02-22 02:27:26 +07:00
|
|
|
u32 api_ver, hdr_size;
|
|
|
|
const u8 *src;
|
|
|
|
|
|
|
|
priv->ucode_ver = le32_to_cpu(ucode->ver);
|
2011-10-24 20:41:30 +07:00
|
|
|
api_ver = IL_UCODE_API(priv->ucode_ver);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
switch (api_ver) {
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
hdr_size = 24;
|
|
|
|
if (ucode_raw->size < hdr_size) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "File size too small!\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
pieces->inst_size = le32_to_cpu(ucode->v1.inst_size);
|
|
|
|
pieces->data_size = le32_to_cpu(ucode->v1.data_size);
|
|
|
|
pieces->init_size = le32_to_cpu(ucode->v1.init_size);
|
|
|
|
pieces->init_data_size =
|
|
|
|
le32_to_cpu(ucode->v1.init_data_size);
|
|
|
|
pieces->boot_size = le32_to_cpu(ucode->v1.boot_size);
|
|
|
|
src = ucode->v1.data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify size of file vs. image size info in file's header */
|
|
|
|
if (ucode_raw->size != hdr_size + pieces->inst_size +
|
|
|
|
pieces->data_size + pieces->init_size +
|
|
|
|
pieces->init_data_size + pieces->boot_size) {
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"uCode file size %d does not match expected size\n",
|
|
|
|
(int)ucode_raw->size);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pieces->inst = src;
|
|
|
|
src += pieces->inst_size;
|
|
|
|
pieces->data = src;
|
|
|
|
src += pieces->data_size;
|
|
|
|
pieces->init = src;
|
|
|
|
src += pieces->init_size;
|
|
|
|
pieces->init_data = src;
|
|
|
|
src += pieces->init_data_size;
|
|
|
|
pieces->boot = src;
|
|
|
|
src += pieces->boot_size;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 20:41:30 +07:00
|
|
|
* il4965_ucode_callback - callback when firmware was loaded
|
2011-02-22 02:27:26 +07:00
|
|
|
*
|
|
|
|
* If loaded successfully, copies the firmware into buffers
|
|
|
|
* for the card to fetch (via DMA).
|
|
|
|
*/
|
|
|
|
static void
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_ucode_callback(const struct firmware *ucode_raw, void *context)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = context;
|
|
|
|
struct il_ucode_header *ucode;
|
2011-02-22 02:27:26 +07:00
|
|
|
int err;
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il4965_firmware_pieces pieces;
|
2011-02-22 02:27:26 +07:00
|
|
|
const unsigned int api_max = priv->cfg->ucode_api_max;
|
|
|
|
const unsigned int api_min = priv->cfg->ucode_api_min;
|
|
|
|
u32 api_ver;
|
|
|
|
|
|
|
|
u32 max_probe_length = 200;
|
|
|
|
u32 standard_phy_calibration_size =
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
memset(&pieces, 0, sizeof(pieces));
|
|
|
|
|
|
|
|
if (!ucode_raw) {
|
|
|
|
if (priv->fw_index <= priv->cfg->ucode_api_max)
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"request for firmware file '%s' failed.\n",
|
|
|
|
priv->firmware_name);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->firmware_name, ucode_raw->size);
|
|
|
|
|
|
|
|
/* Make sure that we got at least the API version number */
|
|
|
|
if (ucode_raw->size < 4) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "File size way too small!\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Data from ucode file: header followed by uCode images */
|
2011-10-24 20:41:30 +07:00
|
|
|
ucode = (struct il_ucode_header *)ucode_raw->data;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
err = il4965_load_firmware(priv, ucode_raw, &pieces);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto try_again;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
api_ver = IL_UCODE_API(priv->ucode_ver);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* api_ver should match the api version forming part of the
|
|
|
|
* firmware filename ... but we don't check for that and only rely
|
|
|
|
* on the API version read from firmware header from here on forward
|
|
|
|
*/
|
|
|
|
if (api_ver < api_min || api_ver > api_max) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"Driver unable to support your firmware API. "
|
|
|
|
"Driver supports v%u, firmware is v%u.\n",
|
|
|
|
api_max, api_ver);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (api_ver != api_max)
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"Firmware has old API version. Expected v%u, "
|
|
|
|
"got v%u. New firmware can be obtained "
|
|
|
|
"from http://www.intellinuxwireless.org.\n",
|
|
|
|
api_max, api_ver);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n",
|
|
|
|
IL_UCODE_MAJOR(priv->ucode_ver),
|
|
|
|
IL_UCODE_MINOR(priv->ucode_ver),
|
|
|
|
IL_UCODE_API(priv->ucode_ver),
|
|
|
|
IL_UCODE_SERIAL(priv->ucode_ver));
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
snprintf(priv->hw->wiphy->fw_version,
|
|
|
|
sizeof(priv->hw->wiphy->fw_version),
|
|
|
|
"%u.%u.%u.%u",
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_UCODE_MAJOR(priv->ucode_ver),
|
|
|
|
IL_UCODE_MINOR(priv->ucode_ver),
|
|
|
|
IL_UCODE_API(priv->ucode_ver),
|
|
|
|
IL_UCODE_SERIAL(priv->ucode_ver));
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For any of the failures below (before allocating pci memory)
|
|
|
|
* we will try to load a version with a smaller API -- maybe the
|
|
|
|
* user just got a corrupted version of the latest API.
|
|
|
|
*/
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->ucode_ver);
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.inst_size);
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.data_size);
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.init_size);
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.init_data_size);
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %Zd\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.boot_size);
|
|
|
|
|
|
|
|
/* Verify that uCode images will fit in card's SRAM */
|
|
|
|
if (pieces.inst_size > priv->hw_params.max_inst_size) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "uCode instr len %Zd too large to fit in\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.inst_size);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pieces.data_size > priv->hw_params.max_data_size) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "uCode data len %Zd too large to fit in\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.data_size);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pieces.init_size > priv->hw_params.max_inst_size) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "uCode init instr len %Zd too large to fit in\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.init_size);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pieces.init_data_size > priv->hw_params.max_data_size) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "uCode init data len %Zd too large to fit in\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.init_data_size);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pieces.boot_size > priv->hw_params.max_bsm_size) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "uCode boot instr len %Zd too large to fit in\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.boot_size);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate ucode buffers for card's bus-master loading ... */
|
|
|
|
|
|
|
|
/* Runtime instructions and 2 copies of data:
|
|
|
|
* 1) unmodified from disk
|
|
|
|
* 2) backup cache for save/restore during power-downs */
|
|
|
|
priv->ucode_code.len = pieces.inst_size;
|
2011-10-24 20:41:30 +07:00
|
|
|
il_alloc_fw_desc(priv->pci_dev, &priv->ucode_code);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
priv->ucode_data.len = pieces.data_size;
|
2011-10-24 20:41:30 +07:00
|
|
|
il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
priv->ucode_data_backup.len = pieces.data_size;
|
2011-10-24 20:41:30 +07:00
|
|
|
il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr ||
|
|
|
|
!priv->ucode_data_backup.v_addr)
|
|
|
|
goto err_pci_alloc;
|
|
|
|
|
|
|
|
/* Initialization instructions and data */
|
|
|
|
if (pieces.init_size && pieces.init_data_size) {
|
|
|
|
priv->ucode_init.len = pieces.init_size;
|
2011-10-24 20:41:30 +07:00
|
|
|
il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
priv->ucode_init_data.len = pieces.init_data_size;
|
2011-10-24 20:41:30 +07:00
|
|
|
il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr)
|
|
|
|
goto err_pci_alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Bootstrap (instructions only, no data) */
|
|
|
|
if (pieces.boot_size) {
|
|
|
|
priv->ucode_boot.len = pieces.boot_size;
|
2011-10-24 20:41:30 +07:00
|
|
|
il_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (!priv->ucode_boot.v_addr)
|
|
|
|
goto err_pci_alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now that we can no longer fail, copy information */
|
|
|
|
|
|
|
|
priv->sta_key_max_num = STA_KEY_MAX_NUM;
|
|
|
|
|
|
|
|
/* Copy images into buffers for card's bus-master reads ... */
|
|
|
|
|
|
|
|
/* Runtime instructions (first block of data in file) */
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.inst_size);
|
|
|
|
memcpy(priv->ucode_code.v_addr, pieces.inst, pieces.inst_size);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Runtime data
|
2011-10-24 20:41:30 +07:00
|
|
|
* NOTE: Copy into backup buffer will be done in il_up()
|
2011-02-22 02:27:26 +07:00
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.data_size);
|
|
|
|
memcpy(priv->ucode_data.v_addr, pieces.data, pieces.data_size);
|
|
|
|
memcpy(priv->ucode_data_backup.v_addr, pieces.data, pieces.data_size);
|
|
|
|
|
|
|
|
/* Initialization instructions */
|
|
|
|
if (pieces.init_size) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"Copying (but not loading) init instr len %Zd\n",
|
|
|
|
pieces.init_size);
|
|
|
|
memcpy(priv->ucode_init.v_addr, pieces.init, pieces.init_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialization data */
|
|
|
|
if (pieces.init_data_size) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"Copying (but not loading) init data len %Zd\n",
|
|
|
|
pieces.init_data_size);
|
|
|
|
memcpy(priv->ucode_init_data.v_addr, pieces.init_data,
|
|
|
|
pieces.init_data_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Bootstrap instructions */
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pieces.boot_size);
|
|
|
|
memcpy(priv->ucode_boot.v_addr, pieces.boot, pieces.boot_size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* figure out the offset of chain noise reset and gain commands
|
|
|
|
* base on the size of standard phy calibration commands table size
|
|
|
|
*/
|
|
|
|
priv->_4965.phy_calib_chain_noise_reset_cmd =
|
|
|
|
standard_phy_calibration_size;
|
|
|
|
priv->_4965.phy_calib_chain_noise_gain_cmd =
|
|
|
|
standard_phy_calibration_size + 1;
|
|
|
|
|
|
|
|
/**************************************************
|
|
|
|
* This is still part of probe() in a sense...
|
|
|
|
*
|
|
|
|
* 9. Setup and register with mac80211 and debugfs
|
|
|
|
**************************************************/
|
2011-10-24 20:41:30 +07:00
|
|
|
err = il4965_mac_setup_register(priv, max_probe_length);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (err)
|
|
|
|
goto out_unbind;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
err = il_dbgfs_register(priv, DRV_NAME);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (err)
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"failed to create debugfs files. Ignoring error: %d\n", err);
|
|
|
|
|
|
|
|
err = sysfs_create_group(&priv->pci_dev->dev.kobj,
|
2011-10-24 20:41:30 +07:00
|
|
|
&il_attribute_group);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (err) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "failed to create sysfs device attributes\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
goto out_unbind;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have our copies now, allow OS release its copies */
|
|
|
|
release_firmware(ucode_raw);
|
|
|
|
complete(&priv->_4965.firmware_loading_complete);
|
|
|
|
return;
|
|
|
|
|
|
|
|
try_again:
|
|
|
|
/* try next, if any */
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il4965_request_firmware(priv, false))
|
2011-02-22 02:27:26 +07:00
|
|
|
goto out_unbind;
|
|
|
|
release_firmware(ucode_raw);
|
|
|
|
return;
|
|
|
|
|
|
|
|
err_pci_alloc:
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "failed to allocate pci memory\n");
|
|
|
|
il4965_dealloc_ucode_pci(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
out_unbind:
|
|
|
|
complete(&priv->_4965.firmware_loading_complete);
|
|
|
|
device_release_driver(&priv->pci_dev->dev);
|
|
|
|
release_firmware(ucode_raw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char * const desc_lookup_text[] = {
|
|
|
|
"OK",
|
|
|
|
"FAIL",
|
|
|
|
"BAD_PARAM",
|
|
|
|
"BAD_CHECKSUM",
|
|
|
|
"NMI_INTERRUPT_WDG",
|
|
|
|
"SYSASSERT",
|
|
|
|
"FATAL_ERROR",
|
|
|
|
"BAD_COMMAND",
|
|
|
|
"HW_ERROR_TUNE_LOCK",
|
|
|
|
"HW_ERROR_TEMPERATURE",
|
|
|
|
"ILLEGAL_CHAN_FREQ",
|
|
|
|
"VCC_NOT_STABLE",
|
|
|
|
"FH_ERROR",
|
|
|
|
"NMI_INTERRUPT_HOST",
|
|
|
|
"NMI_INTERRUPT_ACTION_PT",
|
|
|
|
"NMI_INTERRUPT_UNKNOWN",
|
|
|
|
"UCODE_VERSION_MISMATCH",
|
|
|
|
"HW_ERROR_ABS_LOCK",
|
|
|
|
"HW_ERROR_CAL_LOCK_FAIL",
|
|
|
|
"NMI_INTERRUPT_INST_ACTION_PT",
|
|
|
|
"NMI_INTERRUPT_DATA_ACTION_PT",
|
|
|
|
"NMI_TRM_HW_ER",
|
|
|
|
"NMI_INTERRUPT_TRM",
|
2011-07-09 13:20:24 +07:00
|
|
|
"NMI_INTERRUPT_BREAK_POINT",
|
2011-02-22 02:27:26 +07:00
|
|
|
"DEBUG_0",
|
|
|
|
"DEBUG_1",
|
|
|
|
"DEBUG_2",
|
|
|
|
"DEBUG_3",
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct { char *name; u8 num; } advanced_lookup[] = {
|
|
|
|
{ "NMI_INTERRUPT_WDG", 0x34 },
|
|
|
|
{ "SYSASSERT", 0x35 },
|
|
|
|
{ "UCODE_VERSION_MISMATCH", 0x37 },
|
|
|
|
{ "BAD_COMMAND", 0x38 },
|
|
|
|
{ "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C },
|
|
|
|
{ "FATAL_ERROR", 0x3D },
|
|
|
|
{ "NMI_TRM_HW_ERR", 0x46 },
|
|
|
|
{ "NMI_INTERRUPT_TRM", 0x4C },
|
|
|
|
{ "NMI_INTERRUPT_BREAK_POINT", 0x54 },
|
|
|
|
{ "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C },
|
|
|
|
{ "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 },
|
|
|
|
{ "NMI_INTERRUPT_HOST", 0x66 },
|
|
|
|
{ "NMI_INTERRUPT_ACTION_PT", 0x7C },
|
|
|
|
{ "NMI_INTERRUPT_UNKNOWN", 0x84 },
|
|
|
|
{ "NMI_INTERRUPT_INST_ACTION_PT", 0x86 },
|
|
|
|
{ "ADVANCED_SYSASSERT", 0 },
|
|
|
|
};
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static const char *il4965_desc_lookup(u32 num)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int max = ARRAY_SIZE(desc_lookup_text);
|
|
|
|
|
|
|
|
if (num < max)
|
|
|
|
return desc_lookup_text[num];
|
|
|
|
|
|
|
|
max = ARRAY_SIZE(advanced_lookup) - 1;
|
|
|
|
for (i = 0; i < max; i++) {
|
|
|
|
if (advanced_lookup[i].num == num)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return advanced_lookup[i].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ERROR_START_OFFSET (1 * sizeof(u32))
|
|
|
|
#define ERROR_ELEM_SIZE (7 * sizeof(u32))
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_dump_nic_error_log(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
u32 data2, line;
|
|
|
|
u32 desc, time, count, base, data1;
|
|
|
|
u32 blink1, blink2, ilink1, ilink2;
|
|
|
|
u32 pc, hcmd;
|
|
|
|
|
|
|
|
if (priv->ucode_type == UCODE_INIT) {
|
|
|
|
base = le32_to_cpu(priv->card_alive_init.error_event_table_ptr);
|
|
|
|
} else {
|
|
|
|
base = le32_to_cpu(priv->card_alive.error_event_table_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"Not valid error log pointer 0x%08X for %s uCode\n",
|
|
|
|
base, (priv->ucode_type == UCODE_INIT) ? "Init" : "RT");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
count = il_read_targ_mem(priv, base);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Start IWL Error Log Dump:\n");
|
|
|
|
IL_ERR(priv, "Status: 0x%08lX, count: %d\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->status, count);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
desc = il_read_targ_mem(priv, base + 1 * sizeof(u32));
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->isr_stats.err_code = desc;
|
2011-10-24 20:41:30 +07:00
|
|
|
pc = il_read_targ_mem(priv, base + 2 * sizeof(u32));
|
|
|
|
blink1 = il_read_targ_mem(priv, base + 3 * sizeof(u32));
|
|
|
|
blink2 = il_read_targ_mem(priv, base + 4 * sizeof(u32));
|
|
|
|
ilink1 = il_read_targ_mem(priv, base + 5 * sizeof(u32));
|
|
|
|
ilink2 = il_read_targ_mem(priv, base + 6 * sizeof(u32));
|
|
|
|
data1 = il_read_targ_mem(priv, base + 7 * sizeof(u32));
|
|
|
|
data2 = il_read_targ_mem(priv, base + 8 * sizeof(u32));
|
|
|
|
line = il_read_targ_mem(priv, base + 9 * sizeof(u32));
|
|
|
|
time = il_read_targ_mem(priv, base + 11 * sizeof(u32));
|
|
|
|
hcmd = il_read_targ_mem(priv, base + 22 * sizeof(u32));
|
|
|
|
|
|
|
|
IL_ERR(priv, "Desc Time "
|
2011-02-22 02:27:26 +07:00
|
|
|
"data1 data2 line\n");
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n",
|
|
|
|
il4965_desc_lookup(desc), desc, time, data1, data2, line);
|
|
|
|
IL_ERR(priv, "pc blink1 blink2 ilink1 ilink2 hcmd\n");
|
|
|
|
IL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
pc, blink1, blink2, ilink1, ilink2, hcmd);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_rf_kill_ct_config(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_ct_kill_config cmd;
|
2011-02-22 02:27:26 +07:00
|
|
|
unsigned long flags;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_UCODE_DRV_GP1_CLR,
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
|
|
cmd.critical_temperature_R =
|
|
|
|
cpu_to_le32(priv->hw_params.ct_kill_threshold);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD,
|
2011-02-22 02:27:26 +07:00
|
|
|
sizeof(cmd), &cmd);
|
|
|
|
if (ret)
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
else
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD "
|
2011-02-22 02:27:26 +07:00
|
|
|
"succeeded, "
|
|
|
|
"critical temperature is %d\n",
|
|
|
|
priv->hw_params.ct_kill_threshold);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const s8 default_queue_to_tx_fifo[] = {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_TX_FIFO_VO,
|
|
|
|
IL_TX_FIFO_VI,
|
|
|
|
IL_TX_FIFO_BE,
|
|
|
|
IL_TX_FIFO_BK,
|
2011-02-22 02:27:26 +07:00
|
|
|
IWL49_CMD_FIFO_NUM,
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_TX_FIFO_UNUSED,
|
|
|
|
IL_TX_FIFO_UNUSED,
|
2011-02-22 02:27:26 +07:00
|
|
|
};
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static int il4965_alive_notify(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
u32 a;
|
|
|
|
unsigned long flags;
|
|
|
|
int i, chan;
|
|
|
|
u32 reg_val;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
|
|
|
|
|
|
/* Clear 4965's internal Tx Scheduler data base */
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->scd_base_addr = il_read_prph(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
IWL49_SCD_SRAM_BASE_ADDR);
|
|
|
|
a = priv->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET;
|
|
|
|
for (; a < priv->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4)
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_targ_mem(priv, a, 0);
|
2011-02-22 02:27:26 +07:00
|
|
|
for (; a < priv->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4)
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_targ_mem(priv, a, 0);
|
2011-02-22 02:27:26 +07:00
|
|
|
for (; a < priv->scd_base_addr +
|
|
|
|
IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4)
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_targ_mem(priv, a, 0);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Tel 4965 where to find Tx byte count tables */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR,
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->scd_bc_tbls.dma >> 10);
|
|
|
|
|
|
|
|
/* Enable DMA channel */
|
|
|
|
for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++)
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_direct32(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
FH_TCSR_CHNL_TX_CONFIG_REG(chan),
|
|
|
|
FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
|
|
|
|
FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
|
|
|
|
|
|
|
|
/* Update FH chicken bits */
|
2011-10-24 20:41:30 +07:00
|
|
|
reg_val = il_read_direct32(priv, FH_TX_CHICKEN_BITS_REG);
|
|
|
|
il_write_direct32(priv, FH_TX_CHICKEN_BITS_REG,
|
2011-02-22 02:27:26 +07:00
|
|
|
reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
|
|
|
|
|
|
|
|
/* Disable chain mode for all queues */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Initialize each Tx queue (including the command queue) */
|
|
|
|
for (i = 0; i < priv->hw_params.max_txq_num; i++) {
|
|
|
|
|
|
|
|
/* TFD circular buffer read/write indexes */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(i), 0);
|
|
|
|
il_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8));
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Max Tx Window size for Scheduler-ACK mode */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_targ_mem(priv, priv->scd_base_addr +
|
2011-02-22 02:27:26 +07:00
|
|
|
IWL49_SCD_CONTEXT_QUEUE_OFFSET(i),
|
|
|
|
(SCD_WIN_SIZE <<
|
|
|
|
IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) &
|
|
|
|
IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK);
|
|
|
|
|
|
|
|
/* Frame limit */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_targ_mem(priv, priv->scd_base_addr +
|
2011-02-22 02:27:26 +07:00
|
|
|
IWL49_SCD_CONTEXT_QUEUE_OFFSET(i) +
|
|
|
|
sizeof(u32),
|
|
|
|
(SCD_FRAME_LIMIT <<
|
|
|
|
IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
|
|
|
|
IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK);
|
|
|
|
|
|
|
|
}
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_prph(priv, IWL49_SCD_INTERRUPT_MASK,
|
2011-02-22 02:27:26 +07:00
|
|
|
(1 << priv->hw_params.max_txq_num) - 1);
|
|
|
|
|
|
|
|
/* Activate all Tx DMA/FIFO channels */
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_txq_set_sched(priv, IL_MASK(0, 6));
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_set_wr_ptrs(priv, IL_DEFAULT_CMD_QUEUE_NUM, 0);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* make sure all queue are not stopped */
|
|
|
|
memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped));
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
atomic_set(&priv->queue_stop_count[i], 0);
|
|
|
|
|
|
|
|
/* reset to 0 to enable all the queue first */
|
|
|
|
priv->txq_ctx_active_msk = 0;
|
|
|
|
/* Map each Tx/cmd queue to its corresponding fifo */
|
|
|
|
BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7);
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) {
|
|
|
|
int ac = default_queue_to_tx_fifo[i];
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_txq_ctx_activate(priv, i);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (ac == IL_TX_FIFO_UNUSED)
|
2011-02-22 02:27:26 +07:00
|
|
|
continue;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 20:41:30 +07:00
|
|
|
* il4965_alive_start - called after REPLY_ALIVE notification received
|
2011-02-22 02:27:26 +07:00
|
|
|
* from protocol/runtime uCode (initialization uCode's
|
2011-10-24 20:41:30 +07:00
|
|
|
* Alive gets handled by il_init_alive_start()).
|
2011-02-22 02:27:26 +07:00
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_alive_start(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
int ret = 0;
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS];
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Runtime Alive received.\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (priv->card_alive.is_valid != UCODE_VALID_OK) {
|
|
|
|
/* We had an error bringing up the hardware, so take it
|
|
|
|
* all the way back down so we can try again */
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Alive failed.\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize uCode has loaded Runtime uCode ... verify inst image.
|
|
|
|
* This is a paranoid check, because we would not have gotten the
|
|
|
|
* "runtime" alive if code weren't properly loaded. */
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il4965_verify_ucode(priv)) {
|
2011-02-22 02:27:26 +07:00
|
|
|
/* Runtime instruction load was bad;
|
|
|
|
* take it all the way back down so we can try again */
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Bad runtime uCode load.\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il4965_alive_notify(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (ret) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
"Could not complete ALIVE transition [ntf]: %d\n", ret);
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* After the ALIVE response, we can send host commands to the uCode */
|
|
|
|
set_bit(STATUS_ALIVE, &priv->status);
|
|
|
|
|
|
|
|
/* Enable watchdog to monitor the driver tx queues */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_setup_watchdog(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_is_rfkill(priv))
|
2011-02-22 02:27:26 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
ieee80211_wake_queues(priv->hw);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->active_rate = IL_RATES_MASK;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_is_associated_ctx(ctx)) {
|
|
|
|
struct il_rxon_cmd *active_rxon =
|
|
|
|
(struct il_rxon_cmd *)&ctx->active;
|
2011-02-22 02:27:26 +07:00
|
|
|
/* apply any changes in staging */
|
|
|
|
ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
|
|
|
|
active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
|
|
|
|
} else {
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rxon_context *tmp;
|
2011-02-22 02:27:26 +07:00
|
|
|
/* Initialize our rx_config data */
|
|
|
|
for_each_context(priv, tmp)
|
2011-10-24 20:41:30 +07:00
|
|
|
il_connection_init_rx_config(priv, tmp);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (priv->cfg->ops->hcmd->set_rxon_chain)
|
|
|
|
priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Configure bluetooth coexistence if enabled */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_send_bt_config(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_reset_run_time_calib(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
set_bit(STATUS_READY, &priv->status);
|
|
|
|
|
|
|
|
/* Configure the adapter for unassociated operation */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_commit_rxon(priv, ctx);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* At this point, the NIC is initialized and operational */
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rf_kill_ct_config(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
|
2011-09-20 21:49:03 +07:00
|
|
|
wake_up(&priv->wait_command_queue);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_power_update_mode(priv, true);
|
|
|
|
IL_DEBUG_INFO(priv, "Updated power mode\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
restart:
|
|
|
|
queue_work(priv->workqueue, &priv->restart);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_cancel_deferred_work(struct il_priv *priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void __il4965_down(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
2011-04-28 16:51:24 +07:00
|
|
|
int exit_pending;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, DRV_NAME " is going down\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_scan_cancel_timeout(priv, 200);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status);
|
|
|
|
|
|
|
|
/* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set
|
|
|
|
* to prevent rearm timer */
|
|
|
|
del_timer_sync(&priv->watchdog);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_clear_ucode_stations(priv, NULL);
|
|
|
|
il_dealloc_bcast_stations(priv);
|
|
|
|
il_clear_driver_stations(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Unblock any waiting calls */
|
2011-09-20 21:49:03 +07:00
|
|
|
wake_up_all(&priv->wait_command_queue);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Wipe out the EXIT_PENDING status bit if we are not actually
|
|
|
|
* exiting the module */
|
|
|
|
if (!exit_pending)
|
|
|
|
clear_bit(STATUS_EXIT_PENDING, &priv->status);
|
|
|
|
|
|
|
|
/* stop and reset the on-board processor */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* tell the device to stop sending interrupts */
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
2011-10-24 20:41:30 +07:00
|
|
|
il_disable_interrupts(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_synchronize_irq(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (priv->mac80211_registered)
|
|
|
|
ieee80211_stop_queues(priv->hw);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
/* If we have not previously called il_init() then
|
2011-02-22 02:27:26 +07:00
|
|
|
* clear all bits but the RF Kill bit and return */
|
2011-10-24 20:41:30 +07:00
|
|
|
if (!il_is_init(priv)) {
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) <<
|
|
|
|
STATUS_RF_KILL_HW |
|
|
|
|
test_bit(STATUS_GEO_CONFIGURED, &priv->status) <<
|
|
|
|
STATUS_GEO_CONFIGURED |
|
|
|
|
test_bit(STATUS_EXIT_PENDING, &priv->status) <<
|
|
|
|
STATUS_EXIT_PENDING;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ...otherwise clear out all the status bits but the RF Kill
|
|
|
|
* bit and continue taking the NIC down. */
|
|
|
|
priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) <<
|
|
|
|
STATUS_RF_KILL_HW |
|
|
|
|
test_bit(STATUS_GEO_CONFIGURED, &priv->status) <<
|
|
|
|
STATUS_GEO_CONFIGURED |
|
|
|
|
test_bit(STATUS_FW_ERROR, &priv->status) <<
|
|
|
|
STATUS_FW_ERROR |
|
|
|
|
test_bit(STATUS_EXIT_PENDING, &priv->status) <<
|
|
|
|
STATUS_EXIT_PENDING;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_txq_ctx_stop(priv);
|
|
|
|
il4965_rxq_stop(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Power-down device's busmaster DMA clocks */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT);
|
2011-02-22 02:27:26 +07:00
|
|
|
udelay(5);
|
|
|
|
|
|
|
|
/* Make sure (redundant) we've released our request to stay awake */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_clear_bit(priv, CSR_GP_CNTRL,
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
|
|
|
|
|
|
|
|
/* Stop the device, and put it in low power state */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_apm_stop(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
exit:
|
2011-10-24 20:41:30 +07:00
|
|
|
memset(&priv->card_alive, 0, sizeof(struct il_alive_resp));
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
dev_kfree_skb(priv->beacon_skb);
|
|
|
|
priv->beacon_skb = NULL;
|
|
|
|
|
|
|
|
/* clear out any free frames */
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_clear_free_frames(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_down(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
mutex_lock(&priv->mutex);
|
2011-10-24 20:41:30 +07:00
|
|
|
__il4965_down(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_cancel_deferred_work(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
#define HW_READY_TIMEOUT (50)
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static int il4965_set_hw_ready(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_set_bit(priv, CSR_HW_IF_CONFIG_REG,
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_HW_IF_CONFIG_REG_BIT_NIC_READY);
|
|
|
|
|
|
|
|
/* See if we got it */
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_HW_IF_CONFIG_REG_BIT_NIC_READY,
|
|
|
|
CSR_HW_IF_CONFIG_REG_BIT_NIC_READY,
|
|
|
|
HW_READY_TIMEOUT);
|
|
|
|
if (ret != -ETIMEDOUT)
|
|
|
|
priv->hw_ready = true;
|
|
|
|
else
|
|
|
|
priv->hw_ready = false;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "hardware %s\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
(priv->hw_ready == 1) ? "ready" : "not ready");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static int il4965_prepare_card_hw(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "il4965_prepare_card_hw enter\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il4965_set_hw_ready(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (priv->hw_ready)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* If HW is not ready, prepare the conditions to check again */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_set_bit(priv, CSR_HW_IF_CONFIG_REG,
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_HW_IF_CONFIG_REG_PREPARE);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
|
2011-02-22 02:27:26 +07:00
|
|
|
~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE,
|
|
|
|
CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000);
|
|
|
|
|
|
|
|
/* HW should be ready by now, check again. */
|
|
|
|
if (ret != -ETIMEDOUT)
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_set_hw_ready(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_HW_RESTARTS 5
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static int __il4965_up(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rxon_context *ctx;
|
2011-02-22 02:27:26 +07:00
|
|
|
int i;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, "Exit pending; will not bring the NIC up\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "ucode not available for device bringup\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
for_each_context(priv, ctx) {
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il4965_alloc_bcast_station(priv, ctx);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (ret) {
|
2011-10-24 20:41:30 +07:00
|
|
|
il_dealloc_bcast_stations(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_prepare_card_hw(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (!priv->hw_ready) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, "Exit HW not ready\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If platform's RF_KILL switch is NOT set to KILL */
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_read32(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
|
|
|
|
clear_bit(STATUS_RF_KILL_HW, &priv->status);
|
|
|
|
else
|
|
|
|
set_bit(STATUS_RF_KILL_HW, &priv->status);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_is_rfkill(priv)) {
|
2011-02-22 02:27:26 +07:00
|
|
|
wiphy_rfkill_set_hw_state(priv->hw->wiphy, true);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_enable_interrupts(priv);
|
|
|
|
IL_WARN(priv, "Radio disabled by HW RF Kill switch\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_INT, 0xFFFFFFFF);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
/* must be initialised before il_hw_nic_init */
|
|
|
|
priv->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il4965_hw_nic_init(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (ret) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Unable to init nic\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure rfkill handshake bits are cleared */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
|
|
|
|
il_write32(priv, CSR_UCODE_DRV_GP1_CLR,
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
|
|
|
|
|
|
|
|
/* clear (again), then enable host interrupts */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_INT, 0xFFFFFFFF);
|
|
|
|
il_enable_interrupts(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* really make sure rfkill handshake bits are cleared */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
|
|
|
|
il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Copy original ucode data image from disk into backup cache.
|
|
|
|
* This will be used to initialize the on-board processor's
|
|
|
|
* data SRAM for a clean start when the runtime program first loads. */
|
|
|
|
memcpy(priv->ucode_data_backup.v_addr, priv->ucode_data.v_addr,
|
|
|
|
priv->ucode_data.len);
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_HW_RESTARTS; i++) {
|
|
|
|
|
|
|
|
/* load bootstrap state machine,
|
|
|
|
* load bootstrap program into processor's memory,
|
|
|
|
* prepare to load the "initialize" uCode */
|
|
|
|
ret = priv->cfg->ops->lib->load_ucode(priv);
|
|
|
|
|
|
|
|
if (ret) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Unable to set up bootstrap uCode: %d\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
ret);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start card; "initialize" will load runtime ucode */
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_nic_start(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, DRV_NAME " is coming up\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_bit(STATUS_EXIT_PENDING, &priv->status);
|
2011-10-24 20:41:30 +07:00
|
|
|
__il4965_down(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
clear_bit(STATUS_EXIT_PENDING, &priv->status);
|
|
|
|
|
|
|
|
/* tried to restart and config the device for as long as our
|
|
|
|
* patience could withstand */
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Unable to initialize device after %d attempts.\n", i);
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* Workqueue callbacks
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_bg_init_alive_start(struct work_struct *data)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv =
|
|
|
|
container_of(data, struct il_priv, init_alive_start.work);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-04-28 16:51:32 +07:00
|
|
|
mutex_lock(&priv->mutex);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
|
2011-04-28 16:51:32 +07:00
|
|
|
goto out;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
priv->cfg->ops->lib->init_alive_start(priv);
|
2011-04-28 16:51:32 +07:00
|
|
|
out:
|
2011-02-22 02:27:26 +07:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_bg_alive_start(struct work_struct *data)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv =
|
|
|
|
container_of(data, struct il_priv, alive_start.work);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-04-28 16:51:32 +07:00
|
|
|
mutex_lock(&priv->mutex);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
|
2011-04-28 16:51:32 +07:00
|
|
|
goto out;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_alive_start(priv);
|
2011-04-28 16:51:32 +07:00
|
|
|
out:
|
2011-02-22 02:27:26 +07:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_bg_run_time_calib_work(struct work_struct *work)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = container_of(work, struct il_priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
run_time_calib_work);
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
|
|
|
|
test_bit(STATUS_SCANNING, &priv->status)) {
|
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->start_calib) {
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_chain_noise_calibration(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
(void *)&priv->_4965.statistics);
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_sensitivity_calibration(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
(void *)&priv->_4965.statistics);
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_bg_restart(struct work_struct *data)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = container_of(data, struct il_priv, restart);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) {
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rxon_context *ctx;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
for_each_context(priv, ctx)
|
|
|
|
ctx->vif = NULL;
|
|
|
|
priv->is_open = 0;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
__il4965_down(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
mutex_unlock(&priv->mutex);
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_cancel_deferred_work(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
ieee80211_restart_hw(priv->hw);
|
|
|
|
} else {
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_down(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-04-28 16:51:32 +07:00
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
|
|
|
|
mutex_unlock(&priv->mutex);
|
2011-02-22 02:27:26 +07:00
|
|
|
return;
|
2011-04-28 16:51:32 +07:00
|
|
|
}
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
__il4965_up(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_bg_rx_replenish(struct work_struct *data)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv =
|
|
|
|
container_of(data, struct il_priv, rx_replenish);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
|
|
|
|
return;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rx_replenish(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* mac80211 entry point functions
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#define UCODE_READY_TIMEOUT (4 * HZ)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Not a mac80211 entry point function, but it fits in with all the
|
|
|
|
* other mac80211 functions grouped here.
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
static int il4965_mac_setup_register(struct il_priv *priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
u32 max_probe_length)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct ieee80211_hw *hw = priv->hw;
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rxon_context *ctx;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
hw->rate_control_algorithm = "iwl-4965-rs";
|
|
|
|
|
|
|
|
/* Tell mac80211 our characteristics */
|
|
|
|
hw->flags = IEEE80211_HW_SIGNAL_DBM |
|
|
|
|
IEEE80211_HW_AMPDU_AGGREGATION |
|
|
|
|
IEEE80211_HW_NEED_DTIM_PERIOD |
|
|
|
|
IEEE80211_HW_SPECTRUM_MGMT |
|
|
|
|
IEEE80211_HW_REPORTS_TX_ACK_STATUS;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (priv->cfg->sku & IL_SKU_N)
|
2011-02-22 02:27:26 +07:00
|
|
|
hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS |
|
|
|
|
IEEE80211_HW_SUPPORTS_STATIC_SMPS;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
hw->sta_data_size = sizeof(struct il_station_priv);
|
|
|
|
hw->vif_data_size = sizeof(struct il_vif_priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
for_each_context(priv, ctx) {
|
|
|
|
hw->wiphy->interface_modes |= ctx->interface_modes;
|
|
|
|
hw->wiphy->interface_modes |= ctx->exclusive_interface_modes;
|
|
|
|
}
|
|
|
|
|
|
|
|
hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
|
|
|
|
WIPHY_FLAG_DISABLE_BEACON_HINTS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For now, disable PS by default because it affects
|
|
|
|
* RX performance significantly.
|
|
|
|
*/
|
|
|
|
hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
|
|
|
|
|
|
|
|
hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
|
|
|
|
/* we create the 802.11 header and a zero-length SSID element */
|
|
|
|
hw->wiphy->max_scan_ie_len = max_probe_length - 24 - 2;
|
|
|
|
|
|
|
|
/* Default value; 4 EDCA QOS priorities */
|
|
|
|
hw->queues = 4;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (priv->bands[IEEE80211_BAND_2GHZ].n_channels)
|
|
|
|
priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
|
|
|
|
&priv->bands[IEEE80211_BAND_2GHZ];
|
|
|
|
if (priv->bands[IEEE80211_BAND_5GHZ].n_channels)
|
|
|
|
priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
|
|
|
|
&priv->bands[IEEE80211_BAND_5GHZ];
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_leds_init(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
ret = ieee80211_register_hw(priv->hw);
|
|
|
|
if (ret) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Failed to register hw (error %d)\n", ret);
|
2011-02-22 02:27:26 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
priv->mac80211_registered = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
int il4965_mac_start(struct ieee80211_hw *hw)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = hw->priv;
|
2011-02-22 02:27:26 +07:00
|
|
|
int ret;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "enter\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* we should be verifying the device is ready to be opened */
|
|
|
|
mutex_lock(&priv->mutex);
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = __il4965_up(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_is_rfkill(priv))
|
2011-02-22 02:27:26 +07:00
|
|
|
goto out;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Start UP work done.\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from
|
|
|
|
* mac80211 will not be run successfully. */
|
2011-09-20 21:49:03 +07:00
|
|
|
ret = wait_event_timeout(priv->wait_command_queue,
|
2011-02-22 02:27:26 +07:00
|
|
|
test_bit(STATUS_READY, &priv->status),
|
|
|
|
UCODE_READY_TIMEOUT);
|
|
|
|
if (!ret) {
|
|
|
|
if (!test_bit(STATUS_READY, &priv->status)) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "START_ALIVE timeout after %dms.\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
jiffies_to_msecs(UCODE_READY_TIMEOUT));
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_led_enable(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
out:
|
|
|
|
priv->is_open = 1;
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "leave\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_mac_stop(struct ieee80211_hw *hw)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = hw->priv;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "enter\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (!priv->is_open)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv->is_open = 0;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_down(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
flush_workqueue(priv->workqueue);
|
|
|
|
|
2011-04-28 16:51:25 +07:00
|
|
|
/* User space software may expect getting rfkill changes
|
|
|
|
* even if interface is down */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_INT, 0xFFFFFFFF);
|
|
|
|
il_enable_rfkill_int(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "leave\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = hw->priv;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MACDUMP(priv, "enter\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len,
|
2011-02-22 02:27:26 +07:00
|
|
|
ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il4965_tx_skb(priv, skb))
|
2011-02-22 02:27:26 +07:00
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MACDUMP(priv, "leave\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_mac_update_tkip_key(struct ieee80211_hw *hw,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_key_conf *keyconf,
|
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
u32 iv32, u16 *phase1key)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = hw->priv;
|
|
|
|
struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "enter\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_update_tkip_key(priv, vif_priv->ctx, keyconf, sta,
|
2011-02-22 02:27:26 +07:00
|
|
|
iv32, phase1key);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "leave\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct ieee80211_vif *vif, struct ieee80211_sta *sta,
|
|
|
|
struct ieee80211_key_conf *key)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = hw->priv;
|
|
|
|
struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
|
|
|
|
struct il_rxon_context *ctx = vif_priv->ctx;
|
2011-02-22 02:27:26 +07:00
|
|
|
int ret;
|
|
|
|
u8 sta_id;
|
|
|
|
bool is_default_wep_key = false;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "enter\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (priv->cfg->mod_params->sw_crypto) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
sta_id = il_sta_id_or_broadcast(priv, vif_priv->ctx, sta);
|
|
|
|
if (sta_id == IL_INVALID_STATION)
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
2011-10-24 20:41:30 +07:00
|
|
|
il_scan_cancel_timeout(priv, 100);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we are getting WEP group key and we didn't receive any key mapping
|
|
|
|
* so far, we are in legacy wep mode (group key only), otherwise we are
|
|
|
|
* in 1X mode.
|
|
|
|
* In legacy wep mode, we use another host command to the uCode.
|
|
|
|
*/
|
|
|
|
if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
|
|
|
|
key->cipher == WLAN_CIPHER_SUITE_WEP104) &&
|
|
|
|
!sta) {
|
|
|
|
if (cmd == SET_KEY)
|
|
|
|
is_default_wep_key = !ctx->key_mapping_keys;
|
|
|
|
else
|
|
|
|
is_default_wep_key =
|
|
|
|
(key->hw_key_idx == HW_KEY_DEFAULT);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SET_KEY:
|
|
|
|
if (is_default_wep_key)
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il4965_set_default_wep_key(priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
vif_priv->ctx, key);
|
|
|
|
else
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il4965_set_dynamic_key(priv, vif_priv->ctx,
|
2011-02-22 02:27:26 +07:00
|
|
|
key, sta_id);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "enable hwcrypto key\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
break;
|
|
|
|
case DISABLE_KEY:
|
|
|
|
if (is_default_wep_key)
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il4965_remove_default_wep_key(priv, ctx, key);
|
2011-02-22 02:27:26 +07:00
|
|
|
else
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il4965_remove_dynamic_key(priv, ctx,
|
2011-02-22 02:27:26 +07:00
|
|
|
key, sta_id);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "disable hwcrypto key\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&priv->mutex);
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "leave\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
int il4965_mac_ampdu_action(struct ieee80211_hw *hw,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
enum ieee80211_ampdu_mlme_action action,
|
|
|
|
struct ieee80211_sta *sta, u16 tid, u16 *ssn,
|
|
|
|
u8 buf_size)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = hw->priv;
|
2011-02-22 02:27:26 +07:00
|
|
|
int ret = -EINVAL;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
sta->addr, tid);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (!(priv->cfg->sku & IL_SKU_N))
|
2011-02-22 02:27:26 +07:00
|
|
|
return -EACCES;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case IEEE80211_AMPDU_RX_START:
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_HT(priv, "start Rx\n");
|
|
|
|
ret = il4965_sta_rx_agg_start(priv, sta, tid, *ssn);
|
2011-02-22 02:27:26 +07:00
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_RX_STOP:
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_HT(priv, "stop Rx\n");
|
|
|
|
ret = il4965_sta_rx_agg_stop(priv, sta, tid);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_START:
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_HT(priv, "start Tx\n");
|
|
|
|
ret = il4965_tx_agg_start(priv, vif, sta, tid, ssn);
|
2011-02-22 02:27:26 +07:00
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_STOP:
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_HT(priv, "stop Tx\n");
|
|
|
|
ret = il4965_tx_agg_stop(priv, vif, sta, tid);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_OPERATIONAL:
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
int il4965_mac_sta_add(struct ieee80211_hw *hw,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = hw->priv;
|
|
|
|
struct il_station_priv *sta_priv = (void *)sta->drv_priv;
|
|
|
|
struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
|
2011-02-22 02:27:26 +07:00
|
|
|
bool is_ap = vif->type == NL80211_IFTYPE_STATION;
|
|
|
|
int ret;
|
|
|
|
u8 sta_id;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "received request to add station %pM\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
sta->addr);
|
|
|
|
mutex_lock(&priv->mutex);
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "proceeding to add station %pM\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
sta->addr);
|
2011-10-24 20:41:30 +07:00
|
|
|
sta_priv->common.sta_id = IL_INVALID_STATION;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
atomic_set(&sta_priv->pending_frames, 0);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il_add_station_common(priv, vif_priv->ctx, sta->addr,
|
2011-02-22 02:27:26 +07:00
|
|
|
is_ap, sta, &sta_id);
|
|
|
|
if (ret) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Unable to add station %pM (%d)\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
sta->addr, ret);
|
|
|
|
/* Should we return success if return code is EEXIST ? */
|
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
sta_priv->common.sta_id = sta_id;
|
|
|
|
|
|
|
|
/* Initialize rate scaling */
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
sta->addr);
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rs_rate_init(priv, sta, sta_id);
|
2011-02-22 02:27:26 +07:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_mac_channel_switch(struct ieee80211_hw *hw,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct ieee80211_channel_switch *ch_switch)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = hw->priv;
|
|
|
|
const struct il_channel_info *ch_info;
|
2011-02-22 02:27:26 +07:00
|
|
|
struct ieee80211_conf *conf = &hw->conf;
|
|
|
|
struct ieee80211_channel *channel = ch_switch->channel;
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_ht_config *ht_conf = &priv->current_ht_config;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS];
|
2011-02-22 02:27:26 +07:00
|
|
|
u16 ch;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "enter\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-04-28 16:51:32 +07:00
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_is_rfkill(priv))
|
2011-04-28 16:51:32 +07:00
|
|
|
goto out;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
|
2011-06-08 20:26:31 +07:00
|
|
|
test_bit(STATUS_SCANNING, &priv->status) ||
|
|
|
|
test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status))
|
2011-04-28 16:51:32 +07:00
|
|
|
goto out;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (!il_is_associated_ctx(ctx))
|
2011-04-28 16:51:32 +07:00
|
|
|
goto out;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-06-15 20:10:10 +07:00
|
|
|
if (!priv->cfg->ops->lib->set_channel_switch)
|
2011-06-08 20:28:29 +07:00
|
|
|
goto out;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-06-08 20:28:29 +07:00
|
|
|
ch = channel->hw_value;
|
|
|
|
if (le16_to_cpu(ctx->active.channel) == ch)
|
|
|
|
goto out;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ch_info = il_get_channel_info(priv, channel->band, ch);
|
|
|
|
if (!il_is_channel_valid(ch_info)) {
|
|
|
|
IL_DEBUG_MAC80211(priv, "invalid channel\n");
|
2011-06-08 20:28:29 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-06-15 20:10:10 +07:00
|
|
|
spin_lock_irq(&priv->lock);
|
2011-06-08 20:28:29 +07:00
|
|
|
|
|
|
|
priv->current_ht_config.smps = conf->smps_mode;
|
|
|
|
|
|
|
|
/* Configure HT40 channels */
|
|
|
|
ctx->ht.enabled = conf_is_ht(conf);
|
|
|
|
if (ctx->ht.enabled) {
|
|
|
|
if (conf_is_ht40_minus(conf)) {
|
|
|
|
ctx->ht.extension_chan_offset =
|
|
|
|
IEEE80211_HT_PARAM_CHA_SEC_BELOW;
|
|
|
|
ctx->ht.is_40mhz = true;
|
|
|
|
} else if (conf_is_ht40_plus(conf)) {
|
|
|
|
ctx->ht.extension_chan_offset =
|
|
|
|
IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
|
|
|
|
ctx->ht.is_40mhz = true;
|
|
|
|
} else {
|
|
|
|
ctx->ht.extension_chan_offset =
|
|
|
|
IEEE80211_HT_PARAM_CHA_SEC_NONE;
|
|
|
|
ctx->ht.is_40mhz = false;
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
2011-06-08 20:28:29 +07:00
|
|
|
} else
|
|
|
|
ctx->ht.is_40mhz = false;
|
|
|
|
|
|
|
|
if ((le16_to_cpu(ctx->staging.channel) != ch))
|
|
|
|
ctx->staging.flags = 0;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_set_rxon_channel(priv, channel, ctx);
|
|
|
|
il_set_rxon_ht(priv, ht_conf);
|
|
|
|
il_set_flags_for_band(priv, ctx, channel->band, ctx->vif);
|
2011-06-08 20:28:29 +07:00
|
|
|
|
|
|
|
spin_unlock_irq(&priv->lock);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_set_rate(priv);
|
2011-06-08 20:28:29 +07:00
|
|
|
/*
|
|
|
|
* at this point, staging_rxon has the
|
|
|
|
* configuration for channel switch
|
|
|
|
*/
|
|
|
|
set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
|
|
|
|
priv->switch_channel = cpu_to_le16(ch);
|
|
|
|
if (priv->cfg->ops->lib->set_channel_switch(priv, ch_switch)) {
|
|
|
|
clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
|
|
|
|
priv->switch_channel = 0;
|
|
|
|
ieee80211_chswitch_done(ctx->vif, false);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
2011-06-08 20:28:29 +07:00
|
|
|
|
2011-02-22 02:27:26 +07:00
|
|
|
out:
|
|
|
|
mutex_unlock(&priv->mutex);
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "leave\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_configure_filter(struct ieee80211_hw *hw,
|
2011-02-22 02:27:26 +07:00
|
|
|
unsigned int changed_flags,
|
|
|
|
unsigned int *total_flags,
|
|
|
|
u64 multicast)
|
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = hw->priv;
|
2011-02-22 02:27:26 +07:00
|
|
|
__le32 filter_or = 0, filter_nand = 0;
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_rxon_context *ctx;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
#define CHK(test, flag) do { \
|
|
|
|
if (*total_flags & (test)) \
|
|
|
|
filter_or |= (flag); \
|
|
|
|
else \
|
|
|
|
filter_nand |= (flag); \
|
|
|
|
} while (0)
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
changed_flags, *total_flags);
|
|
|
|
|
|
|
|
CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK);
|
|
|
|
/* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */
|
|
|
|
CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK);
|
|
|
|
CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK);
|
|
|
|
|
|
|
|
#undef CHK
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
|
|
|
|
for_each_context(priv, ctx) {
|
|
|
|
ctx->staging.filter_flags &= ~filter_nand;
|
|
|
|
ctx->staging.filter_flags |= filter_or;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Not committing directly because hardware can perform a scan,
|
|
|
|
* but we'll eventually commit the filter flags change anyway.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Receiving all multicast frames is always enabled by the
|
2011-10-24 20:41:30 +07:00
|
|
|
* default flags setup in il_connection_init_rx_config()
|
2011-02-22 02:27:26 +07:00
|
|
|
* since we currently do not support programming multicast
|
|
|
|
* filters into the device.
|
|
|
|
*/
|
|
|
|
*total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
|
|
|
|
FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* driver setup and teardown
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_bg_txpower_work(struct work_struct *work)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = container_of(work, struct il_priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
txpower_work);
|
|
|
|
|
2011-04-28 16:36:54 +07:00
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
|
2011-02-22 02:27:26 +07:00
|
|
|
/* If a scan happened to start before we got here
|
|
|
|
* then just return; the statistics notification will
|
|
|
|
* kick off another scheduled work to compensate for
|
|
|
|
* any temperature delta we missed here. */
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
|
|
|
|
test_bit(STATUS_SCANNING, &priv->status))
|
2011-04-28 16:36:54 +07:00
|
|
|
goto out;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Regardless of if we are associated, we must reconfigure the
|
|
|
|
* TX power since frames can be sent on non-radar channels while
|
|
|
|
* not associated */
|
|
|
|
priv->cfg->ops->lib->send_tx_power(priv);
|
|
|
|
|
|
|
|
/* Update last_temperature to keep is_calib_needed from running
|
|
|
|
* when it isn't needed... */
|
|
|
|
priv->last_temperature = priv->temperature;
|
2011-04-28 16:36:54 +07:00
|
|
|
out:
|
2011-02-22 02:27:26 +07:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_setup_deferred_work(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
priv->workqueue = create_singlethread_workqueue(DRV_NAME);
|
|
|
|
|
|
|
|
init_waitqueue_head(&priv->wait_command_queue);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
INIT_WORK(&priv->restart, il4965_bg_restart);
|
|
|
|
INIT_WORK(&priv->rx_replenish, il4965_bg_rx_replenish);
|
|
|
|
INIT_WORK(&priv->run_time_calib_work, il4965_bg_run_time_calib_work);
|
|
|
|
INIT_DELAYED_WORK(&priv->init_alive_start, il4965_bg_init_alive_start);
|
|
|
|
INIT_DELAYED_WORK(&priv->alive_start, il4965_bg_alive_start);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_setup_scan_deferred_work(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
INIT_WORK(&priv->txpower_work, il4965_bg_txpower_work);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
init_timer(&priv->statistics_periodic);
|
|
|
|
priv->statistics_periodic.data = (unsigned long)priv;
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->statistics_periodic.function = il4965_bg_statistics_periodic;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
init_timer(&priv->watchdog);
|
|
|
|
priv->watchdog.data = (unsigned long)priv;
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->watchdog.function = il_bg_watchdog;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_irq_tasklet, (unsigned long)priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_cancel_deferred_work(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
cancel_work_sync(&priv->txpower_work);
|
|
|
|
cancel_delayed_work_sync(&priv->init_alive_start);
|
|
|
|
cancel_delayed_work(&priv->alive_start);
|
|
|
|
cancel_work_sync(&priv->run_time_calib_work);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_cancel_scan_deferred_work(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
del_timer_sync(&priv->statistics_periodic);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_init_hw_rates(struct il_priv *priv,
|
2011-02-22 02:27:26 +07:00
|
|
|
struct ieee80211_rate *rates)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) {
|
2011-02-26 03:51:01 +07:00
|
|
|
rates[i].bitrate = iwlegacy_rates[i].ieee * 5;
|
2011-02-22 02:27:26 +07:00
|
|
|
rates[i].hw_value = i; /* Rate scaling will work on indexes */
|
|
|
|
rates[i].hw_value_short = i;
|
|
|
|
rates[i].flags = 0;
|
2011-10-24 20:41:30 +07:00
|
|
|
if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) {
|
2011-02-22 02:27:26 +07:00
|
|
|
/*
|
|
|
|
* If CCK != 1M then set short preamble rate flag.
|
|
|
|
*/
|
|
|
|
rates[i].flags |=
|
2011-10-24 20:41:30 +07:00
|
|
|
(iwlegacy_rates[i].plcp == IL_RATE_1M_PLCP) ?
|
2011-02-22 02:27:26 +07:00
|
|
|
0 : IEEE80211_RATE_SHORT_PREAMBLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Acquire priv->lock before calling this function !
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_set_wr_ptrs(struct il_priv *priv, int txq_id, u32 index)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_direct32(priv, HBUS_TARG_WRPTR,
|
2011-02-22 02:27:26 +07:00
|
|
|
(index & 0xff) | (txq_id << 8));
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(txq_id), index);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_tx_queue_set_status(struct il_priv *priv,
|
|
|
|
struct il_tx_queue *txq,
|
2011-02-22 02:27:26 +07:00
|
|
|
int tx_fifo_id, int scd_retry)
|
|
|
|
{
|
|
|
|
int txq_id = txq->q.id;
|
|
|
|
|
|
|
|
/* Find out whether to activate Tx queue */
|
|
|
|
int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0;
|
|
|
|
|
|
|
|
/* Set up and activate */
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id),
|
2011-02-22 02:27:26 +07:00
|
|
|
(active << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
|
|
|
|
(tx_fifo_id << IWL49_SCD_QUEUE_STTS_REG_POS_TXF) |
|
|
|
|
(scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_WSL) |
|
|
|
|
(scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) |
|
|
|
|
IWL49_SCD_QUEUE_STTS_REG_MSK);
|
|
|
|
|
|
|
|
txq->sched_retry = scd_retry;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "%s %s Queue %d on AC %d\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
active ? "Activate" : "Deactivate",
|
|
|
|
scd_retry ? "BA" : "AC", txq_id, tx_fifo_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static int il4965_init_drv(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
spin_lock_init(&priv->sta_lock);
|
|
|
|
spin_lock_init(&priv->hcmd_lock);
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&priv->free_frames);
|
|
|
|
|
|
|
|
mutex_init(&priv->mutex);
|
|
|
|
|
|
|
|
priv->ieee_channels = NULL;
|
|
|
|
priv->ieee_rates = NULL;
|
|
|
|
priv->band = IEEE80211_BAND_2GHZ;
|
|
|
|
|
|
|
|
priv->iw_mode = NL80211_IFTYPE_STATION;
|
|
|
|
priv->current_ht_config.smps = IEEE80211_SMPS_STATIC;
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* initialize force reset */
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Choose which receivers/antennas to use */
|
|
|
|
if (priv->cfg->ops->hcmd->set_rxon_chain)
|
|
|
|
priv->cfg->ops->hcmd->set_rxon_chain(priv,
|
2011-10-24 20:41:30 +07:00
|
|
|
&priv->contexts[IL_RXON_CTX_BSS]);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_init_scan_params(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il_init_channel_map(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (ret) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "initializing regulatory failed: %d\n", ret);
|
2011-02-22 02:27:26 +07:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il_init_geos(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (ret) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "initializing geos failed: %d\n", ret);
|
2011-02-22 02:27:26 +07:00
|
|
|
goto err_free_channel_map;
|
|
|
|
}
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_init_hw_rates(priv, priv->ieee_rates);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_free_channel_map:
|
2011-10-24 20:41:30 +07:00
|
|
|
il_free_channel_map(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
err:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_uninit_drv(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_calib_free_results(priv);
|
|
|
|
il_free_geos(priv);
|
|
|
|
il_free_channel_map(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
kfree(priv->scan_cmd);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void il4965_hw_detect(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->hw_rev = _il_read32(priv, CSR_HW_REV);
|
|
|
|
priv->hw_wa_rev = _il_read32(priv, CSR_HW_REV_WA_REG);
|
2011-04-15 22:23:11 +07:00
|
|
|
priv->rev_id = priv->pci_dev->revision;
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", priv->rev_id);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static int il4965_set_hw_params(struct il_priv *priv)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
priv->hw_params.max_rxq_size = RX_QUEUE_SIZE;
|
|
|
|
priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG;
|
|
|
|
if (priv->cfg->mod_params->amsdu_size_8K)
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K);
|
2011-02-22 02:27:26 +07:00
|
|
|
else
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (priv->cfg->mod_params->disable_11n)
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->cfg->sku &= ~IL_SKU_N;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* Device-specific setup */
|
|
|
|
return priv->cfg->ops->lib->set_hw_params(priv);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static const u8 il4965_bss_ac_to_fifo[] = {
|
|
|
|
IL_TX_FIFO_VO,
|
|
|
|
IL_TX_FIFO_VI,
|
|
|
|
IL_TX_FIFO_BE,
|
|
|
|
IL_TX_FIFO_BK,
|
2011-02-22 02:27:26 +07:00
|
|
|
};
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static const u8 il4965_bss_ac_to_queue[] = {
|
2011-02-22 02:27:26 +07:00
|
|
|
0, 1, 2, 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
int err = 0, i;
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv;
|
2011-02-22 02:27:26 +07:00
|
|
|
struct ieee80211_hw *hw;
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data);
|
2011-02-22 02:27:26 +07:00
|
|
|
unsigned long flags;
|
|
|
|
u16 pci_cmd;
|
|
|
|
|
|
|
|
/************************
|
|
|
|
* 1. Allocating HW data
|
|
|
|
************************/
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
hw = il_alloc_all(cfg);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (!hw) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
priv = hw->priv;
|
|
|
|
/* At this point both hw and priv are allocated. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The default context is always valid,
|
|
|
|
* more may be discovered when firmware
|
|
|
|
* is loaded.
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->valid_contexts = BIT(IL_RXON_CTX_BSS);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
for (i = 0; i < NUM_IL_RXON_CTX; i++)
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->contexts[i].ctxid = i;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->contexts[IL_RXON_CTX_BSS].always_active = true;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].is_active = true;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes =
|
2011-02-22 02:27:26 +07:00
|
|
|
BIT(NL80211_IFTYPE_ADHOC);
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->contexts[IL_RXON_CTX_BSS].interface_modes =
|
2011-02-22 02:27:26 +07:00
|
|
|
BIT(NL80211_IFTYPE_STATION);
|
2011-10-24 20:41:30 +07:00
|
|
|
priv->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS;
|
|
|
|
priv->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS;
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
BUILD_BUG_ON(NUM_IL_RXON_CTX != 1);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
SET_IEEE80211_DEV(hw, &pdev->dev);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->cfg = cfg;
|
|
|
|
priv->pci_dev = pdev;
|
|
|
|
priv->inta_mask = CSR_INI_SET_MASK;
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_alloc_traffic_mem(priv))
|
|
|
|
IL_ERR(priv, "Not enough memory to generate traffic log\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/**************************
|
|
|
|
* 2. Initializing PCI bus
|
|
|
|
**************************/
|
|
|
|
pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 |
|
|
|
|
PCIE_LINK_STATE_CLKPM);
|
|
|
|
|
|
|
|
if (pci_enable_device(pdev)) {
|
|
|
|
err = -ENODEV;
|
|
|
|
goto out_ieee80211_free_hw;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_set_master(pdev);
|
|
|
|
|
|
|
|
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36));
|
|
|
|
if (!err)
|
|
|
|
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36));
|
|
|
|
if (err) {
|
|
|
|
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
|
|
|
if (!err)
|
|
|
|
err = pci_set_consistent_dma_mask(pdev,
|
|
|
|
DMA_BIT_MASK(32));
|
|
|
|
/* both attempts failed: */
|
|
|
|
if (err) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, "No suitable DMA available.\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
goto out_pci_disable_device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
err = pci_request_regions(pdev, DRV_NAME);
|
|
|
|
if (err)
|
|
|
|
goto out_pci_disable_device;
|
|
|
|
|
|
|
|
pci_set_drvdata(pdev, priv);
|
|
|
|
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* 3. Read REV register
|
|
|
|
***********************/
|
|
|
|
priv->hw_base = pci_iomap(pdev, 0, 0);
|
|
|
|
if (!priv->hw_base) {
|
|
|
|
err = -ENODEV;
|
|
|
|
goto out_pci_release_regions;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
(unsigned long long) pci_resource_len(pdev, 0));
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* these spin locks will be used in apm_ops.init and EEPROM access
|
|
|
|
* we should init now
|
|
|
|
*/
|
|
|
|
spin_lock_init(&priv->reg_lock);
|
|
|
|
spin_lock_init(&priv->lock);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* stop and reset the on-board processor just in case it is in a
|
|
|
|
* strange state ... like being left stranded by a primary kernel
|
|
|
|
* and this is now the kdump kernel trying to start up
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_hw_detect(priv);
|
|
|
|
IL_INFO(priv, "Detected %s, REV=0x%X\n",
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->cfg->name, priv->hw_rev);
|
|
|
|
|
|
|
|
/* We disable the RETRY_TIMEOUT register (0x41) to keep
|
|
|
|
* PCI Tx retries from interfering with C3 CPU state */
|
|
|
|
pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_prepare_card_hw(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (!priv->hw_ready) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_WARN(priv, "Failed, HW not ready\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
goto out_iounmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************
|
|
|
|
* 4. Read EEPROM
|
|
|
|
*****************/
|
|
|
|
/* Read the EEPROM */
|
2011-10-24 20:41:30 +07:00
|
|
|
err = il_eeprom_init(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (err) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Unable to init EEPROM\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
goto out_iounmap;
|
|
|
|
}
|
2011-10-24 20:41:30 +07:00
|
|
|
err = il4965_eeprom_check_version(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (err)
|
|
|
|
goto out_free_eeprom;
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto out_free_eeprom;
|
|
|
|
|
|
|
|
/* extract MAC Address */
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_eeprom_get_mac(priv, priv->addresses[0].addr);
|
|
|
|
IL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->addresses[0].addr);
|
2011-02-22 02:27:26 +07:00
|
|
|
priv->hw->wiphy->addresses = priv->addresses;
|
|
|
|
priv->hw->wiphy->n_addresses = 1;
|
|
|
|
|
|
|
|
/************************
|
|
|
|
* 5. Setup HW constants
|
|
|
|
************************/
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il4965_set_hw_params(priv)) {
|
|
|
|
IL_ERR(priv, "failed to set hw parameters\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
goto out_free_eeprom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************
|
|
|
|
* 6. Setup priv
|
|
|
|
*******************/
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
err = il4965_init_drv(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (err)
|
|
|
|
goto out_free_eeprom;
|
|
|
|
/* At this point both hw and priv are initialized. */
|
|
|
|
|
|
|
|
/********************
|
|
|
|
* 7. Setup services
|
|
|
|
********************/
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
2011-10-24 20:41:30 +07:00
|
|
|
il_disable_interrupts(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
|
|
pci_enable_msi(priv->pci_dev);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
err = request_irq(priv->pci_dev->irq, il_isr,
|
2011-02-22 02:27:26 +07:00
|
|
|
IRQF_SHARED, DRV_NAME, priv);
|
|
|
|
if (err) {
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq);
|
2011-02-22 02:27:26 +07:00
|
|
|
goto out_disable_msi;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_setup_deferred_work(priv);
|
|
|
|
il4965_setup_rx_handlers(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/*********************************************
|
|
|
|
* 8. Enable interrupts and read RFKILL state
|
|
|
|
*********************************************/
|
|
|
|
|
2011-04-28 16:51:25 +07:00
|
|
|
/* enable rfkill interrupt: hw bug w/a */
|
2011-02-22 02:27:26 +07:00
|
|
|
pci_read_config_word(priv->pci_dev, PCI_COMMAND, &pci_cmd);
|
|
|
|
if (pci_cmd & PCI_COMMAND_INTX_DISABLE) {
|
|
|
|
pci_cmd &= ~PCI_COMMAND_INTX_DISABLE;
|
|
|
|
pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd);
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_enable_rfkill_int(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* If platform's RF_KILL switch is NOT set to KILL */
|
2011-10-24 20:41:30 +07:00
|
|
|
if (il_read32(priv, CSR_GP_CNTRL) &
|
2011-02-22 02:27:26 +07:00
|
|
|
CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
|
|
|
|
clear_bit(STATUS_RF_KILL_HW, &priv->status);
|
|
|
|
else
|
|
|
|
set_bit(STATUS_RF_KILL_HW, &priv->status);
|
|
|
|
|
|
|
|
wiphy_rfkill_set_hw_state(priv->hw->wiphy,
|
|
|
|
test_bit(STATUS_RF_KILL_HW, &priv->status));
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_power_initialize(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
init_completion(&priv->_4965.firmware_loading_complete);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
err = il4965_request_firmware(priv, true);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (err)
|
|
|
|
goto out_destroy_workqueue;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_destroy_workqueue:
|
|
|
|
destroy_workqueue(priv->workqueue);
|
|
|
|
priv->workqueue = NULL;
|
|
|
|
free_irq(priv->pci_dev->irq, priv);
|
|
|
|
out_disable_msi:
|
|
|
|
pci_disable_msi(priv->pci_dev);
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_uninit_drv(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
out_free_eeprom:
|
2011-10-24 20:41:30 +07:00
|
|
|
il_eeprom_free(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
out_iounmap:
|
|
|
|
pci_iounmap(pdev, priv->hw_base);
|
|
|
|
out_pci_release_regions:
|
|
|
|
pci_set_drvdata(pdev, NULL);
|
|
|
|
pci_release_regions(pdev);
|
|
|
|
out_pci_disable_device:
|
|
|
|
pci_disable_device(pdev);
|
|
|
|
out_ieee80211_free_hw:
|
2011-10-24 20:41:30 +07:00
|
|
|
il_free_traffic_mem(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
ieee80211_free_hw(priv->hw);
|
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void __devexit il4965_pci_remove(struct pci_dev *pdev)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
struct il_priv *priv = pci_get_drvdata(pdev);
|
2011-02-22 02:27:26 +07:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (!priv)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wait_for_completion(&priv->_4965.firmware_loading_complete);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
IL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_dbgfs_unregister(priv);
|
|
|
|
sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
/* ieee80211_unregister_hw call wil cause il_mac_stop to
|
|
|
|
* to be called and il4965_down since we are removing the device
|
2011-02-22 02:27:26 +07:00
|
|
|
* we need to set STATUS_EXIT_PENDING bit.
|
|
|
|
*/
|
|
|
|
set_bit(STATUS_EXIT_PENDING, &priv->status);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_leds_exit(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (priv->mac80211_registered) {
|
|
|
|
ieee80211_unregister_hw(priv->hw);
|
|
|
|
priv->mac80211_registered = 0;
|
|
|
|
} else {
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_down(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure device is reset to low power before unloading driver.
|
2011-10-24 20:41:30 +07:00
|
|
|
* This may be redundant with il4965_down(), but there are paths to
|
|
|
|
* run il4965_down() without calling apm_ops.stop(), and there are
|
|
|
|
* paths to avoid running il4965_down() at all before leaving driver.
|
2011-02-22 02:27:26 +07:00
|
|
|
* This (inexpensive) call *makes sure* device is reset.
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
il_apm_stop(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
/* make sure we flush any pending irq or
|
|
|
|
* tasklet for the driver
|
|
|
|
*/
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
2011-10-24 20:41:30 +07:00
|
|
|
il_disable_interrupts(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_synchronize_irq(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_dealloc_ucode_pci(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
if (priv->rxq.bd)
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rx_queue_free(priv, &priv->rxq);
|
|
|
|
il4965_hw_txq_ctx_free(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il_eeprom_free(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
|
|
|
|
/*netif_stop_queue(dev); */
|
|
|
|
flush_workqueue(priv->workqueue);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
/* ieee80211_unregister_hw calls il_mac_stop, which flushes
|
2011-02-22 02:27:26 +07:00
|
|
|
* priv->workqueue... so we can't take down the workqueue
|
|
|
|
* until now... */
|
|
|
|
destroy_workqueue(priv->workqueue);
|
|
|
|
priv->workqueue = NULL;
|
2011-10-24 20:41:30 +07:00
|
|
|
il_free_traffic_mem(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
free_irq(priv->pci_dev->irq, priv);
|
|
|
|
pci_disable_msi(priv->pci_dev);
|
|
|
|
pci_iounmap(pdev, priv->hw_base);
|
|
|
|
pci_release_regions(pdev);
|
|
|
|
pci_disable_device(pdev);
|
|
|
|
pci_set_drvdata(pdev, NULL);
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_uninit_drv(priv);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
dev_kfree_skb(priv->beacon_skb);
|
|
|
|
|
|
|
|
ieee80211_free_hw(priv->hw);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
|
|
|
|
* must be called under priv->lock and mac access
|
|
|
|
*/
|
2011-10-24 20:41:30 +07:00
|
|
|
void il4965_txq_set_sched(struct il_priv *priv, u32 mask)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
il_write_prph(priv, IWL49_SCD_TXFACT, mask);
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* driver and module entry point
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/* Hardware specific file defines the PCI IDs table for that hardware module */
|
2011-10-24 20:41:30 +07:00
|
|
|
static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = {
|
2011-02-22 02:27:26 +07:00
|
|
|
#if defined(CONFIG_IWL4965_MODULE) || defined(CONFIG_IWL4965)
|
2011-10-24 20:41:30 +07:00
|
|
|
{IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)},
|
|
|
|
{IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)},
|
2011-02-22 02:27:26 +07:00
|
|
|
#endif /* CONFIG_IWL4965 */
|
|
|
|
|
|
|
|
{0}
|
|
|
|
};
|
2011-10-24 20:41:30 +07:00
|
|
|
MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static struct pci_driver il4965_driver = {
|
2011-02-22 02:27:26 +07:00
|
|
|
.name = DRV_NAME,
|
2011-10-24 20:41:30 +07:00
|
|
|
.id_table = il4965_hw_card_ids,
|
|
|
|
.probe = il4965_pci_probe,
|
|
|
|
.remove = __devexit_p(il4965_pci_remove),
|
|
|
|
.driver.pm = IL_LEGACY_PM_OPS,
|
2011-02-22 02:27:26 +07:00
|
|
|
};
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static int __init il4965_init(void)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n");
|
|
|
|
pr_info(DRV_COPYRIGHT "\n");
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = il4965_rate_control_register();
|
2011-02-22 02:27:26 +07:00
|
|
|
if (ret) {
|
|
|
|
pr_err("Unable to register rate control algorithm: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
ret = pci_register_driver(&il4965_driver);
|
2011-02-22 02:27:26 +07:00
|
|
|
if (ret) {
|
|
|
|
pr_err("Unable to initialize PCI module\n");
|
|
|
|
goto error_register;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
error_register:
|
2011-10-24 20:41:30 +07:00
|
|
|
il4965_rate_control_unregister();
|
2011-02-22 02:27:26 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
static void __exit il4965_exit(void)
|
2011-02-22 02:27:26 +07:00
|
|
|
{
|
2011-10-24 20:41:30 +07:00
|
|
|
pci_unregister_driver(&il4965_driver);
|
|
|
|
il4965_rate_control_unregister();
|
2011-02-22 02:27:26 +07:00
|
|
|
}
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
module_exit(il4965_exit);
|
|
|
|
module_init(il4965_init);
|
2011-02-22 02:27:26 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
2011-02-26 03:51:01 +07:00
|
|
|
module_param_named(debug, iwlegacy_debug_level, uint, S_IRUGO | S_IWUSR);
|
2011-02-22 02:27:26 +07:00
|
|
|
MODULE_PARM_DESC(debug, "debug output mask");
|
|
|
|
#endif
|
|
|
|
|
2011-10-24 20:41:30 +07:00
|
|
|
module_param_named(swcrypto, il4965_mod_params.sw_crypto, int, S_IRUGO);
|
2011-02-22 02:27:26 +07:00
|
|
|
MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
|
2011-10-24 20:41:30 +07:00
|
|
|
module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO);
|
2011-02-22 02:27:26 +07:00
|
|
|
MODULE_PARM_DESC(queues_num, "number of hw queues.");
|
2011-10-24 20:41:30 +07:00
|
|
|
module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO);
|
2011-02-22 02:27:26 +07:00
|
|
|
MODULE_PARM_DESC(11n_disable, "disable 11n functionality");
|
2011-10-24 20:41:30 +07:00
|
|
|
module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K,
|
2011-02-22 02:27:26 +07:00
|
|
|
int, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size");
|
2011-10-24 20:41:30 +07:00
|
|
|
module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO);
|
2011-02-22 02:27:26 +07:00
|
|
|
MODULE_PARM_DESC(fw_restart, "restart firmware in case of error");
|