2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
void il4965_update_chain_flags(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rxon_context *ctx;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->cfg->ops->hcmd->set_rxon_chain) {
|
|
|
|
for_each_context(il, ctx) {
|
|
|
|
il->cfg->ops->hcmd->set_rxon_chain(il, ctx);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (ctx->active.rx_chain != ctx->staging.rx_chain)
|
2011-10-24 14:49:25 +00:00
|
|
|
il_commit_rxon(il, ctx);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_clear_free_frames(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
struct list_head *element;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "%d frames on pre-allocated heap on clear.\n",
|
|
|
|
il->frames_count);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
while (!list_empty(&il->free_frames)) {
|
|
|
|
element = il->free_frames.next;
|
2011-02-21 19:27:26 +00:00
|
|
|
list_del(element);
|
2011-10-24 13:41:30 +00:00
|
|
|
kfree(list_entry(element, struct il_frame, list));
|
2011-10-24 14:49:25 +00:00
|
|
|
il->frames_count--;
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->frames_count) {
|
|
|
|
IL_WARN(il, "%d frames still in use. Did we lose one?\n",
|
|
|
|
il->frames_count);
|
|
|
|
il->frames_count = 0;
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static struct il_frame *il4965_get_free_frame(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_frame *frame;
|
2011-02-21 19:27:26 +00:00
|
|
|
struct list_head *element;
|
2011-10-24 14:49:25 +00:00
|
|
|
if (list_empty(&il->free_frames)) {
|
2011-02-21 19:27:26 +00:00
|
|
|
frame = kzalloc(sizeof(*frame), GFP_KERNEL);
|
|
|
|
if (!frame) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Could not allocate frame!\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->frames_count++;
|
2011-02-21 19:27:26 +00:00
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
element = il->free_frames.next;
|
2011-02-21 19:27:26 +00:00
|
|
|
list_del(element);
|
2011-10-24 13:41:30 +00:00
|
|
|
return list_entry(element, struct il_frame, list);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_free_frame(struct il_priv *il, struct il_frame *frame)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
memset(frame, 0, sizeof(*frame));
|
2011-10-24 14:49:25 +00:00
|
|
|
list_add(&frame->list, &il->free_frames);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static u32 il4965_fill_beacon_frame(struct il_priv *il,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct ieee80211_hdr *hdr,
|
|
|
|
int left)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
lockdep_assert_held(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il->beacon_skb)
|
2011-02-21 19:27:26 +00:00
|
|
|
return 0;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->beacon_skb->len > left)
|
2011-02-21 19:27:26 +00:00
|
|
|
return 0;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
return il->beacon_skb->len;
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_set_beacon_tim(struct il_priv *il,
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_tx_beacon_cmd *tx_beacon_cmd,
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
IL_WARN(il, "Unable to find TIM Element in beacon\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il,
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_frame *frame)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_tx_beacon_cmd *tx_beacon_cmd;
|
2011-02-21 19:27:26 +00: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.
|
|
|
|
*/
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
lockdep_assert_held(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il->beacon_ctx) {
|
|
|
|
IL_ERR(il, "trying to build beacon w/o beacon context!\n");
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
frame_size = il4965_fill_beacon_frame(il, tx_beacon_cmd->frame,
|
2011-02-21 19:27:26 +00: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);
|
2011-10-24 14:49:25 +00:00
|
|
|
tx_beacon_cmd->tx.sta_id = il->beacon_ctx->bcast_sta_id;
|
2011-02-21 19:27:26 +00:00
|
|
|
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 14:49:25 +00:00
|
|
|
il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame,
|
2011-02-21 19:27:26 +00:00
|
|
|
frame_size);
|
|
|
|
|
|
|
|
/* Set up packet rate and flags */
|
2011-10-24 14:49:25 +00:00
|
|
|
rate = il_get_lowest_plcp(il, il->beacon_ctx);
|
|
|
|
il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant,
|
|
|
|
il->hw_params.valid_tx_ant);
|
|
|
|
rate_flags = il4965_ant_idx_to_flags(il->mgmt_tx_ant);
|
2011-10-24 13:41:30 +00:00
|
|
|
if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE))
|
2011-02-21 19:27:26 +00:00
|
|
|
rate_flags |= RATE_MCS_CCK_MSK;
|
2011-10-24 13:41:30 +00:00
|
|
|
tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate,
|
2011-02-21 19:27:26 +00:00
|
|
|
rate_flags);
|
|
|
|
|
|
|
|
return sizeof(*tx_beacon_cmd) + frame_size;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
int il4965_send_beacon_cmd(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_frame *frame;
|
2011-02-21 19:27:26 +00:00
|
|
|
unsigned int frame_size;
|
|
|
|
int rc;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
frame = il4965_get_free_frame(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (!frame) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Could not obtain free frame buffer for beacon "
|
2011-02-21 19:27:26 +00:00
|
|
|
"command.\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
frame_size = il4965_hw_get_beacon_cmd(il, frame);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (!frame_size) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Error configuring the beacon command\n");
|
|
|
|
il4965_free_frame(il, frame);
|
2011-02-21 19:27:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size,
|
2011-02-21 19:27:26 +00:00
|
|
|
&frame->u.cmd[0]);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_free_frame(il, frame);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_tfd_tb *tb = &tfd->tbs[idx];
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_tfd_tb *tb = &tfd->tbs[idx];
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return le16_to_cpu(tb->hi_n_len) >> 4;
|
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx,
|
2011-02-21 19:27:26 +00:00
|
|
|
dma_addr_t addr, u16 len)
|
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_tfd_tb *tb = &tfd->tbs[idx];
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
return tfd->num_tbs & 0x1f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 13:41:30 +00:00
|
|
|
* il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr]
|
2011-10-24 14:49:25 +00:00
|
|
|
* @il - driver ilate data
|
2011-02-21 19:27:26 +00:00
|
|
|
* @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 14:49:25 +00:00
|
|
|
void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds;
|
|
|
|
struct il_tfd *tfd;
|
2011-10-24 14:49:25 +00:00
|
|
|
struct pci_dev *dev = il->pci_dev;
|
2011-02-21 19:27:26 +00:00
|
|
|
int index = txq->q.read_ptr;
|
|
|
|
int i;
|
|
|
|
int num_tbs;
|
|
|
|
|
|
|
|
tfd = &tfd_tmp[index];
|
|
|
|
|
|
|
|
/* Sanity check on number of chunks */
|
2011-10-24 13:41:30 +00:00
|
|
|
num_tbs = il4965_tfd_get_num_tbs(tfd);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
if (num_tbs >= IL_NUM_OF_TBS) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Too many chunks: %i\n", num_tbs);
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i),
|
|
|
|
il4965_tfd_tb_get_len(tfd, i),
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il,
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_tx_queue *txq,
|
2011-02-21 19:27:26 +00:00
|
|
|
dma_addr_t addr, u16 len,
|
|
|
|
u8 reset, u8 pad)
|
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_queue *q;
|
|
|
|
struct il_tfd *tfd, *tfd_tmp;
|
2011-02-21 19:27:26 +00:00
|
|
|
u32 num_tbs;
|
|
|
|
|
|
|
|
q = &txq->q;
|
2011-10-24 13:41:30 +00:00
|
|
|
tfd_tmp = (struct il_tfd *)txq->tfds;
|
2011-02-21 19:27:26 +00:00
|
|
|
tfd = &tfd_tmp[q->write_ptr];
|
|
|
|
|
|
|
|
if (reset)
|
|
|
|
memset(tfd, 0, sizeof(*tfd));
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
num_tbs = il4965_tfd_get_num_tbs(tfd);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Each TFD can point to a maximum 20 Tx buffers */
|
2011-10-24 13:41:30 +00:00
|
|
|
if (num_tbs >= IL_NUM_OF_TBS) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Error can not send more than %d chunks\n",
|
2011-10-24 13:41:30 +00:00
|
|
|
IL_NUM_OF_TBS);
|
2011-02-21 19:27:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BUG_ON(addr & ~DMA_BIT_MASK(36));
|
2011-10-24 13:41:30 +00:00
|
|
|
if (unlikely(addr & ~IL_TX_DMA_MASK))
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Unaligned address = %llx\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
(unsigned long long)addr);
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
il4965_tfd_set_tb(tfd, num_tbs, addr, len);
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
int il4965_hw_tx_queue_init(struct il_priv *il,
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_tx_queue *txq)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
int txq_id = txq->q.id;
|
|
|
|
|
|
|
|
/* Circular buffer (TFD queue in DRAM) physical base address */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_direct32(il, FH_MEM_CBBC_QUEUE(txq_id),
|
2011-02-21 19:27:26 +00:00
|
|
|
txq->q.dma_addr >> 8);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Generic RX handler implementations
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_rx_reply_alive(struct il_priv *il,
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rx_mem_buffer *rxb)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rx_packet *pkt = rxb_addr(rxb);
|
|
|
|
struct il_alive_resp *palive;
|
2011-02-21 19:27:26 +00:00
|
|
|
struct delayed_work *pwork;
|
|
|
|
|
|
|
|
palive = &pkt->u.alive_frame;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Alive ucode status 0x%08X revision "
|
2011-02-21 19:27:26 +00:00
|
|
|
"0x%01X 0x%01X\n",
|
|
|
|
palive->is_valid, palive->ver_type,
|
|
|
|
palive->ver_subtype);
|
|
|
|
|
|
|
|
if (palive->ver_subtype == INITIALIZE_SUBTYPE) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Initialization Alive received.\n");
|
|
|
|
memcpy(&il->card_alive_init,
|
2011-02-21 19:27:26 +00:00
|
|
|
&pkt->u.alive_frame,
|
2011-10-24 13:41:30 +00:00
|
|
|
sizeof(struct il_init_alive_resp));
|
2011-10-24 14:49:25 +00:00
|
|
|
pwork = &il->init_alive_start;
|
2011-02-21 19:27:26 +00:00
|
|
|
} else {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Runtime Alive received.\n");
|
|
|
|
memcpy(&il->card_alive, &pkt->u.alive_frame,
|
2011-10-24 13:41:30 +00:00
|
|
|
sizeof(struct il_alive_resp));
|
2011-10-24 14:49:25 +00:00
|
|
|
pwork = &il->alive_start;
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* We delay the ALIVE response by 5ms to
|
|
|
|
* give the HW RF Kill time to activate... */
|
|
|
|
if (palive->is_valid == UCODE_VALID_OK)
|
2011-10-24 14:49:25 +00:00
|
|
|
queue_delayed_work(il->workqueue, pwork,
|
2011-02-21 19:27:26 +00:00
|
|
|
msecs_to_jiffies(5));
|
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_WARN(il, "uCode did not respond OK.\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 13:41:30 +00:00
|
|
|
* il4965_bg_statistics_periodic - Timer callback to queue statistics
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
static void il4965_bg_statistics_periodic(unsigned long data)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = (struct il_priv *)data;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status))
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* dont send host command if rf-kill is on */
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il_is_ready_rf(il))
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_send_statistics_request(il, CMD_ASYNC, false);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_rx_beacon_notif(struct il_priv *il,
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rx_mem_buffer *rxb)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rx_packet *pkt = rxb_addr(rxb);
|
|
|
|
struct il4965_beacon_notif *beacon =
|
|
|
|
(struct il4965_beacon_notif *)pkt->u.raw;
|
2011-02-21 19:27:26 +00:00
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
2011-10-24 13:41:30 +00:00
|
|
|
u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_RX(il, "beacon status %x retries %d iss %d "
|
2011-02-21 19:27:26 +00: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
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_perform_ct_kill_task(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_POWER(il, "Stop all queues\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->mac80211_registered)
|
|
|
|
ieee80211_stop_queues(il->hw);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write32(il, CSR_UCODE_DRV_GP1_SET,
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
|
2011-10-24 14:49:25 +00:00
|
|
|
il_read32(il, CSR_UCODE_DRV_GP1);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_lock_irqsave(&il->reg_lock, flags);
|
|
|
|
if (!il_grab_nic_access(il))
|
|
|
|
il_release_nic_access(il);
|
|
|
|
spin_unlock_irqrestore(&il->reg_lock, flags);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle notification from uCode that card's power state is changing
|
|
|
|
* due to software, hardware, or critical temperature RFKILL */
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_rx_card_state_notif(struct il_priv *il,
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rx_mem_buffer *rxb)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rx_packet *pkt = rxb_addr(rxb);
|
2011-02-21 19:27:26 +00:00
|
|
|
u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);
|
2011-10-24 14:49:25 +00:00
|
|
|
unsigned long status = il->status;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_RF_KILL(il, "Card state received: HW:%s SW:%s CT:%s\n",
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
il_write32(il, CSR_UCODE_DRV_GP1_SET,
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_direct32(il, HBUS_TARG_MBX_C,
|
2011-02-21 19:27:26 +00:00
|
|
|
HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
|
|
|
|
|
|
|
|
if (!(flags & RXON_CARD_DISABLED)) {
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write32(il, CSR_UCODE_DRV_GP1_CLR,
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_direct32(il, HBUS_TARG_MBX_C,
|
2011-02-21 19:27:26 +00:00
|
|
|
HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & CT_CARD_DISABLED)
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_perform_ct_kill_task(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
if (flags & HW_CARD_DISABLED)
|
2011-10-24 14:49:25 +00:00
|
|
|
set_bit(STATUS_RF_KILL_HW, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
clear_bit(STATUS_RF_KILL_HW, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
if (!(flags & RXON_CARD_DISABLED))
|
2011-10-24 14:49:25 +00:00
|
|
|
il_scan_cancel(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
if ((test_bit(STATUS_RF_KILL_HW, &status) !=
|
2011-10-24 14:49:25 +00:00
|
|
|
test_bit(STATUS_RF_KILL_HW, &il->status)))
|
|
|
|
wiphy_rfkill_set_hw_state(il->hw->wiphy,
|
|
|
|
test_bit(STATUS_RF_KILL_HW, &il->status));
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
wake_up(&il->wait_command_queue);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 13:41:30 +00:00
|
|
|
* il4965_setup_rx_handlers - Initialize Rx handler callbacks
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
static void il4965_setup_rx_handlers(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
il->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive;
|
|
|
|
il->rx_handlers[REPLY_ERROR] = il_rx_reply_error;
|
|
|
|
il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa;
|
|
|
|
il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] =
|
2011-10-24 13:41:30 +00:00
|
|
|
il_rx_spectrum_measure_notif;
|
2011-10-24 14:49:25 +00:00
|
|
|
il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif;
|
|
|
|
il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] =
|
2011-10-24 13:41:30 +00:00
|
|
|
il_rx_pm_debug_statistics_notif;
|
2011-10-24 14:49:25 +00:00
|
|
|
il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif;
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_statistics;
|
|
|
|
il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_statistics;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_setup_rx_scan_handlers(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* status change handler */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->rx_handlers[CARD_STATE_NOTIFICATION] =
|
2011-10-24 13:41:30 +00:00
|
|
|
il4965_rx_card_state_notif;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->rx_handlers[MISSED_BEACONS_NOTIFICATION] =
|
2011-10-24 13:41:30 +00:00
|
|
|
il4965_rx_missed_beacon_notif;
|
2011-02-21 19:27:26 +00:00
|
|
|
/* Rx handlers */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy;
|
|
|
|
il->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx;
|
2011-02-21 19:27:26 +00:00
|
|
|
/* block ack */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba;
|
2011-02-21 19:27:26 +00:00
|
|
|
/* Set up hardware specific Rx handlers */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->cfg->ops->lib->rx_handler_setup(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 13:41:30 +00:00
|
|
|
* il4965_rx_handle - Main entry function for receiving responses from uCode
|
2011-02-21 19:27:26 +00:00
|
|
|
*
|
2011-10-24 14:49:25 +00:00
|
|
|
* Uses the il->rx_handlers callback function array to invoke
|
2011-02-21 19:27:26 +00:00
|
|
|
* the appropriate handlers, including command responses,
|
|
|
|
* frame-received notifications, and other notifications.
|
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
void il4965_rx_handle(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rx_mem_buffer *rxb;
|
|
|
|
struct il_rx_packet *pkt;
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_rx_queue *rxq = &il->rxq;
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
IL_DEBUG_RX(il, "r = %d, i = %d\n", r, i);
|
2011-02-21 19:27:26 +00: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;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
pci_unmap_page(il->pci_dev, rxb->page_dma,
|
|
|
|
PAGE_SIZE << il->hw_params.rx_page_order,
|
2011-02-21 19:27:26 +00:00
|
|
|
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 13:41:30 +00:00
|
|
|
* rx_handlers table. See il4965_setup_rx_handlers() */
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->rx_handlers[pkt->hdr.cmd]) {
|
|
|
|
IL_DEBUG_RX(il, "r = %d, i = %d, %s, 0x%02x\n", r,
|
2011-10-24 13:41:30 +00:00
|
|
|
i, il_get_cmd_string(pkt->hdr.cmd),
|
2011-02-21 19:27:26 +00:00
|
|
|
pkt->hdr.cmd);
|
2011-10-24 14:49:25 +00:00
|
|
|
il->isr_stats.rx_handlers[pkt->hdr.cmd]++;
|
|
|
|
il->rx_handlers[pkt->hdr.cmd] (il, rxb);
|
2011-02-21 19:27:26 +00:00
|
|
|
} else {
|
|
|
|
/* No handling needed */
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_RX(il,
|
2011-02-21 19:27:26 +00:00
|
|
|
"r %d i %d No handler needed for %s, 0x%02x\n",
|
2011-10-24 13:41:30 +00:00
|
|
|
r, i, il_get_cmd_string(pkt->hdr.cmd),
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
* and fire off the (possibly) blocking il_send_cmd()
|
2011-02-21 19:27:26 +00:00
|
|
|
* as we reclaim the driver command queue */
|
|
|
|
if (rxb->page)
|
2011-10-24 14:49:25 +00:00
|
|
|
il_tx_cmd_complete(il, rxb);
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_WARN(il, "Claim null rxb?\n");
|
2011-02-21 19:27:26 +00: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) {
|
2011-10-24 14:49:25 +00:00
|
|
|
rxb->page_dma = pci_map_page(il->pci_dev, rxb->page,
|
|
|
|
0, PAGE_SIZE << il->hw_params.rx_page_order,
|
2011-02-21 19:27:26 +00:00
|
|
|
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 14:49:25 +00:00
|
|
|
il4965_rx_replenish_now(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
count = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Backtrack one entry */
|
|
|
|
rxq->read = i;
|
|
|
|
if (fill_rx)
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_rx_replenish_now(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_rx_queue_restock(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* call this function to flush any scheduled tasklet */
|
2011-10-24 14:49:25 +00:00
|
|
|
static inline void il4965_synchronize_irq(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
/* wait to make sure we flush pending tasklet*/
|
2011-10-24 14:49:25 +00:00
|
|
|
synchronize_irq(il->pci_dev->irq);
|
|
|
|
tasklet_kill(&il->irq_tasklet);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_irq_tasklet(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
u32 inta, handled = 0;
|
|
|
|
u32 inta_fh;
|
|
|
|
unsigned long flags;
|
|
|
|
u32 i;
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
|
|
|
u32 inta_mask;
|
|
|
|
#endif
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_lock_irqsave(&il->lock, flags);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* 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 14:49:25 +00:00
|
|
|
inta = il_read32(il, CSR_INT);
|
|
|
|
il_write32(il, CSR_INT, inta);
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
inta_fh = il_read32(il, CSR_FH_INT_STATUS);
|
|
|
|
il_write32(il, CSR_FH_INT_STATUS, inta_fh);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il_get_debug_level(il) & IL_DL_ISR) {
|
2011-02-21 19:27:26 +00:00
|
|
|
/* just for debug */
|
2011-10-24 14:49:25 +00:00
|
|
|
inta_mask = il_read32(il, CSR_INT_MASK);
|
|
|
|
IL_DEBUG_ISR(il, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
inta, inta_mask, inta_fh);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_unlock_irqrestore(&il->lock, flags);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* 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 14:49:25 +00:00
|
|
|
IL_ERR(il, "Hardware error detected. Restarting.\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Tell the device to stop sending interrupts */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_disable_interrupts(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->isr_stats.hw++;
|
|
|
|
il_irq_handle_error(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
handled |= CSR_INT_BIT_HW_ERR;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il_get_debug_level(il) & (IL_DL_ISR)) {
|
2011-02-21 19:27:26 +00:00
|
|
|
/* NIC fires this, but we don't use it, redundant with WAKEUP */
|
|
|
|
if (inta & CSR_INT_BIT_SCD) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_ISR(il, "Scheduler finished to transmit "
|
2011-02-21 19:27:26 +00:00
|
|
|
"the frame/frames.\n");
|
2011-10-24 14:49:25 +00:00
|
|
|
il->isr_stats.sch++;
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Alive notification via Rx interrupt will do the real work */
|
|
|
|
if (inta & CSR_INT_BIT_ALIVE) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_ISR(il, "Alive interrupt\n");
|
|
|
|
il->isr_stats.alive++;
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#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 14:49:25 +00:00
|
|
|
if (!(il_read32(il, CSR_GP_CNTRL) &
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
|
|
|
|
hw_rf_kill = 1;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_WARN(il, "RF_KILL bit toggled to %s.\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
hw_rf_kill ? "disable radio" : "enable radio");
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->isr_stats.rfkill++;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!test_bit(STATUS_ALIVE, &il->status)) {
|
2011-02-21 19:27:26 +00:00
|
|
|
if (hw_rf_kill)
|
2011-10-24 14:49:25 +00:00
|
|
|
set_bit(STATUS_RF_KILL_HW, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
clear_bit(STATUS_RF_KILL_HW, &il->status);
|
|
|
|
wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handled |= CSR_INT_BIT_RF_KILL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Chip got too hot and stopped itself */
|
|
|
|
if (inta & CSR_INT_BIT_CT_KILL) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Microcode CT kill error detected.\n");
|
|
|
|
il->isr_stats.ctkill++;
|
2011-02-21 19:27:26 +00:00
|
|
|
handled |= CSR_INT_BIT_CT_KILL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Error detected by uCode */
|
|
|
|
if (inta & CSR_INT_BIT_SW_ERR) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Microcode SW error detected. "
|
2011-02-21 19:27:26 +00:00
|
|
|
" Restarting 0x%X.\n", inta);
|
2011-10-24 14:49:25 +00:00
|
|
|
il->isr_stats.sw++;
|
|
|
|
il_irq_handle_error(il);
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
IL_DEBUG_ISR(il, "Wakeup interrupt\n");
|
|
|
|
il_rx_queue_update_write_ptr(il, &il->rxq);
|
|
|
|
for (i = 0; i < il->hw_params.max_txq_num; i++)
|
|
|
|
il_txq_update_write_ptr(il, &il->txq[i]);
|
|
|
|
il->isr_stats.wakeup++;
|
2011-02-21 19:27:26 +00:00
|
|
|
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 14:49:25 +00:00
|
|
|
il4965_rx_handle(il);
|
|
|
|
il->isr_stats.rx++;
|
2011-02-21 19:27:26 +00:00
|
|
|
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 14:49:25 +00:00
|
|
|
IL_DEBUG_ISR(il, "uCode load interrupt\n");
|
|
|
|
il->isr_stats.tx++;
|
2011-02-21 19:27:26 +00:00
|
|
|
handled |= CSR_INT_BIT_FH_TX;
|
|
|
|
/* Wake up uCode load routine, now that load is complete */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->ucode_write_complete = 1;
|
|
|
|
wake_up(&il->wait_command_queue);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (inta & ~handled) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Unhandled INTA bits 0x%08x\n", inta & ~handled);
|
|
|
|
il->isr_stats.unhandled++;
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (inta & ~(il->inta_mask)) {
|
|
|
|
IL_WARN(il, "Disabled INTA bits 0x%08x were pending\n",
|
|
|
|
inta & ~il->inta_mask);
|
|
|
|
IL_WARN(il, " with FH_INT = 0x%08x\n", inta_fh);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Re-enable all interrupts */
|
2011-04-28 09:51:30 +00:00
|
|
|
/* only Re-enable if disabled by irq */
|
2011-10-24 14:49:25 +00:00
|
|
|
if (test_bit(STATUS_INT_ENABLED, &il->status))
|
|
|
|
il_enable_interrupts(il);
|
2011-04-28 09:51:25 +00:00
|
|
|
/* Re-enable RF_KILL if it occurred */
|
|
|
|
else if (handled & CSR_INT_BIT_RF_KILL)
|
2011-10-24 14:49:25 +00:00
|
|
|
il_enable_rfkill_int(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il_get_debug_level(il) & (IL_DL_ISR)) {
|
|
|
|
inta = il_read32(il, CSR_INT);
|
|
|
|
inta_mask = il_read32(il, CSR_INT_MASK);
|
|
|
|
inta_fh = il_read32(il, CSR_FH_INT_STATUS);
|
|
|
|
IL_DEBUG_ISR(il,
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
static ssize_t il4965_show_debug_level(struct device *d,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = dev_get_drvdata(d);
|
|
|
|
return sprintf(buf, "0x%08X\n", il_get_debug_level(il));
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
2011-10-24 13:41:30 +00:00
|
|
|
static ssize_t il4965_store_debug_level(struct device *d,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = dev_get_drvdata(d);
|
2011-02-21 19:27:26 +00:00
|
|
|
unsigned long val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = strict_strtoul(buf, 0, &val);
|
|
|
|
if (ret)
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "%s is not in hex or decimal form.\n", buf);
|
2011-02-21 19:27:26 +00:00
|
|
|
else {
|
2011-10-24 14:49:25 +00:00
|
|
|
il->debug_level = val;
|
|
|
|
if (il_alloc_traffic_mem(il))
|
|
|
|
IL_ERR(il,
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
il4965_show_debug_level, il4965_store_debug_level);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */
|
|
|
|
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static ssize_t il4965_show_temperature(struct device *d,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = dev_get_drvdata(d);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il_is_alive(il))
|
2011-02-21 19:27:26 +00:00
|
|
|
return -EAGAIN;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
return sprintf(buf, "%d\n", il->temperature);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static ssize_t il4965_show_tx_power(struct device *d,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = dev_get_drvdata(d);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il_is_ready_rf(il))
|
2011-02-21 19:27:26 +00:00
|
|
|
return sprintf(buf, "off\n");
|
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
return sprintf(buf, "%d\n", il->tx_power_user_lmt);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static ssize_t il4965_store_tx_power(struct device *d,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = dev_get_drvdata(d);
|
2011-02-21 19:27:26 +00:00
|
|
|
unsigned long val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = strict_strtoul(buf, 10, &val);
|
|
|
|
if (ret)
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_INFO(il, "%s is not in decimal form.\n", buf);
|
2011-02-21 19:27:26 +00:00
|
|
|
else {
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il_set_tx_power(il, val, false);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (ret)
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "failed setting tx power (0x%d).\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
ret);
|
|
|
|
else
|
|
|
|
ret = count;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO,
|
2011-10-24 13:41:30 +00:00
|
|
|
il4965_show_tx_power, il4965_store_tx_power);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static struct attribute *il_sysfs_entries[] = {
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
static struct attribute_group il_attribute_group = {
|
2011-02-21 19:27:26 +00:00
|
|
|
.name = NULL, /* put in device directory */
|
2011-10-24 13:41:30 +00:00
|
|
|
.attrs = il_sysfs_entries,
|
2011-02-21 19:27:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* uCode download functions
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_dealloc_ucode_pci(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
il_free_fw_desc(il->pci_dev, &il->ucode_code);
|
|
|
|
il_free_fw_desc(il->pci_dev, &il->ucode_data);
|
|
|
|
il_free_fw_desc(il->pci_dev, &il->ucode_data_backup);
|
|
|
|
il_free_fw_desc(il->pci_dev, &il->ucode_init);
|
|
|
|
il_free_fw_desc(il->pci_dev, &il->ucode_init_data);
|
|
|
|
il_free_fw_desc(il->pci_dev, &il->ucode_boot);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_nic_start(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
/* Remove all resets to allow NIC to operate */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write32(il, CSR_RESET, 0);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static void il4965_ucode_callback(const struct firmware *ucode_raw,
|
2011-02-21 19:27:26 +00:00
|
|
|
void *context);
|
2011-10-24 14:49:25 +00:00
|
|
|
static int il4965_mac_setup_register(struct il_priv *il,
|
2011-02-21 19:27:26 +00:00
|
|
|
u32 max_probe_length);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static int __must_check il4965_request_firmware(struct il_priv *il, bool first)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
const char *name_pre = il->cfg->fw_name_pre;
|
2011-02-21 19:27:26 +00:00
|
|
|
char tag[8];
|
|
|
|
|
|
|
|
if (first) {
|
2011-10-24 14:49:25 +00:00
|
|
|
il->fw_index = il->cfg->ucode_api_max;
|
|
|
|
sprintf(tag, "%d", il->fw_index);
|
2011-02-21 19:27:26 +00:00
|
|
|
} else {
|
2011-10-24 14:49:25 +00:00
|
|
|
il->fw_index--;
|
|
|
|
sprintf(tag, "%d", il->fw_index);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->fw_index < il->cfg->ucode_api_min) {
|
|
|
|
IL_ERR(il, "no suitable firmware found!\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "attempting to load firmware '%s'\n",
|
|
|
|
il->firmware_name);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name,
|
|
|
|
&il->pci_dev->dev, GFP_KERNEL, il,
|
2011-10-24 13:41:30 +00:00
|
|
|
il4965_ucode_callback);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il4965_firmware_pieces {
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
static int il4965_load_firmware(struct il_priv *il,
|
2011-02-21 19:27:26 +00:00
|
|
|
const struct firmware *ucode_raw,
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il4965_firmware_pieces *pieces)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_ucode_header *ucode = (void *)ucode_raw->data;
|
2011-02-21 19:27:26 +00:00
|
|
|
u32 api_ver, hdr_size;
|
|
|
|
const u8 *src;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->ucode_ver = le32_to_cpu(ucode->ver);
|
|
|
|
api_ver = IL_UCODE_API(il->ucode_ver);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
switch (api_ver) {
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
hdr_size = 24;
|
|
|
|
if (ucode_raw->size < hdr_size) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "File size too small!\n");
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
IL_ERR(il,
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
* il4965_ucode_callback - callback when firmware was loaded
|
2011-02-21 19:27:26 +00:00
|
|
|
*
|
|
|
|
* If loaded successfully, copies the firmware into buffers
|
|
|
|
* for the card to fetch (via DMA).
|
|
|
|
*/
|
|
|
|
static void
|
2011-10-24 13:41:30 +00:00
|
|
|
il4965_ucode_callback(const struct firmware *ucode_raw, void *context)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = context;
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_ucode_header *ucode;
|
2011-02-21 19:27:26 +00:00
|
|
|
int err;
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il4965_firmware_pieces pieces;
|
2011-10-24 14:49:25 +00:00
|
|
|
const unsigned int api_max = il->cfg->ucode_api_max;
|
|
|
|
const unsigned int api_min = il->cfg->ucode_api_min;
|
2011-02-21 19:27:26 +00:00
|
|
|
u32 api_ver;
|
|
|
|
|
|
|
|
u32 max_probe_length = 200;
|
|
|
|
u32 standard_phy_calibration_size =
|
2011-10-24 13:41:30 +00:00
|
|
|
IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
memset(&pieces, 0, sizeof(pieces));
|
|
|
|
|
|
|
|
if (!ucode_raw) {
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->fw_index <= il->cfg->ucode_api_max)
|
|
|
|
IL_ERR(il,
|
2011-02-21 19:27:26 +00:00
|
|
|
"request for firmware file '%s' failed.\n",
|
2011-10-24 14:49:25 +00:00
|
|
|
il->firmware_name);
|
2011-02-21 19:27:26 +00:00
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Loaded firmware file '%s' (%zd bytes).\n",
|
|
|
|
il->firmware_name, ucode_raw->size);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Make sure that we got at least the API version number */
|
|
|
|
if (ucode_raw->size < 4) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "File size way too small!\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Data from ucode file: header followed by uCode images */
|
2011-10-24 13:41:30 +00:00
|
|
|
ucode = (struct il_ucode_header *)ucode_raw->data;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
err = il4965_load_firmware(il, ucode_raw, &pieces);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto try_again;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
api_ver = IL_UCODE_API(il->ucode_ver);
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
IL_ERR(il,
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
IL_ERR(il,
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
IL_INFO(il, "loaded firmware version %u.%u.%u.%u\n",
|
|
|
|
IL_UCODE_MAJOR(il->ucode_ver),
|
|
|
|
IL_UCODE_MINOR(il->ucode_ver),
|
|
|
|
IL_UCODE_API(il->ucode_ver),
|
|
|
|
IL_UCODE_SERIAL(il->ucode_ver));
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
snprintf(il->hw->wiphy->fw_version,
|
|
|
|
sizeof(il->hw->wiphy->fw_version),
|
2011-02-21 19:27:26 +00:00
|
|
|
"%u.%u.%u.%u",
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_UCODE_MAJOR(il->ucode_ver),
|
|
|
|
IL_UCODE_MINOR(il->ucode_ver),
|
|
|
|
IL_UCODE_API(il->ucode_ver),
|
|
|
|
IL_UCODE_SERIAL(il->ucode_ver));
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "f/w package hdr ucode version raw = 0x%x\n",
|
|
|
|
il->ucode_ver);
|
|
|
|
IL_DEBUG_INFO(il, "f/w package hdr runtime inst size = %Zd\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.inst_size);
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "f/w package hdr runtime data size = %Zd\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.data_size);
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "f/w package hdr init inst size = %Zd\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.init_size);
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "f/w package hdr init data size = %Zd\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.init_data_size);
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "f/w package hdr boot inst size = %Zd\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.boot_size);
|
|
|
|
|
|
|
|
/* Verify that uCode images will fit in card's SRAM */
|
2011-10-24 14:49:25 +00:00
|
|
|
if (pieces.inst_size > il->hw_params.max_inst_size) {
|
|
|
|
IL_ERR(il, "uCode instr len %Zd too large to fit in\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.inst_size);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (pieces.data_size > il->hw_params.max_data_size) {
|
|
|
|
IL_ERR(il, "uCode data len %Zd too large to fit in\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.data_size);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (pieces.init_size > il->hw_params.max_inst_size) {
|
|
|
|
IL_ERR(il, "uCode init instr len %Zd too large to fit in\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.init_size);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (pieces.init_data_size > il->hw_params.max_data_size) {
|
|
|
|
IL_ERR(il, "uCode init data len %Zd too large to fit in\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.init_data_size);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (pieces.boot_size > il->hw_params.max_bsm_size) {
|
|
|
|
IL_ERR(il, "uCode boot instr len %Zd too large to fit in\n",
|
2011-02-21 19:27:26 +00: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 */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->ucode_code.len = pieces.inst_size;
|
|
|
|
il_alloc_fw_desc(il->pci_dev, &il->ucode_code);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->ucode_data.len = pieces.data_size;
|
|
|
|
il_alloc_fw_desc(il->pci_dev, &il->ucode_data);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->ucode_data_backup.len = pieces.data_size;
|
|
|
|
il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il->ucode_code.v_addr || !il->ucode_data.v_addr ||
|
|
|
|
!il->ucode_data_backup.v_addr)
|
2011-02-21 19:27:26 +00:00
|
|
|
goto err_pci_alloc;
|
|
|
|
|
|
|
|
/* Initialization instructions and data */
|
|
|
|
if (pieces.init_size && pieces.init_data_size) {
|
2011-10-24 14:49:25 +00:00
|
|
|
il->ucode_init.len = pieces.init_size;
|
|
|
|
il_alloc_fw_desc(il->pci_dev, &il->ucode_init);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->ucode_init_data.len = pieces.init_data_size;
|
|
|
|
il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr)
|
2011-02-21 19:27:26 +00:00
|
|
|
goto err_pci_alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Bootstrap (instructions only, no data) */
|
|
|
|
if (pieces.boot_size) {
|
2011-10-24 14:49:25 +00:00
|
|
|
il->ucode_boot.len = pieces.boot_size;
|
|
|
|
il_alloc_fw_desc(il->pci_dev, &il->ucode_boot);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il->ucode_boot.v_addr)
|
2011-02-21 19:27:26 +00:00
|
|
|
goto err_pci_alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now that we can no longer fail, copy information */
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->sta_key_max_num = STA_KEY_MAX_NUM;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Copy images into buffers for card's bus-master reads ... */
|
|
|
|
|
|
|
|
/* Runtime instructions (first block of data in file) */
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Copying (but not loading) uCode instr len %Zd\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.inst_size);
|
2011-10-24 14:49:25 +00:00
|
|
|
memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n",
|
|
|
|
il->ucode_code.v_addr, (u32)il->ucode_code.p_addr);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Runtime data
|
2011-10-24 13:41:30 +00:00
|
|
|
* NOTE: Copy into backup buffer will be done in il_up()
|
2011-02-21 19:27:26 +00:00
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Copying (but not loading) uCode data len %Zd\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.data_size);
|
2011-10-24 14:49:25 +00:00
|
|
|
memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size);
|
|
|
|
memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Initialization instructions */
|
|
|
|
if (pieces.init_size) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il,
|
2011-02-21 19:27:26 +00:00
|
|
|
"Copying (but not loading) init instr len %Zd\n",
|
|
|
|
pieces.init_size);
|
2011-10-24 14:49:25 +00:00
|
|
|
memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialization data */
|
|
|
|
if (pieces.init_data_size) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il,
|
2011-02-21 19:27:26 +00:00
|
|
|
"Copying (but not loading) init data len %Zd\n",
|
|
|
|
pieces.init_data_size);
|
2011-10-24 14:49:25 +00:00
|
|
|
memcpy(il->ucode_init_data.v_addr, pieces.init_data,
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.init_data_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Bootstrap instructions */
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Copying (but not loading) boot instr len %Zd\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pieces.boot_size);
|
2011-10-24 14:49:25 +00:00
|
|
|
memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* figure out the offset of chain noise reset and gain commands
|
|
|
|
* base on the size of standard phy calibration commands table size
|
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
il->_4965.phy_calib_chain_noise_reset_cmd =
|
2011-02-21 19:27:26 +00:00
|
|
|
standard_phy_calibration_size;
|
2011-10-24 14:49:25 +00:00
|
|
|
il->_4965.phy_calib_chain_noise_gain_cmd =
|
2011-02-21 19:27:26 +00:00
|
|
|
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 14:49:25 +00:00
|
|
|
err = il4965_mac_setup_register(il, max_probe_length);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (err)
|
|
|
|
goto out_unbind;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
err = il_dbgfs_register(il, DRV_NAME);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (err)
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il,
|
2011-02-21 19:27:26 +00:00
|
|
|
"failed to create debugfs files. Ignoring error: %d\n", err);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
err = sysfs_create_group(&il->pci_dev->dev.kobj,
|
2011-10-24 13:41:30 +00:00
|
|
|
&il_attribute_group);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (err) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "failed to create sysfs device attributes\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
goto out_unbind;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have our copies now, allow OS release its copies */
|
|
|
|
release_firmware(ucode_raw);
|
2011-10-24 14:49:25 +00:00
|
|
|
complete(&il->_4965.firmware_loading_complete);
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
try_again:
|
|
|
|
/* try next, if any */
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il4965_request_firmware(il, false))
|
2011-02-21 19:27:26 +00:00
|
|
|
goto out_unbind;
|
|
|
|
release_firmware(ucode_raw);
|
|
|
|
return;
|
|
|
|
|
|
|
|
err_pci_alloc:
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "failed to allocate pci memory\n");
|
|
|
|
il4965_dealloc_ucode_pci(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
out_unbind:
|
2011-10-24 14:49:25 +00:00
|
|
|
complete(&il->_4965.firmware_loading_complete);
|
|
|
|
device_release_driver(&il->pci_dev->dev);
|
2011-02-21 19:27:26 +00:00
|
|
|
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 06:20:24 +00:00
|
|
|
"NMI_INTERRUPT_BREAK_POINT",
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
static const char *il4965_desc_lookup(u32 num)
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
void il4965_dump_nic_error_log(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
u32 data2, line;
|
|
|
|
u32 desc, time, count, base, data1;
|
|
|
|
u32 blink1, blink2, ilink1, ilink2;
|
|
|
|
u32 pc, hcmd;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->ucode_type == UCODE_INIT) {
|
|
|
|
base = le32_to_cpu(il->card_alive_init.error_event_table_ptr);
|
2011-02-21 19:27:26 +00:00
|
|
|
} else {
|
2011-10-24 14:49:25 +00:00
|
|
|
base = le32_to_cpu(il->card_alive.error_event_table_ptr);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) {
|
|
|
|
IL_ERR(il,
|
2011-02-21 19:27:26 +00:00
|
|
|
"Not valid error log pointer 0x%08X for %s uCode\n",
|
2011-10-24 14:49:25 +00:00
|
|
|
base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT");
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
count = il_read_targ_mem(il, base);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Start IWL Error Log Dump:\n");
|
|
|
|
IL_ERR(il, "Status: 0x%08lX, count: %d\n",
|
|
|
|
il->status, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
desc = il_read_targ_mem(il, base + 1 * sizeof(u32));
|
|
|
|
il->isr_stats.err_code = desc;
|
|
|
|
pc = il_read_targ_mem(il, base + 2 * sizeof(u32));
|
|
|
|
blink1 = il_read_targ_mem(il, base + 3 * sizeof(u32));
|
|
|
|
blink2 = il_read_targ_mem(il, base + 4 * sizeof(u32));
|
|
|
|
ilink1 = il_read_targ_mem(il, base + 5 * sizeof(u32));
|
|
|
|
ilink2 = il_read_targ_mem(il, base + 6 * sizeof(u32));
|
|
|
|
data1 = il_read_targ_mem(il, base + 7 * sizeof(u32));
|
|
|
|
data2 = il_read_targ_mem(il, base + 8 * sizeof(u32));
|
|
|
|
line = il_read_targ_mem(il, base + 9 * sizeof(u32));
|
|
|
|
time = il_read_targ_mem(il, base + 11 * sizeof(u32));
|
|
|
|
hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32));
|
|
|
|
|
|
|
|
IL_ERR(il, "Desc Time "
|
2011-02-21 19:27:26 +00:00
|
|
|
"data1 data2 line\n");
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n",
|
2011-10-24 13:41:30 +00:00
|
|
|
il4965_desc_lookup(desc), desc, time, data1, data2, line);
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "pc blink1 blink2 ilink1 ilink2 hcmd\n");
|
|
|
|
IL_ERR(il, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
pc, blink1, blink2, ilink1, ilink2, hcmd);
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_rf_kill_ct_config(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_ct_kill_config cmd;
|
2011-02-21 19:27:26 +00:00
|
|
|
unsigned long flags;
|
|
|
|
int ret = 0;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_lock_irqsave(&il->lock, flags);
|
|
|
|
il_write32(il, CSR_UCODE_DRV_GP1_CLR,
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_unlock_irqrestore(&il->lock, flags);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
cmd.critical_temperature_R =
|
2011-10-24 14:49:25 +00:00
|
|
|
cpu_to_le32(il->hw_params.ct_kill_threshold);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD,
|
2011-02-21 19:27:26 +00:00
|
|
|
sizeof(cmd), &cmd);
|
|
|
|
if (ret)
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "REPLY_CT_KILL_CONFIG_CMD failed\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "REPLY_CT_KILL_CONFIG_CMD "
|
2011-02-21 19:27:26 +00:00
|
|
|
"succeeded, "
|
|
|
|
"critical temperature is %d\n",
|
2011-10-24 14:49:25 +00:00
|
|
|
il->hw_params.ct_kill_threshold);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const s8 default_queue_to_tx_fifo[] = {
|
2011-10-24 13:41:30 +00:00
|
|
|
IL_TX_FIFO_VO,
|
|
|
|
IL_TX_FIFO_VI,
|
|
|
|
IL_TX_FIFO_BE,
|
|
|
|
IL_TX_FIFO_BK,
|
2011-02-21 19:27:26 +00:00
|
|
|
IWL49_CMD_FIFO_NUM,
|
2011-10-24 13:41:30 +00:00
|
|
|
IL_TX_FIFO_UNUSED,
|
|
|
|
IL_TX_FIFO_UNUSED,
|
2011-02-21 19:27:26 +00:00
|
|
|
};
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static int il4965_alive_notify(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
u32 a;
|
|
|
|
unsigned long flags;
|
|
|
|
int i, chan;
|
|
|
|
u32 reg_val;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_lock_irqsave(&il->lock, flags);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Clear 4965's internal Tx Scheduler data base */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->scd_base_addr = il_read_prph(il,
|
2011-02-21 19:27:26 +00:00
|
|
|
IWL49_SCD_SRAM_BASE_ADDR);
|
2011-10-24 14:49:25 +00:00
|
|
|
a = il->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET;
|
|
|
|
for (; a < il->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4)
|
|
|
|
il_write_targ_mem(il, a, 0);
|
|
|
|
for (; a < il->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4)
|
|
|
|
il_write_targ_mem(il, a, 0);
|
|
|
|
for (; a < il->scd_base_addr +
|
|
|
|
IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4)
|
|
|
|
il_write_targ_mem(il, a, 0);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Tel 4965 where to find Tx byte count tables */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_prph(il, IWL49_SCD_DRAM_BASE_ADDR,
|
|
|
|
il->scd_bc_tbls.dma >> 10);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Enable DMA channel */
|
|
|
|
for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++)
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_direct32(il,
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
reg_val = il_read_direct32(il, FH_TX_CHICKEN_BITS_REG);
|
|
|
|
il_write_direct32(il, FH_TX_CHICKEN_BITS_REG,
|
2011-02-21 19:27:26 +00:00
|
|
|
reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
|
|
|
|
|
|
|
|
/* Disable chain mode for all queues */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_prph(il, IWL49_SCD_QUEUECHAIN_SEL, 0);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Initialize each Tx queue (including the command queue) */
|
2011-10-24 14:49:25 +00:00
|
|
|
for (i = 0; i < il->hw_params.max_txq_num; i++) {
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* TFD circular buffer read/write indexes */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0);
|
|
|
|
il_write_direct32(il, HBUS_TARG_WRPTR, 0 | (i << 8));
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Max Tx Window size for Scheduler-ACK mode */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_targ_mem(il, il->scd_base_addr +
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
il_write_targ_mem(il, il->scd_base_addr +
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
il_write_prph(il, IWL49_SCD_INTERRUPT_MASK,
|
|
|
|
(1 << il->hw_params.max_txq_num) - 1);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Activate all Tx DMA/FIFO channels */
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_txq_set_sched(il, IL_MASK(0, 6));
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_set_wr_ptrs(il, IL_DEFAULT_CMD_QUEUE_NUM, 0);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* make sure all queue are not stopped */
|
2011-10-24 14:49:25 +00:00
|
|
|
memset(&il->queue_stopped[0], 0, sizeof(il->queue_stopped));
|
2011-02-21 19:27:26 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2011-10-24 14:49:25 +00:00
|
|
|
atomic_set(&il->queue_stop_count[i], 0);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* reset to 0 to enable all the queue first */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->txq_ctx_active_msk = 0;
|
2011-02-21 19:27:26 +00:00
|
|
|
/* 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 14:49:25 +00:00
|
|
|
il_txq_ctx_activate(il, i);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
if (ac == IL_TX_FIFO_UNUSED)
|
2011-02-21 19:27:26 +00:00
|
|
|
continue;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_tx_queue_set_status(il, &il->txq[i], ac, 0);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_unlock_irqrestore(&il->lock, flags);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-24 13:41:30 +00:00
|
|
|
* il4965_alive_start - called after REPLY_ALIVE notification received
|
2011-02-21 19:27:26 +00:00
|
|
|
* from protocol/runtime uCode (initialization uCode's
|
2011-10-24 13:41:30 +00:00
|
|
|
* Alive gets handled by il_init_alive_start()).
|
2011-02-21 19:27:26 +00:00
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_alive_start(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Runtime Alive received.\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->card_alive.is_valid != UCODE_VALID_OK) {
|
2011-02-21 19:27:26 +00:00
|
|
|
/* We had an error bringing up the hardware, so take it
|
|
|
|
* all the way back down so we can try again */
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Alive failed.\n");
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
if (il4965_verify_ucode(il)) {
|
2011-02-21 19:27:26 +00:00
|
|
|
/* Runtime instruction load was bad;
|
|
|
|
* take it all the way back down so we can try again */
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Bad runtime uCode load.\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il4965_alive_notify(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (ret) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_WARN(il,
|
2011-02-21 19:27:26 +00:00
|
|
|
"Could not complete ALIVE transition [ntf]: %d\n", ret);
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* After the ALIVE response, we can send host commands to the uCode */
|
2011-10-24 14:49:25 +00:00
|
|
|
set_bit(STATUS_ALIVE, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Enable watchdog to monitor the driver tx queues */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_setup_watchdog(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il_is_rfkill(il))
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ieee80211_wake_queues(il->hw);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->active_rate = IL_RATES_MASK;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
if (il_is_associated_ctx(ctx)) {
|
|
|
|
struct il_rxon_cmd *active_rxon =
|
|
|
|
(struct il_rxon_cmd *)&ctx->active;
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
struct il_rxon_context *tmp;
|
2011-02-21 19:27:26 +00:00
|
|
|
/* Initialize our rx_config data */
|
2011-10-24 14:49:25 +00:00
|
|
|
for_each_context(il, tmp)
|
|
|
|
il_connection_init_rx_config(il, tmp);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->cfg->ops->hcmd->set_rxon_chain)
|
|
|
|
il->cfg->ops->hcmd->set_rxon_chain(il, ctx);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Configure bluetooth coexistence if enabled */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_send_bt_config(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_reset_run_time_calib(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
set_bit(STATUS_READY, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Configure the adapter for unassociated operation */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_commit_rxon(il, ctx);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* At this point, the NIC is initialized and operational */
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_rf_kill_ct_config(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "ALIVE processing complete.\n");
|
|
|
|
wake_up(&il->wait_command_queue);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_power_update_mode(il, true);
|
|
|
|
IL_DEBUG_INFO(il, "Updated power mode\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
restart:
|
2011-10-24 14:49:25 +00:00
|
|
|
queue_work(il->workqueue, &il->restart);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_cancel_deferred_work(struct il_priv *il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void __il4965_down(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
2011-04-28 09:51:24 +00:00
|
|
|
int exit_pending;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, DRV_NAME " is going down\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_scan_cancel_timeout(il, 200);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set
|
|
|
|
* to prevent rearm timer */
|
2011-10-24 14:49:25 +00:00
|
|
|
del_timer_sync(&il->watchdog);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_clear_ucode_stations(il, NULL);
|
|
|
|
il_dealloc_bcast_stations(il);
|
|
|
|
il_clear_driver_stations(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Unblock any waiting calls */
|
2011-10-24 14:49:25 +00:00
|
|
|
wake_up_all(&il->wait_command_queue);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Wipe out the EXIT_PENDING status bit if we are not actually
|
|
|
|
* exiting the module */
|
|
|
|
if (!exit_pending)
|
2011-10-24 14:49:25 +00:00
|
|
|
clear_bit(STATUS_EXIT_PENDING, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* stop and reset the on-board processor */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* tell the device to stop sending interrupts */
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_lock_irqsave(&il->lock, flags);
|
|
|
|
il_disable_interrupts(il);
|
|
|
|
spin_unlock_irqrestore(&il->lock, flags);
|
|
|
|
il4965_synchronize_irq(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->mac80211_registered)
|
|
|
|
ieee80211_stop_queues(il->hw);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
/* If we have not previously called il_init() then
|
2011-02-21 19:27:26 +00:00
|
|
|
* clear all bits but the RF Kill bit and return */
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il_is_init(il)) {
|
|
|
|
il->status = test_bit(STATUS_RF_KILL_HW, &il->status) <<
|
2011-02-21 19:27:26 +00:00
|
|
|
STATUS_RF_KILL_HW |
|
2011-10-24 14:49:25 +00:00
|
|
|
test_bit(STATUS_GEO_CONFIGURED, &il->status) <<
|
2011-02-21 19:27:26 +00:00
|
|
|
STATUS_GEO_CONFIGURED |
|
2011-10-24 14:49:25 +00:00
|
|
|
test_bit(STATUS_EXIT_PENDING, &il->status) <<
|
2011-02-21 19:27:26 +00:00
|
|
|
STATUS_EXIT_PENDING;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ...otherwise clear out all the status bits but the RF Kill
|
|
|
|
* bit and continue taking the NIC down. */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) <<
|
2011-02-21 19:27:26 +00:00
|
|
|
STATUS_RF_KILL_HW |
|
2011-10-24 14:49:25 +00:00
|
|
|
test_bit(STATUS_GEO_CONFIGURED, &il->status) <<
|
2011-02-21 19:27:26 +00:00
|
|
|
STATUS_GEO_CONFIGURED |
|
2011-10-24 14:49:25 +00:00
|
|
|
test_bit(STATUS_FW_ERROR, &il->status) <<
|
2011-02-21 19:27:26 +00:00
|
|
|
STATUS_FW_ERROR |
|
2011-10-24 14:49:25 +00:00
|
|
|
test_bit(STATUS_EXIT_PENDING, &il->status) <<
|
2011-02-21 19:27:26 +00:00
|
|
|
STATUS_EXIT_PENDING;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_txq_ctx_stop(il);
|
|
|
|
il4965_rxq_stop(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Power-down device's busmaster DMA clocks */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT);
|
2011-02-21 19:27:26 +00:00
|
|
|
udelay(5);
|
|
|
|
|
|
|
|
/* Make sure (redundant) we've released our request to stay awake */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_clear_bit(il, CSR_GP_CNTRL,
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
|
|
|
|
|
|
|
|
/* Stop the device, and put it in low power state */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_apm_stop(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
exit:
|
2011-10-24 14:49:25 +00:00
|
|
|
memset(&il->card_alive, 0, sizeof(struct il_alive_resp));
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
dev_kfree_skb(il->beacon_skb);
|
|
|
|
il->beacon_skb = NULL;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* clear out any free frames */
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_clear_free_frames(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_down(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
|
|
|
__il4965_down(il);
|
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_cancel_deferred_work(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define HW_READY_TIMEOUT (50)
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static int il4965_set_hw_ready(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_set_bit(il, CSR_HW_IF_CONFIG_REG,
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_HW_IF_CONFIG_REG_BIT_NIC_READY);
|
|
|
|
|
|
|
|
/* See if we got it */
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG,
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_HW_IF_CONFIG_REG_BIT_NIC_READY,
|
|
|
|
CSR_HW_IF_CONFIG_REG_BIT_NIC_READY,
|
|
|
|
HW_READY_TIMEOUT);
|
|
|
|
if (ret != -ETIMEDOUT)
|
2011-10-24 14:49:25 +00:00
|
|
|
il->hw_ready = true;
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
il->hw_ready = false;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "hardware %s\n",
|
|
|
|
(il->hw_ready == 1) ? "ready" : "not ready");
|
2011-02-21 19:27:26 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static int il4965_prepare_card_hw(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "il4965_prepare_card_hw enter\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il4965_set_hw_ready(il);
|
|
|
|
if (il->hw_ready)
|
2011-02-21 19:27:26 +00:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* If HW is not ready, prepare the conditions to check again */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_set_bit(il, CSR_HW_IF_CONFIG_REG,
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_HW_IF_CONFIG_REG_PREPARE);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG,
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
il4965_set_hw_ready(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_HW_RESTARTS 5
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static int __il4965_up(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rxon_context *ctx;
|
2011-02-21 19:27:26 +00:00
|
|
|
int i;
|
|
|
|
int ret;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status)) {
|
|
|
|
IL_WARN(il, "Exit pending; will not bring the NIC up\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) {
|
|
|
|
IL_ERR(il, "ucode not available for device bringup\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
for_each_context(il, ctx) {
|
|
|
|
ret = il4965_alloc_bcast_station(il, ctx);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (ret) {
|
2011-10-24 14:49:25 +00:00
|
|
|
il_dealloc_bcast_stations(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_prepare_card_hw(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il->hw_ready) {
|
|
|
|
IL_WARN(il, "Exit HW not ready\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If platform's RF_KILL switch is NOT set to KILL */
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il_read32(il,
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
|
2011-10-24 14:49:25 +00:00
|
|
|
clear_bit(STATUS_RF_KILL_HW, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
set_bit(STATUS_RF_KILL_HW, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il_is_rfkill(il)) {
|
|
|
|
wiphy_rfkill_set_hw_state(il->hw->wiphy, true);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_enable_interrupts(il);
|
|
|
|
IL_WARN(il, "Radio disabled by HW RF Kill switch\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write32(il, CSR_INT, 0xFFFFFFFF);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
/* must be initialised before il_hw_nic_init */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il4965_hw_nic_init(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (ret) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Unable to init nic\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure rfkill handshake bits are cleared */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
|
|
|
|
il_write32(il, CSR_UCODE_DRV_GP1_CLR,
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
|
|
|
|
|
|
|
|
/* clear (again), then enable host interrupts */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write32(il, CSR_INT, 0xFFFFFFFF);
|
|
|
|
il_enable_interrupts(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* really make sure rfkill handshake bits are cleared */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
|
|
|
|
il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
|
2011-02-21 19:27:26 +00: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. */
|
2011-10-24 14:49:25 +00:00
|
|
|
memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr,
|
|
|
|
il->ucode_data.len);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
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 */
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il->cfg->ops->lib->load_ucode(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
if (ret) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Unable to set up bootstrap uCode: %d\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
ret);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start card; "initialize" will load runtime ucode */
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_nic_start(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, DRV_NAME " is coming up\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
set_bit(STATUS_EXIT_PENDING, &il->status);
|
|
|
|
__il4965_down(il);
|
|
|
|
clear_bit(STATUS_EXIT_PENDING, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* tried to restart and config the device for as long as our
|
|
|
|
* patience could withstand */
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Unable to initialize device after %d attempts.\n", i);
|
2011-02-21 19:27:26 +00:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* Workqueue callbacks
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static void il4965_bg_init_alive_start(struct work_struct *data)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il =
|
2011-10-24 13:41:30 +00:00
|
|
|
container_of(data, struct il_priv, init_alive_start.work);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status))
|
2011-04-28 09:51:32 +00:00
|
|
|
goto out;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->cfg->ops->lib->init_alive_start(il);
|
2011-04-28 09:51:32 +00:00
|
|
|
out:
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static void il4965_bg_alive_start(struct work_struct *data)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il =
|
2011-10-24 13:41:30 +00:00
|
|
|
container_of(data, struct il_priv, alive_start.work);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status))
|
2011-04-28 09:51:32 +00:00
|
|
|
goto out;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_alive_start(il);
|
2011-04-28 09:51:32 +00:00
|
|
|
out:
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static void il4965_bg_run_time_calib_work(struct work_struct *work)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = container_of(work, struct il_priv,
|
2011-02-21 19:27:26 +00:00
|
|
|
run_time_calib_work);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status) ||
|
|
|
|
test_bit(STATUS_SCANNING, &il->status)) {
|
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->start_calib) {
|
|
|
|
il4965_chain_noise_calibration(il,
|
|
|
|
(void *)&il->_4965.statistics);
|
|
|
|
il4965_sensitivity_calibration(il,
|
|
|
|
(void *)&il->_4965.statistics);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static void il4965_bg_restart(struct work_struct *data)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = container_of(data, struct il_priv, restart);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status))
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) {
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rxon_context *ctx;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
|
|
|
for_each_context(il, ctx)
|
2011-02-21 19:27:26 +00:00
|
|
|
ctx->vif = NULL;
|
2011-10-24 14:49:25 +00:00
|
|
|
il->is_open = 0;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
__il4965_down(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_unlock(&il->mutex);
|
|
|
|
il4965_cancel_deferred_work(il);
|
|
|
|
ieee80211_restart_hw(il->hw);
|
2011-02-21 19:27:26 +00:00
|
|
|
} else {
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_down(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status)) {
|
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
2011-04-28 09:51:32 +00:00
|
|
|
}
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
__il4965_up(il);
|
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static void il4965_bg_rx_replenish(struct work_struct *data)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il =
|
2011-10-24 13:41:30 +00:00
|
|
|
container_of(data, struct il_priv, rx_replenish);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status))
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
|
|
|
il4965_rx_replenish(il);
|
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* 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 14:49:25 +00:00
|
|
|
static int il4965_mac_setup_register(struct il_priv *il,
|
2011-02-21 19:27:26 +00:00
|
|
|
u32 max_probe_length)
|
|
|
|
{
|
|
|
|
int ret;
|
2011-10-24 14:49:25 +00:00
|
|
|
struct ieee80211_hw *hw = il->hw;
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rxon_context *ctx;
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
if (il->cfg->sku & IL_SKU_N)
|
2011-02-21 19:27:26 +00:00
|
|
|
hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS |
|
|
|
|
IEEE80211_HW_SUPPORTS_STATIC_SMPS;
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
hw->sta_data_size = sizeof(struct il_station_priv);
|
|
|
|
hw->vif_data_size = sizeof(struct il_vif_priv);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
for_each_context(il, ctx) {
|
2011-02-21 19:27:26 +00:00
|
|
|
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 13:41:30 +00:00
|
|
|
hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->bands[IEEE80211_BAND_2GHZ].n_channels)
|
|
|
|
il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
|
|
|
|
&il->bands[IEEE80211_BAND_2GHZ];
|
|
|
|
if (il->bands[IEEE80211_BAND_5GHZ].n_channels)
|
|
|
|
il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
|
|
|
|
&il->bands[IEEE80211_BAND_5GHZ];
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_leds_init(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = ieee80211_register_hw(il->hw);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (ret) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Failed to register hw (error %d)\n", ret);
|
2011-02-21 19:27:26 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2011-10-24 14:49:25 +00:00
|
|
|
il->mac80211_registered = 1;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
int il4965_mac_start(struct ieee80211_hw *hw)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = hw->priv;
|
2011-02-21 19:27:26 +00:00
|
|
|
int ret;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "enter\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* we should be verifying the device is ready to be opened */
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
|
|
|
ret = __il4965_up(il);
|
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il_is_rfkill(il))
|
2011-02-21 19:27:26 +00:00
|
|
|
goto out;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Start UP work done.\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from
|
|
|
|
* mac80211 will not be run successfully. */
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = wait_event_timeout(il->wait_command_queue,
|
|
|
|
test_bit(STATUS_READY, &il->status),
|
2011-02-21 19:27:26 +00:00
|
|
|
UCODE_READY_TIMEOUT);
|
|
|
|
if (!ret) {
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!test_bit(STATUS_READY, &il->status)) {
|
|
|
|
IL_ERR(il, "START_ALIVE timeout after %dms.\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
jiffies_to_msecs(UCODE_READY_TIMEOUT));
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_led_enable(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
out:
|
2011-10-24 14:49:25 +00:00
|
|
|
il->is_open = 1;
|
|
|
|
IL_DEBUG_MAC80211(il, "leave\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
void il4965_mac_stop(struct ieee80211_hw *hw)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = hw->priv;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "enter\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il->is_open)
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->is_open = 0;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_down(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
flush_workqueue(il->workqueue);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-04-28 09:51:25 +00:00
|
|
|
/* User space software may expect getting rfkill changes
|
|
|
|
* even if interface is down */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write32(il, CSR_INT, 0xFFFFFFFF);
|
|
|
|
il_enable_rfkill_int(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "leave\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = hw->priv;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MACDUMP(il, "enter\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_TX(il, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len,
|
2011-02-21 19:27:26 +00:00
|
|
|
ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il4965_tx_skb(il, skb))
|
2011-02-21 19:27:26 +00:00
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MACDUMP(il, "leave\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
void il4965_mac_update_tkip_key(struct ieee80211_hw *hw,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_key_conf *keyconf,
|
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
u32 iv32, u16 *phase1key)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = hw->priv;
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "enter\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta,
|
2011-02-21 19:27:26 +00:00
|
|
|
iv32, phase1key);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "leave\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct ieee80211_vif *vif, struct ieee80211_sta *sta,
|
|
|
|
struct ieee80211_key_conf *key)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = hw->priv;
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
|
|
|
|
struct il_rxon_context *ctx = vif_priv->ctx;
|
2011-02-21 19:27:26 +00:00
|
|
|
int ret;
|
|
|
|
u8 sta_id;
|
|
|
|
bool is_default_wep_key = false;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "enter\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->cfg->mod_params->sw_crypto) {
|
|
|
|
IL_DEBUG_MAC80211(il, "leave - hwcrypto disabled\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
sta_id = il_sta_id_or_broadcast(il, vif_priv->ctx, sta);
|
2011-10-24 13:41:30 +00:00
|
|
|
if (sta_id == IL_INVALID_STATION)
|
2011-02-21 19:27:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
|
|
|
il_scan_cancel_timeout(il, 100);
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
ret = il4965_set_default_wep_key(il,
|
2011-02-21 19:27:26 +00:00
|
|
|
vif_priv->ctx, key);
|
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il4965_set_dynamic_key(il, vif_priv->ctx,
|
2011-02-21 19:27:26 +00:00
|
|
|
key, sta_id);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "enable hwcrypto key\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
break;
|
|
|
|
case DISABLE_KEY:
|
|
|
|
if (is_default_wep_key)
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il4965_remove_default_wep_key(il, ctx, key);
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il4965_remove_dynamic_key(il, ctx,
|
2011-02-21 19:27:26 +00:00
|
|
|
key, sta_id);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "disable hwcrypto key\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_unlock(&il->mutex);
|
|
|
|
IL_DEBUG_MAC80211(il, "leave\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
int il4965_mac_ampdu_action(struct ieee80211_hw *hw,
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
struct il_priv *il = hw->priv;
|
2011-02-21 19:27:26 +00:00
|
|
|
int ret = -EINVAL;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_HT(il, "A-MPDU action on addr %pM tid %d\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
sta->addr, tid);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!(il->cfg->sku & IL_SKU_N))
|
2011-02-21 19:27:26 +00:00
|
|
|
return -EACCES;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case IEEE80211_AMPDU_RX_START:
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_HT(il, "start Rx\n");
|
|
|
|
ret = il4965_sta_rx_agg_start(il, sta, tid, *ssn);
|
2011-02-21 19:27:26 +00:00
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_RX_STOP:
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_HT(il, "stop Rx\n");
|
|
|
|
ret = il4965_sta_rx_agg_stop(il, sta, tid);
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status))
|
2011-02-21 19:27:26 +00:00
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_START:
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_HT(il, "start Tx\n");
|
|
|
|
ret = il4965_tx_agg_start(il, vif, sta, tid, ssn);
|
2011-02-21 19:27:26 +00:00
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_STOP:
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_HT(il, "stop Tx\n");
|
|
|
|
ret = il4965_tx_agg_stop(il, vif, sta, tid);
|
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status))
|
2011-02-21 19:27:26 +00:00
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_OPERATIONAL:
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
int il4965_mac_sta_add(struct ieee80211_hw *hw,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = hw->priv;
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_station_priv *sta_priv = (void *)sta->drv_priv;
|
|
|
|
struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
|
2011-02-21 19:27:26 +00:00
|
|
|
bool is_ap = vif->type == NL80211_IFTYPE_STATION;
|
|
|
|
int ret;
|
|
|
|
u8 sta_id;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "received request to add station %pM\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
sta->addr);
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
|
|
|
IL_DEBUG_INFO(il, "proceeding to add station %pM\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
sta->addr);
|
2011-10-24 13:41:30 +00:00
|
|
|
sta_priv->common.sta_id = IL_INVALID_STATION;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
atomic_set(&sta_priv->pending_frames, 0);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il_add_station_common(il, vif_priv->ctx, sta->addr,
|
2011-02-21 19:27:26 +00:00
|
|
|
is_ap, sta, &sta_id);
|
|
|
|
if (ret) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Unable to add station %pM (%d)\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
sta->addr, ret);
|
|
|
|
/* Should we return success if return code is EEXIST ? */
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
sta_priv->common.sta_id = sta_id;
|
|
|
|
|
|
|
|
/* Initialize rate scaling */
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "Initializing rate scaling for station %pM\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
sta->addr);
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_rs_rate_init(il, sta, sta_id);
|
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
void il4965_mac_channel_switch(struct ieee80211_hw *hw,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct ieee80211_channel_switch *ch_switch)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = hw->priv;
|
2011-10-24 13:41:30 +00:00
|
|
|
const struct il_channel_info *ch_info;
|
2011-02-21 19:27:26 +00:00
|
|
|
struct ieee80211_conf *conf = &hw->conf;
|
|
|
|
struct ieee80211_channel *channel = ch_switch->channel;
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_ht_config *ht_conf = &il->current_ht_config;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
|
2011-02-21 19:27:26 +00:00
|
|
|
u16 ch;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "enter\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
2011-04-28 09:51:32 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il_is_rfkill(il))
|
2011-04-28 09:51:32 +00:00
|
|
|
goto out;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status) ||
|
|
|
|
test_bit(STATUS_SCANNING, &il->status) ||
|
|
|
|
test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status))
|
2011-04-28 09:51:32 +00:00
|
|
|
goto out;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
if (!il_is_associated_ctx(ctx))
|
2011-04-28 09:51:32 +00:00
|
|
|
goto out;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il->cfg->ops->lib->set_channel_switch)
|
2011-06-08 13:28:29 +00:00
|
|
|
goto out;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-06-08 13:28:29 +00:00
|
|
|
ch = channel->hw_value;
|
|
|
|
if (le16_to_cpu(ctx->active.channel) == ch)
|
|
|
|
goto out;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ch_info = il_get_channel_info(il, channel->band, ch);
|
2011-10-24 13:41:30 +00:00
|
|
|
if (!il_is_channel_valid(ch_info)) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "invalid channel\n");
|
2011-06-08 13:28:29 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_lock_irq(&il->lock);
|
2011-06-08 13:28:29 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->current_ht_config.smps = conf->smps_mode;
|
2011-06-08 13:28:29 +00:00
|
|
|
|
|
|
|
/* 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-21 19:27:26 +00:00
|
|
|
}
|
2011-06-08 13:28:29 +00:00
|
|
|
} else
|
|
|
|
ctx->ht.is_40mhz = false;
|
|
|
|
|
|
|
|
if ((le16_to_cpu(ctx->staging.channel) != ch))
|
|
|
|
ctx->staging.flags = 0;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_set_rxon_channel(il, channel, ctx);
|
|
|
|
il_set_rxon_ht(il, ht_conf);
|
|
|
|
il_set_flags_for_band(il, ctx, channel->band, ctx->vif);
|
2011-06-08 13:28:29 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_unlock_irq(&il->lock);
|
2011-06-08 13:28:29 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_set_rate(il);
|
2011-06-08 13:28:29 +00:00
|
|
|
/*
|
|
|
|
* at this point, staging_rxon has the
|
|
|
|
* configuration for channel switch
|
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
set_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status);
|
|
|
|
il->switch_channel = cpu_to_le16(ch);
|
|
|
|
if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) {
|
|
|
|
clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status);
|
|
|
|
il->switch_channel = 0;
|
2011-06-08 13:28:29 +00:00
|
|
|
ieee80211_chswitch_done(ctx->vif, false);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
2011-06-08 13:28:29 +00:00
|
|
|
|
2011-02-21 19:27:26 +00:00
|
|
|
out:
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_unlock(&il->mutex);
|
|
|
|
IL_DEBUG_MAC80211(il, "leave\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
void il4965_configure_filter(struct ieee80211_hw *hw,
|
2011-02-21 19:27:26 +00:00
|
|
|
unsigned int changed_flags,
|
|
|
|
unsigned int *total_flags,
|
|
|
|
u64 multicast)
|
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = hw->priv;
|
2011-02-21 19:27:26 +00:00
|
|
|
__le32 filter_or = 0, filter_nand = 0;
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_rxon_context *ctx;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
#define CHK(test, flag) do { \
|
|
|
|
if (*total_flags & (test)) \
|
|
|
|
filter_or |= (flag); \
|
|
|
|
else \
|
|
|
|
filter_nand |= (flag); \
|
|
|
|
} while (0)
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_MAC80211(il, "Enter: changed: 0x%x, total: 0x%x\n",
|
2011-02-21 19:27:26 +00: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
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
for_each_context(il, ctx) {
|
2011-02-21 19:27:26 +00:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Receiving all multicast frames is always enabled by the
|
2011-10-24 13:41:30 +00:00
|
|
|
* default flags setup in il_connection_init_rx_config()
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
static void il4965_bg_txpower_work(struct work_struct *work)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = container_of(work, struct il_priv,
|
2011-02-21 19:27:26 +00:00
|
|
|
txpower_work);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_lock(&il->mutex);
|
2011-04-28 09:36:54 +00:00
|
|
|
|
2011-02-21 19:27:26 +00: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. */
|
2011-10-24 14:49:25 +00:00
|
|
|
if (test_bit(STATUS_EXIT_PENDING, &il->status) ||
|
|
|
|
test_bit(STATUS_SCANNING, &il->status))
|
2011-04-28 09:36:54 +00:00
|
|
|
goto out;
|
2011-02-21 19:27:26 +00: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 */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->cfg->ops->lib->send_tx_power(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Update last_temperature to keep is_calib_needed from running
|
|
|
|
* when it isn't needed... */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->last_temperature = il->temperature;
|
2011-04-28 09:36:54 +00:00
|
|
|
out:
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_unlock(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_setup_deferred_work(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
il->workqueue = create_singlethread_workqueue(DRV_NAME);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
init_waitqueue_head(&il->wait_command_queue);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
INIT_WORK(&il->restart, il4965_bg_restart);
|
|
|
|
INIT_WORK(&il->rx_replenish, il4965_bg_rx_replenish);
|
|
|
|
INIT_WORK(&il->run_time_calib_work, il4965_bg_run_time_calib_work);
|
|
|
|
INIT_DELAYED_WORK(&il->init_alive_start, il4965_bg_init_alive_start);
|
|
|
|
INIT_DELAYED_WORK(&il->alive_start, il4965_bg_alive_start);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_setup_scan_deferred_work(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
INIT_WORK(&il->txpower_work, il4965_bg_txpower_work);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
init_timer(&il->statistics_periodic);
|
|
|
|
il->statistics_periodic.data = (unsigned long)il;
|
|
|
|
il->statistics_periodic.function = il4965_bg_statistics_periodic;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
init_timer(&il->watchdog);
|
|
|
|
il->watchdog.data = (unsigned long)il;
|
|
|
|
il->watchdog.function = il_bg_watchdog;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
tasklet_init(&il->irq_tasklet, (void (*)(unsigned long))
|
|
|
|
il4965_irq_tasklet, (unsigned long)il);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_cancel_deferred_work(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
cancel_work_sync(&il->txpower_work);
|
|
|
|
cancel_delayed_work_sync(&il->init_alive_start);
|
|
|
|
cancel_delayed_work(&il->alive_start);
|
|
|
|
cancel_work_sync(&il->run_time_calib_work);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_cancel_scan_deferred_work(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
del_timer_sync(&il->statistics_periodic);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_init_hw_rates(struct il_priv *il,
|
2011-02-21 19:27:26 +00:00
|
|
|
struct ieee80211_rate *rates)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) {
|
2011-08-16 12:17:04 +00:00
|
|
|
rates[i].bitrate = il_rates[i].ieee * 5;
|
2011-02-21 19:27:26 +00: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 13:41:30 +00:00
|
|
|
if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) {
|
2011-02-21 19:27:26 +00:00
|
|
|
/*
|
|
|
|
* If CCK != 1M then set short preamble rate flag.
|
|
|
|
*/
|
|
|
|
rates[i].flags |=
|
2011-08-16 12:17:04 +00:00
|
|
|
(il_rates[i].plcp == IL_RATE_1M_PLCP) ?
|
2011-02-21 19:27:26 +00:00
|
|
|
0 : IEEE80211_RATE_SHORT_PREAMBLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
2011-10-24 14:49:25 +00:00
|
|
|
* Acquire il->lock before calling this function !
|
2011-02-21 19:27:26 +00:00
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_direct32(il, HBUS_TARG_WRPTR,
|
2011-02-21 19:27:26 +00:00
|
|
|
(index & 0xff) | (txq_id << 8));
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
void il4965_tx_queue_set_status(struct il_priv *il,
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_tx_queue *txq,
|
2011-02-21 19:27:26 +00:00
|
|
|
int tx_fifo_id, int scd_retry)
|
|
|
|
{
|
|
|
|
int txq_id = txq->q.id;
|
|
|
|
|
|
|
|
/* Find out whether to activate Tx queue */
|
2011-10-24 14:49:25 +00:00
|
|
|
int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Set up and activate */
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id),
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "%s %s Queue %d on AC %d\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
active ? "Activate" : "Deactivate",
|
|
|
|
scd_retry ? "BA" : "AC", txq_id, tx_fifo_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static int il4965_init_drv(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_lock_init(&il->sta_lock);
|
|
|
|
spin_lock_init(&il->hcmd_lock);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
INIT_LIST_HEAD(&il->free_frames);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
mutex_init(&il->mutex);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->ieee_channels = NULL;
|
|
|
|
il->ieee_rates = NULL;
|
|
|
|
il->band = IEEE80211_BAND_2GHZ;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->iw_mode = NL80211_IFTYPE_STATION;
|
|
|
|
il->current_ht_config.smps = IEEE80211_SMPS_STATIC;
|
|
|
|
il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* initialize force reset */
|
2011-10-24 14:49:25 +00:00
|
|
|
il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Choose which receivers/antennas to use */
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->cfg->ops->hcmd->set_rxon_chain)
|
|
|
|
il->cfg->ops->hcmd->set_rxon_chain(il,
|
|
|
|
&il->contexts[IL_RXON_CTX_BSS]);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_init_scan_params(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il_init_channel_map(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (ret) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "initializing regulatory failed: %d\n", ret);
|
2011-02-21 19:27:26 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ret = il_init_geos(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (ret) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "initializing geos failed: %d\n", ret);
|
2011-02-21 19:27:26 +00:00
|
|
|
goto err_free_channel_map;
|
|
|
|
}
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_init_hw_rates(il, il->ieee_rates);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_free_channel_map:
|
2011-10-24 14:49:25 +00:00
|
|
|
il_free_channel_map(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
err:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_uninit_drv(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_calib_free_results(il);
|
|
|
|
il_free_geos(il);
|
|
|
|
il_free_channel_map(il);
|
|
|
|
kfree(il->scan_cmd);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static void il4965_hw_detect(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
il->hw_rev = _il_read32(il, CSR_HW_REV);
|
|
|
|
il->hw_wa_rev = _il_read32(il, CSR_HW_REV_WA_REG);
|
|
|
|
il->rev_id = il->pci_dev->revision;
|
|
|
|
IL_DEBUG_INFO(il, "HW Revision ID = 0x%X\n", il->rev_id);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
static int il4965_set_hw_params(struct il_priv *il)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
il->hw_params.max_rxq_size = RX_QUEUE_SIZE;
|
|
|
|
il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG;
|
|
|
|
if (il->cfg->mod_params->amsdu_size_8K)
|
|
|
|
il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K);
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->cfg->mod_params->disable_11n)
|
|
|
|
il->cfg->sku &= ~IL_SKU_N;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* Device-specific setup */
|
2011-10-24 14:49:25 +00:00
|
|
|
return il->cfg->ops->lib->set_hw_params(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00: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-21 19:27:26 +00:00
|
|
|
};
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static const u8 il4965_bss_ac_to_queue[] = {
|
2011-02-21 19:27:26 +00:00
|
|
|
0, 1, 2, 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2011-10-24 13:41:30 +00:00
|
|
|
il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
int err = 0, i;
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il;
|
2011-02-21 19:27:26 +00:00
|
|
|
struct ieee80211_hw *hw;
|
2011-10-24 13:41:30 +00:00
|
|
|
struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data);
|
2011-02-21 19:27:26 +00:00
|
|
|
unsigned long flags;
|
|
|
|
u16 pci_cmd;
|
|
|
|
|
|
|
|
/************************
|
|
|
|
* 1. Allocating HW data
|
|
|
|
************************/
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
hw = il_alloc_all(cfg);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (!hw) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
2011-10-24 14:49:25 +00:00
|
|
|
il = hw->priv;
|
|
|
|
/* At this point both hw and il are allocated. */
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The default context is always valid,
|
|
|
|
* more may be discovered when firmware
|
|
|
|
* is loaded.
|
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
il->valid_contexts = BIT(IL_RXON_CTX_BSS);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
for (i = 0; i < NUM_IL_RXON_CTX; i++)
|
2011-10-24 14:49:25 +00:00
|
|
|
il->contexts[i].ctxid = i;
|
|
|
|
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].always_active = true;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].is_active = true;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes =
|
2011-02-21 19:27:26 +00:00
|
|
|
BIT(NL80211_IFTYPE_ADHOC);
|
2011-10-24 14:49:25 +00:00
|
|
|
il->contexts[IL_RXON_CTX_BSS].interface_modes =
|
2011-02-21 19:27:26 +00:00
|
|
|
BIT(NL80211_IFTYPE_STATION);
|
2011-10-24 14:49:25 +00:00
|
|
|
il->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS;
|
|
|
|
il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
BUILD_BUG_ON(NUM_IL_RXON_CTX != 1);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
SET_IEEE80211_DEV(hw, &pdev->dev);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "*** LOAD DRIVER ***\n");
|
|
|
|
il->cfg = cfg;
|
|
|
|
il->pci_dev = pdev;
|
|
|
|
il->inta_mask = CSR_INI_SET_MASK;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il_alloc_traffic_mem(il))
|
|
|
|
IL_ERR(il, "Not enough memory to generate traffic log\n");
|
2011-02-21 19:27:26 +00: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 14:49:25 +00:00
|
|
|
IL_WARN(il, "No suitable DMA available.\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
goto out_pci_disable_device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
err = pci_request_regions(pdev, DRV_NAME);
|
|
|
|
if (err)
|
|
|
|
goto out_pci_disable_device;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
pci_set_drvdata(pdev, il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* 3. Read REV register
|
|
|
|
***********************/
|
2011-10-24 14:49:25 +00:00
|
|
|
il->hw_base = pci_iomap(pdev, 0, 0);
|
|
|
|
if (!il->hw_base) {
|
2011-02-21 19:27:26 +00:00
|
|
|
err = -ENODEV;
|
|
|
|
goto out_pci_release_regions;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "pci_resource_len = 0x%08llx\n",
|
2011-02-21 19:27:26 +00:00
|
|
|
(unsigned long long) pci_resource_len(pdev, 0));
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "pci_resource_base = %p\n", il->hw_base);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* these spin locks will be used in apm_ops.init and EEPROM access
|
|
|
|
* we should init now
|
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_lock_init(&il->reg_lock);
|
|
|
|
spin_lock_init(&il->lock);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 14:49:25 +00:00
|
|
|
il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_hw_detect(il);
|
|
|
|
IL_INFO(il, "Detected %s, REV=0x%X\n",
|
|
|
|
il->cfg->name, il->hw_rev);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* 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 14:49:25 +00:00
|
|
|
il4965_prepare_card_hw(il);
|
|
|
|
if (!il->hw_ready) {
|
|
|
|
IL_WARN(il, "Failed, HW not ready\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
goto out_iounmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************
|
|
|
|
* 4. Read EEPROM
|
|
|
|
*****************/
|
|
|
|
/* Read the EEPROM */
|
2011-10-24 14:49:25 +00:00
|
|
|
err = il_eeprom_init(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (err) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Unable to init EEPROM\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
goto out_iounmap;
|
|
|
|
}
|
2011-10-24 14:49:25 +00:00
|
|
|
err = il4965_eeprom_check_version(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (err)
|
|
|
|
goto out_free_eeprom;
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto out_free_eeprom;
|
|
|
|
|
|
|
|
/* extract MAC Address */
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_eeprom_get_mac(il, il->addresses[0].addr);
|
|
|
|
IL_DEBUG_INFO(il, "MAC address: %pM\n", il->addresses[0].addr);
|
|
|
|
il->hw->wiphy->addresses = il->addresses;
|
|
|
|
il->hw->wiphy->n_addresses = 1;
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/************************
|
|
|
|
* 5. Setup HW constants
|
|
|
|
************************/
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il4965_set_hw_params(il)) {
|
|
|
|
IL_ERR(il, "failed to set hw parameters\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
goto out_free_eeprom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************
|
2011-10-24 14:49:25 +00:00
|
|
|
* 6. Setup il
|
2011-02-21 19:27:26 +00:00
|
|
|
*******************/
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
err = il4965_init_drv(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (err)
|
|
|
|
goto out_free_eeprom;
|
2011-10-24 14:49:25 +00:00
|
|
|
/* At this point both hw and il are initialized. */
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/********************
|
|
|
|
* 7. Setup services
|
|
|
|
********************/
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_lock_irqsave(&il->lock, flags);
|
|
|
|
il_disable_interrupts(il);
|
|
|
|
spin_unlock_irqrestore(&il->lock, flags);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
pci_enable_msi(il->pci_dev);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
err = request_irq(il->pci_dev->irq, il_isr,
|
|
|
|
IRQF_SHARED, DRV_NAME, il);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (err) {
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_ERR(il, "Error allocating IRQ %d\n", il->pci_dev->irq);
|
2011-02-21 19:27:26 +00:00
|
|
|
goto out_disable_msi;
|
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_setup_deferred_work(il);
|
|
|
|
il4965_setup_rx_handlers(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/*********************************************
|
|
|
|
* 8. Enable interrupts and read RFKILL state
|
|
|
|
*********************************************/
|
|
|
|
|
2011-04-28 09:51:25 +00:00
|
|
|
/* enable rfkill interrupt: hw bug w/a */
|
2011-10-24 14:49:25 +00:00
|
|
|
pci_read_config_word(il->pci_dev, PCI_COMMAND, &pci_cmd);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (pci_cmd & PCI_COMMAND_INTX_DISABLE) {
|
|
|
|
pci_cmd &= ~PCI_COMMAND_INTX_DISABLE;
|
2011-10-24 14:49:25 +00:00
|
|
|
pci_write_config_word(il->pci_dev, PCI_COMMAND, pci_cmd);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_enable_rfkill_int(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* If platform's RF_KILL switch is NOT set to KILL */
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il_read32(il, CSR_GP_CNTRL) &
|
2011-02-21 19:27:26 +00:00
|
|
|
CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
|
2011-10-24 14:49:25 +00:00
|
|
|
clear_bit(STATUS_RF_KILL_HW, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
else
|
2011-10-24 14:49:25 +00:00
|
|
|
set_bit(STATUS_RF_KILL_HW, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
wiphy_rfkill_set_hw_state(il->hw->wiphy,
|
|
|
|
test_bit(STATUS_RF_KILL_HW, &il->status));
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_power_initialize(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
init_completion(&il->_4965.firmware_loading_complete);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
err = il4965_request_firmware(il, true);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (err)
|
|
|
|
goto out_destroy_workqueue;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_destroy_workqueue:
|
2011-10-24 14:49:25 +00:00
|
|
|
destroy_workqueue(il->workqueue);
|
|
|
|
il->workqueue = NULL;
|
|
|
|
free_irq(il->pci_dev->irq, il);
|
2011-02-21 19:27:26 +00:00
|
|
|
out_disable_msi:
|
2011-10-24 14:49:25 +00:00
|
|
|
pci_disable_msi(il->pci_dev);
|
|
|
|
il4965_uninit_drv(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
out_free_eeprom:
|
2011-10-24 14:49:25 +00:00
|
|
|
il_eeprom_free(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
out_iounmap:
|
2011-10-24 14:49:25 +00:00
|
|
|
pci_iounmap(pdev, il->hw_base);
|
2011-02-21 19:27:26 +00:00
|
|
|
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 14:49:25 +00:00
|
|
|
il_free_traffic_mem(il);
|
|
|
|
ieee80211_free_hw(il->hw);
|
2011-02-21 19:27:26 +00:00
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static void __devexit il4965_pci_remove(struct pci_dev *pdev)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
struct il_priv *il = pci_get_drvdata(pdev);
|
2011-02-21 19:27:26 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (!il)
|
2011-02-21 19:27:26 +00:00
|
|
|
return;
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
wait_for_completion(&il->_4965.firmware_loading_complete);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
IL_DEBUG_INFO(il, "*** UNLOAD DRIVER ***\n");
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_dbgfs_unregister(il);
|
2011-10-24 13:41:30 +00:00
|
|
|
sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00: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-21 19:27:26 +00:00
|
|
|
* we need to set STATUS_EXIT_PENDING bit.
|
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
set_bit(STATUS_EXIT_PENDING, &il->status);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_leds_exit(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->mac80211_registered) {
|
|
|
|
ieee80211_unregister_hw(il->hw);
|
|
|
|
il->mac80211_registered = 0;
|
2011-02-21 19:27:26 +00:00
|
|
|
} else {
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_down(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure device is reset to low power before unloading driver.
|
2011-10-24 13:41:30 +00: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-21 19:27:26 +00:00
|
|
|
* This (inexpensive) call *makes sure* device is reset.
|
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
il_apm_stop(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
/* make sure we flush any pending irq or
|
|
|
|
* tasklet for the driver
|
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
spin_lock_irqsave(&il->lock, flags);
|
|
|
|
il_disable_interrupts(il);
|
|
|
|
spin_unlock_irqrestore(&il->lock, flags);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_synchronize_irq(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_dealloc_ucode_pci(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
if (il->rxq.bd)
|
|
|
|
il4965_rx_queue_free(il, &il->rxq);
|
|
|
|
il4965_hw_txq_ctx_free(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il_eeprom_free(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*netif_stop_queue(dev); */
|
2011-10-24 14:49:25 +00:00
|
|
|
flush_workqueue(il->workqueue);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
/* ieee80211_unregister_hw calls il_mac_stop, which flushes
|
2011-10-24 14:49:25 +00:00
|
|
|
* il->workqueue... so we can't take down the workqueue
|
2011-02-21 19:27:26 +00:00
|
|
|
* until now... */
|
2011-10-24 14:49:25 +00:00
|
|
|
destroy_workqueue(il->workqueue);
|
|
|
|
il->workqueue = NULL;
|
|
|
|
il_free_traffic_mem(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
free_irq(il->pci_dev->irq, il);
|
|
|
|
pci_disable_msi(il->pci_dev);
|
|
|
|
pci_iounmap(pdev, il->hw_base);
|
2011-02-21 19:27:26 +00:00
|
|
|
pci_release_regions(pdev);
|
|
|
|
pci_disable_device(pdev);
|
|
|
|
pci_set_drvdata(pdev, NULL);
|
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
il4965_uninit_drv(il);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
dev_kfree_skb(il->beacon_skb);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 14:49:25 +00:00
|
|
|
ieee80211_free_hw(il->hw);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
|
2011-10-24 14:49:25 +00:00
|
|
|
* must be called under il->lock and mac access
|
2011-02-21 19:27:26 +00:00
|
|
|
*/
|
2011-10-24 14:49:25 +00:00
|
|
|
void il4965_txq_set_sched(struct il_priv *il, u32 mask)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 14:49:25 +00:00
|
|
|
il_write_prph(il, IWL49_SCD_TXFACT, mask);
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* driver and module entry point
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/* Hardware specific file defines the PCI IDs table for that hardware module */
|
2011-10-24 13:41:30 +00:00
|
|
|
static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = {
|
2011-02-21 19:27:26 +00:00
|
|
|
#if defined(CONFIG_IWL4965_MODULE) || defined(CONFIG_IWL4965)
|
2011-10-24 13:41:30 +00:00
|
|
|
{IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)},
|
|
|
|
{IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)},
|
2011-02-21 19:27:26 +00:00
|
|
|
#endif /* CONFIG_IWL4965 */
|
|
|
|
|
|
|
|
{0}
|
|
|
|
};
|
2011-10-24 13:41:30 +00:00
|
|
|
MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static struct pci_driver il4965_driver = {
|
2011-02-21 19:27:26 +00:00
|
|
|
.name = DRV_NAME,
|
2011-10-24 13:41:30 +00: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-21 19:27:26 +00:00
|
|
|
};
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static int __init il4965_init(void)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n");
|
|
|
|
pr_info(DRV_COPYRIGHT "\n");
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
ret = il4965_rate_control_register();
|
2011-02-21 19:27:26 +00:00
|
|
|
if (ret) {
|
|
|
|
pr_err("Unable to register rate control algorithm: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
ret = pci_register_driver(&il4965_driver);
|
2011-02-21 19:27:26 +00:00
|
|
|
if (ret) {
|
|
|
|
pr_err("Unable to initialize PCI module\n");
|
|
|
|
goto error_register;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
error_register:
|
2011-10-24 13:41:30 +00:00
|
|
|
il4965_rate_control_unregister();
|
2011-02-21 19:27:26 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
static void __exit il4965_exit(void)
|
2011-02-21 19:27:26 +00:00
|
|
|
{
|
2011-10-24 13:41:30 +00:00
|
|
|
pci_unregister_driver(&il4965_driver);
|
|
|
|
il4965_rate_control_unregister();
|
2011-02-21 19:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
module_exit(il4965_exit);
|
|
|
|
module_init(il4965_init);
|
2011-02-21 19:27:26 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
|
2011-08-16 12:17:04 +00:00
|
|
|
module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR);
|
2011-02-21 19:27:26 +00:00
|
|
|
MODULE_PARM_DESC(debug, "debug output mask");
|
|
|
|
#endif
|
|
|
|
|
2011-10-24 13:41:30 +00:00
|
|
|
module_param_named(swcrypto, il4965_mod_params.sw_crypto, int, S_IRUGO);
|
2011-02-21 19:27:26 +00:00
|
|
|
MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
|
2011-10-24 13:41:30 +00:00
|
|
|
module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO);
|
2011-02-21 19:27:26 +00:00
|
|
|
MODULE_PARM_DESC(queues_num, "number of hw queues.");
|
2011-10-24 13:41:30 +00:00
|
|
|
module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO);
|
2011-02-21 19:27:26 +00:00
|
|
|
MODULE_PARM_DESC(11n_disable, "disable 11n functionality");
|
2011-10-24 13:41:30 +00:00
|
|
|
module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K,
|
2011-02-21 19:27:26 +00:00
|
|
|
int, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size");
|
2011-10-24 13:41:30 +00:00
|
|
|
module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO);
|
2011-02-21 19:27:26 +00:00
|
|
|
MODULE_PARM_DESC(fw_restart, "restart firmware in case of error");
|