Copyright(c) 2003 - 2006 Intel Corporation. All rights reserved.
Contact Information: Intel Linux Wireless <ilw@linux.intel.com> Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
Portions of this file are based on the sample_* files provided by Wireless Extensions 0.26 package and copyright (c) 1997-2003 Jean Tourrilhes <jt@hpl.hp.com>
Portions of this file are based on the Host AP project, Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen <j@w1.fi> Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
Portions of ipw2100_mod_firmware_load, ipw2100_do_mod_firmware_load, and ipw2100_fw_load are loosely based on drivers/sound/sound_firmware.c available in the 2.4.25 kernel sources, and are copyright (c) Alan Cox
Initial driver on which this is based was developed by Janusz Gorycki, Maciej Urbaniak, and Maciej Sosnowski.
Promiscuous mode support added by Jacek Wysoczynski and Maciej Urbaniak.
Theory of Operation
Tx - Commands and Data
Firmware and host share a circular queue of Transmit Buffer Descriptors (TBDs) Each TBD contains a pointer to the physical (dma_addr_t) address of data being sent to the firmware as well as the length of the data.
The host writes to the TBD queue at the WRITE index. The WRITE index points to the _next_ packet to be written and is advanced when after the TBD has been filled.
The firmware pulls from the TBD queue at the READ index. The READ index points to the currently being read entry, and is advanced once the firmware is done with a packet.
When data is sent to the firmware, the first TBD is used to indicate to the firmware if a Command or Data is being sent. If it is Command, all of the command information is contained within the physical address referred to by the TBD. If it is Data, the first TBD indicates the type of data packet, number of fragments, etc. The next TBD then refers to the actual packet location.
The Tx flow cycle is as follows:
1) ipw2100_tx() is called by kernel with SKB to transmit 2) Packet is move from the tx_free_list and appended to the transmit pending list (tx_pend_list) 3) work is scheduled to move pending packets into the shared circular queue. 4) when placing packet in the circular queue, the incoming SKB is DMA mapped to a physical address. That address is entered into a TBD. Two TBDs are filled out. The first indicating a data packet, the second referring to the actual payload data. 5) the packet is removed from tx_pend_list and placed on the end of the firmware pending list (fw_pend_list) 6) firmware is notified that the WRITE index has 7) Once the firmware has processed the TBD, INTA is triggered. 8) For each Tx interrupt received from the firmware, the READ index is checked to see which TBDs are done being processed. 9) For each TBD that has been processed, the ISR pulls the oldest packet from the fw_pend_list. 10)The packet structure contained in the fw_pend_list is then used to unmap the DMA address and to free the SKB originally passed to the driver from the kernel. 11)The packet structure is placed onto the tx_free_list
The above steps are the same for commands, only the msg_free_list/msg_pend_list are used instead of tx_free_list/tx_pend_list
...
Critical Sections / Locking :
There are two locks utilized. The first is the low level lock (priv->low_lock) that protects the following:
- Access to the Tx/Rx queue lists via priv->low_lock. The lists are as follows:
tx_free_list : Holds pre-allocated Tx buffers. TAIL modified in __ipw2100_tx_process() HEAD modified in ipw2100_tx()
tx_pend_list : Holds used Tx buffers waiting to go into the TBD ring TAIL modified ipw2100_tx() HEAD modified by ipw2100_tx_send_data()
msg_free_list : Holds pre-allocated Msg (Command) buffers TAIL modified in __ipw2100_tx_process() HEAD modified in ipw2100_hw_send_command()
msg_pend_list : Holds used Msg buffers waiting to go into the TBD ring TAIL modified in ipw2100_hw_send_command() HEAD modified in ipw2100_tx_send_commands()
/* Pre-decl until we get the code solid and then we can clean it up */ staticvoid ipw2100_tx_send_commands(struct ipw2100_priv *priv); staticvoid ipw2100_tx_send_data(struct ipw2100_priv *priv); staticint ipw2100_adapter_setup(struct ipw2100_priv *priv);
/* read first nibble byte by byte */
aligned_addr = addr & (~0x3);
dif_len = addr - aligned_addr; if (dif_len) { /* Start reading at aligned_addr + dif_len */
write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
aligned_addr); for (i = dif_len; i < 4; i++, buf++)
write_register_byte(dev,
IPW_REG_INDIRECT_ACCESS_DATA + i,
*buf);
len -= dif_len;
aligned_addr += 4;
}
/* read DWs through autoincrement registers */
write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS, aligned_addr);
aligned_len = len & (~0x3); for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
write_register(dev, IPW_REG_AUTOINCREMENT_DATA, *(u32 *) buf);
/* copy the last nibble */
dif_len = len - aligned_len;
write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, aligned_addr); for (i = 0; i < dif_len; i++, buf++)
write_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA + i,
*buf);
}
/* read first nibble byte by byte */
aligned_addr = addr & (~0x3);
dif_len = addr - aligned_addr; if (dif_len) { /* Start reading at aligned_addr + dif_len */
write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
aligned_addr); for (i = dif_len; i < 4; i++, buf++)
read_register_byte(dev,
IPW_REG_INDIRECT_ACCESS_DATA + i,
buf);
len -= dif_len;
aligned_addr += 4;
}
/* read DWs through autoincrement registers */
write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS, aligned_addr);
aligned_len = len & (~0x3); for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
read_register(dev, IPW_REG_AUTOINCREMENT_DATA, (u32 *) buf);
/* copy the last nibble */
dif_len = len - aligned_len;
write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, aligned_addr); for (i = 0; i < dif_len; i++, buf++)
read_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA + i, buf);
}
/* get the address of statistic */
read_nic_dword(priv->net_dev,
ordinals->table2_addr + (ord << 3), &addr);
/* get the second DW of statistics ;
* two 16-bit words - first is length, second is count */
read_nic_dword(priv->net_dev,
ordinals->table2_addr + (ord << 3) + sizeof(u32),
&field_info);
/* get each entry length */
field_len = *((u16 *) & field_info);
/* get number of entries */
field_count = *(((u16 *) & field_info) + 1);
/* abort if no enough memory */
total_length = field_len * field_count; if (total_length > *len) {
*len = total_length; return -EINVAL;
}
*len = total_length; if (!total_length) return 0;
/* read the ordinal data from the SRAM */
read_nic_memory(priv->net_dev, addr, total_length, val);
return 0;
}
printk(KERN_WARNING DRV_NAME ": ordinal %d neither in table 1 nor " "in table 2\n", ord);
while (len) {
printk(KERN_DEBUG "%s\n",
snprint_line(line, sizeof(line), &data[ofs],
min(len, 16U), ofs));
ofs += 16;
len -= min(len, 16U);
}
}
#define MAX_RESET_BACKOFF 10
staticvoid schedule_reset(struct ipw2100_priv *priv)
{
time64_t now = ktime_get_boottime_seconds();
/* If we haven't received a reset request within the backoff period, * then we can reset the backoff interval so this reset occurs
* immediately */ if (priv->reset_backoff &&
(now - priv->last_reset > priv->reset_backoff))
priv->reset_backoff = 0;
if (priv->fatal_error) {
IPW_DEBUG_INFO
("Attempt to send command while hardware in fatal error condition.\n");
err = -EIO; goto fail_unlock;
}
if (!(priv->status & STATUS_RUNNING)) {
IPW_DEBUG_INFO
("Attempt to send command while hardware is not running.\n");
err = -EIO; goto fail_unlock;
}
if (priv->status & STATUS_CMD_ACTIVE) {
IPW_DEBUG_INFO
("Attempt to send command while another command is pending.\n");
err = -EBUSY; goto fail_unlock;
}
if (list_empty(&priv->msg_free_list)) {
IPW_DEBUG_INFO("no available msg buffers\n"); goto fail_unlock;
}
/* * We must wait for this command to complete before another * command can be sent... but if we wait more than 3 seconds * then there is a problem.
*/
err =
wait_event_interruptible_timeout(priv->wait_command_queue,
!(priv->
status & STATUS_CMD_ACTIVE),
HOST_COMPLETE_TIMEOUT);
if (err == 0) {
IPW_DEBUG_INFO("Command completion failed out after %dms.\n",
1000 * (HOST_COMPLETE_TIMEOUT / HZ));
priv->fatal_error = IPW2100_ERR_MSG_TIMEOUT;
priv->status &= ~STATUS_CMD_ACTIVE;
schedule_reset(priv); return -EIO;
}
/* !!!!! HACK TEST !!!!! * When lots of debug trace statements are enabled, the driver * doesn't seem to have as many firmware restart cycles... *
* As a test, we're sticking in a 1/100s delay here */
schedule_timeout_uninterruptible(msecs_to_jiffies(10));
/* * Verify the values and data access of the hardware * No locks needed or used. No functions called.
*/ staticint ipw2100_verify(struct ipw2100_priv *priv)
{
u32 data1, data2;
u32 address;
u32 val1 = 0x76543210;
u32 val2 = 0xFEDCBA98;
/* Domain 0 check - all values should be DOA_DEBUG */ for (address = IPW_REG_DOA_DEBUG_AREA_START;
address < IPW_REG_DOA_DEBUG_AREA_END; address += sizeof(u32)) {
read_register(priv->net_dev, address, &data1); if (data1 != IPW_DATA_DOA_DEBUG_VALUE) return -EIO;
}
/* Domain 1 check - use arbitrary read/write compare */ for (address = 0; address < 5; address++) { /* The memory area is not used now */
write_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x32,
val1);
write_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x36,
val2);
read_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x32,
&data1);
read_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x36,
&data2); if (val1 == data1 && val2 == data2) return 0;
}
return -EIO;
}
/* * * Loop until the CARD_DISABLED bit is the same value as the * supplied parameter * * TODO: See if it would be more efficient to do a wait/wake * cycle and have the completion event trigger the wakeup *
*/ #define IPW_CARD_DISABLE_COMPLETE_WAIT 100 // 100 milli staticint ipw2100_wait_for_card_state(struct ipw2100_priv *priv, int state)
{ int i;
u32 card_state;
u32 len = sizeof(card_state); int err;
for (i = 0; i <= IPW_CARD_DISABLE_COMPLETE_WAIT * 1000; i += 50) {
err = ipw2100_get_ordinal(priv, IPW_ORD_CARD_DISABLED,
&card_state, &len); if (err) {
IPW_DEBUG_INFO("Query of CARD_DISABLED ordinal " "failed.\n"); return 0;
}
/* We'll break out if either the HW state says it is * in the state we want, or if HOST_COMPLETE command
* finishes */ if ((card_state == state) ||
((priv->status & STATUS_ENABLED) ?
IPW_HW_STATE_ENABLED : IPW_HW_STATE_DISABLED) == state) { if (state == IPW_HW_STATE_ENABLED)
priv->status |= STATUS_ENABLED; else
priv->status &= ~STATUS_ENABLED;
return 0;
}
udelay(50);
}
IPW_DEBUG_INFO("ipw2100_wait_for_card_state to %s state timed out\n",
state ? "DISABLED" : "ENABLED"); return -EIO;
}
/********************************************************************* Procedure : sw_reset_and_clock Purpose : Asserts s/w reset, asserts clock initialization and waits for clock stabilization
********************************************************************/ staticint sw_reset_and_clock(struct ipw2100_priv *priv)
{ int i;
u32 r;
// wait for clock stabilization for (i = 0; i < 1000; i++) {
udelay(IPW_WAIT_RESET_ARC_COMPLETE_DELAY);
// check clock ready bit
read_register(priv->net_dev, IPW_REG_RESET_REG, &r); if (r & IPW_AUX_HOST_RESET_REG_PRINCETON_RESET) break;
}
if (i == 1000) return -EIO; // TODO: better error value
/* set "initialization complete" bit to move adapter to
* D0 state */
write_register(priv->net_dev, IPW_REG_GP_CNTRL,
IPW_AUX_HOST_GP_CNTRL_BIT_INIT_DONE);
/* wait for clock stabilization */ for (i = 0; i < 10000; i++) {
udelay(IPW_WAIT_CLOCK_STABILIZATION_DELAY * 4);
/* check clock ready bit */
read_register(priv->net_dev, IPW_REG_GP_CNTRL, &r); if (r & IPW_AUX_HOST_GP_CNTRL_BIT_CLOCK_READY) break;
}
if (i == 10000) return -EIO; /* TODO: better error value */
/* set D0 standby bit */
read_register(priv->net_dev, IPW_REG_GP_CNTRL, &r);
write_register(priv->net_dev, IPW_REG_GP_CNTRL,
r | IPW_AUX_HOST_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY);
return 0;
}
/********************************************************************* Procedure : ipw2100_download_firmware Purpose : Initiaze adapter after power on. The sequence is: 1. assert s/w reset first! 2. awake clocks & wait for clock stabilization 3. hold ARC (don't ask me why...) 4. load Dino ucode and reset/clock init again 5. zero-out shared mem 6. download f/w
*******************************************************************/ staticint ipw2100_download_firmware(struct ipw2100_priv *priv)
{
u32 address; int err;
#ifndef CONFIG_PM /* Fetch the firmware and microcode */ struct ipw2100_fw ipw2100_firmware; #endif
if (priv->fatal_error) {
IPW_DEBUG_ERROR("%s: ipw2100_download_firmware called after " "fatal error %d. Interface must be brought down.\n",
priv->net_dev->name, priv->fatal_error); return -EINVAL;
} #ifdef CONFIG_PM if (!ipw2100_firmware.version) {
err = ipw2100_get_firmware(priv, &ipw2100_firmware); if (err) {
IPW_DEBUG_ERROR("%s: ipw2100_get_firmware failed: %d\n",
priv->net_dev->name, err);
priv->fatal_error = IPW2100_ERR_FW_LOAD; goto fail;
}
} #else
err = ipw2100_get_firmware(priv, &ipw2100_firmware); if (err) {
IPW_DEBUG_ERROR("%s: ipw2100_get_firmware failed: %d\n",
priv->net_dev->name, err);
priv->fatal_error = IPW2100_ERR_FW_LOAD; goto fail;
} #endif
priv->firmware_version = ipw2100_firmware.version;
/* load f/w */
err = ipw2100_fw_download(priv, &ipw2100_firmware); if (err) {
IPW_DEBUG_ERROR("%s: Error loading firmware: %d\n",
priv->net_dev->name, err); goto fail;
} #ifndef CONFIG_PM /* * When the .resume method of the driver is called, the other * part of the system, i.e. the ide driver could still stay in * the suspend stage. This prevents us from loading the firmware * from the disk. --YZ
*/
/* free any storage allocated for firmware image */
ipw2100_release_firmware(priv, &ipw2100_firmware); #endif
/* zero out Domain 1 area indirectly (Si requirement) */ for (address = IPW_HOST_FW_SHARED_AREA0;
address < IPW_HOST_FW_SHARED_AREA0_END; address += 4)
write_nic_dword(priv->net_dev, address, 0); for (address = IPW_HOST_FW_SHARED_AREA1;
address < IPW_HOST_FW_SHARED_AREA1_END; address += 4)
write_nic_dword(priv->net_dev, address, 0); for (address = IPW_HOST_FW_SHARED_AREA2;
address < IPW_HOST_FW_SHARED_AREA2_END; address += 4)
write_nic_dword(priv->net_dev, address, 0); for (address = IPW_HOST_FW_SHARED_AREA3;
address < IPW_HOST_FW_SHARED_AREA3_END; address += 4)
write_nic_dword(priv->net_dev, address, 0); for (address = IPW_HOST_FW_INTERRUPT_AREA;
address < IPW_HOST_FW_INTERRUPT_AREA_END; address += 4)
write_nic_dword(priv->net_dev, address, 0);
/* * EEPROM_SRAM_DB_START_ADDRESS using ordinal in ordinal table 1
*/
len = sizeof(addr); if (ipw2100_get_ordinal
(priv, IPW_ORD_EEPROM_SRAM_DB_BLOCK_START_ADDRESS, &addr, &len)) {
IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
__LINE__); return -EIO;
}
IPW_DEBUG_INFO("EEPROM address: %08X\n", addr);
/* * EEPROM version is the byte at offset 0xfd in firmware
* We read 4 bytes, then shift out the byte we actually want */
read_nic_dword(priv->net_dev, addr + 0xFC, &val);
priv->eeprom_version = (val >> 24) & 0xFF;
IPW_DEBUG_INFO("EEPROM version: %d\n", priv->eeprom_version);
/* * HW RF Kill enable is bit 0 in byte at offset 0x21 in firmware * * notice that the EEPROM bit is reverse polarity, i.e. * bit = 0 signifies HW RF kill switch is supported * bit = 1 signifies HW RF kill switch is NOT supported
*/
read_nic_dword(priv->net_dev, addr + 0x20, &val); if (!((val >> 24) & 0x01))
priv->hw_features |= HW_FEATURE_RFKILL;
/* * Start firmware execution after power on and initialization * The sequence is: * 1. Release ARC * 2. Wait for f/w initialization completes;
*/ staticint ipw2100_start_adapter(struct ipw2100_priv *priv)
{ int i;
u32 inta, inta_mask, gpio;
IPW_DEBUG_INFO("enter\n");
if (priv->status & STATUS_RUNNING) return 0;
/* * Initialize the hw - drive adapter to DO state by setting * init_done bit. Wait for clk_ready bit and Download * fw & dino ucode
*/ if (ipw2100_download_firmware(priv)) {
printk(KERN_ERR DRV_NAME ": %s: Failed to power on the adapter.\n",
priv->net_dev->name); return -EIO;
}
/* Clear the Tx, Rx and Msg queues and the r/w indexes
* in the firmware RBD and TBD ring queue */
ipw2100_queues_initialize(priv);
ipw2100_hw_set_gpio(priv);
/* TODO -- Look at disabling interrupts here to make sure none
* get fired during FW initialization */
/* wait for f/w initialization complete */
IPW_DEBUG_FW("Waiting for f/w initialization to complete...\n");
i = 5000; do {
schedule_timeout_uninterruptible(msecs_to_jiffies(40)); /* Todo... wait for sync command ... */
/* check "init done" bit */ if (inta & IPW2100_INTA_FW_INIT_DONE) { /* reset "init done" bit */
write_register(priv->net_dev, IPW_REG_INTA,
IPW2100_INTA_FW_INIT_DONE); break;
}
/* check error conditions : we check these after the firmware * check so that if there is an error, the interrupt handler
* will see it and the adapter will be reset */ if (inta &
(IPW2100_INTA_FATAL_ERROR | IPW2100_INTA_PARITY_ERROR)) { /* clear error conditions */
write_register(priv->net_dev, IPW_REG_INTA,
IPW2100_INTA_FATAL_ERROR |
IPW2100_INTA_PARITY_ERROR);
}
} while (--i);
/* Clear out any pending INTAs since we aren't supposed to have
* interrupts enabled at this point... */
read_register(priv->net_dev, IPW_REG_INTA, &inta);
read_register(priv->net_dev, IPW_REG_INTA_MASK, &inta_mask);
inta &= IPW_INTERRUPT_MASK; /* Clear out any pending interrupts */ if (inta & inta_mask)
write_register(priv->net_dev, IPW_REG_INTA, inta);
IPW_DEBUG_FW("f/w initialization complete: %s\n",
i ? "SUCCESS" : "FAILED");
if (!i) {
printk(KERN_WARNING DRV_NAME ": %s: Firmware did not initialize.\n",
priv->net_dev->name); return -EIO;
}
/* allow firmware to write to GPIO1 & GPIO3 */
read_register(priv->net_dev, IPW_REG_GPIO, &gpio);
/* Step 2. Wait for stop Master Assert
* (not more than 50us, otherwise ret error */
i = 5; do {
udelay(IPW_WAIT_RESET_MASTER_ASSERT_COMPLETE_DELAY);
read_register(priv->net_dev, IPW_REG_RESET_REG, ®);
if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED) break;
} while (--i);
priv->status &= ~STATUS_RESET_PENDING;
if (!i) {
IPW_DEBUG_INFO
("exit - waited too long for master assert stop\n"); return -EIO;
}
/* Reset any fatal_error conditions */
ipw2100_reset_fatalerror(priv);
/* At this point, the adapter is now stopped and disabled */
priv->status &= ~(STATUS_RUNNING | STATUS_ASSOCIATING |
STATUS_ASSOCIATED | STATUS_ENABLED);
return 0;
}
/* * Send the CARD_DISABLE_PHY_OFF command to the card to disable it * * After disabling, if the card was associated, a STATUS_ASSN_LOST will be sent. * * STATUS_CARD_DISABLE_NOTIFICATION will be sent regardless of * if STATUS_ASSN_LOST is sent.
*/ staticint ipw2100_hw_phy_off(struct ipw2100_priv *priv)
{
/* We can only shut down the card if the firmware is operational. So, * if we haven't reset since a fatal_error, then we can not send the
* shutdown commands. */ if (!priv->fatal_error) { /* First, make sure the adapter is enabled so that the PHY_OFF
* command can shut it down */
ipw2100_enable_adapter(priv);
err = ipw2100_hw_phy_off(priv); if (err)
printk(KERN_WARNING DRV_NAME ": Error disabling radio %d\n", err);
/* * If in D0-standby mode going directly to D3 may cause a * PCI bus violation. Therefore we must change out of the D0 * state. * * Sending the PREPARE_FOR_POWER_DOWN will restrict the * hardware from going into standby mode and will transition * out of D0-standby if it is already in that state. * * STATUS_PREPARE_POWER_DOWN_COMPLETE will be sent by the * driver upon completion. Once received, the driver can * proceed to the D3 state. * * Prepare for power down command to fw. This command would * take HW out of D0-standby and prepare it for D3 state. * * Currently FW does not support event notification for this * event. Therefore, skip waiting for it. Just wait a fixed * 100ms
*/
IPW_DEBUG_HC("HOST_PRE_POWER_DOWN\n");
err = ipw2100_hw_send_command(priv, &cmd); if (err)
printk(KERN_WARNING DRV_NAME ": " "%s: Power down command failed: Error %d\n",
priv->net_dev->name, err); else
schedule_timeout_uninterruptible(HW_POWER_DOWN_DELAY);
}
priv->status &= ~STATUS_ENABLED;
/* * Set GPIO 3 writable by FW; GPIO 1 writable * by driver and enable clock
*/
ipw2100_hw_set_gpio(priv);
/* * Power down adapter. Sequence: * 1. Stop master assert (RESET_REG[9]=1) * 2. Wait for stop master (RESET_REG[8]==1) * 3. S/w reset assert (RESET_REG[7] = 1)
*/
/* No scanning if in monitor mode */ if (priv->ieee->iw_mode == IW_MODE_MONITOR) return 1;
if (priv->status & STATUS_SCANNING) {
IPW_DEBUG_SCAN("Scan requested while already in scan...\n"); return 0;
}
IPW_DEBUG_INFO("enter\n");
/* Not clearing here; doing so makes iwlist always return nothing... * * We should modify the table logic to use aging tables vs. clearing * the table on each scan start.
*/
IPW_DEBUG_SCAN("starting scan\n");
staticint ipw2100_up(struct ipw2100_priv *priv, int deferred)
{ unsignedlong flags; int err = 0;
u32 lock;
u32 ord_len = sizeof(lock);
/* Age scan list entries found before suspend */ if (priv->suspend_time) {
libipw_networks_age(priv->ieee, priv->suspend_time);
priv->suspend_time = 0;
}
/* Quiet if manually disabled. */ if (priv->status & STATUS_RF_KILL_SW) {
IPW_DEBUG_INFO("%s: Radio is disabled by Manual Disable " "switch\n", priv->net_dev->name); return 0;
}
/* the ipw2100 hardware really doesn't want power management delays * longer than 175usec
*/
cpu_latency_qos_update_request(&ipw2100_pm_qos_req, 175);
/* If the interrupt is enabled, turn it off... */
spin_lock_irqsave(&priv->low_lock, flags);
ipw2100_disable_interrupts(priv);
/* Reset any fatal_error conditions */
ipw2100_reset_fatalerror(priv);
spin_unlock_irqrestore(&priv->low_lock, flags);
if (priv->status & STATUS_POWERED ||
(priv->status & STATUS_RESET_PENDING)) { /* Power cycle the card ... */
err = ipw2100_power_cycle_adapter(priv); if (err) {
printk(KERN_WARNING DRV_NAME ": %s: Could not cycle adapter.\n",
priv->net_dev->name); gotoexit;
}
} else
priv->status |= STATUS_POWERED;
/* Load the firmware, start the clocks, etc. */
err = ipw2100_start_adapter(priv); if (err) {
printk(KERN_ERR DRV_NAME ": %s: Failed to start the firmware.\n",
priv->net_dev->name); gotoexit;
}
ipw2100_initialize_ordinals(priv);
/* Determine capabilities of this particular HW configuration */
err = ipw2100_get_hw_features(priv); if (err) {
printk(KERN_ERR DRV_NAME ": %s: Failed to determine HW features.\n",
priv->net_dev->name); gotoexit;
}
/* Initialize the geo */
libipw_set_geo(priv->ieee, &ipw_geos[0]);
priv->ieee->freq_band = LIBIPW_24GHZ_BAND;
if (rf_kill_active(priv)) {
printk(KERN_INFO "%s: Radio is disabled by RF switch.\n",
priv->net_dev->name);
if (priv->stop_rf_kill) {
priv->stop_rf_kill = 0;
schedule_delayed_work(&priv->rf_kill,
round_jiffies_relative(HZ));
}
deferred = 1;
}
/* Turn on the interrupt so that commands can be processed */
ipw2100_enable_interrupts(priv);
/* Send all of the commands that must be sent prior to
* HOST_COMPLETE */
err = ipw2100_adapter_setup(priv); if (err) {
printk(KERN_ERR DRV_NAME ": %s: Failed to start the card.\n",
priv->net_dev->name); gotoexit;
}
if (!deferred) { /* Enable the adapter - sends HOST_COMPLETE */
err = ipw2100_enable_adapter(priv); if (err) {
printk(KERN_ERR DRV_NAME ": " "%s: failed in call to enable adapter.\n",
priv->net_dev->name);
ipw2100_hw_stop_adapter(priv); gotoexit;
}
/* Kill the RF switch timer */ if (!priv->stop_rf_kill) {
priv->stop_rf_kill = 1;
cancel_delayed_work(&priv->rf_kill);
}
/* Kill the firmware hang check timer */ if (!priv->stop_hang_check) {
priv->stop_hang_check = 1;
cancel_delayed_work(&priv->hang_check);
}
/* Kill any pending resets */ if (priv->status & STATUS_RESET_PENDING)
cancel_delayed_work(&priv->reset_work);
/* Make sure the interrupt is on so that FW commands will be
* processed correctly */
spin_lock_irqsave(&priv->low_lock, flags);
ipw2100_enable_interrupts(priv);
spin_unlock_irqrestore(&priv->low_lock, flags);
if (ipw2100_hw_stop_adapter(priv))
printk(KERN_ERR DRV_NAME ": %s: Error stopping adapter.\n",
priv->net_dev->name);
/* Do not disable the interrupt until _after_ we disable * the adaptor. Otherwise the CARD_DISABLE command will never
* be ack'd by the firmware */
spin_lock_irqsave(&priv->low_lock, flags);
ipw2100_disable_interrupts(priv);
spin_unlock_irqrestore(&priv->low_lock, flags);
/* Force a power cycle even if interface hasn't been opened
* yet */
cancel_delayed_work(&priv->reset_work);
priv->status |= STATUS_RESET_PENDING;
spin_unlock_irqrestore(&priv->low_lock, flags);
mutex_lock(&priv->action_mutex); /* stop timed checks so that they don't interfere with reset */
priv->stop_hang_check = 1;
cancel_delayed_work(&priv->hang_check);
/* We have to signal any supplicant if we are disassociating */ if (associated)
wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
/* * TBD: BSSID is usually 00:00:00:00:00:00 here and not * an actual MAC of the AP. Seems like FW sets this * address too late. Read it later and expose through * /proc or schedule a later task to query and update
*/
essid_len = IW_ESSID_MAX_SIZE;
ret = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_SSID,
essid, &essid_len); if (ret) {
IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
__LINE__); return;
}
len = sizeof(u32);
ret = ipw2100_get_ordinal(priv, IPW_ORD_CURRENT_TX_RATE, &txrate, &len); if (ret) {
IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
__LINE__); return;
}
len = sizeof(u32);
ret = ipw2100_get_ordinal(priv, IPW_ORD_OUR_FREQ, &chan, &len); if (ret) {
IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
__LINE__); return;
}
len = ETH_ALEN;
ret = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID, bssid,
&len); if (ret) {
IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
__LINE__); return;
}
memcpy(priv->ieee->bssid, bssid, ETH_ALEN);
switch (txrate) { case TX_RATE_1_MBIT:
txratename = "1Mbps"; break; case TX_RATE_2_MBIT:
txratename = "2Mbsp"; break; case TX_RATE_5_5_MBIT:
txratename = "5.5Mbps"; break; case TX_RATE_11_MBIT:
txratename = "11Mbps"; break; default:
IPW_DEBUG_INFO("Unknown rate: %d\n", txrate);
txratename = "unknown rate"; break;
}
IPW_DEBUG_INFO("%s: Associated with '%*pE' at %s, channel %d (BSSID=%pM)\n",
priv->net_dev->name, essid_len, essid,
txratename, chan, bssid);
/* now we copy read ssid into dev */ if (!(priv->config & CFG_STATIC_ESSID)) {
priv->essid_len = min((u8) essid_len, (u8) IW_ESSID_MAX_SIZE);
memcpy(priv->essid, essid, priv->essid_len);
}
priv->channel = chan;
memcpy(priv->bssid, bssid, ETH_ALEN);
staticint ipw2100_set_essid(struct ipw2100_priv *priv, char *essid, int length, int batch_mode)
{ int ssid_len = min(length, IW_ESSID_MAX_SIZE); struct host_command cmd = {
.host_command = SSID,
.host_command_sequence = 0,
.host_command_length = ssid_len
}; int err;
IPW_DEBUG_HC("SSID: '%*pE'\n", ssid_len, essid);
if (ssid_len)
memcpy(cmd.host_command_parameters, essid, ssid_len);
if (!batch_mode) {
err = ipw2100_disable_adapter(priv); if (err) return err;
}
/* Bug in FW currently doesn't honor bit 0 in SET_SCAN_OPTIONS to
* disable auto association -- so we cheat by setting a bogus SSID */ if (!ssid_len && !(priv->config & CFG_ASSOCIATE)) { int i;
u8 *bogus = (u8 *) cmd.host_command_parameters; for (i = 0; i < IW_ESSID_MAX_SIZE; i++)
bogus[i] = 0x18 + i;
cmd.host_command_length = IW_ESSID_MAX_SIZE;
}
/* NOTE: We always send the SSID command even if the provided ESSID is
* the same as what we currently think is set. */
s = in_buf; if (mode == SEARCH_SNAPSHOT) { if (!ipw2100_snapshot_alloc(priv))
mode = SEARCH_DISCARD;
}
for (ret = SEARCH_FAIL, i = 0; i < 0x30000; i += 4) {
read_nic_dword(priv->net_dev, i, &tmp); if (mode == SEARCH_SNAPSHOT)
*(u32 *) SNAPSHOT_ADDR(i) = tmp; if (ret == SEARCH_FAIL) {
d = (u8 *) & tmp; for (j = 0; j < 4; j++) { if (*s != *d) {
s = in_buf; continue;
}
s++;
d++;
if ((s - in_buf) == len)
ret = (i + j) - len + 1;
}
} elseif (mode == SEARCH_DISCARD) return ret;
}
return ret;
} #endif
/* * * 0) Disconnect the SKB from the firmware (just unmap) * 1) Pack the ETH header into the SKB * 2) Pass the SKB to the network stack * * When packet is provided by the firmware, it contains the following: * * . libipw_hdr * . libipw_snap_hdr * * The size of the constructed ethernet *
*/ #ifdef IPW2100_RX_DEBUG static u8 packet_data[IPW_RX_NIC_BUFFER_LENGTH]; #endif
staticvoid ipw2100_corruption_detected(struct ipw2100_priv *priv, int i)
{ #ifdef IPW2100_DEBUG_C3 struct ipw2100_status *status = &priv->status_queue.drv[i];
u32 match, reg; int j; #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.