Skip to content

Commit

Permalink
iwlwifi: use mac80211 throughput trigger
Browse files Browse the repository at this point in the history
Instead of keeping track of LED blink speed
in the driver, use the new mac80211 trigger
and link it up with an LED classdev that we
now register. This also allows users more
flexibility in how they want to have the LED
blink or not.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
  • Loading branch information
Wey-Yi Guy committed Jan 21, 2011
1 parent 4a4fdf2 commit 5ed540a
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 240 deletions.
4 changes: 4 additions & 0 deletions drivers/net/wireless/iwlwifi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ config IWLWIFI
tristate "Intel Wireless Wifi"
depends on PCI && MAC80211
select FW_LOADER
select NEW_LEDS
select LEDS_CLASS
select LEDS_TRIGGERS
select MAC80211_LEDS

menu "Debugging Options"
depends on IWLWIFI
Expand Down
27 changes: 0 additions & 27 deletions drivers/net/wireless/iwlwifi/iwl-3945-led.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,6 @@ static int iwl3945_send_led_cmd(struct iwl_priv *priv,
return iwl_send_cmd(priv, &cmd);
}

/* Set led on command */
static int iwl3945_led_on(struct iwl_priv *priv)
{
struct iwl_led_cmd led_cmd = {
.id = IWL_LED_LINK,
.on = IWL_LED_SOLID,
.off = 0,
.interval = IWL_DEF_LED_INTRVL
};
return iwl3945_send_led_cmd(priv, &led_cmd);
}

/* Set led off command */
static int iwl3945_led_off(struct iwl_priv *priv)
{
struct iwl_led_cmd led_cmd = {
.id = IWL_LED_LINK,
.on = 0,
.off = 0,
.interval = IWL_DEF_LED_INTRVL
};
IWL_DEBUG_LED(priv, "led off\n");
return iwl3945_send_led_cmd(priv, &led_cmd);
}

const struct iwl_led_ops iwl3945_led_ops = {
.cmd = iwl3945_send_led_cmd,
.on = iwl3945_led_on,
.off = iwl3945_led_off,
};
14 changes: 1 addition & 13 deletions drivers/net/wireless/iwlwifi/iwl-agn-led.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,11 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
}

/* Set led register off */
static int iwl_led_on_reg(struct iwl_priv *priv)
void iwlagn_led_enable(struct iwl_priv *priv)
{
IWL_DEBUG_LED(priv, "led on\n");
iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
return 0;
}

/* Set led register off */
static int iwl_led_off_reg(struct iwl_priv *priv)
{
IWL_DEBUG_LED(priv, "LED Reg off\n");
iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_OFF);
return 0;
}

const struct iwl_led_ops iwlagn_led_ops = {
.cmd = iwl_send_led_cmd,
.on = iwl_led_on_reg,
.off = iwl_led_off_reg,
};
1 change: 1 addition & 0 deletions drivers/net/wireless/iwlwifi/iwl-agn-led.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
#define __iwl_agn_led_h__

extern const struct iwl_led_ops iwlagn_led_ops;
void iwlagn_led_enable(struct iwl_priv *priv);

#endif /* __iwl_agn_led_h__ */
2 changes: 0 additions & 2 deletions drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,12 +557,10 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,

if (changes & BSS_CHANGED_ASSOC) {
if (bss_conf->assoc) {
iwl_led_associate(priv);
priv->timestamp = bss_conf->timestamp;
ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
} else {
ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
iwl_led_disassociate(priv);
}
}

Expand Down
10 changes: 7 additions & 3 deletions drivers/net/wireless/iwlwifi/iwl-agn.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include "iwl-sta.h"
#include "iwl-agn-calib.h"
#include "iwl-agn.h"
#include "iwl-agn-led.h"


/******************************************************************************
Expand Down Expand Up @@ -2741,8 +2742,6 @@ static void iwl_alive_start(struct iwl_priv *priv)
/* At this point, the NIC is initialized and operational */
iwl_rf_kill_ct_config(priv);

iwl_leds_init(priv);

IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
wake_up_interruptible(&priv->wait_command_queue);

Expand Down Expand Up @@ -3234,6 +3233,8 @@ static int iwl_mac_setup_register(struct iwl_priv *priv,
priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
&priv->bands[IEEE80211_BAND_5GHZ];

iwl_leds_init(priv);

ret = ieee80211_register_hw(priv->hw);
if (ret) {
IWL_ERR(priv, "Failed to register hw (error %d)\n", ret);
Expand Down Expand Up @@ -3278,7 +3279,7 @@ int iwlagn_mac_start(struct ieee80211_hw *hw)
}
}

iwl_led_start(priv);
iwlagn_led_enable(priv);

out:
priv->is_open = 1;
Expand Down Expand Up @@ -4288,6 +4289,9 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
* we need to set STATUS_EXIT_PENDING bit.
*/
set_bit(STATUS_EXIT_PENDING, &priv->status);

iwl_leds_exit(priv);

if (priv->mac80211_registered) {
ieee80211_unregister_hw(priv->hw);
priv->mac80211_registered = 0;
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/wireless/iwlwifi/iwl-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,6 @@ void iwl_clear_traffic_stats(struct iwl_priv *priv)
{
memset(&priv->tx_stats, 0, sizeof(struct traffic_stats));
memset(&priv->rx_stats, 0, sizeof(struct traffic_stats));
priv->led_tpt = 0;
}

/*
Expand Down Expand Up @@ -1769,7 +1768,6 @@ void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len)
stats->data_cnt++;
stats->data_bytes += len;
}
iwl_leds_background(priv);
}
EXPORT_SYMBOL(iwl_update_stats);
#endif
Expand Down
14 changes: 0 additions & 14 deletions drivers/net/wireless/iwlwifi/iwl-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ struct iwl_lib_ops {

struct iwl_led_ops {
int (*cmd)(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd);
int (*on)(struct iwl_priv *priv);
int (*off)(struct iwl_priv *priv);
};

/* NIC specific ops */
Expand Down Expand Up @@ -494,18 +492,6 @@ static inline void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx,
__le16 fc, u16 len)
{
struct traffic_stats *stats;

if (is_tx)
stats = &priv->tx_stats;
else
stats = &priv->rx_stats;

if (ieee80211_is_data(fc)) {
/* data */
stats->data_bytes += len;
}
iwl_leds_background(priv);
}
#endif
/*****************************************************
Expand Down
25 changes: 0 additions & 25 deletions drivers/net/wireless/iwlwifi/iwl-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,29 +668,6 @@ static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
}

static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct iwl_priv *priv = file->private_data;
int pos = 0;
char buf[256];
const size_t bufsz = sizeof(buf);

pos += scnprintf(buf + pos, bufsz - pos,
"allow blinking: %s\n",
(priv->allow_blinking) ? "True" : "False");
if (priv->allow_blinking) {
pos += scnprintf(buf + pos, bufsz - pos,
"Led blinking rate: %u\n",
priv->last_blink_rate);
pos += scnprintf(buf + pos, bufsz - pos,
"Last blink time: %lu\n",
priv->last_blink_time);
}

return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
}

static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
char __user *user_buf,
size_t count, loff_t *ppos)
Expand Down Expand Up @@ -856,7 +833,6 @@ DEBUGFS_READ_FILE_OPS(channels);
DEBUGFS_READ_FILE_OPS(status);
DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
DEBUGFS_READ_FILE_OPS(qos);
DEBUGFS_READ_FILE_OPS(led);
DEBUGFS_READ_FILE_OPS(thermal_throttling);
DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
Expand Down Expand Up @@ -1725,7 +1701,6 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR);
DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR);
if (!priv->cfg->base_params->broken_powersave) {
DEBUGFS_ADD_FILE(sleep_level_override, dir_data,
S_IWUSR | S_IRUSR);
Expand Down
18 changes: 7 additions & 11 deletions drivers/net/wireless/iwlwifi/iwl-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/pci.h> /* for struct pci_device_id */
#include <linux/kernel.h>
#include <linux/wait.h>
#include <linux/leds.h>
#include <net/ieee80211_radiotap.h>

#include "iwl-eeprom.h"
Expand Down Expand Up @@ -996,7 +997,6 @@ struct reply_agg_tx_error_statistics {
u32 unknown;
};

#ifdef CONFIG_IWLWIFI_DEBUGFS
/* management statistics */
enum iwl_mgmt_stats {
MANAGEMENT_ASSOC_REQ = 0,
Expand Down Expand Up @@ -1027,16 +1027,13 @@ enum iwl_ctrl_stats {
};

struct traffic_stats {
#ifdef CONFIG_IWLWIFI_DEBUGFS
u32 mgmt[MANAGEMENT_MAX];
u32 ctrl[CONTROL_MAX];
u32 data_cnt;
u64 data_bytes;
};
#else
struct traffic_stats {
u64 data_bytes;
};
#endif
};

/*
* iwl_switch_rxon: "channel switch" structure
Expand Down Expand Up @@ -1338,11 +1335,6 @@ struct iwl_priv {
struct iwl_init_alive_resp card_alive_init;
struct iwl_alive_resp card_alive;

unsigned long last_blink_time;
u8 last_blink_rate;
u8 allow_blinking;
u64 led_tpt;

u16 active_rate;

u8 start_calib;
Expand Down Expand Up @@ -1580,6 +1572,10 @@ struct iwl_priv {
bool hw_ready;

struct iwl_event_log event_log;

struct led_classdev led;
unsigned long blink_on, blink_off;
bool led_registered;
}; /*iwl_priv */

static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
Expand Down
Loading

0 comments on commit 5ed540a

Please sign in to comment.