History log of /drivers/net/wireless/iwlwifi/iwl-debugfs.c
Revision Date Author Comments
234e340582901211f40d8c732afc49f0630ecf05 05-Apr-2012 Stephen Boyd <sboyd@codeaurora.org> simple_open: automatically convert to simple_open()

Many users of debugfs copy the implementation of default_open() when
they want to support a custom read/write function op. This leads to a
proliferation of the default_open() implementation across the entire
tree.

Now that the common implementation has been consolidated into libfs we
can replace all the users of this function with simple_open().

This replacement was done with the following semantic patch:

<smpl>
@ open @
identifier open_f != simple_open;
identifier i, f;
@@
-int open_f(struct inode *i, struct file *f)
-{
(
-if (i->i_private)
-f->private_data = i->i_private;
|
-f->private_data = i->i_private;
)
-return 0;
-}

@ has_open depends on open @
identifier fops;
identifier open.open_f;
@@
struct file_operations fops = {
...
-.open = open_f,
+.open = simple_open,
...
};
</smpl>

[akpm@linux-foundation.org: checkpatch fixes]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
6dfa8d019cd21d08634ceb65a3fb90d0648bd93b 10-Mar-2012 David Spinadel <david.spinadel@intel.com> iwlwifi: change struct iwl_fw

Change iwl_fw struct to hold an array of fw_img instead of
three separated instances.

Change fw_img to hold an array of fw_desc instead of two
separate descriptors for instructions and data.

Change load_given_ucode, load_section, verification functions
etc. to support this structure.

Signed-off-by: David Spinadel <david.spinadel@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8f7ffbe2b275e5315773322161945a24518e31f4 10-Mar-2012 David Spinadel <david.spinadel@intel.com> iwlwifi: avoid some operations if no uCode loaded

Printing the SRAM and similar testmode operations could
be triggered when no uCode is loaded; prevent those
invalid operations by tracking whether uCode is loaded.

Signed-off-by: David Spinadel <david.spinadel@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1745e4405b2c0da6db2ec4b6bc0ad930612d8295 09-Mar-2012 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: fix the delta for remove max_txq_num patch

BIg portion of "iwlwifi: remove max_txq_num from hw_params" was
missing during merge, here is the fix for it.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
83626404a70da74c67f32f119e53c0ba032ba2d8 07-Mar-2012 Don Fry <donald.h.fry@intel.com> iwlwifi: more status bit factoring

Continue splitting the status bits between transport and op_mode.
All but a few are separated.

Signed-off-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9a716863ae4a2f039bc4d0b2b2bb4b24a1dc7a91 07-Mar-2012 Don Fry <donald.h.fry@intel.com> iwlwifi: separate status to priv and trans

The shared status bits are a mixture of transport and op mode bits.
Some are used just by one or the other, some are shared. Begin the
de-tangling of these bits.

Signed-off-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b9ad70da6a7ed166539b188a95e0aef119555e14 06-Mar-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: put use_rts_for_aggregation into hw_params

The hardware config ht_params shouldn't be modified,
so copy the use_rts_for_aggregation parameter into
hw_params and use/modify it there.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e7a09438b3369732b9c5cfbca24d3bc894fc1ec1 06-Mar-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: use watchdog timeout from hw_params

This is the version that can be modified, the
config params should be read-only.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ab5c0f1f2d525ed17f1abf727d213cf220ed26a8 06-Mar-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: keep plcp_delta_threshold in priv

The base_params shouldn't be writable, so keep
a copy of this in priv that can be modified.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b1eea297d6b522b801c95b60b1e64fb61228c6c7 06-Mar-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: move mutex out of shared

Now the mutex no longer needs to be
shared, so move it into iwl_priv.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
965974a631756ab2729469b9ecadfe61ee44dfc5 06-Mar-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: remove iwl-wifi.h

This file was recently introduced, but then
directly abused -- it contained private data
that shouldn't have been used by anything
but the implementation of firmware requests
and some very core code. Now that it is no
longer accessed by any code but the code in
iwl-drv.c, we can dissolve it.

Also rename the iwl_nic struct to iwl_drv to
better reflect where and how it is used.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0692fe41b36159be5d8c7d4eef0699e79c383c85 06-Mar-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: split out firmware store

Through the driver, struct iwl_fw will
store the firmware. Split this out into
a separate file, iwl-fw.h, and make all
other code use it. To do this, also move
the log pointers into it, and remove the
knowledge of "nic" from everything.

Now the op_mode has a fw pointer, and
(unfortunately) for now the shared data
also needs to keep one for the transport
to access dump the error log -- I think
that will move later.

Since I wanted to constify the firmware
pointers, some more changes were needed.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7e79a3937a44b1dc5f457e6dbb8c50e93719286a 05-Mar-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: use valid TX/RX antenna from hw_params

It's not really a good idea to write to the
global static configuration. Use the valid
TX/RX antenna information only from the HW
params struct except in the case where the
values from the config are used to override
the values from the EEPROM.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a8bceb392a739321ec20d03a91a86ebdde9c07bb 05-Mar-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: remove per-device debug level

There's no need for the per-device debug
level that we expose in debugfs since the
module parameter is writable in sysfs.

At the same time, simplify code by changing
iwl_get_debug_level(shrd) & IWL_DL_ISR)
to
iwl_have_debug_level(IWL_DL_ISR)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4ff70fcdf3c424c3fdca253e7b7556f77eaf39be 05-Mar-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: introduce statistics lock

The statistics are currently only half-heartedly
locked against concurrent reading & modification
so introduce a lock to really protect them.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6516174d1a42c1b1b2861360bf44fe9992fb0f7e 08-Feb-2012 Don Fry <donald.h.fry@intel.com> iwlwifi: Move ucode pointers to iwl_fw

The ucode image is a ucode related thing not a transport one. Move them.

Signed-off-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
1042db2af183b96cdce5972014d85e8bca0634ad 03-Jan-2012 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlwifi: give trans to all the read / write functions

From now on, the transport layer in charge of providing access to the
device. So change all the driver to give a pointer to the transport
to all the low level functions that actually access the device.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
2b2db58d65edcab4bcc9d6fdd2770bb0275cdac4 28-Jan-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: fix uCode event tracing

Fix multiple bugs in event tracing:

1) If you enable uCode tracing with the device down,
it will still attempt to access the device and
continuously log "MAC is in deep sleep!" errors.
Fix this by only starting logging when the device
is actually alive.

2) Now you can set the flag when the device is down,
but logging doesn't happen when you bring it up.
To fix that, start logging when the device comes
alive. This means we don't log before -- we could
do that but I don't need it right now.

3) For some reason we read the error instead of the
event log -- use the right pointer.

4) Optimise SRAM reading of event log header.

5) Fix reading write pointer == capacity, which can
happen due to racy SRAM access

6) Most importantly: fix an error where we would try
to read WAY too many events (like 2^32-300) when
we read the wrap counter before it is updated by
the uCode -- this does happen in practice and will
cause the driver to hang the machine.

7) Finally, change the timer to 10ms instead of 100ms
as 100ms is too slow to capture all data with a
normal event log and with 100ms the log will wrap
multiple times before we have a chance to read it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
98d4bf0c49de0d7c68fa7e1f7bd0a37420f712ca 13-Jan-2012 Johannes Berg <johannes.berg@intel.com> iwlwifi: fix uCode event tracing

Fix multiple bugs in event tracing:

1) If you enable uCode tracing with the device down,
it will still attempt to access the device and
continuously log "MAC is in deep sleep!" errors.
Fix this by only starting logging when the device
is actually alive.

2) Now you can set the flag when the device is down,
but logging doesn't happen when you bring it up.
To fix that, start logging when the device comes
alive. This means we don't log before -- we could
do that but I don't need it right now.

3) For some reason we read the error instead of the
event log -- use the right pointer.

4) Optimise SRAM reading of event log header.

5) Fix reading write pointer == capacity, which can
happen due to racy SRAM access

6) Most importantly: fix an error where we would try
to read WAY too many events (like 2^32-300) when
we read the wrap counter before it is updated by
the uCode -- this does happen in practice and will
cause the driver to hang the machine.

7) Finally, change the timer to 10ms instead of 100ms
as 100ms is too slow to capture all data with a
normal event log and with 100ms the log will wrap
multiple times before we have a chance to read it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
fb4961dbc27d40cdbed297aa9bd74fa4a0e2ba6c 06-Jan-2012 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: update Copyright

Update Copyright to 2012

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4e3182626a914443a5e0fbe014813f03e51a75df 27-Dec-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: update Copyright

Update Copyright to 2012

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
04cf6824a5e92e6f86c0abcb38ac65ee744c3d34 23-Nov-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlwifi: tid_data moves to iwl_priv

The transport doesn't need to access it any more.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
76bc10fcd128ad028cf77c62e179cd20dc2ffecf 21-Nov-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlwifi: tid_data logic move to upper layer - txqid

The tid_data is not related to the transport layer, so move
the logic that depends on it to the upper layer.
This patch deals with the mapping of RA / TID to HW queues in AGG.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
eb9a372a73ea3e2b7e795a7ea03a5b8d92815672 21-Nov-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlwifi: don't count the tfds in HW queue any more

Since packets sent to an RA / TID in AGG are sent from a
separate HW Tx queue, we may get into a race:
the regular queue isn't empty while we already begin to
send packets from the AGG queue. This would result in sending
packets out of order.

In order to cope with this, mac80211 waits until the driver
reports that the legacy queue is drained before it can send
packets to the AGG queue. During that time, mac80211 buffers
packets for the driver. These packets will be sent in order
after the driver reports it is ready.

The way this was implemented in the driver is as follows:
We held a counter that monitors the number of packets for
an RA / TID in the HW queues. When this counter reached 0,
we knew that the HW queues were drained and we reported to
mac80211 that were ready to proceed.

This patch changes the implementation described above. We
now remember what is the wifi sequence number of the first
packet that will be sent in the AGG queue (lets' call it
ssn). When we reclaim the packet before ssn, we know that
the queue is drained, and we are ready to proceed.

This will allow us to move this logic in the upper layer and
eventually remove the tid_data from the shared area.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
3862241945026a8fa165ab73c57739df77b8e1fb 16-Dec-2011 Don Fry <donald.h.fry@intel.com> iwlwifi: move iwl_cfg from iwl_priv to iwl_shared

Move the configuration pointer from the upper level iwl_priv to the
lower level iwl_shared structure, with associated code fixes.

Signed-off-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
ab36eab24e7847d6d92872c55b46554c8ac4c4b3 01-Dec-2011 Don Fry <donald.h.fry@intel.com> iwlwifi: move eeprom pointer from iwl_priv to iwl_shared

The eeprom image is a device level component, move from iwl_priv
to iwl_shared, with associated code changes.

Signed-off-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
a96b724d5ad7d44184d6a871bc1d35b005f2d53e 02-Dec-2011 Don Fry <donald.h.fry@intel.com> iwlwifi: move ucode_type from iwl_priv to iwl_shared

Move the ucode_type variable from the iwl_priv to the iwl_shared
structure with associated code changes.

Signed-off-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3d6acefc0a24bf90746c1f259e9d65d1ed7ea5e2 29-Nov-2011 Don Fry <donald.h.fry@intel.com> iwlwifi: move ucode_type from iwl_priv to iwl_shared

Move the ucode_type variable from the iwl_priv to the iwl_shared
structure with associated code changes.

Signed-off-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
97b52cfd1ae0c2f7284ee36e80ea0c22000f90bf 10-Nov-2011 Don Fry <donald.h.fry@intel.com> iwlagn: move nvm_device_type from iwl_priv to iwl_trans

The nvm_device_type is eeprom related and does not need to be part
of the iwl_priv structure. Move it and eliminate access to the iwl_priv
structure.

Signed-off-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
de7f5f92dbda0652dcb850fd02762e628556f645 10-Nov-2011 Don Fry <donald.h.fry@intel.com> iwlagn: move ucode files out of the iwl_priv structure

Relocate the ucode files and update relevant code.
More code refactoring.

Signed-off-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3eae4bb176d3d51f6c61b8b1679116e58586d669 10-Oct-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: kill hw_params.max_stations

Not needed since driver split.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7e4005cc4ae49100582ee1c97368dd79474f0a82 10-Oct-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: add "echo test" command to debugfs

For command queue testing, add "echo test" to debugfs

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
511afa3bfbb421ff0e87086725367f762587ab87 22-Sep-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: sparse warning priv->temperature is signed

Since priv->temperature is signed, we cannot use debugfs_create_u32
to refer to it.
Use a regular debugfs file instead.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ca934b6715c134573da5acea01e9258eb0bf7c27 15-Sep-2011 Johannes Berg <johannes.berg@intel.com> iwlagn: move sysfs files to debugfs

The debug_level and temperature files should be in
debugfs, the txpower file is completely unneeded
since TX power can be set with iw/iwconfig.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
41f5e0475c7c04b17b207736146187636b04eb4c 06-Sep-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: move traffic_log back to upper layer

The traffic log debugfs handlers were mistakenly moved to the
transport layer because they print the pointers of the Tx / Rx
queues. The pointers of the queues can be fetched by another debugfs
handler.
So bring the traffic log back to the upper layer and remove the part
that reads the Tx / Rx queues' pointers.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5f85a7890cbfd2be8f4c6620b2a6774d6b5ac647 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: iwl_tid_data moves to iwl-shared

The rate scaling and the transport need to access the data in
iwl_tid_data, hence the move.

Note that the only component in the upper layer that needs this data
is the rate scaling. Refactoring the rate scaling may help to move
iwl_tid_data from the shared area to the transport area.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
83ed90155f98bd949735c2cc22d832b557a6d7d1 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: all function iwl-io.c receive iwl_bus

Which means that iwl-io.c doesn't need to include iwl-dev.h any more.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
16db88ba51d669ef63c58990771a47208913152c 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: move dump_csr and dump_fh to transport layer

These are transport layer related. Move also the corresponding debugfs handlers.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
845a9c0d8acea87dede740bc5feb9ec2d00505d9 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: move all iwl_is_XXX helpers to iwl-shared.h

Logic move after all priv->status moved to struct iwl_shared

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1f7b6172db86e9ab2b4cd794441bb2c40ab287fc 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: move isr_statistics to transport layer

It is accessed by the transport layer only, hence the move.
The debugfs handlers that accessed it moved to the transport layer too.
The rx_handlers part of it stayed in the upper layer and a special debugfs
has been added for it

Also add missing includes to iwl-commands.h.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7ff94706a055f3e21710b08ffbe3979d7db615db 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: move the NIC error flow to the transport layer

It is transport dependent, move to the PCIe transport layer.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
87e5666c0722d5f4cad3560ab5c180c8bba62b8b 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: transport handler can register debugfs entries

Add a handler in iwl_trans_ops to allow it to add entries under debugfs dir
given by the upper level.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6ac2f839b0b21225a65f41802c5f0df5eff4f16c 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: priv->mutex moves to iwl_shared

Since it is used by all the layers, it needs to move to iwl_shared.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
63013ae30159c90d2a873e20e680e7810fa533fa 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: priv->status moves to iwl_shared

Since it is used by all the layers, it needs to move to iwl_shared.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d618912417fbce4f6514fe1cbef7df2e73bdb6c2 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: hw_params moves to iwl_shared

Since it is used by all the layers, it needs to move to iwl_shared.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8f470ce31de1a9dfe6b53e0967eaa7e72b741714 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: debug_level moves to struct iwl_shared

This will allow all the modules to look at it.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a294b96f25f2d436c90ca54d91e13461696cbcd4 26-Aug-2011 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlagn: use iwl_get_debug_level instead of iwl_debug_level

The latter may return incomplete information.
For example, if one switched IWL_DL_TX on through sysfs, IWL_DL_TX bit would
have been set in priv->debug_level, but since iwl_alloc_traffic_mem looked at
iwl_debug_level only, it wouldn't have allocated the tx_traffic buffer.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c8ac61cf6e53fefb3b439fc58390fb65d2730e63 15-Jul-2011 Johannes Berg <johannes.berg@intel.com> iwlagn: implement WoWLAN

Implement WoWLAN support in iwlagn. The device
supports a number of wakeup triggers and can do
GTK rekeying when asleep (if HW crypto is used).
Unfortunately, we need to disconnect from the AP
after resume since we can't yet get all the info
out of the wowlan uCode to stay connected safely.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
898ed67be047d0762cc7592f67bf1313dff53ca9 13-Jul-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: remove un-necessary "_agn"

After driver split, extra _agn in priv structure is no needed, remove it.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
c68744fb935400964f7af4835017cad5014c8c88 18-Jun-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: Remove un-necessary indirect call

After driver split, no need to make indirect call to txfifo flush function

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
872907bb17fe2d8d01d0e9723f72f91cb4ea103f 06-Jun-2011 Johannes Berg <johannes.berg@intel.com> iwlagn: don't check ucode subtype

The ucode subtypes keep changing, and there's no
particular reason to be checking them (other than
a paranoid sanity check). Since the numbers are
also in conflict between different ucode images
now, simply don't check them any more and rely on
the images being built correctly.

Also, to indicate that, rename the constants and
the enum, moving it to a different file.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
d6d023a1948d13652d719238f8039c09acceda8c 30-Apr-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: remove un-necessary debugfs callback

After driver split, no need for debugfs callback, remove those

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
dbf28e21ca391110e90ccad05dda79d2e2f60e0e 16-Apr-2011 Johannes Berg <johannes.berg@intel.com> iwlagn: combine firmware code/data

On new hardware, ucode images always come in
pairs: code and data. Therefore, combine the
variables into an appropriate struct and use
that when both code and data are needed.

Also, combine allocation and copying so that
we have less code in total.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
ca7966c88e44233fac113579071a6f55e00ef5ac 22-Apr-2011 Johannes Berg <johannes.berg@intel.com> iwlagn: implement synchronous firmware load

The current firmware loading mechanism in
iwlwifi is very hard to follow, and thus
hard to maintain. To make it easier, make
the firmware loading synchronous.

For now, as a side effect, this removes a
number of retry possibilities we had. It
isn't typical for this to fail, but if it
does happen we restart from scratch which
this also makes easier to do should it be
necessary.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
b7af6a99690503a48c63ce5e587b4e4555f31cdb 07-Apr-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: always support uCode trace

All _agn devices support continuous uCode trace, remove checking

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
0da0e5bf1522d75d446f5124e17016628d0a149e 08-Apr-2011 Johannes Berg <johannes.berg@intel.com> iwlagn: clean up & autodetect statistics

There's no need to keep both normal and BT statistics
versions around all the time in memory when we only
use a subset of both. So keep only the subsets that
we need in memory, depending on the debug config).

Also, in doing so, we can remove all the calls to
iwl_bt_statistics() in the driver as we'll just
access the copied statistics now.

Finally, also remove this call from the one place
where it might still be needed and automatically
detect what kind of statistics the device is sending
based on their size. This way, we don't need to keep
track of which devices do what any more, which is
good since this is subject to change based on the
ucode version (as some ucode even for non-BT devices
will in fact use BT statistics).

Warn upon encountering a statistics command from the
ucode that isn't known, so we will find such issues
earlier in the future.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Tested-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
703bc583cb98a24eeedd297ee59dfa12852897d1 03-Apr-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: sensitivity and chain noise done by driver

_agn driver should perform both sensitivity and chain noise calib.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
ae89726a02049e8f61bb3c8bf5dbf1fc06527a07 02-Apr-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: tx power calib always done in firmware

Remove the config flag for tx power calib

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
23c0fcc66b4345ea97ae588c2e01f10c994652ba 02-Apr-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: all _agn devices support power save mode

Remove broken_power_save checking

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
3ecccbcd3c67374aeee447c08fcb9e39a99f7ee5 30-Mar-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: remove un-necessary function pointer

After driver split, no need to use function pointer for those event and
register dump function.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
901069c71415a76d731857ccda814e18ded062f7 05-Apr-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: change Copyright to 2011

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
08960dea6c736280a03cb947f445fdb94fdaa2ee 05-Apr-2011 Johannes Berg <johannes.berg@intel.com> iwlagn: remove pointless return variables

A number of places just use a variable to return
it right away, which is useless, so let's remove
the variables there.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
be663ab67077fac8e23eb8e231a8c1c94cb32e54 21-Feb-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: split the drivers for agn and legacy devices 3945/4965

Intel WiFi devices 3945 and 4965 now have their own driver in the folder

drivers/net/wireless/iwlegacy

Add support to build these drivers independently of the driver for
AGN devices. Selecting the 3945 builds iwl3945.ko and iwl_legacy.ko,
and selecting the 4965 builds iwl4965.ko and iwl_legacy.ko. iwl-legacy.ko
contains code shared between both devices.

The 3945 is an ABG/BG device, with no support for 802.11n. The 4965 is a 2x3
ABGN device.

Signed-off-by: Meenakshi Venkataraman <meenakshi.venkataraman@intel.com>
Acked-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
4bc85c1324aaa4a8bb0171e332ff762b6230bdfe 21-Feb-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> Revert "iwlwifi: split the drivers for agn and legacy devices 3945/4965"

This reverts commit aa833c4b1a928b8d3c4fcc2faaa0d6b81ea02b56.
aa833c4b1a928b8d3c4fcc2faaa0d6b81ea02b56 21-Feb-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: split the drivers for agn and legacy devices 3945/4965

Intel WiFi devices 3945 and 4965 now have their own driver in the folder

drivers/net/wireless/iwlegacy

Add support to build these drivers independently of the driver for
AGN devices. Selecting the 3945 builds iwl3945.ko and iwl_legacy.ko,
and selecting the 4965 builds iwl4965.ko and iwl_legacy.ko. iwl-legacy.ko
contains code shared between both devices.

The 3945 is an ABG/BG device, with no support for 802.11n. The 4965 is a 2x3
ABGN device.

Signed-off-by: Meenakshi Venkataraman <meenakshi.venkataraman@intel.com>
Acked-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
187bc4f6b2f81e1c8f6b1e9d5dee3e8e9018ebbf 27-Jan-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: remove unsupported BT SCO command

During the period of BT coex changes, REPLY_BT_COEX_SCO host command
is no longer needed to support SCO/eSCO type of traffic. delete it.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
9f60e7ee4206507c7f248d06e3b4a8a59ed33308 28-Jan-2011 Stanislaw Gruszka <sgruszka@redhat.com> iwlwifi: introduce iwl_bt_statistics

We use priv->cfg->bt_params && priv->cfg->bt_params->bt_statistics
conditional in few places, merge it into one function.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
88e58fc5d940c3463c7070a2a7a8a0ce65af3fdc 28-Jan-2011 Stanislaw Gruszka <sgruszka@redhat.com> iwlwifi: introduce iwl_advanced_bt_coexist()

We use priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist
conditional in few places, merge it into one function.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
24834d2c8455a6eeee82e007d41d7e05986d134f 12-Jan-2011 Jay Sternberg <jay.e.sternberg@intel.com> iwlwifi: correct debugfs data dumped from sram

the sram data dumped through the debugfs interface would only work properly
when dumping data on even u32 boundaries and swap bytes based on endianness
on that boundary making byte arrays impossible to read.

now addresses are displayed at the start of every line and the data is
displayed consistently if dumping 1 byte or 20 and regardless of what is the
starting address.

if no lenght given, address displayed is u32 in device format

Signed-off-by: Jay Sternberg <jay.e.sternberg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
5ed540aecc2aae92d5c97b9a9306a5bf88ad5574 22-Jan-2011 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: use mac80211 throughput trigger

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>
f21dd005df95e0fc6a578342c61b5333ce2abc2b 09-Dec-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: keep track of bt coex enable/disable stage

For debugging purpose, keep track of the bt coex enable/disable state.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
22de94de7de78b8de2fb1f2df5aa85b5556cfcfd 03-Dec-2010 Stanislaw Gruszka <sgruszka@redhat.com> iwlwifi: jiffies based tx queues watchdog

This patch replace monitor/recover timer by watchdog based on time
stamp. New code allow to discover hangs more precisely.

Timeout values are currently doubled monitoring period values of
previous timer. This have to be tuned based of firmware timing
capabilities.

Tested on 3945, 4965, 5300, 6300.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ea9b307f8e859186a6791e0d508c5993448ac900 11-Nov-2010 Johannes Berg <johannes.berg@intel.com> iwlwifi: always build swq_id as virtual queue ID

Previously, we used the swq_id's mechanism
to have AC and HW queue different only for
aggregation queues. To be able to fix a bug
with iPAN simply always build the swq_id as
ac | (hwq << 2) and remove the flag bit.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
66e863a527f9ed3a871797862aaf0d62b0954813 08-Nov-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: support dynamic aggregation for BT coex

Use dynamic aggregation threshold if bt traffic load is high
to reduce the impact on aggregated frame.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
0de76736552cff02cc6ee4bae41e5502d7673f8e 22-Sep-2010 Johannes Berg <johannes.berg@intel.com> iwlwifi: clean up declarations

A number of declarations in iwl-core.h should
be in agn specific files, and also rename the
iwl-calib.h file to iwl-agn-calib.h to better
reflect that it belongs to agn.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
7cb1b0887fcc61918e3d64827fbef968bb67a57a 06-Oct-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: reduce redundant parameter definitions

move paramater definitions to a device paramater structure only
leaving the device name, which antennas are used and what firmware
file to use in the iwl_cfg structure. this will not completely
remove the redundancies but greatly reduce them for devices that
only vary by name or antennas. the parameters that are more
likely to change within a given device family are left in iwl_cfg.
also separate bt param structure added to help reduce more.

Signed-off-by: Jay Sternberg <jay.e.sternberg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
54a9aa65f749673f851ef86481940394185c1b0e 05-Sep-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: keep track of failure tx status

Tx command response sent to host by uCode after completed
the transmission attempt. The status parameter indicates
whether the transmission was successful, or else why if failed.

Here we keep the counters to help understand the different failure
cases.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
2b18ab36cf7e956fb5b5ee12847e94fc66d496f4 06-Jul-2010 Arnd Bergmann <arnd@arndb.de> net/wireless: use generic_file_llseek in debugfs

The default llseek operation is changing from
default_llseek to no_llseek, so all code relying on
the current behaviour needs to make that explicit.

The wireless driver infrastructure and some of the drivers
make use of generated debugfs files, so they cannot
be converted by our script that automatically determines
the right operation.

All these files use debugfs and they typically rely
on simple_read_from_buffer, so the best llseek operation
here is generic_file_llseek.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
c6abdc0dc3440b9b6ae00a59c3560ab2160c7c7d 02-Sep-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: allow configure protection mode

Even driver use rts/cts protection mode for aggregation packets by default.
Allow the protection mode to be configure through debugfs

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
6e6ebf4befa75ebdf28130d0135f3ad3aadc02f8 27-Aug-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: remember the last uCode sysassert error code

When sysassert happen, uCode will report the error code,
driver dump the information to dmesg. Here also remember
the last error code for future reference.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
8dfdb9d5757424f7018a643258065c4fc8e6a439 23-Aug-2010 Johannes Berg <johannes.berg@intel.com> iwlwifi: move QoS into context

Since mac80211 doesn't currently enable/disable
QoS per interface, we can't yet do it properly,
but we can already prepare for it and move the
QoS data and command ID into the context struct.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
246ed355221076884d225f9d8a4c30a048be8162 23-Aug-2010 Johannes Berg <johannes.berg@intel.com> iwlwifi: initial contextification

In order to support multiple interfaces, we must move
a lot of data into per-context structures so we can
use the contexts the device offers. To start with,
this makes a lot of code context-aware, more changes
will move more things into the context structure.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
befe8c469baebe8a0fb5bd9b7cd4afd8c54ebbd5 23-Aug-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: add bt traffic load debugfs file

Add the debugfs file to show current bluetooth traffic load

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7bdc473c7a52497af9fe8c73e4745615a2825aaa 23-Aug-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: add debugfs to control stuck queue timer

In current implementation, stuck queue timer is fixed to 1 second. Add
debugfs file to modify the timer to enhance the flexibility:

Set the monitor_period as following:
0: disable stuck queue force reset function
1 - 60000: monitor period (1 - 60 second)

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
81e95430aaa898799421617c2db2882386bab69a 28-Jul-2010 Shanyu Zhao <shanyu.zhao@intel.com> iwlwifi: do not call ieee80211_frequency_to_channel

A few cases in iwlwifi driver function ieee80211_frequency_to_channel()
is called to get channel number from center frequency. This is not needed
since the channel number is already saved in hw_value field of struct
ieee80211_channel in function iwlcore_init_geos(). So replace those function
calls with hw_value field of struct ieee80211_channel.

Signed-off-by: Shanyu Zhao <shanyu.zhao@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
ffb7d896b3bc21e09d77fed45b52b2ff4ce213e5 14-Jul-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlagn: add bluetooth stats to debugfs

For WiFi/BT combo devices, add bluetooth statistics counter
read function to debugfs.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
57674308d00b5ebb639ce53d388e61728e0c7f72 12-Jul-2010 Joe Perches <joe@perches.com> drivers/net/wireless: Remove unnecessary casts of private_data

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4bf49a90bc0bda131ef353cca631025849f36b4e 24-Jun-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: debugfs file for txfifo command testing

Add debugfs file for REPLY_TXFIFO_FLUSH host command testing.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
c04f9f220300da83f71698fa7be24714152faf0d 22-Jun-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: fix fw_restart module parameter

fw_restart module parameter was broken by the recent check for stuck
queue patch, driver check the fx_restart module parameter
before reload the firmware; but the stuck queue timer kick in after
firmware error and reload the firmware even fw_restart=0. In this case,
driver should not reload the firmware, it is important to help debugging
uCode error.

The only case we can ignore the module parameter is when user request
firmware reload from debugfs, which can bypass the checking and perform
firmware reload all the time.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
680788aca3dcc24b932eb7a4219ab921ac5bf2d0 18-Jun-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: add a mechanism to disable plcp error checking

For some devices, especially the upcoming new devices, the plcp error
rate is different. Before the correct error rate can be determine, also
for the debugging purpose; add the mechanism to disable plcp error checking
which cause radio reset happen.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
f5cc6a224d9f41d963fa4cee35d3db2559e8015d 01-Jun-2010 Dor Shaish <dor.shaish@intel.com> iwlwifi: Fix null pointer referencing in iwl_dbgfs_rx_queue_read.

Test for null pointer prior to access.
Print "Not Allocated" if null pointer.

Signed-off-by: Dor Shaish <dor.shaish@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
da73511d4316c4e3efe903e123286c5b55a1999f 03-May-2010 Johannes Berg <johannes.berg@intel.com> iwlwifi: improve station debugfs

The stations debugfs entry doesn't even show
the stations' MAC addresses Also, the TID
information is formatted very oddly, and
misses the important tfds_in_queue variable.
Fix this to make the file more useful.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
1d60a79ed516edcc62c5f74e4223d21e10a5cc14 30-Apr-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: separate statistics flag function for agn & 3945

Since agn and 3945 have different statistics_notif data structure, each
should has its own statistics_flag function.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
a2064b7a4a22d118087898e4308670da7ac07911 30-Apr-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: move _agn statistics related structure

agn and 3945 has different statistics_notif data structure; since 3945
has it statistics_notif data structure inside the _3945 portion of
iwl_priv, it make sense to move the agn statistics_notif into _agn portion.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
470356b891f1d18e87d5fdc393976fab6d0a978d 30-Apr-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: "tx power per chain" are part of ucode_tx_stats

Move "tx power per chain" into ucode_tx_stats, it is debugging
information provided by uCode as part of statistics notification.

The "tx power per chain" parameters are optional parameters which only
supported by 6000 series device today; those are reserved fields for all
the other devices.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
0af0d04b8db7712498558541cbedeeebdbabf70f 27-Apr-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: give correct return information for tx power debugfs

Return -EAGAIN when request tx power information and uCode is not ready;
so it will not confuse with tx power information not available.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
65d1f89682acf4d61dec7a8b771ed34afb7c17d9 26-Apr-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: use cfg to configure calibration operation

sensitivity calibration and chain noise calibration are not available
for all the devices; use .cfg to configure the availability of those
calibration functions

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
6e5c800e75fad95f2a12d45d9b548b23834a13ff 27-Apr-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: use .cfg to enable/disable continuous ucode trace

Instead of checking device type for enable/disable continuous ucode
trace function; put it in .cfg for better control and more
flexibilities.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
4e7033ef491a8447247e77b20626cbc197a2eb83 27-Apr-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: remove device type checking for tx power in debugfs

Instead of checking device type for enable/disable tx power control,
move it to .cfg for better control and more flexibilities.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
683abfbefe95750f8aa47dc6d2a7ee41c01c14ad 27-Apr-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: rename "tx_power" to "chain_tx_power"

The "chain_tx_power" debugfs function is to display the tx power per
chain based. Name it "tx_power" is misleading.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
381733cc53ce7abf3d8498f8ccf7586546c0b264 25-Apr-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: remove powersave debugfs if it is not supported

For the devices do not have power save support, remove the power save
control related debugfs files.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
17f36fc6ef3d1ab15f9d2160a9daa107db0887ca 16-Apr-2010 Abhijeet Kolekar <abhijeet.kolekar@intel.com> iwl3945: add ucode statistics

Add general, rx and tx uCode statistics to 3945. This will help
in debugging

Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
b8c76267cfb9a025afdd122bc2a8942dbf493dd1 09-Apr-2010 Abhijeet Kolekar <abhijeet.kolekar@intel.com> iwlwifi: add debugfs ops to iwlwifi

Seperate debugfs functions into iwlagn specific
debugfs file and Add debugfs ops to iwlwifi.

Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
9856b7fa36a77d69e1413c63cb867514876796d2 23-Feb-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: remove duplicate function

"internal_scan" debugfs function serves the same propose of mode "0" of
"force_reset" debugfs function. Remove it to avoid duplicate.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
4967c31677cf3c6c49aadf205f1a31d15d7610da 19-Feb-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: remove un-necessary parameters

small code cleanup to remove un-necessary parameters

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
60987206cba0dbb547bce2d23c3a3338c5aaf5ac 18-Feb-2010 Johannes Berg <johannes.berg@intel.com> iwlagn: move sysfs flags and filter_flags files to debugfs

These files are incompatible with some changes
I'm making, and don't really belong into sysfs
anyway as they can only be used for debugging.
Since writing them will probably crash the
firmware, keep only the reading part and move
them into debugfs.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
b55e75ed926ded110293b0d1e24eb6a878883115 17-Feb-2010 Johannes Berg <johannes.berg@intel.com> iwlwifi: remove STATUS_MODE_PENDING

Since rfkill integration, mac80211 can no
longer add an interface while the hardware
is not ready, so STATUS_MODE_PENDING can
never be set.

Also, remove another superfluous channel
sanity check and return the commit_rxon
return value in case it failed.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
528c3126a98e75f47fc9fa11b243c82a59271d0d 19-Feb-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: add debugfs to monitor force reset parameters

Adding debugfs file to monitor the counters and other
information related to "force_reset" request.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d2dfe6df755abb365aa3e2e67d88bda3cce5fd12 19-Feb-2010 Reinette Chatre <reinette.chatre@intel.com> iwlwifi: enable serialization of synchronous commands

Until now it was only possible to have one synchronous command running at
any time. If a synchronous command is in progress when a second request
arrives then the second command will fail. Create a new mutex specific for
this purpose to only allow one synchronous command at a time, but enable
other commands to wait instead of fail if a synchronous command is in
progress.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
04cafd7fa74d5f70efc93bef36f118177057ff74 03-Feb-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: add debug function to reset/reload radio/firmware

Adding function to force reset radio or reload firmware from debugfs.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
d3a571971e5af241074947fc80f6284677f6e014 21-Jan-2010 Reinette Chatre <reinette.chatre@intel.com> iwlwifi: iwl_power_update_mode always hold mutex

iwl_power_update_mode expects to be called with mutex held, for example to
protect priv->vif. Only one caller currently does not do this, fix this.
Also, add a comment to iwl_power_update_mode to indicate this requirement.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
4c84a8f1679f754d6080e49892f5cae2c88c91a8 22-Jan-2010 Johannes Berg <johannes@sipsolutions.net> iwlwifi: clean up debugfs code

The debugfs code can be made a whole lot more
efficient by using debugfs_remove_recursive(),
the large chunk of variables can completely go
away and by moving two variables we no longer
need to allocate an extra chunk of memory.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3e4fb5faefb57824f2e42305b3d5907845af978c 22-Jan-2010 Trieu 'Andrew' Nguyen <trieux.t.nguyen@intel.com> iwlwifi: Tune radio to prevent unexpected behavior

We have seen the throughput dropped due to external noisy environment
and the radio is out of tune. There are lot of plcp errors indicating
this condition. Eventually the station can get de-authenticated by the
Access Point. By resetting and tuning the radio, the plcp errors are
reduced or eliminated and the throughput starts to rise.

To prevent unexpected behavior such as drop in throughput or deauthentication,
- The change provides the driver feature to monitor and tune the radio base on
the statistics notification from the uCode.
- It also allows the setting of the plcp error rate threshold via
the plcp_delta under debugfs interface.

Signed-off-by: Trieu 'Andrew' Nguyen <trieux.t.nguyen@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
afbdd69af0e6a0c40676d4d4b94a0a4414708eaa 22-Jan-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: add function to reset/tune radio if needed

Adding "radio reset" function to help reset and stabilize the radio.

During normal operation, sometime for unknown reason, radio encounter
problem and can not recover by itself; the best way to
recover from it is to reset and re-tune the radio. Currently, there is
no RF reset command available, but since radio will get reset when
switching channel, use internal hw scan request to force radio
reset and get back to normal operation state.

The internal hw scan will only perform passive scan on the first
available channel (not the channel being used) in associated state. The
request should be ignored if already performing scan operation or STA is
not in associated state.

Also include an "internal_scan" debugfs file to help trigger the
internal scan from user mode.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4 22-Jan-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: configure missed beacon threshold

Add support to configure missed beacon threshold, by default, if receive
"missed beacon" notification from uCode and has more than 5 consecutive
beacon missed, then perform sensitivity calibration; with this change,
allow user to adjust the missed beacon threshold from debugfs in case
more sensitivity calibration required for better performance in noisy
environment

The default value (=5) should be good enough for the normal condition,
but for very noisy environment, more sensitivity calibration could help
improve the throughput, so by setting the missed beacon threshold to
lower number, user might experience better performance result.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1f44780827c6bbbcd1f12d5c6b6ce84f49a96bc0 15-Jan-2010 Reinette Chatre <reinette.chatre@intel.com> iwlwifi: update copyright year to 2010

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4e9772b0a94c7d3a5f7062ba94afdbb9e692275d 15-Jan-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: remove extra statistics request from debugfs

When reading current ucode statistics information from debugfs, in
current implementation, it will always send a new "statistics request" to
uCode. In normal operation, uCode should report the statistics per beacon
interval. Remove this extra request to reduce the additional command exchanges
between driver and uCode.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1b3eb8236ad9369ae519216b61a3d22806370115 15-Jan-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: display flowhandler register when sw error or on-demand

Flowhandler handle the communication between driver and uCode, when any
uCode error happen, we also like to know what is the status of the
flowhandler; it can help to debug flowhandler related problem.

Also adding debugfs file to dump current value of flowhandler registers.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
937c397eb633b804d9a806d08c395ecfc42b1fec 15-Jan-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: correct return code for log_event

When dumping event log in debugfs, iwl_dump_nic_event_log()
should return the correct error code instead of let the calling
function makes it own assumption.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
11fc524941248dc717f1af5dfa844eceb7c0217f 15-Jan-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: add num_of_sos_stats to statistics counter

When uCode detects number of beacon missed consecutively above the
internal missed beacon threshold (set by uCode), it will reset and
re-tune the radio in order to get out of bad PHY state.

This "num_of_sos_states" counter monitors number of time uCode
encounters this bad condition and has to re-tune the radio.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e3ef2164386a13a37714ec033e30811d052c7999 15-Jan-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: format and show statistics counter from uCode

To help debug uCode related problem, adding "delta" and "max"
information in debugfs statistics counters display.

Those information show the delta between two statistics report from
uCode, user can monitor the counters for any "un-normal" behavior.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Jay Sternberg<jay.e.sternberg@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
28f63a4bb744ea81030219aba2337fddb10b380b 09-Jan-2010 H Hartley Sweeten <hartleys@visionengravers.com> iwl-debugfs.c: remove unnecessary casts of void *

void pointers do not need to be cast to other pointer types.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Acked-by: Zhu Yi <yi.zhu@intel.com>
Cc: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f0118a4575d45ce3074c830660de938bc6e17bda 08-Jan-2010 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: ucode statistics data structure update

Update data structure to match latest statistics report from uCode.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b03d7d0fd3d23b7cf130fa702f4ae3b1bc827d4b 14-Dec-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: on-screen event log dump

This feature enables the on-screen uCode event log dump. The original
method will append the event log to syslog; with this capability,
we also enable the user to write script to capture the
events which provide additional flexibility to help uCode debugging

Method
1) change to debugfs directory (sys/kernel/debug/phyX/iwlagn/data)
2) #cat log_event

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a9e1cb6a78ea8a74c49bf76726a2942f636a833b 10-Dec-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: add continuous uCode event log capability

In order to help uCode debugging, adding the capability to provide
continuous uCode event logging function.

uCode events is located in round-robin event queue and filled by uCode,
by enable continuous event logging, driver check the write pointer
and log the newly added events in iwl_bg_ucode_trace() timer function.

There is still possibility of missing events if event queue being
wrapped before next event dump; but with this capability, we can have
much better understanding of the uCode behavior during runtime; it can
help to debug the uCode related issues.

Methods to enable/disable the continuous event log:
step 1: enable ucode trace timer
"echo 1 >
/sys/kernel/debug/ieee80211/phyX/iwlagn/debug/ucode_tracing"
step 2: start ftrace
sudo ./trace-cmd record -e iwlwifi_ucode:* sleep 1d
step 3: stop ftrace
sudo ./trace-cmd report trace.dat
step 4: disable ucode trace timer
"echo 0 >
/sys/kernel/debug/ieee80211/phyX/iwlagn/debug/ucode_tracing"

use "ucode_tracing" debugfs file to display number of event
queue wrapped when driver attempt the continuous event logging. If event
queue being wrapped more than once when driver has opportunity to log
the event; it indicated there are events missing in the event log trace.

This continuous event log function only available for 4965 and newer
NICs.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
696bdee3ba216186e21997d20a839b76158346e6 10-Dec-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: dump "Control and Status Register" when detect uCode HW/SW error

When uCode HW/SW error detected, dumping important CSR (Control and Status
Registers) values.
Also add "csr" debugfs file to dump the current values of CSR defined in
CSR table to syslog.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c341ddb283b9e1a6d217e73fa36738629ca8f4fb 20-Nov-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: print limited number of event log when uCode error

To help iwlagn uCode debugging, event log will dump to syslog when driver
detect uCode error occurred, but this only happen when compile with
CONFIG_IWLWIFI_DEBUG and debug flag is enabled; which is not always
the case. Also, there is another problem, if the flag is set, the entire
event log buffer will be dump to syslog, it can flood the syslog and
make it very difficult to debug the problem.

Change the default to only dump last 20 entries of event log to syslog
unless the following condition meets:
1. both compile with CONFIG_IWLWIFI_DEBUG and debug flag
is enabled, and then dump the entire event buffer to syslog.
2. dump event log request from debugfs

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Acked-by: Ben Cahill <ben.m.cahill@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5ade1e4dd1df436c3a441d17321c24aac8497306 20-Nov-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: by default, dump entire sram data portion

For "sram" debugfs file, if user did not specify the offset and length,
dump the entire data portion of sram by default.
Data portion is 0x800000 - 0x80ffff, but the actual data size is known
to the driver from the ucode file.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2943f136ffe29adb08162197b129bf8106e8191c 20-Nov-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: dynamically allocate buffer for sram debugfs file

Dynamically allocate memory for dumping SRAM based on the length of memory
to be displayed.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d23db556819c00d297c0f447bdd75b282d563122 20-Nov-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: increase tx_queue debugfs buffer size

For tx_queue, need to increase the buffer size allocated for it,
so all the queues information can be displayed

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
43e851157adb966dd633e983b24040f72877737e 20-Nov-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: set read/write permission for debugfs files

Set the correct Read/Write file permission for iwlwifi debugfs files
based on the functionality of the files

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7163b8a4ec995dabda3e92c6fed7b8600060618c 20-Nov-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: reset led_tpt when clear tx/rx traffic byte counts

LED blink rate is based on the traffic load, when tx/rx traffic counts
got reset, we also need to reset the led_tpt to prevent incorrect
blink rate being calculated.

Merge both clear_tx_statistics() and clear_rx_statistics() into
single clear_traffic_statistics() function, when reset the traffic byte
counts, both tx and rx need to be reset at the same time, to make
sure calculated the correct led blink rate.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6ab10ff8738dfb098fd32132b7ebcf5cdb43ebde 13-Nov-2009 Johannes Berg <johannes@sipsolutions.net> iwlwifi: handle unicast PS buffering

Using the new mac80211 functionality, this makes
iwlwifi handle unicast PS buffering correctly.
The device works like this:

* when a station goes to sleep, the microcode notices
this and marks the station as asleep
* when the station is marked asleep, the microcode
refuses to transmit to the station and rejects all
frames queued to it with the failure status code
TX_STATUS_FAIL_DEST_PS (a previous patch handled
this correctly)
* when we need to send frames to the station _although_
it is asleep, we need to tell the ucode how many,
and this is asynchronous with sending so we cannot
just send the frames, we need to wait for all other
frames to be flushed, and then update the counter
before sending out the poll response frames. This
is handled partially in the driver and partially in
mac80211.

In order to do all this correctly, we need to
* keep track of how many frames are pending for each
associated client station (avoid doing it for other
stations to avoid the atomic ops)
* tell mac80211 that we driver-block the PS status
while there are still frames pending on the queues,
and once they are all rejected (due to the dest sta
being in PS) unblock mac80211

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
98a7b43be19faa7b92576c62614c45e38517331c 13-Nov-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: align tx/rx statistics debugfs format

Align the format for tx_statistics and rx_statistics debugfs output for
better readability

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ef8d5529b015d4c5db7fad1adfc91edfd5abad56 13-Nov-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: update reply_statistics_cmd with 'clear' parameter

When issue REPLY_STATISTICS_CMD to uCode, two possible flag
can be set in the configuration flags

bit 0: Clear statistics
0: Do not clear Statistics counters
1: Clear to zero Statistics counters

Allow "clear" parameter to be set from the caller.

Add debugfs file to clear the statistics counters to help monitor and
debug the uCode behavior.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4ad177b5c860dc0b1083eccc55957daf4a116b90 16-Oct-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: rework for static power save

For static power save, the actual intervals are calculated by driver based on
the default table and DTIM flag, then sent to uCode when the scheme
is changed.

Three tables are defined based on DTIM period.
1. DTIM 0 - 2
2. DTIM 3 - 10
3. DTIM > 11

The actual number of DTIM a station may miss may not exceed the
following:
. Only 1 DTIM may be skipped at PI=4 when allowed
. Only 2 DTIMs may be skipped at PI=5 when allowed
. DTIM may be skipped only 5 sec after last activity
. DTIM may be skipped only 30 sec after connection establishment

Only allow user to override the power_level when rf is ready to make sure
power level gets changed upon request.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c09430abed4159e5c56aaea257d040f7452daba6 16-Oct-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: show current power save status reported by uCode

Power save request is sent from driver to uCode, but there is no
indication from uCode about the current device power save state.

Reading GP_CNTRL register bit 25:24 to show the current power save
status

00: no power save
01: MAC power down
10: PHY power down
11: Error

The uCode could switch in and out of power save mode in the order of
once per 100-300 ms in many cases. The reading here should just be used for
reference on the current uCode power save status. Do not confuse this
reading with the PowerSave set by driver and mac80211.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
92a35bda792cf9295b1d399f7c937d4560292b1e 09-Oct-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: showing accumulative ucode statistics counters

Adding accumulative statistics counters in iwlwifi driver.
Statistics counters are reported by uCode every beacon interval; but can
be reset by uCode when needed. The accumulative statistics counters is
maintained by driver to keep track of the history of all the counters.

Update the ucode stats files in debugfs to display both latest and
accumulative counters.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
88804e2b33b6ab3974ff2330cd045ca53d6750c5 09-Oct-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: dynamic allocate tx queue structure

Instead of always allocate the max number of tx queue structure,
use dynamic allocation based on the number of queues in device
configuration. With these changes, device does not have to allocate more
memory than the h/w can support.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1a34c043802a213e719420ece395cf25c85cc7c5 09-Oct-2009 Reinette Chatre <reinette.chatre@intel.com> iwlwifi: fix userspace setting of sleep_level_override

The sleep_level_override debugfs file is used by the user to request a
static power index instead of the dynamic sleep values. Users are expected
to provide value from 1 to 5 as an index or -1 to disable it.

The problem at the moment is that users can also provide 0 to this file
which, together with the value 1, is translated to index 1. This is
confusing and even more so when users write 0 to sleep_level_override and
then read 1 from it afterwards.

Modify checking to treat 0 as invalid.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e932a609e9759cc75db0c234f465a5fd6e20d362 02-Oct-2009 Johannes Berg <johannes@sipsolutions.net> iwlwifi: LED cleanup

The iwlwifi drivers have LED blinking requirements that
mac80211 cannot fulfill due to the use of just a single
LED instead of different ones for TX, RX, radio etc.
Instead, the single LED blinks according to transfers
and is solid on the rest of the time. As such, having
LED class devices registered that mac80211 triggers are
connected to is pointless as we don't use the triggers
anyway.

Remove all the useless code and add hooks into the
driver itself. At the same time, make the LED code
abstracted so the core code that determines blink rate
etc. can be shared between 3945 and agn in iwlcore.

At the same time, the fact that we removed the use of
the mac80211 LED triggers means we can also remove the
IWLWIFI_LEDS Kconfig symbol since the LED support is
now self-contained.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7812b16730ccebce71a3b2228ac08dd4f8b39469 02-Oct-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: reliable entering of critical temperature state

When uCode detects critical temperature it should send "card state
notification" interrupt to driver and then shut itself down to prevent
overheating. There is a race condition where uCode shuts down before it
can deliver the interrupt to driver.
Additional method provided here for driver to enter CT_KILL state based
on temperature reading.

How it works:
Method 1:
If driver receive "card state notification" interrupt from uCode; it
enters "CT_KILL" state immediately

Method 2:
If the last temperature report by Card reach Critical temperature,
driver will send "statistic notification" request to uCode to verify the
temperature reading, if driver can not get reply from uCode within
300ms, driver will enter CT_KILL state automatically.

Method 3:
If the last temperature report by Card did not reach Critical
temperature, but uCode already shut down due to critical temperature.
All the host commands send to uCode will not get process by uCode;
when command queue reach the limit, driver will check the last reported
temperature reading, if it is within pre-defined margin, enter "CT_KILL"
state immediately. In this case, when uCode ready to exit from "CT_KILL" state,
driver need to restart the adapter in order to reset all the queues and
resume normal operation.

One additional issue being address here, when system is in CT_KILL
state, both tx and rx already stopped, but driver still can send host
command to uCode, it will flood the command queue since card was not
responding; adding STATUS_CT_KILL flag to reject enqueue host commands
to uCode if it is in CT_KILL state, when uCode is ready to come out of
CT_KILL, driver will clear the STATUS_CT_KILL bit and allow enqueue the host
commands to uCode to recover from CT_KILL state.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e307ddce394ee7bcec41fb74330ac89eafaea1d9 11-Sep-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: show NVM version in debugfs

Show version number along with dumping NVM data, the version information
being removed from sysfs, add it back to debugfs to help debugging.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b7a794048ff30d53764c1e41ccb2bff7f7bec2a8 25-Sep-2009 Reinette Chatre <reinette.chatre@intel.com> iwlwifi: fix 3945 ucode info retrieval after failure

When hardware or uCode problem occurs driver captures significant
information from device to enable debugging. The format of this information
is different between 3945 and 4965 and later devices, yet currently the
3945 uses the 4965 and later format. Fix this by adding a new library call
that is initialized to the correct formatting routine based on device.

This moves the iwlagn event and error log handling back to iwl-agn.c to
make it part of iwlagn module.

Also remove the 3945 sysfs file that triggers dump of event log - there is
already a debugfs file that can do it for all drivers.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2fac9717a05fc4b4824422d2c439c1260807c110 25-Sep-2009 Reinette Chatre <reinette.chatre@intel.com> iwlwifi: fix debugfs buffer handling

We keep track of where to write into a buffer by keeping a count of how
much has been written so far. When writing to the buffer we thus take the
buffer pointer and adding the count of what has been written so far.
Keeping track of what has been written so far is done by incrementing
this number every time something is written to the buffer with how much has
been written at that time.

Currently this number is incremented incorrectly when using the
"hex_dump_to_buffer" call to add data to the buffer. Fix this by only
adding what has been added to the buffer in that call instead of what has
been added since beginning of buffer.

Issue was discovered and discussed during testing of
https://bugzilla.redhat.com/show_bug.cgi?id=464598 .

When a user views any of these files they will see something like:

[ 179.355202] ------------[ cut here ]------------
[ 179.355209] WARNING: at ../lib/vsprintf.c:989 vsnprintf+0x5ec/0x5f0()
[ 179.355212] Hardware name: VGN-Z540N
[ 179.355213] Modules linked in: i915 drm i2c_algo_bit i2c_core ipv6 acpi_cpufreq cpufreq_userspace cpufreq_powersave cpufreq_ondemand cpufreq_conservative cpufreq_stats freq_table container sbs sbshc arc4 ecb iwlagn iwlcore joydev led_class mac80211 af_packet pcmcia psmouse sony_laptop cfg80211 iTCO_wdt iTCO_vendor_support pcspkr serio_raw rfkill intel_agp video output tpm_infineon tpm tpm_bios button battery yenta_socket rsrc_nonstatic pcmcia_core processor ac evdev ext3 jbd mbcache sr_mod sg cdrom sd_mod ahci libata scsi_mod ehci_hcd uhci_hcd usbcore thermal fan thermal_sys
[ 179.355262] Pid: 5449, comm: cat Not tainted 2.6.31-wl-54419-ge881071 #62
[ 179.355264] Call Trace:
[ 179.355267] [<ffffffff811ad14c>] ? vsnprintf+0x5ec/0x5f0
[ 179.355271] [<ffffffff81041348>] warn_slowpath_common+0x78/0xd0
[ 179.355275] [<ffffffff810413af>] warn_slowpath_null+0xf/0x20
[ 179.355277] [<ffffffff811ad14c>] vsnprintf+0x5ec/0x5f0
[ 179.355280] [<ffffffff811ad23d>] ? scnprintf+0x5d/0x80
[ 179.355283] [<ffffffff811ad23d>] scnprintf+0x5d/0x80
[ 179.355286] [<ffffffff811aed29>] ? hex_dump_to_buffer+0x189/0x340
[ 179.355290] [<ffffffff810e91d7>] ? __kmalloc+0x207/0x260
[ 179.355303] [<ffffffffa02a02f8>] iwl_dbgfs_nvm_read+0xe8/0x220 [iwlcore]
[ 179.355306] [<ffffffff811a9b62>] ? __up_read+0x92/0xb0
[ 179.355310] [<ffffffff810f0988>] vfs_read+0xc8/0x1a0
[ 179.355313] [<ffffffff810f0b50>] sys_read+0x50/0x90
[ 179.355316] [<ffffffff8100bd6b>] system_call_fastpath+0x16/0x1b
[ 179.355319] ---[ end trace 2383d0d5e0752ca0 ]---

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f204b2487e5503ca4a9f3e69dcd63f6af979aaac 21-Aug-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: show current tx power

debugFs file show current tx power for all the transmit chains

Adding "tx_power" file in /sys/kernal/debug/ieee80211/phy0/iwlagn/debug
to display current tx power for all the active chains in 1/2 dB step.

Show tx power information "Not available" if uCode can not provide the
information or interface is down.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0a 08-Aug-2009 Johannes Berg <johannes@sipsolutions.net> iwlwifi: automatically adjust sleep level

Depending on required latency requested by pm_qos (via mac80211)
we can automatically adjust the sleep state. Also, mac80211 has
a user-visible dynamic sleep feature where we are supposed to
stay awake after sending/receiving frames to better receive
response frames to our packets, this can be integrated into the
sleep command.

Currently, and this patch doesn't change that yet, we default
to using sleep level 1 if PS is enabled. With a module parameter
to iwlcore, automatic adjustment to changing network latency
requirements can be enabled -- this isn't yet the default due
to requiring more testing.

The goal is to enable automatic adjustment and then go into the
deepest possible sleep state possible depending on the networking
latency requirements.

This patch does, however, enable IEEE80211_HW_SUPPORTS_DYNAMIC_PS
to avoid the double-timer (one in software and one in the device)
when transmitting -- the exact timeout may be ignored but that is
not of big concern.

Note also that we keep the hard-coded power indices around for
thermal throttling -- the specification of that calls for using
the specified power levels. Those can also be selected in debugfs
to allow easier testing of such parameters.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3ad3b92a5517c043ef30e4b95c4c39a35bbc36be 08-Aug-2009 Johannes Berg <johannes@sipsolutions.net> iwlwifi: refactor some thermal throttle code

Some of the thermal throttle data structures and code
are really very intermingled with the sleep (power)
control code. They really do belong together in a way
since the thermal throttle code uses powersaving to
achieve its goal, but it's making it hard to work on
the powersave code. Split this up to make that easier.
I've also changed the antenna defines to an enum and
used the same enum for RX and TX.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5225935b53ce1eafb222c644230d03ad6011d357 08-Aug-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: Display sensitivity and chain noise information

Display sensitivity and chain noise data to help understand the current
environment and RF condition.

The data is feeded by statistics notification and Beacon from uCode;
then used by sensitivity calibration and chain noise calibration to
determine how DSP should react to the environment changes

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e8fe59aecb9020b06305be4f8c67d73cbf49cbd2 08-Aug-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: uCode statistics notification counter

Display statistics notification information
The information break down into
uCode_tx_stats
uCode_rx_stats
uCode_general_stats
and can be found in /sys/kernel/debug/ieee80211/phy0/iwlagn/debug
directory

The statistic information display in debugFs is based on the last
statistics notification from uCode; it might not reflect the current
uCode activity. Using "watch" command to monitor the uCode
activity should give up-to-date statistics provided by uCode.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
141b03e07a54af68fc099459bf780a182b240b45 08-Aug-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: tx/rx queue pointer information

Adding debugfs function to show current TxFifo/RxFifo read/write
pointer, plus the current tx queue status (wake/stop) for both real and
virtual queue.
This is part of debug feature set to help debugging driver/uCode.

use tx_queue and rx_queue in
/sys/kernel/debug/ieee80211/phy0/iwlagn/debug directory to show the
current read/write pointer for both TxFifo and RxFifo queue

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
22fdf3c9e19dce6d66bcfdbed547a5aa52b89933 08-Aug-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: Traffic type and counter for debugFs

Break down the traffic type and counter for both Tx and Rx.
Enhance the tx_statistics and rx_statistics debugfs function and move
to /sys/kernel/debug/ieee80211/phy0/iwlagn/debug directory to help
better debugging both driver and uCode related problems.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
20594eb0daa67f7a0cc19d74a1bafceb1bb09f4a 08-Aug-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: new debugging feature for dumping data traffic

The traffic buffer will only beallocated and used if either bit 23
(IWL_DX_TX) or bit 24 (IWL_DL_RX) of "debug" is set;
example: "debug=0x800000" - log tx data traffic
"debug=0x1000000" - log rx data traffic
"debug=0x1800000" - log both tx and rx traffic

The traffic log will store the beginning portion (64 bytes) of the
latest 256 of tx and rx packets in the round-robbin buffer for
debugging,
user can examine the log through debugfs file.

How to display the current logged tx/rx traffic and txfifo and rxfifo
read/write point:
"cat traffic_log" in /sys/kernel/debug/ieee80211/phy0/iwlagn/debug
directory

By echo "0" to traffic_log file will empty the traffic log buffer and
reset both tx and rx taffic log index to 0.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c37457e69ffd7d3c94cbfcc1c39be9a45dd7ad21 03-Aug-2009 Julia Lawall <julia@diku.dk> drivers/net/wireless/iwlwifi: introduce missing kfree

Move orthogonal error handling code up before a kzalloc, so that it
doesn't have to free the allocated data.

The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
statement S;
expression E;
identifier f,f1,l;
position p1,p2;
expression *ptr != NULL;
@@

x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
when != if (...) { <+...x...+> }
(
x->f1 = E
|
(x->f1 == NULL || ...)
|
f(...,x->f1,...)
)
...>
(
return \(0\|<+...x...+>\|ptr\);
|
return@p2 ...;
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1e4247d457c6a42e4a05cb7dfa4e6ea1fa65c112 27-Jul-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: debugFs to enable/disable HT40 support

Add debugfs file to enable/disable HT40(40MHz) channel support.
By default, 40MHz is supported if AP can support the function.

By echo "1" to "disable_ht40" file, iwlwifi driver will disable the
40MHz support and only allow 20MHz channel.

Because the information exchange happen during association time,
so enable/disable ht40 channel only can be performed when it is not
associated with AP.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fbf3a2af3834e8e93e9c2876de62c5b49988e352 24-Jul-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: Thermal Throttling debugfs function

Add debugfs function to display current thermal throttling status for
both Legacy and Advance Thermal Throttling Management

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a283c0116b0cc5e82327e50ad4d05f6d4d42c603 17-Jul-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: add led debugfs function

Adding debugfs file to show current led blinking rate
/sys/kernel/debug/ieee80211/phy0/iwlagn/data/led

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fcf89d05404dafcde581d44dfa89bd8c8def27f9 09-Jul-2009 Reinette Chatre <reinette.chatre@intel.com> iwlwifi: fix permissions on debugfs files

debugfs files are created with 644 permissions which gives everybody
read access. This presents a security issue if a user opens the file and
holds it open at the time the driver removes the file. At this point
invalid memory will be accessed.

Fix this by only allowing root to read debugfs files.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f5ad69fa47e7b204d0032d569812544cd9a351fb 09-Jul-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: move show_qos to debugfs

This move the show_qos file from sysfs to debugfs because the "one
value per file" sysfs rule.

The file is located in
/sys/kernel/debug/ieee80211/phy0/iwlagn/data

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
030b865520c3e26f4a316852aa022a22c4948907 12-Jun-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: remove disable_tx_power for device > 4965

After 4965, tx_power_calibration moved from driver to uCode.
remove "disable_tx_power" from debugfs to minimize the confusion.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a60e77e5a41330334fd0ca428f18919d1ea6ed62 04-Jun-2009 Johannes Berg <johannes@sipsolutions.net> iwlwifi: port to cfg80211 rfkill

This ports the iwlwifi rfkill code to the new API offered by
cfg80211 and thus removes a lot of useless stuff. The soft-
rfkill is completely removed since that is now handled by
setting the interfaces down.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Tested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a2e2322d83df82a57ba456cfa604c8b8f7b04670 22-May-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: check for valid band for channel info

when display channel info in debugfs, always check for valid band
before access the pointer and display information

for 1000 NIC, it only support "bgn" mode, so there is no 5.2GHz channels
available to display.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a8b50a0a966d7ac313f624c6ab4996231a5fe25a 22-May-2009 Mohamed Abbas <mohamed.abbas@intel.com> iwlcore: register locks

Add new lock to be used when accessing some registers. Also move
the register lock and iwl_grab_nic_access inside the function for register access. This
will prevent from forgetting to hold locks and nic access in the right way and make code
easier to maintain.

We over use the priv->lock spin lock and I guess we need to add new
one for Tx queue after that we might need to change most of these lock to
BH and just keep priv->lock as irq type.

Signed-off-by: Mohamed Abbas <mohamed.abbas@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0848e297c2107dbc12a91a1709c879c73bd188d8 22-May-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: support NVM access (EEPROM/OTP)

Two type of NVM available for devices 1000, 6000 and after, adding
support to read OTP lower blocks if OTP is used instead of EEPROM.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a83b9141b540f96dd59409c6487828e880113a29 08-Apr-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: adding interrupt counter in debugfs for debugging

This patch adds interrupt statistics report to debugfs, this can help to
understand number of interrupts happened which including HW/SW error for
easier and better debugging.

in /sys/kernel/debug/ieee80211/phyN/iwlagn/data directory
use "cat interrupt" to view the current interrupt counter
use "echo 0 > interrupt" to clear interrupt counter

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1620108910b07bc41f4ad462ca56e899faf7e61a 08-Apr-2009 Mohamed Abbas <mohamed.abbas@intel.com> iwlcore: fix channel display in debugfs

Fix displaying of wrong channel information when user query
channel through debugfs

Signed-off-by: Mohamed Abbas <mohamed.abbas@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6da3a13e4fcab0ff58592087d28bd283caf23d88 26-Mar-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: merge and better support of suspend/resume for iwlagn and iwl3945

With mac80211's help to call stop() and start() in mac80211
suspend/resume function, both iwlagn and iwl3945 no longer calling
stop() and start(); remove un-necessary STATUS_IN_SUSPEND bit from both
header files and functions,

Move apm_ops.stop() function into pci_suspend() to ensure
DMA is stopped before go into suspend mode.

iwl3945 has the similar suspend/resume function as iwlagn, so move both
functions to iwlcore to be shared by both drivers.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
08df05aa9b25f3079585855506022bb33a011183 24-Mar-2009 Wey-Yi Guy <wey-yi.w.guy@intel.com> iwlwifi: show current driver status in user readable format

change the display of current driver status bit to user readable format
for better and easier debugging

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
01f8162a854df7f9c259c839ad3c1168ac13b7b8 08-Jan-2009 Reinette Chatre <reinette.chatre@intel.com> iwlwifi: update copyright year to 2009

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
15b1687cb4f45b87ddbe4dfc7759ff5bb69497d2 19-Dec-2008 Winkler, Tomas <tomas.winkler@intel.com> iwlwifi: replace IWL_ERROR with IWL_ERR

IWL_ERR doesn't use hidden priv pointer.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
978785a3892b34448446e8c8a17f48454f1bdd6a 19-Dec-2008 Tomas Winkler <tomas.winkler@intel.com> iwlwifi: clean up printing

Use IWL_ macros where possible to unify debug output usage.
Define new unconditional printouts IWL_ERR, IWL_WARN, IWL_INFO,
and IWL_CRIT which don't use hidden priv pointer.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2ddfa129bbf3dca708ffb0eb29d08de32cacd547 22-Dec-2008 Winkler, Tomas <tomas.winkler@intel.com> iwlwifi: move sysfs status entry to debugfs

This patch moves priv->status sysfs entry to debugfs. It is for
debugging only anyway.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
759ef89fb096c4a6ef078d3cfd5682ac037bd789 09-Dec-2008 Winkler, Tomas <tomas.winkler@intel.com> iwlwifi: change email contact information

This patch replaces personal emails with hopefully
always valid Intel Linux Wireless, which will be routed
to a current maintainer

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>
d366df5abb8d5ce7e2c36d3b678177787ccd9749 02-Dec-2008 Winkler, Tomas <tomas.winkler@intel.com> iwlwifi: move channels sysfs to debugfs

This patch moves channels info display from sysfs to debugfs.
This shows channel information as stored in NIC EEPROM. This
is useful in debugging CRDA or iwl goes setting so it belongs
rather to debugfs then to sysfs.

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>
9b24001db145cf1da76a479918373c18aa10bb4b 22-Oct-2008 Zhaolei <zhaolei@cn.fujitsu.com> Fix debugfs_create_bool's error checking method for wireless/iwlwifi/

debugfs_create_bool() returns NULL if an error occurs, returns -ENODEV
when debugfs is not enabled in the kernel.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e174961ca1a0b28f7abf0be47973ad57cb74e5f0 27-Oct-2008 Johannes Berg <johannes@sipsolutions.net> net: convert print_mac to %pM

This converts pretty much everything to print_mac. There were
a few things that had conflicts which I have just dropped for
now, no harm done.

I've built an allyesconfig with this and looked at the files
that weren't built very carefully, but it's a huge patch.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
3ac7f14694dd38273d9d96f1c873233d71190c15 21-Jul-2008 Tomas Winkler <tomas.winkler@intel.com> iwlwifi: fix checkpatch.pl errors

This patch fixes errors reported by checkpatch in iwlwifi drivers

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
203566f359b5702be72238a8b1d37655c986cc7c 12-Jun-2008 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlwifi: add possibility to disable tx_power calibration

This patch adds the possibility to disable the tx_power calibration.
In 5000 HW, this calibration is implemented in uCode, hence, it is
disabled in driver by default.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
16e727e866d739d7f02790c794410f6d9f1d720b 12-Jun-2008 Emmanuel Grumbach <emmanuel.grumbach@intel.com> iwlwifi: removes the RUN_TIME_CALIB ifdef

This patch removes the possibility not to compile the run time
calibrations. It also renames priv->sensitivity_work to
priv->run_time_calib_work, and moves bg_run_time_calib to iwl4965_base
since it is common to both: 4965 and 5000.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4f85f5b39208e755a93f63296ec1224d14121b6c 09-Jun-2008 Ron Rindjunsky <ron.rindjunsky@intel.com> iwlwifi: removing IWL4965_HT config

This patch removes CONFIG_IWL4965_HT #ifdefs for iwl 4965 and 5000. 11n
feature is stable in those drivers and its mode of operation is determined
in mac80211, so this dependency is not needed any more.

Signed-off-by: Ron Rindjunsky <ron.rindjunsky@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
95b1a8224abf6230899856753c5506a3f737a65b 29-May-2008 Zhu Yi <yi.zhu@intel.com> iwlwifi: create drivers debugfs dir under wiphy->debugfsdir

This patch creates driver's debugfs tree under wiphy->debugfsdir.
This patch fixes collision in debugfs if two or more NICs are plugged.

Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
189a2b5942d62bd18e1e01772c4c784253f5dd16 15-May-2008 Ester Kummer <ester.kummer@intel.com> iwlwifi: trigger event log from debugfs

This patch adds a trigger for event log printing to debugfs.
It removes the triger from sysfs.

Signed-off-by: Ester Kummer <ester.kummer@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
445c2dff409ef9de5d2f964d20917ab238fd266f 15-May-2008 Tomas Winkler <tomas.winkler@intel.com> iwlwifi: add debugfs to disable/enable run time calibration

This patch adds functionality to debugfs to enable or disable chain
noise or sensitivity calibrations.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8dd266ef4eb51d034fa1c5f9307a9ff07547d8e6 05-May-2008 Tomas Winkler <tomas.winkler@intel.com> iwlwifi: debugfs EEPROM dump

This patch adds EEPROM dump in debugfs.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6def9761f72501e638e79eebcd70afea12a3a93d 05-May-2008 Tomas Winkler <tomas.winkler@intel.com> iwlwifi: remove 4965 from station_entry

This patch removes 4965 mark form the station entry structure.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3e0d4cb12f6fd97193a455b49125398b2231c87c 24-Apr-2008 Tomas Winkler <tomas.winkler@intel.com> iwlwifi: rename iwl-4965.h to iwl-dev.h

This patch renames iwl-4965.h to iwl-dev.h

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
344234de54891ed15bf8127e4640ff9238076d6c 20-Apr-2008 David S. Miller <davem@davemloft.net> iwlwifi: Fix unconditional access to station->tidp[].agg.

Reportred by Ingo Molnar:

drivers/net/wireless/iwlwifi/iwl-debugfs.c: In function 'iwl_dbgfs_stations_read':
drivers/net/wireless/iwlwifi/iwl-debugfs.c:256: error: 'struct iwl4965_tid_data' has no member named 'agg'

Needs CONFIG_IWL4965_HT protection.

Signed-off-by: David S. Miller <davem@davemloft.net>
5425e490471d521bae2fce16d22995803b41d90f 16-Apr-2008 Tomas Winkler <tomas.winkler@intel.com> iwlwifi: hw_setting cleanup

1. This patch renames hw_setting to hw_params
2. Align names of the structure and variables
3. set_hw_params is called from libs_ops

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>
db0589f3b9443f2b57ea6daaec09c1ab0ac99cb0 15-Apr-2008 Abhijeet Kolekar <abhijeet.kolekar@intel.com> iwlwifi: replace sprintf with scnprintf for debugfs output

The buffersize allocated is not accurate.
Writing to these buffers with scnprintf is safer.

Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fee1247a30e5b3d48fe985b4a935eb6818f3b464 04-Apr-2008 Tomas Winkler <tomas.winkler@intel.com> iwlwifi: move driver status inliners into iwl-core.h

This patch moves inline functions into iwl-core.h

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>
16788599a9601cbba6ad7b58b3b52227ea59c013 02-Apr-2008 John W. Linville <linville@tuxdriver.com> drivers/net/wireless/iwlwifi/iwl-debugfs.c: fix another '%llu' warning

drivers/net/wireless/iwlwifi/iwl-debugfs.c: In function ‘iwl_dbgfs_stations_read’:
drivers/net/wireless/iwlwifi/iwl-debugfs.c:247: warning: format ‘%llu’ expects type ‘long long unsigned int’, but argument 4 has type ‘u64’

Cc: Reinette Chatre <reinette.chatre@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3395f6e9cf48469d7ee05703cad1502002741c16 26-Mar-2008 Tomas Winkler <tomas.winkler@intel.com> iwlwifi: rename iwl-4965-io.h to iwl-io.h

This patch renames iwl-4965-io.h back to iw-io.h
it also remove 4965 from all functions it supplies

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>
712b6cf57a53da608a682b5f782c5785bda76001 13-Mar-2008 Tomas Winkler <tomas.winkler@intel.com> iwlwifi: Add debugfs to iwl core

This patch adds debugfs support to iwl core
currently only iwl4965 is supported

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>