#include <linux/etherdevice.h>
#include "rt2x00.h"
+#include "rt2x00lib.h"
#include "rt2x00dev.h"
/*
ieee80211_start_queues(rt2x00dev->hw);
+ if (is_interface_present(&rt2x00dev->interface))
+ rt2x00_start_link_tune(rt2x00dev);
+
return 0;
}
if (!__test_and_clear_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
return;
+ rt2x00_stop_link_tune(rt2x00dev);
+
ieee80211_stop_queues(rt2x00dev->hw);
rt2x00lib_toggle_rx(rt2x00dev, 0);
/*
* When we are disabling the rx, we should also stop the link tuner.
*/
- if (!enable && work_pending(&rt2x00dev->link.work.work))
+ if (!enable)
rt2x00_stop_link_tune(rt2x00dev);
rt2x00dev->ops->lib->set_device_state(rt2x00dev,
/*
* When we are enabling the rx, we should also start the link tuner.
*/
- if (enable)
+ if (enable && is_interface_present(&rt2x00dev->interface))
rt2x00_start_link_tune(rt2x00dev);
}
{
struct rt2x00_dev *rt2x00dev =
container_of(work, struct rt2x00_dev, link.work.work);
- int rssi;
/*
* Update promisc mode (this function will first check
if (test_bit(CONFIG_DISABLE_LINK_TUNING, &rt2x00dev->flags))
return;
- /*
- * Retrieve link quality.
- * Also convert rssi to dBm using the max_rssi value.
- */
- rssi = rt2x00_get_link_rssi(&rt2x00dev->link);
- rssi -= rt2x00dev->hw->max_rssi;
-
- rt2x00dev->ops->lib->link_tuner(rt2x00dev, rssi);
+ rt2x00dev->ops->lib->link_tuner(rt2x00dev);
/*
* Increase tuner counter, and reschedule the next link tuner run.
*/
rt2x00dev->link.count++;
- queue_delayed_work(rt2x00dev->workqueue, &rt2x00dev->link.work,
+ queue_delayed_work(rt2x00dev->hw->workqueue, &rt2x00dev->link.work,
LINK_TUNE_INTERVAL);
}
struct hw_mode_spec *spec = &rt2x00dev->spec;
int status;
- /*
- * Initialize device.
- */
- SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->device);
-
- /*
- * Initialize MAC address.
- */
- if (!is_valid_ether_addr(spec->mac_addr)) {
- ERROR(rt2x00dev, "Invalid MAC addr: " MAC_FMT ".\n",
- MAC_ARG(spec->mac_addr));
- return -EINVAL;
- }
-
- rt2x00dev->ops->lib->config_mac_addr(rt2x00dev, spec->mac_addr);
- SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, spec->mac_addr);
-
/*
* Initialize HW modes.
*/
/*
* Initialization/uninitialization handlers.
*/
-static int rt2x00lib_alloc_ring(struct data_ring *ring,
+static int rt2x00lib_alloc_ring_entries(struct data_ring *ring,
const u16 max_entries, const u16 data_size, const u16 desc_size)
{
struct data_entry *entry;
return 0;
}
-static int rt2x00lib_allocate_rings(struct rt2x00_dev *rt2x00dev)
+static int rt2x00lib_allocate_ring_entries(struct rt2x00_dev *rt2x00dev)
{
struct data_ring *ring;
/*
* Allocate the RX ring.
*/
- if (rt2x00lib_alloc_ring(rt2x00dev->rx,
+ if (rt2x00lib_alloc_ring_entries(rt2x00dev->rx,
RX_ENTRIES, DATA_FRAME_SIZE, rt2x00dev->ops->rxd_size))
return -ENOMEM;
* First allocate the TX rings.
*/
txring_for_each(rt2x00dev, ring) {
- if (rt2x00lib_alloc_ring(ring,
+ if (rt2x00lib_alloc_ring_entries(ring,
TX_ENTRIES, DATA_FRAME_SIZE, rt2x00dev->ops->txd_size))
return -ENOMEM;
}
/*
* Allocate the BEACON ring.
*/
- if (rt2x00lib_alloc_ring(&rt2x00dev->bcn[0],
+ if (rt2x00lib_alloc_ring_entries(&rt2x00dev->bcn[0],
BEACON_ENTRIES, MGMT_FRAME_SIZE, rt2x00dev->ops->txd_size))
return -ENOMEM;
* Allocate the Atim ring.
*/
if (test_bit(DEVICE_SUPPORT_ATIM, &rt2x00dev->flags)) {
- if (rt2x00lib_alloc_ring(&rt2x00dev->bcn[1],
+ if (rt2x00lib_alloc_ring_entries(&rt2x00dev->bcn[1],
ATIM_ENTRIES, DATA_FRAME_SIZE, rt2x00dev->ops->txd_size))
return -ENOMEM;
}
return 0;
}
-static void rt2x00lib_free_rings(struct rt2x00_dev *rt2x00dev)
+static void rt2x00lib_free_ring_entries(struct rt2x00_dev *rt2x00dev)
{
struct data_ring *ring;
/*
* Allocate all data rings.
*/
- status = rt2x00lib_allocate_rings(rt2x00dev);
+ status = rt2x00lib_allocate_ring_entries(rt2x00dev);
if (status) {
ERROR(rt2x00dev, "DMA allocation failed.\n");
return status;
rt2x00lib_uninitialize(rt2x00dev);
exit:
- rt2x00lib_free_rings(rt2x00dev);
+ rt2x00lib_free_ring_entries(rt2x00dev);
return status;
}
if (!__test_and_clear_bit(DEVICE_INITIALIZED, &rt2x00dev->flags))
return;
- /*
- * Flush out all pending work.
- */
- flush_workqueue(rt2x00dev->workqueue);
-
/*
* Unregister rfkill.
*/
/*
* Free allocated datarings.
*/
- rt2x00lib_free_rings(rt2x00dev);
+ rt2x00lib_free_ring_entries(rt2x00dev);
}
/*
{
int retval = -ENOMEM;
- /*
- * Create workqueue.
- */
- rt2x00dev->workqueue = create_singlethread_workqueue(DRV_NAME);
- if (!rt2x00dev->workqueue)
- goto exit;
-
/*
* Let the driver probe the device to detect the capabilities.
*/
*/
rt2x00lib_deinit_hw(rt2x00dev);
- /*
- * Free workqueue.
- */
- if (likely(rt2x00dev->workqueue)) {
- destroy_workqueue(rt2x00dev->workqueue);
- rt2x00dev->workqueue = NULL;
- }
-
/*
* Free ring structures.
*/
return retval;
}
- /*
- * Set device mode to awake for power management.
- */
- retval = rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_AWAKE);
- if (retval)
- return retval;
-
return 0;
}
EXPORT_SYMBOL_GPL(rt2x00lib_resume);
*/
if (signal & 0x08)
val = rate->val2;
- val = rate->val;
+ else
+ val = rate->val;
break;
}
}
rx_status->rate = val;
rx_status->ssi = rssi;
- rx_status->noise = rt2x00dev->link.curr_noise;
rt2x00_update_link_rssi(&rt2x00dev->link, rssi);
/*
if (ieee80211_get_morefrag(ieee80211hdr))
__set_bit(ENTRY_TXD_MORE_FRAG, &entry->flags);
- /*
- * Check if this is a new sequence
- */
- if ((seq_ctrl & IEEE80211_SCTL_FRAG) == 0)
- __set_bit(ENTRY_TXD_NEW_SEQ, &entry->flags);
-
/*
* Beacons and probe responses require the tsf timestamp
* to be inserted into the frame.