2008-03-10 18:41:24

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 0/7] iwlwifi driver updates

Series contains LED support as a new feature, some fixes, as well as
changes to move to a shared library design.

[PATCH 1/7] iwlwifi: Add led support
[PATCH 2/7] iwlwifi: fix bug to show hidden APs during scan
[PATCH 3/7] iwlwifi: Use sta_bcast_id variable instead of BROADCAST_ID constant
[PATCH 4/7] iwlwifi: update copyright year
[PATCH 5/7] iwlwifi: Use eeprom form iwlcore
[PATCH 6/7] iwlwifi: Fix endianity in debug print
[PATCH 7/7] iwlwifi: change rate number to a constant


Reinette


2008-03-10 18:41:25

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 4/7] iwlwifi: update copyright year

Also fix a copy and paste error in header of iwl-core.c. This file
is not dual licensed.

Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-3945-commands.h | 4 ++--
drivers/net/wireless/iwlwifi/iwl-3945-debug.h | 2 +-
drivers/net/wireless/iwlwifi/iwl-3945-hw.h | 4 ++--
drivers/net/wireless/iwlwifi/iwl-3945-io.h | 2 +-
drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-3945-rs.h | 2 +-
drivers/net/wireless/iwlwifi/iwl-3945.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-3945.h | 2 +-
drivers/net/wireless/iwlwifi/iwl-4965-commands.h | 4 ++--
drivers/net/wireless/iwlwifi/iwl-4965-debug.h | 2 +-
drivers/net/wireless/iwlwifi/iwl-4965-hw.h | 4 ++--
drivers/net/wireless/iwlwifi/iwl-4965-io.h | 2 +-
drivers/net/wireless/iwlwifi/iwl-4965-rs.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-4965-rs.h | 2 +-
drivers/net/wireless/iwlwifi/iwl-4965.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-4965.h | 2 +-
drivers/net/wireless/iwlwifi/iwl-core.c | 3 ---
drivers/net/wireless/iwlwifi/iwl-csr.h | 2 +-
drivers/net/wireless/iwlwifi/iwl-helpers.h | 2 +-
drivers/net/wireless/iwlwifi/iwl-prph.h | 4 ++--
drivers/net/wireless/iwlwifi/iwl-spectrum.h | 2 +-
drivers/net/wireless/iwlwifi/iwl3945-base.c | 4 ++--
drivers/net/wireless/iwlwifi/iwl4965-base.c | 2 +-
23 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-commands.h b/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
index 8b7ef9f..824a6e5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
@@ -5,7 +5,7 @@
*
* GPL LICENSE SUMMARY
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
*
* BSD LICENSE
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-debug.h b/drivers/net/wireless/iwlwifi/iwl-3945-debug.h
index 28ecfe8..f1d002f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-debug.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* Portions of this file are derived from the ipw3945 project.
*
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
index 7dc1913..1ca6fa4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
@@ -5,7 +5,7 @@
*
* GPL LICENSE SUMMARY
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
*
* BSD LICENSE
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-io.h b/drivers/net/wireless/iwlwifi/iwl-3945-io.h
index 4a18729..0b94751 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-io.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* Portions of this file are derived from the ipw3945 project.
*
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index 08604eb..157e572 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
index b082a09..e88b1d3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 4e6c529..eb30819 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 076e2d7..e0655b9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-commands.h b/drivers/net/wireless/iwlwifi/iwl-4965-commands.h
index 327eabc..35f592d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-commands.h
@@ -5,7 +5,7 @@
*
* GPL LICENSE SUMMARY
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
*
* BSD LICENSE
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-debug.h b/drivers/net/wireless/iwlwifi/iwl-4965-debug.h
index baf07c7..df32948 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-debug.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* Portions of this file are derived from the ipw3945 project.
*
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
index 24413a4..4a29b44 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
@@ -5,7 +5,7 @@
*
* GPL LICENSE SUMMARY
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
*
* BSD LICENSE
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-io.h b/drivers/net/wireless/iwlwifi/iwl-4965-io.h
index 4af0c01..07fca88 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-io.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* Portions of this file are derived from the ipw3945 project.
*
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
index 25e7386..4b46226 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.h b/drivers/net/wireless/iwlwifi/iwl-4965-rs.h
index 911f213..ae827e1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 90462a0..5140a16 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.h b/drivers/net/wireless/iwlwifi/iwl-4965.h
index d54068b..0895af6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 675b34b..b8383c8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1,8 +1,5 @@
/******************************************************************************
*
- * This file is provided under a dual BSD/GPLv2 license. When using or
- * redistributing this file, you may do so under either license.
- *
* GPL LICENSE SUMMARY
*
* Copyright(c) 2008 Intel Corporation. All rights reserved.
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index 758e940..1272579 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -30,7 +30,7 @@
*
* BSD LICENSE
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-helpers.h b/drivers/net/wireless/iwlwifi/iwl-helpers.h
index 736b888..a443472 100644
--- a/drivers/net/wireless/iwlwifi/iwl-helpers.h
+++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* Portions of this file are derived from the ipw3945 project, as well
* as portions of the ieee80211 subsystem header files.
diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
index 4ba1216..ecf651a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
@@ -5,7 +5,7 @@
*
* GPL LICENSE SUMMARY
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
*
* BSD LICENSE
*
- * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-spectrum.h b/drivers/net/wireless/iwlwifi/iwl-spectrum.h
index b576ff2..a40a217 100644
--- a/drivers/net/wireless/iwlwifi/iwl-spectrum.h
+++ b/drivers/net/wireless/iwlwifi/iwl-spectrum.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* Portions of this file are derived from the ieee80211 subsystem header files.
*
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index e791fa6..ea71caa 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* Portions of this file are derived from the ipw3945 project, as well
* as portions of the ieee80211 subsystem header files.
@@ -93,7 +93,7 @@ int iwl3945_param_queues_num = IWL_MAX_NUM_QUEUES; /* def: 8 Tx queues */
#endif

#define IWLWIFI_VERSION "1.2.26k" VD VS
-#define DRV_COPYRIGHT "Copyright(c) 2003-2007 Intel Corporation"
+#define DRV_COPYRIGHT "Copyright(c) 2003-2008 Intel Corporation"
#define DRV_VERSION IWLWIFI_VERSION


diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index b3bafef..324b66f 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* Portions of this file are derived from the ipw3945 project, as well
* as portions of the ieee80211 subsystem header files.
--
1.5.3.4


2008-03-10 18:41:24

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 2/7] iwlwifi: fix bug to show hidden APs during scan

Indirect scanning ('iwlist scan') should report information about
hidden APs. When an AP is hidden it does not respond to active scanning,
we thus have to use passive scanning to locate these APs.

This fixes http://bughost.org/bugzilla/show_bug.cgi?id=1499

Signed-off-by: Reinette Chatre <[email protected]>
Tested-by: Bill Moss <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl3945-base.c | 21 +++++++++++++--------
drivers/net/wireless/iwlwifi/iwl4965-base.c | 21 +++++++++++++--------
2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index c3c21ab..e791fa6 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -6316,18 +6316,23 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR)
scan->filter_flags = RXON_FILTER_PROMISC_MSK;

- if (direct_mask)
+ if (direct_mask) {
IWL_DEBUG_SCAN
("Initiating direct scan for %s.\n",
iwl3945_escape_essid(priv->essid, priv->essid_len));
- else
+ scan->channel_count =
+ iwl3945_get_channels_for_scan(
+ priv, band, 1, /* active */
+ direct_mask,
+ (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
+ } else {
IWL_DEBUG_SCAN("Initiating indirect scan.\n");
-
- scan->channel_count =
- iwl3945_get_channels_for_scan(
- priv, band, 1, /* active */
- direct_mask,
- (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
+ scan->channel_count =
+ iwl3945_get_channels_for_scan(
+ priv, band, 0, /* passive */
+ direct_mask,
+ (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
+ }

cmd.len += le16_to_cpu(scan->tx_cmd.len) +
scan->channel_count * sizeof(struct iwl3945_scan_channel);
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 029556e..b3bafef 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -6829,18 +6829,23 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR)
scan->filter_flags = RXON_FILTER_PROMISC_MSK;

- if (direct_mask)
+ if (direct_mask) {
IWL_DEBUG_SCAN
("Initiating direct scan for %s.\n",
iwl4965_escape_essid(priv->essid, priv->essid_len));
- else
+ scan->channel_count =
+ iwl4965_get_channels_for_scan(
+ priv, band, 1, /* active */
+ direct_mask,
+ (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
+ } else {
IWL_DEBUG_SCAN("Initiating indirect scan.\n");
-
- scan->channel_count =
- iwl4965_get_channels_for_scan(
- priv, band, 1, /* active */
- direct_mask,
- (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
+ scan->channel_count =
+ iwl4965_get_channels_for_scan(
+ priv, band, 0, /* passive */
+ direct_mask,
+ (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
+ }

cmd.len += le16_to_cpu(scan->tx_cmd.len) +
scan->channel_count * sizeof(struct iwl4965_scan_channel);
--
1.5.3.4


2008-03-10 18:41:27

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 7/7] iwlwifi: change rate number to a constant

From: Tomas Winkler <[email protected]>

This patch moves a number to an understandable define

Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Ron Rindjunsky <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl4965-base.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 49041e9..035db13 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -5454,8 +5454,9 @@ static void iwl4965_init_hw_rates(struct iwl4965_priv *priv,
/*
* If CCK != 1M then set short preamble rate flag.
*/
- rates[i].flags |= (iwl4965_rates[i].plcp == 10) ?
- 0 : IEEE80211_RATE_SHORT_PREAMBLE;
+ rates[i].flags |=
+ (iwl4965_rates[i].plcp == IWL_RATE_1M_PLCP) ?
+ 0 : IEEE80211_RATE_SHORT_PREAMBLE;
}
}
}
--
1.5.3.4


2008-03-10 18:41:25

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 1/7] iwlwifi: Add led support

From: Mohamed Abbas <[email protected]>

This patch add LEDS support to 3965 and 4965 drivers. It is based on led
trigger and class. For our drivers we needed to avoid two things.
1- We receive led trigger on/off on each Rx\Tx frame. In our driver
we can not call led command like that. In this driver once driver
receive a start of traffic it call the led command to start blinking then
we count all bytes of Tx and Rx frame, after two second we count the blink
rate of last two second then id blink rate changed we call the led commands
2- Since we can call led command very often, we make sure we call the
led command after we receive the statistics notification so
we dont need to wakeup the ucode id it is in sleep state.
This patch was tested with 4965 and 3945.

This patch fixes compile and sparse warnings from earlier version.
Patch also includes fixes for endianity.

Signed-off-by: Mohamed abbas<[email protected]>
Signed-off-by: Ian Schram<[email protected]>
Signed-off-by: Tomas Winkler <[email protected]>
---
drivers/net/wireless/iwlwifi/Kconfig | 20 ++-
drivers/net/wireless/iwlwifi/Makefile | 8 +
drivers/net/wireless/iwlwifi/iwl-3945-led.c | 433 ++++++++++++++++++++++++++
drivers/net/wireless/iwlwifi/iwl-3945-led.h | 73 +++++
drivers/net/wireless/iwlwifi/iwl-3945.c | 6 +
drivers/net/wireless/iwlwifi/iwl-3945.h | 13 +-
drivers/net/wireless/iwlwifi/iwl-4965-led.c | 440 +++++++++++++++++++++++++++
drivers/net/wireless/iwlwifi/iwl-4965-led.h | 73 +++++
drivers/net/wireless/iwlwifi/iwl-4965.c | 8 +-
drivers/net/wireless/iwlwifi/iwl-4965.h | 12 +-
drivers/net/wireless/iwlwifi/iwl-csr.h | 6 +
drivers/net/wireless/iwlwifi/iwl3945-base.c | 9 +-
drivers/net/wireless/iwlwifi/iwl4965-base.c | 10 +-
13 files changed, 1095 insertions(+), 16 deletions(-)
create mode 100644 drivers/net/wireless/iwlwifi/iwl-3945-led.c
create mode 100644 drivers/net/wireless/iwlwifi/iwl-3945-led.h
create mode 100644 drivers/net/wireless/iwlwifi/iwl-4965-led.c
create mode 100644 drivers/net/wireless/iwlwifi/iwl-4965-led.h

diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index 5b7c016..496dd3d 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -37,6 +37,15 @@ config IWL4965_HT
This option enables IEEE 802.11n High Throughput features
for the iwl4965 driver.

+config IWL4965_LEDS
+ bool "Enable LEDS features in iwl4965 driver"
+ depends on IWL4965
+ select LEDS_CLASS
+ select LEDS_TRIGGERS
+ select MAC80211_LEDS
+ ---help---
+ This option enables LEDS for the iwl4965 driver.
+
config IWL4965_SPECTRUM_MEASUREMENT
bool "Enable Spectrum Measurement in iwl4965 driver"
depends on IWL4965
@@ -46,7 +55,7 @@ config IWL4965_SPECTRUM_MEASUREMENT
config IWL4965_SENSITIVITY
bool "Enable Sensitivity Calibration in iwl4965 driver"
depends on IWL4965
- ---help---
+---help---
This option will enable sensitivity calibration for the iwl4965
driver.

@@ -108,6 +117,15 @@ config IWL3945_SPECTRUM_MEASUREMENT
---help---
This option will enable spectrum measurement for the iwl3945 driver.

+config IWL3945_LEDS
+ bool "Enable LEDS features in iwl3945 driver"
+ depends on IWL3945
+ select LEDS_CLASS
+ select LEDS_TRIGGERS
+ select MAC80211_LEDS
+ ---help---
+ This option enables LEDS for the iwl3945 driver.
+
config IWL3945_DEBUG
bool "Enable full debugging output in iwl3945 driver"
depends on IWL3945
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 6b85cca..abcfdbf 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -3,6 +3,14 @@ iwlcore-objs = iwl-core.o

obj-$(CONFIG_IWL3945) += iwl3945.o
iwl3945-objs = iwl3945-base.o iwl-3945.o iwl-3945-rs.o
+ifeq ($(CONFIG_IWL3945_LEDS),y)
+ iwl3945-objs += iwl-3945-led.o
+endif
+

obj-$(CONFIG_IWL4965) += iwl4965.o
iwl4965-objs = iwl4965-base.o iwl-4965.o iwl-4965-rs.o
+ifeq ($(CONFIG_IWL4965_LEDS),y)
+ iwl4965-objs += iwl-4965-led.o
+endif
+
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.c b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
new file mode 100644
index 0000000..d200d08
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
@@ -0,0 +1,433 @@
+/******************************************************************************
+ *
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ *
+ * Contact Information:
+ * James P. Ketrenos <[email protected]>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ *****************************************************************************/
+
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/dma-mapping.h>
+#include <linux/delay.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/wireless.h>
+#include <net/mac80211.h>
+#include <linux/etherdevice.h>
+#include <asm/unaligned.h>
+
+#include "iwl-3945.h"
+#include "iwl-helpers.h"
+
+#define IWL_1MB_RATE (128 * 1024)
+#define IWL_LED_THRESHOLD (16)
+#define IWL_MAX_BLINK_TBL (10)
+
+static const struct {
+ u16 brightness;
+ u8 on_time;
+ u8 of_time;
+} blink_tbl[] =
+{
+ {300, 25, 25},
+ {200, 40, 40},
+ {100, 55, 55},
+ {70, 65, 65},
+ {50, 75, 75},
+ {20, 85, 85},
+ {15, 95, 95 },
+ {10, 110, 110},
+ {5, 130, 130},
+ {0, 167, 167}
+};
+
+static int iwl3945_led_cmd_callback(struct iwl3945_priv *priv,
+ struct iwl3945_cmd *cmd,
+ struct sk_buff *skb)
+{
+ return 1;
+}
+
+
+/* Send led command */
+static int iwl_send_led_cmd(struct iwl3945_priv *priv,
+ struct iwl3945_led_cmd *led_cmd)
+{
+ struct iwl3945_host_cmd cmd = {
+ .id = REPLY_LEDS_CMD,
+ .len = sizeof(struct iwl3945_led_cmd),
+ .data = led_cmd,
+ .meta.flags = CMD_ASYNC,
+ .meta.u.callback = iwl3945_led_cmd_callback
+ };
+
+ return iwl3945_send_cmd(priv, &cmd);
+}
+
+
+/* Set led on command */
+static int iwl3945_led_on(struct iwl3945_priv *priv, int led_id)
+{
+ struct iwl3945_led_cmd led_cmd = {
+ .id = led_id,
+ .on = IWL_LED_SOLID,
+ .off = 0,
+ .interval = IWL_DEF_LED_INTRVL
+ };
+ return iwl_send_led_cmd(priv, &led_cmd);
+}
+
+/* Set led on command */
+static int iwl3945_led_pattern(struct iwl3945_priv *priv, int led_id,
+ enum led_brightness brightness)
+{
+ struct iwl3945_led_cmd led_cmd = {
+ .id = led_id,
+ .on = brightness,
+ .off = brightness,
+ .interval = IWL_DEF_LED_INTRVL
+ };
+ if (brightness == LED_FULL) {
+ led_cmd.on = IWL_LED_SOLID;
+ led_cmd.off = 0;
+ }
+ return iwl_send_led_cmd(priv, &led_cmd);
+}
+
+/* Set led register off */
+static int iwl3945_led_on_reg(struct iwl3945_priv *priv, int led_id)
+{
+ IWL_DEBUG_LED("led on %d\n", led_id);
+ return iwl3945_led_on(priv, led_id);
+}
+
+/* Set led off command */
+static int iwl3945_led_off(struct iwl3945_priv *priv, int led_id)
+{
+ struct iwl3945_led_cmd led_cmd = {
+ .id = led_id,
+ .on = 0,
+ .off = 0,
+ .interval = IWL_DEF_LED_INTRVL
+ };
+ IWL_DEBUG_LED("led off %d\n", led_id);
+ return iwl_send_led_cmd(priv, &led_cmd);
+}
+
+/* Set led register off */
+static int iwl3945_led_off_reg(struct iwl3945_priv *priv, int led_id)
+{
+ iwl3945_led_off(priv, led_id);
+ return 0;
+}
+
+/* Set led blink command */
+static int iwl3945_led_not_solid(struct iwl3945_priv *priv, int led_id,
+ u8 brightness)
+{
+ struct iwl3945_led_cmd led_cmd = {
+ .id = led_id,
+ .on = brightness,
+ .off = brightness,
+ .interval = IWL_DEF_LED_INTRVL
+ };
+
+ return iwl_send_led_cmd(priv, &led_cmd);
+}
+
+
+/*
+ * brightness call back function for Tx/Rx LED
+ */
+static int iwl3945_led_associated(struct iwl3945_priv *priv, int led_id)
+{
+ if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
+ !test_bit(STATUS_READY, &priv->status))
+ return 0;
+
+
+ /* start counting Tx/Rx bytes */
+ if (!priv->last_blink_time && priv->allow_blinking)
+ priv->last_blink_time = jiffies;
+ return 0;
+}
+
+/*
+ * brightness call back for association and radio
+ */
+static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+{
+ struct iwl3945_led *led = container_of(led_cdev,
+ struct iwl3945_led, led_dev);
+ struct iwl3945_priv *priv = led->priv;
+
+ if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+ return;
+
+ switch (brightness) {
+ case LED_FULL:
+ if (led->type == IWL_LED_TRG_ASSOC) {
+ priv->allow_blinking = 1;
+ IWL_DEBUG_LED("MAC is associated\n");
+ }
+ if (led->led_on)
+ led->led_on(priv, IWL_LED_LINK);
+ break;
+ case LED_OFF:
+ if (led->type == IWL_LED_TRG_ASSOC) {
+ priv->allow_blinking = 0;
+ IWL_DEBUG_LED("MAC is disassociated\n");
+ }
+ if (led->led_off)
+ led->led_off(priv, IWL_LED_LINK);
+ break;
+ default:
+ if (led->led_pattern)
+ led->led_pattern(priv, IWL_LED_LINK, brightness);
+ break;
+ }
+}
+
+
+
+/*
+ * Register led class with the system
+ */
+static int iwl3945_led_register_led(struct iwl3945_priv *priv,
+ struct iwl3945_led *led,
+ enum led_type type, u8 set_led,
+ const char *name, char *trigger)
+{
+ struct device *device = wiphy_dev(priv->hw->wiphy);
+ int ret;
+
+ led->led_dev.name = name;
+ led->led_dev.brightness_set = iwl3945_led_brightness_set;
+ led->led_dev.default_trigger = trigger;
+
+ ret = led_classdev_register(device, &led->led_dev);
+ if (ret) {
+ IWL_ERROR("Error: failed to register led handler.\n");
+ return ret;
+ }
+
+ led->priv = priv;
+ led->type = type;
+ led->registered = 1;
+
+ if (set_led && led->led_on)
+ led->led_on(priv, IWL_LED_LINK);
+ return 0;
+}
+
+
+/*
+ * calculate blink rate according to last 2 sec Tx/Rx activities
+ */
+static inline u8 get_blink_rate(struct iwl3945_priv *priv)
+{
+ int index;
+ u8 blink_rate;
+
+ if (priv->rxtxpackets < IWL_LED_THRESHOLD)
+ index = 10;
+ else {
+ for (index = 0; index < IWL_MAX_BLINK_TBL; index++) {
+ if (priv->rxtxpackets > (blink_tbl[index].brightness *
+ IWL_1MB_RATE))
+ break;
+ }
+ }
+ /* if 0 frame is transfered */
+ if ((index == IWL_MAX_BLINK_TBL) || !priv->allow_blinking)
+ blink_rate = IWL_LED_SOLID;
+ else
+ blink_rate = blink_tbl[index].on_time;
+
+ return blink_rate;
+}
+
+static inline int is_rf_kill(struct iwl3945_priv *priv)
+{
+ return test_bit(STATUS_RF_KILL_HW, &priv->status) ||
+ test_bit(STATUS_RF_KILL_SW, &priv->status);
+}
+
+/*
+ * this function called from handler. Since setting Led command can
+ * happen very frequent we postpone led command to be called from
+ * REPLY handler so we know ucode is up
+ */
+void iwl3945_led_background(struct iwl3945_priv *priv)
+{
+ u8 blink_rate;
+
+ if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
+ priv->last_blink_time = 0;
+ return;
+ }
+ if (is_rf_kill(priv)) {
+ priv->last_blink_time = 0;
+ return;
+ }
+
+ if (!priv->allow_blinking) {
+ priv->last_blink_time = 0;
+ if (priv->last_blink_rate != IWL_LED_SOLID) {
+ priv->last_blink_rate = IWL_LED_SOLID;
+ iwl3945_led_on(priv, IWL_LED_LINK);
+ }
+ return;
+ }
+ if (!priv->last_blink_time ||
+ !time_after(jiffies, priv->last_blink_time +
+ msecs_to_jiffies(1000)))
+ return;
+
+ blink_rate = get_blink_rate(priv);
+
+ /* call only if blink rate change */
+ if (blink_rate != priv->last_blink_rate) {
+ if (blink_rate != IWL_LED_SOLID) {
+ priv->last_blink_time = jiffies +
+ msecs_to_jiffies(1000);
+ iwl3945_led_not_solid(priv, IWL_LED_LINK, blink_rate);
+ } else {
+ priv->last_blink_time = 0;
+ iwl3945_led_on(priv, IWL_LED_LINK);
+ }
+ }
+
+ priv->last_blink_rate = blink_rate;
+ priv->rxtxpackets = 0;
+}
+
+
+/* Register all led handler */
+int iwl3945_led_register(struct iwl3945_priv *priv)
+{
+ char *trigger;
+ char name[32];
+ int ret;
+
+ priv->last_blink_rate = 0;
+ priv->rxtxpackets = 0;
+ priv->last_blink_time = 0;
+ priv->allow_blinking = 0;
+
+ trigger = ieee80211_get_radio_led_name(priv->hw);
+ snprintf(name, sizeof(name), "iwl-%s:radio",
+ wiphy_name(priv->hw->wiphy));
+
+ priv->led[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on_reg;
+ priv->led[IWL_LED_TRG_RADIO].led_off = iwl3945_led_off_reg;
+ priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL;
+
+ ret = iwl3945_led_register_led(priv,
+ &priv->led[IWL_LED_TRG_RADIO],
+ IWL_LED_TRG_RADIO, 1,
+ name, trigger);
+ if (ret)
+ goto exit_fail;
+
+ trigger = ieee80211_get_assoc_led_name(priv->hw);
+ snprintf(name, sizeof(name), "iwl-%s:assoc",
+ wiphy_name(priv->hw->wiphy));
+
+ ret = iwl3945_led_register_led(priv,
+ &priv->led[IWL_LED_TRG_ASSOC],
+ IWL_LED_TRG_ASSOC, 0,
+ name, trigger);
+ /* for assoc always turn led on */
+ priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on_reg;
+ priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on_reg;
+ priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;
+
+ if (ret)
+ goto exit_fail;
+
+ trigger = ieee80211_get_rx_led_name(priv->hw);
+ snprintf(name, sizeof(name), "iwl-%s:RX",
+ wiphy_name(priv->hw->wiphy));
+
+
+ ret = iwl3945_led_register_led(priv,
+ &priv->led[IWL_LED_TRG_RX],
+ IWL_LED_TRG_RX, 0,
+ name, trigger);
+
+ priv->led[IWL_LED_TRG_RX].led_on = iwl3945_led_associated;
+ priv->led[IWL_LED_TRG_RX].led_off = iwl3945_led_associated;
+ priv->led[IWL_LED_TRG_RX].led_pattern = iwl3945_led_pattern;
+
+ if (ret)
+ goto exit_fail;
+
+ trigger = ieee80211_get_tx_led_name(priv->hw);
+ snprintf(name, sizeof(name), "iwl-%s:TX",
+ wiphy_name(priv->hw->wiphy));
+ ret = iwl3945_led_register_led(priv,
+ &priv->led[IWL_LED_TRG_TX],
+ IWL_LED_TRG_TX, 0,
+ name, trigger);
+ priv->led[IWL_LED_TRG_TX].led_on = iwl3945_led_associated;
+ priv->led[IWL_LED_TRG_TX].led_off = iwl3945_led_associated;
+ priv->led[IWL_LED_TRG_TX].led_pattern = iwl3945_led_pattern;
+
+ if (ret)
+ goto exit_fail;
+
+ return 0;
+
+exit_fail:
+ iwl3945_led_unregister(priv);
+ return ret;
+}
+
+
+/* unregister led class */
+static void iwl3945_led_unregister_led(struct iwl3945_led *led, u8 set_led)
+{
+ if (!led->registered)
+ return;
+
+ led_classdev_unregister(&led->led_dev);
+
+ if (set_led)
+ led->led_dev.brightness_set(&led->led_dev, LED_OFF);
+ led->registered = 0;
+}
+
+/* Unregister all led handlers */
+void iwl3945_led_unregister(struct iwl3945_priv *priv)
+{
+ iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_ASSOC], 0);
+ iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_RX], 0);
+ iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_TX], 0);
+ iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_RADIO], 1);
+}
+
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.h b/drivers/net/wireless/iwlwifi/iwl-3945-led.h
new file mode 100644
index 0000000..b1d2f6b
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.h
@@ -0,0 +1,73 @@
+/******************************************************************************
+ *
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ *
+ * Contact Information:
+ * James P. Ketrenos <[email protected]>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ *****************************************************************************/
+
+#ifndef IWL3945_LEDS_H
+#define IWL3945_LEDS_H
+
+struct iwl3945_priv;
+
+#ifdef CONFIG_IWL3945_LEDS
+#define IWL_LED_SOLID 11
+#define IWL_LED_NAME_LEN 31
+#define IWL_DEF_LED_INTRVL __constant_cpu_to_le32(1000)
+
+#define IWL_LED_ACTIVITY (0<<1)
+#define IWL_LED_LINK (1<<1)
+
+enum led_type {
+ IWL_LED_TRG_TX,
+ IWL_LED_TRG_RX,
+ IWL_LED_TRG_ASSOC,
+ IWL_LED_TRG_RADIO,
+ IWL_LED_TRG_MAX,
+};
+
+#include <linux/leds.h>
+
+struct iwl3945_led {
+ struct iwl3945_priv *priv;
+ struct led_classdev led_dev;
+
+ int (*led_on) (struct iwl3945_priv *priv, int led_id);
+ int (*led_off) (struct iwl3945_priv *priv, int led_id);
+ int (*led_pattern) (struct iwl3945_priv *priv, int led_id,
+ enum led_brightness brightness);
+
+ enum led_type type;
+ unsigned int registered;
+};
+
+extern int iwl3945_led_register(struct iwl3945_priv *priv);
+extern void iwl3945_led_unregister(struct iwl3945_priv *priv);
+extern void iwl3945_led_background(struct iwl3945_priv *priv);
+
+#else
+static inline int iwl3945_led_register(struct iwl3945_priv *priv) { return 0; }
+static inline void iwl3945_led_unregister(struct iwl3945_priv *priv) {}
+static inline void iwl3945_led_background(struct iwl3945_priv *priv) {}
+#endif /* CONFIG_IWL3945_LEDS */
+
+#endif /* IWL3945_LEDS_H */
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 50a641c..bcfa299 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -358,6 +358,8 @@ void iwl3945_hw_rx_statistics(struct iwl3945_priv *priv, struct iwl3945_rx_mem_b

memcpy(&priv->statistics, pkt->u.raw, sizeof(priv->statistics));

+ iwl3945_led_background(priv);
+
priv->last_statistics_time = jiffies;
}

@@ -640,6 +642,10 @@ static void iwl3945_handle_data_packet(struct iwl3945_priv *priv, int is_data,
if (priv->add_radiotap)
iwl3945_add_radiotap(priv, rxb->skb, rx_hdr, stats);

+#ifdef CONFIG_IWL3945_LEDS
+ if (is_data)
+ priv->rxtxpackets += len;
+#endif
ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats);
rxb->skb = NULL;
}
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 0ab22d3..076e2d7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -44,6 +44,7 @@ extern struct pci_device_id iwl3945_hw_card_ids[];
#include "iwl-prph.h"
#include "iwl-3945-hw.h"
#include "iwl-3945-debug.h"
+#include "iwl-3945-led.h"

/* Change firmware file name, using "-" and incrementing number,
* *only* when uCode interface or architecture changes so that it
@@ -777,13 +778,15 @@ struct iwl3945_priv {
struct iwl3945_init_alive_resp card_alive_init;
struct iwl3945_alive_resp card_alive;

-#ifdef LED
- /* LED related variables */
- struct iwl3945_activity_blink activity;
- unsigned long led_packets;
- int led_state;
+#ifdef CONFIG_IWL4965_LEDS
+ struct iwl3945_led led[IWL_LED_TRG_MAX];
+ unsigned long last_blink_time;
+ u8 last_blink_rate;
+ u8 allow_blinking;
+ unsigned int rxtxpackets;
#endif

+
u16 active_rate;
u16 active_rate_basic;

diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-led.c b/drivers/net/wireless/iwlwifi/iwl-4965-led.c
new file mode 100644
index 0000000..c7246bd
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-led.c
@@ -0,0 +1,440 @@
+/******************************************************************************
+ *
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ *
+ * Contact Information:
+ * James P. Ketrenos <[email protected]>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ *****************************************************************************/
+
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/dma-mapping.h>
+#include <linux/delay.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/wireless.h>
+#include <net/mac80211.h>
+#include <linux/etherdevice.h>
+#include <asm/unaligned.h>
+
+#include "iwl-4965.h"
+#include "iwl-helpers.h"
+
+#define IWL_1MB_RATE (128 * 1024)
+#define IWL_LED_THRESHOLD (16)
+#define IWL_MAX_BLINK_TBL (10)
+
+static const struct {
+ u16 brightness;
+ u8 on_time;
+ u8 of_time;
+} blink_tbl[] =
+{
+ {300, 25, 25},
+ {200, 40, 40},
+ {100, 55, 55},
+ {70, 65, 65},
+ {50, 75, 75},
+ {20, 85, 85},
+ {15, 95, 95 },
+ {10, 110, 110},
+ {5, 130, 130},
+ {0, 167, 167}
+};
+
+static int iwl4965_led_cmd_callback(struct iwl4965_priv *priv,
+ struct iwl4965_cmd *cmd, struct sk_buff *skb)
+{
+ return 1;
+}
+
+
+/* Send led command */
+static int iwl_send_led_cmd(struct iwl4965_priv *priv,
+ struct iwl4965_led_cmd *led_cmd)
+{
+ struct iwl4965_host_cmd cmd = {
+ .id = REPLY_LEDS_CMD,
+ .len = sizeof(struct iwl4965_led_cmd),
+ .data = led_cmd,
+ .meta.flags = CMD_ASYNC,
+ .meta.u.callback = iwl4965_led_cmd_callback
+ };
+ u32 reg;
+
+ reg = iwl4965_read32(priv, CSR_LED_REG);
+ if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
+ iwl4965_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK);
+
+ return iwl4965_send_cmd(priv, &cmd);
+}
+
+
+/* Set led on command */
+static int iwl4965_led_on(struct iwl4965_priv *priv, int led_id)
+{
+ struct iwl4965_led_cmd led_cmd = {
+ .id = led_id,
+ .on = IWL_LED_SOLID,
+ .off = 0,
+ .interval = IWL_DEF_LED_INTRVL
+ };
+ return iwl_send_led_cmd(priv, &led_cmd);
+}
+
+/* Set led on command */
+static int iwl4965_led_pattern(struct iwl4965_priv *priv, int led_id,
+ enum led_brightness brightness)
+{
+ struct iwl4965_led_cmd led_cmd = {
+ .id = led_id,
+ .on = brightness,
+ .off = brightness,
+ .interval = IWL_DEF_LED_INTRVL
+ };
+ if (brightness == LED_FULL) {
+ led_cmd.on = IWL_LED_SOLID;
+ led_cmd.off = 0;
+ }
+ return iwl_send_led_cmd(priv, &led_cmd);
+}
+
+/* Set led register off */
+static int iwl4965_led_on_reg(struct iwl4965_priv *priv, int led_id)
+{
+ IWL_DEBUG_LED("led on %d\n", led_id);
+ iwl4965_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
+ return 0;
+}
+
+#if 0
+/* Set led off command */
+int iwl4965_led_off(struct iwl4965_priv *priv, int led_id)
+{
+ struct iwl4965_led_cmd led_cmd = {
+ .id = led_id,
+ .on = 0,
+ .off = 0,
+ .interval = IWL_DEF_LED_INTRVL
+ };
+ IWL_DEBUG_LED("led off %d\n", led_id);
+ return iwl_send_led_cmd(priv, &led_cmd);
+}
+#endif
+
+
+/* Set led register off */
+static int iwl4965_led_off_reg(struct iwl4965_priv *priv, int led_id)
+{
+ IWL_DEBUG_LED("radio off\n");
+ iwl4965_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_OFF);
+ return 0;
+}
+
+/* Set led blink command */
+static int iwl4965_led_not_solid(struct iwl4965_priv *priv, int led_id,
+ u8 brightness)
+{
+ struct iwl4965_led_cmd led_cmd = {
+ .id = led_id,
+ .on = brightness,
+ .off = brightness,
+ .interval = IWL_DEF_LED_INTRVL
+ };
+
+ return iwl_send_led_cmd(priv, &led_cmd);
+}
+
+
+/*
+ * brightness call back function for Tx/Rx LED
+ */
+static int iwl4965_led_associated(struct iwl4965_priv *priv, int led_id)
+{
+ if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
+ !test_bit(STATUS_READY, &priv->status))
+ return 0;
+
+
+ /* start counting Tx/Rx bytes */
+ if (!priv->last_blink_time && priv->allow_blinking)
+ priv->last_blink_time = jiffies;
+ return 0;
+}
+
+/*
+ * brightness call back for association and radio
+ */
+static void iwl4965_led_brightness_set(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+{
+ struct iwl4965_led *led = container_of(led_cdev,
+ struct iwl4965_led, led_dev);
+ struct iwl4965_priv *priv = led->priv;
+
+ if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+ return;
+
+ switch (brightness) {
+ case LED_FULL:
+ if (led->type == IWL_LED_TRG_ASSOC)
+ priv->allow_blinking = 1;
+
+ if (led->led_on)
+ led->led_on(priv, IWL_LED_LINK);
+ break;
+ case LED_OFF:
+ if (led->type == IWL_LED_TRG_ASSOC)
+ priv->allow_blinking = 0;
+
+ if (led->led_off)
+ led->led_off(priv, IWL_LED_LINK);
+ break;
+ default:
+ if (led->led_pattern)
+ led->led_pattern(priv, IWL_LED_LINK, brightness);
+ break;
+ }
+}
+
+
+
+/*
+ * Register led class with the system
+ */
+static int iwl4965_led_register_led(struct iwl4965_priv *priv,
+ struct iwl4965_led *led,
+ enum led_type type, u8 set_led,
+ const char *name, char *trigger)
+{
+ struct device *device = wiphy_dev(priv->hw->wiphy);
+ int ret;
+
+ led->led_dev.name = name;
+ led->led_dev.brightness_set = iwl4965_led_brightness_set;
+ led->led_dev.default_trigger = trigger;
+
+ ret = led_classdev_register(device, &led->led_dev);
+ if (ret) {
+ IWL_ERROR("Error: failed to register led handler.\n");
+ return ret;
+ }
+
+ led->priv = priv;
+ led->type = type;
+ led->registered = 1;
+
+ if (set_led && led->led_on)
+ led->led_on(priv, IWL_LED_LINK);
+ return 0;
+}
+
+
+/*
+ * calculate blink rate according to last 2 sec Tx/Rx activities
+ */
+static inline u8 get_blink_rate(struct iwl4965_priv *priv)
+{
+ int index;
+ u8 blink_rate;
+
+ if (priv->rxtxpackets < IWL_LED_THRESHOLD)
+ index = 10;
+ else {
+ for (index = 0; index < IWL_MAX_BLINK_TBL; index++) {
+ if (priv->rxtxpackets > (blink_tbl[index].brightness *
+ IWL_1MB_RATE))
+ break;
+ }
+ }
+ /* if 0 frame is transfered */
+ if ((index == IWL_MAX_BLINK_TBL) || !priv->allow_blinking)
+ blink_rate = IWL_LED_SOLID;
+ else
+ blink_rate = blink_tbl[index].on_time;
+
+ return blink_rate;
+}
+
+static inline int is_rf_kill(struct iwl4965_priv *priv)
+{
+ return test_bit(STATUS_RF_KILL_HW, &priv->status) ||
+ test_bit(STATUS_RF_KILL_SW, &priv->status);
+}
+
+/*
+ * this function called from handler. Since setting Led command can
+ * happen very frequent we postpone led command to be called from
+ * REPLY handler so we know ucode is up
+ */
+void iwl4965_led_background(struct iwl4965_priv *priv)
+{
+ u8 blink_rate;
+
+ if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
+ priv->last_blink_time = 0;
+ return;
+ }
+ if (is_rf_kill(priv)) {
+ priv->last_blink_time = 0;
+ return;
+ }
+
+ if (!priv->allow_blinking) {
+ priv->last_blink_time = 0;
+ if (priv->last_blink_rate != IWL_LED_SOLID) {
+ priv->last_blink_rate = IWL_LED_SOLID;
+ iwl4965_led_on(priv, IWL_LED_LINK);
+ }
+ return;
+ }
+ if (!priv->last_blink_time ||
+ !time_after(jiffies, priv->last_blink_time +
+ msecs_to_jiffies(1000)))
+ return;
+
+ blink_rate = get_blink_rate(priv);
+
+ /* call only if blink rate change */
+ if (blink_rate != priv->last_blink_rate) {
+ if (blink_rate != IWL_LED_SOLID) {
+ priv->last_blink_time = jiffies +
+ msecs_to_jiffies(1000);
+ iwl4965_led_not_solid(priv, IWL_LED_LINK, blink_rate);
+ } else {
+ priv->last_blink_time = 0;
+ iwl4965_led_on(priv, IWL_LED_LINK);
+ }
+ }
+
+ priv->last_blink_rate = blink_rate;
+ priv->rxtxpackets = 0;
+}
+
+
+/* Register all led handler */
+int iwl4965_led_register(struct iwl4965_priv *priv)
+{
+ char *trigger;
+ char name[32];
+ int ret;
+
+ priv->last_blink_rate = 0;
+ priv->rxtxpackets = 0;
+ priv->last_blink_time = 0;
+ priv->allow_blinking = 0;
+
+ trigger = ieee80211_get_radio_led_name(priv->hw);
+ snprintf(name, sizeof(name), "iwl-%s:radio",
+ wiphy_name(priv->hw->wiphy));
+
+ priv->led[IWL_LED_TRG_RADIO].led_on = iwl4965_led_on_reg;
+ priv->led[IWL_LED_TRG_RADIO].led_off = iwl4965_led_off_reg;
+ priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL;
+
+ ret = iwl4965_led_register_led(priv,
+ &priv->led[IWL_LED_TRG_RADIO],
+ IWL_LED_TRG_RADIO, 1,
+ name, trigger);
+ if (ret)
+ goto exit_fail;
+
+ trigger = ieee80211_get_assoc_led_name(priv->hw);
+ snprintf(name, sizeof(name), "iwl-%s:assoc",
+ wiphy_name(priv->hw->wiphy));
+
+ ret = iwl4965_led_register_led(priv,
+ &priv->led[IWL_LED_TRG_ASSOC],
+ IWL_LED_TRG_ASSOC, 0,
+ name, trigger);
+ /* for assoc always turn led on */
+ priv->led[IWL_LED_TRG_ASSOC].led_on = iwl4965_led_on_reg;
+ priv->led[IWL_LED_TRG_ASSOC].led_off = iwl4965_led_on_reg;
+ priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;
+
+ if (ret)
+ goto exit_fail;
+
+ trigger = ieee80211_get_rx_led_name(priv->hw);
+ snprintf(name, sizeof(name), "iwl-%s:RX",
+ wiphy_name(priv->hw->wiphy));
+
+
+ ret = iwl4965_led_register_led(priv,
+ &priv->led[IWL_LED_TRG_RX],
+ IWL_LED_TRG_RX, 0,
+ name, trigger);
+
+ priv->led[IWL_LED_TRG_RX].led_on = iwl4965_led_associated;
+ priv->led[IWL_LED_TRG_RX].led_off = iwl4965_led_associated;
+ priv->led[IWL_LED_TRG_RX].led_pattern = iwl4965_led_pattern;
+
+ if (ret)
+ goto exit_fail;
+
+ trigger = ieee80211_get_tx_led_name(priv->hw);
+ snprintf(name, sizeof(name), "iwl-%s:TX",
+ wiphy_name(priv->hw->wiphy));
+ ret = iwl4965_led_register_led(priv,
+ &priv->led[IWL_LED_TRG_TX],
+ IWL_LED_TRG_TX, 0,
+ name, trigger);
+ priv->led[IWL_LED_TRG_TX].led_on = iwl4965_led_associated;
+ priv->led[IWL_LED_TRG_TX].led_off = iwl4965_led_associated;
+ priv->led[IWL_LED_TRG_TX].led_pattern = iwl4965_led_pattern;
+
+ if (ret)
+ goto exit_fail;
+
+ return 0;
+
+exit_fail:
+ iwl4965_led_unregister(priv);
+ return ret;
+}
+
+
+/* unregister led class */
+static void iwl4965_led_unregister_led(struct iwl4965_led *led, u8 set_led)
+{
+ if (!led->registered)
+ return;
+
+ led_classdev_unregister(&led->led_dev);
+
+ if (set_led)
+ led->led_dev.brightness_set(&led->led_dev, LED_OFF);
+ led->registered = 0;
+}
+
+/* Unregister all led handlers */
+void iwl4965_led_unregister(struct iwl4965_priv *priv)
+{
+ iwl4965_led_unregister_led(&priv->led[IWL_LED_TRG_ASSOC], 0);
+ iwl4965_led_unregister_led(&priv->led[IWL_LED_TRG_RX], 0);
+ iwl4965_led_unregister_led(&priv->led[IWL_LED_TRG_TX], 0);
+ iwl4965_led_unregister_led(&priv->led[IWL_LED_TRG_RADIO], 1);
+}
+
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-led.h b/drivers/net/wireless/iwlwifi/iwl-4965-led.h
new file mode 100644
index 0000000..17bbbe0
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-led.h
@@ -0,0 +1,73 @@
+/******************************************************************************
+ *
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ *
+ * Contact Information:
+ * James P. Ketrenos <[email protected]>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ *****************************************************************************/
+
+#ifndef IWL4965_LEDS_H
+#define IWL4965_LEDS_H
+
+struct iwl4965_priv;
+
+#ifdef CONFIG_IWL4965_LEDS
+#define IWL_LED_SOLID 11
+#define IWL_LED_NAME_LEN 31
+#define IWL_DEF_LED_INTRVL __constant_cpu_to_le32(1000)
+
+#define IWL_LED_ACTIVITY (0<<1)
+#define IWL_LED_LINK (1<<1)
+
+enum led_type {
+ IWL_LED_TRG_TX,
+ IWL_LED_TRG_RX,
+ IWL_LED_TRG_ASSOC,
+ IWL_LED_TRG_RADIO,
+ IWL_LED_TRG_MAX,
+};
+
+#include <linux/leds.h>
+
+struct iwl4965_led {
+ struct iwl4965_priv *priv;
+ struct led_classdev led_dev;
+
+ int (*led_on) (struct iwl4965_priv *priv, int led_id);
+ int (*led_off) (struct iwl4965_priv *priv, int led_id);
+ int (*led_pattern) (struct iwl4965_priv *priv, int led_id,
+ enum led_brightness brightness);
+
+ enum led_type type;
+ unsigned int registered;
+};
+
+extern int iwl4965_led_register(struct iwl4965_priv *priv);
+extern void iwl4965_led_unregister(struct iwl4965_priv *priv);
+extern void iwl4965_led_background(struct iwl4965_priv *priv);
+
+#else
+static inline int iwl4965_led_register(struct iwl4965_priv *priv) { return 0; }
+static inline void iwl4965_led_unregister(struct iwl4965_priv *priv) {}
+static inline void iwl4965_led_background(struct iwl4965_priv *priv) {}
+#endif /* CONFIG_IWL4965_LEDS */
+
+#endif /* IWL4965_LEDS_H */
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 2f01a49..6468504 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -3202,6 +3202,8 @@ void iwl4965_hw_rx_statistics(struct iwl4965_priv *priv, struct iwl4965_rx_mem_b
#endif
}

+ iwl4965_led_background(priv);
+
/* If the hardware hasn't reported a change in
* temperature then don't bother computing a
* calibrated temperature value */
@@ -3408,9 +3410,9 @@ static void iwl4965_handle_data_packet(struct iwl4965_priv *priv, int is_data,
ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats);
priv->alloc_rxb_skb--;
rxb->skb = NULL;
-#ifdef LED
- priv->led_packets += len;
- iwl4965_setup_activity_timer(priv);
+#ifdef CONFIG_IWL4965_LEDS
+ if (is_data)
+ priv->rxtxpackets += len;
#endif
}

diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.h b/drivers/net/wireless/iwlwifi/iwl-4965.h
index 057fa15..d54068b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.h
@@ -44,6 +44,7 @@ extern struct pci_device_id iwl4965_hw_card_ids[];
#include "iwl-csr.h"
#include "iwl-prph.h"
#include "iwl-4965-debug.h"
+#include "iwl-4965-led.h"

/* Change firmware file name, using "-" and incrementing number,
* *only* when uCode interface or architecture changes so that it
@@ -1060,11 +1061,12 @@ struct iwl4965_priv {
struct iwl4965_init_alive_resp card_alive_init;
struct iwl4965_alive_resp card_alive;

-#ifdef LED
- /* LED related variables */
- struct iwl4965_activity_blink activity;
- unsigned long led_packets;
- int led_state;
+#ifdef CONFIG_IWL4965_LEDS
+ struct iwl4965_led led[IWL_LED_TRG_MAX];
+ unsigned long last_blink_time;
+ u8 last_blink_rate;
+ u8 allow_blinking;
+ unsigned int rxtxpackets;
#endif

u16 active_rate;
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index 7016e5b..758e940 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -93,6 +93,7 @@
#define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c)
#define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060)
#define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100)
+#define CSR_LED_REG (CSR_BASE+0x094)

/* Analog phase-lock-loop configuration (3945 only)
* Set bit 24. */
@@ -214,6 +215,11 @@
#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000)
#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000)

+/* LED */
+#define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF)
+#define CSR_LED_REG_TRUN_ON (0x78)
+#define CSR_LED_REG_TRUN_OFF (0x38)
+
/*=== HBUS (Host-side Bus) ===*/
#define HBUS_BASE (0x400)
/*
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index ecf749c..c3c21ab 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -2481,8 +2481,12 @@ static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv,
cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3);
else
cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2);
- } else
+ } else {
cmd->cmd.tx.timeout.pm_frame_timeout = 0;
+#ifdef CONFIG_IWL3945_LEDS
+ priv->rxtxpackets += le16_to_cpu(cmd->cmd.tx.len);
+#endif
+ }

cmd->cmd.tx.driver_txop = 0;
cmd->cmd.tx.tx_flags = tx_flags;
@@ -5851,6 +5855,8 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv)
IWL_DEBUG_INFO("ALIVE processing complete.\n");
wake_up_interruptible(&priv->wait_command_queue);

+ iwl3945_led_register(priv);
+
if (priv->error_recovering)
iwl3945_error_recovery(priv);

@@ -5875,6 +5881,7 @@ static void __iwl3945_down(struct iwl3945_priv *priv)
if (!exit_pending)
set_bit(STATUS_EXIT_PENDING, &priv->status);

+ iwl3945_led_unregister(priv);
iwl3945_clear_stations_table(priv);

/* Unblock any waiting calls */
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 28c64c3..029556e 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -2598,8 +2598,12 @@ static void iwl4965_build_tx_cmd_basic(struct iwl4965_priv *priv,
cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3);
else
cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2);
- } else
+ } else {
cmd->cmd.tx.timeout.pm_frame_timeout = 0;
+#ifdef CONFIG_IWL4965_LEDS
+ priv->rxtxpackets += le16_to_cpu(cmd->cmd.tx.len);
+#endif
+ }

cmd->cmd.tx.driver_txop = 0;
cmd->cmd.tx.tx_flags = tx_flags;
@@ -6355,6 +6359,8 @@ static void iwl4965_alive_start(struct iwl4965_priv *priv)
IWL_DEBUG_INFO("ALIVE processing complete.\n");
wake_up_interruptible(&priv->wait_command_queue);

+ iwl4965_led_register(priv);
+
if (priv->error_recovering)
iwl4965_error_recovery(priv);

@@ -6379,6 +6385,8 @@ static void __iwl4965_down(struct iwl4965_priv *priv)
if (!exit_pending)
set_bit(STATUS_EXIT_PENDING, &priv->status);

+ iwl4965_led_unregister(priv);
+
iwl4965_clear_stations_table(priv);

/* Unblock any waiting calls */
--
1.5.3.4


2008-03-11 06:37:59

by Tomas Winkler

[permalink] [raw]
Subject: Re: [ipw3945-devel] [PATCH 1/7] iwlwifi: Add led support

On Mon, Mar 10, 2008 at 9:35 PM, Chatre, Reinette
<[email protected]> wrote:
> On , Reinette Chatre wrote:
>
> > Signed-off-by: Ian Schram<[email protected]>
>
> This email address is not valid - it just bounced when I pushed the
> patch.
> John, could you please use [email protected] instead?
>
> Please let me know if you need a new patch to fix this problem.
>
> Thank you very much
>
Actually I would like to respin this patch anyway
Tomas

>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Ipw3945-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ipw3945-devel
>

2008-03-11 17:16:37

by Reinette Chatre

[permalink] [raw]
Subject: RE: [PATCH 0/7] iwlwifi driver updates

On Monday, March 10, 2008 11:35 AM, Chatre, Reinette wrote:

> Series contains LED support as a new feature, some fixes, as well as
> changes to move to a shared library design.
>
> [PATCH 1/7] iwlwifi: Add led support
> [PATCH 2/7] iwlwifi: fix bug to show hidden APs during scan
> [PATCH 3/7] iwlwifi: Use sta_bcast_id variable instead of
> BROADCAST_ID constant [PATCH 4/7] iwlwifi: update copyright year
> [PATCH 5/7] iwlwifi: Use eeprom form iwlcore
> [PATCH 6/7] iwlwifi: Fix endianity in debug print
> [PATCH 7/7] iwlwifi: change rate number to a constant
>
>
> Reinette

John,

Could you please ignore this series - I will resend it later.

Sorry for the inconvenience.

Reinette

2008-03-10 18:41:27

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 6/7] iwlwifi: Fix endianity in debug print

From: Tomas Winkler <[email protected]>

This patch fix debug print out endianity issue for bitmap
Since u64 and le64 variables are casted to unsigned long long,
after patch 'wireless: correct warnings from using '%llx' for type 'u64'
also bitmaps need to be converted to native endianity

Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-4965.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index b3bf7c1..67091b8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -4265,7 +4265,7 @@ static void iwl4965_rx_reply_compressed_ba(struct iwl4965_priv *priv,
"%d, scd_ssn = %d\n",
ba_resp->tid,
ba_resp->seq_ctl,
- (unsigned long long)ba_resp->bitmap,
+ (unsigned long long)le64_to_cpu(ba_resp->bitmap),
ba_resp->scd_flow,
ba_resp->scd_ssn);
IWL_DEBUG_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx \n",
--
1.5.3.4


2008-03-10 19:35:57

by Reinette Chatre

[permalink] [raw]
Subject: RE: [ipw3945-devel] [PATCH 1/7] iwlwifi: Add led support

On , Reinette Chatre wrote:

> Signed-off-by: Ian Schram<[email protected]>

This email address is not valid - it just bounced when I pushed the
patch.
John, could you please use [email protected] instead?

Please let me know if you need a new patch to fix this problem.

Thank you very much

Reinette

2008-03-10 18:41:29

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 5/7] iwlwifi: Use eeprom form iwlcore

From: Assaf Krauss <[email protected]>

This patch puts in use eeprom from iwlcore module

Signed-off-by: Assaf Krauss <[email protected]>
Signed-off-by: Tomas Winkler <[email protected]>
---
drivers/net/wireless/iwlwifi/Makefile | 2 +-
drivers/net/wireless/iwlwifi/iwl-4965-hw.h | 310 ---------------------------
drivers/net/wireless/iwlwifi/iwl-4965.c | 45 ++---
drivers/net/wireless/iwlwifi/iwl-4965.h | 4 +-
drivers/net/wireless/iwlwifi/iwl-core.c | 1 +
drivers/net/wireless/iwlwifi/iwl-core.h | 10 +
drivers/net/wireless/iwlwifi/iwl4965-base.c | 84 +-------
7 files changed, 30 insertions(+), 426 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index abcfdbf..8a0a0c8 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -1,5 +1,5 @@
obj-$(CONFIG_IWLCORE) += iwlcore.o
-iwlcore-objs = iwl-core.o
+iwlcore-objs = iwl-core.o iwl-eeprom.o

obj-$(CONFIG_IWL3945) += iwl3945.o
iwl3945-objs = iwl3945-base.o iwl-3945.o iwl-3945-rs.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
index 4a29b44..c66993e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
@@ -92,316 +92,6 @@
/* RSSI to dBm */
#define IWL_RSSI_OFFSET 44

-/*
- * EEPROM related constants, enums, and structures.
- */
-
-/*
- * EEPROM access time values:
- *
- * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG,
- * then clearing (with subsequent read/modify/write) CSR_EEPROM_REG bit
- * CSR_EEPROM_REG_BIT_CMD (0x2).
- * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1).
- * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec.
- * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG.
- */
-#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
-#define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */
-
-/*
- * Regulatory channel usage flags in EEPROM struct iwl4965_eeprom_channel.flags.
- *
- * IBSS and/or AP operation is allowed *only* on those channels with
- * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because
- * RADAR detection is not supported by the 4965 driver, but is a
- * requirement for establishing a new network for legal operation on channels
- * requiring RADAR detection or restricting ACTIVE scanning.
- *
- * NOTE: "WIDE" flag does not indicate anything about "FAT" 40 MHz channels.
- * It only indicates that 20 MHz channel use is supported; FAT channel
- * usage is indicated by a separate set of regulatory flags for each
- * FAT channel pair.
- *
- * NOTE: Using a channel inappropriately will result in a uCode error!
- */
-enum {
- EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */
- EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */
- /* Bit 2 Reserved */
- EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */
- EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */
- EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */
- EEPROM_CHANNEL_NARROW = (1 << 6), /* 10 MHz channel (not used) */
- EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */
-};
-
-/* SKU Capabilities */
-#define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0)
-#define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1)
-
-/* *regulatory* channel data format in eeprom, one for each channel.
- * There are separate entries for FAT (40 MHz) vs. normal (20 MHz) channels. */
-struct iwl4965_eeprom_channel {
- u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */
- s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */
-} __attribute__ ((packed));
-
-/* 4965 has two radio transmitters (and 3 radio receivers) */
-#define EEPROM_TX_POWER_TX_CHAINS (2)
-
-/* 4965 has room for up to 8 sets of txpower calibration data */
-#define EEPROM_TX_POWER_BANDS (8)
-
-/* 4965 factory calibration measures txpower gain settings for
- * each of 3 target output levels */
-#define EEPROM_TX_POWER_MEASUREMENTS (3)
-
-/* 4965 driver does not work with txpower calibration version < 5.
- * Look for this in calib_version member of struct iwl4965_eeprom. */
-#define EEPROM_TX_POWER_VERSION_NEW (5)
-
-
-/*
- * 4965 factory calibration data for one txpower level, on one channel,
- * measured on one of the 2 tx chains (radio transmitter and associated
- * antenna). EEPROM contains:
- *
- * 1) Temperature (degrees Celsius) of device when measurement was made.
- *
- * 2) Gain table index used to achieve the target measurement power.
- * This refers to the "well-known" gain tables (see iwl-4965-hw.h).
- *
- * 3) Actual measured output power, in half-dBm ("34" = 17 dBm).
- *
- * 4) RF power amplifier detector level measurement (not used).
- */
-struct iwl4965_eeprom_calib_measure {
- u8 temperature; /* Device temperature (Celsius) */
- u8 gain_idx; /* Index into gain table */
- u8 actual_pow; /* Measured RF output power, half-dBm */
- s8 pa_det; /* Power amp detector level (not used) */
-} __attribute__ ((packed));
-
-
-/*
- * 4965 measurement set for one channel. EEPROM contains:
- *
- * 1) Channel number measured
- *
- * 2) Measurements for each of 3 power levels for each of 2 radio transmitters
- * (a.k.a. "tx chains") (6 measurements altogether)
- */
-struct iwl4965_eeprom_calib_ch_info {
- u8 ch_num;
- struct iwl4965_eeprom_calib_measure measurements[EEPROM_TX_POWER_TX_CHAINS]
- [EEPROM_TX_POWER_MEASUREMENTS];
-} __attribute__ ((packed));
-
-/*
- * 4965 txpower subband info.
- *
- * For each frequency subband, EEPROM contains the following:
- *
- * 1) First and last channels within range of the subband. "0" values
- * indicate that this sample set is not being used.
- *
- * 2) Sample measurement sets for 2 channels close to the range endpoints.
- */
-struct iwl4965_eeprom_calib_subband_info {
- u8 ch_from; /* channel number of lowest channel in subband */
- u8 ch_to; /* channel number of highest channel in subband */
- struct iwl4965_eeprom_calib_ch_info ch1;
- struct iwl4965_eeprom_calib_ch_info ch2;
-} __attribute__ ((packed));
-
-
-/*
- * 4965 txpower calibration info. EEPROM contains:
- *
- * 1) Factory-measured saturation power levels (maximum levels at which
- * tx power amplifier can output a signal without too much distortion).
- * There is one level for 2.4 GHz band and one for 5 GHz band. These
- * values apply to all channels within each of the bands.
- *
- * 2) Factory-measured power supply voltage level. This is assumed to be
- * constant (i.e. same value applies to all channels/bands) while the
- * factory measurements are being made.
- *
- * 3) Up to 8 sets of factory-measured txpower calibration values.
- * These are for different frequency ranges, since txpower gain
- * characteristics of the analog radio circuitry vary with frequency.
- *
- * Not all sets need to be filled with data;
- * struct iwl4965_eeprom_calib_subband_info contains range of channels
- * (0 if unused) for each set of data.
- */
-struct iwl4965_eeprom_calib_info {
- u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */
- u8 saturation_power52; /* half-dBm */
- s16 voltage; /* signed */
- struct iwl4965_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS];
-} __attribute__ ((packed));
-
-
-/*
- * 4965 EEPROM map
- */
-struct iwl4965_eeprom {
- u8 reserved0[16];
-#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
- u16 device_id; /* abs.ofs: 16 */
- u8 reserved1[2];
-#define EEPROM_PMC (2*0x0A) /* 2 bytes */
- u16 pmc; /* abs.ofs: 20 */
- u8 reserved2[20];
-#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
- u8 mac_address[6]; /* abs.ofs: 42 */
- u8 reserved3[58];
-#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
- u16 board_revision; /* abs.ofs: 106 */
- u8 reserved4[11];
-#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
- u8 board_pba_number[9]; /* abs.ofs: 119 */
- u8 reserved5[8];
-#define EEPROM_VERSION (2*0x44) /* 2 bytes */
- u16 version; /* abs.ofs: 136 */
-#define EEPROM_SKU_CAP (2*0x45) /* 1 bytes */
- u8 sku_cap; /* abs.ofs: 138 */
-#define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */
- u8 leds_mode; /* abs.ofs: 139 */
-#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
- u16 oem_mode;
-#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
- u16 wowlan_mode; /* abs.ofs: 142 */
-#define EEPROM_LEDS_TIME_INTERVAL (2*0x48) /* 2 bytes */
- u16 leds_time_interval; /* abs.ofs: 144 */
-#define EEPROM_LEDS_OFF_TIME (2*0x49) /* 1 bytes */
- u8 leds_off_time; /* abs.ofs: 146 */
-#define EEPROM_LEDS_ON_TIME (2*0x49+1) /* 1 bytes */
- u8 leds_on_time; /* abs.ofs: 147 */
-#define EEPROM_ALMGOR_M_VERSION (2*0x4A) /* 1 bytes */
- u8 almgor_m_version; /* abs.ofs: 148 */
-#define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */
- u8 antenna_switch_type; /* abs.ofs: 149 */
- u8 reserved6[8];
-#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */
- u16 board_revision_4965; /* abs.ofs: 158 */
- u8 reserved7[13];
-#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */
- u8 board_pba_number_4965[9]; /* abs.ofs: 173 */
- u8 reserved8[10];
-#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
- u8 sku_id[4]; /* abs.ofs: 192 */
-
-/*
- * Per-channel regulatory data.
- *
- * Each channel that *might* be supported by 3945 or 4965 has a fixed location
- * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
- * txpower (MSB).
- *
- * Entries immediately below are for 20 MHz channel width. FAT (40 MHz)
- * channels (only for 4965, not supported by 3945) appear later in the EEPROM.
- *
- * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
- */
-#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
- u16 band_1_count; /* abs.ofs: 196 */
-#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
- struct iwl4965_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */
-
-/*
- * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
- * 5.0 GHz channels 7, 8, 11, 12, 16
- * (4915-5080MHz) (none of these is ever supported)
- */
-#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
- u16 band_2_count; /* abs.ofs: 226 */
-#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
- struct iwl4965_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
-
-/*
- * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
- * (5170-5320MHz)
- */
-#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
- u16 band_3_count; /* abs.ofs: 254 */
-#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
- struct iwl4965_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
-
-/*
- * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
- * (5500-5700MHz)
- */
-#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
- u16 band_4_count; /* abs.ofs: 280 */
-#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
- struct iwl4965_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
-
-/*
- * 5.7 GHz channels 145, 149, 153, 157, 161, 165
- * (5725-5825MHz)
- */
-#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
- u16 band_5_count; /* abs.ofs: 304 */
-#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
- struct iwl4965_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
-
- u8 reserved10[2];
-
-
-/*
- * 2.4 GHz FAT channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11)
- *
- * The channel listed is the center of the lower 20 MHz half of the channel.
- * The overall center frequency is actually 2 channels (10 MHz) above that,
- * and the upper half of each FAT channel is centered 4 channels (20 MHz) away
- * from the lower half; e.g. the upper half of FAT channel 1 is channel 5,
- * and the overall FAT channel width centers on channel 3.
- *
- * NOTE: The RXON command uses 20 MHz channel numbers to specify the
- * control channel to which to tune. RXON also specifies whether the
- * control channel is the upper or lower half of a FAT channel.
- *
- * NOTE: 4965 does not support FAT channels on 2.4 GHz.
- */
-#define EEPROM_REGULATORY_BAND_24_FAT_CHANNELS (2*0xA0) /* 14 bytes */
- struct iwl4965_eeprom_channel band_24_channels[7]; /* abs.ofs: 320 */
- u8 reserved11[2];
-
-/*
- * 5.2 GHz FAT channels 36 (40), 44 (48), 52 (56), 60 (64),
- * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161)
- */
-#define EEPROM_REGULATORY_BAND_52_FAT_CHANNELS (2*0xA8) /* 22 bytes */
- struct iwl4965_eeprom_channel band_52_channels[11]; /* abs.ofs: 336 */
- u8 reserved12[6];
-
-/*
- * 4965 driver requires txpower calibration format version 5 or greater.
- * Driver does not work with txpower calibration version < 5.
- * This value is simply a 16-bit number, no major/minor versions here.
- */
-#define EEPROM_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */
- u16 calib_version; /* abs.ofs: 364 */
- u8 reserved13[2];
- u8 reserved14[96]; /* abs.ofs: 368 */
-
-/*
- * 4965 Txpower calibration data.
- */
-#define EEPROM_IWL_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */
- struct iwl4965_eeprom_calib_info calib_info; /* abs.ofs: 464 */
-
- u8 reserved16[140]; /* fill out to full 1024 byte block */
-
-
-} __attribute__ ((packed));
-
-#define IWL_EEPROM_IMAGE_SIZE 1024
-
-/* End of EEPROM */

#include "iwl-4965-commands.h"

diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 5140a16..b3bf7c1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -38,6 +38,7 @@
#include <linux/etherdevice.h>
#include <asm/unaligned.h>

+#include "iwl-eeprom.h"
#include "iwl-core.h"
#include "iwl-4965.h"
#include "iwl-helpers.h"
@@ -4826,10 +4827,23 @@ void iwl4965_hw_cancel_deferred_work(struct iwl4965_priv *priv)
cancel_delayed_work(&priv->init_alive_start);
}

+static struct iwl_lib_ops iwl4965_lib = {
+ .eeprom_ops = {
+ .verify_signature = iwlcore_eeprom_verify_signature,
+ .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
+ .release_semaphore = iwlcore_eeprom_release_semaphore,
+ },
+};
+
+static struct iwl_ops iwl4965_ops = {
+ .lib = &iwl4965_lib,
+};
+
static struct iwl_cfg iwl4965_agn_cfg = {
.name = "4965AGN",
.fw_name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode",
.sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
+ .ops = &iwl4965_ops,
};

struct pci_device_id iwl4965_hw_card_ids[] = {
@@ -4838,35 +4852,4 @@ struct pci_device_id iwl4965_hw_card_ids[] = {
{0}
};

-/*
- * The device's EEPROM semaphore prevents conflicts between driver and uCode
- * when accessing the EEPROM; each access is a series of pulses to/from the
- * EEPROM chip, not a single event, so even reads could conflict if they
- * weren't arbitrated by the semaphore.
- */
-int iwl4965_eeprom_acquire_semaphore(struct iwl4965_priv *priv)
-{
- u16 count;
- int rc;
-
- for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) {
- /* Request semaphore */
- iwl4965_set_bit(priv, CSR_HW_IF_CONFIG_REG,
- CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
-
- /* See if we got it */
- rc = iwl4965_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
- CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
- CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
- EEPROM_SEM_TIMEOUT);
- if (rc >= 0) {
- IWL_DEBUG_IO("Acquired semaphore after %d tries.\n",
- count+1);
- return rc;
- }
- }
-
- return rc;
-}
-
MODULE_DEVICE_TABLE(pci, iwl4965_hw_card_ids);
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.h b/drivers/net/wireless/iwlwifi/iwl-4965.h
index 0895af6..6e38ac2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.h
@@ -40,6 +40,7 @@
extern struct pci_device_id iwl4965_hw_card_ids[];

#define DRV_NAME "iwl4965"
+#include "iwl-eeprom.h"
#include "iwl-4965-hw.h"
#include "iwl-csr.h"
#include "iwl-prph.h"
@@ -641,7 +642,6 @@ extern u8 iwl4965_add_station_flags(struct iwl4965_priv *priv, const u8 *addr,
extern int iwl4965_is_network_packet(struct iwl4965_priv *priv,
struct ieee80211_hdr *header);
extern int iwl4965_power_init_handle(struct iwl4965_priv *priv);
-extern int iwl4965_eeprom_init(struct iwl4965_priv *priv);
extern void iwl4965_handle_data_packet_monitor(struct iwl4965_priv *priv,
struct iwl4965_rx_mem_buffer *rxb,
void *data, short len,
@@ -747,8 +747,6 @@ struct iwl4965_priv;
/*
* Forward declare iwl-4965.c functions for iwl-base.c
*/
-extern int iwl4965_eeprom_acquire_semaphore(struct iwl4965_priv *priv);
-
extern int iwl4965_tx_queue_update_wr_ptr(struct iwl4965_priv *priv,
struct iwl4965_tx_queue *txq,
u16 byte_cnt);
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index b8383c8..9ca5398 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -31,6 +31,7 @@
#include <linux/version.h>

#include "iwl-4965-debug.h"
+#include "iwl-eeprom.h"
#include "iwl-core.h"

MODULE_DESCRIPTION("iwl core");
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index bdd32f8..88fd49a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -75,10 +75,20 @@
#define IWL_SKU_A 0x2
#define IWL_SKU_N 0x8

+struct iwl_lib_ops {
+ /* eeprom operations (as defined in iwl-eeprom.h) */
+ struct iwl_eeprom_ops eeprom_ops;
+};
+
+struct iwl_ops {
+ const struct iwl_lib_ops *lib;
+};
+
struct iwl_cfg {
const char *name;
const char *fw_name;
unsigned int sku;
+ const struct iwl_ops *ops;
};

#endif /* __iwl_core_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 324b66f..49041e9 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -45,6 +45,7 @@

#include <asm/div64.h>

+#include "iwl-eeprom.h"
#include "iwl-core.h"
#include "iwl-4965.h"
#include "iwl-helpers.h"
@@ -1562,85 +1563,6 @@ static int iwl4965_send_beacon_cmd(struct iwl4965_priv *priv)

/******************************************************************************
*
- * EEPROM related functions
- *
- ******************************************************************************/
-
-static void get_eeprom_mac(struct iwl4965_priv *priv, u8 *mac)
-{
- memcpy(mac, priv->eeprom.mac_address, 6);
-}
-
-static inline void iwl4965_eeprom_release_semaphore(struct iwl4965_priv *priv)
-{
- iwl4965_clear_bit(priv, CSR_HW_IF_CONFIG_REG,
- CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
-}
-
-/**
- * iwl4965_eeprom_init - read EEPROM contents
- *
- * Load the EEPROM contents from adapter into priv->eeprom
- *
- * NOTE: This routine uses the non-debug IO access functions.
- */
-int iwl4965_eeprom_init(struct iwl4965_priv *priv)
-{
- u16 *e = (u16 *)&priv->eeprom;
- u32 gp = iwl4965_read32(priv, CSR_EEPROM_GP);
- u32 r;
- int sz = sizeof(priv->eeprom);
- int rc;
- int i;
- u16 addr;
-
- /* The EEPROM structure has several padding buffers within it
- * and when adding new EEPROM maps is subject to programmer errors
- * which may be very difficult to identify without explicitly
- * checking the resulting size of the eeprom map. */
- BUILD_BUG_ON(sizeof(priv->eeprom) != IWL_EEPROM_IMAGE_SIZE);
-
- if ((gp & CSR_EEPROM_GP_VALID_MSK) == CSR_EEPROM_GP_BAD_SIGNATURE) {
- IWL_ERROR("EEPROM not found, EEPROM_GP=0x%08x", gp);
- return -ENOENT;
- }
-
- /* Make sure driver (instead of uCode) is allowed to read EEPROM */
- rc = iwl4965_eeprom_acquire_semaphore(priv);
- if (rc < 0) {
- IWL_ERROR("Failed to acquire EEPROM semaphore.\n");
- return -ENOENT;
- }
-
- /* eeprom is an array of 16bit values */
- for (addr = 0; addr < sz; addr += sizeof(u16)) {
- _iwl4965_write32(priv, CSR_EEPROM_REG, addr << 1);
- _iwl4965_clear_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_BIT_CMD);
-
- for (i = 0; i < IWL_EEPROM_ACCESS_TIMEOUT;
- i += IWL_EEPROM_ACCESS_DELAY) {
- r = _iwl4965_read_direct32(priv, CSR_EEPROM_REG);
- if (r & CSR_EEPROM_REG_READ_VALID_MSK)
- break;
- udelay(IWL_EEPROM_ACCESS_DELAY);
- }
-
- if (!(r & CSR_EEPROM_REG_READ_VALID_MSK)) {
- IWL_ERROR("Time out reading EEPROM[%d]", addr);
- rc = -ETIMEDOUT;
- goto done;
- }
- e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
- }
- rc = 0;
-
-done:
- iwl4965_eeprom_release_semaphore(priv);
- return rc;
-}
-
-/******************************************************************************
- *
* Misc. internal state and helper functions
*
******************************************************************************/
@@ -8778,13 +8700,13 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
goto out_remove_sysfs;
}
/* Read the EEPROM */
- err = iwl4965_eeprom_init(priv);
+ err = iwl_eeprom_init(priv);
if (err) {
IWL_ERROR("Unable to init EEPROM\n");
goto out_remove_sysfs;
}
/* MAC Address location in EEPROM same for 3945/4965 */
- get_eeprom_mac(priv, priv->mac_addr);
+ iwl_eeprom_get_mac(priv, priv->mac_addr);
IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr));
SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);

--
1.5.3.4


2008-03-10 18:41:27

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 3/7] iwlwifi: Use sta_bcast_id variable instead of BROADCAST_ID constant

From: Tomas Winkler <[email protected]>

This patch removes iwlYYY_BROADCAST_ID from run time usage.
hw_setting.sta_bcast_id is used instead.

Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-3945.c | 4 ++--
drivers/net/wireless/iwlwifi/iwl-4965.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index bcfa299..4e6c529 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -986,7 +986,7 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl3945_priv *priv,
priv->stations[sta_id].current_rate.rate_n_flags = rate;

if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) &&
- (sta_id != IWL3945_BROADCAST_ID) &&
+ (sta_id != priv->hw_setting.bcast_sta_id) &&
(sta_id != IWL_MULTICAST_ID))
priv->stations[IWL_STA_ID].current_rate.rate_n_flags = rate;

@@ -2601,7 +2601,7 @@ unsigned int iwl3945_hw_get_beacon_cmd(struct iwl3945_priv *priv,
tx_beacon_cmd = (struct iwl3945_tx_beacon_cmd *)&frame->u;
memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd));

- tx_beacon_cmd->tx.sta_id = IWL3945_BROADCAST_ID;
+ tx_beacon_cmd->tx.sta_id = priv->hw_setting.bcast_sta_id;
tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;

frame_size = iwl3945_fill_beacon_frame(priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 6468504..90462a0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -254,7 +254,7 @@ u8 iwl4965_hw_find_station(struct iwl4965_priv *priv, const u8 *addr)
start = IWL_STA_ID;

if (is_broadcast_ether_addr(addr))
- return IWL4965_BROADCAST_ID;
+ return priv->hw_setting.bcast_sta_id;

spin_lock_irqsave(&priv->sta_lock, flags);
for (i = start; i < priv->hw_setting.max_stations; i++)
@@ -2836,7 +2836,7 @@ unsigned int iwl4965_hw_get_beacon_cmd(struct iwl4965_priv *priv,
tx_beacon_cmd = &frame->u.beacon;
memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd));

- tx_beacon_cmd->tx.sta_id = IWL4965_BROADCAST_ID;
+ tx_beacon_cmd->tx.sta_id = priv->hw_setting.bcast_sta_id;
tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;

frame_size = iwl4965_fill_beacon_frame(priv,
@@ -4438,7 +4438,7 @@ void iwl4965_add_station(struct iwl4965_priv *priv, const u8 *addr, int is_ap)
link_cmd.agg_params.agg_time_limit = cpu_to_le16(4000);

/* Update the rate scaling for control frame Tx to AP */
- link_cmd.sta_id = is_ap ? IWL_AP_ID : IWL4965_BROADCAST_ID;
+ link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_setting.bcast_sta_id;

iwl4965_send_cmd_pdu(priv, REPLY_TX_LINK_QUALITY_CMD, sizeof(link_cmd),
&link_cmd);
--
1.5.3.4