]> err.no Git - linux-2.6/commitdiff
iwlwifi: Add TX/RX statistcs to driver
authorTomas Winkler <tomas.winkler@intel.com>
Wed, 12 Mar 2008 23:58:51 +0000 (16:58 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 25 Mar 2008 20:41:47 +0000 (16:41 -0400)
This patch supports collecting of TX and RX statistics in the driver.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl-4965.c
drivers/net/wireless/iwlwifi/iwl-4965.h
drivers/net/wireless/iwlwifi/iwl4965-base.c

index 7b0ad728f9279a4f0f5a699b18e216fb1f51b3f3..b2ea4d4f3f31892fe9fed28ea6e1e7e5f89f391b 100644 (file)
@@ -3337,6 +3337,14 @@ static void iwl4965_add_radiotap(struct iwl_priv *priv,
        stats->flag |= RX_FLAG_RADIOTAP;
 }
 
+static void iwl_update_rx_stats(struct iwl_priv *priv, u16 fc, u16 len)
+{
+       /* 0 - mgmt, 1 - cnt, 2 - data */
+       int idx = (fc & IEEE80211_FCTL_FTYPE) >> 2;
+       priv->rx_stats[idx].cnt++;
+       priv->rx_stats[idx].bytes += len;
+}
+
 static void iwl4965_handle_data_packet(struct iwl_priv *priv, int is_data,
                                       int include_phy,
                                       struct iwl4965_rx_mem_buffer *rxb,
@@ -3406,6 +3414,7 @@ static void iwl4965_handle_data_packet(struct iwl_priv *priv, int is_data,
        if (priv->add_radiotap)
                iwl4965_add_radiotap(priv, rxb->skb, rx_start, stats, ampdu_status);
 
+       iwl_update_rx_stats(priv, le16_to_cpu(hdr->frame_control), len);
        ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats);
        priv->alloc_rxb_skb--;
        rxb->skb = NULL;
index 60353b2645d41ce18049bbd8800d8d7acfa1b739..aded6010ce205d73fa96a4bef1e58e99f6598ceb 100644 (file)
@@ -1107,6 +1107,12 @@ struct iwl_priv {
        int last_rx_rssi;       /* From Rx packet statisitics */
        int last_rx_noise;      /* From beacon statistics */
 
+       /* counts mgmt, ctl, and data packets */
+       struct traffic_stats {
+               u32 cnt;
+               u64 bytes;
+       } tx_stats[3], rx_stats[3];
+
        struct iwl4965_power_mgr power_data;
 
        struct iwl4965_notif_statistics statistics;
index 4e899ce81b32b1571cb78968280a87e40d390d01..4f6ed6942065c00a71fe5ac46e3e09cd04351823 100644 (file)
@@ -2529,7 +2529,13 @@ static void iwl4965_build_tx_cmd_basic(struct iwl_priv *priv,
        cmd->cmd.tx.tx_flags = tx_flags;
        cmd->cmd.tx.next_frame_len = 0;
 }
-
+static void iwl_update_tx_stats(struct iwl_priv *priv, u16 fc, u16 len)
+{
+       /* 0 - mgmt, 1 - cnt, 2 - data */
+       int idx = (fc & IEEE80211_FCTL_FTYPE) >> 2;
+       priv->tx_stats[idx].cnt++;
+       priv->tx_stats[idx].bytes += len;
+}
 /**
  * iwl4965_get_sta_id - Find station's index within station table
  *
@@ -2776,6 +2782,8 @@ static int iwl4965_tx_skb(struct iwl_priv *priv,
        /* set is_hcca to 0; it probably will never be implemented */
        iwl4965_hw_build_tx_cmd_rate(priv, out_cmd, ctl, hdr, sta_id, 0);
 
+       iwl_update_tx_stats(priv, fc, len);
+
        scratch_phys = txcmd_phys + sizeof(struct iwl4965_cmd_header) +
                offsetof(struct iwl4965_tx_cmd, scratch);
        out_cmd->cmd.tx.dram_lsb_ptr = cpu_to_le32(scratch_phys);