From e95a6f0df25d5edcbe162b1f0ca5a46447e482e7 Mon Sep 17 00:00:00 2001 From: Ben Cahill Date: Thu, 16 Aug 2007 14:49:16 -0700 Subject: [PATCH 07/31] iwlwifi: add struct iwl_card_state_cmd as documentation Add struct iwl_card_state_cmd as documentation. Also add comments, especially for statistics and LEDs. Signed-off-by: Ben Cahill Signed-off-by: Zhu Yi --- drivers/net/wireless/iwl-commands.h | 198 +++++++++++++++++++++++++---------- 1 files changed, 143 insertions(+), 55 deletions(-) diff --git a/drivers/net/wireless/iwl-commands.h b/drivers/net/wireless/iwl-commands.h index 93aab74..7f39b03 100644 --- a/drivers/net/wireless/iwl-commands.h +++ b/drivers/net/wireless/iwl-commands.h @@ -68,7 +68,7 @@ enum { REPLY_ALIVE = 0x1, REPLY_ERROR = 0x2, - /* RXON state commands */ + /* RXON and QOS commands */ REPLY_RXON = 0x10, REPLY_RXON_ASSOC = 0x11, REPLY_QOS_PARAM = 0x13, @@ -76,29 +76,27 @@ enum { /* Multi-Station support */ REPLY_ADD_STA = 0x18, - REPLY_REMOVE_STA = 0x19, - REPLY_REMOVE_ALL_STA = 0x1a, + REPLY_REMOVE_STA = 0x19, /* not used */ + REPLY_REMOVE_ALL_STA = 0x1a, /* not used */ - /* RX, TX */ + /* RX, TX, LEDs */ #if IWL == 3945 - REPLY_3945_RX = 0x1b, + REPLY_3945_RX = 0x1b, /* 3945 only */ #endif REPLY_TX = 0x1c, - - /* MISC commands */ - REPLY_RATE_SCALE = 0x47, + REPLY_RATE_SCALE = 0x47, /* 3945 only */ REPLY_LEDS_CMD = 0x48, - REPLY_TX_LINK_QUALITY_CMD = 0x4e, + REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* 4965 only */ /* 802.11h related */ - RADAR_NOTIFICATION = 0x70, - REPLY_QUIET_CMD = 0x71, + RADAR_NOTIFICATION = 0x70, /* not used */ + REPLY_QUIET_CMD = 0x71, /* not used */ REPLY_CHANNEL_SWITCH = 0x72, CHANNEL_SWITCH_NOTIFICATION = 0x73, REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74, SPECTRUM_MEASURE_NOTIFICATION = 0x75, - /* Power Management *** */ + /* Power Management */ POWER_TABLE_CMD = 0x77, PM_SLEEP_NOTIFICATION = 0x7A, PM_DEBUG_STATISTIC_NOTIFIC = 0x7B, @@ -106,7 +104,6 @@ enum { /* Scan commands and notifications */ REPLY_SCAN_CMD = 0x80, REPLY_SCAN_ABORT_CMD = 0x81, - SCAN_START_NOTIFICATION = 0x82, SCAN_RESULTS_NOTIFICATION = 0x83, SCAN_COMPLETE_NOTIFICATION = 0x84, @@ -114,18 +111,21 @@ enum { /* IBSS/AP commands */ BEACON_NOTIFICATION = 0x90, REPLY_TX_BEACON = 0x91, - WHO_IS_AWAKE_NOTIFICATION = 0x94, + WHO_IS_AWAKE_NOTIFICATION = 0x94, /* not used */ - QUIET_NOTIFICATION = 0x96, + /* Miscellaneous commands */ + QUIET_NOTIFICATION = 0x96, /* not used */ REPLY_TX_PWR_TABLE_CMD = 0x97, - MEASURE_ABORT_NOTIFICATION = 0x99, + MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */ /* BT config command */ REPLY_BT_CONFIG = 0x9b, + + /* 4965 Statistics */ REPLY_STATISTICS_CMD = 0x9c, STATISTICS_NOTIFICATION = 0x9d, - /* RF-KILL commands and notifications *** */ + /* RF-KILL commands and notifications */ REPLY_CARD_STATE_CMD = 0xa0, CARD_STATE_NOTIFICATION = 0xa1, @@ -178,7 +178,6 @@ struct iwl_cmd_header { * *****************************************************************************/ - #define UCODE_VALID_OK __constant_cpu_to_le32(0x1) #define INITIALIZE_SUBTYPE (9) @@ -360,7 +359,19 @@ struct iwl_rxon_time_cmd { __le16 reserved; } __attribute__ ((packed)); -#if IWL == 4965 +struct iwl_tx_power { + u8 tx_gain; /* gain for analog radio */ + u8 dsp_atten; /* gain for DSP */ +} __attribute__ ((packed)); + +#if IWL == 3945 +struct iwl_power_per_rate { + u8 rate; /* plcp */ + struct iwl_tx_power tpc; + u8 reserved; +} __attribute__ ((packed)); + +#elif IWL == 4965 #define POWER_TABLE_NUM_ENTRIES 33 #define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32 #define POWER_TABLE_CCK_ENTRY 32 @@ -371,10 +382,10 @@ struct tx_power_dual_stream { struct iwl_tx_power_db { struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES]; } __attribute__ ((packed)); +#endif /* - * REPLY_CHANNEL_SWITCH = 0x72, - * 4965 + * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response) */ struct iwl_channel_switch_cmd { u8 band; @@ -383,18 +394,20 @@ struct iwl_channel_switch_cmd { __le32 rxon_flags; __le32 rxon_filter_flags; __le32 switch_time; +#if IWL == 3945 + struct iwl_power_per_rate power[IWL_MAX_RATES]; +#elif IWL == 4965 struct iwl_tx_power_db tx_power; -} __attribute__ ((packed)); #endif +} __attribute__ ((packed)); /* - * CHANNEL_SWITCH_NOTIFICATION = 0x73, - * 3945 and 4965 + * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command) */ -struct iwl_channel_switch_notif { +struct iwl_csa_notification { __le16 band; __le16 channel; - __le32 status; + __le32 status; /* 0 - OK, 1 - fail */ } __attribute__ ((packed)); /****************************************************************************** @@ -863,18 +876,7 @@ struct iwl_tx_resp { } __attribute__ ((packed)); #endif -struct iwl_tx_power { - u8 tx_gain; /* gain for analog radio */ - u8 dsp_atten; /* gain for DSP */ -} __attribute__ ((packed)); - #if IWL == 3945 -struct iwl_power_per_rate { - u8 rate; /* plcp */ - struct iwl_tx_power tpc; - u8 reserved; -} __attribute__ ((packed)); - /* * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response) * 3945 Tx Power Table Command @@ -911,6 +913,8 @@ struct iwl_rate_scaling_info { /** * struct iwl_rate_scaling_cmd - Rate Scaling Command & Response * + * REPLY_RATE_SCALE = 0x47 (command, has simple generic response) + * * NOTE: The table of rates passed to the uCode via the * RATE_SCALE command sets up the corresponding order of * rates used for all related commands, including rate @@ -954,6 +958,9 @@ struct iwl_link_qual_agg_params { __le32 reserved; } __attribute__ ((packed)); +/* + * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) + */ struct iwl_link_quality_cmd { u8 sta_id; u8 reserved1; @@ -967,7 +974,9 @@ struct iwl_link_quality_cmd { } __attribute__ ((packed)); #endif - +/* + * REPLY_BT_CONFIG = 0x9b (command, has simple generic response) + */ struct iwl_bt_cmd { u8 flags; u8 lead_time; @@ -1002,6 +1011,9 @@ struct iwl_measure_channel { __le16 reserved; } __attribute__ ((packed)); +/* + * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command) + */ struct iwl_spectrum_cmd { __le16 len; /* number of bytes starting from token */ u8 token; /* token id */ @@ -1018,6 +1030,9 @@ struct iwl_spectrum_cmd { struct iwl_measure_channel channels[10]; } __attribute__ ((packed)); +/* + * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response) + */ struct iwl_spectrum_resp { u8 token; u8 id; /* id of the prior command replaced, or 0xff */ @@ -1065,6 +1080,9 @@ enum iwl_measure_type { IWL_MEASURE_IDLE = (1 << 7), }; +/* + * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command) + */ struct iwl_spectrum_notification { u8 id; /* measurement id -- 0 or 1 */ u8 token; @@ -1088,12 +1106,6 @@ struct iwl_spectrum_notification { __le32 status; /* see iwl_measurement_status */ } __attribute__ ((packed)); -struct iwl_csa_notification { - __le16 band; - __le16 channel; - __le32 status; /* 0 - OK, 1 - fail */ -} __attribute__ ((packed)); - /****************************************************************************** * (7) * Power Management Commands, Responses, Notifications: @@ -1104,6 +1116,8 @@ struct iwl_csa_notification { * struct iwl_powertable_cmd - Power Table Command * @flags: See below: * + * POWER_TABLE_CMD = 0x77 (command, has simple generic response) + * * PM allow: * bit 0 - '0' Driver not allow power management * '1' Driver allow PM (use rest of parameters) @@ -1158,6 +1172,10 @@ struct iwl_powertable_cmd { } __attribute__ ((packed)); #endif +/* + * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command) + * 3945 and 4965 identical. + */ struct iwl_sleep_notification { u8 pm_sleep_mode; u8 pm_wakeup_src; @@ -1167,6 +1185,7 @@ struct iwl_sleep_notification { __le32 bcon_timer; } __attribute__ ((packed)); +/* Sleep states. 3945 and 4965 identical. */ enum { IWL_PM_NO_SLEEP = 0, IWL_PM_SLP_MAC = 1, @@ -1182,12 +1201,18 @@ enum { }; /* - * card_state Command and Notification + * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response) */ +#define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */ +#define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */ +#define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */ +struct iwl_card_state_cmd { + __le32 status; /* CARD_STATE_CMD_* request new power state */ +} __attribute__ ((packed)); -#define CARD_STATE_CMD_DISABLE 0x00 -#define CARD_STATE_CMD_ENABLE 0x01 - +/* + * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command) + */ struct iwl_card_state_notif { __le32 flags; } __attribute__ ((packed)); @@ -1232,8 +1257,11 @@ struct iwl_ssid_ie { #define PROBE_OPTION_MAX 0x4 #define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF) #define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1) - #define IWL_MAX_SCAN_SIZE 1024 + +/* + * REPLY_SCAN_CMD = 0x80 (command) + */ struct iwl_scan_cmd { __le16 len; u8 reserved0; @@ -1278,10 +1306,16 @@ struct iwl_scan_cmd { /* complete notification statuses */ #define ABORT_STATUS 0x2 +/* + * REPLY_SCAN_CMD = 0x80 (response) + */ struct iwl_scanreq_notification { - __le32 status; + __le32 status; /* 1: okay, 2: cannot fulfill request */ } __attribute__ ((packed)); +/* + * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command) + */ struct iwl_scanstart_notification { __le32 tsf_low; __le32 tsf_high; @@ -1296,6 +1330,9 @@ struct iwl_scanstart_notification { #define MEASURE_OWNER_STATUS 0x2; #define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */ +/* + * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command) + */ struct iwl_scanresults_notification { u8 channel; u8 band; @@ -1305,6 +1342,9 @@ struct iwl_scanresults_notification { __le32 statistics[NUMBER_OF_STATISTICS]; } __attribute__ ((packed)); +/* + * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command) + */ struct iwl_scancomplete_notification { u8 scanned_channels; u8 status; @@ -1322,7 +1362,7 @@ struct iwl_scancomplete_notification { *****************************************************************************/ /* - * Tx Beacon Command & Response + * BEACON_NOTIFICATION = 0x90 (notification only, not a command) */ struct iwl_beacon_notif { struct iwl_tx_resp beacon_notify_hdr; @@ -1331,6 +1371,9 @@ struct iwl_beacon_notif { __le32 ibss_mgr_status; } __attribute__ ((packed)); +/* + * REPLY_TX_BEACON = 0x91 (command, has simple generic response) + */ struct iwl_tx_beacon_cmd { struct iwl_tx_cmd tx; __le16 tim_idx; @@ -1524,6 +1567,42 @@ struct statistics_general { #endif } __attribute__ ((packed)); +/* + * REPLY_STATISTICS_CMD = 0x9c, + * 3945 and 4965 identical. + * + * This command triggers an immediate response containing uCode statistics. + * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below. + * + * If the CLEAR_STATS configuration flag is set, uCode will clear its + * internal copy of the statistics (counters) after issuing the response. + * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below). + * + * If the DISABLE_NOTIF configuration flag is set, uCode will not issue + * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag + * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself. + */ +#define IWL_STATS_CONF_CLEAR_STATS __constant_cpu_to_le32(0x1) /* see above */ +#define IWL_STATS_CONF_DISABLE_NOTIF __constant_cpu_to_le32(0x2)/* see above */ +struct iwl_statistics_cmd { + __le32 configuration_flags; /* IWL_STATS_CONF_* */ +} __attribute__ ((packed)); + +/* + * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command) + * + * By default, uCode issues this notification after receiving a beacon + * while associated. To disable this behavior, set DISABLE_NOTIF flag in the + * REPLY_STATISTICS_CMD 0x9c, above. + * + * Statistics counters continue to increment beacon after beacon, but are + * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD + * 0x9c with CLEAR_STATS bit set (see above). + * + * uCode also issues this notification during scans. uCode clears statistics + * appropriately so that each notification contains statistics for only the + * one channel that has just been scanned. + */ struct iwl_notif_statistics { __le32 flag; struct statistics_rx rx; @@ -1532,6 +1611,9 @@ struct iwl_notif_statistics { } __attribute__ ((packed)); +/* + * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command) + */ /* if ucode missed CONSECUTIVE_MISSED_BCONS_TH beacons in a row, * then this notification will be sent. */ #define CONSECUTIVE_MISSED_BCONS_TH 20 @@ -1575,12 +1657,18 @@ struct iwl_calibration_cmd { /* * LEDs Command & Response + * REPLY_LEDS_CMD = 0x48 (command, has simple generic response) + * + * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field), + * this command turns it on or off, or sets up a periodic blinking cycle. */ struct iwl_led_cmd { - __le32 interval; - u8 id; - u8 off; - u8 on; + __le32 interval; /* "interval" in uSec */ + u8 id; /* 1: Activity, 2: Link, 3: Tech */ + u8 off; /* # intervals off while blinking; + * "0", with >0 "on" value, turns LED on */ + u8 on; /* # intervals on while blinking; + * "0", regardless of "off", turns LED off */ u8 reserved; } __attribute__ ((packed)); -- 1.5.2