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
IPW_DEBUG_INFO(": PCI latency error detected at 0x%04zX.\n",
i * sizeof(struct ipw2100_status));
#ifdef IPW2100_DEBUG_C3 /* Halt the firmware so we can get a good image */
write_register(priv->net_dev, IPW_REG_RESET_REG,
IPW_AUX_HOST_RESET_REG_STOP_MASTER);
j = 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 (j--);
match = ipw2100_match_buf(priv, (u8 *) status, sizeof(struct ipw2100_status),
SEARCH_SNAPSHOT); if (match < SEARCH_SUCCESS)
IPW_DEBUG_INFO("%s: DMA status match in Firmware at " "offset 0x%06X, length %d:\n",
priv->net_dev->name, match, sizeof(struct ipw2100_status)); else
IPW_DEBUG_INFO("%s: No DMA status match in " "Firmware.\n", priv->net_dev->name);
if (unlikely(!netif_running(dev))) {
dev->stats.rx_errors++;
priv->wstats.discard.misc++;
IPW_DEBUG_DROP("Dropping packet while interface is not up.\n"); return;
}
if (unlikely(priv->ieee->iw_mode != IW_MODE_MONITOR &&
!(priv->status & STATUS_ASSOCIATED))) {
IPW_DEBUG_DROP("Dropping packet while not associated.\n");
priv->wstats.discard.misc++; return;
}
#ifdef IPW2100_RX_DEBUG /* Make a copy of the frame so we can dump it to the logs if
* libipw_rx fails */
skb_copy_from_linear_data(packet->skb, packet_data,
min_t(u32, status->frame_size,
IPW_RX_NIC_BUFFER_LENGTH)); #endif
if (!libipw_rx(priv->ieee, packet->skb, stats)) { #ifdef IPW2100_RX_DEBUG
IPW_DEBUG_DROP("%s: Non consumed packet:\n",
dev->name);
printk_buf(IPW_DL_DROP, packet_data, status->frame_size); #endif
dev->stats.rx_errors++;
/* libipw_rx failed, so it didn't free the SKB */
dev_kfree_skb_any(packet->skb);
packet->skb = NULL;
}
/* We need to allocate a new SKB and attach it to the RDB. */ if (unlikely(ipw2100_alloc_skb(priv, packet))) {
printk(KERN_WARNING DRV_NAME ": " "%s: Unable to allocate SKB onto RBD ring - disabling " "adapter.\n", dev->name); /* TODO: schedule adapter shutdown */
IPW_DEBUG_INFO("TODO: Shutdown adapter...\n");
}
/* Update the RDB entry */
priv->rx_queue.drv[i].host_addr = packet->dma_addr;
}
/* Magic struct that slots into the radiotap header -- no reason * to build this manually element by element, we can write it much
* more efficiently than we can parse it. ORDER MATTERS HERE */ struct ipw_rt_hdr { struct ieee80211_radiotap_header_fixed rt_hdr;
s8 rt_dbmsignal; /* signal in dbM, kluged to signed */
} *ipw_rt;
if (unlikely(!netif_running(dev))) {
dev->stats.rx_errors++;
priv->wstats.discard.misc++;
IPW_DEBUG_DROP("Dropping packet while interface is not up.\n"); return;
}
if (unlikely(priv->config & CFG_CRC_CHECK &&
status->flags & IPW_STATUS_FLAG_CRC_ERROR)) {
IPW_DEBUG_RX("CRC error in packet. Dropping.\n");
dev->stats.rx_errors++; return;
}
ipw_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION;
ipw_rt->rt_hdr.it_pad = 0; /* always good to zero */
ipw_rt->rt_hdr.it_len = cpu_to_le16(sizeof(struct ipw_rt_hdr)); /* total hdr+data */
if (!libipw_rx(priv->ieee, packet->skb, stats)) {
dev->stats.rx_errors++;
/* libipw_rx failed, so it didn't free the SKB */
dev_kfree_skb_any(packet->skb);
packet->skb = NULL;
}
/* We need to allocate a new SKB and attach it to the RDB. */ if (unlikely(ipw2100_alloc_skb(priv, packet))) {
IPW_DEBUG_WARNING( "%s: Unable to allocate SKB onto RBD ring - disabling " "adapter.\n", dev->name); /* TODO: schedule adapter shutdown */
IPW_DEBUG_INFO("TODO: Shutdown adapter...\n");
}
/* Update the RDB entry */
priv->rx_queue.drv[i].host_addr = packet->dma_addr;
}
switch (frame_type) { case COMMAND_STATUS_VAL: return (status->frame_size != sizeof(u->rx_data.command)); case STATUS_CHANGE_VAL: return (status->frame_size != sizeof(u->rx_data.status)); case HOST_NOTIFICATION_VAL: return (status->frame_size < sizeof(u->rx_data.notification)); case P80211_DATA_VAL: case P8023_DATA_VAL: #ifdef CONFIG_IPW2100_MONITOR return 0; #else switch (WLAN_FC_GET_TYPE(le16_to_cpu(u->rx_data.header.frame_ctl))) { case IEEE80211_FTYPE_MGMT: case IEEE80211_FTYPE_CTL: return 0; case IEEE80211_FTYPE_DATA: return (status->frame_size >
IPW_MAX_802_11_PAYLOAD_LENGTH);
} #endif
}
return 1;
}
/* * ipw2100 interrupts are disabled at this point, and the ISR * is the only code that calls this method. So, we do not need * to play with any locks. * * RX Queue works as follows: * * Read index - firmware places packet in entry identified by the * Read index and advances Read index. In this manner, * Read index will always point to the next packet to * be filled--but not yet valid. * * Write index - driver fills this entry with an unused RBD entry. * This entry has not filled by the firmware yet. * * In between the W and R indexes are the RBDs that have been received * but not yet processed. * * The process of handling packets will start at WRITE + 1 and advance * until it reaches the READ index. * * The WRITE index is cached in the variable 'priv->rx_queue.next'. *
*/ staticvoid __ipw2100_rx_process(struct ipw2100_priv *priv)
{ struct ipw2100_bd_queue *rxq = &priv->rx_queue; struct ipw2100_status_queue *sq = &priv->status_queue; struct ipw2100_rx_packet *packet;
u16 frame_type;
u32 r, w, i, s; struct ipw2100_rx *u; struct libipw_rx_stats stats = {
.mac_time = jiffies,
};
if (r >= rxq->entries) {
IPW_DEBUG_RX("exit - bad read index\n"); return;
}
i = (rxq->next + 1) % rxq->entries;
s = i; while (i != r) { /* IPW_DEBUG_RX("r = %d : w = %d : processing = %d\n",
r, rxq->next, i); */
packet = &priv->rx_buffers[i];
/* Sync the DMA for the RX buffer so CPU is sure to get
* the correct values */
dma_sync_single_for_cpu(&priv->pci_dev->dev, packet->dma_addr, sizeof(struct ipw2100_rx),
DMA_FROM_DEVICE);
if (unlikely(ipw2100_corruption_check(priv, i))) {
ipw2100_corruption_detected(priv, i); goto increment;
}
/* * __ipw2100_tx_process * * This routine will determine whether the next packet on * the fw_pend_list has been processed by the firmware yet. * * If not, then it does nothing and returns. * * If so, then it removes the item from the fw_pend_list, frees * any associated storage, and places the item back on the * free list of its source (either msg_free_list or tx_free_list) * * TX Queue works as follows: * * Read index - points to the next TBD that the firmware will * process. The firmware will read the data, and once * done processing, it will advance the Read index. * * Write index - driver fills this entry with an constructed TBD * entry. The Write index is not advanced until the * packet has been configured. * * In between the W and R indexes are the TBDs that have NOT been * processed. Lagging behind the R index are packets that have * been processed but have not been freed by the driver. * * In order to free old storage, an internal index will be maintained * that points to the next packet to be freed. When all used * packets have been freed, the oldest index will be the same as the * firmware's read index. * * The OLDEST index is cached in the variable 'priv->tx_queue.oldest' * * Because the TBD structure can not contain arbitrary data, the * driver must keep an internal queue of cached allocations such that * it can put that data back into the tx_free_list and msg_free_list * for use by future command and data packets. *
*/ staticint __ipw2100_tx_process(struct ipw2100_priv *priv)
{ struct ipw2100_bd_queue *txq = &priv->tx_queue; struct ipw2100_bd *tbd; struct list_head *element; struct ipw2100_tx_packet *packet; int descriptors_used; int e, i;
u32 r, w, frag_num = 0;
/* Determine how many TBD entries must be finished... */ switch (packet->type) { case COMMAND: /* COMMAND uses only one slot; don't advance */
descriptors_used = 1;
e = txq->oldest; break;
case DATA: /* DATA uses two slots; advance and loop position. */
descriptors_used = tbd->num_fragments;
frag_num = tbd->num_fragments - 1;
e = txq->oldest + frag_num;
e %= txq->entries; break;
/* if the last TBD is not done by NIC yet, then packet is * not ready to be released. *
*/
read_register(priv->net_dev, IPW_MEM_HOST_SHARED_TX_QUEUE_READ_INDEX,
&r);
read_register(priv->net_dev, IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX,
&w); if (w != txq->next)
printk(KERN_WARNING DRV_NAME ": %s: write index mismatch\n",
priv->net_dev->name);
/* * txq->next is the index of the last packet written txq->oldest is * the index of the r is the index of the next packet to be read by * firmware
*/
/* * Quick graphic to help you visualize the following * if / else statement * * ===>| s---->|=============== * e>| * | a | b | c | d | e | f | g | h | i | j | k | l * r---->| * w * * w - updated by driver * r - updated by firmware * s - start of oldest BD entry (txq->oldest) * e - end of oldest BD entry *
*/ if (!((r <= w && (e < r || e >= w)) || (e < r && e >= w))) {
IPW_DEBUG_TX("exit - no processed packets ready to release.\n"); return 0;
}
list_del(element);
DEC_STAT(&priv->fw_pend_stat);
#ifdef CONFIG_IPW2100_DEBUG
{
i = txq->oldest;
IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i,
&txq->drv[i],
(u32) (txq->nic + i * sizeof(struct ipw2100_bd)),
txq->drv[i].host_addr, txq->drv[i].buf_length);
if (packet->type == DATA) {
i = (i + 1) % txq->entries;
IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i,
&txq->drv[i],
(u32) (txq->nic + i * sizeof(struct ipw2100_bd)),
(u32) txq->drv[i].host_addr,
txq->drv[i].buf_length);
}
} #endif
switch (packet->type) { case DATA: if (txq->drv[txq->oldest].status.info.fields.txType != 0)
printk(KERN_WARNING DRV_NAME ": %s: Queue mismatch. " "Expecting DATA TBD but pulled " "something else: ids %d=%d.\n",
priv->net_dev->name, txq->oldest, packet->index);
/* DATA packet; we have to unmap and free the SKB */ for (i = 0; i < frag_num; i++) {
tbd = &txq->drv[(packet->index + 1 + i) % txq->entries];
/* We have a free slot in the Tx queue, so wake up the
* transmit layer if it is stopped. */ if (priv->status & STATUS_ASSOCIATED)
netif_wake_queue(priv->net_dev);
/* A packet was processed by the hardware, so update the
* watchdog */
netif_trans_update(priv->net_dev);
break;
case COMMAND: if (txq->drv[txq->oldest].status.info.fields.txType != 1)
printk(KERN_WARNING DRV_NAME ": %s: Queue mismatch. " "Expecting COMMAND TBD but pulled " "something else: ids %d=%d.\n",
priv->net_dev->name, txq->oldest, packet->index);
/* advance oldest used TBD pointer to start of next entry */
txq->oldest = (e + 1) % txq->entries; /* increase available TBDs number */
txq->available += descriptors_used;
SET_STAT(&priv->txq_stat, txq->available);
IPW_DEBUG_TX("packet latency (send to process) %ld jiffies\n",
jiffies - packet->jiffy_start);
return (!list_empty(&priv->fw_pend_list));
}
staticinlinevoid __ipw2100_tx_complete(struct ipw2100_priv *priv)
{ int i = 0;
while (__ipw2100_tx_process(priv) && i < 200)
i++;
if (i == 200) {
printk(KERN_WARNING DRV_NAME ": " "%s: Driver is running slow (%d iters).\n",
priv->net_dev->name, i);
}
}
while (!list_empty(&priv->msg_pend_list)) { /* if there isn't enough space in TBD queue, then * don't stuff a new one in. * NOTE: 3 are needed as a command will take one, * and there is a minimum of 2 that must be * maintained between the r and w indexes
*/ if (txq->available <= 3) {
IPW_DEBUG_TX("no room in tx_queue\n"); break;
}
element = priv->msg_pend_list.next;
list_del(element);
DEC_STAT(&priv->msg_pend_stat);
if (txq->next != next) { /* kick off the DMA by notifying firmware the
* write index has moved; make sure TBD stores are sync'd */
wmb();
write_register(priv->net_dev,
IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX,
txq->next);
}
}
/* * ipw2100_tx_send_data *
*/ staticvoid ipw2100_tx_send_data(struct ipw2100_priv *priv)
{ struct list_head *element; struct ipw2100_tx_packet *packet; struct ipw2100_bd_queue *txq = &priv->tx_queue; struct ipw2100_bd *tbd; int next = txq->next; int i = 0; struct ipw2100_data_header *ipw_hdr; struct libipw_hdr_3addr *hdr;
while (!list_empty(&priv->tx_pend_list)) { /* if there isn't enough space in TBD queue, then * don't stuff a new one in. * NOTE: 4 are needed as a data will take two, * and there is a minimum of 2 that must be * maintained between the r and w indexes
*/
element = priv->tx_pend_list.next;
packet = list_entry(element, struct ipw2100_tx_packet, list);
if (unlikely(1 + packet->info.d_struct.txb->nr_frags >
IPW_MAX_BDS)) { /* TODO: Support merging buffers if more than
* IPW_MAX_BDS are used */
IPW_DEBUG_INFO("%s: Maximum BD threshold exceeded. " "Increase fragmentation level.\n",
priv->net_dev->name);
}
if (txq->available <= 3 + packet->info.d_struct.txb->nr_frags) {
IPW_DEBUG_TX("no room in tx_queue\n"); break;
}
/* For now we only support host based encryption */
ipw_hdr->needs_encryption = 0;
ipw_hdr->encrypted = packet->info.d_struct.txb->encrypted; if (packet->info.d_struct.txb->nr_frags > 1)
ipw_hdr->fragment_size =
packet->info.d_struct.txb->frag_size -
LIBIPW_3ADDR_LEN; else
ipw_hdr->fragment_size = 0;
if (txq->next != next) { /* kick off the DMA by notifying firmware the
* write index has moved; make sure TBD stores are sync'd */
write_register(priv->net_dev,
IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX,
txq->next);
}
}
/* We do not loop and keep polling for more interrupts as this * is frowned upon and doesn't play nicely with other potentially
* chained IRQs */
IPW_DEBUG_ISR("INTA: 0x%08lX\n",
(unsignedlong)inta & IPW_INTERRUPT_MASK);
/* We check to see if we should be ignoring interrupts before * we touch the hardware. During ucode load if we try and handle * an interrupt we can cause keyboard problems as well as cause
* the ucode to fail to initialize */ if (!(priv->status & STATUS_INT_ENABLED)) { /* Shared IRQ */ goto none;
}
/* We disable the hardware interrupt here just to prevent unneeded * calls to be made. We disable this again within the actual * work tasklet, so if another part of the code re-enables the
* interrupt, that is fine */
ipw2100_disable_interrupts(priv);
if (!(priv->status & STATUS_ASSOCIATED)) {
IPW_DEBUG_INFO("Can not transmit when not connected.\n");
priv->net_dev->stats.tx_carrier_errors++;
netif_stop_queue(dev); goto fail_unlock;
}
if (list_empty(&priv->tx_free_list)) goto fail_unlock;
element = priv->tx_free_list.next;
packet = list_entry(element, struct ipw2100_tx_packet, list);
packet->info.d_struct.txb = txb;
IPW_DEBUG_TX("Sending fragment (%d bytes):\n", txb->fragments[0]->len);
printk_buf(IPW_DL_TX, txb->fragments[0]->data, txb->fragments[0]->len);
for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++)
list_add_tail(&priv->msg_buffers[i].list, &priv->msg_free_list);
SET_STAT(&priv->msg_free_stat, i);
return 0;
}
staticvoid ipw2100_msg_free(struct ipw2100_priv *priv)
{ int i;
if (!priv->msg_buffers) return;
for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {
dma_free_coherent(&priv->pci_dev->dev, sizeof(struct ipw2100_cmd_header),
priv->msg_buffers[i].info.c_struct.cmd,
priv->msg_buffers[i].info.c_struct.cmd_phys);
}
/* sysfs provides us PAGE_SIZE buffer */ while (len < PAGE_SIZE - 128 && loop < 0x30000) {
if (priv->snapshot[0]) for (i = 0; i < 4; i++)
buffer[i] =
*(u32 *) SNAPSHOT_ADDR(loop + i * 4); else for (i = 0; i < 4; i++)
read_nic_dword(dev, loop + i * 4, &buffer[i]);
length = IW_ESSID_MAX_SIZE;
ret = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_SSID, essid, &length); if (ret)
IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
__LINE__);
length = sizeof(bssid);
ret = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID,
bssid, &length); if (ret)
IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
__LINE__);
length = sizeof(u32);
ret = ipw2100_get_ordinal(priv, IPW_ORD_OUR_FREQ, &chan, &length); if (ret)
IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
__LINE__);
out += sprintf(out, "ESSID: %s\n", essid);
out += sprintf(out, "BSSID: %pM\n", bssid);
out += sprintf(out, "Channel: %d\n", chan);
IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n",
disable_radio ? "OFF" : "ON");
mutex_lock(&priv->action_mutex);
if (disable_radio) {
priv->status |= STATUS_RF_KILL_SW;
ipw2100_down(priv);
} else {
priv->status &= ~STATUS_RF_KILL_SW; if (rf_kill_active(priv)) {
IPW_DEBUG_RF_KILL("Can not turn radio back on - " "disabled by HW switch\n"); /* Make sure the RF_KILL check timer is running */
priv->stop_rf_kill = 0;
mod_delayed_work(system_wq, &priv->rf_kill,
round_jiffies_relative(HZ));
} else
schedule_reset(priv);
}
for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) { /* We simply drop any SKBs that have been queued for
* transmit */ if (priv->tx_buffers[i].info.d_struct.txb) {
libipw_txb_free(priv->tx_buffers[i].info.d_struct.
txb);
priv->tx_buffers[i].info.d_struct.txb = NULL;
}
for (i = 0; i < RX_QUEUE_LENGTH; i++) { if (priv->rx_buffers[i].rxp) {
dma_unmap_single(&priv->pci_dev->dev,
priv->rx_buffers[i].dma_addr, sizeof(struct ipw2100_rx),
DMA_FROM_DEVICE);
dev_kfree_skb(priv->rx_buffers[i].skb);
}
}
/* 11b only */ /*cmd.host_command_parameters[0] |= DIVERSITY_ANTENNA_A; */
err = ipw2100_hw_send_command(priv, &cmd); if (err) return err;
/* If IPv6 is configured in the kernel then we don't want to filter out all
* of the multicast packets as IPv6 needs some. */ #if !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE)
cmd.host_command = ADD_MULTICAST;
cmd.host_command_sequence = 0;
cmd.host_command_length = 0;
ipw2100_hw_send_command(priv, &cmd); #endif if (!batch_mode) {
err = ipw2100_enable_adapter(priv); if (err) return err;
}
/* The Firmware currently ignores the BSSID and just disassociates from * the currently associated AP -- but in the off chance that a future * firmware does use the BSSID provided here, we go ahead and try and
* set it to the currently associated AP's BSSID */
memcpy(cmd.host_command_parameters, priv->bssid, ETH_ALEN);
staticint ipw2100_set_security_information(struct ipw2100_priv *priv, int auth_mode, int security_level, int unicast_using_group, int batch_mode)
{ struct host_command cmd = {
.host_command = SET_SECURITY_INFORMATION,
.host_command_sequence = 0,
.host_command_length = sizeof(struct security_info_params)
}; struct security_info_params *security =
(struct security_info_params *)&cmd.host_command_parameters; int err;
memset(security, 0, sizeof(*security));
/* If shared key AP authentication is turned on, then we need to * configure the firmware to try and use it. *
* Actual data encryption/decryption is handled by the host. */
security->auth_mode = auth_mode;
security->unicast_using_group = unicast_using_group;
/** * ipw2100_set_key() - Set a the wep key * * @priv: struct to work on * @idx: index of the key we want to set * @key: ptr to the key data to set * @len: length of the buffer at @key * @batch_mode: FIXME perform the operation in batch mode, not * disabling the device. * * @returns 0 if OK, < 0 errno code on error. * * Fill out a command structure with the new wep key, length an * index and send it down the wire.
*/ staticint ipw2100_set_key(struct ipw2100_priv *priv, int idx, char *key, int len, int batch_mode)
{ int keylen = len ? (len <= 5 ? 5 : 13) : 0; struct host_command cmd = {
.host_command = WEP_KEY_INFO,
.host_command_sequence = 0,
.host_command_length = sizeof(struct ipw2100_wep_key),
}; struct ipw2100_wep_key *wep_key = (void *)cmd.host_command_parameters; int err;
IPW_DEBUG_HC("WEP_KEY_INFO: index = %d, len = %d/%d\n",
idx, keylen, len);
/* NOTE: We don't check cached values in case the firmware was reset * or some other problem is occurring. If the user is setting the key,
* then we push the change */
/* Will be optimized out on debug not being configured in */ if (keylen == 0)
IPW_DEBUG_WEP("%s: Clearing key %d\n",
priv->net_dev->name, wep_key->idx); elseif (keylen == 5)
IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_64 "\n",
priv->net_dev->name, wep_key->idx, wep_key->len,
WEP_STR_64(wep_key->key)); else
IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_128 "\n",
priv->net_dev->name, wep_key->idx, wep_key->len,
WEP_STR_128(wep_key->key));
if (!batch_mode) {
err = ipw2100_disable_adapter(priv); /* FIXME: IPG: shouldn't this prink be in _disable_adapter()? */ if (err) {
printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
priv->net_dev->name, err); return err;
}
}
/* send cmd to firmware */
err = ipw2100_hw_send_command(priv, &cmd);
if (!batch_mode) { int err2 = ipw2100_enable_adapter(priv); if (err == 0)
err = err2;
} return err;
}
staticint ipw2100_set_key_index(struct ipw2100_priv *priv, int idx, int batch_mode)
{ struct host_command cmd = {
.host_command = WEP_KEY_INDEX,
.host_command_sequence = 0,
.host_command_length = 4,
.host_command_parameters = {idx},
}; int err;
IPW_DEBUG_HC("WEP_KEY_INDEX: index = %d\n", idx);
if (idx < 0 || idx > 3) return -EINVAL;
if (!batch_mode) {
err = ipw2100_disable_adapter(priv); if (err) {
printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
priv->net_dev->name, err); return err;
}
}
/* send cmd to firmware */
err = ipw2100_hw_send_command(priv, &cmd);
if (!batch_mode)
ipw2100_enable_adapter(priv);
return err;
}
staticint ipw2100_configure_security(struct ipw2100_priv *priv, int batch_mode)
{ int i, err, auth_mode, sec_level, use_group;
if (!(priv->status & STATUS_RUNNING)) return 0;
if (!batch_mode) {
err = ipw2100_disable_adapter(priv); if (err) return err;
}
/* Always enable privacy so the Host can filter WEP packets if
* encrypted data is sent up */
err =
ipw2100_set_wep_flags(priv,
priv->ieee->sec.
enabled ? IPW_PRIVACY_CAPABLE : 0, 1); if (err) gotoexit;
priv->status &= ~STATUS_SECURITY_UPDATED;
exit: if (!batch_mode)
ipw2100_enable_adapter(priv);
/* If we happen to have reconnected before we get a chance to * process this, then update the security settings--which causes
* a disassociation to occur */ if (!(priv->status & STATUS_ASSOCIATED) &&
priv->status & STATUS_SECURITY_UPDATED)
ipw2100_configure_security(priv, 0);
}
/* As a temporary work around to enable WPA until we figure out why * wpa_supplicant toggles the security capability of the driver, which * forces a disassociation with force_update... *
* if (force_update || !(priv->status & STATUS_ASSOCIATED))*/ if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)))
ipw2100_configure_security(priv, 0);
done:
mutex_unlock(&priv->action_mutex);
}
staticint ipw2100_adapter_setup(struct ipw2100_priv *priv)
{ int err; int batch_mode = 1;
u8 *bssid;
IPW_DEBUG_INFO("enter\n");
err = ipw2100_disable_adapter(priv); if (err) return err; #ifdef CONFIG_IPW2100_MONITOR if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
err = ipw2100_set_channel(priv, priv->channel, batch_mode); if (err) return err;
IPW_DEBUG_INFO("exit\n");
return 0;
} #endif/* CONFIG_IPW2100_MONITOR */
err = ipw2100_read_mac_address(priv); if (err) return -EIO;
err = ipw2100_set_mac_address(priv, batch_mode); if (err) return err;
err = ipw2100_set_port_type(priv, priv->ieee->iw_mode, batch_mode); if (err) return err;
if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
err = ipw2100_set_channel(priv, priv->channel, batch_mode); if (err) return err;
}
err = ipw2100_system_config(priv, batch_mode); if (err) return err;
err = ipw2100_set_tx_rates(priv, priv->tx_rates, batch_mode); if (err) return err;
/* Default to power mode OFF */
err = ipw2100_set_power_mode(priv, IPW_POWER_MODE_CAM); if (err) return err;
err = ipw2100_set_rts_threshold(priv, priv->rts_threshold); if (err) return err;
if (priv->config & CFG_STATIC_BSSID)
bssid = priv->bssid; else
bssid = NULL;
err = ipw2100_set_mandatory_bssid(priv, bssid, batch_mode); if (err) return err;
/************************************************************************* * * EXTERNALLY CALLED METHODS *
*************************************************************************/
/* This method is called by the network layer -- not to be confused with * ipw2100_set_mac_address() declared above called by this driver (and this
* method as well) to talk to the firmware */ staticint ipw2100_set_address(struct net_device *dev, void *p)
{ struct ipw2100_priv *priv = libipw_priv(dev); struct sockaddr *addr = p; int err = 0;
if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL;
staticint ipw2100_wpa_enable(struct ipw2100_priv *priv, int value)
{ /* This is called when wpa_supplicant loads and closes the driver
* interface. */
priv->ieee->wpa_enabled = value; return 0;
}
staticint ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value)
{
struct libipw_device *ieee = priv->ieee; struct libipw_security sec = {
.flags = SEC_AUTH_MODE,
}; int ret = 0;
if (priv->fatal_error != 0) { /* If fatal_error is set then we need to restart */
IPW_DEBUG_INFO("%s: Hardware fatal error detected.\n",
priv->net_dev->name);
/* NOTE: We don't use the wireless_handlers hook * in dev as the system will start throwing WX requests * to us before we're actually initialized and it just * ends up causing problems. So, we just handle
* the WX extensions through the ipw2100_ioctl interface */
/* memset() puts everything to 0, so we only have explicitly set
* those values that need to be something else */
/* If power management is turned on, default to AUTO mode */
priv->power_mode = IPW_POWER_AUTO;
/* We disable the RETRY_TIMEOUT register (0x41) to keep
* PCI Tx retries from interfering with C3 CPU state */
pci_read_config_dword(pci_dev, 0x40, &val); if ((val & 0x0000ff00) != 0)
pci_write_config_dword(pci_dev, 0x40, val & 0xffff00ff);
if (!ipw2100_hw_is_adapter_in_system(dev)) {
printk(KERN_WARNING DRV_NAME "Device not found via register read.\n");
err = -ENODEV; goto fail;
}
SET_NETDEV_DEV(dev, &pci_dev->dev);
/* Force interrupts to be shut off on the device */
priv->status |= STATUS_INT_ENABLED;
ipw2100_disable_interrupts(priv);
/* Allocate and initialize the Tx/Rx queues and lists */ if (ipw2100_queues_allocate(priv)) {
printk(KERN_WARNING DRV_NAME "Error calling ipw2100_queues_allocate.\n");
err = -ENOMEM; goto fail;
}
ipw2100_queues_initialize(priv);
err = ipw2100_wdev_init(dev); if (err) goto fail;
registered = 1;
/* Bring up the interface. Pre 0.46, after we registered the * network device we would call ipw2100_up. This introduced a race * condition with newer hotplug configurations (network was coming * up and making calls before the device was initialized).
*/
err = register_netdev(dev); if (err) {
printk(KERN_WARNING DRV_NAME "Error calling register_netdev.\n"); goto fail;
}
registered = 2;
mutex_lock(&priv->action_mutex);
IPW_DEBUG_INFO("%s: Bound to %s\n", dev->name, pci_name(pci_dev));
/* perform this after register_netdev so that dev->name is set */
err = sysfs_create_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); if (err) goto fail_unlock;
/* If the RF Kill switch is disabled, go ahead and complete the
* startup sequence */ if (!(priv->status & STATUS_RF_KILL_MASK)) { /* Enable the adapter - sends HOST_COMPLETE */ if (ipw2100_enable_adapter(priv)) {
printk(KERN_WARNING DRV_NAME ": %s: failed in call to enable adapter.\n",
priv->net_dev->name);
ipw2100_hw_stop_adapter(priv);
err = -EIO; goto fail_unlock;
}
fail_unlock:
mutex_unlock(&priv->action_mutex);
fail: if (dev) { if (registered >= 2)
unregister_netdev(dev);
if (registered) {
wiphy_unregister(priv->ieee->wdev.wiphy);
kfree(priv->ieee->bg_band.channels);
}
ipw2100_hw_stop_adapter(priv);
ipw2100_disable_interrupts(priv);
if (dev->irq)
free_irq(dev->irq, priv);
ipw2100_kill_works(priv);
/* These are safe to call even if they weren't allocated */
ipw2100_queues_free(priv);
sysfs_remove_group(&pci_dev->dev.kobj,
&ipw2100_attribute_group);
#ifdef CONFIG_PM if (ipw2100_firmware.version)
ipw2100_release_firmware(priv, &ipw2100_firmware); #endif /* Take down the hardware */
ipw2100_down(priv);
/* Release the mutex so that the network subsystem can
* complete any needed calls into the driver... */
mutex_unlock(&priv->action_mutex);
/* Unregister the device first - this results in close() * being called if the device is open. If we free storage * first, then close() will crash.
* FIXME: remove the comment above. */
unregister_netdev(dev);
/* wiphy_unregister needs to be here, before free_libipw */
wiphy_unregister(priv->ieee->wdev.wiphy);
kfree(priv->ieee->bg_band.channels);
free_libipw(dev, 0);
IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name);
/* * Suspend/Resume resets the PCI configuration space, so we have to * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries * from interfering with C3 CPU state. pci_restore_state won't help * here since it only restores the first 64 bytes pci config header.
*/
pci_read_config_dword(pci_dev, 0x40, &val); if ((val & 0x0000ff00) != 0)
pci_write_config_dword(pci_dev, 0x40, val & 0xffff00ff);
/* Set the device back into the PRESENT state; this will also wake
* the queue of needed */
netif_device_attach(dev);
/* * Initialize the ipw2100 driver/module * * @returns 0 if ok, < 0 errno node con error. * * Note: we cannot init the /proc stuff until the PCI driver is there, * or we risk an unlikely race condition on someone accessing * uninitialized data in the PCI dev struct through /proc.
*/ staticint __init ipw2100_init(void)
{ int ret;
ret = pci_register_driver(&ipw2100_pci_driver); if (ret) goto out;
#ifdef CONFIG_IPW2100_DEBUG
ipw2100_debug_level = debug;
ret = driver_create_file(&ipw2100_pci_driver.driver,
&driver_attr_debug_level); #endif
out: return ret;
}
/* * Cleanup ipw2100 driver registration
*/ staticvoid __exit ipw2100_exit(void)
{ /* FIXME: IPG: check that we have no instances of the devices open */ #ifdef CONFIG_IPW2100_DEBUG
driver_remove_file(&ipw2100_pci_driver.driver,
&driver_attr_debug_level); #endif
pci_unregister_driver(&ipw2100_pci_driver);
cpu_latency_qos_remove_request(&ipw2100_pm_qos_req);
}
staticint ipw2100_wx_get_name(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
/* if setting by freq convert to channel */ if (fwrq->e == 1) { if ((fwrq->m >= (int)2.412e8 && fwrq->m <= (int)2.487e8)) { int f = fwrq->m / 100000; int c = 0;
while ((c < REG_MAX_CHANNEL) &&
(f != ipw2100_frequencies[c]))
c++;
/* hack to fall through */
fwrq->e = 0;
fwrq->m = c + 1;
}
}
staticint ipw2100_wx_get_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
struct ipw2100_priv *priv = libipw_priv(dev);
wrqu->freq.e = 0;
/* If we are associated, trying to associate, or have a statically
* configured CHANNEL then return that; otherwise return ANY */ if (priv->config & CFG_STATIC_CHANNEL ||
priv->status & STATUS_ASSOCIATED)
wrqu->freq.m = priv->channel; else
wrqu->freq.m = 0;
staticint ipw2100_wx_get_mode(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
staticint ipw2100_wx_get_range(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
struct ipw2100_priv *priv = libipw_priv(dev); struct iw_range *range = (struct iw_range *)extra;
u16 val; int i, level;
// range->sensitivity; /* signal level threshold range */
range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */
range->max_qual.level = 0;
range->max_qual.noise = 0;
range->max_qual.updated = 7; /* Updated all three */
range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */ /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
range->avg_qual.level = 20 + IPW2100_RSSI_TO_DBM;
range->avg_qual.noise = 0;
range->avg_qual.updated = 7; /* Updated all three */
range->num_bitrates = RATE_COUNT;
for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) {
range->bitrate[i] = ipw2100_bg_rates[i].bitrate * 100 * 1000;
}
/* How to decode max/min PM period */
range->pmp_flags = IW_POWER_PERIOD; /* How to decode max/min PM period */
range->pmt_flags = IW_POWER_TIMEOUT; /* What PM options are supported */
range->pm_capa = IW_POWER_TIMEOUT | IW_POWER_PERIOD;
range->encoding_size[0] = 5;
range->encoding_size[1] = 13; /* Different token sizes */
range->num_encoding_sizes = 2; /* Number of entry in the list */
range->max_encoding_tokens = WEP_KEYS; /* Max number of tokens */ // range->encoding_login_index; /* token index for login token */
/* Set the Wireless Extension versions */
range->we_version_compiled = WIRELESS_EXT;
range->we_version_source = 18;
// range->retry_capa; /* What retry options are supported */ // range->retry_flags; /* How to decode max/min retry limit */ // range->r_time_flags; /* How to decode max/min retry life */ // range->min_retry; /* Minimal number of retries */ // range->max_retry; /* Maximal number of retries */ // range->min_r_time; /* Minimal retry lifetime */ // range->max_r_time; /* Maximal retry lifetime */
range->num_channels = FREQ_COUNT;
val = 0; for (i = 0; i < FREQ_COUNT; i++) { // TODO: Include only legal frequencies for some countries // if (local->channel_mask & (1 << i)) {
range->freq[val].i = i + 1;
range->freq[val].m = ipw2100_frequencies[i] * 100000;
range->freq[val].e = 1;
val++; // } if (val == IW_MAX_FREQUENCIES) break;
}
range->num_frequency = val;
staticint ipw2100_wx_get_wap(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
struct ipw2100_priv *priv = libipw_priv(dev);
/* If we are associated, trying to associate, or have a statically
* configured BSSID then return that; otherwise return ANY */ if (priv->config & CFG_STATIC_BSSID || priv->status & STATUS_ASSOCIATED) {
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
memcpy(wrqu->ap_addr.sa_data, priv->bssid, ETH_ALEN);
} else
eth_zero_addr(wrqu->ap_addr.sa_data);
staticint ipw2100_wx_get_essid(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
struct ipw2100_priv *priv = libipw_priv(dev);
/* If we are associated, trying to associate, or have a statically
* configured ESSID then return that; otherwise return ANY */ if (priv->config & CFG_STATIC_ESSID || priv->status & STATUS_ASSOCIATED) {
IPW_DEBUG_WX("Getting essid: '%*pE'\n",
priv->essid_len, priv->essid);
memcpy(extra, priv->essid, priv->essid_len);
wrqu->essid.length = priv->essid_len;
wrqu->essid.flags = 1; /* active */
} else {
IPW_DEBUG_WX("Getting essid: ANY\n");
wrqu->essid.length = 0;
wrqu->essid.flags = 0; /* active */
}
return 0;
}
staticint ipw2100_wx_set_nick(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
struct ipw2100_priv *priv = libipw_priv(dev);
if (wrqu->data.length > IW_ESSID_MAX_SIZE) return -E2BIG;
staticint ipw2100_wx_get_nick(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
staticint ipw2100_wx_get_rts(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
struct ipw2100_priv *priv = libipw_priv(dev);
wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED;
wrqu->rts.fixed = 1; /* no auto select */
/* If RTS is set to the default value, then it is disabled */
wrqu->rts.disabled = (priv->rts_threshold & RTS_DISABLED) ? 1 : 0;
staticint ipw2100_wx_get_txpow(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
IPW_DEBUG_WX("GET TX Power -> %d\n", wrqu->txpower.value);
return 0;
}
staticint ipw2100_wx_set_frag(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
staticint ipw2100_wx_get_frag(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
staticint ipw2100_wx_get_retry(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
struct ipw2100_priv *priv = libipw_priv(dev);
wrqu->retry.disabled = 0; /* can't be disabled */
if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) return -EINVAL;
staticint ipw2100_wx_get_scan(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
staticint ipw2100_wx_get_encode(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *key)
{ /* * This can be called at any time. No action lock required
*/
if (wrqu->power.disabled) {
priv->power_mode = IPW_POWER_LEVEL(priv->power_mode);
err = ipw2100_set_power_mode(priv, IPW_POWER_MODE_CAM);
IPW_DEBUG_WX("SET Power Management Mode -> off\n"); goto done;
}
switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_ON: /* If not specified */ case IW_POWER_MODE: /* If set all mask */ case IW_POWER_ALL_R: /* If explicitly state all */ break; default: /* Otherwise we don't support it */
IPW_DEBUG_WX("SET PM Mode: %X not supported.\n",
wrqu->power.flags);
err = -EOPNOTSUPP; goto done;
}
/* If the user hasn't specified a power management mode yet, default
* to BATTERY */
priv->power_mode = IPW_POWER_ENABLED | priv->power_mode;
err = ipw2100_set_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode));
IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode);
staticint ipw2100_wx_get_power(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
switch (param->flags & IW_AUTH_INDEX) { case IW_AUTH_WPA_VERSION: case IW_AUTH_CIPHER_PAIRWISE: case IW_AUTH_CIPHER_GROUP: case IW_AUTH_KEY_MGMT: /* * ipw2200 does not use these parameters
*/ break;
case IW_AUTH_TKIP_COUNTERMEASURES:
crypt = priv->ieee->crypt_info.crypt[priv->ieee->crypt_info.tx_keyidx]; if (!crypt || !crypt->ops->set_flags || !crypt->ops->get_flags) break;
flags = crypt->ops->get_flags(crypt->priv);
if (param->value)
flags |= IEEE80211_CRYPTO_TKIP_COUNTERMEASURES; else
flags &= ~IEEE80211_CRYPTO_TKIP_COUNTERMEASURES;
crypt->ops->set_flags(flags, crypt->priv);
break;
case IW_AUTH_DROP_UNENCRYPTED:{ /* HACK: * * wpa_supplicant calls set_wpa_enabled when the driver * is loaded and unloaded, regardless of if WPA is being * used. No other calls are made which can be used to * determine if encryption will be used or not prior to * association being expected. If encryption is not being * used, drop_unencrypted is set to false, else true -- we * can use this to determine if the CAP_PRIVACY_ON bit should * be set.
*/ struct libipw_security sec = {
.flags = SEC_ENABLED,
.enabled = param->value,
};
priv->ieee->drop_unencrypted = param->value; /* We only change SEC_LEVEL for open mode. Others * are set by ipw_wpa_set_encryption.
*/ if (!param->value) {
sec.flags |= SEC_LEVEL;
sec.level = SEC_LEVEL_0;
} else {
sec.flags |= SEC_LEVEL;
sec.level = SEC_LEVEL_1;
} if (priv->ieee->set_security)
priv->ieee->set_security(priv->ieee->dev, &sec); break;
}
case IW_AUTH_80211_AUTH_ALG:
ret = ipw2100_wpa_set_auth_algs(priv, param->value); break;
case IW_AUTH_WPA_ENABLED:
ret = ipw2100_wpa_enable(priv, param->value); break;
case IW_AUTH_RX_UNENCRYPTED_EAPOL:
ieee->ieee802_1x = param->value; break;
//case IW_AUTH_ROAMING_CONTROL: case IW_AUTH_PRIVACY_INVOKED:
ieee->privacy_invoked = param->value; break;
switch (param->flags & IW_AUTH_INDEX) { case IW_AUTH_WPA_VERSION: case IW_AUTH_CIPHER_PAIRWISE: case IW_AUTH_CIPHER_GROUP: case IW_AUTH_KEY_MGMT: /* * wpa_supplicant will control these internally
*/ break;
case IW_AUTH_TKIP_COUNTERMEASURES:
crypt = priv->ieee->crypt_info.crypt[priv->ieee->crypt_info.tx_keyidx]; if (!crypt || !crypt->ops->get_flags) {
IPW_DEBUG_WARNING("Can't get TKIP countermeasures: " "crypt not set!\n"); break;
}
#define MAX_POWER_STRING 80 staticint ipw2100_wx_get_powermode(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
staticint ipw2100_wx_get_preamble(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
staticint ipw2100_wx_get_crc_check(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
{ /* * This can be called at any time. No action lock required
*/
/* * Get wireless statistics. * Called by /proc/net/wireless * Also called by SIOCGIWSTATS
*/ staticstruct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev)
{ enum {
POOR = 30,
FAIR = 60,
GOOD = 80,
VERY_GOOD = 90,
EXCELLENT = 95,
PERFECT = 100
}; int rssi_qual; int tx_qual; int beacon_qual; int quality;
/* if hw is disabled, then ipw2100_get_ordinal() can't be called. * ipw2100_wx_wireless_stats seems to be called before fw is * initialized. STATUS_ASSOCIATED will only be set if the hw is up * and associated; if not associcated, the values are all meaningless
* anyway, so set them all to NULL and INVALID */ if (!(priv->status & STATUS_ASSOCIATED)) {
wstats->miss.beacon = 0;
wstats->discard.retries = 0;
wstats->qual.qual = 0;
wstats->qual.level = 0;
wstats->qual.noise = 0;
wstats->qual.updated = 7;
wstats->qual.updated |= IW_QUAL_NOISE_INVALID |
IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; return wstats;
}
if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_PERCENT_MISSED_BCNS,
&missed_beacons, &ord_len)) goto fail_get_ordinal;
staticvoid ipw2100_wx_event_work(struct work_struct *work)
{ struct ipw2100_priv *priv =
container_of(work, struct ipw2100_priv, wx_event_work.work); union iwreq_data wrqu; unsignedint len = ETH_ALEN;
if (priv->status & STATUS_STOPPING) return;
mutex_lock(&priv->action_mutex);
IPW_DEBUG_WX("enter\n");
mutex_unlock(&priv->action_mutex);
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
/* Fetch BSSID from the hardware */ if (!(priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) ||
priv->status & STATUS_RF_KILL_MASK ||
ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID,
&priv->bssid, &len)) {
eth_zero_addr(wrqu.ap_addr.sa_data);
} else { /* We now have the BSSID, so can finish setting to the full
* associated state */
memcpy(wrqu.ap_addr.sa_data, priv->bssid, ETH_ALEN);
memcpy(priv->ieee->bssid, priv->bssid, ETH_ALEN);
priv->status &= ~STATUS_ASSOCIATING;
priv->status |= STATUS_ASSOCIATED;
netif_carrier_on(priv->net_dev);
netif_wake_queue(priv->net_dev);
}
if (!(priv->status & STATUS_ASSOCIATED)) {
IPW_DEBUG_WX("Configuring ESSID\n");
mutex_lock(&priv->action_mutex); /* This is a disassociation event, so kick the firmware to
* look for another AP */ if (priv->config & CFG_STATIC_ESSID)
ipw2100_set_essid(priv, priv->essid, priv->essid_len,
0); else
ipw2100_set_essid(priv, NULL, 0, 0);
mutex_unlock(&priv->action_mutex);
}
if (IPW2100_FW_MAJOR(h->version) != IPW2100_FW_MAJOR_VERSION) {
printk(KERN_WARNING DRV_NAME ": Firmware image not compatible " "(detected version id of %u). " "See Documentation/networking/device_drivers/wifi/intel/ipw2100.rst\n",
h->version); return 1;
}
staticint ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf,
size_t max)
{ char ver[MAX_FW_VERSION_LEN];
u32 len = MAX_FW_VERSION_LEN;
u32 tmp; int i; /* firmware version is an ascii string (max len of 14) */ if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_FW_VER_NUM, ver, &len)) return -EIO;
tmp = max; if (len >= max)
len = max - 1; for (i = 0; i < len; i++)
buf[i] = ver[i];
buf[i] = '\0'; return tmp;
}
/* * On exit, the firmware will have been freed from the fw list
*/ staticint ipw2100_fw_download(struct ipw2100_priv *priv, struct ipw2100_fw *fw)
{ /* firmware is constructed of N contiguous entries, each entry is * structured as: * * offset sie desc * 0 4 address to write to * 4 2 length of data run * 6 length data
*/ unsignedint addr; unsignedshort len;
/* Enable System (Reg 0)
* second enable should be OK */
write_nic_byte(dev, 0x210000, 0x00); // clear enable system
readl(reg);
write_nic_byte(dev, 0x210000, 0x80); // set enable system
/* check Symbol is enabled - upped this from 5 as it wasn't always
* catching the update */ for (i = 0; i < 10; i++) {
udelay(10);
/* check Dino is enabled bit */
read_nic_byte(dev, 0x210000, &data); if (data & 0x1) break;
}
if (i == 10) {
printk(KERN_ERR DRV_NAME ": %s: Error initializing Symbol\n",
dev->name); return -EIO;
}
/* Get Symbol alive response */ for (i = 0; i < 30; i++) { /* Read alive response structure */ for (j = 0;
j < (sizeof(struct symbol_alive_response) >> 1); j++)
read_nic_word(dev, 0x210004, ((u16 *) & response) + j);
if (i == 30) {
printk(KERN_ERR DRV_NAME ": %s: No response from Symbol - hw not alive\n",
dev->name);
printk_buf(IPW_DL_ERROR, (u8 *) & response, sizeof(response)); return -EIO;
}
return 0;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.171 Sekunden
(vorverarbeitet am 2026-04-28)
¤
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.