aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ps3_gelic_wireless.c2
-rw-r--r--drivers/net/wireless/b43/Makefile4
-rw-r--r--drivers/net/wireless/b43/nphy.h40
-rw-r--r--drivers/net/wireless/ipw2200.c12
-rw-r--r--drivers/net/wireless/ipw2200.h112
-rw-r--r--drivers/net/wireless/iwlwifi/Kconfig8
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-commands.h39
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-hw.h32
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-commands.h28
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-hw.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-io.h94
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-rs.c53
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c560
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.h210
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c216
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h55
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h (renamed from drivers/net/wireless/iwlwifi/iwl-4965-debug.h)55
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c319
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c368
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h58
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c251
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c1729
-rw-r--r--drivers/net/wireless/libertas/11d.c16
-rw-r--r--drivers/net/wireless/libertas/11d.h5
-rw-r--r--drivers/net/wireless/libertas/assoc.c16
-rw-r--r--drivers/net/wireless/libertas/cmd.c254
-rw-r--r--drivers/net/wireless/libertas/cmd.h9
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c66
-rw-r--r--drivers/net/wireless/libertas/debugfs.c8
-rw-r--r--drivers/net/wireless/libertas/decl.h5
-rw-r--r--drivers/net/wireless/libertas/dev.h4
-rw-r--r--drivers/net/wireless/libertas/host.h3
-rw-r--r--drivers/net/wireless/libertas/hostcmd.h7
-rw-r--r--drivers/net/wireless/libertas/if_cs.c3
-rw-r--r--drivers/net/wireless/libertas/join.c9
-rw-r--r--drivers/net/wireless/libertas/join.h9
-rw-r--r--drivers/net/wireless/libertas/main.c35
-rw-r--r--drivers/net/wireless/libertas/scan.c4
-rw-r--r--drivers/net/wireless/libertas/scan.h7
-rw-r--r--drivers/net/wireless/libertas/wext.c40
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig4
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c99
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c110
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c127
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c10
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c15
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c57
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.h22
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c114
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c131
-rw-r--r--include/net/mac80211.h47
-rw-r--r--include/net/wireless.h6
-rw-r--r--net/mac80211/ieee80211.c7
-rw-r--r--net/mac80211/ieee80211_i.h2
-rw-r--r--net/mac80211/ieee80211_ioctl.c31
-rw-r--r--net/mac80211/ieee80211_sta.c125
-rw-r--r--net/mac80211/tkip.c68
-rw-r--r--net/mac80211/tkip.h2
-rw-r--r--net/mac80211/wpa.c2
-rw-r--r--net/wireless/util.c23
62 files changed, 3199 insertions, 2568 deletions
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index ddbc6e475e28..f9719cfa046c 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -87,7 +87,7 @@ static inline int wpa2_capable(void)
87 87
88static inline int precise_ie(void) 88static inline int precise_ie(void)
89{ 89{
90 return 0; /* FIXME */ 90 return (0 <= ps3_compare_firmware_version(2, 2, 0));
91} 91}
92/* 92/*
93 * post_eurus_cmd helpers 93 * post_eurus_cmd helpers
diff --git a/drivers/net/wireless/b43/Makefile b/drivers/net/wireless/b43/Makefile
index ac1329dba045..ae11fe4c0be6 100644
--- a/drivers/net/wireless/b43/Makefile
+++ b/drivers/net/wireless/b43/Makefile
@@ -1,8 +1,8 @@
1b43-y += main.o 1b43-y += main.o
2b43-y += tables.o 2b43-y += tables.o
3b43-y += tables_nphy.o 3b43-$(CONFIG_B43_NPHY) += tables_nphy.o
4b43-y += phy.o 4b43-y += phy.o
5b43-y += nphy.o 5b43-$(CONFIG_B43_NPHY) += nphy.o
6b43-y += sysfs.o 6b43-y += sysfs.o
7b43-y += xmit.o 7b43-y += xmit.o
8b43-y += lo.o 8b43-y += lo.o
diff --git a/drivers/net/wireless/b43/nphy.h b/drivers/net/wireless/b43/nphy.h
index 5d95118b8193..faf46b9cbf1b 100644
--- a/drivers/net/wireless/b43/nphy.h
+++ b/drivers/net/wireless/b43/nphy.h
@@ -919,6 +919,10 @@
919 919
920struct b43_wldev; 920struct b43_wldev;
921 921
922
923#ifdef CONFIG_B43_NPHY
924/* N-PHY support enabled */
925
922int b43_phy_initn(struct b43_wldev *dev); 926int b43_phy_initn(struct b43_wldev *dev);
923 927
924void b43_nphy_radio_turn_on(struct b43_wldev *dev); 928void b43_nphy_radio_turn_on(struct b43_wldev *dev);
@@ -929,4 +933,40 @@ int b43_nphy_selectchannel(struct b43_wldev *dev, u8 channel);
929void b43_nphy_xmitpower(struct b43_wldev *dev); 933void b43_nphy_xmitpower(struct b43_wldev *dev);
930void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna); 934void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna);
931 935
936
937#else /* CONFIG_B43_NPHY */
938/* N-PHY support disabled */
939
940
941static inline
942int b43_phy_initn(struct b43_wldev *dev)
943{
944 return -EOPNOTSUPP;
945}
946
947static inline
948void b43_nphy_radio_turn_on(struct b43_wldev *dev)
949{
950}
951static inline
952void b43_nphy_radio_turn_off(struct b43_wldev *dev)
953{
954}
955
956static inline
957int b43_nphy_selectchannel(struct b43_wldev *dev, u8 channel)
958{
959 return -ENOSYS;
960}
961
962static inline
963void b43_nphy_xmitpower(struct b43_wldev *dev)
964{
965}
966static inline
967void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna)
968{
969}
970
971#endif /* CONFIG_B43_NPHY */
932#endif /* B43_NPHY_H_ */ 972#endif /* B43_NPHY_H_ */
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 3d4b590046a8..e79de53bd4f3 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -4495,9 +4495,9 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4495 priv-> 4495 priv->
4496 essid_len), 4496 essid_len),
4497 print_mac(mac, priv->bssid), 4497 print_mac(mac, priv->bssid),
4498 ntohs(auth->status), 4498 le16_to_cpu(auth->status),
4499 ipw_get_status_code 4499 ipw_get_status_code
4500 (ntohs 4500 (le16_to_cpu
4501 (auth->status))); 4501 (auth->status)));
4502 4502
4503 priv->status &= 4503 priv->status &=
@@ -4532,9 +4532,9 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4532 IPW_DL_STATE | 4532 IPW_DL_STATE |
4533 IPW_DL_ASSOC, 4533 IPW_DL_ASSOC,
4534 "association failed (0x%04X): %s\n", 4534 "association failed (0x%04X): %s\n",
4535 ntohs(resp->status), 4535 le16_to_cpu(resp->status),
4536 ipw_get_status_code 4536 ipw_get_status_code
4537 (ntohs 4537 (le16_to_cpu
4538 (resp->status))); 4538 (resp->status)));
4539 } 4539 }
4540 4540
@@ -4591,8 +4591,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4591 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | 4591 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
4592 IPW_DL_ASSOC, 4592 IPW_DL_ASSOC,
4593 "authentication failed (0x%04X): %s\n", 4593 "authentication failed (0x%04X): %s\n",
4594 ntohs(auth->status), 4594 le16_to_cpu(auth->status),
4595 ipw_get_status_code(ntohs 4595 ipw_get_status_code(le16_to_cpu
4596 (auth-> 4596 (auth->
4597 status))); 4597 status)));
4598 } 4598 }
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index fdc187e0769d..cd3295b66dd6 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -385,73 +385,73 @@ struct clx2_queue {
385 dma_addr_t dma_addr; /**< physical addr for BD's */ 385 dma_addr_t dma_addr; /**< physical addr for BD's */
386 int low_mark; /**< low watermark, resume queue if free space more than this */ 386 int low_mark; /**< low watermark, resume queue if free space more than this */
387 int high_mark; /**< high watermark, stop queue if free space less than this */ 387 int high_mark; /**< high watermark, stop queue if free space less than this */
388} __attribute__ ((packed)); 388} __attribute__ ((packed)); /* XXX */
389 389
390struct machdr32 { 390struct machdr32 {
391 __le16 frame_ctl; 391 __le16 frame_ctl;
392 u16 duration; // watch out for endians! 392 __le16 duration; // watch out for endians!
393 u8 addr1[MACADRR_BYTE_LEN]; 393 u8 addr1[MACADRR_BYTE_LEN];
394 u8 addr2[MACADRR_BYTE_LEN]; 394 u8 addr2[MACADRR_BYTE_LEN];
395 u8 addr3[MACADRR_BYTE_LEN]; 395 u8 addr3[MACADRR_BYTE_LEN];
396 u16 seq_ctrl; // more endians! 396 __le16 seq_ctrl; // more endians!
397 u8 addr4[MACADRR_BYTE_LEN]; 397 u8 addr4[MACADRR_BYTE_LEN];
398 __le16 qos_ctrl; 398 __le16 qos_ctrl;
399} __attribute__ ((packed)); 399} __attribute__ ((packed));
400 400
401struct machdr30 { 401struct machdr30 {
402 __le16 frame_ctl; 402 __le16 frame_ctl;
403 u16 duration; // watch out for endians! 403 __le16 duration; // watch out for endians!
404 u8 addr1[MACADRR_BYTE_LEN]; 404 u8 addr1[MACADRR_BYTE_LEN];
405 u8 addr2[MACADRR_BYTE_LEN]; 405 u8 addr2[MACADRR_BYTE_LEN];
406 u8 addr3[MACADRR_BYTE_LEN]; 406 u8 addr3[MACADRR_BYTE_LEN];
407 u16 seq_ctrl; // more endians! 407 __le16 seq_ctrl; // more endians!
408 u8 addr4[MACADRR_BYTE_LEN]; 408 u8 addr4[MACADRR_BYTE_LEN];
409} __attribute__ ((packed)); 409} __attribute__ ((packed));
410 410
411struct machdr26 { 411struct machdr26 {
412 __le16 frame_ctl; 412 __le16 frame_ctl;
413 u16 duration; // watch out for endians! 413 __le16 duration; // watch out for endians!
414 u8 addr1[MACADRR_BYTE_LEN]; 414 u8 addr1[MACADRR_BYTE_LEN];
415 u8 addr2[MACADRR_BYTE_LEN]; 415 u8 addr2[MACADRR_BYTE_LEN];
416 u8 addr3[MACADRR_BYTE_LEN]; 416 u8 addr3[MACADRR_BYTE_LEN];
417 u16 seq_ctrl; // more endians! 417 __le16 seq_ctrl; // more endians!
418 __le16 qos_ctrl; 418 __le16 qos_ctrl;
419} __attribute__ ((packed)); 419} __attribute__ ((packed));
420 420
421struct machdr24 { 421struct machdr24 {
422 __le16 frame_ctl; 422 __le16 frame_ctl;
423 u16 duration; // watch out for endians! 423 __le16 duration; // watch out for endians!
424 u8 addr1[MACADRR_BYTE_LEN]; 424 u8 addr1[MACADRR_BYTE_LEN];
425 u8 addr2[MACADRR_BYTE_LEN]; 425 u8 addr2[MACADRR_BYTE_LEN];
426 u8 addr3[MACADRR_BYTE_LEN]; 426 u8 addr3[MACADRR_BYTE_LEN];
427 u16 seq_ctrl; // more endians! 427 __le16 seq_ctrl; // more endians!
428} __attribute__ ((packed)); 428} __attribute__ ((packed));
429 429
430// TX TFD with 32 byte MAC Header 430// TX TFD with 32 byte MAC Header
431struct tx_tfd_32 { 431struct tx_tfd_32 {
432 struct machdr32 mchdr; // 32 432 struct machdr32 mchdr; // 32
433 u32 uivplaceholder[2]; // 8 433 __le32 uivplaceholder[2]; // 8
434} __attribute__ ((packed)); 434} __attribute__ ((packed));
435 435
436// TX TFD with 30 byte MAC Header 436// TX TFD with 30 byte MAC Header
437struct tx_tfd_30 { 437struct tx_tfd_30 {
438 struct machdr30 mchdr; // 30 438 struct machdr30 mchdr; // 30
439 u8 reserved[2]; // 2 439 u8 reserved[2]; // 2
440 u32 uivplaceholder[2]; // 8 440 __le32 uivplaceholder[2]; // 8
441} __attribute__ ((packed)); 441} __attribute__ ((packed));
442 442
443// tx tfd with 26 byte mac header 443// tx tfd with 26 byte mac header
444struct tx_tfd_26 { 444struct tx_tfd_26 {
445 struct machdr26 mchdr; // 26 445 struct machdr26 mchdr; // 26
446 u8 reserved1[2]; // 2 446 u8 reserved1[2]; // 2
447 u32 uivplaceholder[2]; // 8 447 __le32 uivplaceholder[2]; // 8
448 u8 reserved2[4]; // 4 448 u8 reserved2[4]; // 4
449} __attribute__ ((packed)); 449} __attribute__ ((packed));
450 450
451// tx tfd with 24 byte mac header 451// tx tfd with 24 byte mac header
452struct tx_tfd_24 { 452struct tx_tfd_24 {
453 struct machdr24 mchdr; // 24 453 struct machdr24 mchdr; // 24
454 u32 uivplaceholder[2]; // 8 454 __le32 uivplaceholder[2]; // 8
455 u8 reserved[8]; // 8 455 u8 reserved[8]; // 8
456} __attribute__ ((packed)); 456} __attribute__ ((packed));
457 457
@@ -460,7 +460,7 @@ struct tx_tfd_24 {
460struct tfd_command { 460struct tfd_command {
461 u8 index; 461 u8 index;
462 u8 length; 462 u8 length;
463 u16 reserved; 463 __le16 reserved;
464 u8 payload[0]; 464 u8 payload[0];
465} __attribute__ ((packed)); 465} __attribute__ ((packed));
466 466
@@ -562,27 +562,27 @@ struct rate_histogram {
562struct ipw_cmd_stats { 562struct ipw_cmd_stats {
563 u8 cmd_id; 563 u8 cmd_id;
564 u8 seq_num; 564 u8 seq_num;
565 u16 good_sfd; 565 __le16 good_sfd;
566 u16 bad_plcp; 566 __le16 bad_plcp;
567 u16 wrong_bssid; 567 __le16 wrong_bssid;
568 u16 valid_mpdu; 568 __le16 valid_mpdu;
569 u16 bad_mac_header; 569 __le16 bad_mac_header;
570 u16 reserved_frame_types; 570 __le16 reserved_frame_types;
571 u16 rx_ina; 571 __le16 rx_ina;
572 u16 bad_crc32; 572 __le16 bad_crc32;
573 u16 invalid_cts; 573 __le16 invalid_cts;
574 u16 invalid_acks; 574 __le16 invalid_acks;
575 u16 long_distance_ina_fina; 575 __le16 long_distance_ina_fina;
576 u16 dsp_silence_unreachable; 576 __le16 dsp_silence_unreachable;
577 u16 accumulated_rssi; 577 __le16 accumulated_rssi;
578 u16 rx_ovfl_frame_tossed; 578 __le16 rx_ovfl_frame_tossed;
579 u16 rssi_silence_threshold; 579 __le16 rssi_silence_threshold;
580 u16 rx_ovfl_frame_supplied; 580 __le16 rx_ovfl_frame_supplied;
581 u16 last_rx_frame_signal; 581 __le16 last_rx_frame_signal;
582 u16 last_rx_frame_noise; 582 __le16 last_rx_frame_noise;
583 u16 rx_autodetec_no_ofdm; 583 __le16 rx_autodetec_no_ofdm;
584 u16 rx_autodetec_no_barker; 584 __le16 rx_autodetec_no_barker;
585 u16 reserved; 585 __le16 reserved;
586} __attribute__ ((packed)); 586} __attribute__ ((packed));
587 587
588struct notif_channel_result { 588struct notif_channel_result {
@@ -637,7 +637,7 @@ struct notif_association {
637struct notif_authenticate { 637struct notif_authenticate {
638 u8 state; 638 u8 state;
639 struct machdr24 addr; 639 struct machdr24 addr;
640 u16 status; 640 __le16 status;
641} __attribute__ ((packed)); 641} __attribute__ ((packed));
642 642
643struct notif_calibration { 643struct notif_calibration {
@@ -732,14 +732,14 @@ struct ipw_rx_queue {
732struct alive_command_responce { 732struct alive_command_responce {
733 u8 alive_command; 733 u8 alive_command;
734 u8 sequence_number; 734 u8 sequence_number;
735 u16 software_revision; 735 __le16 software_revision;
736 u8 device_identifier; 736 u8 device_identifier;
737 u8 reserved1[5]; 737 u8 reserved1[5];
738 u16 reserved2; 738 __le16 reserved2;
739 u16 reserved3; 739 __le16 reserved3;
740 u16 clock_settle_time; 740 __le16 clock_settle_time;
741 u16 powerup_settle_time; 741 __le16 powerup_settle_time;
742 u16 reserved4; 742 __le16 reserved4;
743 u8 time_stamp[5]; /* month, day, year, hours, minutes */ 743 u8 time_stamp[5]; /* month, day, year, hours, minutes */
744 u8 ucode_valid; 744 u8 ucode_valid;
745} __attribute__ ((packed)); 745} __attribute__ ((packed));
@@ -878,7 +878,11 @@ static inline void ipw_set_scan_type(struct ipw_scan_request_ext *scan,
878 878
879struct ipw_associate { 879struct ipw_associate {
880 u8 channel; 880 u8 channel;
881#ifdef __LITTLE_ENDIAN_BITFIELD
881 u8 auth_type:4, auth_key:4; 882 u8 auth_type:4, auth_key:4;
883#else
884 u8 auth_key:4, auth_type:4;
885#endif
882 u8 assoc_type; 886 u8 assoc_type;
883 u8 reserved; 887 u8 reserved;
884 __le16 policy_support; 888 __le16 policy_support;
@@ -918,12 +922,12 @@ struct ipw_frag_threshold {
918struct ipw_retry_limit { 922struct ipw_retry_limit {
919 u8 short_retry_limit; 923 u8 short_retry_limit;
920 u8 long_retry_limit; 924 u8 long_retry_limit;
921 u16 reserved; 925 __le16 reserved;
922} __attribute__ ((packed)); 926} __attribute__ ((packed));
923 927
924struct ipw_dino_config { 928struct ipw_dino_config {
925 u32 dino_config_addr; 929 __le32 dino_config_addr;
926 u16 dino_config_size; 930 __le16 dino_config_size;
927 u8 dino_response; 931 u8 dino_response;
928 u8 reserved; 932 u8 reserved;
929} __attribute__ ((packed)); 933} __attribute__ ((packed));
@@ -998,7 +1002,7 @@ struct ipw_sensitivity_calib {
998 * - \a status contains status; 1002 * - \a status contains status;
999 * - \a param filled with status parameters. 1003 * - \a param filled with status parameters.
1000 */ 1004 */
1001struct ipw_cmd { 1005struct ipw_cmd { /* XXX */
1002 u32 cmd; /**< Host command */ 1006 u32 cmd; /**< Host command */
1003 u32 status;/**< Status */ 1007 u32 status;/**< Status */
1004 u32 status_len; 1008 u32 status_len;
@@ -1092,7 +1096,7 @@ struct ipw_ibss_seq {
1092 struct list_head list; 1096 struct list_head list;
1093}; 1097};
1094 1098
1095struct ipw_error_elem { 1099struct ipw_error_elem { /* XXX */
1096 u32 desc; 1100 u32 desc;
1097 u32 time; 1101 u32 time;
1098 u32 blink1; 1102 u32 blink1;
@@ -1102,13 +1106,13 @@ struct ipw_error_elem {
1102 u32 data; 1106 u32 data;
1103}; 1107};
1104 1108
1105struct ipw_event { 1109struct ipw_event { /* XXX */
1106 u32 event; 1110 u32 event;
1107 u32 time; 1111 u32 time;
1108 u32 data; 1112 u32 data;
1109} __attribute__ ((packed)); 1113} __attribute__ ((packed));
1110 1114
1111struct ipw_fw_error { 1115struct ipw_fw_error { /* XXX */
1112 unsigned long jiffies; 1116 unsigned long jiffies;
1113 u32 status; 1117 u32 status;
1114 u32 config; 1118 u32 config;
@@ -1153,7 +1157,7 @@ struct ipw_prom_priv {
1153 */ 1157 */
1154struct ipw_rt_hdr { 1158struct ipw_rt_hdr {
1155 struct ieee80211_radiotap_header rt_hdr; 1159 struct ieee80211_radiotap_header rt_hdr;
1156 u64 rt_tsf; /* TSF */ 1160 u64 rt_tsf; /* TSF */ /* XXX */
1157 u8 rt_flags; /* radiotap packet flags */ 1161 u8 rt_flags; /* radiotap packet flags */
1158 u8 rt_rate; /* rate in 500kb/s */ 1162 u8 rt_rate; /* rate in 500kb/s */
1159 __le16 rt_channel; /* channel in mhz */ 1163 __le16 rt_channel; /* channel in mhz */
@@ -1940,8 +1944,8 @@ enum {
1940#define IPW_MEM_FIXED_OVERRIDE (IPW_SHARED_LOWER_BOUND + 0x41C) 1944#define IPW_MEM_FIXED_OVERRIDE (IPW_SHARED_LOWER_BOUND + 0x41C)
1941 1945
1942struct ipw_fixed_rate { 1946struct ipw_fixed_rate {
1943 u16 tx_rates; 1947 __le16 tx_rates;
1944 u16 reserved; 1948 __le16 reserved;
1945} __attribute__ ((packed)); 1949} __attribute__ ((packed));
1946 1950
1947#define IPW_INDIRECT_ADDR_MASK (~0x3ul) 1951#define IPW_INDIRECT_ADDR_MASK (~0x3ul)
@@ -1951,12 +1955,12 @@ struct host_cmd {
1951 u8 len; 1955 u8 len;
1952 u16 reserved; 1956 u16 reserved;
1953 u32 *param; 1957 u32 *param;
1954} __attribute__ ((packed)); 1958} __attribute__ ((packed)); /* XXX */
1955 1959
1956struct cmdlog_host_cmd { 1960struct cmdlog_host_cmd {
1957 u8 cmd; 1961 u8 cmd;
1958 u8 len; 1962 u8 len;
1959 u16 reserved; 1963 __le16 reserved;
1960 char param[124]; 1964 char param[124];
1961} __attribute__ ((packed)); 1965} __attribute__ ((packed));
1962 1966
diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index 5b7c0160e1fa..1ab14ed33f58 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -50,7 +50,7 @@ config IWL4965_SENSITIVITY
50 This option will enable sensitivity calibration for the iwl4965 50 This option will enable sensitivity calibration for the iwl4965
51 driver. 51 driver.
52 52
53config IWL4965_DEBUG 53config IWLWIFI_DEBUG
54 bool "Enable full debugging output in iwl4965 driver" 54 bool "Enable full debugging output in iwl4965 driver"
55 depends on IWL4965 55 depends on IWL4965
56 ---help--- 56 ---help---
@@ -76,6 +76,12 @@ config IWL4965_DEBUG
76 as the debug information can assist others in helping you resolve 76 as the debug information can assist others in helping you resolve
77 any problems you may encounter. 77 any problems you may encounter.
78 78
79config IWLWIFI_DEBUGFS
80 bool "Iwlwifi debugfs support"
81 depends on IWLCORE && IWLWIFI_DEBUG && MAC80211_DEBUGFS
82 ---help---
83 Enable creation of debugfs files for the iwlwifi drivers.
84
79config IWL3945 85config IWL3945
80 tristate "Intel PRO/Wireless 3945ABG/BG Network Connection" 86 tristate "Intel PRO/Wireless 3945ABG/BG Network Connection"
81 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL 87 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 59d9c90d3610..6be8012a1743 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -1,5 +1,9 @@
1obj-$(CONFIG_IWLCORE) += iwlcore.o 1obj-$(CONFIG_IWLCORE) += iwlcore.o
2iwlcore-objs = iwl-core.o iwl-eeprom.o 2iwlcore-objs = iwl-core.o iwl-eeprom.o iwl-hcmd.o
3
4ifeq ($(CONFIG_IWLWIFI_DEBUGFS),y)
5 iwlcore-objs += iwl-debugfs.o
6endif
3 7
4obj-$(CONFIG_IWL3945) += iwl3945.o 8obj-$(CONFIG_IWL3945) += iwl3945.o
5iwl3945-objs = iwl3945-base.o iwl-3945.o iwl-3945-rs.o 9iwl3945-objs = iwl3945-base.o iwl-3945.o iwl-3945-rs.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-commands.h b/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
index 824a6e532de7..817ece773643 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
@@ -707,45 +707,6 @@ struct iwl3945_rx_frame {
707 struct iwl3945_rx_frame_end end; 707 struct iwl3945_rx_frame_end end;
708} __attribute__ ((packed)); 708} __attribute__ ((packed));
709 709
710/* Fixed (non-configurable) rx data from phy */
711#define RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
712#define RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
713#define IWL_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
714#define IWL_AGC_DB_POS (7)
715struct iwl4965_rx_non_cfg_phy {
716 __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
717 __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
718 u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
719 u8 pad[0];
720} __attribute__ ((packed));
721
722/*
723 * REPLY_4965_RX = 0xc3 (response only, not a command)
724 * Used only for legacy (non 11n) frames.
725 */
726#define RX_RES_PHY_CNT 14
727struct iwl4965_rx_phy_res {
728 u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
729 u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
730 u8 stat_id; /* configurable DSP phy data set ID */
731 u8 reserved1;
732 __le64 timestamp; /* TSF at on air rise */
733 __le32 beacon_time_stamp; /* beacon at on-air rise */
734 __le16 phy_flags; /* general phy flags: band, modulation, ... */
735 __le16 channel; /* channel number */
736 __le16 non_cfg_phy[RX_RES_PHY_CNT]; /* upto 14 phy entries */
737 __le32 reserved2;
738 __le32 rate_n_flags;
739 __le16 byte_count; /* frame's byte-count */
740 __le16 reserved3;
741} __attribute__ ((packed));
742
743struct iwl4965_rx_mpdu_res_start {
744 __le16 byte_count;
745 __le16 reserved;
746} __attribute__ ((packed));
747
748
749/****************************************************************************** 710/******************************************************************************
750 * (5) 711 * (5)
751 * Tx Commands & Responses: 712 * Tx Commands & Responses:
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
index 1ca6fa494e4b..368da9852aab 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
@@ -198,43 +198,27 @@ struct iwl3945_eeprom_temperature_corr {
198 */ 198 */
199struct iwl3945_eeprom { 199struct iwl3945_eeprom {
200 u8 reserved0[16]; 200 u8 reserved0[16];
201#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
202 u16 device_id; /* abs.ofs: 16 */ 201 u16 device_id; /* abs.ofs: 16 */
203 u8 reserved1[2]; 202 u8 reserved1[2];
204#define EEPROM_PMC (2*0x0A) /* 2 bytes */
205 u16 pmc; /* abs.ofs: 20 */ 203 u16 pmc; /* abs.ofs: 20 */
206 u8 reserved2[20]; 204 u8 reserved2[20];
207#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
208 u8 mac_address[6]; /* abs.ofs: 42 */ 205 u8 mac_address[6]; /* abs.ofs: 42 */
209 u8 reserved3[58]; 206 u8 reserved3[58];
210#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
211 u16 board_revision; /* abs.ofs: 106 */ 207 u16 board_revision; /* abs.ofs: 106 */
212 u8 reserved4[11]; 208 u8 reserved4[11];
213#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
214 u8 board_pba_number[9]; /* abs.ofs: 119 */ 209 u8 board_pba_number[9]; /* abs.ofs: 119 */
215 u8 reserved5[8]; 210 u8 reserved5[8];
216#define EEPROM_VERSION (2*0x44) /* 2 bytes */
217 u16 version; /* abs.ofs: 136 */ 211 u16 version; /* abs.ofs: 136 */
218#define EEPROM_SKU_CAP (2*0x45) /* 1 bytes */
219 u8 sku_cap; /* abs.ofs: 138 */ 212 u8 sku_cap; /* abs.ofs: 138 */
220#define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */
221 u8 leds_mode; /* abs.ofs: 139 */ 213 u8 leds_mode; /* abs.ofs: 139 */
222#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
223 u16 oem_mode; 214 u16 oem_mode;
224#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
225 u16 wowlan_mode; /* abs.ofs: 142 */ 215 u16 wowlan_mode; /* abs.ofs: 142 */
226#define EEPROM_LEDS_TIME_INTERVAL (2*0x48) /* 2 bytes */
227 u16 leds_time_interval; /* abs.ofs: 144 */ 216 u16 leds_time_interval; /* abs.ofs: 144 */
228#define EEPROM_LEDS_OFF_TIME (2*0x49) /* 1 bytes */
229 u8 leds_off_time; /* abs.ofs: 146 */ 217 u8 leds_off_time; /* abs.ofs: 146 */
230#define EEPROM_LEDS_ON_TIME (2*0x49+1) /* 1 bytes */
231 u8 leds_on_time; /* abs.ofs: 147 */ 218 u8 leds_on_time; /* abs.ofs: 147 */
232#define EEPROM_ALMGOR_M_VERSION (2*0x4A) /* 1 bytes */
233 u8 almgor_m_version; /* abs.ofs: 148 */ 219 u8 almgor_m_version; /* abs.ofs: 148 */
234#define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */
235 u8 antenna_switch_type; /* abs.ofs: 149 */ 220 u8 antenna_switch_type; /* abs.ofs: 149 */
236 u8 reserved6[42]; 221 u8 reserved6[42];
237#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
238 u8 sku_id[4]; /* abs.ofs: 192 */ 222 u8 sku_id[4]; /* abs.ofs: 192 */
239 223
240/* 224/*
@@ -249,9 +233,7 @@ struct iwl3945_eeprom {
249 * 233 *
250 * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 234 * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
251 */ 235 */
252#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
253 u16 band_1_count; /* abs.ofs: 196 */ 236 u16 band_1_count; /* abs.ofs: 196 */
254#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
255 struct iwl3945_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */ 237 struct iwl3945_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */
256 238
257/* 239/*
@@ -259,36 +241,28 @@ struct iwl3945_eeprom {
259 * 5.0 GHz channels 7, 8, 11, 12, 16 241 * 5.0 GHz channels 7, 8, 11, 12, 16
260 * (4915-5080MHz) (none of these is ever supported) 242 * (4915-5080MHz) (none of these is ever supported)
261 */ 243 */
262#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
263 u16 band_2_count; /* abs.ofs: 226 */ 244 u16 band_2_count; /* abs.ofs: 226 */
264#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
265 struct iwl3945_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ 245 struct iwl3945_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
266 246
267/* 247/*
268 * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 248 * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
269 * (5170-5320MHz) 249 * (5170-5320MHz)
270 */ 250 */
271#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
272 u16 band_3_count; /* abs.ofs: 254 */ 251 u16 band_3_count; /* abs.ofs: 254 */
273#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
274 struct iwl3945_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ 252 struct iwl3945_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
275 253
276/* 254/*
277 * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 255 * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
278 * (5500-5700MHz) 256 * (5500-5700MHz)
279 */ 257 */
280#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
281 u16 band_4_count; /* abs.ofs: 280 */ 258 u16 band_4_count; /* abs.ofs: 280 */
282#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
283 struct iwl3945_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ 259 struct iwl3945_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
284 260
285/* 261/*
286 * 5.7 GHz channels 145, 149, 153, 157, 161, 165 262 * 5.7 GHz channels 145, 149, 153, 157, 161, 165
287 * (5725-5825MHz) 263 * (5725-5825MHz)
288 */ 264 */
289#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
290 u16 band_5_count; /* abs.ofs: 304 */ 265 u16 band_5_count; /* abs.ofs: 304 */
291#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
292 struct iwl3945_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ 266 struct iwl3945_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
293 267
294 u8 reserved9[194]; 268 u8 reserved9[194];
@@ -296,15 +270,9 @@ struct iwl3945_eeprom {
296/* 270/*
297 * 3945 Txpower calibration data. 271 * 3945 Txpower calibration data.
298 */ 272 */
299#define EEPROM_TXPOWER_CALIB_GROUP0 0x200
300#define EEPROM_TXPOWER_CALIB_GROUP1 0x240
301#define EEPROM_TXPOWER_CALIB_GROUP2 0x280
302#define EEPROM_TXPOWER_CALIB_GROUP3 0x2c0
303#define EEPROM_TXPOWER_CALIB_GROUP4 0x300
304#define IWL_NUM_TX_CALIB_GROUPS 5 273#define IWL_NUM_TX_CALIB_GROUPS 5
305 struct iwl3945_eeprom_txpower_group groups[IWL_NUM_TX_CALIB_GROUPS]; 274 struct iwl3945_eeprom_txpower_group groups[IWL_NUM_TX_CALIB_GROUPS];
306/* abs.ofs: 512 */ 275/* abs.ofs: 512 */
307#define EEPROM_CALIB_TEMPERATURE_CORRECT 0x340
308 struct iwl3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ 276 struct iwl3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */
309 u8 reserved16[172]; /* fill out to full 1024 byte block */ 277 u8 reserved16[172]; /* fill out to full 1024 byte block */
310} __attribute__ ((packed)); 278} __attribute__ ((packed));
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-commands.h b/drivers/net/wireless/iwlwifi/iwl-4965-commands.h
index 35f592dc40c6..7e36ecb27575 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-commands.h
@@ -139,7 +139,7 @@ enum {
139 REPLY_PHY_CALIBRATION_CMD = 0xb0, 139 REPLY_PHY_CALIBRATION_CMD = 0xb0,
140 REPLY_RX_PHY_CMD = 0xc0, 140 REPLY_RX_PHY_CMD = 0xc0,
141 REPLY_RX_MPDU_CMD = 0xc1, 141 REPLY_RX_MPDU_CMD = 0xc1,
142 REPLY_4965_RX = 0xc3, 142 REPLY_RX = 0xc3,
143 REPLY_COMPRESSED_BA = 0xc5, 143 REPLY_COMPRESSED_BA = 0xc5,
144 REPLY_MAX = 0xff 144 REPLY_MAX = 0xff
145}; 145};
@@ -151,16 +151,16 @@ enum {
151 * 151 *
152 *****************************************************************************/ 152 *****************************************************************************/
153 153
154/* iwl4965_cmd_header flags value */ 154/* iwl_cmd_header flags value */
155#define IWL_CMD_FAILED_MSK 0x40 155#define IWL_CMD_FAILED_MSK 0x40
156 156
157/** 157/**
158 * struct iwl4965_cmd_header 158 * struct iwl_cmd_header
159 * 159 *
160 * This header format appears in the beginning of each command sent from the 160 * This header format appears in the beginning of each command sent from the
161 * driver, and each response/notification received from uCode. 161 * driver, and each response/notification received from uCode.
162 */ 162 */
163struct iwl4965_cmd_header { 163struct iwl_cmd_header {
164 u8 cmd; /* Command ID: REPLY_RXON, etc. */ 164 u8 cmd; /* Command ID: REPLY_RXON, etc. */
165 u8 flags; /* IWL_CMD_* */ 165 u8 flags; /* IWL_CMD_* */
166 /* 166 /*
@@ -194,7 +194,7 @@ struct iwl4965_cmd_header {
194 * 4965 rate_n_flags bit fields 194 * 4965 rate_n_flags bit fields
195 * 195 *
196 * rate_n_flags format is used in following 4965 commands: 196 * rate_n_flags format is used in following 4965 commands:
197 * REPLY_4965_RX (response only) 197 * REPLY_RX (response only)
198 * REPLY_TX (both command and response) 198 * REPLY_TX (both command and response)
199 * REPLY_TX_LINK_QUALITY_CMD 199 * REPLY_TX_LINK_QUALITY_CMD
200 * 200 *
@@ -741,6 +741,7 @@ struct iwl4965_qosparam_cmd {
741/* wep key in STA: 5-bytes (0) or 13-bytes (1) */ 741/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
742#define STA_KEY_FLG_KEY_SIZE_MSK __constant_cpu_to_le16(0x1000) 742#define STA_KEY_FLG_KEY_SIZE_MSK __constant_cpu_to_le16(0x1000)
743#define STA_KEY_MULTICAST_MSK __constant_cpu_to_le16(0x4000) 743#define STA_KEY_MULTICAST_MSK __constant_cpu_to_le16(0x4000)
744#define STA_KEY_MAX_NUM 8
744 745
745/* Flags indicate whether to modify vs. don't change various station params */ 746/* Flags indicate whether to modify vs. don't change various station params */
746#define STA_MODIFY_KEY_MASK 0x01 747#define STA_MODIFY_KEY_MASK 0x01
@@ -889,6 +890,10 @@ struct iwl4965_rx_frame_hdr {
889#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8) 890#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
890#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8) 891#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
891#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8) 892#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
893#define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8)
894
895#define RX_RES_STATUS_STATION_FOUND (1<<6)
896#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7)
892 897
893#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11) 898#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
894#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11) 899#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
@@ -896,6 +901,11 @@ struct iwl4965_rx_frame_hdr {
896#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11) 901#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
897#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11) 902#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
898 903
904#define RX_MPDU_RES_STATUS_ICV_OK (0x20)
905#define RX_MPDU_RES_STATUS_MIC_OK (0x40)
906#define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7)
907#define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800)
908
899struct iwl4965_rx_frame_end { 909struct iwl4965_rx_frame_end {
900 __le32 status; 910 __le32 status;
901 __le64 timestamp; 911 __le64 timestamp;
@@ -929,7 +939,7 @@ struct iwl4965_rx_non_cfg_phy {
929} __attribute__ ((packed)); 939} __attribute__ ((packed));
930 940
931/* 941/*
932 * REPLY_4965_RX = 0xc3 (response only, not a command) 942 * REPLY_RX = 0xc3 (response only, not a command)
933 * Used only for legacy (non 11n) frames. 943 * Used only for legacy (non 11n) frames.
934 */ 944 */
935#define RX_RES_PHY_CNT 14 945#define RX_RES_PHY_CNT 14
@@ -1045,6 +1055,10 @@ struct iwl4965_rx_mpdu_res_start {
1045 * MAC header) to DWORD boundary. */ 1055 * MAC header) to DWORD boundary. */
1046#define TX_CMD_FLG_MH_PAD_MSK __constant_cpu_to_le32(1 << 20) 1056#define TX_CMD_FLG_MH_PAD_MSK __constant_cpu_to_le32(1 << 20)
1047 1057
1058/* accelerate aggregation support
1059 * 0 - no CCMP encryption; 1 - CCMP encryption */
1060#define TX_CMD_FLG_AGG_CCMP_MSK __constant_cpu_to_le32(1 << 22)
1061
1048/* HCCA-AP - disable duration overwriting. */ 1062/* HCCA-AP - disable duration overwriting. */
1049#define TX_CMD_FLG_DUR_MSK __constant_cpu_to_le32(1 << 25) 1063#define TX_CMD_FLG_DUR_MSK __constant_cpu_to_le32(1 << 25)
1050 1064
@@ -2650,7 +2664,7 @@ struct iwl4965_led_cmd {
2650 2664
2651struct iwl4965_rx_packet { 2665struct iwl4965_rx_packet {
2652 __le32 len; 2666 __le32 len;
2653 struct iwl4965_cmd_header hdr; 2667 struct iwl_cmd_header hdr;
2654 union { 2668 union {
2655 struct iwl4965_alive_resp alive_frame; 2669 struct iwl4965_alive_resp alive_frame;
2656 struct iwl4965_rx_frame rx_frame; 2670 struct iwl4965_rx_frame rx_frame;
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
index c66993eb5b6a..1898888e71f2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
@@ -113,9 +113,6 @@
113#define TFD_TX_CMD_SLOTS 256 113#define TFD_TX_CMD_SLOTS 256
114#define TFD_CMD_SLOTS 32 114#define TFD_CMD_SLOTS 32
115 115
116#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl4965_cmd) - \
117 sizeof(struct iwl4965_cmd_meta))
118
119/* 116/*
120 * RX related structures and functions 117 * RX related structures and functions
121 */ 118 */
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-io.h b/drivers/net/wireless/iwlwifi/iwl-4965-io.h
index 07fca8888f40..fba7d03d4291 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-io.h
@@ -31,7 +31,7 @@
31 31
32#include <linux/io.h> 32#include <linux/io.h>
33 33
34#include "iwl-4965-debug.h" 34#include "iwl-debug.h"
35 35
36/* 36/*
37 * IO, register, and NIC memory access functions 37 * IO, register, and NIC memory access functions
@@ -60,8 +60,8 @@
60 */ 60 */
61 61
62#define _iwl4965_write32(priv, ofs, val) writel((val), (priv)->hw_base + (ofs)) 62#define _iwl4965_write32(priv, ofs, val) writel((val), (priv)->hw_base + (ofs))
63#ifdef CONFIG_IWL4965_DEBUG 63#ifdef CONFIG_IWLWIFI_DEBUG
64static inline void __iwl4965_write32(const char *f, u32 l, struct iwl4965_priv *priv, 64static inline void __iwl4965_write32(const char *f, u32 l, struct iwl_priv *priv,
65 u32 ofs, u32 val) 65 u32 ofs, u32 val)
66{ 66{
67 IWL_DEBUG_IO("write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); 67 IWL_DEBUG_IO("write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l);
@@ -74,8 +74,8 @@ static inline void __iwl4965_write32(const char *f, u32 l, struct iwl4965_priv *
74#endif 74#endif
75 75
76#define _iwl4965_read32(priv, ofs) readl((priv)->hw_base + (ofs)) 76#define _iwl4965_read32(priv, ofs) readl((priv)->hw_base + (ofs))
77#ifdef CONFIG_IWL4965_DEBUG 77#ifdef CONFIG_IWLWIFI_DEBUG
78static inline u32 __iwl4965_read32(char *f, u32 l, struct iwl4965_priv *priv, u32 ofs) 78static inline u32 __iwl4965_read32(char *f, u32 l, struct iwl_priv *priv, u32 ofs)
79{ 79{
80 IWL_DEBUG_IO("read_direct32(0x%08X) - %s %d\n", ofs, f, l); 80 IWL_DEBUG_IO("read_direct32(0x%08X) - %s %d\n", ofs, f, l);
81 return _iwl4965_read32(priv, ofs); 81 return _iwl4965_read32(priv, ofs);
@@ -85,7 +85,7 @@ static inline u32 __iwl4965_read32(char *f, u32 l, struct iwl4965_priv *priv, u3
85#define iwl4965_read32(p, o) _iwl4965_read32(p, o) 85#define iwl4965_read32(p, o) _iwl4965_read32(p, o)
86#endif 86#endif
87 87
88static inline int _iwl4965_poll_bit(struct iwl4965_priv *priv, u32 addr, 88static inline int _iwl4965_poll_bit(struct iwl_priv *priv, u32 addr,
89 u32 bits, u32 mask, int timeout) 89 u32 bits, u32 mask, int timeout)
90{ 90{
91 int i = 0; 91 int i = 0;
@@ -99,9 +99,9 @@ static inline int _iwl4965_poll_bit(struct iwl4965_priv *priv, u32 addr,
99 99
100 return -ETIMEDOUT; 100 return -ETIMEDOUT;
101} 101}
102#ifdef CONFIG_IWL4965_DEBUG 102#ifdef CONFIG_IWLWIFI_DEBUG
103static inline int __iwl4965_poll_bit(const char *f, u32 l, 103static inline int __iwl4965_poll_bit(const char *f, u32 l,
104 struct iwl4965_priv *priv, u32 addr, 104 struct iwl_priv *priv, u32 addr,
105 u32 bits, u32 mask, int timeout) 105 u32 bits, u32 mask, int timeout)
106{ 106{
107 int ret = _iwl4965_poll_bit(priv, addr, bits, mask, timeout); 107 int ret = _iwl4965_poll_bit(priv, addr, bits, mask, timeout);
@@ -116,13 +116,13 @@ static inline int __iwl4965_poll_bit(const char *f, u32 l,
116#define iwl4965_poll_bit(p, a, b, m, t) _iwl4965_poll_bit(p, a, b, m, t) 116#define iwl4965_poll_bit(p, a, b, m, t) _iwl4965_poll_bit(p, a, b, m, t)
117#endif 117#endif
118 118
119static inline void _iwl4965_set_bit(struct iwl4965_priv *priv, u32 reg, u32 mask) 119static inline void _iwl4965_set_bit(struct iwl_priv *priv, u32 reg, u32 mask)
120{ 120{
121 _iwl4965_write32(priv, reg, _iwl4965_read32(priv, reg) | mask); 121 _iwl4965_write32(priv, reg, _iwl4965_read32(priv, reg) | mask);
122} 122}
123#ifdef CONFIG_IWL4965_DEBUG 123#ifdef CONFIG_IWLWIFI_DEBUG
124static inline void __iwl4965_set_bit(const char *f, u32 l, 124static inline void __iwl4965_set_bit(const char *f, u32 l,
125 struct iwl4965_priv *priv, u32 reg, u32 mask) 125 struct iwl_priv *priv, u32 reg, u32 mask)
126{ 126{
127 u32 val = _iwl4965_read32(priv, reg) | mask; 127 u32 val = _iwl4965_read32(priv, reg) | mask;
128 IWL_DEBUG_IO("set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); 128 IWL_DEBUG_IO("set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
@@ -133,13 +133,13 @@ static inline void __iwl4965_set_bit(const char *f, u32 l,
133#define iwl4965_set_bit(p, r, m) _iwl4965_set_bit(p, r, m) 133#define iwl4965_set_bit(p, r, m) _iwl4965_set_bit(p, r, m)
134#endif 134#endif
135 135
136static inline void _iwl4965_clear_bit(struct iwl4965_priv *priv, u32 reg, u32 mask) 136static inline void _iwl4965_clear_bit(struct iwl_priv *priv, u32 reg, u32 mask)
137{ 137{
138 _iwl4965_write32(priv, reg, _iwl4965_read32(priv, reg) & ~mask); 138 _iwl4965_write32(priv, reg, _iwl4965_read32(priv, reg) & ~mask);
139} 139}
140#ifdef CONFIG_IWL4965_DEBUG 140#ifdef CONFIG_IWLWIFI_DEBUG
141static inline void __iwl4965_clear_bit(const char *f, u32 l, 141static inline void __iwl4965_clear_bit(const char *f, u32 l,
142 struct iwl4965_priv *priv, u32 reg, u32 mask) 142 struct iwl_priv *priv, u32 reg, u32 mask)
143{ 143{
144 u32 val = _iwl4965_read32(priv, reg) & ~mask; 144 u32 val = _iwl4965_read32(priv, reg) & ~mask;
145 IWL_DEBUG_IO("clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); 145 IWL_DEBUG_IO("clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
@@ -150,12 +150,12 @@ static inline void __iwl4965_clear_bit(const char *f, u32 l,
150#define iwl4965_clear_bit(p, r, m) _iwl4965_clear_bit(p, r, m) 150#define iwl4965_clear_bit(p, r, m) _iwl4965_clear_bit(p, r, m)
151#endif 151#endif
152 152
153static inline int _iwl4965_grab_nic_access(struct iwl4965_priv *priv) 153static inline int _iwl4965_grab_nic_access(struct iwl_priv *priv)
154{ 154{
155 int ret; 155 int ret;
156 u32 gp_ctl; 156 u32 gp_ctl;
157 157
158#ifdef CONFIG_IWL4965_DEBUG 158#ifdef CONFIG_IWLWIFI_DEBUG
159 if (atomic_read(&priv->restrict_refcnt)) 159 if (atomic_read(&priv->restrict_refcnt))
160 return 0; 160 return 0;
161#endif 161#endif
@@ -186,15 +186,15 @@ static inline int _iwl4965_grab_nic_access(struct iwl4965_priv *priv)
186 return -EIO; 186 return -EIO;
187 } 187 }
188 188
189#ifdef CONFIG_IWL4965_DEBUG 189#ifdef CONFIG_IWLWIFI_DEBUG
190 atomic_inc(&priv->restrict_refcnt); 190 atomic_inc(&priv->restrict_refcnt);
191#endif 191#endif
192 return 0; 192 return 0;
193} 193}
194 194
195#ifdef CONFIG_IWL4965_DEBUG 195#ifdef CONFIG_IWLWIFI_DEBUG
196static inline int __iwl4965_grab_nic_access(const char *f, u32 l, 196static inline int __iwl4965_grab_nic_access(const char *f, u32 l,
197 struct iwl4965_priv *priv) 197 struct iwl_priv *priv)
198{ 198{
199 if (atomic_read(&priv->restrict_refcnt)) 199 if (atomic_read(&priv->restrict_refcnt))
200 IWL_DEBUG_INFO("Grabbing access while already held at " 200 IWL_DEBUG_INFO("Grabbing access while already held at "
@@ -210,17 +210,17 @@ static inline int __iwl4965_grab_nic_access(const char *f, u32 l,
210 _iwl4965_grab_nic_access(priv) 210 _iwl4965_grab_nic_access(priv)
211#endif 211#endif
212 212
213static inline void _iwl4965_release_nic_access(struct iwl4965_priv *priv) 213static inline void _iwl4965_release_nic_access(struct iwl_priv *priv)
214{ 214{
215#ifdef CONFIG_IWL4965_DEBUG 215#ifdef CONFIG_IWLWIFI_DEBUG
216 if (atomic_dec_and_test(&priv->restrict_refcnt)) 216 if (atomic_dec_and_test(&priv->restrict_refcnt))
217#endif 217#endif
218 _iwl4965_clear_bit(priv, CSR_GP_CNTRL, 218 _iwl4965_clear_bit(priv, CSR_GP_CNTRL,
219 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); 219 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
220} 220}
221#ifdef CONFIG_IWL4965_DEBUG 221#ifdef CONFIG_IWLWIFI_DEBUG
222static inline void __iwl4965_release_nic_access(const char *f, u32 l, 222static inline void __iwl4965_release_nic_access(const char *f, u32 l,
223 struct iwl4965_priv *priv) 223 struct iwl_priv *priv)
224{ 224{
225 if (atomic_read(&priv->restrict_refcnt) <= 0) 225 if (atomic_read(&priv->restrict_refcnt) <= 0)
226 IWL_ERROR("Release unheld nic access at line %d.\n", l); 226 IWL_ERROR("Release unheld nic access at line %d.\n", l);
@@ -235,13 +235,13 @@ static inline void __iwl4965_release_nic_access(const char *f, u32 l,
235 _iwl4965_release_nic_access(priv) 235 _iwl4965_release_nic_access(priv)
236#endif 236#endif
237 237
238static inline u32 _iwl4965_read_direct32(struct iwl4965_priv *priv, u32 reg) 238static inline u32 _iwl4965_read_direct32(struct iwl_priv *priv, u32 reg)
239{ 239{
240 return _iwl4965_read32(priv, reg); 240 return _iwl4965_read32(priv, reg);
241} 241}
242#ifdef CONFIG_IWL4965_DEBUG 242#ifdef CONFIG_IWLWIFI_DEBUG
243static inline u32 __iwl4965_read_direct32(const char *f, u32 l, 243static inline u32 __iwl4965_read_direct32(const char *f, u32 l,
244 struct iwl4965_priv *priv, u32 reg) 244 struct iwl_priv *priv, u32 reg)
245{ 245{
246 u32 value = _iwl4965_read_direct32(priv, reg); 246 u32 value = _iwl4965_read_direct32(priv, reg);
247 if (!atomic_read(&priv->restrict_refcnt)) 247 if (!atomic_read(&priv->restrict_refcnt))
@@ -256,14 +256,14 @@ static inline u32 __iwl4965_read_direct32(const char *f, u32 l,
256#define iwl4965_read_direct32 _iwl4965_read_direct32 256#define iwl4965_read_direct32 _iwl4965_read_direct32
257#endif 257#endif
258 258
259static inline void _iwl4965_write_direct32(struct iwl4965_priv *priv, 259static inline void _iwl4965_write_direct32(struct iwl_priv *priv,
260 u32 reg, u32 value) 260 u32 reg, u32 value)
261{ 261{
262 _iwl4965_write32(priv, reg, value); 262 _iwl4965_write32(priv, reg, value);
263} 263}
264#ifdef CONFIG_IWL4965_DEBUG 264#ifdef CONFIG_IWLWIFI_DEBUG
265static void __iwl4965_write_direct32(u32 line, 265static void __iwl4965_write_direct32(u32 line,
266 struct iwl4965_priv *priv, u32 reg, u32 value) 266 struct iwl_priv *priv, u32 reg, u32 value)
267{ 267{
268 if (!atomic_read(&priv->restrict_refcnt)) 268 if (!atomic_read(&priv->restrict_refcnt))
269 IWL_ERROR("Nic access not held from line %d\n", line); 269 IWL_ERROR("Nic access not held from line %d\n", line);
@@ -275,7 +275,7 @@ static void __iwl4965_write_direct32(u32 line,
275#define iwl4965_write_direct32 _iwl4965_write_direct32 275#define iwl4965_write_direct32 _iwl4965_write_direct32
276#endif 276#endif
277 277
278static inline void iwl4965_write_reg_buf(struct iwl4965_priv *priv, 278static inline void iwl4965_write_reg_buf(struct iwl_priv *priv,
279 u32 reg, u32 len, u32 *values) 279 u32 reg, u32 len, u32 *values)
280{ 280{
281 u32 count = sizeof(u32); 281 u32 count = sizeof(u32);
@@ -286,7 +286,7 @@ static inline void iwl4965_write_reg_buf(struct iwl4965_priv *priv,
286 } 286 }
287} 287}
288 288
289static inline int _iwl4965_poll_direct_bit(struct iwl4965_priv *priv, 289static inline int _iwl4965_poll_direct_bit(struct iwl_priv *priv,
290 u32 addr, u32 mask, int timeout) 290 u32 addr, u32 mask, int timeout)
291{ 291{
292 int i = 0; 292 int i = 0;
@@ -301,9 +301,9 @@ static inline int _iwl4965_poll_direct_bit(struct iwl4965_priv *priv,
301 return -ETIMEDOUT; 301 return -ETIMEDOUT;
302} 302}
303 303
304#ifdef CONFIG_IWL4965_DEBUG 304#ifdef CONFIG_IWLWIFI_DEBUG
305static inline int __iwl4965_poll_direct_bit(const char *f, u32 l, 305static inline int __iwl4965_poll_direct_bit(const char *f, u32 l,
306 struct iwl4965_priv *priv, 306 struct iwl_priv *priv,
307 u32 addr, u32 mask, int timeout) 307 u32 addr, u32 mask, int timeout)
308{ 308{
309 int ret = _iwl4965_poll_direct_bit(priv, addr, mask, timeout); 309 int ret = _iwl4965_poll_direct_bit(priv, addr, mask, timeout);
@@ -322,13 +322,13 @@ static inline int __iwl4965_poll_direct_bit(const char *f, u32 l,
322#define iwl4965_poll_direct_bit _iwl4965_poll_direct_bit 322#define iwl4965_poll_direct_bit _iwl4965_poll_direct_bit
323#endif 323#endif
324 324
325static inline u32 _iwl4965_read_prph(struct iwl4965_priv *priv, u32 reg) 325static inline u32 _iwl4965_read_prph(struct iwl_priv *priv, u32 reg)
326{ 326{
327 _iwl4965_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); 327 _iwl4965_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
328 return _iwl4965_read_direct32(priv, HBUS_TARG_PRPH_RDAT); 328 return _iwl4965_read_direct32(priv, HBUS_TARG_PRPH_RDAT);
329} 329}
330#ifdef CONFIG_IWL4965_DEBUG 330#ifdef CONFIG_IWLWIFI_DEBUG
331static inline u32 __iwl4965_read_prph(u32 line, struct iwl4965_priv *priv, u32 reg) 331static inline u32 __iwl4965_read_prph(u32 line, struct iwl_priv *priv, u32 reg)
332{ 332{
333 if (!atomic_read(&priv->restrict_refcnt)) 333 if (!atomic_read(&priv->restrict_refcnt))
334 IWL_ERROR("Nic access not held from line %d\n", line); 334 IWL_ERROR("Nic access not held from line %d\n", line);
@@ -341,15 +341,15 @@ static inline u32 __iwl4965_read_prph(u32 line, struct iwl4965_priv *priv, u32 r
341#define iwl4965_read_prph _iwl4965_read_prph 341#define iwl4965_read_prph _iwl4965_read_prph
342#endif 342#endif
343 343
344static inline void _iwl4965_write_prph(struct iwl4965_priv *priv, 344static inline void _iwl4965_write_prph(struct iwl_priv *priv,
345 u32 addr, u32 val) 345 u32 addr, u32 val)
346{ 346{
347 _iwl4965_write_direct32(priv, HBUS_TARG_PRPH_WADDR, 347 _iwl4965_write_direct32(priv, HBUS_TARG_PRPH_WADDR,
348 ((addr & 0x0000FFFF) | (3 << 24))); 348 ((addr & 0x0000FFFF) | (3 << 24)));
349 _iwl4965_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val); 349 _iwl4965_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val);
350} 350}
351#ifdef CONFIG_IWL4965_DEBUG 351#ifdef CONFIG_IWLWIFI_DEBUG
352static inline void __iwl4965_write_prph(u32 line, struct iwl4965_priv *priv, 352static inline void __iwl4965_write_prph(u32 line, struct iwl_priv *priv,
353 u32 addr, u32 val) 353 u32 addr, u32 val)
354{ 354{
355 if (!atomic_read(&priv->restrict_refcnt)) 355 if (!atomic_read(&priv->restrict_refcnt))
@@ -365,8 +365,8 @@ static inline void __iwl4965_write_prph(u32 line, struct iwl4965_priv *priv,
365 365
366#define _iwl4965_set_bits_prph(priv, reg, mask) \ 366#define _iwl4965_set_bits_prph(priv, reg, mask) \
367 _iwl4965_write_prph(priv, reg, (_iwl4965_read_prph(priv, reg) | mask)) 367 _iwl4965_write_prph(priv, reg, (_iwl4965_read_prph(priv, reg) | mask))
368#ifdef CONFIG_IWL4965_DEBUG 368#ifdef CONFIG_IWLWIFI_DEBUG
369static inline void __iwl4965_set_bits_prph(u32 line, struct iwl4965_priv *priv, 369static inline void __iwl4965_set_bits_prph(u32 line, struct iwl_priv *priv,
370 u32 reg, u32 mask) 370 u32 reg, u32 mask)
371{ 371{
372 if (!atomic_read(&priv->restrict_refcnt)) 372 if (!atomic_read(&priv->restrict_refcnt))
@@ -383,9 +383,9 @@ static inline void __iwl4965_set_bits_prph(u32 line, struct iwl4965_priv *priv,
383#define _iwl4965_set_bits_mask_prph(priv, reg, bits, mask) \ 383#define _iwl4965_set_bits_mask_prph(priv, reg, bits, mask) \
384 _iwl4965_write_prph(priv, reg, ((_iwl4965_read_prph(priv, reg) & mask) | bits)) 384 _iwl4965_write_prph(priv, reg, ((_iwl4965_read_prph(priv, reg) & mask) | bits))
385 385
386#ifdef CONFIG_IWL4965_DEBUG 386#ifdef CONFIG_IWLWIFI_DEBUG
387static inline void __iwl4965_set_bits_mask_prph(u32 line, 387static inline void __iwl4965_set_bits_mask_prph(u32 line,
388 struct iwl4965_priv *priv, u32 reg, u32 bits, u32 mask) 388 struct iwl_priv *priv, u32 reg, u32 bits, u32 mask)
389{ 389{
390 if (!atomic_read(&priv->restrict_refcnt)) 390 if (!atomic_read(&priv->restrict_refcnt))
391 IWL_ERROR("Nic access not held from line %d\n", line); 391 IWL_ERROR("Nic access not held from line %d\n", line);
@@ -397,26 +397,26 @@ static inline void __iwl4965_set_bits_mask_prph(u32 line,
397#define iwl4965_set_bits_mask_prph _iwl4965_set_bits_mask_prph 397#define iwl4965_set_bits_mask_prph _iwl4965_set_bits_mask_prph
398#endif 398#endif
399 399
400static inline void iwl4965_clear_bits_prph(struct iwl4965_priv 400static inline void iwl4965_clear_bits_prph(struct iwl_priv
401 *priv, u32 reg, u32 mask) 401 *priv, u32 reg, u32 mask)
402{ 402{
403 u32 val = _iwl4965_read_prph(priv, reg); 403 u32 val = _iwl4965_read_prph(priv, reg);
404 _iwl4965_write_prph(priv, reg, (val & ~mask)); 404 _iwl4965_write_prph(priv, reg, (val & ~mask));
405} 405}
406 406
407static inline u32 iwl4965_read_targ_mem(struct iwl4965_priv *priv, u32 addr) 407static inline u32 iwl4965_read_targ_mem(struct iwl_priv *priv, u32 addr)
408{ 408{
409 iwl4965_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr); 409 iwl4965_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr);
410 return iwl4965_read_direct32(priv, HBUS_TARG_MEM_RDAT); 410 return iwl4965_read_direct32(priv, HBUS_TARG_MEM_RDAT);
411} 411}
412 412
413static inline void iwl4965_write_targ_mem(struct iwl4965_priv *priv, u32 addr, u32 val) 413static inline void iwl4965_write_targ_mem(struct iwl_priv *priv, u32 addr, u32 val)
414{ 414{
415 iwl4965_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); 415 iwl4965_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
416 iwl4965_write_direct32(priv, HBUS_TARG_MEM_WDAT, val); 416 iwl4965_write_direct32(priv, HBUS_TARG_MEM_WDAT, val);
417} 417}
418 418
419static inline void iwl4965_write_targ_mem_buf(struct iwl4965_priv *priv, u32 addr, 419static inline void iwl4965_write_targ_mem_buf(struct iwl_priv *priv, u32 addr,
420 u32 len, u32 *values) 420 u32 len, u32 *values)
421{ 421{
422 iwl4965_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); 422 iwl4965_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
index 4b46226ff350..7d7ce7489ab5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
@@ -39,6 +39,7 @@
39#include "../net/mac80211/ieee80211_rate.h" 39#include "../net/mac80211/ieee80211_rate.h"
40 40
41#include "iwl-4965.h" 41#include "iwl-4965.h"
42#include "iwl-core.h"
42#include "iwl-helpers.h" 43#include "iwl-helpers.h"
43 44
44#define RS_NAME "iwl-4965-rs" 45#define RS_NAME "iwl-4965-rs"
@@ -162,11 +163,11 @@ struct iwl4965_lq_sta {
162 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; 163 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file;
163#endif 164#endif
164 struct iwl4965_rate dbg_fixed; 165 struct iwl4965_rate dbg_fixed;
165 struct iwl4965_priv *drv; 166 struct iwl_priv *drv;
166#endif 167#endif
167}; 168};
168 169
169static void rs_rate_scale_perform(struct iwl4965_priv *priv, 170static void rs_rate_scale_perform(struct iwl_priv *priv,
170 struct net_device *dev, 171 struct net_device *dev,
171 struct ieee80211_hdr *hdr, 172 struct ieee80211_hdr *hdr,
172 struct sta_info *sta); 173 struct sta_info *sta);
@@ -229,8 +230,8 @@ static s32 expected_tpt_mimo40MHzSGI[IWL_RATE_COUNT] = {
229 0, 0, 0, 0, 131, 131, 191, 222, 242, 270, 284, 289, 293 230 0, 0, 0, 0, 131, 131, 191, 222, 242, 270, 284, 289, 293
230}; 231};
231 232
232static int iwl4965_lq_sync_callback(struct iwl4965_priv *priv, 233static int iwl4965_lq_sync_callback(struct iwl_priv *priv,
233 struct iwl4965_cmd *cmd, struct sk_buff *skb) 234 struct iwl_cmd *cmd, struct sk_buff *skb)
234{ 235{
235 /*We didn't cache the SKB; let the caller free it */ 236 /*We didn't cache the SKB; let the caller free it */
236 return 1; 237 return 1;
@@ -241,13 +242,13 @@ static inline u8 iwl4965_rate_get_rate(u32 rate_n_flags)
241 return (u8)(rate_n_flags & 0xFF); 242 return (u8)(rate_n_flags & 0xFF);
242} 243}
243 244
244static int rs_send_lq_cmd(struct iwl4965_priv *priv, 245static int rs_send_lq_cmd(struct iwl_priv *priv,
245 struct iwl4965_link_quality_cmd *lq, u8 flags) 246 struct iwl4965_link_quality_cmd *lq, u8 flags)
246{ 247{
247#ifdef CONFIG_IWL4965_DEBUG 248#ifdef CONFIG_IWLWIFI_DEBUG
248 int i; 249 int i;
249#endif 250#endif
250 struct iwl4965_host_cmd cmd = { 251 struct iwl_host_cmd cmd = {
251 .id = REPLY_TX_LINK_QUALITY_CMD, 252 .id = REPLY_TX_LINK_QUALITY_CMD,
252 .len = sizeof(struct iwl4965_link_quality_cmd), 253 .len = sizeof(struct iwl4965_link_quality_cmd),
253 .meta.flags = flags, 254 .meta.flags = flags,
@@ -265,7 +266,7 @@ static int rs_send_lq_cmd(struct iwl4965_priv *priv,
265 IWL_DEBUG_RATE("lq dta 0x%X 0x%X\n", 266 IWL_DEBUG_RATE("lq dta 0x%X 0x%X\n",
266 lq->general_params.single_stream_ant_msk, 267 lq->general_params.single_stream_ant_msk,
267 lq->general_params.dual_stream_ant_msk); 268 lq->general_params.dual_stream_ant_msk);
268#ifdef CONFIG_IWL4965_DEBUG 269#ifdef CONFIG_IWLWIFI_DEBUG
269 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) 270 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++)
270 IWL_DEBUG_RATE("lq index %d 0x%X\n", 271 IWL_DEBUG_RATE("lq index %d 0x%X\n",
271 i, lq->rs_table[i].rate_n_flags); 272 i, lq->rs_table[i].rate_n_flags);
@@ -276,7 +277,7 @@ static int rs_send_lq_cmd(struct iwl4965_priv *priv,
276 277
277 if (iwl4965_is_associated(priv) && priv->assoc_station_added && 278 if (iwl4965_is_associated(priv) && priv->assoc_station_added &&
278 priv->lq_mngr.lq_ready) 279 priv->lq_mngr.lq_ready)
279 return iwl4965_send_cmd(priv, &cmd); 280 return iwl_send_cmd(priv, &cmd);
280 281
281 return 0; 282 return 0;
282} 283}
@@ -388,7 +389,7 @@ static u32 rs_tl_get_load(struct iwl4965_lq_sta *lq_data, u8 tid)
388 return tl->total; 389 return tl->total;
389} 390}
390 391
391static void rs_tl_turn_on_agg_for_tid(struct iwl4965_priv *priv, 392static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
392 struct iwl4965_lq_sta *lq_data, u8 tid, 393 struct iwl4965_lq_sta *lq_data, u8 tid,
393 struct sta_info *sta) 394 struct sta_info *sta)
394{ 395{
@@ -407,7 +408,7 @@ static void rs_tl_turn_on_agg_for_tid(struct iwl4965_priv *priv,
407 } 408 }
408} 409}
409 410
410static void rs_tl_turn_on_agg(struct iwl4965_priv *priv, u8 tid, 411static void rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid,
411 struct iwl4965_lq_sta *lq_data, 412 struct iwl4965_lq_sta *lq_data,
412 struct sta_info *sta) 413 struct sta_info *sta)
413{ 414{
@@ -658,7 +659,7 @@ static inline void rs_toggle_antenna(struct iwl4965_rate *new_rate,
658 } 659 }
659} 660}
660 661
661static inline u8 rs_use_green(struct iwl4965_priv *priv, 662static inline u8 rs_use_green(struct iwl_priv *priv,
662 struct ieee80211_conf *conf) 663 struct ieee80211_conf *conf)
663{ 664{
664#ifdef CONFIG_IWL4965_HT 665#ifdef CONFIG_IWL4965_HT
@@ -821,7 +822,7 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
821 struct iwl4965_link_quality_cmd *table; 822 struct iwl4965_link_quality_cmd *table;
822 struct sta_info *sta; 823 struct sta_info *sta;
823 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 824 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
824 struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; 825 struct iwl_priv *priv = (struct iwl_priv *)priv_rate;
825 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 826 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
826 struct ieee80211_hw *hw = local_to_hw(local); 827 struct ieee80211_hw *hw = local_to_hw(local);
827 struct iwl4965_rate_scale_data *window = NULL; 828 struct iwl4965_rate_scale_data *window = NULL;
@@ -1128,7 +1129,7 @@ static void rs_get_expected_tpt_table(struct iwl4965_lq_sta *lq_sta,
1128 * to decrease to match "active" throughput. When moving from MIMO to SISO, 1129 * to decrease to match "active" throughput. When moving from MIMO to SISO,
1129 * bit rate will typically need to increase, but not if performance was bad. 1130 * bit rate will typically need to increase, but not if performance was bad.
1130 */ 1131 */
1131static s32 rs_get_best_rate(struct iwl4965_priv *priv, 1132static s32 rs_get_best_rate(struct iwl_priv *priv,
1132 struct iwl4965_lq_sta *lq_sta, 1133 struct iwl4965_lq_sta *lq_sta,
1133 struct iwl4965_scale_tbl_info *tbl, /* "search" */ 1134 struct iwl4965_scale_tbl_info *tbl, /* "search" */
1134 u16 rate_mask, s8 index, s8 rate) 1135 u16 rate_mask, s8 index, s8 rate)
@@ -1226,7 +1227,7 @@ static inline u8 rs_is_both_ant_supp(u8 valid_antenna)
1226/* 1227/*
1227 * Set up search table for MIMO 1228 * Set up search table for MIMO
1228 */ 1229 */
1229static int rs_switch_to_mimo(struct iwl4965_priv *priv, 1230static int rs_switch_to_mimo(struct iwl_priv *priv,
1230 struct iwl4965_lq_sta *lq_sta, 1231 struct iwl4965_lq_sta *lq_sta,
1231 struct ieee80211_conf *conf, 1232 struct ieee80211_conf *conf,
1232 struct sta_info *sta, 1233 struct sta_info *sta,
@@ -1291,7 +1292,7 @@ static int rs_switch_to_mimo(struct iwl4965_priv *priv,
1291/* 1292/*
1292 * Set up search table for SISO 1293 * Set up search table for SISO
1293 */ 1294 */
1294static int rs_switch_to_siso(struct iwl4965_priv *priv, 1295static int rs_switch_to_siso(struct iwl_priv *priv,
1295 struct iwl4965_lq_sta *lq_sta, 1296 struct iwl4965_lq_sta *lq_sta,
1296 struct ieee80211_conf *conf, 1297 struct ieee80211_conf *conf,
1297 struct sta_info *sta, 1298 struct sta_info *sta,
@@ -1354,7 +1355,7 @@ static int rs_switch_to_siso(struct iwl4965_priv *priv,
1354/* 1355/*
1355 * Try to switch to new modulation mode from legacy 1356 * Try to switch to new modulation mode from legacy
1356 */ 1357 */
1357static int rs_move_legacy_other(struct iwl4965_priv *priv, 1358static int rs_move_legacy_other(struct iwl_priv *priv,
1358 struct iwl4965_lq_sta *lq_sta, 1359 struct iwl4965_lq_sta *lq_sta,
1359 struct ieee80211_conf *conf, 1360 struct ieee80211_conf *conf,
1360 struct sta_info *sta, 1361 struct sta_info *sta,
@@ -1452,7 +1453,7 @@ static int rs_move_legacy_other(struct iwl4965_priv *priv,
1452/* 1453/*
1453 * Try to switch to new modulation mode from SISO 1454 * Try to switch to new modulation mode from SISO
1454 */ 1455 */
1455static int rs_move_siso_to_other(struct iwl4965_priv *priv, 1456static int rs_move_siso_to_other(struct iwl_priv *priv,
1456 struct iwl4965_lq_sta *lq_sta, 1457 struct iwl4965_lq_sta *lq_sta,
1457 struct ieee80211_conf *conf, 1458 struct ieee80211_conf *conf,
1458 struct sta_info *sta, 1459 struct sta_info *sta,
@@ -1548,7 +1549,7 @@ static int rs_move_siso_to_other(struct iwl4965_priv *priv,
1548/* 1549/*
1549 * Try to switch to new modulation mode from MIMO 1550 * Try to switch to new modulation mode from MIMO
1550 */ 1551 */
1551static int rs_move_mimo_to_other(struct iwl4965_priv *priv, 1552static int rs_move_mimo_to_other(struct iwl_priv *priv,
1552 struct iwl4965_lq_sta *lq_sta, 1553 struct iwl4965_lq_sta *lq_sta,
1553 struct ieee80211_conf *conf, 1554 struct ieee80211_conf *conf,
1554 struct sta_info *sta, 1555 struct sta_info *sta,
@@ -1728,7 +1729,7 @@ static void rs_stay_in_table(struct iwl4965_lq_sta *lq_sta)
1728/* 1729/*
1729 * Do rate scaling and search for new modulation mode. 1730 * Do rate scaling and search for new modulation mode.
1730 */ 1731 */
1731static void rs_rate_scale_perform(struct iwl4965_priv *priv, 1732static void rs_rate_scale_perform(struct iwl_priv *priv,
1732 struct net_device *dev, 1733 struct net_device *dev,
1733 struct ieee80211_hdr *hdr, 1734 struct ieee80211_hdr *hdr,
1734 struct sta_info *sta) 1735 struct sta_info *sta)
@@ -2148,7 +2149,7 @@ out:
2148} 2149}
2149 2150
2150 2151
2151static void rs_initialize_lq(struct iwl4965_priv *priv, 2152static void rs_initialize_lq(struct iwl_priv *priv,
2152 struct ieee80211_conf *conf, 2153 struct ieee80211_conf *conf,
2153 struct sta_info *sta) 2154 struct sta_info *sta)
2154{ 2155{
@@ -2213,7 +2214,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
2213 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 2214 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2214 struct sta_info *sta; 2215 struct sta_info *sta;
2215 u16 fc; 2216 u16 fc;
2216 struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; 2217 struct iwl_priv *priv = (struct iwl_priv *)priv_rate;
2217 struct iwl4965_lq_sta *lq_sta; 2218 struct iwl4965_lq_sta *lq_sta;
2218 2219
2219 IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n"); 2220 IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n");
@@ -2294,7 +2295,7 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
2294 int i, j; 2295 int i, j;
2295 struct ieee80211_conf *conf = &local->hw.conf; 2296 struct ieee80211_conf *conf = &local->hw.conf;
2296 struct ieee80211_supported_band *sband; 2297 struct ieee80211_supported_band *sband;
2297 struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; 2298 struct iwl_priv *priv = (struct iwl_priv *)priv_rate;
2298 struct iwl4965_lq_sta *lq_sta = priv_sta; 2299 struct iwl4965_lq_sta *lq_sta = priv_sta;
2299 2300
2300 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 2301 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
@@ -2516,7 +2517,7 @@ static void rs_free(void *priv_rate)
2516 2517
2517static void rs_clear(void *priv_rate) 2518static void rs_clear(void *priv_rate)
2518{ 2519{
2519 struct iwl4965_priv *priv = (struct iwl4965_priv *) priv_rate; 2520 struct iwl_priv *priv = (struct iwl_priv *) priv_rate;
2520 2521
2521 IWL_DEBUG_RATE("enter\n"); 2522 IWL_DEBUG_RATE("enter\n");
2522 2523
@@ -2726,7 +2727,7 @@ static struct rate_control_ops rs_ops = {
2726int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) 2727int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id)
2727{ 2728{
2728 struct ieee80211_local *local = hw_to_local(hw); 2729 struct ieee80211_local *local = hw_to_local(hw);
2729 struct iwl4965_priv *priv = hw->priv; 2730 struct iwl_priv *priv = hw->priv;
2730 struct iwl4965_lq_sta *lq_sta; 2731 struct iwl4965_lq_sta *lq_sta;
2731 struct sta_info *sta; 2732 struct sta_info *sta;
2732 int cnt = 0, i; 2733 int cnt = 0, i;
@@ -2816,7 +2817,7 @@ int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id)
2816 2817
2817void iwl4965_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) 2818void iwl4965_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
2818{ 2819{
2819 struct iwl4965_priv *priv = hw->priv; 2820 struct iwl_priv *priv = hw->priv;
2820 2821
2821 priv->lq_mngr.lq_ready = 1; 2822 priv->lq_mngr.lq_ready = 1;
2822} 2823}
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 3401f2a30cc5..1db873b02f1e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -43,7 +43,15 @@
43#include "iwl-4965.h" 43#include "iwl-4965.h"
44#include "iwl-helpers.h" 44#include "iwl-helpers.h"
45 45
46static void iwl4965_hw_card_show_info(struct iwl4965_priv *priv); 46/* module parameters */
47static struct iwl_mod_params iwl4965_mod_params = {
48 .num_of_queues = IWL_MAX_NUM_QUEUES,
49 .enable_qos = 1,
50 .amsdu_size_8K = 1,
51 /* the rest are 0 by default */
52};
53
54static void iwl4965_hw_card_show_info(struct iwl_priv *priv);
47 55
48#define IWL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ 56#define IWL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \
49 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ 57 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \
@@ -105,13 +113,97 @@ static const u16 default_tid_to_tx_fifo[] = {
105 113
106#endif /*CONFIG_IWL4965_HT */ 114#endif /*CONFIG_IWL4965_HT */
107 115
116static int iwl4965_init_drv(struct iwl_priv *priv)
117{
118 int ret;
119 int i;
120
121 priv->antenna = (enum iwl4965_antenna)priv->cfg->mod_params->antenna;
122 priv->retry_rate = 1;
123 priv->ibss_beacon = NULL;
124
125 spin_lock_init(&priv->lock);
126 spin_lock_init(&priv->power_data.lock);
127 spin_lock_init(&priv->sta_lock);
128 spin_lock_init(&priv->hcmd_lock);
129 spin_lock_init(&priv->lq_mngr.lock);
130
131 for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++)
132 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
133
134 INIT_LIST_HEAD(&priv->free_frames);
135
136 mutex_init(&priv->mutex);
137
138 /* Clear the driver's (not device's) station table */
139 iwlcore_clear_stations_table(priv);
140
141 priv->data_retry_limit = -1;
142 priv->ieee_channels = NULL;
143 priv->ieee_rates = NULL;
144 priv->band = IEEE80211_BAND_2GHZ;
145
146 priv->iw_mode = IEEE80211_IF_TYPE_STA;
147
148 priv->use_ant_b_for_management_frame = 1; /* start with ant B */
149 priv->valid_antenna = 0x7; /* assume all 3 connected */
150 priv->ps_mode = IWL_MIMO_PS_NONE;
151
152 /* Choose which receivers/antennas to use */
153 iwl4965_set_rxon_chain(priv);
154
155 iwlcore_reset_qos(priv);
156
157 priv->qos_data.qos_active = 0;
158 priv->qos_data.qos_cap.val = 0;
159
160 iwlcore_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6);
161
162 priv->rates_mask = IWL_RATES_MASK;
163 /* If power management is turned on, default to AC mode */
164 priv->power_mode = IWL_POWER_AC;
165 priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
166
167 ret = iwl_init_channel_map(priv);
168 if (ret) {
169 IWL_ERROR("initializing regulatory failed: %d\n", ret);
170 goto err;
171 }
172
173 ret = iwl4965_init_geos(priv);
174 if (ret) {
175 IWL_ERROR("initializing geos failed: %d\n", ret);
176 goto err_free_channel_map;
177 }
178
179 iwl4965_rate_control_register(priv->hw);
180 ret = ieee80211_register_hw(priv->hw);
181 if (ret) {
182 IWL_ERROR("Failed to register network device (error %d)\n",
183 ret);
184 goto err_free_geos;
185 }
186
187 priv->hw->conf.beacon_int = 100;
188 priv->mac80211_registered = 1;
189
190 return 0;
191
192err_free_geos:
193 iwl4965_free_geos(priv);
194err_free_channel_map:
195 iwl_free_channel_map(priv);
196err:
197 return ret;
198}
199
108static int is_fat_channel(__le32 rxon_flags) 200static int is_fat_channel(__le32 rxon_flags)
109{ 201{
110 return (rxon_flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK) || 202 return (rxon_flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK) ||
111 (rxon_flags & RXON_FLG_CHANNEL_MODE_MIXED_MSK); 203 (rxon_flags & RXON_FLG_CHANNEL_MODE_MIXED_MSK);
112} 204}
113 205
114static u8 is_single_stream(struct iwl4965_priv *priv) 206static u8 is_single_stream(struct iwl_priv *priv)
115{ 207{
116#ifdef CONFIG_IWL4965_HT 208#ifdef CONFIG_IWL4965_HT
117 if (!priv->current_ht_config.is_ht || 209 if (!priv->current_ht_config.is_ht ||
@@ -155,7 +247,7 @@ int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags)
155/** 247/**
156 * translate ucode response to mac80211 tx status control values 248 * translate ucode response to mac80211 tx status control values
157 */ 249 */
158void iwl4965_hwrate_to_tx_control(struct iwl4965_priv *priv, u32 rate_n_flags, 250void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
159 struct ieee80211_tx_control *control) 251 struct ieee80211_tx_control *control)
160{ 252{
161 int rate_index; 253 int rate_index;
@@ -188,7 +280,7 @@ void iwl4965_hwrate_to_tx_control(struct iwl4965_priv *priv, u32 rate_n_flags,
188 * MIMO (dual stream) requires at least 2, but works better with 3. 280 * MIMO (dual stream) requires at least 2, but works better with 3.
189 * This does not determine *which* chains to use, just how many. 281 * This does not determine *which* chains to use, just how many.
190 */ 282 */
191static int iwl4965_get_rx_chain_counter(struct iwl4965_priv *priv, 283static int iwl4965_get_rx_chain_counter(struct iwl_priv *priv,
192 u8 *idle_state, u8 *rx_state) 284 u8 *idle_state, u8 *rx_state)
193{ 285{
194 u8 is_single = is_single_stream(priv); 286 u8 is_single = is_single_stream(priv);
@@ -217,7 +309,7 @@ static int iwl4965_get_rx_chain_counter(struct iwl4965_priv *priv,
217 return 0; 309 return 0;
218} 310}
219 311
220int iwl4965_hw_rxq_stop(struct iwl4965_priv *priv) 312int iwl4965_hw_rxq_stop(struct iwl_priv *priv)
221{ 313{
222 int rc; 314 int rc;
223 unsigned long flags; 315 unsigned long flags;
@@ -242,7 +334,7 @@ int iwl4965_hw_rxq_stop(struct iwl4965_priv *priv)
242 return 0; 334 return 0;
243} 335}
244 336
245u8 iwl4965_hw_find_station(struct iwl4965_priv *priv, const u8 *addr) 337u8 iwl4965_hw_find_station(struct iwl_priv *priv, const u8 *addr)
246{ 338{
247 int i; 339 int i;
248 int start = 0; 340 int start = 0;
@@ -274,7 +366,7 @@ u8 iwl4965_hw_find_station(struct iwl4965_priv *priv, const u8 *addr)
274 return ret; 366 return ret;
275} 367}
276 368
277static int iwl4965_nic_set_pwr_src(struct iwl4965_priv *priv, int pwr_max) 369static int iwl4965_nic_set_pwr_src(struct iwl_priv *priv, int pwr_max)
278{ 370{
279 int ret; 371 int ret;
280 unsigned long flags; 372 unsigned long flags;
@@ -307,7 +399,7 @@ static int iwl4965_nic_set_pwr_src(struct iwl4965_priv *priv, int pwr_max)
307 return ret; 399 return ret;
308} 400}
309 401
310static int iwl4965_rx_init(struct iwl4965_priv *priv, struct iwl4965_rx_queue *rxq) 402static int iwl4965_rx_init(struct iwl_priv *priv, struct iwl4965_rx_queue *rxq)
311{ 403{
312 int rc; 404 int rc;
313 unsigned long flags; 405 unsigned long flags;
@@ -320,7 +412,7 @@ static int iwl4965_rx_init(struct iwl4965_priv *priv, struct iwl4965_rx_queue *r
320 return rc; 412 return rc;
321 } 413 }
322 414
323 if (iwl4965_param_amsdu_size_8K) 415 if (priv->cfg->mod_params->amsdu_size_8K)
324 rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; 416 rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K;
325 else 417 else
326 rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; 418 rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K;
@@ -360,7 +452,7 @@ static int iwl4965_rx_init(struct iwl4965_priv *priv, struct iwl4965_rx_queue *r
360} 452}
361 453
362/* Tell 4965 where to find the "keep warm" buffer */ 454/* Tell 4965 where to find the "keep warm" buffer */
363static int iwl4965_kw_init(struct iwl4965_priv *priv) 455static int iwl4965_kw_init(struct iwl_priv *priv)
364{ 456{
365 unsigned long flags; 457 unsigned long flags;
366 int rc; 458 int rc;
@@ -378,7 +470,7 @@ out:
378 return rc; 470 return rc;
379} 471}
380 472
381static int iwl4965_kw_alloc(struct iwl4965_priv *priv) 473static int iwl4965_kw_alloc(struct iwl_priv *priv)
382{ 474{
383 struct pci_dev *dev = priv->pci_dev; 475 struct pci_dev *dev = priv->pci_dev;
384 struct iwl4965_kw *kw = &priv->kw; 476 struct iwl4965_kw *kw = &priv->kw;
@@ -391,59 +483,10 @@ static int iwl4965_kw_alloc(struct iwl4965_priv *priv)
391 return 0; 483 return 0;
392} 484}
393 485
394#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \
395 ? # x " " : "")
396
397/**
398 * iwl4965_set_fat_chan_info - Copy fat channel info into driver's priv.
399 *
400 * Does not set up a command, or touch hardware.
401 */
402int iwl4965_set_fat_chan_info(struct iwl4965_priv *priv,
403 enum ieee80211_band band, u16 channel,
404 const struct iwl4965_eeprom_channel *eeprom_ch,
405 u8 fat_extension_channel)
406{
407 struct iwl4965_channel_info *ch_info;
408
409 ch_info = (struct iwl4965_channel_info *)
410 iwl4965_get_channel_info(priv, band, channel);
411
412 if (!is_channel_valid(ch_info))
413 return -1;
414
415 IWL_DEBUG_INFO("FAT Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x"
416 " %ddBm): Ad-Hoc %ssupported\n",
417 ch_info->channel,
418 is_channel_a_band(ch_info) ?
419 "5.2" : "2.4",
420 CHECK_AND_PRINT(IBSS),
421 CHECK_AND_PRINT(ACTIVE),
422 CHECK_AND_PRINT(RADAR),
423 CHECK_AND_PRINT(WIDE),
424 CHECK_AND_PRINT(NARROW),
425 CHECK_AND_PRINT(DFS),
426 eeprom_ch->flags,
427 eeprom_ch->max_power_avg,
428 ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS)
429 && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ?
430 "" : "not ");
431
432 ch_info->fat_eeprom = *eeprom_ch;
433 ch_info->fat_max_power_avg = eeprom_ch->max_power_avg;
434 ch_info->fat_curr_txpow = eeprom_ch->max_power_avg;
435 ch_info->fat_min_power = 0;
436 ch_info->fat_scan_power = eeprom_ch->max_power_avg;
437 ch_info->fat_flags = eeprom_ch->flags;
438 ch_info->fat_extension_channel = fat_extension_channel;
439
440 return 0;
441}
442
443/** 486/**
444 * iwl4965_kw_free - Free the "keep warm" buffer 487 * iwl4965_kw_free - Free the "keep warm" buffer
445 */ 488 */
446static void iwl4965_kw_free(struct iwl4965_priv *priv) 489static void iwl4965_kw_free(struct iwl_priv *priv)
447{ 490{
448 struct pci_dev *dev = priv->pci_dev; 491 struct pci_dev *dev = priv->pci_dev;
449 struct iwl4965_kw *kw = &priv->kw; 492 struct iwl4965_kw *kw = &priv->kw;
@@ -461,7 +504,7 @@ static void iwl4965_kw_free(struct iwl4965_priv *priv)
461 * @param priv 504 * @param priv
462 * @return error code 505 * @return error code
463 */ 506 */
464static int iwl4965_txq_ctx_reset(struct iwl4965_priv *priv) 507static int iwl4965_txq_ctx_reset(struct iwl_priv *priv)
465{ 508{
466 int rc = 0; 509 int rc = 0;
467 int txq_id, slots_num; 510 int txq_id, slots_num;
@@ -523,7 +566,7 @@ static int iwl4965_txq_ctx_reset(struct iwl4965_priv *priv)
523 return rc; 566 return rc;
524} 567}
525 568
526int iwl4965_hw_nic_init(struct iwl4965_priv *priv) 569int iwl4965_hw_nic_init(struct iwl_priv *priv)
527{ 570{
528 int rc; 571 int rc;
529 unsigned long flags; 572 unsigned long flags;
@@ -668,7 +711,7 @@ int iwl4965_hw_nic_init(struct iwl4965_priv *priv)
668 return 0; 711 return 0;
669} 712}
670 713
671int iwl4965_hw_nic_stop_master(struct iwl4965_priv *priv) 714int iwl4965_hw_nic_stop_master(struct iwl_priv *priv)
672{ 715{
673 int rc = 0; 716 int rc = 0;
674 u32 reg_val; 717 u32 reg_val;
@@ -704,7 +747,7 @@ int iwl4965_hw_nic_stop_master(struct iwl4965_priv *priv)
704/** 747/**
705 * iwl4965_hw_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory 748 * iwl4965_hw_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory
706 */ 749 */
707void iwl4965_hw_txq_ctx_stop(struct iwl4965_priv *priv) 750void iwl4965_hw_txq_ctx_stop(struct iwl_priv *priv)
708{ 751{
709 752
710 int txq_id; 753 int txq_id;
@@ -732,7 +775,7 @@ void iwl4965_hw_txq_ctx_stop(struct iwl4965_priv *priv)
732 iwl4965_hw_txq_ctx_free(priv); 775 iwl4965_hw_txq_ctx_free(priv);
733} 776}
734 777
735int iwl4965_hw_nic_reset(struct iwl4965_priv *priv) 778int iwl4965_hw_nic_reset(struct iwl_priv *priv)
736{ 779{
737 int rc = 0; 780 int rc = 0;
738 unsigned long flags; 781 unsigned long flags;
@@ -793,7 +836,7 @@ int iwl4965_hw_nic_reset(struct iwl4965_priv *priv)
793 */ 836 */
794static void iwl4965_bg_statistics_periodic(unsigned long data) 837static void iwl4965_bg_statistics_periodic(unsigned long data)
795{ 838{
796 struct iwl4965_priv *priv = (struct iwl4965_priv *)data; 839 struct iwl_priv *priv = (struct iwl_priv *)data;
797 840
798 queue_work(priv->workqueue, &priv->statistics_work); 841 queue_work(priv->workqueue, &priv->statistics_work);
799} 842}
@@ -805,7 +848,7 @@ static void iwl4965_bg_statistics_periodic(unsigned long data)
805 */ 848 */
806static void iwl4965_bg_statistics_work(struct work_struct *work) 849static void iwl4965_bg_statistics_work(struct work_struct *work)
807{ 850{
808 struct iwl4965_priv *priv = container_of(work, struct iwl4965_priv, 851 struct iwl_priv *priv = container_of(work, struct iwl_priv,
809 statistics_work); 852 statistics_work);
810 853
811 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 854 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
@@ -819,14 +862,14 @@ static void iwl4965_bg_statistics_work(struct work_struct *work)
819#define CT_LIMIT_CONST 259 862#define CT_LIMIT_CONST 259
820#define TM_CT_KILL_THRESHOLD 110 863#define TM_CT_KILL_THRESHOLD 110
821 864
822void iwl4965_rf_kill_ct_config(struct iwl4965_priv *priv) 865void iwl4965_rf_kill_ct_config(struct iwl_priv *priv)
823{ 866{
824 struct iwl4965_ct_kill_config cmd; 867 struct iwl4965_ct_kill_config cmd;
825 u32 R1, R2, R3; 868 u32 R1, R2, R3;
826 u32 temp_th; 869 u32 temp_th;
827 u32 crit_temperature; 870 u32 crit_temperature;
828 unsigned long flags; 871 unsigned long flags;
829 int rc = 0; 872 int ret = 0;
830 873
831 spin_lock_irqsave(&priv->lock, flags); 874 spin_lock_irqsave(&priv->lock, flags);
832 iwl4965_write32(priv, CSR_UCODE_DRV_GP1_CLR, 875 iwl4965_write32(priv, CSR_UCODE_DRV_GP1_CLR,
@@ -847,9 +890,9 @@ void iwl4965_rf_kill_ct_config(struct iwl4965_priv *priv)
847 890
848 crit_temperature = ((temp_th * (R3-R1))/CT_LIMIT_CONST) + R2; 891 crit_temperature = ((temp_th * (R3-R1))/CT_LIMIT_CONST) + R2;
849 cmd.critical_temperature_R = cpu_to_le32(crit_temperature); 892 cmd.critical_temperature_R = cpu_to_le32(crit_temperature);
850 rc = iwl4965_send_cmd_pdu(priv, 893 ret = iwl_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD,
851 REPLY_CT_KILL_CONFIG_CMD, sizeof(cmd), &cmd); 894 sizeof(cmd), &cmd);
852 if (rc) 895 if (ret)
853 IWL_ERROR("REPLY_CT_KILL_CONFIG_CMD failed\n"); 896 IWL_ERROR("REPLY_CT_KILL_CONFIG_CMD failed\n");
854 else 897 else
855 IWL_DEBUG_INFO("REPLY_CT_KILL_CONFIG_CMD succeeded\n"); 898 IWL_DEBUG_INFO("REPLY_CT_KILL_CONFIG_CMD succeeded\n");
@@ -865,7 +908,7 @@ void iwl4965_rf_kill_ct_config(struct iwl4965_priv *priv)
865 * enough to receive all of our own network traffic, but not so 908 * enough to receive all of our own network traffic, but not so
866 * high that our DSP gets too busy trying to lock onto non-network 909 * high that our DSP gets too busy trying to lock onto non-network
867 * activity/noise. */ 910 * activity/noise. */
868static int iwl4965_sens_energy_cck(struct iwl4965_priv *priv, 911static int iwl4965_sens_energy_cck(struct iwl_priv *priv,
869 u32 norm_fa, 912 u32 norm_fa,
870 u32 rx_enable_time, 913 u32 rx_enable_time,
871 struct statistics_general_data *rx_info) 914 struct statistics_general_data *rx_info)
@@ -1056,7 +1099,7 @@ static int iwl4965_sens_energy_cck(struct iwl4965_priv *priv,
1056} 1099}
1057 1100
1058 1101
1059static int iwl4965_sens_auto_corr_ofdm(struct iwl4965_priv *priv, 1102static int iwl4965_sens_auto_corr_ofdm(struct iwl_priv *priv,
1060 u32 norm_fa, 1103 u32 norm_fa,
1061 u32 rx_enable_time) 1104 u32 rx_enable_time)
1062{ 1105{
@@ -1121,25 +1164,25 @@ static int iwl4965_sens_auto_corr_ofdm(struct iwl4965_priv *priv,
1121 return 0; 1164 return 0;
1122} 1165}
1123 1166
1124static int iwl4965_sensitivity_callback(struct iwl4965_priv *priv, 1167static int iwl4965_sensitivity_callback(struct iwl_priv *priv,
1125 struct iwl4965_cmd *cmd, struct sk_buff *skb) 1168 struct iwl_cmd *cmd, struct sk_buff *skb)
1126{ 1169{
1127 /* We didn't cache the SKB; let the caller free it */ 1170 /* We didn't cache the SKB; let the caller free it */
1128 return 1; 1171 return 1;
1129} 1172}
1130 1173
1131/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ 1174/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */
1132static int iwl4965_sensitivity_write(struct iwl4965_priv *priv, u8 flags) 1175static int iwl4965_sensitivity_write(struct iwl_priv *priv, u8 flags)
1133{ 1176{
1134 int rc = 0;
1135 struct iwl4965_sensitivity_cmd cmd ; 1177 struct iwl4965_sensitivity_cmd cmd ;
1136 struct iwl4965_sensitivity_data *data = NULL; 1178 struct iwl4965_sensitivity_data *data = NULL;
1137 struct iwl4965_host_cmd cmd_out = { 1179 struct iwl_host_cmd cmd_out = {
1138 .id = SENSITIVITY_CMD, 1180 .id = SENSITIVITY_CMD,
1139 .len = sizeof(struct iwl4965_sensitivity_cmd), 1181 .len = sizeof(struct iwl4965_sensitivity_cmd),
1140 .meta.flags = flags, 1182 .meta.flags = flags,
1141 .data = &cmd, 1183 .data = &cmd,
1142 }; 1184 };
1185 int ret;
1143 1186
1144 data = &(priv->sensitivity_data); 1187 data = &(priv->sensitivity_data);
1145 1188
@@ -1197,20 +1240,18 @@ static int iwl4965_sensitivity_write(struct iwl4965_priv *priv, u8 flags)
1197 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), 1240 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]),
1198 sizeof(u16)*HD_TABLE_SIZE); 1241 sizeof(u16)*HD_TABLE_SIZE);
1199 1242
1200 rc = iwl4965_send_cmd(priv, &cmd_out); 1243 ret = iwl_send_cmd(priv, &cmd_out);
1201 if (!rc) { 1244 if (ret)
1202 IWL_DEBUG_CALIB("SENSITIVITY_CMD succeeded\n"); 1245 IWL_ERROR("SENSITIVITY_CMD failed\n");
1203 return rc;
1204 }
1205 1246
1206 return 0; 1247 return ret;
1207} 1248}
1208 1249
1209void iwl4965_init_sensitivity(struct iwl4965_priv *priv, u8 flags, u8 force) 1250void iwl4965_init_sensitivity(struct iwl_priv *priv, u8 flags, u8 force)
1210{ 1251{
1211 int rc = 0;
1212 int i;
1213 struct iwl4965_sensitivity_data *data = NULL; 1252 struct iwl4965_sensitivity_data *data = NULL;
1253 int i;
1254 int ret = 0;
1214 1255
1215 IWL_DEBUG_CALIB("Start iwl4965_init_sensitivity\n"); 1256 IWL_DEBUG_CALIB("Start iwl4965_init_sensitivity\n");
1216 1257
@@ -1254,8 +1295,8 @@ void iwl4965_init_sensitivity(struct iwl4965_priv *priv, u8 flags, u8 force)
1254 memset(&(priv->sensitivity_tbl[0]), 0, 1295 memset(&(priv->sensitivity_tbl[0]), 0,
1255 sizeof(u16)*HD_TABLE_SIZE); 1296 sizeof(u16)*HD_TABLE_SIZE);
1256 1297
1257 rc |= iwl4965_sensitivity_write(priv, flags); 1298 ret |= iwl4965_sensitivity_write(priv, flags);
1258 IWL_DEBUG_CALIB("<<return 0x%X\n", rc); 1299 IWL_DEBUG_CALIB("<<return 0x%X\n", ret);
1259 1300
1260 return; 1301 return;
1261} 1302}
@@ -1264,10 +1305,9 @@ void iwl4965_init_sensitivity(struct iwl4965_priv *priv, u8 flags, u8 force)
1264/* Reset differential Rx gains in NIC to prepare for chain noise calibration. 1305/* Reset differential Rx gains in NIC to prepare for chain noise calibration.
1265 * Called after every association, but this runs only once! 1306 * Called after every association, but this runs only once!
1266 * ... once chain noise is calibrated the first time, it's good forever. */ 1307 * ... once chain noise is calibrated the first time, it's good forever. */
1267void iwl4965_chain_noise_reset(struct iwl4965_priv *priv) 1308void iwl4965_chain_noise_reset(struct iwl_priv *priv)
1268{ 1309{
1269 struct iwl4965_chain_noise_data *data = NULL; 1310 struct iwl4965_chain_noise_data *data = NULL;
1270 int rc = 0;
1271 1311
1272 data = &(priv->chain_noise_data); 1312 data = &(priv->chain_noise_data);
1273 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl4965_is_associated(priv)) { 1313 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl4965_is_associated(priv)) {
@@ -1278,7 +1318,7 @@ void iwl4965_chain_noise_reset(struct iwl4965_priv *priv)
1278 cmd.diff_gain_a = 0; 1318 cmd.diff_gain_a = 0;
1279 cmd.diff_gain_b = 0; 1319 cmd.diff_gain_b = 0;
1280 cmd.diff_gain_c = 0; 1320 cmd.diff_gain_c = 0;
1281 rc = iwl4965_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, 1321 iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
1282 sizeof(cmd), &cmd); 1322 sizeof(cmd), &cmd);
1283 msleep(4); 1323 msleep(4);
1284 data->state = IWL_CHAIN_NOISE_ACCUMULATE; 1324 data->state = IWL_CHAIN_NOISE_ACCUMULATE;
@@ -1293,11 +1333,11 @@ void iwl4965_chain_noise_reset(struct iwl4965_priv *priv)
1293 * 1) Which antennas are connected. 1333 * 1) Which antennas are connected.
1294 * 2) Differential rx gain settings to balance the 3 receivers. 1334 * 2) Differential rx gain settings to balance the 3 receivers.
1295 */ 1335 */
1296static void iwl4965_noise_calibration(struct iwl4965_priv *priv, 1336static void iwl4965_noise_calibration(struct iwl_priv *priv,
1297 struct iwl4965_notif_statistics *stat_resp) 1337 struct iwl4965_notif_statistics *stat_resp)
1298{ 1338{
1299 struct iwl4965_chain_noise_data *data = NULL; 1339 struct iwl4965_chain_noise_data *data = NULL;
1300 int rc = 0; 1340 int ret = 0;
1301 1341
1302 u32 chain_noise_a; 1342 u32 chain_noise_a;
1303 u32 chain_noise_b; 1343 u32 chain_noise_b;
@@ -1503,9 +1543,9 @@ static void iwl4965_noise_calibration(struct iwl4965_priv *priv,
1503 cmd.diff_gain_a = data->delta_gain_code[0]; 1543 cmd.diff_gain_a = data->delta_gain_code[0];
1504 cmd.diff_gain_b = data->delta_gain_code[1]; 1544 cmd.diff_gain_b = data->delta_gain_code[1];
1505 cmd.diff_gain_c = data->delta_gain_code[2]; 1545 cmd.diff_gain_c = data->delta_gain_code[2];
1506 rc = iwl4965_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, 1546 ret = iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
1507 sizeof(cmd), &cmd); 1547 sizeof(cmd), &cmd);
1508 if (rc) 1548 if (ret)
1509 IWL_DEBUG_CALIB("fail sending cmd " 1549 IWL_DEBUG_CALIB("fail sending cmd "
1510 "REPLY_PHY_CALIBRATION_CMD \n"); 1550 "REPLY_PHY_CALIBRATION_CMD \n");
1511 1551
@@ -1526,10 +1566,9 @@ static void iwl4965_noise_calibration(struct iwl4965_priv *priv,
1526 return; 1566 return;
1527} 1567}
1528 1568
1529static void iwl4965_sensitivity_calibration(struct iwl4965_priv *priv, 1569static void iwl4965_sensitivity_calibration(struct iwl_priv *priv,
1530 struct iwl4965_notif_statistics *resp) 1570 struct iwl4965_notif_statistics *resp)
1531{ 1571{
1532 int rc = 0;
1533 u32 rx_enable_time; 1572 u32 rx_enable_time;
1534 u32 fa_cck; 1573 u32 fa_cck;
1535 u32 fa_ofdm; 1574 u32 fa_ofdm;
@@ -1542,6 +1581,7 @@ static void iwl4965_sensitivity_calibration(struct iwl4965_priv *priv,
1542 struct statistics_rx *statistics = &(resp->rx); 1581 struct statistics_rx *statistics = &(resp->rx);
1543 unsigned long flags; 1582 unsigned long flags;
1544 struct statistics_general_data statis; 1583 struct statistics_general_data statis;
1584 int ret;
1545 1585
1546 data = &(priv->sensitivity_data); 1586 data = &(priv->sensitivity_data);
1547 1587
@@ -1626,14 +1666,14 @@ static void iwl4965_sensitivity_calibration(struct iwl4965_priv *priv,
1626 1666
1627 iwl4965_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); 1667 iwl4965_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time);
1628 iwl4965_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); 1668 iwl4965_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis);
1629 rc |= iwl4965_sensitivity_write(priv, CMD_ASYNC); 1669 ret = iwl4965_sensitivity_write(priv, CMD_ASYNC);
1630 1670
1631 return; 1671 return;
1632} 1672}
1633 1673
1634static void iwl4965_bg_sensitivity_work(struct work_struct *work) 1674static void iwl4965_bg_sensitivity_work(struct work_struct *work)
1635{ 1675{
1636 struct iwl4965_priv *priv = container_of(work, struct iwl4965_priv, 1676 struct iwl_priv *priv = container_of(work, struct iwl_priv,
1637 sensitivity_work); 1677 sensitivity_work);
1638 1678
1639 mutex_lock(&priv->mutex); 1679 mutex_lock(&priv->mutex);
@@ -1663,7 +1703,7 @@ static void iwl4965_bg_sensitivity_work(struct work_struct *work)
1663 1703
1664static void iwl4965_bg_txpower_work(struct work_struct *work) 1704static void iwl4965_bg_txpower_work(struct work_struct *work)
1665{ 1705{
1666 struct iwl4965_priv *priv = container_of(work, struct iwl4965_priv, 1706 struct iwl_priv *priv = container_of(work, struct iwl_priv,
1667 txpower_work); 1707 txpower_work);
1668 1708
1669 /* If a scan happened to start before we got here 1709 /* If a scan happened to start before we got here
@@ -1691,7 +1731,7 @@ static void iwl4965_bg_txpower_work(struct work_struct *work)
1691/* 1731/*
1692 * Acquire priv->lock before calling this function ! 1732 * Acquire priv->lock before calling this function !
1693 */ 1733 */
1694static void iwl4965_set_wr_ptrs(struct iwl4965_priv *priv, int txq_id, u32 index) 1734static void iwl4965_set_wr_ptrs(struct iwl_priv *priv, int txq_id, u32 index)
1695{ 1735{
1696 iwl4965_write_direct32(priv, HBUS_TARG_WRPTR, 1736 iwl4965_write_direct32(priv, HBUS_TARG_WRPTR,
1697 (index & 0xff) | (txq_id << 8)); 1737 (index & 0xff) | (txq_id << 8));
@@ -1705,7 +1745,7 @@ static void iwl4965_set_wr_ptrs(struct iwl4965_priv *priv, int txq_id, u32 index
1705 * 1745 *
1706 * NOTE: Acquire priv->lock before calling this function ! 1746 * NOTE: Acquire priv->lock before calling this function !
1707 */ 1747 */
1708static void iwl4965_tx_queue_set_status(struct iwl4965_priv *priv, 1748static void iwl4965_tx_queue_set_status(struct iwl_priv *priv,
1709 struct iwl4965_tx_queue *txq, 1749 struct iwl4965_tx_queue *txq,
1710 int tx_fifo_id, int scd_retry) 1750 int tx_fifo_id, int scd_retry)
1711{ 1751{
@@ -1739,22 +1779,22 @@ static const u16 default_queue_to_tx_fifo[] = {
1739 IWL_TX_FIFO_HCCA_2 1779 IWL_TX_FIFO_HCCA_2
1740}; 1780};
1741 1781
1742static inline void iwl4965_txq_ctx_activate(struct iwl4965_priv *priv, int txq_id) 1782static inline void iwl4965_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
1743{ 1783{
1744 set_bit(txq_id, &priv->txq_ctx_active_msk); 1784 set_bit(txq_id, &priv->txq_ctx_active_msk);
1745} 1785}
1746 1786
1747static inline void iwl4965_txq_ctx_deactivate(struct iwl4965_priv *priv, int txq_id) 1787static inline void iwl4965_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id)
1748{ 1788{
1749 clear_bit(txq_id, &priv->txq_ctx_active_msk); 1789 clear_bit(txq_id, &priv->txq_ctx_active_msk);
1750} 1790}
1751 1791
1752int iwl4965_alive_notify(struct iwl4965_priv *priv) 1792int iwl4965_alive_notify(struct iwl_priv *priv)
1753{ 1793{
1754 u32 a; 1794 u32 a;
1755 int i = 0; 1795 int i = 0;
1756 unsigned long flags; 1796 unsigned long flags;
1757 int rc; 1797 int ret;
1758 1798
1759 spin_lock_irqsave(&priv->lock, flags); 1799 spin_lock_irqsave(&priv->lock, flags);
1760 1800
@@ -1767,10 +1807,10 @@ int iwl4965_alive_notify(struct iwl4965_priv *priv)
1767 priv->chain_noise_data.delta_gain_code[i] = 1807 priv->chain_noise_data.delta_gain_code[i] =
1768 CHAIN_NOISE_DELTA_GAIN_INIT_VAL; 1808 CHAIN_NOISE_DELTA_GAIN_INIT_VAL;
1769#endif /* CONFIG_IWL4965_SENSITIVITY*/ 1809#endif /* CONFIG_IWL4965_SENSITIVITY*/
1770 rc = iwl4965_grab_nic_access(priv); 1810 ret = iwl4965_grab_nic_access(priv);
1771 if (rc) { 1811 if (ret) {
1772 spin_unlock_irqrestore(&priv->lock, flags); 1812 spin_unlock_irqrestore(&priv->lock, flags);
1773 return rc; 1813 return ret;
1774 } 1814 }
1775 1815
1776 /* Clear 4965's internal Tx Scheduler data base */ 1816 /* Clear 4965's internal Tx Scheduler data base */
@@ -1833,7 +1873,7 @@ int iwl4965_alive_notify(struct iwl4965_priv *priv)
1833 iwl4965_release_nic_access(priv); 1873 iwl4965_release_nic_access(priv);
1834 spin_unlock_irqrestore(&priv->lock, flags); 1874 spin_unlock_irqrestore(&priv->lock, flags);
1835 1875
1836 return 0; 1876 return ret;
1837} 1877}
1838 1878
1839/** 1879/**
@@ -1841,24 +1881,36 @@ int iwl4965_alive_notify(struct iwl4965_priv *priv)
1841 * 1881 *
1842 * Called when initializing driver 1882 * Called when initializing driver
1843 */ 1883 */
1844int iwl4965_hw_set_hw_setting(struct iwl4965_priv *priv) 1884int iwl4965_hw_set_hw_setting(struct iwl_priv *priv)
1845{ 1885{
1886 int ret = 0;
1887
1888 if ((priv->cfg->mod_params->num_of_queues > IWL_MAX_NUM_QUEUES) ||
1889 (priv->cfg->mod_params->num_of_queues < IWL_MIN_NUM_QUEUES)) {
1890 IWL_ERROR("invalid queues_num, should be between %d and %d\n",
1891 IWL_MIN_NUM_QUEUES, IWL_MAX_NUM_QUEUES);
1892 ret = -EINVAL;
1893 goto out;
1894 }
1895
1846 /* Allocate area for Tx byte count tables and Rx queue status */ 1896 /* Allocate area for Tx byte count tables and Rx queue status */
1847 priv->hw_setting.shared_virt = 1897 priv->hw_setting.shared_virt =
1848 pci_alloc_consistent(priv->pci_dev, 1898 pci_alloc_consistent(priv->pci_dev,
1849 sizeof(struct iwl4965_shared), 1899 sizeof(struct iwl4965_shared),
1850 &priv->hw_setting.shared_phys); 1900 &priv->hw_setting.shared_phys);
1851 1901
1852 if (!priv->hw_setting.shared_virt) 1902 if (!priv->hw_setting.shared_virt) {
1853 return -1; 1903 ret = -ENOMEM;
1904 goto out;
1905 }
1854 1906
1855 memset(priv->hw_setting.shared_virt, 0, sizeof(struct iwl4965_shared)); 1907 memset(priv->hw_setting.shared_virt, 0, sizeof(struct iwl4965_shared));
1856 1908
1857 priv->hw_setting.max_txq_num = iwl4965_param_queues_num; 1909 priv->hw_setting.max_txq_num = priv->cfg->mod_params->num_of_queues;
1858 priv->hw_setting.tx_cmd_len = sizeof(struct iwl4965_tx_cmd); 1910 priv->hw_setting.tx_cmd_len = sizeof(struct iwl4965_tx_cmd);
1859 priv->hw_setting.max_rxq_size = RX_QUEUE_SIZE; 1911 priv->hw_setting.max_rxq_size = RX_QUEUE_SIZE;
1860 priv->hw_setting.max_rxq_log = RX_QUEUE_SIZE_LOG; 1912 priv->hw_setting.max_rxq_log = RX_QUEUE_SIZE_LOG;
1861 if (iwl4965_param_amsdu_size_8K) 1913 if (priv->cfg->mod_params->amsdu_size_8K)
1862 priv->hw_setting.rx_buf_size = IWL_RX_BUF_SIZE_8K; 1914 priv->hw_setting.rx_buf_size = IWL_RX_BUF_SIZE_8K;
1863 else 1915 else
1864 priv->hw_setting.rx_buf_size = IWL_RX_BUF_SIZE_4K; 1916 priv->hw_setting.rx_buf_size = IWL_RX_BUF_SIZE_4K;
@@ -1868,7 +1920,8 @@ int iwl4965_hw_set_hw_setting(struct iwl4965_priv *priv)
1868 1920
1869 priv->hw_setting.tx_ant_num = 2; 1921 priv->hw_setting.tx_ant_num = 2;
1870 1922
1871 return 0; 1923out:
1924 return ret;
1872} 1925}
1873 1926
1874/** 1927/**
@@ -1876,7 +1929,7 @@ int iwl4965_hw_set_hw_setting(struct iwl4965_priv *priv)
1876 * 1929 *
1877 * Destroy all TX DMA queues and structures 1930 * Destroy all TX DMA queues and structures
1878 */ 1931 */
1879void iwl4965_hw_txq_ctx_free(struct iwl4965_priv *priv) 1932void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv)
1880{ 1933{
1881 int txq_id; 1934 int txq_id;
1882 1935
@@ -1894,7 +1947,7 @@ void iwl4965_hw_txq_ctx_free(struct iwl4965_priv *priv)
1894 * Does NOT advance any TFD circular buffer read/write indexes 1947 * Does NOT advance any TFD circular buffer read/write indexes
1895 * Does NOT free the TFD itself (which is within circular buffer) 1948 * Does NOT free the TFD itself (which is within circular buffer)
1896 */ 1949 */
1897int iwl4965_hw_txq_free_tfd(struct iwl4965_priv *priv, struct iwl4965_tx_queue *txq) 1950int iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl4965_tx_queue *txq)
1898{ 1951{
1899 struct iwl4965_tfd_frame *bd_tmp = (struct iwl4965_tfd_frame *)&txq->bd[0]; 1952 struct iwl4965_tfd_frame *bd_tmp = (struct iwl4965_tfd_frame *)&txq->bd[0];
1900 struct iwl4965_tfd_frame *bd = &bd_tmp[txq->q.read_ptr]; 1953 struct iwl4965_tfd_frame *bd = &bd_tmp[txq->q.read_ptr];
@@ -1947,7 +2000,7 @@ int iwl4965_hw_txq_free_tfd(struct iwl4965_priv *priv, struct iwl4965_tx_queue *
1947 return 0; 2000 return 0;
1948} 2001}
1949 2002
1950int iwl4965_hw_reg_set_txpower(struct iwl4965_priv *priv, s8 power) 2003int iwl4965_hw_reg_set_txpower(struct iwl_priv *priv, s8 power)
1951{ 2004{
1952 IWL_ERROR("TODO: Implement iwl4965_hw_reg_set_txpower!\n"); 2005 IWL_ERROR("TODO: Implement iwl4965_hw_reg_set_txpower!\n");
1953 return -EINVAL; 2006 return -EINVAL;
@@ -2002,13 +2055,13 @@ static s32 iwl4965_get_voltage_compensation(s32 eeprom_voltage,
2002 return comp; 2055 return comp;
2003} 2056}
2004 2057
2005static const struct iwl4965_channel_info * 2058static const struct iwl_channel_info *
2006iwl4965_get_channel_txpower_info(struct iwl4965_priv *priv, 2059iwl4965_get_channel_txpower_info(struct iwl_priv *priv,
2007 enum ieee80211_band band, u16 channel) 2060 enum ieee80211_band band, u16 channel)
2008{ 2061{
2009 const struct iwl4965_channel_info *ch_info; 2062 const struct iwl_channel_info *ch_info;
2010 2063
2011 ch_info = iwl4965_get_channel_info(priv, band, channel); 2064 ch_info = iwl_get_channel_info(priv, band, channel);
2012 2065
2013 if (!is_channel_valid(ch_info)) 2066 if (!is_channel_valid(ch_info))
2014 return NULL; 2067 return NULL;
@@ -2042,7 +2095,7 @@ static s32 iwl4965_get_tx_atten_grp(u16 channel)
2042 return -1; 2095 return -1;
2043} 2096}
2044 2097
2045static u32 iwl4965_get_sub_band(const struct iwl4965_priv *priv, u32 channel) 2098static u32 iwl4965_get_sub_band(const struct iwl_priv *priv, u32 channel)
2046{ 2099{
2047 s32 b = -1; 2100 s32 b = -1;
2048 2101
@@ -2078,7 +2131,7 @@ static s32 iwl4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2)
2078 * differences in channel frequencies, which is proportional to differences 2131 * differences in channel frequencies, which is proportional to differences
2079 * in channel number. 2132 * in channel number.
2080 */ 2133 */
2081static int iwl4965_interpolate_chan(struct iwl4965_priv *priv, u32 channel, 2134static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel,
2082 struct iwl4965_eeprom_calib_ch_info *chan_info) 2135 struct iwl4965_eeprom_calib_ch_info *chan_info)
2083{ 2136{
2084 s32 s = -1; 2137 s32 s = -1;
@@ -2411,7 +2464,7 @@ static const struct gain_entry gain_table[2][108] = {
2411 } 2464 }
2412}; 2465};
2413 2466
2414static int iwl4965_fill_txpower_tbl(struct iwl4965_priv *priv, u8 band, u16 channel, 2467static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
2415 u8 is_fat, u8 ctrl_chan_high, 2468 u8 is_fat, u8 ctrl_chan_high,
2416 struct iwl4965_tx_power_db *tx_power_tbl) 2469 struct iwl4965_tx_power_db *tx_power_tbl)
2417{ 2470{
@@ -2425,7 +2478,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl4965_priv *priv, u8 band, u16 chan
2425 s32 txatten_grp = CALIB_CH_GROUP_MAX; 2478 s32 txatten_grp = CALIB_CH_GROUP_MAX;
2426 int i; 2479 int i;
2427 int c; 2480 int c;
2428 const struct iwl4965_channel_info *ch_info = NULL; 2481 const struct iwl_channel_info *ch_info = NULL;
2429 struct iwl4965_eeprom_calib_ch_info ch_eeprom_info; 2482 struct iwl4965_eeprom_calib_ch_info ch_eeprom_info;
2430 const struct iwl4965_eeprom_calib_measure *measurement; 2483 const struct iwl4965_eeprom_calib_measure *measurement;
2431 s16 voltage; 2484 s16 voltage;
@@ -2668,10 +2721,10 @@ static int iwl4965_fill_txpower_tbl(struct iwl4965_priv *priv, u8 band, u16 chan
2668 * Uses the active RXON for channel, band, and characteristics (fat, high) 2721 * Uses the active RXON for channel, band, and characteristics (fat, high)
2669 * The power limit is taken from priv->user_txpower_limit. 2722 * The power limit is taken from priv->user_txpower_limit.
2670 */ 2723 */
2671int iwl4965_hw_reg_send_txpower(struct iwl4965_priv *priv) 2724int iwl4965_hw_reg_send_txpower(struct iwl_priv *priv)
2672{ 2725{
2673 struct iwl4965_txpowertable_cmd cmd = { 0 }; 2726 struct iwl4965_txpowertable_cmd cmd = { 0 };
2674 int rc = 0; 2727 int ret;
2675 u8 band = 0; 2728 u8 band = 0;
2676 u8 is_fat = 0; 2729 u8 is_fat = 0;
2677 u8 ctrl_chan_high = 0; 2730 u8 ctrl_chan_high = 0;
@@ -2695,28 +2748,30 @@ int iwl4965_hw_reg_send_txpower(struct iwl4965_priv *priv)
2695 cmd.band = band; 2748 cmd.band = band;
2696 cmd.channel = priv->active_rxon.channel; 2749 cmd.channel = priv->active_rxon.channel;
2697 2750
2698 rc = iwl4965_fill_txpower_tbl(priv, band, 2751 ret = iwl4965_fill_txpower_tbl(priv, band,
2699 le16_to_cpu(priv->active_rxon.channel), 2752 le16_to_cpu(priv->active_rxon.channel),
2700 is_fat, ctrl_chan_high, &cmd.tx_power); 2753 is_fat, ctrl_chan_high, &cmd.tx_power);
2701 if (rc) 2754 if (ret)
2702 return rc; 2755 goto out;
2703 2756
2704 rc = iwl4965_send_cmd_pdu(priv, REPLY_TX_PWR_TABLE_CMD, sizeof(cmd), &cmd); 2757 ret = iwl_send_cmd_pdu(priv, REPLY_TX_PWR_TABLE_CMD, sizeof(cmd), &cmd);
2705 return rc; 2758
2759out:
2760 return ret;
2706} 2761}
2707 2762
2708int iwl4965_hw_channel_switch(struct iwl4965_priv *priv, u16 channel) 2763int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel)
2709{ 2764{
2710 int rc; 2765 int rc;
2711 u8 band = 0; 2766 u8 band = 0;
2712 u8 is_fat = 0; 2767 u8 is_fat = 0;
2713 u8 ctrl_chan_high = 0; 2768 u8 ctrl_chan_high = 0;
2714 struct iwl4965_channel_switch_cmd cmd = { 0 }; 2769 struct iwl4965_channel_switch_cmd cmd = { 0 };
2715 const struct iwl4965_channel_info *ch_info; 2770 const struct iwl_channel_info *ch_info;
2716 2771
2717 band = priv->band == IEEE80211_BAND_2GHZ; 2772 band = priv->band == IEEE80211_BAND_2GHZ;
2718 2773
2719 ch_info = iwl4965_get_channel_info(priv, priv->band, channel); 2774 ch_info = iwl_get_channel_info(priv, priv->band, channel);
2720 2775
2721 is_fat = is_fat_channel(priv->staging_rxon.flags); 2776 is_fat = is_fat_channel(priv->staging_rxon.flags);
2722 2777
@@ -2742,15 +2797,15 @@ int iwl4965_hw_channel_switch(struct iwl4965_priv *priv, u16 channel)
2742 return rc; 2797 return rc;
2743 } 2798 }
2744 2799
2745 rc = iwl4965_send_cmd_pdu(priv, REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); 2800 rc = iwl_send_cmd_pdu(priv, REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd);
2746 return rc; 2801 return rc;
2747} 2802}
2748 2803
2749#define RTS_HCCA_RETRY_LIMIT 3 2804#define RTS_HCCA_RETRY_LIMIT 3
2750#define RTS_DFAULT_RETRY_LIMIT 60 2805#define RTS_DFAULT_RETRY_LIMIT 60
2751 2806
2752void iwl4965_hw_build_tx_cmd_rate(struct iwl4965_priv *priv, 2807void iwl4965_hw_build_tx_cmd_rate(struct iwl_priv *priv,
2753 struct iwl4965_cmd *cmd, 2808 struct iwl_cmd *cmd,
2754 struct ieee80211_tx_control *ctrl, 2809 struct ieee80211_tx_control *ctrl,
2755 struct ieee80211_hdr *hdr, int sta_id, 2810 struct ieee80211_hdr *hdr, int sta_id,
2756 int is_hcca) 2811 int is_hcca)
@@ -2816,19 +2871,19 @@ void iwl4965_hw_build_tx_cmd_rate(struct iwl4965_priv *priv,
2816 tx->rate_n_flags = iwl4965_hw_set_rate_n_flags(rate_plcp, rate_flags); 2871 tx->rate_n_flags = iwl4965_hw_set_rate_n_flags(rate_plcp, rate_flags);
2817} 2872}
2818 2873
2819int iwl4965_hw_get_rx_read(struct iwl4965_priv *priv) 2874int iwl4965_hw_get_rx_read(struct iwl_priv *priv)
2820{ 2875{
2821 struct iwl4965_shared *shared_data = priv->hw_setting.shared_virt; 2876 struct iwl4965_shared *shared_data = priv->hw_setting.shared_virt;
2822 2877
2823 return IWL_GET_BITS(*shared_data, rb_closed_stts_rb_num); 2878 return IWL_GET_BITS(*shared_data, rb_closed_stts_rb_num);
2824} 2879}
2825 2880
2826int iwl4965_hw_get_temperature(struct iwl4965_priv *priv) 2881int iwl4965_hw_get_temperature(struct iwl_priv *priv)
2827{ 2882{
2828 return priv->temperature; 2883 return priv->temperature;
2829} 2884}
2830 2885
2831unsigned int iwl4965_hw_get_beacon_cmd(struct iwl4965_priv *priv, 2886unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
2832 struct iwl4965_frame *frame, u8 rate) 2887 struct iwl4965_frame *frame, u8 rate)
2833{ 2888{
2834 struct iwl4965_tx_beacon_cmd *tx_beacon_cmd; 2889 struct iwl4965_tx_beacon_cmd *tx_beacon_cmd;
@@ -2867,7 +2922,7 @@ unsigned int iwl4965_hw_get_beacon_cmd(struct iwl4965_priv *priv,
2867 * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA 2922 * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA
2868 * channels supported in hardware. 2923 * channels supported in hardware.
2869 */ 2924 */
2870int iwl4965_hw_tx_queue_init(struct iwl4965_priv *priv, struct iwl4965_tx_queue *txq) 2925int iwl4965_hw_tx_queue_init(struct iwl_priv *priv, struct iwl4965_tx_queue *txq)
2871{ 2926{
2872 int rc; 2927 int rc;
2873 unsigned long flags; 2928 unsigned long flags;
@@ -2895,7 +2950,7 @@ int iwl4965_hw_tx_queue_init(struct iwl4965_priv *priv, struct iwl4965_tx_queue
2895 return 0; 2950 return 0;
2896} 2951}
2897 2952
2898int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl4965_priv *priv, void *ptr, 2953int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *ptr,
2899 dma_addr_t addr, u16 len) 2954 dma_addr_t addr, u16 len)
2900{ 2955{
2901 int index, is_odd; 2956 int index, is_odd;
@@ -2929,7 +2984,7 @@ int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl4965_priv *priv, void *ptr,
2929 return 0; 2984 return 0;
2930} 2985}
2931 2986
2932static void iwl4965_hw_card_show_info(struct iwl4965_priv *priv) 2987static void iwl4965_hw_card_show_info(struct iwl_priv *priv)
2933{ 2988{
2934 u16 hw_version = priv->eeprom.board_revision_4965; 2989 u16 hw_version = priv->eeprom.board_revision_4965;
2935 2990
@@ -2947,7 +3002,7 @@ static void iwl4965_hw_card_show_info(struct iwl4965_priv *priv)
2947/** 3002/**
2948 * iwl4965_tx_queue_update_wr_ptr - Set up entry in Tx byte-count array 3003 * iwl4965_tx_queue_update_wr_ptr - Set up entry in Tx byte-count array
2949 */ 3004 */
2950int iwl4965_tx_queue_update_wr_ptr(struct iwl4965_priv *priv, 3005int iwl4965_tx_queue_update_wr_ptr(struct iwl_priv *priv,
2951 struct iwl4965_tx_queue *txq, u16 byte_cnt) 3006 struct iwl4965_tx_queue *txq, u16 byte_cnt)
2952{ 3007{
2953 int len; 3008 int len;
@@ -2978,7 +3033,7 @@ int iwl4965_tx_queue_update_wr_ptr(struct iwl4965_priv *priv,
2978 * Selects how many and which Rx receivers/antennas/chains to use. 3033 * Selects how many and which Rx receivers/antennas/chains to use.
2979 * This should not be used for scan command ... it puts data in wrong place. 3034 * This should not be used for scan command ... it puts data in wrong place.
2980 */ 3035 */
2981void iwl4965_set_rxon_chain(struct iwl4965_priv *priv) 3036void iwl4965_set_rxon_chain(struct iwl_priv *priv)
2982{ 3037{
2983 u8 is_single = is_single_stream(priv); 3038 u8 is_single = is_single_stream(priv);
2984 u8 idle_state, rx_state; 3039 u8 idle_state, rx_state;
@@ -3031,7 +3086,7 @@ static s32 sign_extend(u32 oper, int index)
3031 * 3086 *
3032 * A return of <0 indicates bogus data in the statistics 3087 * A return of <0 indicates bogus data in the statistics
3033 */ 3088 */
3034int iwl4965_get_temperature(const struct iwl4965_priv *priv) 3089int iwl4965_get_temperature(const struct iwl_priv *priv)
3035{ 3090{
3036 s32 temperature; 3091 s32 temperature;
3037 s32 vt; 3092 s32 vt;
@@ -3099,7 +3154,7 @@ int iwl4965_get_temperature(const struct iwl4965_priv *priv)
3099 * Assumes caller will replace priv->last_temperature once calibration 3154 * Assumes caller will replace priv->last_temperature once calibration
3100 * executed. 3155 * executed.
3101 */ 3156 */
3102static int iwl4965_is_temp_calib_needed(struct iwl4965_priv *priv) 3157static int iwl4965_is_temp_calib_needed(struct iwl_priv *priv)
3103{ 3158{
3104 int temp_diff; 3159 int temp_diff;
3105 3160
@@ -3132,7 +3187,7 @@ static int iwl4965_is_temp_calib_needed(struct iwl4965_priv *priv)
3132/* Calculate noise level, based on measurements during network silence just 3187/* Calculate noise level, based on measurements during network silence just
3133 * before arriving beacon. This measurement can be done only if we know 3188 * before arriving beacon. This measurement can be done only if we know
3134 * exactly when to expect beacons, therefore only when we're associated. */ 3189 * exactly when to expect beacons, therefore only when we're associated. */
3135static void iwl4965_rx_calc_noise(struct iwl4965_priv *priv) 3190static void iwl4965_rx_calc_noise(struct iwl_priv *priv)
3136{ 3191{
3137 struct statistics_rx_non_phy *rx_info 3192 struct statistics_rx_non_phy *rx_info
3138 = &(priv->statistics.rx.general); 3193 = &(priv->statistics.rx.general);
@@ -3169,7 +3224,7 @@ static void iwl4965_rx_calc_noise(struct iwl4965_priv *priv)
3169 priv->last_rx_noise); 3224 priv->last_rx_noise);
3170} 3225}
3171 3226
3172void iwl4965_hw_rx_statistics(struct iwl4965_priv *priv, struct iwl4965_rx_mem_buffer *rxb) 3227void iwl4965_hw_rx_statistics(struct iwl_priv *priv, struct iwl4965_rx_mem_buffer *rxb)
3173{ 3228{
3174 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3229 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
3175 int change; 3230 int change;
@@ -3233,7 +3288,7 @@ void iwl4965_hw_rx_statistics(struct iwl4965_priv *priv, struct iwl4965_rx_mem_b
3233 queue_work(priv->workqueue, &priv->txpower_work); 3288 queue_work(priv->workqueue, &priv->txpower_work);
3234} 3289}
3235 3290
3236static void iwl4965_add_radiotap(struct iwl4965_priv *priv, 3291static void iwl4965_add_radiotap(struct iwl_priv *priv,
3237 struct sk_buff *skb, 3292 struct sk_buff *skb,
3238 struct iwl4965_rx_phy_res *rx_start, 3293 struct iwl4965_rx_phy_res *rx_start,
3239 struct ieee80211_rx_status *stats, 3294 struct ieee80211_rx_status *stats,
@@ -3337,7 +3392,74 @@ static void iwl4965_add_radiotap(struct iwl4965_priv *priv,
3337 stats->flag |= RX_FLAG_RADIOTAP; 3392 stats->flag |= RX_FLAG_RADIOTAP;
3338} 3393}
3339 3394
3340static void iwl4965_handle_data_packet(struct iwl4965_priv *priv, int is_data, 3395static void iwl_update_rx_stats(struct iwl_priv *priv, u16 fc, u16 len)
3396{
3397 /* 0 - mgmt, 1 - cnt, 2 - data */
3398 int idx = (fc & IEEE80211_FCTL_FTYPE) >> 2;
3399 priv->rx_stats[idx].cnt++;
3400 priv->rx_stats[idx].bytes += len;
3401}
3402
3403static u32 iwl4965_translate_rx_status(u32 decrypt_in)
3404{
3405 u32 decrypt_out = 0;
3406
3407 if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) ==
3408 RX_RES_STATUS_STATION_FOUND)
3409 decrypt_out |= (RX_RES_STATUS_STATION_FOUND |
3410 RX_RES_STATUS_NO_STATION_INFO_MISMATCH);
3411
3412 decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK);
3413
3414 /* packet was not encrypted */
3415 if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==
3416 RX_RES_STATUS_SEC_TYPE_NONE)
3417 return decrypt_out;
3418
3419 /* packet was encrypted with unknown alg */
3420 if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==
3421 RX_RES_STATUS_SEC_TYPE_ERR)
3422 return decrypt_out;
3423
3424 /* decryption was not done in HW */
3425 if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) !=
3426 RX_MPDU_RES_STATUS_DEC_DONE_MSK)
3427 return decrypt_out;
3428
3429 switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) {
3430
3431 case RX_RES_STATUS_SEC_TYPE_CCMP:
3432 /* alg is CCM: check MIC only */
3433 if (!(decrypt_in & RX_MPDU_RES_STATUS_MIC_OK))
3434 /* Bad MIC */
3435 decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;
3436 else
3437 decrypt_out |= RX_RES_STATUS_DECRYPT_OK;
3438
3439 break;
3440
3441 case RX_RES_STATUS_SEC_TYPE_TKIP:
3442 if (!(decrypt_in & RX_MPDU_RES_STATUS_TTAK_OK)) {
3443 /* Bad TTAK */
3444 decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK;
3445 break;
3446 }
3447 /* fall through if TTAK OK */
3448 default:
3449 if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK))
3450 decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;
3451 else
3452 decrypt_out |= RX_RES_STATUS_DECRYPT_OK;
3453 break;
3454 };
3455
3456 IWL_DEBUG_RX("decrypt_in:0x%x decrypt_out = 0x%x\n",
3457 decrypt_in, decrypt_out);
3458
3459 return decrypt_out;
3460}
3461
3462static void iwl4965_handle_data_packet(struct iwl_priv *priv, int is_data,
3341 int include_phy, 3463 int include_phy,
3342 struct iwl4965_rx_mem_buffer *rxb, 3464 struct iwl4965_rx_mem_buffer *rxb,
3343 struct ieee80211_rx_status *stats) 3465 struct ieee80211_rx_status *stats)
@@ -3350,6 +3472,7 @@ static void iwl4965_handle_data_packet(struct iwl4965_priv *priv, int is_data,
3350 __le32 *rx_end; 3472 __le32 *rx_end;
3351 unsigned int skblen; 3473 unsigned int skblen;
3352 u32 ampdu_status; 3474 u32 ampdu_status;
3475 u32 ampdu_status_legacy;
3353 3476
3354 if (!include_phy && priv->last_phy_res[0]) 3477 if (!include_phy && priv->last_phy_res[0])
3355 rx_start = (struct iwl4965_rx_phy_res *)&priv->last_phy_res[1]; 3478 rx_start = (struct iwl4965_rx_phy_res *)&priv->last_phy_res[1];
@@ -3386,6 +3509,12 @@ static void iwl4965_handle_data_packet(struct iwl4965_priv *priv, int is_data,
3386 ampdu_status = le32_to_cpu(*rx_end); 3509 ampdu_status = le32_to_cpu(*rx_end);
3387 skblen = ((u8 *) rx_end - (u8 *) & pkt->u.raw[0]) + sizeof(u32); 3510 skblen = ((u8 *) rx_end - (u8 *) & pkt->u.raw[0]) + sizeof(u32);
3388 3511
3512 if (!include_phy) {
3513 /* New status scheme, need to translate */
3514 ampdu_status_legacy = ampdu_status;
3515 ampdu_status = iwl4965_translate_rx_status(ampdu_status);
3516 }
3517
3389 /* start from MAC */ 3518 /* start from MAC */
3390 skb_reserve(rxb->skb, (void *)hdr - (void *)pkt); 3519 skb_reserve(rxb->skb, (void *)hdr - (void *)pkt);
3391 skb_put(rxb->skb, len); /* end where data ends */ 3520 skb_put(rxb->skb, len); /* end where data ends */
@@ -3400,12 +3529,13 @@ static void iwl4965_handle_data_packet(struct iwl4965_priv *priv, int is_data,
3400 stats->flag = 0; 3529 stats->flag = 0;
3401 hdr = (struct ieee80211_hdr *)rxb->skb->data; 3530 hdr = (struct ieee80211_hdr *)rxb->skb->data;
3402 3531
3403 if (iwl4965_param_hwcrypto) 3532 if (priv->cfg->mod_params->hw_crypto)
3404 iwl4965_set_decrypted_flag(priv, rxb->skb, ampdu_status, stats); 3533 iwl4965_set_decrypted_flag(priv, rxb->skb, ampdu_status, stats);
3405 3534
3406 if (priv->add_radiotap) 3535 if (priv->add_radiotap)
3407 iwl4965_add_radiotap(priv, rxb->skb, rx_start, stats, ampdu_status); 3536 iwl4965_add_radiotap(priv, rxb->skb, rx_start, stats, ampdu_status);
3408 3537
3538 iwl_update_rx_stats(priv, le16_to_cpu(hdr->frame_control), len);
3409 ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats); 3539 ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats);
3410 priv->alloc_rxb_skb--; 3540 priv->alloc_rxb_skb--;
3411 rxb->skb = NULL; 3541 rxb->skb = NULL;
@@ -3522,7 +3652,8 @@ static int parse_elems(u8 *start, size_t len, struct ieee802_11_elems *elems)
3522 return 0; 3652 return 0;
3523} 3653}
3524 3654
3525void iwl4965_init_ht_hw_capab(struct ieee80211_ht_info *ht_info, 3655void iwl4965_init_ht_hw_capab(struct iwl_priv *priv,
3656 struct ieee80211_ht_info *ht_info,
3526 enum ieee80211_band band) 3657 enum ieee80211_band band)
3527{ 3658{
3528 ht_info->cap = 0; 3659 ht_info->cap = 0;
@@ -3539,10 +3670,9 @@ void iwl4965_init_ht_hw_capab(struct ieee80211_ht_info *ht_info,
3539 ht_info->cap |= (u16)IEEE80211_HT_CAP_SGI_20; 3670 ht_info->cap |= (u16)IEEE80211_HT_CAP_SGI_20;
3540 ht_info->cap |= (u16)(IEEE80211_HT_CAP_MIMO_PS & 3671 ht_info->cap |= (u16)(IEEE80211_HT_CAP_MIMO_PS &
3541 (IWL_MIMO_PS_NONE << 2)); 3672 (IWL_MIMO_PS_NONE << 2));
3542 if (iwl4965_param_amsdu_size_8K) { 3673
3543 printk(KERN_DEBUG "iwl4965 in A-MSDU 8K support mode\n"); 3674 if (priv->cfg->mod_params->amsdu_size_8K)
3544 ht_info->cap |= (u16)IEEE80211_HT_CAP_MAX_AMSDU; 3675 ht_info->cap |= (u16)IEEE80211_HT_CAP_MAX_AMSDU;
3545 }
3546 3676
3547 ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; 3677 ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF;
3548 ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; 3678 ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF;
@@ -3552,7 +3682,7 @@ void iwl4965_init_ht_hw_capab(struct ieee80211_ht_info *ht_info,
3552} 3682}
3553#endif /* CONFIG_IWL4965_HT */ 3683#endif /* CONFIG_IWL4965_HT */
3554 3684
3555static void iwl4965_sta_modify_ps_wake(struct iwl4965_priv *priv, int sta_id) 3685static void iwl4965_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id)
3556{ 3686{
3557 unsigned long flags; 3687 unsigned long flags;
3558 3688
@@ -3566,7 +3696,7 @@ static void iwl4965_sta_modify_ps_wake(struct iwl4965_priv *priv, int sta_id)
3566 iwl4965_send_add_station(priv, &priv->stations[sta_id].sta, CMD_ASYNC); 3696 iwl4965_send_add_station(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
3567} 3697}
3568 3698
3569static void iwl4965_update_ps_mode(struct iwl4965_priv *priv, u16 ps_bit, u8 *addr) 3699static void iwl4965_update_ps_mode(struct iwl_priv *priv, u16 ps_bit, u8 *addr)
3570{ 3700{
3571 /* FIXME: need locking over ps_status ??? */ 3701 /* FIXME: need locking over ps_status ??? */
3572 u8 sta_id = iwl4965_hw_find_station(priv, addr); 3702 u8 sta_id = iwl4965_hw_find_station(priv, addr);
@@ -3583,7 +3713,7 @@ static void iwl4965_update_ps_mode(struct iwl4965_priv *priv, u16 ps_bit, u8 *ad
3583 } 3713 }
3584 } 3714 }
3585} 3715}
3586#ifdef CONFIG_IWL4965_DEBUG 3716#ifdef CONFIG_IWLWIFI_DEBUG
3587 3717
3588/** 3718/**
3589 * iwl4965_dbg_report_frame - dump frame to syslog during debug sessions 3719 * iwl4965_dbg_report_frame - dump frame to syslog during debug sessions
@@ -3595,7 +3725,7 @@ static void iwl4965_update_ps_mode(struct iwl4965_priv *priv, u16 ps_bit, u8 *ad
3595 * TODO: This was originally written for 3945, need to audit for 3725 * TODO: This was originally written for 3945, need to audit for
3596 * proper operation with 4965. 3726 * proper operation with 4965.
3597 */ 3727 */
3598static void iwl4965_dbg_report_frame(struct iwl4965_priv *priv, 3728static void iwl4965_dbg_report_frame(struct iwl_priv *priv,
3599 struct iwl4965_rx_packet *pkt, 3729 struct iwl4965_rx_packet *pkt,
3600 struct ieee80211_hdr *header, int group100) 3730 struct ieee80211_hdr *header, int group100)
3601{ 3731{
@@ -3623,7 +3753,7 @@ static void iwl4965_dbg_report_frame(struct iwl4965_priv *priv,
3623 struct iwl4965_rx_frame_end *rx_end = IWL_RX_END(pkt); 3753 struct iwl4965_rx_frame_end *rx_end = IWL_RX_END(pkt);
3624 u8 *data = IWL_RX_DATA(pkt); 3754 u8 *data = IWL_RX_DATA(pkt);
3625 3755
3626 if (likely(!(iwl4965_debug_level & IWL_DL_RX))) 3756 if (likely(!(iwl_debug_level & IWL_DL_RX)))
3627 return; 3757 return;
3628 3758
3629 /* MAC header */ 3759 /* MAC header */
@@ -3726,10 +3856,10 @@ static void iwl4965_dbg_report_frame(struct iwl4965_priv *priv,
3726 } 3856 }
3727 } 3857 }
3728 if (print_dump) 3858 if (print_dump)
3729 iwl4965_print_hex_dump(IWL_DL_RX, data, length); 3859 iwl_print_hex_dump(IWL_DL_RX, data, length);
3730} 3860}
3731#else 3861#else
3732static inline void iwl4965_dbg_report_frame(struct iwl4965_priv *priv, 3862static inline void iwl4965_dbg_report_frame(struct iwl_priv *priv,
3733 struct iwl4965_rx_packet *pkt, 3863 struct iwl4965_rx_packet *pkt,
3734 struct ieee80211_hdr *header, 3864 struct ieee80211_hdr *header,
3735 int group100) 3865 int group100)
@@ -3740,9 +3870,9 @@ static inline void iwl4965_dbg_report_frame(struct iwl4965_priv *priv,
3740 3870
3741#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) 3871#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
3742 3872
3743/* Called for REPLY_4965_RX (legacy ABG frames), or 3873/* Called for REPLY_RX (legacy ABG frames), or
3744 * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ 3874 * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */
3745static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv, 3875static void iwl4965_rx_reply_rx(struct iwl_priv *priv,
3746 struct iwl4965_rx_mem_buffer *rxb) 3876 struct iwl4965_rx_mem_buffer *rxb)
3747{ 3877{
3748 struct ieee80211_hdr *header; 3878 struct ieee80211_hdr *header;
@@ -3751,7 +3881,7 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv,
3751 /* Use phy data (Rx signal strength, etc.) contained within 3881 /* Use phy data (Rx signal strength, etc.) contained within
3752 * this rx packet for legacy frames, 3882 * this rx packet for legacy frames,
3753 * or phy data cached from REPLY_RX_PHY_CMD for HT frames. */ 3883 * or phy data cached from REPLY_RX_PHY_CMD for HT frames. */
3754 int include_phy = (pkt->hdr.cmd == REPLY_4965_RX); 3884 int include_phy = (pkt->hdr.cmd == REPLY_RX);
3755 struct iwl4965_rx_phy_res *rx_start = (include_phy) ? 3885 struct iwl4965_rx_phy_res *rx_start = (include_phy) ?
3756 (struct iwl4965_rx_phy_res *)&(pkt->u.raw[0]) : 3886 (struct iwl4965_rx_phy_res *)&(pkt->u.raw[0]) :
3757 (struct iwl4965_rx_phy_res *)&priv->last_phy_res[1]; 3887 (struct iwl4965_rx_phy_res *)&priv->last_phy_res[1];
@@ -4004,7 +4134,7 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv,
4004 4134
4005/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). 4135/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD).
4006 * This will be used later in iwl4965_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ 4136 * This will be used later in iwl4965_rx_reply_rx() for REPLY_RX_MPDU_CMD. */
4007static void iwl4965_rx_reply_rx_phy(struct iwl4965_priv *priv, 4137static void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv,
4008 struct iwl4965_rx_mem_buffer *rxb) 4138 struct iwl4965_rx_mem_buffer *rxb)
4009{ 4139{
4010 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 4140 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
@@ -4013,7 +4143,7 @@ static void iwl4965_rx_reply_rx_phy(struct iwl4965_priv *priv,
4013 sizeof(struct iwl4965_rx_phy_res)); 4143 sizeof(struct iwl4965_rx_phy_res));
4014} 4144}
4015 4145
4016static void iwl4965_rx_missed_beacon_notif(struct iwl4965_priv *priv, 4146static void iwl4965_rx_missed_beacon_notif(struct iwl_priv *priv,
4017 struct iwl4965_rx_mem_buffer *rxb) 4147 struct iwl4965_rx_mem_buffer *rxb)
4018 4148
4019{ 4149{
@@ -4040,7 +4170,7 @@ static void iwl4965_rx_missed_beacon_notif(struct iwl4965_priv *priv,
4040/** 4170/**
4041 * iwl4965_sta_modify_enable_tid_tx - Enable Tx for this TID in station table 4171 * iwl4965_sta_modify_enable_tid_tx - Enable Tx for this TID in station table
4042 */ 4172 */
4043static void iwl4965_sta_modify_enable_tid_tx(struct iwl4965_priv *priv, 4173static void iwl4965_sta_modify_enable_tid_tx(struct iwl_priv *priv,
4044 int sta_id, int tid) 4174 int sta_id, int tid)
4045{ 4175{
4046 unsigned long flags; 4176 unsigned long flags;
@@ -4061,7 +4191,7 @@ static void iwl4965_sta_modify_enable_tid_tx(struct iwl4965_priv *priv,
4061 * Go through block-ack's bitmap of ACK'd frames, update driver's record of 4191 * Go through block-ack's bitmap of ACK'd frames, update driver's record of
4062 * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. 4192 * ACK vs. not. This gets sent to mac80211, then to rate scaling algo.
4063 */ 4193 */
4064static int iwl4965_tx_status_reply_compressed_ba(struct iwl4965_priv *priv, 4194static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv,
4065 struct iwl4965_ht_agg *agg, 4195 struct iwl4965_ht_agg *agg,
4066 struct iwl4965_compressed_ba_resp* 4196 struct iwl4965_compressed_ba_resp*
4067 ba_resp) 4197 ba_resp)
@@ -4126,7 +4256,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl4965_priv *priv,
4126/** 4256/**
4127 * iwl4965_tx_queue_stop_scheduler - Stop queue, but keep configuration 4257 * iwl4965_tx_queue_stop_scheduler - Stop queue, but keep configuration
4128 */ 4258 */
4129static void iwl4965_tx_queue_stop_scheduler(struct iwl4965_priv *priv, 4259static void iwl4965_tx_queue_stop_scheduler(struct iwl_priv *priv,
4130 u16 txq_id) 4260 u16 txq_id)
4131{ 4261{
4132 /* Simply stop the queue, but don't change any configuration; 4262 /* Simply stop the queue, but don't change any configuration;
@@ -4141,7 +4271,7 @@ static void iwl4965_tx_queue_stop_scheduler(struct iwl4965_priv *priv,
4141 * txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID 4271 * txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID
4142 * priv->lock must be held by the caller 4272 * priv->lock must be held by the caller
4143 */ 4273 */
4144static int iwl4965_tx_queue_agg_disable(struct iwl4965_priv *priv, u16 txq_id, 4274static int iwl4965_tx_queue_agg_disable(struct iwl_priv *priv, u16 txq_id,
4145 u16 ssn_idx, u8 tx_fifo) 4275 u16 ssn_idx, u8 tx_fifo)
4146{ 4276{
4147 int ret = 0; 4277 int ret = 0;
@@ -4174,7 +4304,7 @@ static int iwl4965_tx_queue_agg_disable(struct iwl4965_priv *priv, u16 txq_id,
4174 return 0; 4304 return 0;
4175} 4305}
4176 4306
4177int iwl4965_check_empty_hw_queue(struct iwl4965_priv *priv, int sta_id, 4307int iwl4965_check_empty_hw_queue(struct iwl_priv *priv, int sta_id,
4178 u8 tid, int txq_id) 4308 u8 tid, int txq_id)
4179{ 4309{
4180 struct iwl4965_queue *q = &priv->txq[txq_id].q; 4310 struct iwl4965_queue *q = &priv->txq[txq_id].q;
@@ -4224,7 +4354,7 @@ static inline int iwl4965_queue_dec_wrap(int index, int n_bd)
4224 * Handles block-acknowledge notification from device, which reports success 4354 * Handles block-acknowledge notification from device, which reports success
4225 * of frames sent via aggregation. 4355 * of frames sent via aggregation.
4226 */ 4356 */
4227static void iwl4965_rx_reply_compressed_ba(struct iwl4965_priv *priv, 4357static void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv,
4228 struct iwl4965_rx_mem_buffer *rxb) 4358 struct iwl4965_rx_mem_buffer *rxb)
4229{ 4359{
4230 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 4360 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
@@ -4292,7 +4422,7 @@ static void iwl4965_rx_reply_compressed_ba(struct iwl4965_priv *priv,
4292/** 4422/**
4293 * iwl4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue 4423 * iwl4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue
4294 */ 4424 */
4295static int iwl4965_tx_queue_set_q2ratid(struct iwl4965_priv *priv, u16 ra_tid, 4425static int iwl4965_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
4296 u16 txq_id) 4426 u16 txq_id)
4297{ 4427{
4298 u32 tbl_dw_addr; 4428 u32 tbl_dw_addr;
@@ -4323,7 +4453,7 @@ static int iwl4965_tx_queue_set_q2ratid(struct iwl4965_priv *priv, u16 ra_tid,
4323 * NOTE: txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID, 4453 * NOTE: txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID,
4324 * i.e. it must be one of the higher queues used for aggregation 4454 * i.e. it must be one of the higher queues used for aggregation
4325 */ 4455 */
4326static int iwl4965_tx_queue_agg_enable(struct iwl4965_priv *priv, int txq_id, 4456static int iwl4965_tx_queue_agg_enable(struct iwl_priv *priv, int txq_id,
4327 int tx_fifo, int sta_id, int tid, 4457 int tx_fifo, int sta_id, int tid,
4328 u16 ssn_idx) 4458 u16 ssn_idx)
4329{ 4459{
@@ -4400,7 +4530,7 @@ static int iwl4965_tx_queue_agg_enable(struct iwl4965_priv *priv, int txq_id,
4400 * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, 4530 * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD,
4401 * which requires station table entry to exist). 4531 * which requires station table entry to exist).
4402 */ 4532 */
4403void iwl4965_add_station(struct iwl4965_priv *priv, const u8 *addr, int is_ap) 4533void iwl4965_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
4404{ 4534{
4405 int i, r; 4535 int i, r;
4406 struct iwl4965_link_quality_cmd link_cmd = { 4536 struct iwl4965_link_quality_cmd link_cmd = {
@@ -4439,19 +4569,19 @@ void iwl4965_add_station(struct iwl4965_priv *priv, const u8 *addr, int is_ap)
4439 /* Update the rate scaling for control frame Tx to AP */ 4569 /* Update the rate scaling for control frame Tx to AP */
4440 link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_setting.bcast_sta_id; 4570 link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_setting.bcast_sta_id;
4441 4571
4442 iwl4965_send_cmd_pdu(priv, REPLY_TX_LINK_QUALITY_CMD, sizeof(link_cmd), 4572 iwl_send_cmd_pdu(priv, REPLY_TX_LINK_QUALITY_CMD, sizeof(link_cmd),
4443 &link_cmd); 4573 &link_cmd);
4444} 4574}
4445 4575
4446#ifdef CONFIG_IWL4965_HT 4576#ifdef CONFIG_IWL4965_HT
4447 4577
4448static u8 iwl4965_is_channel_extension(struct iwl4965_priv *priv, 4578static u8 iwl4965_is_channel_extension(struct iwl_priv *priv,
4449 enum ieee80211_band band, 4579 enum ieee80211_band band,
4450 u16 channel, u8 extension_chan_offset) 4580 u16 channel, u8 extension_chan_offset)
4451{ 4581{
4452 const struct iwl4965_channel_info *ch_info; 4582 const struct iwl_channel_info *ch_info;
4453 4583
4454 ch_info = iwl4965_get_channel_info(priv, band, channel); 4584 ch_info = iwl_get_channel_info(priv, band, channel);
4455 if (!is_channel_valid(ch_info)) 4585 if (!is_channel_valid(ch_info))
4456 return 0; 4586 return 0;
4457 4587
@@ -4465,7 +4595,7 @@ static u8 iwl4965_is_channel_extension(struct iwl4965_priv *priv,
4465 return 0; 4595 return 0;
4466} 4596}
4467 4597
4468static u8 iwl4965_is_fat_tx_allowed(struct iwl4965_priv *priv, 4598static u8 iwl4965_is_fat_tx_allowed(struct iwl_priv *priv,
4469 struct ieee80211_ht_info *sta_ht_inf) 4599 struct ieee80211_ht_info *sta_ht_inf)
4470{ 4600{
4471 struct iwl_ht_info *iwl_ht_conf = &priv->current_ht_config; 4601 struct iwl_ht_info *iwl_ht_conf = &priv->current_ht_config;
@@ -4486,7 +4616,7 @@ static u8 iwl4965_is_fat_tx_allowed(struct iwl4965_priv *priv,
4486 iwl_ht_conf->extension_chan_offset)); 4616 iwl_ht_conf->extension_chan_offset));
4487} 4617}
4488 4618
4489void iwl4965_set_rxon_ht(struct iwl4965_priv *priv, struct iwl_ht_info *ht_info) 4619void iwl4965_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info)
4490{ 4620{
4491 struct iwl4965_rxon_cmd *rxon = &priv->staging_rxon; 4621 struct iwl4965_rxon_cmd *rxon = &priv->staging_rxon;
4492 u32 val; 4622 u32 val;
@@ -4540,7 +4670,7 @@ void iwl4965_set_rxon_ht(struct iwl4965_priv *priv, struct iwl_ht_info *ht_info)
4540 return; 4670 return;
4541} 4671}
4542 4672
4543void iwl4965_set_ht_add_station(struct iwl4965_priv *priv, u8 index, 4673void iwl4965_set_ht_add_station(struct iwl_priv *priv, u8 index,
4544 struct ieee80211_ht_info *sta_ht_inf) 4674 struct ieee80211_ht_info *sta_ht_inf)
4545{ 4675{
4546 __le32 sta_flags; 4676 __le32 sta_flags;
@@ -4585,7 +4715,7 @@ void iwl4965_set_ht_add_station(struct iwl4965_priv *priv, u8 index,
4585 return; 4715 return;
4586} 4716}
4587 4717
4588static void iwl4965_sta_modify_add_ba_tid(struct iwl4965_priv *priv, 4718static void iwl4965_sta_modify_add_ba_tid(struct iwl_priv *priv,
4589 int sta_id, int tid, u16 ssn) 4719 int sta_id, int tid, u16 ssn)
4590{ 4720{
4591 unsigned long flags; 4721 unsigned long flags;
@@ -4601,7 +4731,7 @@ static void iwl4965_sta_modify_add_ba_tid(struct iwl4965_priv *priv,
4601 iwl4965_send_add_station(priv, &priv->stations[sta_id].sta, CMD_ASYNC); 4731 iwl4965_send_add_station(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
4602} 4732}
4603 4733
4604static void iwl4965_sta_modify_del_ba_tid(struct iwl4965_priv *priv, 4734static void iwl4965_sta_modify_del_ba_tid(struct iwl_priv *priv,
4605 int sta_id, int tid) 4735 int sta_id, int tid)
4606{ 4736{
4607 unsigned long flags; 4737 unsigned long flags;
@@ -4622,7 +4752,7 @@ static void iwl4965_sta_modify_del_ba_tid(struct iwl4965_priv *priv,
4622 * Should never return anything < 7, because they should already 4752 * Should never return anything < 7, because they should already
4623 * be in use as EDCA AC (0-3), Command (4), HCCA (5, 6). 4753 * be in use as EDCA AC (0-3), Command (4), HCCA (5, 6).
4624 */ 4754 */
4625static int iwl4965_txq_ctx_activate_free(struct iwl4965_priv *priv) 4755static int iwl4965_txq_ctx_activate_free(struct iwl_priv *priv)
4626{ 4756{
4627 int txq_id; 4757 int txq_id;
4628 4758
@@ -4635,7 +4765,7 @@ static int iwl4965_txq_ctx_activate_free(struct iwl4965_priv *priv)
4635static int iwl4965_mac_ht_tx_agg_start(struct ieee80211_hw *hw, const u8 *da, 4765static int iwl4965_mac_ht_tx_agg_start(struct ieee80211_hw *hw, const u8 *da,
4636 u16 tid, u16 *start_seq_num) 4766 u16 tid, u16 *start_seq_num)
4637{ 4767{
4638 struct iwl4965_priv *priv = hw->priv; 4768 struct iwl_priv *priv = hw->priv;
4639 int sta_id; 4769 int sta_id;
4640 int tx_fifo; 4770 int tx_fifo;
4641 int txq_id; 4771 int txq_id;
@@ -4695,7 +4825,7 @@ static int iwl4965_mac_ht_tx_agg_stop(struct ieee80211_hw *hw, const u8 *da,
4695 u16 tid) 4825 u16 tid)
4696{ 4826{
4697 4827
4698 struct iwl4965_priv *priv = hw->priv; 4828 struct iwl_priv *priv = hw->priv;
4699 int tx_fifo_id, txq_id, sta_id, ssn = -1; 4829 int tx_fifo_id, txq_id, sta_id, ssn = -1;
4700 struct iwl4965_tid_data *tid_data; 4830 struct iwl4965_tid_data *tid_data;
4701 int ret, write_ptr, read_ptr; 4831 int ret, write_ptr, read_ptr;
@@ -4756,7 +4886,7 @@ int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
4756 enum ieee80211_ampdu_mlme_action action, 4886 enum ieee80211_ampdu_mlme_action action,
4757 const u8 *addr, u16 tid, u16 *ssn) 4887 const u8 *addr, u16 tid, u16 *ssn)
4758{ 4888{
4759 struct iwl4965_priv *priv = hw->priv; 4889 struct iwl_priv *priv = hw->priv;
4760 int sta_id; 4890 int sta_id;
4761 DECLARE_MAC_BUF(mac); 4891 DECLARE_MAC_BUF(mac);
4762 4892
@@ -4789,10 +4919,10 @@ int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
4789#endif /* CONFIG_IWL4965_HT */ 4919#endif /* CONFIG_IWL4965_HT */
4790 4920
4791/* Set up 4965-specific Rx frame reply handlers */ 4921/* Set up 4965-specific Rx frame reply handlers */
4792void iwl4965_hw_rx_handler_setup(struct iwl4965_priv *priv) 4922void iwl4965_hw_rx_handler_setup(struct iwl_priv *priv)
4793{ 4923{
4794 /* Legacy Rx frames */ 4924 /* Legacy Rx frames */
4795 priv->rx_handlers[REPLY_4965_RX] = iwl4965_rx_reply_rx; 4925 priv->rx_handlers[REPLY_RX] = iwl4965_rx_reply_rx;
4796 4926
4797 /* High-throughput (HT) Rx frames */ 4927 /* High-throughput (HT) Rx frames */
4798 priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl4965_rx_reply_rx_phy; 4928 priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl4965_rx_reply_rx_phy;
@@ -4806,7 +4936,7 @@ void iwl4965_hw_rx_handler_setup(struct iwl4965_priv *priv)
4806#endif /* CONFIG_IWL4965_HT */ 4936#endif /* CONFIG_IWL4965_HT */
4807} 4937}
4808 4938
4809void iwl4965_hw_setup_deferred_work(struct iwl4965_priv *priv) 4939void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv)
4810{ 4940{
4811 INIT_WORK(&priv->txpower_work, iwl4965_bg_txpower_work); 4941 INIT_WORK(&priv->txpower_work, iwl4965_bg_txpower_work);
4812 INIT_WORK(&priv->statistics_work, iwl4965_bg_statistics_work); 4942 INIT_WORK(&priv->statistics_work, iwl4965_bg_statistics_work);
@@ -4818,14 +4948,19 @@ void iwl4965_hw_setup_deferred_work(struct iwl4965_priv *priv)
4818 priv->statistics_periodic.function = iwl4965_bg_statistics_periodic; 4948 priv->statistics_periodic.function = iwl4965_bg_statistics_periodic;
4819} 4949}
4820 4950
4821void iwl4965_hw_cancel_deferred_work(struct iwl4965_priv *priv) 4951void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv)
4822{ 4952{
4823 del_timer_sync(&priv->statistics_periodic); 4953 del_timer_sync(&priv->statistics_periodic);
4824 4954
4825 cancel_delayed_work(&priv->init_alive_start); 4955 cancel_delayed_work(&priv->init_alive_start);
4826} 4956}
4827 4957
4958static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = {
4959 .enqueue_hcmd = iwl4965_enqueue_hcmd,
4960};
4961
4828static struct iwl_lib_ops iwl4965_lib = { 4962static struct iwl_lib_ops iwl4965_lib = {
4963 .init_drv = iwl4965_init_drv,
4829 .eeprom_ops = { 4964 .eeprom_ops = {
4830 .verify_signature = iwlcore_eeprom_verify_signature, 4965 .verify_signature = iwlcore_eeprom_verify_signature,
4831 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore, 4966 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
@@ -4835,6 +4970,7 @@ static struct iwl_lib_ops iwl4965_lib = {
4835 4970
4836static struct iwl_ops iwl4965_ops = { 4971static struct iwl_ops iwl4965_ops = {
4837 .lib = &iwl4965_lib, 4972 .lib = &iwl4965_lib,
4973 .utils = &iwl4965_hcmd_utils,
4838}; 4974};
4839 4975
4840static struct iwl_cfg iwl4965_agn_cfg = { 4976static struct iwl_cfg iwl4965_agn_cfg = {
@@ -4842,6 +4978,7 @@ static struct iwl_cfg iwl4965_agn_cfg = {
4842 .fw_name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode", 4978 .fw_name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode",
4843 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 4979 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
4844 .ops = &iwl4965_ops, 4980 .ops = &iwl4965_ops,
4981 .mod_params = &iwl4965_mod_params,
4845}; 4982};
4846 4983
4847struct pci_device_id iwl4965_hw_card_ids[] = { 4984struct pci_device_id iwl4965_hw_card_ids[] = {
@@ -4851,3 +4988,26 @@ struct pci_device_id iwl4965_hw_card_ids[] = {
4851}; 4988};
4852 4989
4853MODULE_DEVICE_TABLE(pci, iwl4965_hw_card_ids); 4990MODULE_DEVICE_TABLE(pci, iwl4965_hw_card_ids);
4991
4992module_param_named(antenna, iwl4965_mod_params.antenna, int, 0444);
4993MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
4994module_param_named(disable, iwl4965_mod_params.disable, int, 0444);
4995MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
4996module_param_named(hwcrypto, iwl4965_mod_params.hw_crypto, int, 0444);
4997MODULE_PARM_DESC(hwcrypto,
4998 "using hardware crypto engine (default 0 [software])\n");
4999module_param_named(debug, iwl4965_mod_params.debug, int, 0444);
5000MODULE_PARM_DESC(debug, "debug output mask");
5001module_param_named(
5002 disable_hw_scan, iwl4965_mod_params.disable_hw_scan, int, 0444);
5003MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 0)");
5004
5005module_param_named(queues_num, iwl4965_mod_params.num_of_queues, int, 0444);
5006MODULE_PARM_DESC(queues_num, "number of hw queues.");
5007
5008/* QoS */
5009module_param_named(qos_enable, iwl4965_mod_params.enable_qos, int, 0444);
5010MODULE_PARM_DESC(qos_enable, "enable all QoS functionality");
5011module_param_named(amsdu_size_8K, iwl4965_mod_params.amsdu_size_8K, int, 0444);
5012MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size");
5013
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.h b/drivers/net/wireless/iwlwifi/iwl-4965.h
index f4e395fcb807..960b53b20df8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.h
@@ -44,7 +44,7 @@ extern struct pci_device_id iwl4965_hw_card_ids[];
44#include "iwl-4965-hw.h" 44#include "iwl-4965-hw.h"
45#include "iwl-csr.h" 45#include "iwl-csr.h"
46#include "iwl-prph.h" 46#include "iwl-prph.h"
47#include "iwl-4965-debug.h" 47#include "iwl-debug.h"
48 48
49/* Change firmware file name, using "-" and incrementing number, 49/* Change firmware file name, using "-" and incrementing number,
50 * *only* when uCode interface or architecture changes so that it 50 * *only* when uCode interface or architecture changes so that it
@@ -66,11 +66,6 @@ extern struct pci_device_id iwl4965_hw_card_ids[];
66 * averages within an s8's (used in some apps) range of negative values. */ 66 * averages within an s8's (used in some apps) range of negative values. */
67#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127) 67#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
68 68
69/* Module parameters accessible from iwl-*.c */
70extern int iwl4965_param_hwcrypto;
71extern int iwl4965_param_queues_num;
72extern int iwl4965_param_amsdu_size_8K;
73
74enum iwl4965_antenna { 69enum iwl4965_antenna {
75 IWL_ANTENNA_DIVERSITY, 70 IWL_ANTENNA_DIVERSITY,
76 IWL_ANTENNA_MAIN, 71 IWL_ANTENNA_MAIN,
@@ -142,7 +137,7 @@ struct iwl4965_tx_info {
142struct iwl4965_tx_queue { 137struct iwl4965_tx_queue {
143 struct iwl4965_queue q; 138 struct iwl4965_queue q;
144 struct iwl4965_tfd_frame *bd; 139 struct iwl4965_tfd_frame *bd;
145 struct iwl4965_cmd *cmd; 140 struct iwl_cmd *cmd;
146 dma_addr_t dma_addr_cmd; 141 dma_addr_t dma_addr_cmd;
147 struct iwl4965_tx_info *txb; 142 struct iwl4965_tx_info *txb;
148 int need_update; 143 int need_update;
@@ -199,7 +194,7 @@ enum {
199 */ 194 */
200#define IWL4965_MAX_RATE (33) 195#define IWL4965_MAX_RATE (33)
201 196
202struct iwl4965_channel_info { 197struct iwl_channel_info {
203 struct iwl4965_channel_tgd_info tgd; 198 struct iwl4965_channel_tgd_info tgd;
204 struct iwl4965_channel_tgh_info tgh; 199 struct iwl4965_channel_tgh_info tgh;
205 struct iwl4965_eeprom_channel eeprom; /* EEPROM regulatory limit */ 200 struct iwl4965_eeprom_channel eeprom; /* EEPROM regulatory limit */
@@ -314,15 +309,15 @@ enum {
314 CMD_WANT_SKB = (1 << 2), 309 CMD_WANT_SKB = (1 << 2),
315}; 310};
316 311
317struct iwl4965_cmd; 312struct iwl_cmd;
318struct iwl4965_priv; 313struct iwl_priv;
319 314
320struct iwl4965_cmd_meta { 315struct iwl_cmd_meta {
321 struct iwl4965_cmd_meta *source; 316 struct iwl_cmd_meta *source;
322 union { 317 union {
323 struct sk_buff *skb; 318 struct sk_buff *skb;
324 int (*callback)(struct iwl4965_priv *priv, 319 int (*callback)(struct iwl_priv *priv,
325 struct iwl4965_cmd *cmd, struct sk_buff *skb); 320 struct iwl_cmd *cmd, struct sk_buff *skb);
326 } __attribute__ ((packed)) u; 321 } __attribute__ ((packed)) u;
327 322
328 /* The CMD_SIZE_HUGE flag bit indicates that the command 323 /* The CMD_SIZE_HUGE flag bit indicates that the command
@@ -332,15 +327,15 @@ struct iwl4965_cmd_meta {
332} __attribute__ ((packed)); 327} __attribute__ ((packed));
333 328
334/** 329/**
335 * struct iwl4965_cmd 330 * struct iwl_cmd
336 * 331 *
337 * For allocation of the command and tx queues, this establishes the overall 332 * For allocation of the command and tx queues, this establishes the overall
338 * size of the largest command we send to uCode, except for a scan command 333 * size of the largest command we send to uCode, except for a scan command
339 * (which is relatively huge; space is allocated separately). 334 * (which is relatively huge; space is allocated separately).
340 */ 335 */
341struct iwl4965_cmd { 336struct iwl_cmd {
342 struct iwl4965_cmd_meta meta; /* driver data */ 337 struct iwl_cmd_meta meta; /* driver data */
343 struct iwl4965_cmd_header hdr; /* uCode API */ 338 struct iwl_cmd_header hdr; /* uCode API */
344 union { 339 union {
345 struct iwl4965_addsta_cmd addsta; 340 struct iwl4965_addsta_cmd addsta;
346 struct iwl4965_led_cmd led; 341 struct iwl4965_led_cmd led;
@@ -360,15 +355,15 @@ struct iwl4965_cmd {
360 } __attribute__ ((packed)) cmd; 355 } __attribute__ ((packed)) cmd;
361} __attribute__ ((packed)); 356} __attribute__ ((packed));
362 357
363struct iwl4965_host_cmd { 358struct iwl_host_cmd {
364 u8 id; 359 u8 id;
365 u16 len; 360 u16 len;
366 struct iwl4965_cmd_meta meta; 361 struct iwl_cmd_meta meta;
367 const void *data; 362 const void *data;
368}; 363};
369 364
370#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl4965_cmd) - \ 365#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_cmd) - \
371 sizeof(struct iwl4965_cmd_meta)) 366 sizeof(struct iwl_cmd_meta))
372 367
373/* 368/*
374 * RX related structures and functions 369 * RX related structures and functions
@@ -483,6 +478,7 @@ struct iwl4965_tid_data {
483struct iwl4965_hw_key { 478struct iwl4965_hw_key {
484 enum ieee80211_key_alg alg; 479 enum ieee80211_key_alg alg;
485 int keylen; 480 int keylen;
481 struct ieee80211_key_conf *conf;
486 u8 key[32]; 482 u8 key[32];
487}; 483};
488 484
@@ -634,51 +630,50 @@ struct iwl4965_driver_hw_info {
634 * 630 *
635 *****************************************************************************/ 631 *****************************************************************************/
636struct iwl4965_addsta_cmd; 632struct iwl4965_addsta_cmd;
637extern int iwl4965_send_add_station(struct iwl4965_priv *priv, 633extern int iwl4965_send_add_station(struct iwl_priv *priv,
638 struct iwl4965_addsta_cmd *sta, u8 flags); 634 struct iwl4965_addsta_cmd *sta, u8 flags);
639extern u8 iwl4965_add_station_flags(struct iwl4965_priv *priv, const u8 *addr, 635extern u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr,
640 int is_ap, u8 flags, void *ht_data); 636 int is_ap, u8 flags, void *ht_data);
641extern int iwl4965_is_network_packet(struct iwl4965_priv *priv, 637extern int iwl4965_is_network_packet(struct iwl_priv *priv,
642 struct ieee80211_hdr *header); 638 struct ieee80211_hdr *header);
643extern int iwl4965_power_init_handle(struct iwl4965_priv *priv); 639extern int iwl4965_power_init_handle(struct iwl_priv *priv);
644extern void iwl4965_handle_data_packet_monitor(struct iwl4965_priv *priv, 640extern void iwl4965_handle_data_packet_monitor(struct iwl_priv *priv,
645 struct iwl4965_rx_mem_buffer *rxb, 641 struct iwl4965_rx_mem_buffer *rxb,
646 void *data, short len, 642 void *data, short len,
647 struct ieee80211_rx_status *stats, 643 struct ieee80211_rx_status *stats,
648 u16 phy_flags); 644 u16 phy_flags);
649extern int iwl4965_is_duplicate_packet(struct iwl4965_priv *priv, 645extern int iwl4965_is_duplicate_packet(struct iwl_priv *priv,
650 struct ieee80211_hdr *header); 646 struct ieee80211_hdr *header);
651extern int iwl4965_rx_queue_alloc(struct iwl4965_priv *priv); 647extern int iwl4965_rx_queue_alloc(struct iwl_priv *priv);
652extern void iwl4965_rx_queue_reset(struct iwl4965_priv *priv, 648extern void iwl4965_rx_queue_reset(struct iwl_priv *priv,
653 struct iwl4965_rx_queue *rxq); 649 struct iwl4965_rx_queue *rxq);
654extern int iwl4965_calc_db_from_ratio(int sig_ratio); 650extern int iwl4965_calc_db_from_ratio(int sig_ratio);
655extern int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm); 651extern int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm);
656extern int iwl4965_tx_queue_init(struct iwl4965_priv *priv, 652extern int iwl4965_tx_queue_init(struct iwl_priv *priv,
657 struct iwl4965_tx_queue *txq, int count, u32 id); 653 struct iwl4965_tx_queue *txq, int count, u32 id);
658extern void iwl4965_rx_replenish(void *data); 654extern void iwl4965_rx_replenish(void *data);
659extern void iwl4965_tx_queue_free(struct iwl4965_priv *priv, struct iwl4965_tx_queue *txq); 655extern void iwl4965_tx_queue_free(struct iwl_priv *priv, struct iwl4965_tx_queue *txq);
660extern int iwl4965_send_cmd_pdu(struct iwl4965_priv *priv, u8 id, u16 len, 656extern unsigned int iwl4965_fill_beacon_frame(struct iwl_priv *priv,
661 const void *data);
662extern int __must_check iwl4965_send_cmd(struct iwl4965_priv *priv,
663 struct iwl4965_host_cmd *cmd);
664extern unsigned int iwl4965_fill_beacon_frame(struct iwl4965_priv *priv,
665 struct ieee80211_hdr *hdr, 657 struct ieee80211_hdr *hdr,
666 const u8 *dest, int left); 658 const u8 *dest, int left);
667extern int iwl4965_rx_queue_update_write_ptr(struct iwl4965_priv *priv, 659extern int iwl4965_rx_queue_update_write_ptr(struct iwl_priv *priv,
668 struct iwl4965_rx_queue *q); 660 struct iwl4965_rx_queue *q);
669extern int iwl4965_send_statistics_request(struct iwl4965_priv *priv); 661extern int iwl4965_send_statistics_request(struct iwl_priv *priv);
670extern void iwl4965_set_decrypted_flag(struct iwl4965_priv *priv, struct sk_buff *skb, 662extern void iwl4965_set_decrypted_flag(struct iwl_priv *priv, struct sk_buff *skb,
671 u32 decrypt_res, 663 u32 decrypt_res,
672 struct ieee80211_rx_status *stats); 664 struct ieee80211_rx_status *stats);
673extern __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr); 665extern __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr);
666int iwl4965_init_geos(struct iwl_priv *priv);
667void iwl4965_free_geos(struct iwl_priv *priv);
674 668
675extern const u8 iwl4965_broadcast_addr[ETH_ALEN]; 669extern const u8 iwl4965_broadcast_addr[ETH_ALEN];
670int iwl4965_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
676 671
677/* 672/*
678 * Currently used by iwl-3945-rs... look at restructuring so that it doesn't 673 * Currently used by iwl-3945-rs... look at restructuring so that it doesn't
679 * call this... todo... fix that. 674 * call this... todo... fix that.
680*/ 675*/
681extern u8 iwl4965_sync_station(struct iwl4965_priv *priv, int sta_id, 676extern u8 iwl4965_sync_station(struct iwl_priv *priv, int sta_id,
682 u16 tx_rate, u8 flags); 677 u16 tx_rate, u8 flags);
683 678
684/****************************************************************************** 679/******************************************************************************
@@ -697,36 +692,36 @@ extern u8 iwl4965_sync_station(struct iwl4965_priv *priv, int sta_id,
697 * iwl4965_mac_ <-- mac80211 callback 692 * iwl4965_mac_ <-- mac80211 callback
698 * 693 *
699 ****************************************************************************/ 694 ****************************************************************************/
700extern void iwl4965_hw_rx_handler_setup(struct iwl4965_priv *priv); 695extern void iwl4965_hw_rx_handler_setup(struct iwl_priv *priv);
701extern void iwl4965_hw_setup_deferred_work(struct iwl4965_priv *priv); 696extern void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv);
702extern void iwl4965_hw_cancel_deferred_work(struct iwl4965_priv *priv); 697extern void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv);
703extern int iwl4965_hw_rxq_stop(struct iwl4965_priv *priv); 698extern int iwl4965_hw_rxq_stop(struct iwl_priv *priv);
704extern int iwl4965_hw_set_hw_setting(struct iwl4965_priv *priv); 699extern int iwl4965_hw_set_hw_setting(struct iwl_priv *priv);
705extern int iwl4965_hw_nic_init(struct iwl4965_priv *priv); 700extern int iwl4965_hw_nic_init(struct iwl_priv *priv);
706extern int iwl4965_hw_nic_stop_master(struct iwl4965_priv *priv); 701extern int iwl4965_hw_nic_stop_master(struct iwl_priv *priv);
707extern void iwl4965_hw_txq_ctx_free(struct iwl4965_priv *priv); 702extern void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv);
708extern void iwl4965_hw_txq_ctx_stop(struct iwl4965_priv *priv); 703extern void iwl4965_hw_txq_ctx_stop(struct iwl_priv *priv);
709extern int iwl4965_hw_nic_reset(struct iwl4965_priv *priv); 704extern int iwl4965_hw_nic_reset(struct iwl_priv *priv);
710extern int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl4965_priv *priv, void *tfd, 705extern int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *tfd,
711 dma_addr_t addr, u16 len); 706 dma_addr_t addr, u16 len);
712extern int iwl4965_hw_txq_free_tfd(struct iwl4965_priv *priv, struct iwl4965_tx_queue *txq); 707extern int iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl4965_tx_queue *txq);
713extern int iwl4965_hw_get_temperature(struct iwl4965_priv *priv); 708extern int iwl4965_hw_get_temperature(struct iwl_priv *priv);
714extern int iwl4965_hw_tx_queue_init(struct iwl4965_priv *priv, 709extern int iwl4965_hw_tx_queue_init(struct iwl_priv *priv,
715 struct iwl4965_tx_queue *txq); 710 struct iwl4965_tx_queue *txq);
716extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl4965_priv *priv, 711extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
717 struct iwl4965_frame *frame, u8 rate); 712 struct iwl4965_frame *frame, u8 rate);
718extern int iwl4965_hw_get_rx_read(struct iwl4965_priv *priv); 713extern int iwl4965_hw_get_rx_read(struct iwl_priv *priv);
719extern void iwl4965_hw_build_tx_cmd_rate(struct iwl4965_priv *priv, 714extern void iwl4965_hw_build_tx_cmd_rate(struct iwl_priv *priv,
720 struct iwl4965_cmd *cmd, 715 struct iwl_cmd *cmd,
721 struct ieee80211_tx_control *ctrl, 716 struct ieee80211_tx_control *ctrl,
722 struct ieee80211_hdr *hdr, 717 struct ieee80211_hdr *hdr,
723 int sta_id, int tx_id); 718 int sta_id, int tx_id);
724extern int iwl4965_hw_reg_send_txpower(struct iwl4965_priv *priv); 719extern int iwl4965_hw_reg_send_txpower(struct iwl_priv *priv);
725extern int iwl4965_hw_reg_set_txpower(struct iwl4965_priv *priv, s8 power); 720extern int iwl4965_hw_reg_set_txpower(struct iwl_priv *priv, s8 power);
726extern void iwl4965_hw_rx_statistics(struct iwl4965_priv *priv, 721extern void iwl4965_hw_rx_statistics(struct iwl_priv *priv,
727 struct iwl4965_rx_mem_buffer *rxb); 722 struct iwl4965_rx_mem_buffer *rxb);
728extern void iwl4965_disable_events(struct iwl4965_priv *priv); 723extern void iwl4965_disable_events(struct iwl_priv *priv);
729extern int iwl4965_get_temperature(const struct iwl4965_priv *priv); 724extern int iwl4965_get_temperature(const struct iwl_priv *priv);
730 725
731/** 726/**
732 * iwl4965_hw_find_station - Find station id for a given BSSID 727 * iwl4965_hw_find_station - Find station id for a given BSSID
@@ -736,51 +731,48 @@ extern int iwl4965_get_temperature(const struct iwl4965_priv *priv);
736 * not yet been merged into a single common layer for managing the 731 * not yet been merged into a single common layer for managing the
737 * station tables. 732 * station tables.
738 */ 733 */
739extern u8 iwl4965_hw_find_station(struct iwl4965_priv *priv, const u8 *bssid); 734extern u8 iwl4965_hw_find_station(struct iwl_priv *priv, const u8 *bssid);
740 735
741extern int iwl4965_hw_channel_switch(struct iwl4965_priv *priv, u16 channel); 736extern int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel);
742extern int iwl4965_tx_queue_reclaim(struct iwl4965_priv *priv, int txq_id, int index); 737extern int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index);
743extern int iwl4965_queue_space(const struct iwl4965_queue *q); 738extern int iwl4965_queue_space(const struct iwl4965_queue *q);
744struct iwl4965_priv; 739struct iwl_priv;
745 740
746/* 741/*
747 * Forward declare iwl-4965.c functions for iwl-base.c 742 * Forward declare iwl-4965.c functions for iwl-base.c
748 */ 743 */
749extern int iwl4965_tx_queue_update_wr_ptr(struct iwl4965_priv *priv, 744extern int iwl4965_tx_queue_update_wr_ptr(struct iwl_priv *priv,
750 struct iwl4965_tx_queue *txq, 745 struct iwl4965_tx_queue *txq,
751 u16 byte_cnt); 746 u16 byte_cnt);
752extern void iwl4965_add_station(struct iwl4965_priv *priv, const u8 *addr, 747extern void iwl4965_add_station(struct iwl_priv *priv, const u8 *addr,
753 int is_ap); 748 int is_ap);
754extern void iwl4965_set_rxon_chain(struct iwl4965_priv *priv); 749extern void iwl4965_set_rxon_chain(struct iwl_priv *priv);
755extern int iwl4965_alive_notify(struct iwl4965_priv *priv); 750extern int iwl4965_alive_notify(struct iwl_priv *priv);
756extern void iwl4965_update_rate_scaling(struct iwl4965_priv *priv, u8 mode); 751extern void iwl4965_update_rate_scaling(struct iwl_priv *priv, u8 mode);
757extern void iwl4965_chain_noise_reset(struct iwl4965_priv *priv); 752extern void iwl4965_chain_noise_reset(struct iwl_priv *priv);
758extern void iwl4965_init_sensitivity(struct iwl4965_priv *priv, u8 flags, 753extern void iwl4965_init_sensitivity(struct iwl_priv *priv, u8 flags,
759 u8 force); 754 u8 force);
760extern int iwl4965_set_fat_chan_info(struct iwl4965_priv *priv, 755extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv);
761 enum ieee80211_band band, 756extern void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv,
762 u16 channel,
763 const struct iwl4965_eeprom_channel *eeprom_ch,
764 u8 fat_extension_channel);
765extern void iwl4965_rf_kill_ct_config(struct iwl4965_priv *priv);
766extern void iwl4965_hwrate_to_tx_control(struct iwl4965_priv *priv,
767 u32 rate_n_flags, 757 u32 rate_n_flags,
768 struct ieee80211_tx_control *control); 758 struct ieee80211_tx_control *control);
769 759
770#ifdef CONFIG_IWL4965_HT 760#ifdef CONFIG_IWL4965_HT
771void iwl4965_init_ht_hw_capab(struct ieee80211_ht_info *ht_info, 761void iwl4965_init_ht_hw_capab(struct iwl_priv *priv,
762 struct ieee80211_ht_info *ht_info,
772 enum ieee80211_band band); 763 enum ieee80211_band band);
773void iwl4965_set_rxon_ht(struct iwl4965_priv *priv, 764void iwl4965_set_rxon_ht(struct iwl_priv *priv,
774 struct iwl_ht_info *ht_info); 765 struct iwl_ht_info *ht_info);
775void iwl4965_set_ht_add_station(struct iwl4965_priv *priv, u8 index, 766void iwl4965_set_ht_add_station(struct iwl_priv *priv, u8 index,
776 struct ieee80211_ht_info *sta_ht_inf); 767 struct ieee80211_ht_info *sta_ht_inf);
777int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, 768int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
778 enum ieee80211_ampdu_mlme_action action, 769 enum ieee80211_ampdu_mlme_action action,
779 const u8 *addr, u16 tid, u16 *ssn); 770 const u8 *addr, u16 tid, u16 *ssn);
780int iwl4965_check_empty_hw_queue(struct iwl4965_priv *priv, int sta_id, 771int iwl4965_check_empty_hw_queue(struct iwl_priv *priv, int sta_id,
781 u8 tid, int txq_id); 772 u8 tid, int txq_id);
782#else 773#else
783static inline void iwl4965_init_ht_hw_capab(struct ieee80211_ht_info *ht_info, 774static inline void iwl4965_init_ht_hw_capab(struct iwl_priv *priv,
775 struct ieee80211_ht_info *ht_info,
784 enum ieee80211_band band) {} 776 enum ieee80211_band band) {}
785 777
786#endif /*CONFIG_IWL4965_HT */ 778#endif /*CONFIG_IWL4965_HT */
@@ -966,7 +958,7 @@ enum {
966 958
967#endif 959#endif
968 960
969struct iwl4965_priv { 961struct iwl_priv {
970 962
971 /* ieee device used by generic ieee processing code */ 963 /* ieee device used by generic ieee processing code */
972 struct ieee80211_hw *hw; 964 struct ieee80211_hw *hw;
@@ -982,7 +974,7 @@ struct iwl4965_priv {
982 int alloc_rxb_skb; 974 int alloc_rxb_skb;
983 bool add_radiotap; 975 bool add_radiotap;
984 976
985 void (*rx_handlers[REPLY_MAX])(struct iwl4965_priv *priv, 977 void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
986 struct iwl4965_rx_mem_buffer *rxb); 978 struct iwl4965_rx_mem_buffer *rxb);
987 979
988 struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; 980 struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
@@ -997,7 +989,7 @@ struct iwl4965_priv {
997 989
998 /* we allocate array of iwl4965_channel_info for NIC's valid channels. 990 /* we allocate array of iwl4965_channel_info for NIC's valid channels.
999 * Access via channel # using indirect index array */ 991 * Access via channel # using indirect index array */
1000 struct iwl4965_channel_info *channel_info; /* channel info array */ 992 struct iwl_channel_info *channel_info; /* channel info array */
1001 u8 channel_count; /* # of channels */ 993 u8 channel_count; /* # of channels */
1002 994
1003 /* each calibration channel group in the EEPROM has a derived 995 /* each calibration channel group in the EEPROM has a derived
@@ -1107,6 +1099,12 @@ struct iwl4965_priv {
1107 int last_rx_rssi; /* From Rx packet statisitics */ 1099 int last_rx_rssi; /* From Rx packet statisitics */
1108 int last_rx_noise; /* From beacon statistics */ 1100 int last_rx_noise; /* From beacon statistics */
1109 1101
1102 /* counts mgmt, ctl, and data packets */
1103 struct traffic_stats {
1104 u32 cnt;
1105 u64 bytes;
1106 } tx_stats[3], rx_stats[3];
1107
1110 struct iwl4965_power_mgr power_data; 1108 struct iwl4965_power_mgr power_data;
1111 1109
1112 struct iwl4965_notif_statistics statistics; 1110 struct iwl4965_notif_statistics statistics;
@@ -1202,11 +1200,15 @@ struct iwl4965_priv {
1202 u32 pm_state[16]; 1200 u32 pm_state[16];
1203#endif 1201#endif
1204 1202
1205#ifdef CONFIG_IWL4965_DEBUG 1203#ifdef CONFIG_IWLWIFI_DEBUG
1206 /* debugging info */ 1204 /* debugging info */
1207 u32 framecnt_to_us; 1205 u32 framecnt_to_us;
1208 atomic_t restrict_refcnt; 1206 atomic_t restrict_refcnt;
1209#endif 1207#ifdef CONFIG_IWLWIFI_DEBUGFS
1208 /* debugfs */
1209 struct iwl_debugfs *dbgfs;
1210#endif /* CONFIG_IWLWIFI_DEBUGFS */
1211#endif /* CONFIG_IWLWIFI_DEBUG */
1210 1212
1211 struct work_struct txpower_work; 1213 struct work_struct txpower_work;
1212#ifdef CONFIG_IWL4965_SENSITIVITY 1214#ifdef CONFIG_IWL4965_SENSITIVITY
@@ -1214,54 +1216,54 @@ struct iwl4965_priv {
1214#endif 1216#endif
1215 struct work_struct statistics_work; 1217 struct work_struct statistics_work;
1216 struct timer_list statistics_periodic; 1218 struct timer_list statistics_periodic;
1217}; /*iwl4965_priv */ 1219}; /*iwl_priv */
1218 1220
1219static inline int iwl4965_is_associated(struct iwl4965_priv *priv) 1221static inline int iwl4965_is_associated(struct iwl_priv *priv)
1220{ 1222{
1221 return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; 1223 return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
1222} 1224}
1223 1225
1224static inline int is_channel_valid(const struct iwl4965_channel_info *ch_info) 1226static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
1225{ 1227{
1226 if (ch_info == NULL) 1228 if (ch_info == NULL)
1227 return 0; 1229 return 0;
1228 return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; 1230 return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
1229} 1231}
1230 1232
1231static inline int is_channel_narrow(const struct iwl4965_channel_info *ch_info) 1233static inline int is_channel_narrow(const struct iwl_channel_info *ch_info)
1232{ 1234{
1233 return (ch_info->flags & EEPROM_CHANNEL_NARROW) ? 1 : 0; 1235 return (ch_info->flags & EEPROM_CHANNEL_NARROW) ? 1 : 0;
1234} 1236}
1235 1237
1236static inline int is_channel_radar(const struct iwl4965_channel_info *ch_info) 1238static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
1237{ 1239{
1238 return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; 1240 return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
1239} 1241}
1240 1242
1241static inline u8 is_channel_a_band(const struct iwl4965_channel_info *ch_info) 1243static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
1242{ 1244{
1243 return ch_info->band == IEEE80211_BAND_5GHZ; 1245 return ch_info->band == IEEE80211_BAND_5GHZ;
1244} 1246}
1245 1247
1246static inline u8 is_channel_bg_band(const struct iwl4965_channel_info *ch_info) 1248static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
1247{ 1249{
1248 return ch_info->band == IEEE80211_BAND_2GHZ; 1250 return ch_info->band == IEEE80211_BAND_2GHZ;
1249} 1251}
1250 1252
1251static inline int is_channel_passive(const struct iwl4965_channel_info *ch) 1253static inline int is_channel_passive(const struct iwl_channel_info *ch)
1252{ 1254{
1253 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; 1255 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
1254} 1256}
1255 1257
1256static inline int is_channel_ibss(const struct iwl4965_channel_info *ch) 1258static inline int is_channel_ibss(const struct iwl_channel_info *ch)
1257{ 1259{
1258 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0; 1260 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
1259} 1261}
1260 1262
1261extern const struct iwl4965_channel_info *iwl4965_get_channel_info( 1263extern const struct iwl_channel_info *iwl_get_channel_info(
1262 const struct iwl4965_priv *priv, enum ieee80211_band band, u16 channel); 1264 const struct iwl_priv *priv, enum ieee80211_band band, u16 channel);
1263 1265
1264/* Requires full declaration of iwl4965_priv before including */ 1266/* Requires full declaration of iwl_priv before including */
1265#include "iwl-4965-io.h" 1267#include "iwl-4965-io.h"
1266 1268
1267#endif /* __iwl4965_4965_h__ */ 1269#endif /* __iwl4965_4965_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 9ca539861db2..da51349cbd8b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -29,17 +29,223 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/version.h> 31#include <linux/version.h>
32#include <net/mac80211.h>
32 33
33#include "iwl-4965-debug.h" 34struct iwl_priv; /* FIXME: remove */
35#include "iwl-debug.h"
34#include "iwl-eeprom.h" 36#include "iwl-eeprom.h"
35#include "iwl-core.h" 37#include "iwl-core.h"
36 38
39#include "iwl-4965.h" /* FIXME: remove */
40
37MODULE_DESCRIPTION("iwl core"); 41MODULE_DESCRIPTION("iwl core");
38MODULE_VERSION(IWLWIFI_VERSION); 42MODULE_VERSION(IWLWIFI_VERSION);
39MODULE_AUTHOR(DRV_COPYRIGHT); 43MODULE_AUTHOR(DRV_COPYRIGHT);
40MODULE_LICENSE("GPL/BSD"); 44MODULE_LICENSE("GPL");
41 45
42#ifdef CONFIG_IWL4965_DEBUG 46#ifdef CONFIG_IWLWIFI_DEBUG
43u32 iwl4965_debug_level; 47u32 iwl_debug_level;
44EXPORT_SYMBOL(iwl4965_debug_level); 48EXPORT_SYMBOL(iwl_debug_level);
45#endif 49#endif
50
51/* This function both allocates and initializes hw and priv. */
52struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg,
53 struct ieee80211_ops *hw_ops)
54{
55 struct iwl_priv *priv;
56
57 /* mac80211 allocates memory for this device instance, including
58 * space for this driver's private structure */
59 struct ieee80211_hw *hw =
60 ieee80211_alloc_hw(sizeof(struct iwl_priv), hw_ops);
61 if (hw == NULL) {
62 IWL_ERROR("Can not allocate network device\n");
63 goto out;
64 }
65
66 priv = hw->priv;
67 priv->hw = hw;
68
69out:
70 return hw;
71}
72EXPORT_SYMBOL(iwl_alloc_all);
73
74/**
75 * iwlcore_clear_stations_table - Clear the driver's station table
76 *
77 * NOTE: This does not clear or otherwise alter the device's station table.
78 */
79void iwlcore_clear_stations_table(struct iwl_priv *priv)
80{
81 unsigned long flags;
82
83 spin_lock_irqsave(&priv->sta_lock, flags);
84
85 priv->num_stations = 0;
86 memset(priv->stations, 0, sizeof(priv->stations));
87
88 spin_unlock_irqrestore(&priv->sta_lock, flags);
89}
90EXPORT_SYMBOL(iwlcore_clear_stations_table);
91
92void iwlcore_reset_qos(struct iwl_priv *priv)
93{
94 u16 cw_min = 15;
95 u16 cw_max = 1023;
96 u8 aifs = 2;
97 u8 is_legacy = 0;
98 unsigned long flags;
99 int i;
100
101 spin_lock_irqsave(&priv->lock, flags);
102 priv->qos_data.qos_active = 0;
103
104 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) {
105 if (priv->qos_data.qos_enable)
106 priv->qos_data.qos_active = 1;
107 if (!(priv->active_rate & 0xfff0)) {
108 cw_min = 31;
109 is_legacy = 1;
110 }
111 } else if (priv->iw_mode == IEEE80211_IF_TYPE_AP) {
112 if (priv->qos_data.qos_enable)
113 priv->qos_data.qos_active = 1;
114 } else if (!(priv->staging_rxon.flags & RXON_FLG_SHORT_SLOT_MSK)) {
115 cw_min = 31;
116 is_legacy = 1;
117 }
118
119 if (priv->qos_data.qos_active)
120 aifs = 3;
121
122 priv->qos_data.def_qos_parm.ac[0].cw_min = cpu_to_le16(cw_min);
123 priv->qos_data.def_qos_parm.ac[0].cw_max = cpu_to_le16(cw_max);
124 priv->qos_data.def_qos_parm.ac[0].aifsn = aifs;
125 priv->qos_data.def_qos_parm.ac[0].edca_txop = 0;
126 priv->qos_data.def_qos_parm.ac[0].reserved1 = 0;
127
128 if (priv->qos_data.qos_active) {
129 i = 1;
130 priv->qos_data.def_qos_parm.ac[i].cw_min = cpu_to_le16(cw_min);
131 priv->qos_data.def_qos_parm.ac[i].cw_max = cpu_to_le16(cw_max);
132 priv->qos_data.def_qos_parm.ac[i].aifsn = 7;
133 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
134 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
135
136 i = 2;
137 priv->qos_data.def_qos_parm.ac[i].cw_min =
138 cpu_to_le16((cw_min + 1) / 2 - 1);
139 priv->qos_data.def_qos_parm.ac[i].cw_max =
140 cpu_to_le16(cw_max);
141 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
142 if (is_legacy)
143 priv->qos_data.def_qos_parm.ac[i].edca_txop =
144 cpu_to_le16(6016);
145 else
146 priv->qos_data.def_qos_parm.ac[i].edca_txop =
147 cpu_to_le16(3008);
148 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
149
150 i = 3;
151 priv->qos_data.def_qos_parm.ac[i].cw_min =
152 cpu_to_le16((cw_min + 1) / 4 - 1);
153 priv->qos_data.def_qos_parm.ac[i].cw_max =
154 cpu_to_le16((cw_max + 1) / 2 - 1);
155 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
156 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
157 if (is_legacy)
158 priv->qos_data.def_qos_parm.ac[i].edca_txop =
159 cpu_to_le16(3264);
160 else
161 priv->qos_data.def_qos_parm.ac[i].edca_txop =
162 cpu_to_le16(1504);
163 } else {
164 for (i = 1; i < 4; i++) {
165 priv->qos_data.def_qos_parm.ac[i].cw_min =
166 cpu_to_le16(cw_min);
167 priv->qos_data.def_qos_parm.ac[i].cw_max =
168 cpu_to_le16(cw_max);
169 priv->qos_data.def_qos_parm.ac[i].aifsn = aifs;
170 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
171 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
172 }
173 }
174 IWL_DEBUG_QOS("set QoS to default \n");
175
176 spin_unlock_irqrestore(&priv->lock, flags);
177}
178EXPORT_SYMBOL(iwlcore_reset_qos);
179
180/**
181 * iwlcore_set_rxon_channel - Set the phymode and channel values in staging RXON
182 * @phymode: MODE_IEEE80211A sets to 5.2GHz; all else set to 2.4GHz
183 * @channel: Any channel valid for the requested phymode
184
185 * In addition to setting the staging RXON, priv->phymode is also set.
186 *
187 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
188 * in the staging RXON flag structure based on the phymode
189 */
190int iwlcore_set_rxon_channel(struct iwl_priv *priv,
191 enum ieee80211_band band,
192 u16 channel)
193{
194 if (!iwl_get_channel_info(priv, band, channel)) {
195 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n",
196 channel, band);
197 return -EINVAL;
198 }
199
200 if ((le16_to_cpu(priv->staging_rxon.channel) == channel) &&
201 (priv->band == band))
202 return 0;
203
204 priv->staging_rxon.channel = cpu_to_le16(channel);
205 if (band == IEEE80211_BAND_5GHZ)
206 priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK;
207 else
208 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
209
210 priv->band = band;
211
212 IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band);
213
214 return 0;
215}
216EXPORT_SYMBOL(iwlcore_set_rxon_channel);
217
218static void iwlcore_init_hw(struct iwl_priv *priv)
219{
220 struct ieee80211_hw *hw = priv->hw;
221 hw->rate_control_algorithm = "iwl-4965-rs";
222
223 /* Tell mac80211 and its clients (e.g. Wireless Extensions)
224 * the range of signal quality values that we'll provide.
225 * Negative values for level/noise indicate that we'll provide dBm.
226 * For WE, at least, non-0 values here *enable* display of values
227 * in app (iwconfig). */
228 hw->max_rssi = -20; /* signal level, negative indicates dBm */
229 hw->max_noise = -20; /* noise level, negative indicates dBm */
230 hw->max_signal = 100; /* link quality indication (%) */
231
232 /* Tell mac80211 our Tx characteristics */
233 hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE;
234
235 /* Default value; 4 EDCA QOS priorities */
236 hw->queues = 4;
237#ifdef CONFIG_IWL4965_HT
238 /* Enhanced value; more queues, to support 11n aggregation */
239 hw->queues = 16;
240#endif /* CONFIG_IWL4965_HT */
241}
242
243int iwl_setup(struct iwl_priv *priv)
244{
245 int ret = 0;
246 iwlcore_init_hw(priv);
247 ret = priv->cfg->ops->lib->init_drv(priv);
248 return ret;
249}
250EXPORT_SYMBOL(iwl_setup);
251
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 88fd49abdabd..ce7f90ebf367 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -63,6 +63,13 @@
63#ifndef __iwl_core_h__ 63#ifndef __iwl_core_h__
64#define __iwl_core_h__ 64#define __iwl_core_h__
65 65
66/************************
67 * forward declarations *
68 ************************/
69struct iwl_host_cmd;
70struct iwl_cmd;
71
72
66#define IWLWIFI_VERSION "1.2.26k" 73#define IWLWIFI_VERSION "1.2.26k"
67#define DRV_COPYRIGHT "Copyright(c) 2003-2008 Intel Corporation" 74#define DRV_COPYRIGHT "Copyright(c) 2003-2008 Intel Corporation"
68 75
@@ -75,13 +82,31 @@
75#define IWL_SKU_A 0x2 82#define IWL_SKU_A 0x2
76#define IWL_SKU_N 0x8 83#define IWL_SKU_N 0x8
77 84
85struct iwl_hcmd_utils_ops {
86 int (*enqueue_hcmd)(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
87};
88
78struct iwl_lib_ops { 89struct iwl_lib_ops {
90 /* iwlwifi driver (priv) init */
91 int (*init_drv)(struct iwl_priv *priv);
79 /* eeprom operations (as defined in iwl-eeprom.h) */ 92 /* eeprom operations (as defined in iwl-eeprom.h) */
80 struct iwl_eeprom_ops eeprom_ops; 93 struct iwl_eeprom_ops eeprom_ops;
81}; 94};
82 95
83struct iwl_ops { 96struct iwl_ops {
84 const struct iwl_lib_ops *lib; 97 const struct iwl_lib_ops *lib;
98 const struct iwl_hcmd_utils_ops *utils;
99};
100
101struct iwl_mod_params {
102 int disable; /* def: 0 = enable radio */
103 int hw_crypto; /* def: 0 = using software encryption */
104 int debug; /* def: 0 = minimal debug log messages */
105 int disable_hw_scan; /* def: 0 = use h/w scan */
106 int num_of_queues; /* def: HW dependent */
107 int enable_qos; /* def: 1 = use quality of service */
108 int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */
109 int antenna; /* def: 0 = both antennas (use diversity) */
85}; 110};
86 111
87struct iwl_cfg { 112struct iwl_cfg {
@@ -89,6 +114,36 @@ struct iwl_cfg {
89 const char *fw_name; 114 const char *fw_name;
90 unsigned int sku; 115 unsigned int sku;
91 const struct iwl_ops *ops; 116 const struct iwl_ops *ops;
117 const struct iwl_mod_params *mod_params;
92}; 118};
93 119
120/***************************
121 * L i b *
122 ***************************/
123
124struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg,
125 struct ieee80211_ops *hw_ops);
126
127void iwlcore_clear_stations_table(struct iwl_priv *priv);
128void iwlcore_reset_qos(struct iwl_priv *priv);
129int iwlcore_set_rxon_channel(struct iwl_priv *priv,
130 enum ieee80211_band band,
131 u16 channel);
132
133int iwl_setup(struct iwl_priv *priv);
134
135/*****************************************************
136 * S e n d i n g H o s t C o m m a n d s *
137 *****************************************************/
138
139const char *get_cmd_string(u8 cmd);
140int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
141int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
142int iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u16 len, const void *data);
143int iwl_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len,
144 const void *data,
145 int (*callback)(struct iwl_priv *priv,
146 struct iwl_cmd *cmd,
147 struct sk_buff *skb));
148
94#endif /* __iwl_core_h__ */ 149#endif /* __iwl_core_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index df329481bb45..c60724c21db8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -26,43 +26,72 @@
26 * 26 *
27 *****************************************************************************/ 27 *****************************************************************************/
28 28
29#ifndef __iwl4965_debug_h__ 29#ifndef __iwl_debug_h__
30#define __iwl4965_debug_h__ 30#define __iwl_debug_h__
31 31
32#ifdef CONFIG_IWL4965_DEBUG 32#ifdef CONFIG_IWLWIFI_DEBUG
33extern u32 iwl4965_debug_level; 33extern u32 iwl_debug_level;
34#define IWL_DEBUG(level, fmt, args...) \ 34#define IWL_DEBUG(level, fmt, args...) \
35do { if (iwl4965_debug_level & (level)) \ 35do { if (iwl_debug_level & (level)) \
36 printk(KERN_ERR DRV_NAME": %c %s " fmt, \ 36 printk(KERN_ERR DRV_NAME": %c %s " fmt, \
37 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 37 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
38 38
39#define IWL_DEBUG_LIMIT(level, fmt, args...) \ 39#define IWL_DEBUG_LIMIT(level, fmt, args...) \
40do { if ((iwl4965_debug_level & (level)) && net_ratelimit()) \ 40do { if ((iwl_debug_level & (level)) && net_ratelimit()) \
41 printk(KERN_ERR DRV_NAME": %c %s " fmt, \ 41 printk(KERN_ERR DRV_NAME": %c %s " fmt, \
42 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 42 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
43 43
44static inline void iwl4965_print_hex_dump(int level, void *p, u32 len) 44static inline void iwl_print_hex_dump(int level, void *p, u32 len)
45{ 45{
46 if (!(iwl4965_debug_level & level)) 46 if (!(iwl_debug_level & level))
47 return; 47 return;
48 48
49 print_hex_dump(KERN_DEBUG, "iwl data: ", DUMP_PREFIX_OFFSET, 16, 1, 49 print_hex_dump(KERN_DEBUG, "iwl data: ", DUMP_PREFIX_OFFSET, 16, 1,
50 p, len, 1); 50 p, len, 1);
51} 51}
52#else
53 52
53#ifdef CONFIG_IWLWIFI_DEBUGFS
54struct iwl_debugfs {
55 const char *name;
56 struct dentry *dir_drv;
57 struct dentry *dir_data;
58 struct dir_data_files{
59 struct dentry *file_sram;
60 struct dentry *file_stations;
61 struct dentry *file_rx_statistics;
62 struct dentry *file_tx_statistics;
63 } dbgfs_data_files;
64 u32 sram_offset;
65 u32 sram_len;
66};
67
68int iwl_dbgfs_register(struct iwl_priv *priv, const char *name);
69void iwl_dbgfs_unregister(struct iwl_priv *priv);
70#endif
71
72#else
54static inline void IWL_DEBUG(int level, const char *fmt, ...) 73static inline void IWL_DEBUG(int level, const char *fmt, ...)
55{ 74{
56} 75}
57static inline void IWL_DEBUG_LIMIT(int level, const char *fmt, ...) 76static inline void IWL_DEBUG_LIMIT(int level, const char *fmt, ...)
58{ 77{
59} 78}
60static inline void iwl4965_print_hex_dump(int level, void *p, u32 len) 79static inline void iwl_print_hex_dump(int level, void *p, u32 len)
61{ 80{
62} 81}
63#endif /* CONFIG_IWL4965_DEBUG */ 82#endif /* CONFIG_IWLWIFI_DEBUG */
83
64 84
65 85
86#ifndef CONFIG_IWLWIFI_DEBUGFS
87static inline int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
88{
89 return 0;
90}
91static inline void iwl_dbgfs_unregister(struct iwl_priv *priv)
92{
93}
94#endif /* CONFIG_IWLWIFI_DEBUGFS */
66 95
67/* 96/*
68 * To use the debug system; 97 * To use the debug system;
@@ -83,10 +112,10 @@ static inline void iwl4965_print_hex_dump(int level, void *p, u32 len)
83 * 112 *
84 * % cat /proc/net/iwl/debug_level 113 * % cat /proc/net/iwl/debug_level
85 * 114 *
86 * you simply need to add your entry to the iwl4965_debug_levels array. 115 * you simply need to add your entry to the iwl_debug_levels array.
87 * 116 *
88 * If you do not see debug_level in /proc/net/iwl then you do not have 117 * If you do not see debug_level in /proc/net/iwl then you do not have
89 * CONFIG_IWL4965_DEBUG defined in your kernel configuration 118 * CONFIG_IWLWIFI_DEBUG defined in your kernel configuration
90 * 119 *
91 */ 120 */
92 121
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
new file mode 100644
index 000000000000..c659bd3bc346
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -0,0 +1,319 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Tomas Winkler <tomas.winkler@intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/debugfs.h>
32
33#include <linux/ieee80211.h>
34#include <net/mac80211.h>
35
36
37#include "iwl-4965.h"
38#include "iwl-debug.h"
39#include "iwl-4965-io.h"
40
41
42/* create and remove of files */
43#define DEBUGFS_ADD_DIR(name, parent) do { \
44 dbgfs->dir_##name = debugfs_create_dir(#name, parent); \
45 if (!(dbgfs->dir_##name)) \
46 goto err; \
47} while (0)
48
49#define DEBUGFS_ADD_FILE(name, parent) do { \
50 dbgfs->dbgfs_##parent##_files.file_##name = \
51 debugfs_create_file(#name, 0644, dbgfs->dir_##parent, priv, \
52 &iwl_dbgfs_##name##_ops); \
53 if (!(dbgfs->dbgfs_##parent##_files.file_##name)) \
54 goto err; \
55} while (0)
56
57#define DEBUGFS_REMOVE(name) do { \
58 debugfs_remove(name); \
59 name = NULL; \
60} while (0);
61
62/* file operation */
63#define DEBUGFS_READ_FUNC(name) \
64static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
65 char __user *user_buf, \
66 size_t count, loff_t *ppos);
67
68#define DEBUGFS_WRITE_FUNC(name) \
69static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
70 const char __user *user_buf, \
71 size_t count, loff_t *ppos);
72
73
74static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
75{
76 file->private_data = inode->i_private;
77 return 0;
78}
79
80#define DEBUGFS_READ_FILE_OPS(name) \
81 DEBUGFS_READ_FUNC(name); \
82static const struct file_operations iwl_dbgfs_##name##_ops = { \
83 .read = iwl_dbgfs_##name##_read, \
84 .open = iwl_dbgfs_open_file_generic, \
85};
86
87#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
88 DEBUGFS_READ_FUNC(name); \
89 DEBUGFS_WRITE_FUNC(name); \
90static const struct file_operations iwl_dbgfs_##name##_ops = { \
91 .write = iwl_dbgfs_##name##_write, \
92 .read = iwl_dbgfs_##name##_read, \
93 .open = iwl_dbgfs_open_file_generic, \
94};
95
96
97static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
98 char __user *user_buf,
99 size_t count, loff_t *ppos) {
100
101 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
102 char buf[256];
103 int pos = 0;
104
105 pos += sprintf(buf+pos, "mgmt: %u\n", priv->tx_stats[0].cnt);
106 pos += sprintf(buf+pos, "ctrl: %u\n", priv->tx_stats[1].cnt);
107 pos += sprintf(buf+pos, "data: %u\n", priv->tx_stats[2].cnt);
108
109 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
110}
111
112static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
113 char __user *user_buf,
114 size_t count, loff_t *ppos) {
115
116 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
117 char buf[256];
118 int pos = 0;
119
120 pos += sprintf(buf+pos, "mgmt: %u\n", priv->rx_stats[0].cnt);
121 pos += sprintf(buf+pos, "ctrl: %u\n", priv->rx_stats[1].cnt);
122 pos += sprintf(buf+pos, "data: %u\n", priv->rx_stats[2].cnt);
123
124 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
125}
126
127#define BYTE1_MASK 0x000000ff;
128#define BYTE2_MASK 0x0000ffff;
129#define BYTE3_MASK 0x00ffffff;
130static ssize_t iwl_dbgfs_sram_read(struct file *file,
131 char __user *user_buf,
132 size_t count, loff_t *ppos)
133{
134 u32 val;
135 char buf[1024];
136 ssize_t ret;
137 int i;
138 int pos = 0;
139 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
140
141 printk(KERN_DEBUG "offset is: 0x%x\tlen is: 0x%x\n",
142 priv->dbgfs->sram_offset, priv->dbgfs->sram_len);
143
144 iwl4965_grab_nic_access(priv);
145 for (i = priv->dbgfs->sram_len; i > 0; i -= 4) {
146 val = iwl4965_read_targ_mem(priv, priv->dbgfs->sram_offset + \
147 priv->dbgfs->sram_len - i);
148 if (i < 4) {
149 switch (i) {
150 case 1:
151 val &= BYTE1_MASK;
152 break;
153 case 2:
154 val &= BYTE2_MASK;
155 break;
156 case 3:
157 val &= BYTE3_MASK;
158 break;
159 }
160 }
161 pos += sprintf(buf+pos, "0x%08x ", val);
162 }
163 pos += sprintf(buf+pos, "\n");
164 iwl4965_release_nic_access(priv);
165
166 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
167 return ret;
168}
169
170static ssize_t iwl_dbgfs_sram_write(struct file *file,
171 const char __user *user_buf,
172 size_t count, loff_t *ppos)
173{
174 struct iwl_priv *priv = file->private_data;
175 char buf[64];
176 int buf_size;
177 u32 offset, len;
178
179 memset(buf, 0, sizeof(buf));
180 buf_size = min(count, sizeof(buf) - 1);
181 if (copy_from_user(buf, user_buf, buf_size))
182 return -EFAULT;
183
184 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
185 priv->dbgfs->sram_offset = offset;
186 priv->dbgfs->sram_len = len;
187 } else {
188 priv->dbgfs->sram_offset = 0;
189 priv->dbgfs->sram_len = 0;
190 }
191
192 return count;
193}
194
195static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
196 size_t count, loff_t *ppos)
197{
198 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
199 struct iwl4965_station_entry *station;
200 int max_sta = priv->hw_setting.max_stations;
201 char *buf;
202 int i, j, pos = 0;
203 ssize_t ret;
204 /* Add 30 for initial string */
205 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
206 DECLARE_MAC_BUF(mac);
207
208 buf = kmalloc(bufsz, GFP_KERNEL);
209 if(!buf)
210 return -ENOMEM;
211
212 pos += sprintf(buf+pos, "num of stations: %d\n\n",
213 priv->num_stations);
214
215 for (i = 0; i < max_sta; i++) {
216 station = &priv->stations[i];
217 if (station->used) {
218 pos += sprintf(buf+pos, "station %d:\ngeneral data:\n",
219 i+1);
220 print_mac(mac, station->sta.sta.addr);
221 pos += sprintf(buf+pos, "id: %u\n",
222 station->sta.sta.sta_id);
223 pos += sprintf(buf+pos, "mode: %u\n",
224 station->sta.mode);
225 pos += sprintf(buf+pos, "flags: 0x%x\n",
226 station->sta.station_flags_msk);
227 pos += sprintf(buf+pos, "ps_status: %u\n",
228 station->ps_status);
229
230 pos += sprintf(buf+pos, "tid data:\n");
231
232 pos += sprintf(buf+pos, "seq_num\t\ttxq_id\t");
233 pos += sprintf(buf+pos, "frame_count\twait_for_ba\t");
234 pos += sprintf(buf+pos, "start_idx\tbitmap0\t");
235 pos += sprintf(buf+pos, "bitmap1\trate_n_flags\n");
236
237 for (j = 0; j < MAX_TID_COUNT; j++) {
238 pos += sprintf(buf+pos, "[%d]:\t\t%u\t",
239 j, station->tid[j].seq_number);
240 pos += sprintf(buf+pos, "%u\t\t%u\t\t%u\t\t",
241 station->tid[j].agg.txq_id,
242 station->tid[j].agg.frame_count,
243 station->tid[j].agg.wait_for_ba);
244 pos += sprintf(buf+pos, "%u\t%llu\t%u\n",
245 station->tid[j].agg.start_idx,
246 station->tid[j].agg.bitmap,
247 station->tid[j].agg.rate_n_flags);
248 }
249 pos += sprintf(buf+pos, "\n");
250 }
251 }
252
253 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
254 kfree(buf);
255 return ret;
256}
257
258
259DEBUGFS_READ_WRITE_FILE_OPS(sram);
260DEBUGFS_READ_FILE_OPS(stations);
261DEBUGFS_READ_FILE_OPS(rx_statistics);
262DEBUGFS_READ_FILE_OPS(tx_statistics);
263
264/*
265 * Create the debugfs files and directories
266 *
267 */
268int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
269{
270 struct iwl_debugfs *dbgfs;
271
272 dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL);
273 if (!dbgfs) {
274 goto err;
275 }
276
277 priv->dbgfs = dbgfs;
278 dbgfs->name = name;
279 dbgfs->dir_drv = debugfs_create_dir(name, NULL);
280 if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)){
281 goto err;
282 }
283
284 DEBUGFS_ADD_DIR(data, dbgfs->dir_drv);
285 DEBUGFS_ADD_FILE(sram, data);
286 DEBUGFS_ADD_FILE(stations, data);
287 DEBUGFS_ADD_FILE(rx_statistics, data);
288 DEBUGFS_ADD_FILE(tx_statistics, data);
289
290 return 0;
291
292err:
293 IWL_ERROR("Can't open the debugfs directory\n");
294 iwl_dbgfs_unregister(priv);
295 return -ENOENT;
296}
297EXPORT_SYMBOL(iwl_dbgfs_register);
298
299/**
300 * Remove the debugfs files and directories
301 *
302 */
303void iwl_dbgfs_unregister(struct iwl_priv *priv)
304{
305 if (!(priv->dbgfs))
306 return;
307
308 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics);
309 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics);
310 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);
311 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations);
312 DEBUGFS_REMOVE(priv->dbgfs->dir_data);
313 DEBUGFS_REMOVE(priv->dbgfs->dir_drv);
314 kfree(priv->dbgfs);
315 priv->dbgfs = NULL;
316}
317EXPORT_SYMBOL(iwl_dbgfs_unregister);
318
319
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 0064387dea91..72cad56fbd93 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -71,17 +71,78 @@
71#include "iwl-4965-commands.h" 71#include "iwl-4965-commands.h"
72#include "iwl-4965.h" 72#include "iwl-4965.h"
73#include "iwl-core.h" 73#include "iwl-core.h"
74#include "iwl-4965-debug.h" 74#include "iwl-debug.h"
75#include "iwl-eeprom.h" 75#include "iwl-eeprom.h"
76#include "iwl-4965-io.h" 76#include "iwl-4965-io.h"
77 77
78/************************** EEPROM BANDS ****************************
79 *
80 * The iwl_eeprom_band definitions below provide the mapping from the
81 * EEPROM contents to the specific channel number supported for each
82 * band.
83 *
84 * For example, iwl_priv->eeprom.band_3_channels[4] from the band_3
85 * definition below maps to physical channel 42 in the 5.2GHz spectrum.
86 * The specific geography and calibration information for that channel
87 * is contained in the eeprom map itself.
88 *
89 * During init, we copy the eeprom information and channel map
90 * information into priv->channel_info_24/52 and priv->channel_map_24/52
91 *
92 * channel_map_24/52 provides the index in the channel_info array for a
93 * given channel. We have to have two separate maps as there is channel
94 * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and
95 * band_2
96 *
97 * A value of 0xff stored in the channel_map indicates that the channel
98 * is not supported by the hardware at all.
99 *
100 * A value of 0xfe in the channel_map indicates that the channel is not
101 * valid for Tx with the current hardware. This means that
102 * while the system can tune and receive on a given channel, it may not
103 * be able to associate or transmit any frames on that
104 * channel. There is no corresponding channel information for that
105 * entry.
106 *
107 *********************************************************************/
108
109/* 2.4 GHz */
110const u8 iwl_eeprom_band_1[14] = {
111 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
112};
113
114/* 5.2 GHz bands */
115static const u8 iwl_eeprom_band_2[] = { /* 4915-5080MHz */
116 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16
117};
118
119static const u8 iwl_eeprom_band_3[] = { /* 5170-5320MHz */
120 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
121};
122
123static const u8 iwl_eeprom_band_4[] = { /* 5500-5700MHz */
124 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
125};
126
127static const u8 iwl_eeprom_band_5[] = { /* 5725-5825MHz */
128 145, 149, 153, 157, 161, 165
129};
130
131static const u8 iwl_eeprom_band_6[] = { /* 2.4 FAT channel */
132 1, 2, 3, 4, 5, 6, 7
133};
134
135static const u8 iwl_eeprom_band_7[] = { /* 5.2 FAT channel */
136 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157
137};
138
78/****************************************************************************** 139/******************************************************************************
79 * 140 *
80 * EEPROM related functions 141 * EEPROM related functions
81 * 142 *
82******************************************************************************/ 143******************************************************************************/
83 144
84int iwlcore_eeprom_verify_signature(struct iwl4965_priv *priv) 145int iwlcore_eeprom_verify_signature(struct iwl_priv *priv)
85{ 146{
86 u32 gp = iwl4965_read32(priv, CSR_EEPROM_GP); 147 u32 gp = iwl4965_read32(priv, CSR_EEPROM_GP);
87 if ((gp & CSR_EEPROM_GP_VALID_MSK) == CSR_EEPROM_GP_BAD_SIGNATURE) { 148 if ((gp & CSR_EEPROM_GP_VALID_MSK) == CSR_EEPROM_GP_BAD_SIGNATURE) {
@@ -98,7 +159,7 @@ EXPORT_SYMBOL(iwlcore_eeprom_verify_signature);
98 * EEPROM chip, not a single event, so even reads could conflict if they 159 * EEPROM chip, not a single event, so even reads could conflict if they
99 * weren't arbitrated by the semaphore. 160 * weren't arbitrated by the semaphore.
100 */ 161 */
101int iwlcore_eeprom_acquire_semaphore(struct iwl4965_priv *priv) 162int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv)
102{ 163{
103 u16 count; 164 u16 count;
104 int ret; 165 int ret;
@@ -124,7 +185,7 @@ int iwlcore_eeprom_acquire_semaphore(struct iwl4965_priv *priv)
124} 185}
125EXPORT_SYMBOL(iwlcore_eeprom_acquire_semaphore); 186EXPORT_SYMBOL(iwlcore_eeprom_acquire_semaphore);
126 187
127void iwlcore_eeprom_release_semaphore(struct iwl4965_priv *priv) 188void iwlcore_eeprom_release_semaphore(struct iwl_priv *priv)
128{ 189{
129 iwl4965_clear_bit(priv, CSR_HW_IF_CONFIG_REG, 190 iwl4965_clear_bit(priv, CSR_HW_IF_CONFIG_REG,
130 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); 191 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
@@ -140,7 +201,7 @@ EXPORT_SYMBOL(iwlcore_eeprom_release_semaphore);
140 * 201 *
141 * NOTE: This routine uses the non-debug IO access functions. 202 * NOTE: This routine uses the non-debug IO access functions.
142 */ 203 */
143int iwl_eeprom_init(struct iwl4965_priv *priv) 204int iwl_eeprom_init(struct iwl_priv *priv)
144{ 205{
145 u16 *e = (u16 *)&priv->eeprom; 206 u16 *e = (u16 *)&priv->eeprom;
146 u32 gp = iwl4965_read32(priv, CSR_EEPROM_GP); 207 u32 gp = iwl4965_read32(priv, CSR_EEPROM_GP);
@@ -197,9 +258,304 @@ done:
197EXPORT_SYMBOL(iwl_eeprom_init); 258EXPORT_SYMBOL(iwl_eeprom_init);
198 259
199 260
200void iwl_eeprom_get_mac(const struct iwl4965_priv *priv, u8 *mac) 261void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac)
201{ 262{
202 memcpy(mac, priv->eeprom.mac_address, 6); 263 memcpy(mac, priv->eeprom.mac_address, 6);
203} 264}
204EXPORT_SYMBOL(iwl_eeprom_get_mac); 265EXPORT_SYMBOL(iwl_eeprom_get_mac);
205 266
267static void iwl_init_band_reference(const struct iwl_priv *priv,
268 int band,
269 int *eeprom_ch_count,
270 const struct iwl4965_eeprom_channel
271 **eeprom_ch_info,
272 const u8 **eeprom_ch_index)
273{
274 switch (band) {
275 case 1: /* 2.4GHz band */
276 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_1);
277 *eeprom_ch_info = priv->eeprom.band_1_channels;
278 *eeprom_ch_index = iwl_eeprom_band_1;
279 break;
280 case 2: /* 4.9GHz band */
281 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_2);
282 *eeprom_ch_info = priv->eeprom.band_2_channels;
283 *eeprom_ch_index = iwl_eeprom_band_2;
284 break;
285 case 3: /* 5.2GHz band */
286 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_3);
287 *eeprom_ch_info = priv->eeprom.band_3_channels;
288 *eeprom_ch_index = iwl_eeprom_band_3;
289 break;
290 case 4: /* 5.5GHz band */
291 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_4);
292 *eeprom_ch_info = priv->eeprom.band_4_channels;
293 *eeprom_ch_index = iwl_eeprom_band_4;
294 break;
295 case 5: /* 5.7GHz band */
296 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_5);
297 *eeprom_ch_info = priv->eeprom.band_5_channels;
298 *eeprom_ch_index = iwl_eeprom_band_5;
299 break;
300 case 6: /* 2.4GHz FAT channels */
301 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_6);
302 *eeprom_ch_info = priv->eeprom.band_24_channels;
303 *eeprom_ch_index = iwl_eeprom_band_6;
304 break;
305 case 7: /* 5 GHz FAT channels */
306 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_7);
307 *eeprom_ch_info = priv->eeprom.band_52_channels;
308 *eeprom_ch_index = iwl_eeprom_band_7;
309 break;
310 default:
311 BUG();
312 return;
313 }
314}
315
316#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \
317 ? # x " " : "")
318
319/**
320 * iwl4965_set_fat_chan_info - Copy fat channel info into driver's priv.
321 *
322 * Does not set up a command, or touch hardware.
323 */
324static int iwl4965_set_fat_chan_info(struct iwl_priv *priv,
325 enum ieee80211_band band, u16 channel,
326 const struct iwl4965_eeprom_channel *eeprom_ch,
327 u8 fat_extension_channel)
328{
329 struct iwl_channel_info *ch_info;
330
331 ch_info = (struct iwl_channel_info *)
332 iwl_get_channel_info(priv, band, channel);
333
334 if (!is_channel_valid(ch_info))
335 return -1;
336
337 IWL_DEBUG_INFO("FAT Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x"
338 " %ddBm): Ad-Hoc %ssupported\n",
339 ch_info->channel,
340 is_channel_a_band(ch_info) ?
341 "5.2" : "2.4",
342 CHECK_AND_PRINT(IBSS),
343 CHECK_AND_PRINT(ACTIVE),
344 CHECK_AND_PRINT(RADAR),
345 CHECK_AND_PRINT(WIDE),
346 CHECK_AND_PRINT(NARROW),
347 CHECK_AND_PRINT(DFS),
348 eeprom_ch->flags,
349 eeprom_ch->max_power_avg,
350 ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS)
351 && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ?
352 "" : "not ");
353
354 ch_info->fat_eeprom = *eeprom_ch;
355 ch_info->fat_max_power_avg = eeprom_ch->max_power_avg;
356 ch_info->fat_curr_txpow = eeprom_ch->max_power_avg;
357 ch_info->fat_min_power = 0;
358 ch_info->fat_scan_power = eeprom_ch->max_power_avg;
359 ch_info->fat_flags = eeprom_ch->flags;
360 ch_info->fat_extension_channel = fat_extension_channel;
361
362 return 0;
363}
364
365#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \
366 ? # x " " : "")
367
368/**
369 * iwl_init_channel_map - Set up driver's info for all possible channels
370 */
371int iwl_init_channel_map(struct iwl_priv *priv)
372{
373 int eeprom_ch_count = 0;
374 const u8 *eeprom_ch_index = NULL;
375 const struct iwl4965_eeprom_channel *eeprom_ch_info = NULL;
376 int band, ch;
377 struct iwl_channel_info *ch_info;
378
379 if (priv->channel_count) {
380 IWL_DEBUG_INFO("Channel map already initialized.\n");
381 return 0;
382 }
383
384 if (priv->eeprom.version < 0x2f) {
385 IWL_WARNING("Unsupported EEPROM version: 0x%04X\n",
386 priv->eeprom.version);
387 return -EINVAL;
388 }
389
390 IWL_DEBUG_INFO("Initializing regulatory info from EEPROM\n");
391
392 priv->channel_count =
393 ARRAY_SIZE(iwl_eeprom_band_1) +
394 ARRAY_SIZE(iwl_eeprom_band_2) +
395 ARRAY_SIZE(iwl_eeprom_band_3) +
396 ARRAY_SIZE(iwl_eeprom_band_4) +
397 ARRAY_SIZE(iwl_eeprom_band_5);
398
399 IWL_DEBUG_INFO("Parsing data for %d channels.\n", priv->channel_count);
400
401 priv->channel_info = kzalloc(sizeof(struct iwl_channel_info) *
402 priv->channel_count, GFP_KERNEL);
403 if (!priv->channel_info) {
404 IWL_ERROR("Could not allocate channel_info\n");
405 priv->channel_count = 0;
406 return -ENOMEM;
407 }
408
409 ch_info = priv->channel_info;
410
411 /* Loop through the 5 EEPROM bands adding them in order to the
412 * channel map we maintain (that contains additional information than
413 * what just in the EEPROM) */
414 for (band = 1; band <= 5; band++) {
415
416 iwl_init_band_reference(priv, band, &eeprom_ch_count,
417 &eeprom_ch_info, &eeprom_ch_index);
418
419 /* Loop through each band adding each of the channels */
420 for (ch = 0; ch < eeprom_ch_count; ch++) {
421 ch_info->channel = eeprom_ch_index[ch];
422 ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ :
423 IEEE80211_BAND_5GHZ;
424
425 /* permanently store EEPROM's channel regulatory flags
426 * and max power in channel info database. */
427 ch_info->eeprom = eeprom_ch_info[ch];
428
429 /* Copy the run-time flags so they are there even on
430 * invalid channels */
431 ch_info->flags = eeprom_ch_info[ch].flags;
432
433 if (!(is_channel_valid(ch_info))) {
434 IWL_DEBUG_INFO("Ch. %d Flags %x [%sGHz] - "
435 "No traffic\n",
436 ch_info->channel,
437 ch_info->flags,
438 is_channel_a_band(ch_info) ?
439 "5.2" : "2.4");
440 ch_info++;
441 continue;
442 }
443
444 /* Initialize regulatory-based run-time data */
445 ch_info->max_power_avg = ch_info->curr_txpow =
446 eeprom_ch_info[ch].max_power_avg;
447 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg;
448 ch_info->min_power = 0;
449
450 IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s%s(0x%02x"
451 " %ddBm): Ad-Hoc %ssupported\n",
452 ch_info->channel,
453 is_channel_a_band(ch_info) ?
454 "5.2" : "2.4",
455 CHECK_AND_PRINT_I(VALID),
456 CHECK_AND_PRINT_I(IBSS),
457 CHECK_AND_PRINT_I(ACTIVE),
458 CHECK_AND_PRINT_I(RADAR),
459 CHECK_AND_PRINT_I(WIDE),
460 CHECK_AND_PRINT_I(NARROW),
461 CHECK_AND_PRINT_I(DFS),
462 eeprom_ch_info[ch].flags,
463 eeprom_ch_info[ch].max_power_avg,
464 ((eeprom_ch_info[ch].
465 flags & EEPROM_CHANNEL_IBSS)
466 && !(eeprom_ch_info[ch].
467 flags & EEPROM_CHANNEL_RADAR))
468 ? "" : "not ");
469
470 /* Set the user_txpower_limit to the highest power
471 * supported by any channel */
472 if (eeprom_ch_info[ch].max_power_avg >
473 priv->user_txpower_limit)
474 priv->user_txpower_limit =
475 eeprom_ch_info[ch].max_power_avg;
476
477 ch_info++;
478 }
479 }
480
481 /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */
482 for (band = 6; band <= 7; band++) {
483 enum ieee80211_band ieeeband;
484 u8 fat_extension_chan;
485
486 iwl_init_band_reference(priv, band, &eeprom_ch_count,
487 &eeprom_ch_info, &eeprom_ch_index);
488
489 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */
490 ieeeband =
491 (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
492
493 /* Loop through each band adding each of the channels */
494 for (ch = 0; ch < eeprom_ch_count; ch++) {
495
496 if ((band == 6) &&
497 ((eeprom_ch_index[ch] == 5) ||
498 (eeprom_ch_index[ch] == 6) ||
499 (eeprom_ch_index[ch] == 7)))
500 fat_extension_chan = HT_IE_EXT_CHANNEL_MAX;
501 else
502 fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE;
503
504 /* Set up driver's info for lower half */
505 iwl4965_set_fat_chan_info(priv, ieeeband,
506 eeprom_ch_index[ch],
507 &(eeprom_ch_info[ch]),
508 fat_extension_chan);
509
510 /* Set up driver's info for upper half */
511 iwl4965_set_fat_chan_info(priv, ieeeband,
512 (eeprom_ch_index[ch] + 4),
513 &(eeprom_ch_info[ch]),
514 HT_IE_EXT_CHANNEL_BELOW);
515 }
516 }
517
518 return 0;
519}
520EXPORT_SYMBOL(iwl_init_channel_map);
521
522/*
523 * iwl_free_channel_map - undo allocations in iwl4965_init_channel_map
524 */
525void iwl_free_channel_map(struct iwl_priv *priv)
526{
527 kfree(priv->channel_info);
528 priv->channel_count = 0;
529}
530EXPORT_SYMBOL(iwl_free_channel_map);
531
532/**
533 * iwl_get_channel_info - Find driver's private channel info
534 *
535 * Based on band and channel number.
536 */
537const struct iwl_channel_info *iwl_get_channel_info(
538 const struct iwl_priv *priv,
539 enum ieee80211_band band, u16 channel)
540{
541 int i;
542
543 switch (band) {
544 case IEEE80211_BAND_5GHZ:
545 for (i = 14; i < priv->channel_count; i++) {
546 if (priv->channel_info[i].channel == channel)
547 return &priv->channel_info[i];
548 }
549 break;
550 case IEEE80211_BAND_2GHZ:
551 if (channel >= 1 && channel <= 14)
552 return &priv->channel_info[channel - 1];
553 break;
554 default:
555 BUG();
556 }
557
558 return NULL;
559}
560EXPORT_SYMBOL(iwl_get_channel_info);
561
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 7827566dcc8b..bd0a042ca77f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -63,7 +63,7 @@
63#ifndef __iwl_eeprom_h__ 63#ifndef __iwl_eeprom_h__
64#define __iwl_eeprom_h__ 64#define __iwl_eeprom_h__
65 65
66struct iwl4965_priv; 66struct iwl_priv;
67 67
68/* 68/*
69 * EEPROM access time values: 69 * EEPROM access time values:
@@ -137,6 +137,8 @@ struct iwl4965_eeprom_channel {
137 * Look for this in calib_version member of struct iwl4965_eeprom. */ 137 * Look for this in calib_version member of struct iwl4965_eeprom. */
138#define EEPROM_TX_POWER_VERSION_NEW (5) 138#define EEPROM_TX_POWER_VERSION_NEW (5)
139 139
140/* 2.4 GHz */
141extern const u8 iwl_eeprom_band_1[14];
140 142
141/* 143/*
142 * 4965 factory calibration data for one txpower level, on one channel, 144 * 4965 factory calibration data for one txpower level, on one channel,
@@ -228,49 +230,31 @@ struct iwl4965_eeprom_calib_info {
228 */ 230 */
229struct iwl4965_eeprom { 231struct iwl4965_eeprom {
230 u8 reserved0[16]; 232 u8 reserved0[16];
231#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
232 u16 device_id; /* abs.ofs: 16 */ 233 u16 device_id; /* abs.ofs: 16 */
233 u8 reserved1[2]; 234 u8 reserved1[2];
234#define EEPROM_PMC (2*0x0A) /* 2 bytes */
235 u16 pmc; /* abs.ofs: 20 */ 235 u16 pmc; /* abs.ofs: 20 */
236 u8 reserved2[20]; 236 u8 reserved2[20];
237#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
238 u8 mac_address[6]; /* abs.ofs: 42 */ 237 u8 mac_address[6]; /* abs.ofs: 42 */
239 u8 reserved3[58]; 238 u8 reserved3[58];
240#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
241 u16 board_revision; /* abs.ofs: 106 */ 239 u16 board_revision; /* abs.ofs: 106 */
242 u8 reserved4[11]; 240 u8 reserved4[11];
243#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
244 u8 board_pba_number[9]; /* abs.ofs: 119 */ 241 u8 board_pba_number[9]; /* abs.ofs: 119 */
245 u8 reserved5[8]; 242 u8 reserved5[8];
246#define EEPROM_VERSION (2*0x44) /* 2 bytes */
247 u16 version; /* abs.ofs: 136 */ 243 u16 version; /* abs.ofs: 136 */
248#define EEPROM_SKU_CAP (2*0x45) /* 1 bytes */
249 u8 sku_cap; /* abs.ofs: 138 */ 244 u8 sku_cap; /* abs.ofs: 138 */
250#define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */
251 u8 leds_mode; /* abs.ofs: 139 */ 245 u8 leds_mode; /* abs.ofs: 139 */
252#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
253 u16 oem_mode; 246 u16 oem_mode;
254#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
255 u16 wowlan_mode; /* abs.ofs: 142 */ 247 u16 wowlan_mode; /* abs.ofs: 142 */
256#define EEPROM_LEDS_TIME_INTERVAL (2*0x48) /* 2 bytes */
257 u16 leds_time_interval; /* abs.ofs: 144 */ 248 u16 leds_time_interval; /* abs.ofs: 144 */
258#define EEPROM_LEDS_OFF_TIME (2*0x49) /* 1 bytes */
259 u8 leds_off_time; /* abs.ofs: 146 */ 249 u8 leds_off_time; /* abs.ofs: 146 */
260#define EEPROM_LEDS_ON_TIME (2*0x49+1) /* 1 bytes */
261 u8 leds_on_time; /* abs.ofs: 147 */ 250 u8 leds_on_time; /* abs.ofs: 147 */
262#define EEPROM_ALMGOR_M_VERSION (2*0x4A) /* 1 bytes */
263 u8 almgor_m_version; /* abs.ofs: 148 */ 251 u8 almgor_m_version; /* abs.ofs: 148 */
264#define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */
265 u8 antenna_switch_type; /* abs.ofs: 149 */ 252 u8 antenna_switch_type; /* abs.ofs: 149 */
266 u8 reserved6[8]; 253 u8 reserved6[8];
267#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */
268 u16 board_revision_4965; /* abs.ofs: 158 */ 254 u16 board_revision_4965; /* abs.ofs: 158 */
269 u8 reserved7[13]; 255 u8 reserved7[13];
270#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */
271 u8 board_pba_number_4965[9]; /* abs.ofs: 173 */ 256 u8 board_pba_number_4965[9]; /* abs.ofs: 173 */
272 u8 reserved8[10]; 257 u8 reserved8[10];
273#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
274 u8 sku_id[4]; /* abs.ofs: 192 */ 258 u8 sku_id[4]; /* abs.ofs: 192 */
275 259
276/* 260/*
@@ -285,9 +269,7 @@ struct iwl4965_eeprom {
285 * 269 *
286 * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 270 * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
287 */ 271 */
288#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
289 u16 band_1_count; /* abs.ofs: 196 */ 272 u16 band_1_count; /* abs.ofs: 196 */
290#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
291 struct iwl4965_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */ 273 struct iwl4965_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */
292 274
293/* 275/*
@@ -295,36 +277,28 @@ struct iwl4965_eeprom {
295 * 5.0 GHz channels 7, 8, 11, 12, 16 277 * 5.0 GHz channels 7, 8, 11, 12, 16
296 * (4915-5080MHz) (none of these is ever supported) 278 * (4915-5080MHz) (none of these is ever supported)
297 */ 279 */
298#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
299 u16 band_2_count; /* abs.ofs: 226 */ 280 u16 band_2_count; /* abs.ofs: 226 */
300#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
301 struct iwl4965_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ 281 struct iwl4965_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
302 282
303/* 283/*
304 * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 284 * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
305 * (5170-5320MHz) 285 * (5170-5320MHz)
306 */ 286 */
307#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
308 u16 band_3_count; /* abs.ofs: 254 */ 287 u16 band_3_count; /* abs.ofs: 254 */
309#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
310 struct iwl4965_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ 288 struct iwl4965_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
311 289
312/* 290/*
313 * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 291 * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
314 * (5500-5700MHz) 292 * (5500-5700MHz)
315 */ 293 */
316#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
317 u16 band_4_count; /* abs.ofs: 280 */ 294 u16 band_4_count; /* abs.ofs: 280 */
318#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
319 struct iwl4965_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ 295 struct iwl4965_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
320 296
321/* 297/*
322 * 5.7 GHz channels 145, 149, 153, 157, 161, 165 298 * 5.7 GHz channels 145, 149, 153, 157, 161, 165
323 * (5725-5825MHz) 299 * (5725-5825MHz)
324 */ 300 */
325#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
326 u16 band_5_count; /* abs.ofs: 304 */ 301 u16 band_5_count; /* abs.ofs: 304 */
327#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
328 struct iwl4965_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ 302 struct iwl4965_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
329 303
330 u8 reserved10[2]; 304 u8 reserved10[2];
@@ -345,7 +319,6 @@ struct iwl4965_eeprom {
345 * 319 *
346 * NOTE: 4965 does not support FAT channels on 2.4 GHz. 320 * NOTE: 4965 does not support FAT channels on 2.4 GHz.
347 */ 321 */
348#define EEPROM_REGULATORY_BAND_24_FAT_CHANNELS (2*0xA0) /* 14 bytes */
349 struct iwl4965_eeprom_channel band_24_channels[7]; /* abs.ofs: 320 */ 322 struct iwl4965_eeprom_channel band_24_channels[7]; /* abs.ofs: 320 */
350 u8 reserved11[2]; 323 u8 reserved11[2];
351 324
@@ -353,7 +326,6 @@ struct iwl4965_eeprom {
353 * 5.2 GHz FAT channels 36 (40), 44 (48), 52 (56), 60 (64), 326 * 5.2 GHz FAT channels 36 (40), 44 (48), 52 (56), 60 (64),
354 * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161) 327 * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161)
355 */ 328 */
356#define EEPROM_REGULATORY_BAND_52_FAT_CHANNELS (2*0xA8) /* 22 bytes */
357 struct iwl4965_eeprom_channel band_52_channels[11]; /* abs.ofs: 336 */ 329 struct iwl4965_eeprom_channel band_52_channels[11]; /* abs.ofs: 336 */
358 u8 reserved12[6]; 330 u8 reserved12[6];
359 331
@@ -362,7 +334,6 @@ struct iwl4965_eeprom {
362 * Driver does not work with txpower calibration version < 5. 334 * Driver does not work with txpower calibration version < 5.
363 * This value is simply a 16-bit number, no major/minor versions here. 335 * This value is simply a 16-bit number, no major/minor versions here.
364 */ 336 */
365#define EEPROM_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */
366 u16 calib_version; /* abs.ofs: 364 */ 337 u16 calib_version; /* abs.ofs: 364 */
367 u8 reserved13[2]; 338 u8 reserved13[2];
368 u8 reserved14[96]; /* abs.ofs: 368 */ 339 u8 reserved14[96]; /* abs.ofs: 368 */
@@ -370,7 +341,6 @@ struct iwl4965_eeprom {
370/* 341/*
371 * 4965 Txpower calibration data. 342 * 4965 Txpower calibration data.
372 */ 343 */
373#define EEPROM_IWL_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */
374 struct iwl4965_eeprom_calib_info calib_info; /* abs.ofs: 464 */ 344 struct iwl4965_eeprom_calib_info calib_info; /* abs.ofs: 464 */
375 345
376 u8 reserved16[140]; /* fill out to full 1024 byte block */ 346 u8 reserved16[140]; /* fill out to full 1024 byte block */
@@ -383,17 +353,23 @@ struct iwl4965_eeprom {
383/* End of EEPROM */ 353/* End of EEPROM */
384 354
385struct iwl_eeprom_ops { 355struct iwl_eeprom_ops {
386 int (*verify_signature) (struct iwl4965_priv *priv); 356 int (*verify_signature) (struct iwl_priv *priv);
387 int (*acquire_semaphore) (struct iwl4965_priv *priv); 357 int (*acquire_semaphore) (struct iwl_priv *priv);
388 void (*release_semaphore) (struct iwl4965_priv *priv); 358 void (*release_semaphore) (struct iwl_priv *priv);
389}; 359};
390 360
391 361
392void iwl_eeprom_get_mac(const struct iwl4965_priv *priv, u8 *mac); 362void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac);
393int iwl_eeprom_init(struct iwl4965_priv *priv); 363int iwl_eeprom_init(struct iwl_priv *priv);
394 364
395int iwlcore_eeprom_verify_signature(struct iwl4965_priv *priv); 365int iwlcore_eeprom_verify_signature(struct iwl_priv *priv);
396int iwlcore_eeprom_acquire_semaphore(struct iwl4965_priv *priv); 366int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv);
397void iwlcore_eeprom_release_semaphore(struct iwl4965_priv *priv); 367void iwlcore_eeprom_release_semaphore(struct iwl_priv *priv);
368
369int iwl_init_channel_map(struct iwl_priv *priv);
370void iwl_free_channel_map(struct iwl_priv *priv);
371const struct iwl_channel_info *iwl_get_channel_info(
372 const struct iwl_priv *priv,
373 enum ieee80211_band band, u16 channel);
398 374
399#endif /* __iwl_eeprom_h__ */ 375#endif /* __iwl_eeprom_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
new file mode 100644
index 000000000000..559ff739961e
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
@@ -0,0 +1,251 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Tomas Winkler <tomas.winkler@intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/version.h>
32#include <net/mac80211.h>
33
34#include "iwl-4965.h" /* FIXME: remove */
35#include "iwl-debug.h"
36#include "iwl-eeprom.h"
37#include "iwl-core.h"
38
39
40#define IWL_CMD(x) case x : return #x
41
42const char *get_cmd_string(u8 cmd)
43{
44 switch (cmd) {
45 IWL_CMD(REPLY_ALIVE);
46 IWL_CMD(REPLY_ERROR);
47 IWL_CMD(REPLY_RXON);
48 IWL_CMD(REPLY_RXON_ASSOC);
49 IWL_CMD(REPLY_QOS_PARAM);
50 IWL_CMD(REPLY_RXON_TIMING);
51 IWL_CMD(REPLY_ADD_STA);
52 IWL_CMD(REPLY_REMOVE_STA);
53 IWL_CMD(REPLY_REMOVE_ALL_STA);
54 IWL_CMD(REPLY_TX);
55 IWL_CMD(REPLY_RATE_SCALE);
56 IWL_CMD(REPLY_LEDS_CMD);
57 IWL_CMD(REPLY_TX_LINK_QUALITY_CMD);
58 IWL_CMD(RADAR_NOTIFICATION);
59 IWL_CMD(REPLY_QUIET_CMD);
60 IWL_CMD(REPLY_CHANNEL_SWITCH);
61 IWL_CMD(CHANNEL_SWITCH_NOTIFICATION);
62 IWL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD);
63 IWL_CMD(SPECTRUM_MEASURE_NOTIFICATION);
64 IWL_CMD(POWER_TABLE_CMD);
65 IWL_CMD(PM_SLEEP_NOTIFICATION);
66 IWL_CMD(PM_DEBUG_STATISTIC_NOTIFIC);
67 IWL_CMD(REPLY_SCAN_CMD);
68 IWL_CMD(REPLY_SCAN_ABORT_CMD);
69 IWL_CMD(SCAN_START_NOTIFICATION);
70 IWL_CMD(SCAN_RESULTS_NOTIFICATION);
71 IWL_CMD(SCAN_COMPLETE_NOTIFICATION);
72 IWL_CMD(BEACON_NOTIFICATION);
73 IWL_CMD(REPLY_TX_BEACON);
74 IWL_CMD(WHO_IS_AWAKE_NOTIFICATION);
75 IWL_CMD(QUIET_NOTIFICATION);
76 IWL_CMD(REPLY_TX_PWR_TABLE_CMD);
77 IWL_CMD(MEASURE_ABORT_NOTIFICATION);
78 IWL_CMD(REPLY_BT_CONFIG);
79 IWL_CMD(REPLY_STATISTICS_CMD);
80 IWL_CMD(STATISTICS_NOTIFICATION);
81 IWL_CMD(REPLY_CARD_STATE_CMD);
82 IWL_CMD(CARD_STATE_NOTIFICATION);
83 IWL_CMD(MISSED_BEACONS_NOTIFICATION);
84 IWL_CMD(REPLY_CT_KILL_CONFIG_CMD);
85 IWL_CMD(SENSITIVITY_CMD);
86 IWL_CMD(REPLY_PHY_CALIBRATION_CMD);
87 IWL_CMD(REPLY_RX_PHY_CMD);
88 IWL_CMD(REPLY_RX_MPDU_CMD);
89 IWL_CMD(REPLY_RX);
90 IWL_CMD(REPLY_COMPRESSED_BA);
91 default:
92 return "UNKNOWN";
93
94 }
95}
96EXPORT_SYMBOL(get_cmd_string);
97
98#define HOST_COMPLETE_TIMEOUT (HZ / 2)
99
100static int iwl_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
101{
102 int ret;
103
104 BUG_ON(!(cmd->meta.flags & CMD_ASYNC));
105
106 /* An asynchronous command can not expect an SKB to be set. */
107 BUG_ON(cmd->meta.flags & CMD_WANT_SKB);
108
109 /* An asynchronous command MUST have a callback. */
110 BUG_ON(!cmd->meta.u.callback);
111
112 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
113 return -EBUSY;
114
115 ret = priv->cfg->ops->utils->enqueue_hcmd(priv, cmd);
116 if (ret < 0) {
117 IWL_ERROR("Error sending %s: enqueue_hcmd failed: %d\n",
118 get_cmd_string(cmd->id), ret);
119 return ret;
120 }
121 return 0;
122}
123
124int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
125{
126 int cmd_idx;
127 int ret;
128 static atomic_t entry = ATOMIC_INIT(0); /* reentrance protection */
129
130 BUG_ON(cmd->meta.flags & CMD_ASYNC);
131
132 /* A synchronous command can not have a callback set. */
133 BUG_ON(cmd->meta.u.callback != NULL);
134
135 if (atomic_xchg(&entry, 1)) {
136 IWL_ERROR("Error sending %s: Already sending a host command\n",
137 get_cmd_string(cmd->id));
138 return -EBUSY;
139 }
140
141 set_bit(STATUS_HCMD_ACTIVE, &priv->status);
142
143 if (cmd->meta.flags & CMD_WANT_SKB)
144 cmd->meta.source = &cmd->meta;
145
146 cmd_idx = priv->cfg->ops->utils->enqueue_hcmd(priv, cmd);
147 if (cmd_idx < 0) {
148 ret = cmd_idx;
149 IWL_ERROR("Error sending %s: enqueue_hcmd failed: %d\n",
150 get_cmd_string(cmd->id), ret);
151 goto out;
152 }
153
154 ret = wait_event_interruptible_timeout(priv->wait_command_queue,
155 !test_bit(STATUS_HCMD_ACTIVE, &priv->status),
156 HOST_COMPLETE_TIMEOUT);
157 if (!ret) {
158 if (test_bit(STATUS_HCMD_ACTIVE, &priv->status)) {
159 IWL_ERROR("Error sending %s: time out after %dms.\n",
160 get_cmd_string(cmd->id),
161 jiffies_to_msecs(HOST_COMPLETE_TIMEOUT));
162
163 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
164 ret = -ETIMEDOUT;
165 goto cancel;
166 }
167 }
168
169 if (test_bit(STATUS_RF_KILL_HW, &priv->status)) {
170 IWL_DEBUG_INFO("Command %s aborted: RF KILL Switch\n",
171 get_cmd_string(cmd->id));
172 ret = -ECANCELED;
173 goto fail;
174 }
175 if (test_bit(STATUS_FW_ERROR, &priv->status)) {
176 IWL_DEBUG_INFO("Command %s failed: FW Error\n",
177 get_cmd_string(cmd->id));
178 ret = -EIO;
179 goto fail;
180 }
181 if ((cmd->meta.flags & CMD_WANT_SKB) && !cmd->meta.u.skb) {
182 IWL_ERROR("Error: Response NULL in '%s'\n",
183 get_cmd_string(cmd->id));
184 ret = -EIO;
185 goto out;
186 }
187
188 ret = 0;
189 goto out;
190
191cancel:
192 if (cmd->meta.flags & CMD_WANT_SKB) {
193 struct iwl_cmd *qcmd;
194
195 /* Cancel the CMD_WANT_SKB flag for the cmd in the
196 * TX cmd queue. Otherwise in case the cmd comes
197 * in later, it will possibly set an invalid
198 * address (cmd->meta.source). */
199 qcmd = &priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_idx];
200 qcmd->meta.flags &= ~CMD_WANT_SKB;
201 }
202fail:
203 if (cmd->meta.u.skb) {
204 dev_kfree_skb_any(cmd->meta.u.skb);
205 cmd->meta.u.skb = NULL;
206 }
207out:
208 atomic_set(&entry, 0);
209 return ret;
210}
211EXPORT_SYMBOL(iwl_send_cmd_sync);
212
213int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
214{
215 if (cmd->meta.flags & CMD_ASYNC)
216 return iwl_send_cmd_async(priv, cmd);
217
218 return iwl_send_cmd_sync(priv, cmd);
219}
220EXPORT_SYMBOL(iwl_send_cmd);
221
222int iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u16 len, const void *data)
223{
224 struct iwl_host_cmd cmd = {
225 .id = id,
226 .len = len,
227 .data = data,
228 };
229
230 return iwl_send_cmd_sync(priv, &cmd);
231}
232EXPORT_SYMBOL(iwl_send_cmd_pdu);
233
234int iwl_send_cmd_pdu_async(struct iwl_priv *priv,
235 u8 id, u16 len, const void *data,
236 int (*callback)(struct iwl_priv *priv,
237 struct iwl_cmd *cmd,
238 struct sk_buff *skb))
239{
240 struct iwl_host_cmd cmd = {
241 .id = id,
242 .len = len,
243 .data = data,
244 };
245
246 cmd.meta.flags |= CMD_ASYNC;
247 cmd.meta.u.callback = callback;
248
249 return iwl_send_cmd_async(priv, &cmd);
250}
251EXPORT_SYMBOL(iwl_send_cmd_pdu_async);
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 0b7335181719..44cfd0274976 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -50,7 +50,7 @@
50#include "iwl-4965.h" 50#include "iwl-4965.h"
51#include "iwl-helpers.h" 51#include "iwl-helpers.h"
52 52
53static int iwl4965_tx_queue_update_write_ptr(struct iwl4965_priv *priv, 53static int iwl4965_tx_queue_update_write_ptr(struct iwl_priv *priv,
54 struct iwl4965_tx_queue *txq); 54 struct iwl4965_tx_queue *txq);
55 55
56/****************************************************************************** 56/******************************************************************************
@@ -59,16 +59,6 @@ static int iwl4965_tx_queue_update_write_ptr(struct iwl4965_priv *priv,
59 * 59 *
60 ******************************************************************************/ 60 ******************************************************************************/
61 61
62/* module parameters */
63static int iwl4965_param_disable_hw_scan; /* def: 0 = use 4965's h/w scan */
64static int iwl4965_param_debug; /* def: 0 = minimal debug log messages */
65static int iwl4965_param_disable; /* def: enable radio */
66static int iwl4965_param_antenna; /* def: 0 = both antennas (use diversity) */
67int iwl4965_param_hwcrypto; /* def: using software encryption */
68static int iwl4965_param_qos_enable = 1; /* def: 1 = use quality of service */
69int iwl4965_param_queues_num = IWL_MAX_NUM_QUEUES; /* def: 16 Tx queues */
70int iwl4965_param_amsdu_size_8K; /* def: enable 8K amsdu size */
71
72/* 62/*
73 * module name, copyright, version, etc. 63 * module name, copyright, version, etc.
74 * NOTE: DRV_NAME is defined in iwlwifi.h for use by iwl-debug.h and printk 64 * NOTE: DRV_NAME is defined in iwlwifi.h for use by iwl-debug.h and printk
@@ -76,7 +66,7 @@ int iwl4965_param_amsdu_size_8K; /* def: enable 8K amsdu size */
76 66
77#define DRV_DESCRIPTION "Intel(R) Wireless WiFi Link 4965AGN driver for Linux" 67#define DRV_DESCRIPTION "Intel(R) Wireless WiFi Link 4965AGN driver for Linux"
78 68
79#ifdef CONFIG_IWL4965_DEBUG 69#ifdef CONFIG_IWLWIFI_DEBUG
80#define VD "d" 70#define VD "d"
81#else 71#else
82#define VD 72#define VD
@@ -107,7 +97,7 @@ __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr)
107} 97}
108 98
109static const struct ieee80211_supported_band *iwl4965_get_hw_mode( 99static const struct ieee80211_supported_band *iwl4965_get_hw_mode(
110 struct iwl4965_priv *priv, enum ieee80211_band band) 100 struct iwl_priv *priv, enum ieee80211_band band)
111{ 101{
112 return priv->hw->wiphy->bands[band]; 102 return priv->hw->wiphy->bands[band];
113} 103}
@@ -216,7 +206,7 @@ static inline u8 get_cmd_index(struct iwl4965_queue *q, u32 index, int is_huge)
216/** 206/**
217 * iwl4965_queue_init - Initialize queue's high/low-water and read/write indexes 207 * iwl4965_queue_init - Initialize queue's high/low-water and read/write indexes
218 */ 208 */
219static int iwl4965_queue_init(struct iwl4965_priv *priv, struct iwl4965_queue *q, 209static int iwl4965_queue_init(struct iwl_priv *priv, struct iwl4965_queue *q,
220 int count, int slots_num, u32 id) 210 int count, int slots_num, u32 id)
221{ 211{
222 q->n_bd = count; 212 q->n_bd = count;
@@ -247,7 +237,7 @@ static int iwl4965_queue_init(struct iwl4965_priv *priv, struct iwl4965_queue *q
247/** 237/**
248 * iwl4965_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue 238 * iwl4965_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue
249 */ 239 */
250static int iwl4965_tx_queue_alloc(struct iwl4965_priv *priv, 240static int iwl4965_tx_queue_alloc(struct iwl_priv *priv,
251 struct iwl4965_tx_queue *txq, u32 id) 241 struct iwl4965_tx_queue *txq, u32 id)
252{ 242{
253 struct pci_dev *dev = priv->pci_dev; 243 struct pci_dev *dev = priv->pci_dev;
@@ -292,7 +282,7 @@ static int iwl4965_tx_queue_alloc(struct iwl4965_priv *priv,
292/** 282/**
293 * iwl4965_tx_queue_init - Allocate and initialize one tx/cmd queue 283 * iwl4965_tx_queue_init - Allocate and initialize one tx/cmd queue
294 */ 284 */
295int iwl4965_tx_queue_init(struct iwl4965_priv *priv, 285int iwl4965_tx_queue_init(struct iwl_priv *priv,
296 struct iwl4965_tx_queue *txq, int slots_num, u32 txq_id) 286 struct iwl4965_tx_queue *txq, int slots_num, u32 txq_id)
297{ 287{
298 struct pci_dev *dev = priv->pci_dev; 288 struct pci_dev *dev = priv->pci_dev;
@@ -307,7 +297,7 @@ int iwl4965_tx_queue_init(struct iwl4965_priv *priv,
307 * For normal Tx queues (all other queues), no super-size command 297 * For normal Tx queues (all other queues), no super-size command
308 * space is needed. 298 * space is needed.
309 */ 299 */
310 len = sizeof(struct iwl4965_cmd) * slots_num; 300 len = sizeof(struct iwl_cmd) * slots_num;
311 if (txq_id == IWL_CMD_QUEUE_NUM) 301 if (txq_id == IWL_CMD_QUEUE_NUM)
312 len += IWL_MAX_SCAN_SIZE; 302 len += IWL_MAX_SCAN_SIZE;
313 txq->cmd = pci_alloc_consistent(dev, len, &txq->dma_addr_cmd); 303 txq->cmd = pci_alloc_consistent(dev, len, &txq->dma_addr_cmd);
@@ -344,7 +334,7 @@ int iwl4965_tx_queue_init(struct iwl4965_priv *priv,
344 * Free all buffers. 334 * Free all buffers.
345 * 0-fill, but do not free "txq" descriptor structure. 335 * 0-fill, but do not free "txq" descriptor structure.
346 */ 336 */
347void iwl4965_tx_queue_free(struct iwl4965_priv *priv, struct iwl4965_tx_queue *txq) 337void iwl4965_tx_queue_free(struct iwl_priv *priv, struct iwl4965_tx_queue *txq)
348{ 338{
349 struct iwl4965_queue *q = &txq->q; 339 struct iwl4965_queue *q = &txq->q;
350 struct pci_dev *dev = priv->pci_dev; 340 struct pci_dev *dev = priv->pci_dev;
@@ -358,7 +348,7 @@ void iwl4965_tx_queue_free(struct iwl4965_priv *priv, struct iwl4965_tx_queue *t
358 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) 348 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd))
359 iwl4965_hw_txq_free_tfd(priv, txq); 349 iwl4965_hw_txq_free_tfd(priv, txq);
360 350
361 len = sizeof(struct iwl4965_cmd) * q->n_window; 351 len = sizeof(struct iwl_cmd) * q->n_window;
362 if (q->id == IWL_CMD_QUEUE_NUM) 352 if (q->id == IWL_CMD_QUEUE_NUM)
363 len += IWL_MAX_SCAN_SIZE; 353 len += IWL_MAX_SCAN_SIZE;
364 354
@@ -395,7 +385,7 @@ const u8 iwl4965_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
395 * 385 *
396 * NOTE: This does not remove station from device's station table. 386 * NOTE: This does not remove station from device's station table.
397 */ 387 */
398static u8 iwl4965_remove_station(struct iwl4965_priv *priv, const u8 *addr, int is_ap) 388static u8 iwl4965_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
399{ 389{
400 int index = IWL_INVALID_STATION; 390 int index = IWL_INVALID_STATION;
401 int i; 391 int i;
@@ -433,26 +423,9 @@ out:
433#endif 423#endif
434 424
435/** 425/**
436 * iwl4965_clear_stations_table - Clear the driver's station table
437 *
438 * NOTE: This does not clear or otherwise alter the device's station table.
439 */
440static void iwl4965_clear_stations_table(struct iwl4965_priv *priv)
441{
442 unsigned long flags;
443
444 spin_lock_irqsave(&priv->sta_lock, flags);
445
446 priv->num_stations = 0;
447 memset(priv->stations, 0, sizeof(priv->stations));
448
449 spin_unlock_irqrestore(&priv->sta_lock, flags);
450}
451
452/**
453 * iwl4965_add_station_flags - Add station to tables in driver and device 426 * iwl4965_add_station_flags - Add station to tables in driver and device
454 */ 427 */
455u8 iwl4965_add_station_flags(struct iwl4965_priv *priv, const u8 *addr, 428u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr,
456 int is_ap, u8 flags, void *ht_data) 429 int is_ap, u8 flags, void *ht_data)
457{ 430{
458 int i; 431 int i;
@@ -524,7 +497,7 @@ u8 iwl4965_add_station_flags(struct iwl4965_priv *priv, const u8 *addr,
524 497
525/*************** DRIVER STATUS FUNCTIONS *****/ 498/*************** DRIVER STATUS FUNCTIONS *****/
526 499
527static inline int iwl4965_is_ready(struct iwl4965_priv *priv) 500static inline int iwl4965_is_ready(struct iwl_priv *priv)
528{ 501{
529 /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are 502 /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are
530 * set but EXIT_PENDING is not */ 503 * set but EXIT_PENDING is not */
@@ -533,23 +506,23 @@ static inline int iwl4965_is_ready(struct iwl4965_priv *priv)
533 !test_bit(STATUS_EXIT_PENDING, &priv->status); 506 !test_bit(STATUS_EXIT_PENDING, &priv->status);
534} 507}
535 508
536static inline int iwl4965_is_alive(struct iwl4965_priv *priv) 509static inline int iwl4965_is_alive(struct iwl_priv *priv)
537{ 510{
538 return test_bit(STATUS_ALIVE, &priv->status); 511 return test_bit(STATUS_ALIVE, &priv->status);
539} 512}
540 513
541static inline int iwl4965_is_init(struct iwl4965_priv *priv) 514static inline int iwl4965_is_init(struct iwl_priv *priv)
542{ 515{
543 return test_bit(STATUS_INIT, &priv->status); 516 return test_bit(STATUS_INIT, &priv->status);
544} 517}
545 518
546static inline int iwl4965_is_rfkill(struct iwl4965_priv *priv) 519static inline int iwl4965_is_rfkill(struct iwl_priv *priv)
547{ 520{
548 return test_bit(STATUS_RF_KILL_HW, &priv->status) || 521 return test_bit(STATUS_RF_KILL_HW, &priv->status) ||
549 test_bit(STATUS_RF_KILL_SW, &priv->status); 522 test_bit(STATUS_RF_KILL_SW, &priv->status);
550} 523}
551 524
552static inline int iwl4965_is_ready_rf(struct iwl4965_priv *priv) 525static inline int iwl4965_is_ready_rf(struct iwl_priv *priv)
553{ 526{
554 527
555 if (iwl4965_is_rfkill(priv)) 528 if (iwl4965_is_rfkill(priv))
@@ -560,65 +533,6 @@ static inline int iwl4965_is_ready_rf(struct iwl4965_priv *priv)
560 533
561/*************** HOST COMMAND QUEUE FUNCTIONS *****/ 534/*************** HOST COMMAND QUEUE FUNCTIONS *****/
562 535
563#define IWL_CMD(x) case x : return #x
564
565static const char *get_cmd_string(u8 cmd)
566{
567 switch (cmd) {
568 IWL_CMD(REPLY_ALIVE);
569 IWL_CMD(REPLY_ERROR);
570 IWL_CMD(REPLY_RXON);
571 IWL_CMD(REPLY_RXON_ASSOC);
572 IWL_CMD(REPLY_QOS_PARAM);
573 IWL_CMD(REPLY_RXON_TIMING);
574 IWL_CMD(REPLY_ADD_STA);
575 IWL_CMD(REPLY_REMOVE_STA);
576 IWL_CMD(REPLY_REMOVE_ALL_STA);
577 IWL_CMD(REPLY_TX);
578 IWL_CMD(REPLY_RATE_SCALE);
579 IWL_CMD(REPLY_LEDS_CMD);
580 IWL_CMD(REPLY_TX_LINK_QUALITY_CMD);
581 IWL_CMD(RADAR_NOTIFICATION);
582 IWL_CMD(REPLY_QUIET_CMD);
583 IWL_CMD(REPLY_CHANNEL_SWITCH);
584 IWL_CMD(CHANNEL_SWITCH_NOTIFICATION);
585 IWL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD);
586 IWL_CMD(SPECTRUM_MEASURE_NOTIFICATION);
587 IWL_CMD(POWER_TABLE_CMD);
588 IWL_CMD(PM_SLEEP_NOTIFICATION);
589 IWL_CMD(PM_DEBUG_STATISTIC_NOTIFIC);
590 IWL_CMD(REPLY_SCAN_CMD);
591 IWL_CMD(REPLY_SCAN_ABORT_CMD);
592 IWL_CMD(SCAN_START_NOTIFICATION);
593 IWL_CMD(SCAN_RESULTS_NOTIFICATION);
594 IWL_CMD(SCAN_COMPLETE_NOTIFICATION);
595 IWL_CMD(BEACON_NOTIFICATION);
596 IWL_CMD(REPLY_TX_BEACON);
597 IWL_CMD(WHO_IS_AWAKE_NOTIFICATION);
598 IWL_CMD(QUIET_NOTIFICATION);
599 IWL_CMD(REPLY_TX_PWR_TABLE_CMD);
600 IWL_CMD(MEASURE_ABORT_NOTIFICATION);
601 IWL_CMD(REPLY_BT_CONFIG);
602 IWL_CMD(REPLY_STATISTICS_CMD);
603 IWL_CMD(STATISTICS_NOTIFICATION);
604 IWL_CMD(REPLY_CARD_STATE_CMD);
605 IWL_CMD(CARD_STATE_NOTIFICATION);
606 IWL_CMD(MISSED_BEACONS_NOTIFICATION);
607 IWL_CMD(REPLY_CT_KILL_CONFIG_CMD);
608 IWL_CMD(SENSITIVITY_CMD);
609 IWL_CMD(REPLY_PHY_CALIBRATION_CMD);
610 IWL_CMD(REPLY_RX_PHY_CMD);
611 IWL_CMD(REPLY_RX_MPDU_CMD);
612 IWL_CMD(REPLY_4965_RX);
613 IWL_CMD(REPLY_COMPRESSED_BA);
614 default:
615 return "UNKNOWN";
616
617 }
618}
619
620#define HOST_COMPLETE_TIMEOUT (HZ / 2)
621
622/** 536/**
623 * iwl4965_enqueue_hcmd - enqueue a uCode command 537 * iwl4965_enqueue_hcmd - enqueue a uCode command
624 * @priv: device private data point 538 * @priv: device private data point
@@ -628,13 +542,13 @@ static const char *get_cmd_string(u8 cmd)
628 * failed. On success, it turns the index (> 0) of command in the 542 * failed. On success, it turns the index (> 0) of command in the
629 * command queue. 543 * command queue.
630 */ 544 */
631static int iwl4965_enqueue_hcmd(struct iwl4965_priv *priv, struct iwl4965_host_cmd *cmd) 545int iwl4965_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
632{ 546{
633 struct iwl4965_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; 547 struct iwl4965_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
634 struct iwl4965_queue *q = &txq->q; 548 struct iwl4965_queue *q = &txq->q;
635 struct iwl4965_tfd_frame *tfd; 549 struct iwl4965_tfd_frame *tfd;
636 u32 *control_flags; 550 u32 *control_flags;
637 struct iwl4965_cmd *out_cmd; 551 struct iwl_cmd *out_cmd;
638 u32 idx; 552 u32 idx;
639 u16 fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); 553 u16 fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr));
640 dma_addr_t phys_addr; 554 dma_addr_t phys_addr;
@@ -681,7 +595,7 @@ static int iwl4965_enqueue_hcmd(struct iwl4965_priv *priv, struct iwl4965_host_c
681 out_cmd->hdr.sequence |= cpu_to_le16(SEQ_HUGE_FRAME); 595 out_cmd->hdr.sequence |= cpu_to_le16(SEQ_HUGE_FRAME);
682 596
683 phys_addr = txq->dma_addr_cmd + sizeof(txq->cmd[0]) * idx + 597 phys_addr = txq->dma_addr_cmd + sizeof(txq->cmd[0]) * idx +
684 offsetof(struct iwl4965_cmd, hdr); 598 offsetof(struct iwl_cmd, hdr);
685 iwl4965_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, fix_size); 599 iwl4965_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, fix_size);
686 600
687 IWL_DEBUG_HC("Sending command %s (#%x), seq: 0x%04X, " 601 IWL_DEBUG_HC("Sending command %s (#%x), seq: 0x%04X, "
@@ -703,151 +617,22 @@ static int iwl4965_enqueue_hcmd(struct iwl4965_priv *priv, struct iwl4965_host_c
703 return ret ? ret : idx; 617 return ret ? ret : idx;
704} 618}
705 619
706static int iwl4965_send_cmd_async(struct iwl4965_priv *priv, struct iwl4965_host_cmd *cmd) 620static void iwl4965_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
707{ 621{
708 int ret; 622 struct iwl4965_rxon_cmd *rxon = &priv->staging_rxon;
709
710 BUG_ON(!(cmd->meta.flags & CMD_ASYNC));
711
712 /* An asynchronous command can not expect an SKB to be set. */
713 BUG_ON(cmd->meta.flags & CMD_WANT_SKB);
714
715 /* An asynchronous command MUST have a callback. */
716 BUG_ON(!cmd->meta.u.callback);
717
718 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
719 return -EBUSY;
720
721 ret = iwl4965_enqueue_hcmd(priv, cmd);
722 if (ret < 0) {
723 IWL_ERROR("Error sending %s: iwl4965_enqueue_hcmd failed: %d\n",
724 get_cmd_string(cmd->id), ret);
725 return ret;
726 }
727 return 0;
728}
729
730static int iwl4965_send_cmd_sync(struct iwl4965_priv *priv, struct iwl4965_host_cmd *cmd)
731{
732 int cmd_idx;
733 int ret;
734 static atomic_t entry = ATOMIC_INIT(0); /* reentrance protection */
735
736 BUG_ON(cmd->meta.flags & CMD_ASYNC);
737
738 /* A synchronous command can not have a callback set. */
739 BUG_ON(cmd->meta.u.callback != NULL);
740
741 if (atomic_xchg(&entry, 1)) {
742 IWL_ERROR("Error sending %s: Already sending a host command\n",
743 get_cmd_string(cmd->id));
744 return -EBUSY;
745 }
746
747 set_bit(STATUS_HCMD_ACTIVE, &priv->status);
748
749 if (cmd->meta.flags & CMD_WANT_SKB)
750 cmd->meta.source = &cmd->meta;
751
752 cmd_idx = iwl4965_enqueue_hcmd(priv, cmd);
753 if (cmd_idx < 0) {
754 ret = cmd_idx;
755 IWL_ERROR("Error sending %s: iwl4965_enqueue_hcmd failed: %d\n",
756 get_cmd_string(cmd->id), ret);
757 goto out;
758 }
759
760 ret = wait_event_interruptible_timeout(priv->wait_command_queue,
761 !test_bit(STATUS_HCMD_ACTIVE, &priv->status),
762 HOST_COMPLETE_TIMEOUT);
763 if (!ret) {
764 if (test_bit(STATUS_HCMD_ACTIVE, &priv->status)) {
765 IWL_ERROR("Error sending %s: time out after %dms.\n",
766 get_cmd_string(cmd->id),
767 jiffies_to_msecs(HOST_COMPLETE_TIMEOUT));
768
769 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
770 ret = -ETIMEDOUT;
771 goto cancel;
772 }
773 }
774
775 if (test_bit(STATUS_RF_KILL_HW, &priv->status)) {
776 IWL_DEBUG_INFO("Command %s aborted: RF KILL Switch\n",
777 get_cmd_string(cmd->id));
778 ret = -ECANCELED;
779 goto fail;
780 }
781 if (test_bit(STATUS_FW_ERROR, &priv->status)) {
782 IWL_DEBUG_INFO("Command %s failed: FW Error\n",
783 get_cmd_string(cmd->id));
784 ret = -EIO;
785 goto fail;
786 }
787 if ((cmd->meta.flags & CMD_WANT_SKB) && !cmd->meta.u.skb) {
788 IWL_ERROR("Error: Response NULL in '%s'\n",
789 get_cmd_string(cmd->id));
790 ret = -EIO;
791 goto out;
792 }
793
794 ret = 0;
795 goto out;
796
797cancel:
798 if (cmd->meta.flags & CMD_WANT_SKB) {
799 struct iwl4965_cmd *qcmd;
800
801 /* Cancel the CMD_WANT_SKB flag for the cmd in the
802 * TX cmd queue. Otherwise in case the cmd comes
803 * in later, it will possibly set an invalid
804 * address (cmd->meta.source). */
805 qcmd = &priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_idx];
806 qcmd->meta.flags &= ~CMD_WANT_SKB;
807 }
808fail:
809 if (cmd->meta.u.skb) {
810 dev_kfree_skb_any(cmd->meta.u.skb);
811 cmd->meta.u.skb = NULL;
812 }
813out:
814 atomic_set(&entry, 0);
815 return ret;
816}
817
818int iwl4965_send_cmd(struct iwl4965_priv *priv, struct iwl4965_host_cmd *cmd)
819{
820 if (cmd->meta.flags & CMD_ASYNC)
821 return iwl4965_send_cmd_async(priv, cmd);
822
823 return iwl4965_send_cmd_sync(priv, cmd);
824}
825
826int iwl4965_send_cmd_pdu(struct iwl4965_priv *priv, u8 id, u16 len, const void *data)
827{
828 struct iwl4965_host_cmd cmd = {
829 .id = id,
830 .len = len,
831 .data = data,
832 };
833
834 return iwl4965_send_cmd_sync(priv, &cmd);
835}
836 623
837static int __must_check iwl4965_send_cmd_u32(struct iwl4965_priv *priv, u8 id, u32 val) 624 if (hw_decrypt)
838{ 625 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK;
839 struct iwl4965_host_cmd cmd = { 626 else
840 .id = id, 627 rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK;
841 .len = sizeof(val),
842 .data = &val,
843 };
844 628
845 return iwl4965_send_cmd_sync(priv, &cmd);
846} 629}
847 630
848int iwl4965_send_statistics_request(struct iwl4965_priv *priv) 631int iwl4965_send_statistics_request(struct iwl_priv *priv)
849{ 632{
850 return iwl4965_send_cmd_u32(priv, REPLY_STATISTICS_CMD, 0); 633 u32 flags = 0;
634 return iwl_send_cmd_pdu(priv, REPLY_STATISTICS_CMD,
635 sizeof(flags), &flags);
851} 636}
852 637
853/** 638/**
@@ -856,7 +641,7 @@ int iwl4965_send_statistics_request(struct iwl4965_priv *priv)
856 * there is only one AP station with id= IWL_AP_ID 641 * there is only one AP station with id= IWL_AP_ID
857 * NOTE: mutex must be held before calling this fnction 642 * NOTE: mutex must be held before calling this fnction
858 */ 643 */
859static int iwl4965_rxon_add_station(struct iwl4965_priv *priv, 644static int iwl4965_rxon_add_station(struct iwl_priv *priv,
860 const u8 *addr, int is_ap) 645 const u8 *addr, int is_ap)
861{ 646{
862 u8 sta_id; 647 u8 sta_id;
@@ -883,43 +668,6 @@ static int iwl4965_rxon_add_station(struct iwl4965_priv *priv,
883} 668}
884 669
885/** 670/**
886 * iwl4965_set_rxon_channel - Set the phymode and channel values in staging RXON
887 * @phymode: MODE_IEEE80211A sets to 5.2GHz; all else set to 2.4GHz
888 * @channel: Any channel valid for the requested phymode
889
890 * In addition to setting the staging RXON, priv->phymode is also set.
891 *
892 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
893 * in the staging RXON flag structure based on the phymode
894 */
895static int iwl4965_set_rxon_channel(struct iwl4965_priv *priv,
896 enum ieee80211_band band,
897 u16 channel)
898{
899 if (!iwl4965_get_channel_info(priv, band, channel)) {
900 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n",
901 channel, band);
902 return -EINVAL;
903 }
904
905 if ((le16_to_cpu(priv->staging_rxon.channel) == channel) &&
906 (priv->band == band))
907 return 0;
908
909 priv->staging_rxon.channel = cpu_to_le16(channel);
910 if (band == IEEE80211_BAND_5GHZ)
911 priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK;
912 else
913 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
914
915 priv->band = band;
916
917 IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band);
918
919 return 0;
920}
921
922/**
923 * iwl4965_check_rxon_cmd - validate RXON structure is valid 671 * iwl4965_check_rxon_cmd - validate RXON structure is valid
924 * 672 *
925 * NOTE: This is really only useful during development and can eventually 673 * NOTE: This is really only useful during development and can eventually
@@ -1000,7 +748,7 @@ static int iwl4965_check_rxon_cmd(struct iwl4965_rxon_cmd *rxon)
1000 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that 748 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that
1001 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. 749 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
1002 */ 750 */
1003static int iwl4965_full_rxon_required(struct iwl4965_priv *priv) 751static int iwl4965_full_rxon_required(struct iwl_priv *priv)
1004{ 752{
1005 753
1006 /* These items are only settable from the full RXON command */ 754 /* These items are only settable from the full RXON command */
@@ -1040,12 +788,12 @@ static int iwl4965_full_rxon_required(struct iwl4965_priv *priv)
1040 return 0; 788 return 0;
1041} 789}
1042 790
1043static int iwl4965_send_rxon_assoc(struct iwl4965_priv *priv) 791static int iwl4965_send_rxon_assoc(struct iwl_priv *priv)
1044{ 792{
1045 int rc = 0; 793 int rc = 0;
1046 struct iwl4965_rx_packet *res = NULL; 794 struct iwl4965_rx_packet *res = NULL;
1047 struct iwl4965_rxon_assoc_cmd rxon_assoc; 795 struct iwl4965_rxon_assoc_cmd rxon_assoc;
1048 struct iwl4965_host_cmd cmd = { 796 struct iwl_host_cmd cmd = {
1049 .id = REPLY_RXON_ASSOC, 797 .id = REPLY_RXON_ASSOC,
1050 .len = sizeof(rxon_assoc), 798 .len = sizeof(rxon_assoc),
1051 .meta.flags = CMD_WANT_SKB, 799 .meta.flags = CMD_WANT_SKB,
@@ -1078,7 +826,7 @@ static int iwl4965_send_rxon_assoc(struct iwl4965_priv *priv)
1078 priv->staging_rxon.ofdm_ht_dual_stream_basic_rates; 826 priv->staging_rxon.ofdm_ht_dual_stream_basic_rates;
1079 rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain; 827 rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain;
1080 828
1081 rc = iwl4965_send_cmd_sync(priv, &cmd); 829 rc = iwl_send_cmd_sync(priv, &cmd);
1082 if (rc) 830 if (rc)
1083 return rc; 831 return rc;
1084 832
@@ -1102,7 +850,7 @@ static int iwl4965_send_rxon_assoc(struct iwl4965_priv *priv)
1102 * function correctly transitions out of the RXON_ASSOC_MSK state if 850 * function correctly transitions out of the RXON_ASSOC_MSK state if
1103 * a HW tune is required based on the RXON structure changes. 851 * a HW tune is required based on the RXON structure changes.
1104 */ 852 */
1105static int iwl4965_commit_rxon(struct iwl4965_priv *priv) 853static int iwl4965_commit_rxon(struct iwl_priv *priv)
1106{ 854{
1107 /* cast away the const for active_rxon in this function */ 855 /* cast away the const for active_rxon in this function */
1108 struct iwl4965_rxon_cmd *active_rxon = (void *)&priv->active_rxon; 856 struct iwl4965_rxon_cmd *active_rxon = (void *)&priv->active_rxon;
@@ -1157,7 +905,7 @@ static int iwl4965_commit_rxon(struct iwl4965_priv *priv)
1157 IWL_DEBUG_INFO("Toggling associated bit on current RXON\n"); 905 IWL_DEBUG_INFO("Toggling associated bit on current RXON\n");
1158 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 906 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
1159 907
1160 rc = iwl4965_send_cmd_pdu(priv, REPLY_RXON, 908 rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
1161 sizeof(struct iwl4965_rxon_cmd), 909 sizeof(struct iwl4965_rxon_cmd),
1162 &priv->active_rxon); 910 &priv->active_rxon);
1163 911
@@ -1180,15 +928,16 @@ static int iwl4965_commit_rxon(struct iwl4965_priv *priv)
1180 le16_to_cpu(priv->staging_rxon.channel), 928 le16_to_cpu(priv->staging_rxon.channel),
1181 print_mac(mac, priv->staging_rxon.bssid_addr)); 929 print_mac(mac, priv->staging_rxon.bssid_addr));
1182 930
931 iwl4965_set_rxon_hwcrypto(priv, priv->cfg->mod_params->hw_crypto);
1183 /* Apply the new configuration */ 932 /* Apply the new configuration */
1184 rc = iwl4965_send_cmd_pdu(priv, REPLY_RXON, 933 rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
1185 sizeof(struct iwl4965_rxon_cmd), &priv->staging_rxon); 934 sizeof(struct iwl4965_rxon_cmd), &priv->staging_rxon);
1186 if (rc) { 935 if (rc) {
1187 IWL_ERROR("Error setting new configuration (%d).\n", rc); 936 IWL_ERROR("Error setting new configuration (%d).\n", rc);
1188 return rc; 937 return rc;
1189 } 938 }
1190 939
1191 iwl4965_clear_stations_table(priv); 940 iwlcore_clear_stations_table(priv);
1192 941
1193#ifdef CONFIG_IWL4965_SENSITIVITY 942#ifdef CONFIG_IWL4965_SENSITIVITY
1194 if (!priv->error_recovering) 943 if (!priv->error_recovering)
@@ -1230,7 +979,7 @@ static int iwl4965_commit_rxon(struct iwl4965_priv *priv)
1230 return 0; 979 return 0;
1231} 980}
1232 981
1233static int iwl4965_send_bt_config(struct iwl4965_priv *priv) 982static int iwl4965_send_bt_config(struct iwl_priv *priv)
1234{ 983{
1235 struct iwl4965_bt_cmd bt_cmd = { 984 struct iwl4965_bt_cmd bt_cmd = {
1236 .flags = 3, 985 .flags = 3,
@@ -1240,15 +989,15 @@ static int iwl4965_send_bt_config(struct iwl4965_priv *priv)
1240 .kill_cts_mask = 0, 989 .kill_cts_mask = 0,
1241 }; 990 };
1242 991
1243 return iwl4965_send_cmd_pdu(priv, REPLY_BT_CONFIG, 992 return iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG,
1244 sizeof(struct iwl4965_bt_cmd), &bt_cmd); 993 sizeof(struct iwl4965_bt_cmd), &bt_cmd);
1245} 994}
1246 995
1247static int iwl4965_send_scan_abort(struct iwl4965_priv *priv) 996static int iwl4965_send_scan_abort(struct iwl_priv *priv)
1248{ 997{
1249 int rc = 0; 998 int rc = 0;
1250 struct iwl4965_rx_packet *res; 999 struct iwl4965_rx_packet *res;
1251 struct iwl4965_host_cmd cmd = { 1000 struct iwl_host_cmd cmd = {
1252 .id = REPLY_SCAN_ABORT_CMD, 1001 .id = REPLY_SCAN_ABORT_CMD,
1253 .meta.flags = CMD_WANT_SKB, 1002 .meta.flags = CMD_WANT_SKB,
1254 }; 1003 };
@@ -1261,7 +1010,7 @@ static int iwl4965_send_scan_abort(struct iwl4965_priv *priv)
1261 return 0; 1010 return 0;
1262 } 1011 }
1263 1012
1264 rc = iwl4965_send_cmd_sync(priv, &cmd); 1013 rc = iwl_send_cmd_sync(priv, &cmd);
1265 if (rc) { 1014 if (rc) {
1266 clear_bit(STATUS_SCAN_ABORTING, &priv->status); 1015 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
1267 return rc; 1016 return rc;
@@ -1285,8 +1034,8 @@ static int iwl4965_send_scan_abort(struct iwl4965_priv *priv)
1285 return rc; 1034 return rc;
1286} 1035}
1287 1036
1288static int iwl4965_card_state_sync_callback(struct iwl4965_priv *priv, 1037static int iwl4965_card_state_sync_callback(struct iwl_priv *priv,
1289 struct iwl4965_cmd *cmd, 1038 struct iwl_cmd *cmd,
1290 struct sk_buff *skb) 1039 struct sk_buff *skb)
1291{ 1040{
1292 return 1; 1041 return 1;
@@ -1302,9 +1051,9 @@ static int iwl4965_card_state_sync_callback(struct iwl4965_priv *priv,
1302 * When in the 'halt' state, the card is shut down and must be fully 1051 * When in the 'halt' state, the card is shut down and must be fully
1303 * restarted to come back on. 1052 * restarted to come back on.
1304 */ 1053 */
1305static int iwl4965_send_card_state(struct iwl4965_priv *priv, u32 flags, u8 meta_flag) 1054static int iwl4965_send_card_state(struct iwl_priv *priv, u32 flags, u8 meta_flag)
1306{ 1055{
1307 struct iwl4965_host_cmd cmd = { 1056 struct iwl_host_cmd cmd = {
1308 .id = REPLY_CARD_STATE_CMD, 1057 .id = REPLY_CARD_STATE_CMD,
1309 .len = sizeof(u32), 1058 .len = sizeof(u32),
1310 .data = &flags, 1059 .data = &flags,
@@ -1314,11 +1063,11 @@ static int iwl4965_send_card_state(struct iwl4965_priv *priv, u32 flags, u8 meta
1314 if (meta_flag & CMD_ASYNC) 1063 if (meta_flag & CMD_ASYNC)
1315 cmd.meta.u.callback = iwl4965_card_state_sync_callback; 1064 cmd.meta.u.callback = iwl4965_card_state_sync_callback;
1316 1065
1317 return iwl4965_send_cmd(priv, &cmd); 1066 return iwl_send_cmd(priv, &cmd);
1318} 1067}
1319 1068
1320static int iwl4965_add_sta_sync_callback(struct iwl4965_priv *priv, 1069static int iwl4965_add_sta_sync_callback(struct iwl_priv *priv,
1321 struct iwl4965_cmd *cmd, struct sk_buff *skb) 1070 struct iwl_cmd *cmd, struct sk_buff *skb)
1322{ 1071{
1323 struct iwl4965_rx_packet *res = NULL; 1072 struct iwl4965_rx_packet *res = NULL;
1324 1073
@@ -1345,12 +1094,12 @@ static int iwl4965_add_sta_sync_callback(struct iwl4965_priv *priv,
1345 return 1; 1094 return 1;
1346} 1095}
1347 1096
1348int iwl4965_send_add_station(struct iwl4965_priv *priv, 1097int iwl4965_send_add_station(struct iwl_priv *priv,
1349 struct iwl4965_addsta_cmd *sta, u8 flags) 1098 struct iwl4965_addsta_cmd *sta, u8 flags)
1350{ 1099{
1351 struct iwl4965_rx_packet *res = NULL; 1100 struct iwl4965_rx_packet *res = NULL;
1352 int rc = 0; 1101 int rc = 0;
1353 struct iwl4965_host_cmd cmd = { 1102 struct iwl_host_cmd cmd = {
1354 .id = REPLY_ADD_STA, 1103 .id = REPLY_ADD_STA,
1355 .len = sizeof(struct iwl4965_addsta_cmd), 1104 .len = sizeof(struct iwl4965_addsta_cmd),
1356 .meta.flags = flags, 1105 .meta.flags = flags,
@@ -1362,7 +1111,7 @@ int iwl4965_send_add_station(struct iwl4965_priv *priv,
1362 else 1111 else
1363 cmd.meta.flags |= CMD_WANT_SKB; 1112 cmd.meta.flags |= CMD_WANT_SKB;
1364 1113
1365 rc = iwl4965_send_cmd(priv, &cmd); 1114 rc = iwl_send_cmd(priv, &cmd);
1366 1115
1367 if (rc || (flags & CMD_ASYNC)) 1116 if (rc || (flags & CMD_ASYNC))
1368 return rc; 1117 return rc;
@@ -1392,33 +1141,36 @@ int iwl4965_send_add_station(struct iwl4965_priv *priv,
1392 return rc; 1141 return rc;
1393} 1142}
1394 1143
1395static int iwl4965_update_sta_key_info(struct iwl4965_priv *priv, 1144static int iwl4965_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
1396 struct ieee80211_key_conf *keyconf, 1145 struct ieee80211_key_conf *keyconf,
1397 u8 sta_id) 1146 u8 sta_id)
1398{ 1147{
1399 unsigned long flags; 1148 unsigned long flags;
1400 __le16 key_flags = 0; 1149 __le16 key_flags = 0;
1401 1150
1402 switch (keyconf->alg) { 1151 key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK);
1403 case ALG_CCMP: 1152 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
1404 key_flags |= STA_KEY_FLG_CCMP; 1153
1405 key_flags |= cpu_to_le16( 1154 if (sta_id == priv->hw_setting.bcast_sta_id)
1406 keyconf->keyidx << STA_KEY_FLG_KEYID_POS); 1155 key_flags |= STA_KEY_MULTICAST_MSK;
1407 key_flags &= ~STA_KEY_FLG_INVALID; 1156
1408 break; 1157 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1409 case ALG_TKIP: 1158 keyconf->hw_key_idx = keyconf->keyidx;
1410 case ALG_WEP: 1159
1411 default: 1160 key_flags &= ~STA_KEY_FLG_INVALID;
1412 return -EINVAL; 1161
1413 }
1414 spin_lock_irqsave(&priv->sta_lock, flags); 1162 spin_lock_irqsave(&priv->sta_lock, flags);
1415 priv->stations[sta_id].keyinfo.alg = keyconf->alg; 1163 priv->stations[sta_id].keyinfo.alg = keyconf->alg;
1416 priv->stations[sta_id].keyinfo.keylen = keyconf->keylen; 1164 priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
1165
1417 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 1166 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key,
1418 keyconf->keylen); 1167 keyconf->keylen);
1419 1168
1420 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, 1169 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key,
1421 keyconf->keylen); 1170 keyconf->keylen);
1171
1172 priv->stations[sta_id].sta.key.key_offset
1173 = (sta_id % STA_KEY_MAX_NUM);/*FIXME*/
1422 priv->stations[sta_id].sta.key.key_flags = key_flags; 1174 priv->stations[sta_id].sta.key.key_flags = key_flags;
1423 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; 1175 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
1424 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; 1176 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
@@ -1426,11 +1178,38 @@ static int iwl4965_update_sta_key_info(struct iwl4965_priv *priv,
1426 spin_unlock_irqrestore(&priv->sta_lock, flags); 1178 spin_unlock_irqrestore(&priv->sta_lock, flags);
1427 1179
1428 IWL_DEBUG_INFO("hwcrypto: modify ucode station key info\n"); 1180 IWL_DEBUG_INFO("hwcrypto: modify ucode station key info\n");
1429 iwl4965_send_add_station(priv, &priv->stations[sta_id].sta, 0); 1181 return iwl4965_send_add_station(priv,
1430 return 0; 1182 &priv->stations[sta_id].sta, CMD_ASYNC);
1431} 1183}
1432 1184
1433static int iwl4965_clear_sta_key_info(struct iwl4965_priv *priv, u8 sta_id) 1185static int iwl4965_set_tkip_dynamic_key_info(struct iwl_priv *priv,
1186 struct ieee80211_key_conf *keyconf,
1187 u8 sta_id)
1188{
1189 unsigned long flags;
1190 int ret = 0;
1191
1192 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1193 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1194 keyconf->hw_key_idx = keyconf->keyidx;
1195
1196 spin_lock_irqsave(&priv->sta_lock, flags);
1197
1198 priv->stations[sta_id].keyinfo.alg = keyconf->alg;
1199 priv->stations[sta_id].keyinfo.conf = keyconf;
1200 priv->stations[sta_id].keyinfo.keylen = 16;
1201
1202 /* This copy is acutally not needed: we get the key with each TX */
1203 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16);
1204
1205 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, 16);
1206
1207 spin_unlock_irqrestore(&priv->sta_lock, flags);
1208
1209 return ret;
1210}
1211
1212static int iwl4965_clear_sta_key_info(struct iwl_priv *priv, u8 sta_id)
1434{ 1213{
1435 unsigned long flags; 1214 unsigned long flags;
1436 1215
@@ -1447,7 +1226,47 @@ static int iwl4965_clear_sta_key_info(struct iwl4965_priv *priv, u8 sta_id)
1447 return 0; 1226 return 0;
1448} 1227}
1449 1228
1450static void iwl4965_clear_free_frames(struct iwl4965_priv *priv) 1229static int iwl4965_set_dynamic_key(struct iwl_priv *priv,
1230 struct ieee80211_key_conf *key, u8 sta_id)
1231{
1232 int ret;
1233
1234 switch (key->alg) {
1235 case ALG_CCMP:
1236 ret = iwl4965_set_ccmp_dynamic_key_info(priv, key, sta_id);
1237 break;
1238 case ALG_TKIP:
1239 ret = iwl4965_set_tkip_dynamic_key_info(priv, key, sta_id);
1240 break;
1241 case ALG_WEP:
1242 ret = -EOPNOTSUPP;
1243 break;
1244 default:
1245 IWL_ERROR("Unknown alg: %s alg = %d\n", __func__, key->alg);
1246 ret = -EINVAL;
1247 }
1248
1249 return ret;
1250}
1251
1252static int iwl4965_remove_static_key(struct iwl_priv *priv)
1253{
1254 int ret = -EOPNOTSUPP;
1255
1256 return ret;
1257}
1258
1259static int iwl4965_set_static_key(struct iwl_priv *priv,
1260 struct ieee80211_key_conf *key)
1261{
1262 if (key->alg == ALG_WEP)
1263 return -EOPNOTSUPP;
1264
1265 IWL_ERROR("Static key invalid: alg %d\n", key->alg);
1266 return -EINVAL;
1267}
1268
1269static void iwl4965_clear_free_frames(struct iwl_priv *priv)
1451{ 1270{
1452 struct list_head *element; 1271 struct list_head *element;
1453 1272
@@ -1468,7 +1287,7 @@ static void iwl4965_clear_free_frames(struct iwl4965_priv *priv)
1468 } 1287 }
1469} 1288}
1470 1289
1471static struct iwl4965_frame *iwl4965_get_free_frame(struct iwl4965_priv *priv) 1290static struct iwl4965_frame *iwl4965_get_free_frame(struct iwl_priv *priv)
1472{ 1291{
1473 struct iwl4965_frame *frame; 1292 struct iwl4965_frame *frame;
1474 struct list_head *element; 1293 struct list_head *element;
@@ -1488,13 +1307,13 @@ static struct iwl4965_frame *iwl4965_get_free_frame(struct iwl4965_priv *priv)
1488 return list_entry(element, struct iwl4965_frame, list); 1307 return list_entry(element, struct iwl4965_frame, list);
1489} 1308}
1490 1309
1491static void iwl4965_free_frame(struct iwl4965_priv *priv, struct iwl4965_frame *frame) 1310static void iwl4965_free_frame(struct iwl_priv *priv, struct iwl4965_frame *frame)
1492{ 1311{
1493 memset(frame, 0, sizeof(*frame)); 1312 memset(frame, 0, sizeof(*frame));
1494 list_add(&frame->list, &priv->free_frames); 1313 list_add(&frame->list, &priv->free_frames);
1495} 1314}
1496 1315
1497unsigned int iwl4965_fill_beacon_frame(struct iwl4965_priv *priv, 1316unsigned int iwl4965_fill_beacon_frame(struct iwl_priv *priv,
1498 struct ieee80211_hdr *hdr, 1317 struct ieee80211_hdr *hdr,
1499 const u8 *dest, int left) 1318 const u8 *dest, int left)
1500{ 1319{
@@ -1525,7 +1344,7 @@ static u8 iwl4965_rate_get_lowest_plcp(int rate_mask)
1525 return IWL_RATE_INVALID; 1344 return IWL_RATE_INVALID;
1526} 1345}
1527 1346
1528static int iwl4965_send_beacon_cmd(struct iwl4965_priv *priv) 1347static int iwl4965_send_beacon_cmd(struct iwl_priv *priv)
1529{ 1348{
1530 struct iwl4965_frame *frame; 1349 struct iwl4965_frame *frame;
1531 unsigned int frame_size; 1350 unsigned int frame_size;
@@ -1553,7 +1372,7 @@ static int iwl4965_send_beacon_cmd(struct iwl4965_priv *priv)
1553 1372
1554 frame_size = iwl4965_hw_get_beacon_cmd(priv, frame, rate); 1373 frame_size = iwl4965_hw_get_beacon_cmd(priv, frame, rate);
1555 1374
1556 rc = iwl4965_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, 1375 rc = iwl_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size,
1557 &frame->u.cmd[0]); 1376 &frame->u.cmd[0]);
1558 1377
1559 iwl4965_free_frame(priv, frame); 1378 iwl4965_free_frame(priv, frame);
@@ -1567,7 +1386,7 @@ static int iwl4965_send_beacon_cmd(struct iwl4965_priv *priv)
1567 * 1386 *
1568 ******************************************************************************/ 1387 ******************************************************************************/
1569 1388
1570static void iwl4965_unset_hw_setting(struct iwl4965_priv *priv) 1389static void iwl4965_unset_hw_setting(struct iwl_priv *priv)
1571{ 1390{
1572 if (priv->hw_setting.shared_virt) 1391 if (priv->hw_setting.shared_virt)
1573 pci_free_consistent(priv->pci_dev, 1392 pci_free_consistent(priv->pci_dev,
@@ -1608,7 +1427,7 @@ static u16 iwl4965_supported_rate_to_ie(u8 *ie, u16 supported_rate,
1608/** 1427/**
1609 * iwl4965_fill_probe_req - fill in all required fields and IE for probe request 1428 * iwl4965_fill_probe_req - fill in all required fields and IE for probe request
1610 */ 1429 */
1611static u16 iwl4965_fill_probe_req(struct iwl4965_priv *priv, 1430static u16 iwl4965_fill_probe_req(struct iwl_priv *priv,
1612 enum ieee80211_band band, 1431 enum ieee80211_band band,
1613 struct ieee80211_mgmt *frame, 1432 struct ieee80211_mgmt *frame,
1614 int left, int is_direct) 1433 int left, int is_direct)
@@ -1726,102 +1545,15 @@ static u16 iwl4965_fill_probe_req(struct iwl4965_priv *priv,
1726/* 1545/*
1727 * QoS support 1546 * QoS support
1728*/ 1547*/
1729static int iwl4965_send_qos_params_command(struct iwl4965_priv *priv, 1548static int iwl4965_send_qos_params_command(struct iwl_priv *priv,
1730 struct iwl4965_qosparam_cmd *qos) 1549 struct iwl4965_qosparam_cmd *qos)
1731{ 1550{
1732 1551
1733 return iwl4965_send_cmd_pdu(priv, REPLY_QOS_PARAM, 1552 return iwl_send_cmd_pdu(priv, REPLY_QOS_PARAM,
1734 sizeof(struct iwl4965_qosparam_cmd), qos); 1553 sizeof(struct iwl4965_qosparam_cmd), qos);
1735} 1554}
1736 1555
1737static void iwl4965_reset_qos(struct iwl4965_priv *priv) 1556static void iwl4965_activate_qos(struct iwl_priv *priv, u8 force)
1738{
1739 u16 cw_min = 15;
1740 u16 cw_max = 1023;
1741 u8 aifs = 2;
1742 u8 is_legacy = 0;
1743 unsigned long flags;
1744 int i;
1745
1746 spin_lock_irqsave(&priv->lock, flags);
1747 priv->qos_data.qos_active = 0;
1748
1749 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) {
1750 if (priv->qos_data.qos_enable)
1751 priv->qos_data.qos_active = 1;
1752 if (!(priv->active_rate & 0xfff0)) {
1753 cw_min = 31;
1754 is_legacy = 1;
1755 }
1756 } else if (priv->iw_mode == IEEE80211_IF_TYPE_AP) {
1757 if (priv->qos_data.qos_enable)
1758 priv->qos_data.qos_active = 1;
1759 } else if (!(priv->staging_rxon.flags & RXON_FLG_SHORT_SLOT_MSK)) {
1760 cw_min = 31;
1761 is_legacy = 1;
1762 }
1763
1764 if (priv->qos_data.qos_active)
1765 aifs = 3;
1766
1767 priv->qos_data.def_qos_parm.ac[0].cw_min = cpu_to_le16(cw_min);
1768 priv->qos_data.def_qos_parm.ac[0].cw_max = cpu_to_le16(cw_max);
1769 priv->qos_data.def_qos_parm.ac[0].aifsn = aifs;
1770 priv->qos_data.def_qos_parm.ac[0].edca_txop = 0;
1771 priv->qos_data.def_qos_parm.ac[0].reserved1 = 0;
1772
1773 if (priv->qos_data.qos_active) {
1774 i = 1;
1775 priv->qos_data.def_qos_parm.ac[i].cw_min = cpu_to_le16(cw_min);
1776 priv->qos_data.def_qos_parm.ac[i].cw_max = cpu_to_le16(cw_max);
1777 priv->qos_data.def_qos_parm.ac[i].aifsn = 7;
1778 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
1779 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
1780
1781 i = 2;
1782 priv->qos_data.def_qos_parm.ac[i].cw_min =
1783 cpu_to_le16((cw_min + 1) / 2 - 1);
1784 priv->qos_data.def_qos_parm.ac[i].cw_max =
1785 cpu_to_le16(cw_max);
1786 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
1787 if (is_legacy)
1788 priv->qos_data.def_qos_parm.ac[i].edca_txop =
1789 cpu_to_le16(6016);
1790 else
1791 priv->qos_data.def_qos_parm.ac[i].edca_txop =
1792 cpu_to_le16(3008);
1793 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
1794
1795 i = 3;
1796 priv->qos_data.def_qos_parm.ac[i].cw_min =
1797 cpu_to_le16((cw_min + 1) / 4 - 1);
1798 priv->qos_data.def_qos_parm.ac[i].cw_max =
1799 cpu_to_le16((cw_max + 1) / 2 - 1);
1800 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
1801 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
1802 if (is_legacy)
1803 priv->qos_data.def_qos_parm.ac[i].edca_txop =
1804 cpu_to_le16(3264);
1805 else
1806 priv->qos_data.def_qos_parm.ac[i].edca_txop =
1807 cpu_to_le16(1504);
1808 } else {
1809 for (i = 1; i < 4; i++) {
1810 priv->qos_data.def_qos_parm.ac[i].cw_min =
1811 cpu_to_le16(cw_min);
1812 priv->qos_data.def_qos_parm.ac[i].cw_max =
1813 cpu_to_le16(cw_max);
1814 priv->qos_data.def_qos_parm.ac[i].aifsn = aifs;
1815 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
1816 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
1817 }
1818 }
1819 IWL_DEBUG_QOS("set QoS to default \n");
1820
1821 spin_unlock_irqrestore(&priv->lock, flags);
1822}
1823
1824static void iwl4965_activate_qos(struct iwl4965_priv *priv, u8 force)
1825{ 1557{
1826 unsigned long flags; 1558 unsigned long flags;
1827 1559
@@ -1899,7 +1631,7 @@ static struct iwl4965_power_vec_entry range_1[IWL_POWER_AC] = {
1899 SLP_VEC(4, 7, 10, 10, 0xFF)}, 0} 1631 SLP_VEC(4, 7, 10, 10, 0xFF)}, 0}
1900}; 1632};
1901 1633
1902int iwl4965_power_init_handle(struct iwl4965_priv *priv) 1634int iwl4965_power_init_handle(struct iwl_priv *priv)
1903{ 1635{
1904 int rc = 0, i; 1636 int rc = 0, i;
1905 struct iwl4965_power_mgr *pow_data; 1637 struct iwl4965_power_mgr *pow_data;
@@ -1938,7 +1670,7 @@ int iwl4965_power_init_handle(struct iwl4965_priv *priv)
1938 return rc; 1670 return rc;
1939} 1671}
1940 1672
1941static int iwl4965_update_power_cmd(struct iwl4965_priv *priv, 1673static int iwl4965_update_power_cmd(struct iwl_priv *priv,
1942 struct iwl4965_powertable_cmd *cmd, u32 mode) 1674 struct iwl4965_powertable_cmd *cmd, u32 mode)
1943{ 1675{
1944 int rc = 0, i; 1676 int rc = 0, i;
@@ -2002,7 +1734,7 @@ static int iwl4965_update_power_cmd(struct iwl4965_priv *priv,
2002 return rc; 1734 return rc;
2003} 1735}
2004 1736
2005static int iwl4965_send_power_mode(struct iwl4965_priv *priv, u32 mode) 1737static int iwl4965_send_power_mode(struct iwl_priv *priv, u32 mode)
2006{ 1738{
2007 u32 uninitialized_var(final_mode); 1739 u32 uninitialized_var(final_mode);
2008 int rc; 1740 int rc;
@@ -2027,7 +1759,7 @@ static int iwl4965_send_power_mode(struct iwl4965_priv *priv, u32 mode)
2027 1759
2028 iwl4965_update_power_cmd(priv, &cmd, final_mode); 1760 iwl4965_update_power_cmd(priv, &cmd, final_mode);
2029 1761
2030 rc = iwl4965_send_cmd_pdu(priv, POWER_TABLE_CMD, sizeof(cmd), &cmd); 1762 rc = iwl_send_cmd_pdu(priv, POWER_TABLE_CMD, sizeof(cmd), &cmd);
2031 1763
2032 if (final_mode == IWL_POWER_MODE_CAM) 1764 if (final_mode == IWL_POWER_MODE_CAM)
2033 clear_bit(STATUS_POWER_PMI, &priv->status); 1765 clear_bit(STATUS_POWER_PMI, &priv->status);
@@ -2037,7 +1769,7 @@ static int iwl4965_send_power_mode(struct iwl4965_priv *priv, u32 mode)
2037 return rc; 1769 return rc;
2038} 1770}
2039 1771
2040int iwl4965_is_network_packet(struct iwl4965_priv *priv, struct ieee80211_hdr *header) 1772int iwl4965_is_network_packet(struct iwl_priv *priv, struct ieee80211_hdr *header)
2041{ 1773{
2042 /* Filter incoming packets to determine if they are targeted toward 1774 /* Filter incoming packets to determine if they are targeted toward
2043 * this network, discarding packets coming from ourselves */ 1775 * this network, discarding packets coming from ourselves */
@@ -2098,7 +1830,7 @@ static const char *iwl4965_get_tx_fail_reason(u32 status)
2098 * 1830 *
2099 * NOTE: priv->mutex is not required before calling this function 1831 * NOTE: priv->mutex is not required before calling this function
2100 */ 1832 */
2101static int iwl4965_scan_cancel(struct iwl4965_priv *priv) 1833static int iwl4965_scan_cancel(struct iwl_priv *priv)
2102{ 1834{
2103 if (!test_bit(STATUS_SCAN_HW, &priv->status)) { 1835 if (!test_bit(STATUS_SCAN_HW, &priv->status)) {
2104 clear_bit(STATUS_SCANNING, &priv->status); 1836 clear_bit(STATUS_SCANNING, &priv->status);
@@ -2126,7 +1858,7 @@ static int iwl4965_scan_cancel(struct iwl4965_priv *priv)
2126 * 1858 *
2127 * NOTE: priv->mutex must be held before calling this function 1859 * NOTE: priv->mutex must be held before calling this function
2128 */ 1860 */
2129static int iwl4965_scan_cancel_timeout(struct iwl4965_priv *priv, unsigned long ms) 1861static int iwl4965_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms)
2130{ 1862{
2131 unsigned long now = jiffies; 1863 unsigned long now = jiffies;
2132 int ret; 1864 int ret;
@@ -2145,7 +1877,7 @@ static int iwl4965_scan_cancel_timeout(struct iwl4965_priv *priv, unsigned long
2145 return ret; 1877 return ret;
2146} 1878}
2147 1879
2148static void iwl4965_sequence_reset(struct iwl4965_priv *priv) 1880static void iwl4965_sequence_reset(struct iwl_priv *priv)
2149{ 1881{
2150 /* Reset ieee stats */ 1882 /* Reset ieee stats */
2151 1883
@@ -2175,7 +1907,7 @@ static __le16 iwl4965_adjust_beacon_interval(u16 beacon_val)
2175 return cpu_to_le16(new_val); 1907 return cpu_to_le16(new_val);
2176} 1908}
2177 1909
2178static void iwl4965_setup_rxon_timing(struct iwl4965_priv *priv) 1910static void iwl4965_setup_rxon_timing(struct iwl_priv *priv)
2179{ 1911{
2180 u64 interval_tm_unit; 1912 u64 interval_tm_unit;
2181 u64 tsf, result; 1913 u64 tsf, result;
@@ -2231,7 +1963,7 @@ static void iwl4965_setup_rxon_timing(struct iwl4965_priv *priv)
2231 le16_to_cpu(priv->rxon_timing.atim_window)); 1963 le16_to_cpu(priv->rxon_timing.atim_window));
2232} 1964}
2233 1965
2234static int iwl4965_scan_initiate(struct iwl4965_priv *priv) 1966static int iwl4965_scan_initiate(struct iwl_priv *priv)
2235{ 1967{
2236 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 1968 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) {
2237 IWL_ERROR("APs don't scan.\n"); 1969 IWL_ERROR("APs don't scan.\n");
@@ -2265,19 +1997,8 @@ static int iwl4965_scan_initiate(struct iwl4965_priv *priv)
2265 return 0; 1997 return 0;
2266} 1998}
2267 1999
2268static int iwl4965_set_rxon_hwcrypto(struct iwl4965_priv *priv, int hw_decrypt)
2269{
2270 struct iwl4965_rxon_cmd *rxon = &priv->staging_rxon;
2271 2000
2272 if (hw_decrypt) 2001static void iwl4965_set_flags_for_phymode(struct iwl_priv *priv,
2273 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK;
2274 else
2275 rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK;
2276
2277 return 0;
2278}
2279
2280static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv,
2281 enum ieee80211_band band) 2002 enum ieee80211_band band)
2282{ 2003{
2283 if (band == IEEE80211_BAND_5GHZ) { 2004 if (band == IEEE80211_BAND_5GHZ) {
@@ -2304,9 +2025,9 @@ static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv,
2304/* 2025/*
2305 * initialize rxon structure with default values from eeprom 2026 * initialize rxon structure with default values from eeprom
2306 */ 2027 */
2307static void iwl4965_connection_init_rx_config(struct iwl4965_priv *priv) 2028static void iwl4965_connection_init_rx_config(struct iwl_priv *priv)
2308{ 2029{
2309 const struct iwl4965_channel_info *ch_info; 2030 const struct iwl_channel_info *ch_info;
2310 2031
2311 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon)); 2032 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
2312 2033
@@ -2343,7 +2064,7 @@ static void iwl4965_connection_init_rx_config(struct iwl4965_priv *priv)
2343 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 2064 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
2344#endif 2065#endif
2345 2066
2346 ch_info = iwl4965_get_channel_info(priv, priv->band, 2067 ch_info = iwl_get_channel_info(priv, priv->band,
2347 le16_to_cpu(priv->staging_rxon.channel)); 2068 le16_to_cpu(priv->staging_rxon.channel));
2348 2069
2349 if (!ch_info) 2070 if (!ch_info)
@@ -2376,12 +2097,12 @@ static void iwl4965_connection_init_rx_config(struct iwl4965_priv *priv)
2376 iwl4965_set_rxon_chain(priv); 2097 iwl4965_set_rxon_chain(priv);
2377} 2098}
2378 2099
2379static int iwl4965_set_mode(struct iwl4965_priv *priv, int mode) 2100static int iwl4965_set_mode(struct iwl_priv *priv, int mode)
2380{ 2101{
2381 if (mode == IEEE80211_IF_TYPE_IBSS) { 2102 if (mode == IEEE80211_IF_TYPE_IBSS) {
2382 const struct iwl4965_channel_info *ch_info; 2103 const struct iwl_channel_info *ch_info;
2383 2104
2384 ch_info = iwl4965_get_channel_info(priv, 2105 ch_info = iwl_get_channel_info(priv,
2385 priv->band, 2106 priv->band,
2386 le16_to_cpu(priv->staging_rxon.channel)); 2107 le16_to_cpu(priv->staging_rxon.channel));
2387 2108
@@ -2397,7 +2118,7 @@ static int iwl4965_set_mode(struct iwl4965_priv *priv, int mode)
2397 iwl4965_connection_init_rx_config(priv); 2118 iwl4965_connection_init_rx_config(priv);
2398 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 2119 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
2399 2120
2400 iwl4965_clear_stations_table(priv); 2121 iwlcore_clear_stations_table(priv);
2401 2122
2402 /* dont commit rxon if rf-kill is on*/ 2123 /* dont commit rxon if rf-kill is on*/
2403 if (!iwl4965_is_ready_rf(priv)) 2124 if (!iwl4965_is_ready_rf(priv))
@@ -2415,31 +2136,28 @@ static int iwl4965_set_mode(struct iwl4965_priv *priv, int mode)
2415 return 0; 2136 return 0;
2416} 2137}
2417 2138
2418static void iwl4965_build_tx_cmd_hwcrypto(struct iwl4965_priv *priv, 2139static void iwl4965_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
2419 struct ieee80211_tx_control *ctl, 2140 struct ieee80211_tx_control *ctl,
2420 struct iwl4965_cmd *cmd, 2141 struct iwl_cmd *cmd,
2421 struct sk_buff *skb_frag, 2142 struct sk_buff *skb_frag,
2422 int last_frag) 2143 int sta_id)
2423{ 2144{
2424 struct iwl4965_hw_key *keyinfo = &priv->stations[ctl->key_idx].keyinfo; 2145 struct iwl4965_hw_key *keyinfo = &priv->stations[sta_id].keyinfo;
2425 2146
2426 switch (keyinfo->alg) { 2147 switch (keyinfo->alg) {
2427 case ALG_CCMP: 2148 case ALG_CCMP:
2428 cmd->cmd.tx.sec_ctl = TX_CMD_SEC_CCM; 2149 cmd->cmd.tx.sec_ctl = TX_CMD_SEC_CCM;
2429 memcpy(cmd->cmd.tx.key, keyinfo->key, keyinfo->keylen); 2150 memcpy(cmd->cmd.tx.key, keyinfo->key, keyinfo->keylen);
2151 if (ctl->flags & IEEE80211_TXCTL_AMPDU)
2152 cmd->cmd.tx.tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK;
2430 IWL_DEBUG_TX("tx_cmd with aes hwcrypto\n"); 2153 IWL_DEBUG_TX("tx_cmd with aes hwcrypto\n");
2431 break; 2154 break;
2432 2155
2433 case ALG_TKIP: 2156 case ALG_TKIP:
2434#if 0
2435 cmd->cmd.tx.sec_ctl = TX_CMD_SEC_TKIP; 2157 cmd->cmd.tx.sec_ctl = TX_CMD_SEC_TKIP;
2436 2158 ieee80211_get_tkip_key(keyinfo->conf, skb_frag,
2437 if (last_frag) 2159 IEEE80211_TKIP_P2_KEY, cmd->cmd.tx.key);
2438 memcpy(cmd->cmd.tx.tkip_mic.byte, skb_frag->tail - 8, 2160 IWL_DEBUG_TX("tx_cmd with tkip hwcrypto\n");
2439 8);
2440 else
2441 memset(cmd->cmd.tx.tkip_mic.byte, 0, 8);
2442#endif
2443 break; 2161 break;
2444 2162
2445 case ALG_WEP: 2163 case ALG_WEP:
@@ -2464,8 +2182,8 @@ static void iwl4965_build_tx_cmd_hwcrypto(struct iwl4965_priv *priv,
2464/* 2182/*
2465 * handle build REPLY_TX command notification. 2183 * handle build REPLY_TX command notification.
2466 */ 2184 */
2467static void iwl4965_build_tx_cmd_basic(struct iwl4965_priv *priv, 2185static void iwl4965_build_tx_cmd_basic(struct iwl_priv *priv,
2468 struct iwl4965_cmd *cmd, 2186 struct iwl_cmd *cmd,
2469 struct ieee80211_tx_control *ctrl, 2187 struct ieee80211_tx_control *ctrl,
2470 struct ieee80211_hdr *hdr, 2188 struct ieee80211_hdr *hdr,
2471 int is_unicast, u8 std_id) 2189 int is_unicast, u8 std_id)
@@ -2527,13 +2245,19 @@ static void iwl4965_build_tx_cmd_basic(struct iwl4965_priv *priv,
2527 cmd->cmd.tx.tx_flags = tx_flags; 2245 cmd->cmd.tx.tx_flags = tx_flags;
2528 cmd->cmd.tx.next_frame_len = 0; 2246 cmd->cmd.tx.next_frame_len = 0;
2529} 2247}
2530 2248static void iwl_update_tx_stats(struct iwl_priv *priv, u16 fc, u16 len)
2249{
2250 /* 0 - mgmt, 1 - cnt, 2 - data */
2251 int idx = (fc & IEEE80211_FCTL_FTYPE) >> 2;
2252 priv->tx_stats[idx].cnt++;
2253 priv->tx_stats[idx].bytes += len;
2254}
2531/** 2255/**
2532 * iwl4965_get_sta_id - Find station's index within station table 2256 * iwl4965_get_sta_id - Find station's index within station table
2533 * 2257 *
2534 * If new IBSS station, create new entry in station table 2258 * If new IBSS station, create new entry in station table
2535 */ 2259 */
2536static int iwl4965_get_sta_id(struct iwl4965_priv *priv, 2260static int iwl4965_get_sta_id(struct iwl_priv *priv,
2537 struct ieee80211_hdr *hdr) 2261 struct ieee80211_hdr *hdr)
2538{ 2262{
2539 int sta_id; 2263 int sta_id;
@@ -2576,7 +2300,7 @@ static int iwl4965_get_sta_id(struct iwl4965_priv *priv,
2576 IWL_DEBUG_DROP("Station %s not in station map. " 2300 IWL_DEBUG_DROP("Station %s not in station map. "
2577 "Defaulting to broadcast...\n", 2301 "Defaulting to broadcast...\n",
2578 print_mac(mac, hdr->addr1)); 2302 print_mac(mac, hdr->addr1));
2579 iwl4965_print_hex_dump(IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); 2303 iwl_print_hex_dump(IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
2580 return priv->hw_setting.bcast_sta_id; 2304 return priv->hw_setting.bcast_sta_id;
2581 2305
2582 default: 2306 default:
@@ -2588,7 +2312,7 @@ static int iwl4965_get_sta_id(struct iwl4965_priv *priv,
2588/* 2312/*
2589 * start REPLY_TX command process 2313 * start REPLY_TX command process
2590 */ 2314 */
2591static int iwl4965_tx_skb(struct iwl4965_priv *priv, 2315static int iwl4965_tx_skb(struct iwl_priv *priv,
2592 struct sk_buff *skb, struct ieee80211_tx_control *ctl) 2316 struct sk_buff *skb, struct ieee80211_tx_control *ctl)
2593{ 2317{
2594 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 2318 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
@@ -2600,7 +2324,7 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
2600 dma_addr_t phys_addr; 2324 dma_addr_t phys_addr;
2601 dma_addr_t txcmd_phys; 2325 dma_addr_t txcmd_phys;
2602 dma_addr_t scratch_phys; 2326 dma_addr_t scratch_phys;
2603 struct iwl4965_cmd *out_cmd = NULL; 2327 struct iwl_cmd *out_cmd = NULL;
2604 u16 len, idx, len_org; 2328 u16 len, idx, len_org;
2605 u8 id, hdr_len, unicast; 2329 u8 id, hdr_len, unicast;
2606 u8 sta_id; 2330 u8 sta_id;
@@ -2632,7 +2356,7 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
2632 2356
2633 fc = le16_to_cpu(hdr->frame_control); 2357 fc = le16_to_cpu(hdr->frame_control);
2634 2358
2635#ifdef CONFIG_IWL4965_DEBUG 2359#ifdef CONFIG_IWLWIFI_DEBUG
2636 if (ieee80211_is_auth(fc)) 2360 if (ieee80211_is_auth(fc))
2637 IWL_DEBUG_TX("Sending AUTH frame\n"); 2361 IWL_DEBUG_TX("Sending AUTH frame\n");
2638 else if (ieee80211_is_assoc_request(fc)) 2362 else if (ieee80211_is_assoc_request(fc))
@@ -2729,7 +2453,7 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
2729 * We'll tell device about this padding later. 2453 * We'll tell device about this padding later.
2730 */ 2454 */
2731 len = priv->hw_setting.tx_cmd_len + 2455 len = priv->hw_setting.tx_cmd_len +
2732 sizeof(struct iwl4965_cmd_header) + hdr_len; 2456 sizeof(struct iwl_cmd_header) + hdr_len;
2733 2457
2734 len_org = len; 2458 len_org = len;
2735 len = (len + 3) & ~3; 2459 len = (len + 3) & ~3;
@@ -2741,15 +2465,15 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
2741 2465
2742 /* Physical address of this Tx command's header (not MAC header!), 2466 /* Physical address of this Tx command's header (not MAC header!),
2743 * within command buffer array. */ 2467 * within command buffer array. */
2744 txcmd_phys = txq->dma_addr_cmd + sizeof(struct iwl4965_cmd) * idx + 2468 txcmd_phys = txq->dma_addr_cmd + sizeof(struct iwl_cmd) * idx +
2745 offsetof(struct iwl4965_cmd, hdr); 2469 offsetof(struct iwl_cmd, hdr);
2746 2470
2747 /* Add buffer containing Tx command and MAC(!) header to TFD's 2471 /* Add buffer containing Tx command and MAC(!) header to TFD's
2748 * first entry */ 2472 * first entry */
2749 iwl4965_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len); 2473 iwl4965_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len);
2750 2474
2751 if (!(ctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) 2475 if (!(ctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT))
2752 iwl4965_build_tx_cmd_hwcrypto(priv, ctl, out_cmd, skb, 0); 2476 iwl4965_build_tx_cmd_hwcrypto(priv, ctl, out_cmd, skb, sta_id);
2753 2477
2754 /* Set up TFD's 2nd entry to point directly to remainder of skb, 2478 /* Set up TFD's 2nd entry to point directly to remainder of skb,
2755 * if any (802.11 null frames have no payload). */ 2479 * if any (802.11 null frames have no payload). */
@@ -2774,7 +2498,9 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
2774 /* set is_hcca to 0; it probably will never be implemented */ 2498 /* set is_hcca to 0; it probably will never be implemented */
2775 iwl4965_hw_build_tx_cmd_rate(priv, out_cmd, ctl, hdr, sta_id, 0); 2499 iwl4965_hw_build_tx_cmd_rate(priv, out_cmd, ctl, hdr, sta_id, 0);
2776 2500
2777 scratch_phys = txcmd_phys + sizeof(struct iwl4965_cmd_header) + 2501 iwl_update_tx_stats(priv, fc, len);
2502
2503 scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) +
2778 offsetof(struct iwl4965_tx_cmd, scratch); 2504 offsetof(struct iwl4965_tx_cmd, scratch);
2779 out_cmd->cmd.tx.dram_lsb_ptr = cpu_to_le32(scratch_phys); 2505 out_cmd->cmd.tx.dram_lsb_ptr = cpu_to_le32(scratch_phys);
2780 out_cmd->cmd.tx.dram_msb_ptr = iwl_get_dma_hi_address(scratch_phys); 2506 out_cmd->cmd.tx.dram_msb_ptr = iwl_get_dma_hi_address(scratch_phys);
@@ -2790,10 +2516,10 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
2790 txq->need_update = 0; 2516 txq->need_update = 0;
2791 } 2517 }
2792 2518
2793 iwl4965_print_hex_dump(IWL_DL_TX, out_cmd->cmd.payload, 2519 iwl_print_hex_dump(IWL_DL_TX, out_cmd->cmd.payload,
2794 sizeof(out_cmd->cmd.tx)); 2520 sizeof(out_cmd->cmd.tx));
2795 2521
2796 iwl4965_print_hex_dump(IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr, 2522 iwl_print_hex_dump(IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr,
2797 ieee80211_get_hdrlen(fc)); 2523 ieee80211_get_hdrlen(fc));
2798 2524
2799 /* Set up entry for this TFD in Tx byte-count array */ 2525 /* Set up entry for this TFD in Tx byte-count array */
@@ -2827,7 +2553,7 @@ drop:
2827 return -1; 2553 return -1;
2828} 2554}
2829 2555
2830static void iwl4965_set_rate(struct iwl4965_priv *priv) 2556static void iwl4965_set_rate(struct iwl_priv *priv)
2831{ 2557{
2832 const struct ieee80211_supported_band *hw = NULL; 2558 const struct ieee80211_supported_band *hw = NULL;
2833 struct ieee80211_rate *rate; 2559 struct ieee80211_rate *rate;
@@ -2874,7 +2600,7 @@ static void iwl4965_set_rate(struct iwl4965_priv *priv)
2874 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; 2600 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
2875} 2601}
2876 2602
2877static void iwl4965_radio_kill_sw(struct iwl4965_priv *priv, int disable_radio) 2603static void iwl4965_radio_kill_sw(struct iwl_priv *priv, int disable_radio)
2878{ 2604{
2879 unsigned long flags; 2605 unsigned long flags;
2880 2606
@@ -2923,7 +2649,7 @@ static void iwl4965_radio_kill_sw(struct iwl4965_priv *priv, int disable_radio)
2923 return; 2649 return;
2924} 2650}
2925 2651
2926void iwl4965_set_decrypted_flag(struct iwl4965_priv *priv, struct sk_buff *skb, 2652void iwl4965_set_decrypted_flag(struct iwl_priv *priv, struct sk_buff *skb,
2927 u32 decrypt_res, struct ieee80211_rx_status *stats) 2653 u32 decrypt_res, struct ieee80211_rx_status *stats)
2928{ 2654{
2929 u16 fc = 2655 u16 fc =
@@ -2938,6 +2664,12 @@ void iwl4965_set_decrypted_flag(struct iwl4965_priv *priv, struct sk_buff *skb,
2938 IWL_DEBUG_RX("decrypt_res:0x%x\n", decrypt_res); 2664 IWL_DEBUG_RX("decrypt_res:0x%x\n", decrypt_res);
2939 switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { 2665 switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) {
2940 case RX_RES_STATUS_SEC_TYPE_TKIP: 2666 case RX_RES_STATUS_SEC_TYPE_TKIP:
2667 /* The uCode has got a bad phase 1 Key, pushes the packet.
2668 * Decryption will be done in SW. */
2669 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
2670 RX_RES_STATUS_BAD_KEY_TTAK)
2671 break;
2672
2941 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == 2673 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
2942 RX_RES_STATUS_BAD_ICV_MIC) 2674 RX_RES_STATUS_BAD_ICV_MIC)
2943 stats->flag |= RX_FLAG_MMIC_ERROR; 2675 stats->flag |= RX_FLAG_MMIC_ERROR;
@@ -2958,7 +2690,7 @@ void iwl4965_set_decrypted_flag(struct iwl4965_priv *priv, struct sk_buff *skb,
2958 2690
2959#define IWL_PACKET_RETRY_TIME HZ 2691#define IWL_PACKET_RETRY_TIME HZ
2960 2692
2961int iwl4965_is_duplicate_packet(struct iwl4965_priv *priv, struct ieee80211_hdr *header) 2693int iwl4965_is_duplicate_packet(struct iwl_priv *priv, struct ieee80211_hdr *header)
2962{ 2694{
2963 u16 sc = le16_to_cpu(header->seq_ctrl); 2695 u16 sc = le16_to_cpu(header->seq_ctrl);
2964 u16 seq = (sc & IEEE80211_SCTL_SEQ) >> 4; 2696 u16 seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
@@ -3075,13 +2807,13 @@ static __le32 iwl4965_add_beacon_time(u32 base, u32 addon, u32 beacon_interval)
3075 return cpu_to_le32(res); 2807 return cpu_to_le32(res);
3076} 2808}
3077 2809
3078static int iwl4965_get_measurement(struct iwl4965_priv *priv, 2810static int iwl4965_get_measurement(struct iwl_priv *priv,
3079 struct ieee80211_measurement_params *params, 2811 struct ieee80211_measurement_params *params,
3080 u8 type) 2812 u8 type)
3081{ 2813{
3082 struct iwl4965_spectrum_cmd spectrum; 2814 struct iwl4965_spectrum_cmd spectrum;
3083 struct iwl4965_rx_packet *res; 2815 struct iwl4965_rx_packet *res;
3084 struct iwl4965_host_cmd cmd = { 2816 struct iwl_host_cmd cmd = {
3085 .id = REPLY_SPECTRUM_MEASUREMENT_CMD, 2817 .id = REPLY_SPECTRUM_MEASUREMENT_CMD,
3086 .data = (void *)&spectrum, 2818 .data = (void *)&spectrum,
3087 .meta.flags = CMD_WANT_SKB, 2819 .meta.flags = CMD_WANT_SKB,
@@ -3121,7 +2853,7 @@ static int iwl4965_get_measurement(struct iwl4965_priv *priv,
3121 spectrum.flags |= RXON_FLG_BAND_24G_MSK | 2853 spectrum.flags |= RXON_FLG_BAND_24G_MSK |
3122 RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; 2854 RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK;
3123 2855
3124 rc = iwl4965_send_cmd_sync(priv, &cmd); 2856 rc = iwl_send_cmd_sync(priv, &cmd);
3125 if (rc) 2857 if (rc)
3126 return rc; 2858 return rc;
3127 2859
@@ -3155,7 +2887,7 @@ static int iwl4965_get_measurement(struct iwl4965_priv *priv,
3155} 2887}
3156#endif 2888#endif
3157 2889
3158static void iwl4965_txstatus_to_ieee(struct iwl4965_priv *priv, 2890static void iwl4965_txstatus_to_ieee(struct iwl_priv *priv,
3159 struct iwl4965_tx_info *tx_sta) 2891 struct iwl4965_tx_info *tx_sta)
3160{ 2892{
3161 2893
@@ -3181,7 +2913,7 @@ static void iwl4965_txstatus_to_ieee(struct iwl4965_priv *priv,
3181 * need to be reclaimed. As result, some free space forms. If there is 2913 * need to be reclaimed. As result, some free space forms. If there is
3182 * enough free space (> low mark), wake the stack that feeds us. 2914 * enough free space (> low mark), wake the stack that feeds us.
3183 */ 2915 */
3184int iwl4965_tx_queue_reclaim(struct iwl4965_priv *priv, int txq_id, int index) 2916int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
3185{ 2917{
3186 struct iwl4965_tx_queue *txq = &priv->txq[txq_id]; 2918 struct iwl4965_tx_queue *txq = &priv->txq[txq_id];
3187 struct iwl4965_queue *q = &txq->q; 2919 struct iwl4965_queue *q = &txq->q;
@@ -3232,7 +2964,7 @@ static int iwl4965_is_tx_success(u32 status)
3232 ******************************************************************************/ 2964 ******************************************************************************/
3233#ifdef CONFIG_IWL4965_HT 2965#ifdef CONFIG_IWL4965_HT
3234 2966
3235static inline int iwl4965_get_ra_sta_id(struct iwl4965_priv *priv, 2967static inline int iwl4965_get_ra_sta_id(struct iwl_priv *priv,
3236 struct ieee80211_hdr *hdr) 2968 struct ieee80211_hdr *hdr)
3237{ 2969{
3238 if (priv->iw_mode == IEEE80211_IF_TYPE_STA) 2970 if (priv->iw_mode == IEEE80211_IF_TYPE_STA)
@@ -3244,7 +2976,7 @@ static inline int iwl4965_get_ra_sta_id(struct iwl4965_priv *priv,
3244} 2976}
3245 2977
3246static struct ieee80211_hdr *iwl4965_tx_queue_get_hdr( 2978static struct ieee80211_hdr *iwl4965_tx_queue_get_hdr(
3247 struct iwl4965_priv *priv, int txq_id, int idx) 2979 struct iwl_priv *priv, int txq_id, int idx)
3248{ 2980{
3249 if (priv->txq[txq_id].txb[idx].skb[0]) 2981 if (priv->txq[txq_id].txb[idx].skb[0])
3250 return (struct ieee80211_hdr *)priv->txq[txq_id]. 2982 return (struct ieee80211_hdr *)priv->txq[txq_id].
@@ -3263,7 +2995,7 @@ static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp)
3263/** 2995/**
3264 * iwl4965_tx_status_reply_tx - Handle Tx rspnse for frames in aggregation queue 2996 * iwl4965_tx_status_reply_tx - Handle Tx rspnse for frames in aggregation queue
3265 */ 2997 */
3266static int iwl4965_tx_status_reply_tx(struct iwl4965_priv *priv, 2998static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
3267 struct iwl4965_ht_agg *agg, 2999 struct iwl4965_ht_agg *agg,
3268 struct iwl4965_tx_resp_agg *tx_resp, 3000 struct iwl4965_tx_resp_agg *tx_resp,
3269 u16 start_idx) 3001 u16 start_idx)
@@ -3384,7 +3116,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl4965_priv *priv,
3384/** 3116/**
3385 * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response 3117 * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response
3386 */ 3118 */
3387static void iwl4965_rx_reply_tx(struct iwl4965_priv *priv, 3119static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
3388 struct iwl4965_rx_mem_buffer *rxb) 3120 struct iwl4965_rx_mem_buffer *rxb)
3389{ 3121{
3390 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3122 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
@@ -3495,7 +3227,7 @@ static void iwl4965_rx_reply_tx(struct iwl4965_priv *priv,
3495} 3227}
3496 3228
3497 3229
3498static void iwl4965_rx_reply_alive(struct iwl4965_priv *priv, 3230static void iwl4965_rx_reply_alive(struct iwl_priv *priv,
3499 struct iwl4965_rx_mem_buffer *rxb) 3231 struct iwl4965_rx_mem_buffer *rxb)
3500{ 3232{
3501 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3233 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
@@ -3531,7 +3263,7 @@ static void iwl4965_rx_reply_alive(struct iwl4965_priv *priv,
3531 IWL_WARNING("uCode did not respond OK.\n"); 3263 IWL_WARNING("uCode did not respond OK.\n");
3532} 3264}
3533 3265
3534static void iwl4965_rx_reply_add_sta(struct iwl4965_priv *priv, 3266static void iwl4965_rx_reply_add_sta(struct iwl_priv *priv,
3535 struct iwl4965_rx_mem_buffer *rxb) 3267 struct iwl4965_rx_mem_buffer *rxb)
3536{ 3268{
3537 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3269 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
@@ -3540,7 +3272,7 @@ static void iwl4965_rx_reply_add_sta(struct iwl4965_priv *priv,
3540 return; 3272 return;
3541} 3273}
3542 3274
3543static void iwl4965_rx_reply_error(struct iwl4965_priv *priv, 3275static void iwl4965_rx_reply_error(struct iwl_priv *priv,
3544 struct iwl4965_rx_mem_buffer *rxb) 3276 struct iwl4965_rx_mem_buffer *rxb)
3545{ 3277{
3546 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3278 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
@@ -3556,7 +3288,7 @@ static void iwl4965_rx_reply_error(struct iwl4965_priv *priv,
3556 3288
3557#define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x 3289#define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x
3558 3290
3559static void iwl4965_rx_csa(struct iwl4965_priv *priv, struct iwl4965_rx_mem_buffer *rxb) 3291static void iwl4965_rx_csa(struct iwl_priv *priv, struct iwl4965_rx_mem_buffer *rxb)
3560{ 3292{
3561 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3293 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
3562 struct iwl4965_rxon_cmd *rxon = (void *)&priv->active_rxon; 3294 struct iwl4965_rxon_cmd *rxon = (void *)&priv->active_rxon;
@@ -3567,7 +3299,7 @@ static void iwl4965_rx_csa(struct iwl4965_priv *priv, struct iwl4965_rx_mem_buff
3567 priv->staging_rxon.channel = csa->channel; 3299 priv->staging_rxon.channel = csa->channel;
3568} 3300}
3569 3301
3570static void iwl4965_rx_spectrum_measure_notif(struct iwl4965_priv *priv, 3302static void iwl4965_rx_spectrum_measure_notif(struct iwl_priv *priv,
3571 struct iwl4965_rx_mem_buffer *rxb) 3303 struct iwl4965_rx_mem_buffer *rxb)
3572{ 3304{
3573#ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT 3305#ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
@@ -3585,10 +3317,10 @@ static void iwl4965_rx_spectrum_measure_notif(struct iwl4965_priv *priv,
3585#endif 3317#endif
3586} 3318}
3587 3319
3588static void iwl4965_rx_pm_sleep_notif(struct iwl4965_priv *priv, 3320static void iwl4965_rx_pm_sleep_notif(struct iwl_priv *priv,
3589 struct iwl4965_rx_mem_buffer *rxb) 3321 struct iwl4965_rx_mem_buffer *rxb)
3590{ 3322{
3591#ifdef CONFIG_IWL4965_DEBUG 3323#ifdef CONFIG_IWLWIFI_DEBUG
3592 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3324 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
3593 struct iwl4965_sleep_notification *sleep = &(pkt->u.sleep_notif); 3325 struct iwl4965_sleep_notification *sleep = &(pkt->u.sleep_notif);
3594 IWL_DEBUG_RX("sleep mode: %d, src: %d\n", 3326 IWL_DEBUG_RX("sleep mode: %d, src: %d\n",
@@ -3596,20 +3328,20 @@ static void iwl4965_rx_pm_sleep_notif(struct iwl4965_priv *priv,
3596#endif 3328#endif
3597} 3329}
3598 3330
3599static void iwl4965_rx_pm_debug_statistics_notif(struct iwl4965_priv *priv, 3331static void iwl4965_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
3600 struct iwl4965_rx_mem_buffer *rxb) 3332 struct iwl4965_rx_mem_buffer *rxb)
3601{ 3333{
3602 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3334 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
3603 IWL_DEBUG_RADIO("Dumping %d bytes of unhandled " 3335 IWL_DEBUG_RADIO("Dumping %d bytes of unhandled "
3604 "notification for %s:\n", 3336 "notification for %s:\n",
3605 le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd)); 3337 le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd));
3606 iwl4965_print_hex_dump(IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len)); 3338 iwl_print_hex_dump(IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len));
3607} 3339}
3608 3340
3609static void iwl4965_bg_beacon_update(struct work_struct *work) 3341static void iwl4965_bg_beacon_update(struct work_struct *work)
3610{ 3342{
3611 struct iwl4965_priv *priv = 3343 struct iwl_priv *priv =
3612 container_of(work, struct iwl4965_priv, beacon_update); 3344 container_of(work, struct iwl_priv, beacon_update);
3613 struct sk_buff *beacon; 3345 struct sk_buff *beacon;
3614 3346
3615 /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ 3347 /* Pull updated AP beacon from mac80211. will fail if not in AP mode */
@@ -3631,10 +3363,10 @@ static void iwl4965_bg_beacon_update(struct work_struct *work)
3631 iwl4965_send_beacon_cmd(priv); 3363 iwl4965_send_beacon_cmd(priv);
3632} 3364}
3633 3365
3634static void iwl4965_rx_beacon_notif(struct iwl4965_priv *priv, 3366static void iwl4965_rx_beacon_notif(struct iwl_priv *priv,
3635 struct iwl4965_rx_mem_buffer *rxb) 3367 struct iwl4965_rx_mem_buffer *rxb)
3636{ 3368{
3637#ifdef CONFIG_IWL4965_DEBUG 3369#ifdef CONFIG_IWLWIFI_DEBUG
3638 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3370 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
3639 struct iwl4965_beacon_notif *beacon = &(pkt->u.beacon_status); 3371 struct iwl4965_beacon_notif *beacon = &(pkt->u.beacon_status);
3640 u8 rate = iwl4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); 3372 u8 rate = iwl4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags);
@@ -3654,10 +3386,10 @@ static void iwl4965_rx_beacon_notif(struct iwl4965_priv *priv,
3654} 3386}
3655 3387
3656/* Service response to REPLY_SCAN_CMD (0x80) */ 3388/* Service response to REPLY_SCAN_CMD (0x80) */
3657static void iwl4965_rx_reply_scan(struct iwl4965_priv *priv, 3389static void iwl4965_rx_reply_scan(struct iwl_priv *priv,
3658 struct iwl4965_rx_mem_buffer *rxb) 3390 struct iwl4965_rx_mem_buffer *rxb)
3659{ 3391{
3660#ifdef CONFIG_IWL4965_DEBUG 3392#ifdef CONFIG_IWLWIFI_DEBUG
3661 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3393 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
3662 struct iwl4965_scanreq_notification *notif = 3394 struct iwl4965_scanreq_notification *notif =
3663 (struct iwl4965_scanreq_notification *)pkt->u.raw; 3395 (struct iwl4965_scanreq_notification *)pkt->u.raw;
@@ -3667,7 +3399,7 @@ static void iwl4965_rx_reply_scan(struct iwl4965_priv *priv,
3667} 3399}
3668 3400
3669/* Service SCAN_START_NOTIFICATION (0x82) */ 3401/* Service SCAN_START_NOTIFICATION (0x82) */
3670static void iwl4965_rx_scan_start_notif(struct iwl4965_priv *priv, 3402static void iwl4965_rx_scan_start_notif(struct iwl_priv *priv,
3671 struct iwl4965_rx_mem_buffer *rxb) 3403 struct iwl4965_rx_mem_buffer *rxb)
3672{ 3404{
3673 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3405 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
@@ -3684,7 +3416,7 @@ static void iwl4965_rx_scan_start_notif(struct iwl4965_priv *priv,
3684} 3416}
3685 3417
3686/* Service SCAN_RESULTS_NOTIFICATION (0x83) */ 3418/* Service SCAN_RESULTS_NOTIFICATION (0x83) */
3687static void iwl4965_rx_scan_results_notif(struct iwl4965_priv *priv, 3419static void iwl4965_rx_scan_results_notif(struct iwl_priv *priv,
3688 struct iwl4965_rx_mem_buffer *rxb) 3420 struct iwl4965_rx_mem_buffer *rxb)
3689{ 3421{
3690 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3422 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
@@ -3709,7 +3441,7 @@ static void iwl4965_rx_scan_results_notif(struct iwl4965_priv *priv,
3709} 3441}
3710 3442
3711/* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ 3443/* Service SCAN_COMPLETE_NOTIFICATION (0x84) */
3712static void iwl4965_rx_scan_complete_notif(struct iwl4965_priv *priv, 3444static void iwl4965_rx_scan_complete_notif(struct iwl_priv *priv,
3713 struct iwl4965_rx_mem_buffer *rxb) 3445 struct iwl4965_rx_mem_buffer *rxb)
3714{ 3446{
3715 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3447 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
@@ -3767,7 +3499,7 @@ reschedule:
3767 3499
3768/* Handle notification from uCode that card's power state is changing 3500/* Handle notification from uCode that card's power state is changing
3769 * due to software, hardware, or critical temperature RFKILL */ 3501 * due to software, hardware, or critical temperature RFKILL */
3770static void iwl4965_rx_card_state_notif(struct iwl4965_priv *priv, 3502static void iwl4965_rx_card_state_notif(struct iwl_priv *priv,
3771 struct iwl4965_rx_mem_buffer *rxb) 3503 struct iwl4965_rx_mem_buffer *rxb)
3772{ 3504{
3773 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3505 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
@@ -3845,7 +3577,7 @@ static void iwl4965_rx_card_state_notif(struct iwl4965_priv *priv,
3845 * This function chains into the hardware specific files for them to setup 3577 * This function chains into the hardware specific files for them to setup
3846 * any hardware specific handlers as well. 3578 * any hardware specific handlers as well.
3847 */ 3579 */
3848static void iwl4965_setup_rx_handlers(struct iwl4965_priv *priv) 3580static void iwl4965_setup_rx_handlers(struct iwl_priv *priv)
3849{ 3581{
3850 priv->rx_handlers[REPLY_ALIVE] = iwl4965_rx_reply_alive; 3582 priv->rx_handlers[REPLY_ALIVE] = iwl4965_rx_reply_alive;
3851 priv->rx_handlers[REPLY_ADD_STA] = iwl4965_rx_reply_add_sta; 3583 priv->rx_handlers[REPLY_ADD_STA] = iwl4965_rx_reply_add_sta;
@@ -3887,7 +3619,7 @@ static void iwl4965_setup_rx_handlers(struct iwl4965_priv *priv)
3887 * will be executed. The attached skb (if present) will only be freed 3619 * will be executed. The attached skb (if present) will only be freed
3888 * if the callback returns 1 3620 * if the callback returns 1
3889 */ 3621 */
3890static void iwl4965_tx_cmd_complete(struct iwl4965_priv *priv, 3622static void iwl4965_tx_cmd_complete(struct iwl_priv *priv,
3891 struct iwl4965_rx_mem_buffer *rxb) 3623 struct iwl4965_rx_mem_buffer *rxb)
3892{ 3624{
3893 struct iwl4965_rx_packet *pkt = (struct iwl4965_rx_packet *)rxb->skb->data; 3625 struct iwl4965_rx_packet *pkt = (struct iwl4965_rx_packet *)rxb->skb->data;
@@ -3896,7 +3628,7 @@ static void iwl4965_tx_cmd_complete(struct iwl4965_priv *priv,
3896 int index = SEQ_TO_INDEX(sequence); 3628 int index = SEQ_TO_INDEX(sequence);
3897 int huge = sequence & SEQ_HUGE_FRAME; 3629 int huge = sequence & SEQ_HUGE_FRAME;
3898 int cmd_index; 3630 int cmd_index;
3899 struct iwl4965_cmd *cmd; 3631 struct iwl_cmd *cmd;
3900 3632
3901 /* If a Tx command is being handled and it isn't in the actual 3633 /* If a Tx command is being handled and it isn't in the actual
3902 * command queue then there a command routing bug has been introduced 3634 * command queue then there a command routing bug has been introduced
@@ -4010,7 +3742,7 @@ static int iwl4965_rx_queue_space(const struct iwl4965_rx_queue *q)
4010/** 3742/**
4011 * iwl4965_rx_queue_update_write_ptr - Update the write pointer for the RX queue 3743 * iwl4965_rx_queue_update_write_ptr - Update the write pointer for the RX queue
4012 */ 3744 */
4013int iwl4965_rx_queue_update_write_ptr(struct iwl4965_priv *priv, struct iwl4965_rx_queue *q) 3745int iwl4965_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl4965_rx_queue *q)
4014{ 3746{
4015 u32 reg = 0; 3747 u32 reg = 0;
4016 int rc = 0; 3748 int rc = 0;
@@ -4056,7 +3788,7 @@ int iwl4965_rx_queue_update_write_ptr(struct iwl4965_priv *priv, struct iwl4965_
4056/** 3788/**
4057 * iwl4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr 3789 * iwl4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr
4058 */ 3790 */
4059static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl4965_priv *priv, 3791static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl_priv *priv,
4060 dma_addr_t dma_addr) 3792 dma_addr_t dma_addr)
4061{ 3793{
4062 return cpu_to_le32((u32)(dma_addr >> 8)); 3794 return cpu_to_le32((u32)(dma_addr >> 8));
@@ -4074,7 +3806,7 @@ static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl4965_priv *priv,
4074 * also updates the memory address in the firmware to reference the new 3806 * also updates the memory address in the firmware to reference the new
4075 * target buffer. 3807 * target buffer.
4076 */ 3808 */
4077static int iwl4965_rx_queue_restock(struct iwl4965_priv *priv) 3809static int iwl4965_rx_queue_restock(struct iwl_priv *priv)
4078{ 3810{
4079 struct iwl4965_rx_queue *rxq = &priv->rxq; 3811 struct iwl4965_rx_queue *rxq = &priv->rxq;
4080 struct list_head *element; 3812 struct list_head *element;
@@ -4126,7 +3858,7 @@ static int iwl4965_rx_queue_restock(struct iwl4965_priv *priv)
4126 * Also restock the Rx queue via iwl4965_rx_queue_restock. 3858 * Also restock the Rx queue via iwl4965_rx_queue_restock.
4127 * This is called as a scheduled work item (except for during initialization) 3859 * This is called as a scheduled work item (except for during initialization)
4128 */ 3860 */
4129static void iwl4965_rx_allocate(struct iwl4965_priv *priv) 3861static void iwl4965_rx_allocate(struct iwl_priv *priv)
4130{ 3862{
4131 struct iwl4965_rx_queue *rxq = &priv->rxq; 3863 struct iwl4965_rx_queue *rxq = &priv->rxq;
4132 struct list_head *element; 3864 struct list_head *element;
@@ -4168,7 +3900,7 @@ static void iwl4965_rx_allocate(struct iwl4965_priv *priv)
4168*/ 3900*/
4169static void __iwl4965_rx_replenish(void *data) 3901static void __iwl4965_rx_replenish(void *data)
4170{ 3902{
4171 struct iwl4965_priv *priv = data; 3903 struct iwl_priv *priv = data;
4172 3904
4173 iwl4965_rx_allocate(priv); 3905 iwl4965_rx_allocate(priv);
4174 iwl4965_rx_queue_restock(priv); 3906 iwl4965_rx_queue_restock(priv);
@@ -4177,7 +3909,7 @@ static void __iwl4965_rx_replenish(void *data)
4177 3909
4178void iwl4965_rx_replenish(void *data) 3910void iwl4965_rx_replenish(void *data)
4179{ 3911{
4180 struct iwl4965_priv *priv = data; 3912 struct iwl_priv *priv = data;
4181 unsigned long flags; 3913 unsigned long flags;
4182 3914
4183 iwl4965_rx_allocate(priv); 3915 iwl4965_rx_allocate(priv);
@@ -4192,7 +3924,7 @@ void iwl4965_rx_replenish(void *data)
4192 * This free routine walks the list of POOL entries and if SKB is set to 3924 * This free routine walks the list of POOL entries and if SKB is set to
4193 * non NULL it is unmapped and freed 3925 * non NULL it is unmapped and freed
4194 */ 3926 */
4195static void iwl4965_rx_queue_free(struct iwl4965_priv *priv, struct iwl4965_rx_queue *rxq) 3927static void iwl4965_rx_queue_free(struct iwl_priv *priv, struct iwl4965_rx_queue *rxq)
4196{ 3928{
4197 int i; 3929 int i;
4198 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { 3930 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) {
@@ -4210,7 +3942,7 @@ static void iwl4965_rx_queue_free(struct iwl4965_priv *priv, struct iwl4965_rx_q
4210 rxq->bd = NULL; 3942 rxq->bd = NULL;
4211} 3943}
4212 3944
4213int iwl4965_rx_queue_alloc(struct iwl4965_priv *priv) 3945int iwl4965_rx_queue_alloc(struct iwl_priv *priv)
4214{ 3946{
4215 struct iwl4965_rx_queue *rxq = &priv->rxq; 3947 struct iwl4965_rx_queue *rxq = &priv->rxq;
4216 struct pci_dev *dev = priv->pci_dev; 3948 struct pci_dev *dev = priv->pci_dev;
@@ -4237,7 +3969,7 @@ int iwl4965_rx_queue_alloc(struct iwl4965_priv *priv)
4237 return 0; 3969 return 0;
4238} 3970}
4239 3971
4240void iwl4965_rx_queue_reset(struct iwl4965_priv *priv, struct iwl4965_rx_queue *rxq) 3972void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl4965_rx_queue *rxq)
4241{ 3973{
4242 unsigned long flags; 3974 unsigned long flags;
4243 int i; 3975 int i;
@@ -4352,7 +4084,7 @@ int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm)
4352 * the appropriate handlers, including command responses, 4084 * the appropriate handlers, including command responses,
4353 * frame-received notifications, and other notifications. 4085 * frame-received notifications, and other notifications.
4354 */ 4086 */
4355static void iwl4965_rx_handle(struct iwl4965_priv *priv) 4087static void iwl4965_rx_handle(struct iwl_priv *priv)
4356{ 4088{
4357 struct iwl4965_rx_mem_buffer *rxb; 4089 struct iwl4965_rx_mem_buffer *rxb;
4358 struct iwl4965_rx_packet *pkt; 4090 struct iwl4965_rx_packet *pkt;
@@ -4398,7 +4130,7 @@ static void iwl4965_rx_handle(struct iwl4965_priv *priv)
4398 * but apparently a few don't get set; catch them here. */ 4130 * but apparently a few don't get set; catch them here. */
4399 reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && 4131 reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) &&
4400 (pkt->hdr.cmd != REPLY_RX_PHY_CMD) && 4132 (pkt->hdr.cmd != REPLY_RX_PHY_CMD) &&
4401 (pkt->hdr.cmd != REPLY_4965_RX) && 4133 (pkt->hdr.cmd != REPLY_RX) &&
4402 (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && 4134 (pkt->hdr.cmd != REPLY_COMPRESSED_BA) &&
4403 (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && 4135 (pkt->hdr.cmd != STATISTICS_NOTIFICATION) &&
4404 (pkt->hdr.cmd != REPLY_TX); 4136 (pkt->hdr.cmd != REPLY_TX);
@@ -4421,7 +4153,7 @@ static void iwl4965_rx_handle(struct iwl4965_priv *priv)
4421 4153
4422 if (reclaim) { 4154 if (reclaim) {
4423 /* Invoke any callbacks, transfer the skb to caller, and 4155 /* Invoke any callbacks, transfer the skb to caller, and
4424 * fire off the (possibly) blocking iwl4965_send_cmd() 4156 * fire off the (possibly) blocking iwl_send_cmd()
4425 * as we reclaim the driver command queue */ 4157 * as we reclaim the driver command queue */
4426 if (rxb && rxb->skb) 4158 if (rxb && rxb->skb)
4427 iwl4965_tx_cmd_complete(priv, rxb); 4159 iwl4965_tx_cmd_complete(priv, rxb);
@@ -4465,7 +4197,7 @@ static void iwl4965_rx_handle(struct iwl4965_priv *priv)
4465/** 4197/**
4466 * iwl4965_tx_queue_update_write_ptr - Send new write index to hardware 4198 * iwl4965_tx_queue_update_write_ptr - Send new write index to hardware
4467 */ 4199 */
4468static int iwl4965_tx_queue_update_write_ptr(struct iwl4965_priv *priv, 4200static int iwl4965_tx_queue_update_write_ptr(struct iwl_priv *priv,
4469 struct iwl4965_tx_queue *txq) 4201 struct iwl4965_tx_queue *txq)
4470{ 4202{
4471 u32 reg = 0; 4203 u32 reg = 0;
@@ -4508,13 +4240,13 @@ static int iwl4965_tx_queue_update_write_ptr(struct iwl4965_priv *priv,
4508 return rc; 4240 return rc;
4509} 4241}
4510 4242
4511#ifdef CONFIG_IWL4965_DEBUG 4243#ifdef CONFIG_IWLWIFI_DEBUG
4512static void iwl4965_print_rx_config_cmd(struct iwl4965_rxon_cmd *rxon) 4244static void iwl4965_print_rx_config_cmd(struct iwl4965_rxon_cmd *rxon)
4513{ 4245{
4514 DECLARE_MAC_BUF(mac); 4246 DECLARE_MAC_BUF(mac);
4515 4247
4516 IWL_DEBUG_RADIO("RX CONFIG:\n"); 4248 IWL_DEBUG_RADIO("RX CONFIG:\n");
4517 iwl4965_print_hex_dump(IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); 4249 iwl_print_hex_dump(IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
4518 IWL_DEBUG_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); 4250 IWL_DEBUG_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel));
4519 IWL_DEBUG_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); 4251 IWL_DEBUG_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags));
4520 IWL_DEBUG_RADIO("u32 filter_flags: 0x%08x\n", 4252 IWL_DEBUG_RADIO("u32 filter_flags: 0x%08x\n",
@@ -4531,14 +4263,14 @@ static void iwl4965_print_rx_config_cmd(struct iwl4965_rxon_cmd *rxon)
4531} 4263}
4532#endif 4264#endif
4533 4265
4534static void iwl4965_enable_interrupts(struct iwl4965_priv *priv) 4266static void iwl4965_enable_interrupts(struct iwl_priv *priv)
4535{ 4267{
4536 IWL_DEBUG_ISR("Enabling interrupts\n"); 4268 IWL_DEBUG_ISR("Enabling interrupts\n");
4537 set_bit(STATUS_INT_ENABLED, &priv->status); 4269 set_bit(STATUS_INT_ENABLED, &priv->status);
4538 iwl4965_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK); 4270 iwl4965_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK);
4539} 4271}
4540 4272
4541static inline void iwl4965_disable_interrupts(struct iwl4965_priv *priv) 4273static inline void iwl4965_disable_interrupts(struct iwl_priv *priv)
4542{ 4274{
4543 clear_bit(STATUS_INT_ENABLED, &priv->status); 4275 clear_bit(STATUS_INT_ENABLED, &priv->status);
4544 4276
@@ -4575,7 +4307,7 @@ static const char *desc_lookup(int i)
4575#define ERROR_START_OFFSET (1 * sizeof(u32)) 4307#define ERROR_START_OFFSET (1 * sizeof(u32))
4576#define ERROR_ELEM_SIZE (7 * sizeof(u32)) 4308#define ERROR_ELEM_SIZE (7 * sizeof(u32))
4577 4309
4578static void iwl4965_dump_nic_error_log(struct iwl4965_priv *priv) 4310static void iwl4965_dump_nic_error_log(struct iwl_priv *priv)
4579{ 4311{
4580 u32 data2, line; 4312 u32 data2, line;
4581 u32 desc, time, count, base, data1; 4313 u32 desc, time, count, base, data1;
@@ -4630,7 +4362,7 @@ static void iwl4965_dump_nic_error_log(struct iwl4965_priv *priv)
4630 * 4362 *
4631 * NOTE: Must be called with iwl4965_grab_nic_access() already obtained! 4363 * NOTE: Must be called with iwl4965_grab_nic_access() already obtained!
4632 */ 4364 */
4633static void iwl4965_print_event_log(struct iwl4965_priv *priv, u32 start_idx, 4365static void iwl4965_print_event_log(struct iwl_priv *priv, u32 start_idx,
4634 u32 num_events, u32 mode) 4366 u32 num_events, u32 mode)
4635{ 4367{
4636 u32 i; 4368 u32 i;
@@ -4668,7 +4400,7 @@ static void iwl4965_print_event_log(struct iwl4965_priv *priv, u32 start_idx,
4668 } 4400 }
4669} 4401}
4670 4402
4671static void iwl4965_dump_nic_event_log(struct iwl4965_priv *priv) 4403static void iwl4965_dump_nic_event_log(struct iwl_priv *priv)
4672{ 4404{
4673 int rc; 4405 int rc;
4674 u32 base; /* SRAM byte address of event log header */ 4406 u32 base; /* SRAM byte address of event log header */
@@ -4723,7 +4455,7 @@ static void iwl4965_dump_nic_event_log(struct iwl4965_priv *priv)
4723/** 4455/**
4724 * iwl4965_irq_handle_error - called for HW or SW error interrupt from card 4456 * iwl4965_irq_handle_error - called for HW or SW error interrupt from card
4725 */ 4457 */
4726static void iwl4965_irq_handle_error(struct iwl4965_priv *priv) 4458static void iwl4965_irq_handle_error(struct iwl_priv *priv)
4727{ 4459{
4728 /* Set the FW error flag -- cleared on iwl4965_down */ 4460 /* Set the FW error flag -- cleared on iwl4965_down */
4729 set_bit(STATUS_FW_ERROR, &priv->status); 4461 set_bit(STATUS_FW_ERROR, &priv->status);
@@ -4731,8 +4463,8 @@ static void iwl4965_irq_handle_error(struct iwl4965_priv *priv)
4731 /* Cancel currently queued command. */ 4463 /* Cancel currently queued command. */
4732 clear_bit(STATUS_HCMD_ACTIVE, &priv->status); 4464 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
4733 4465
4734#ifdef CONFIG_IWL4965_DEBUG 4466#ifdef CONFIG_IWLWIFI_DEBUG
4735 if (iwl4965_debug_level & IWL_DL_FW_ERRORS) { 4467 if (iwl_debug_level & IWL_DL_FW_ERRORS) {
4736 iwl4965_dump_nic_error_log(priv); 4468 iwl4965_dump_nic_error_log(priv);
4737 iwl4965_dump_nic_event_log(priv); 4469 iwl4965_dump_nic_event_log(priv);
4738 iwl4965_print_rx_config_cmd(&priv->staging_rxon); 4470 iwl4965_print_rx_config_cmd(&priv->staging_rxon);
@@ -4758,7 +4490,7 @@ static void iwl4965_irq_handle_error(struct iwl4965_priv *priv)
4758 } 4490 }
4759} 4491}
4760 4492
4761static void iwl4965_error_recovery(struct iwl4965_priv *priv) 4493static void iwl4965_error_recovery(struct iwl_priv *priv)
4762{ 4494{
4763 unsigned long flags; 4495 unsigned long flags;
4764 4496
@@ -4775,12 +4507,12 @@ static void iwl4965_error_recovery(struct iwl4965_priv *priv)
4775 spin_unlock_irqrestore(&priv->lock, flags); 4507 spin_unlock_irqrestore(&priv->lock, flags);
4776} 4508}
4777 4509
4778static void iwl4965_irq_tasklet(struct iwl4965_priv *priv) 4510static void iwl4965_irq_tasklet(struct iwl_priv *priv)
4779{ 4511{
4780 u32 inta, handled = 0; 4512 u32 inta, handled = 0;
4781 u32 inta_fh; 4513 u32 inta_fh;
4782 unsigned long flags; 4514 unsigned long flags;
4783#ifdef CONFIG_IWL4965_DEBUG 4515#ifdef CONFIG_IWLWIFI_DEBUG
4784 u32 inta_mask; 4516 u32 inta_mask;
4785#endif 4517#endif
4786 4518
@@ -4798,8 +4530,8 @@ static void iwl4965_irq_tasklet(struct iwl4965_priv *priv)
4798 inta_fh = iwl4965_read32(priv, CSR_FH_INT_STATUS); 4530 inta_fh = iwl4965_read32(priv, CSR_FH_INT_STATUS);
4799 iwl4965_write32(priv, CSR_FH_INT_STATUS, inta_fh); 4531 iwl4965_write32(priv, CSR_FH_INT_STATUS, inta_fh);
4800 4532
4801#ifdef CONFIG_IWL4965_DEBUG 4533#ifdef CONFIG_IWLWIFI_DEBUG
4802 if (iwl4965_debug_level & IWL_DL_ISR) { 4534 if (iwl_debug_level & IWL_DL_ISR) {
4803 /* just for debug */ 4535 /* just for debug */
4804 inta_mask = iwl4965_read32(priv, CSR_INT_MASK); 4536 inta_mask = iwl4965_read32(priv, CSR_INT_MASK);
4805 IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 4537 IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
@@ -4832,8 +4564,8 @@ static void iwl4965_irq_tasklet(struct iwl4965_priv *priv)
4832 return; 4564 return;
4833 } 4565 }
4834 4566
4835#ifdef CONFIG_IWL4965_DEBUG 4567#ifdef CONFIG_IWLWIFI_DEBUG
4836 if (iwl4965_debug_level & (IWL_DL_ISR)) { 4568 if (iwl_debug_level & (IWL_DL_ISR)) {
4837 /* NIC fires this, but we don't use it, redundant with WAKEUP */ 4569 /* NIC fires this, but we don't use it, redundant with WAKEUP */
4838 if (inta & CSR_INT_BIT_SCD) 4570 if (inta & CSR_INT_BIT_SCD)
4839 IWL_DEBUG_ISR("Scheduler finished to transmit " 4571 IWL_DEBUG_ISR("Scheduler finished to transmit "
@@ -4923,8 +4655,8 @@ static void iwl4965_irq_tasklet(struct iwl4965_priv *priv)
4923 /* Re-enable all interrupts */ 4655 /* Re-enable all interrupts */
4924 iwl4965_enable_interrupts(priv); 4656 iwl4965_enable_interrupts(priv);
4925 4657
4926#ifdef CONFIG_IWL4965_DEBUG 4658#ifdef CONFIG_IWLWIFI_DEBUG
4927 if (iwl4965_debug_level & (IWL_DL_ISR)) { 4659 if (iwl_debug_level & (IWL_DL_ISR)) {
4928 inta = iwl4965_read32(priv, CSR_INT); 4660 inta = iwl4965_read32(priv, CSR_INT);
4929 inta_mask = iwl4965_read32(priv, CSR_INT_MASK); 4661 inta_mask = iwl4965_read32(priv, CSR_INT_MASK);
4930 inta_fh = iwl4965_read32(priv, CSR_FH_INT_STATUS); 4662 inta_fh = iwl4965_read32(priv, CSR_FH_INT_STATUS);
@@ -4937,7 +4669,7 @@ static void iwl4965_irq_tasklet(struct iwl4965_priv *priv)
4937 4669
4938static irqreturn_t iwl4965_isr(int irq, void *data) 4670static irqreturn_t iwl4965_isr(int irq, void *data)
4939{ 4671{
4940 struct iwl4965_priv *priv = data; 4672 struct iwl_priv *priv = data;
4941 u32 inta, inta_mask; 4673 u32 inta, inta_mask;
4942 u32 inta_fh; 4674 u32 inta_fh;
4943 if (!priv) 4675 if (!priv)
@@ -4991,308 +4723,6 @@ static irqreturn_t iwl4965_isr(int irq, void *data)
4991 return IRQ_NONE; 4723 return IRQ_NONE;
4992} 4724}
4993 4725
4994/************************** EEPROM BANDS ****************************
4995 *
4996 * The iwl4965_eeprom_band definitions below provide the mapping from the
4997 * EEPROM contents to the specific channel number supported for each
4998 * band.
4999 *
5000 * For example, iwl4965_priv->eeprom.band_3_channels[4] from the band_3
5001 * definition below maps to physical channel 42 in the 5.2GHz spectrum.
5002 * The specific geography and calibration information for that channel
5003 * is contained in the eeprom map itself.
5004 *
5005 * During init, we copy the eeprom information and channel map
5006 * information into priv->channel_info_24/52 and priv->channel_map_24/52
5007 *
5008 * channel_map_24/52 provides the index in the channel_info array for a
5009 * given channel. We have to have two separate maps as there is channel
5010 * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and
5011 * band_2
5012 *
5013 * A value of 0xff stored in the channel_map indicates that the channel
5014 * is not supported by the hardware at all.
5015 *
5016 * A value of 0xfe in the channel_map indicates that the channel is not
5017 * valid for Tx with the current hardware. This means that
5018 * while the system can tune and receive on a given channel, it may not
5019 * be able to associate or transmit any frames on that
5020 * channel. There is no corresponding channel information for that
5021 * entry.
5022 *
5023 *********************************************************************/
5024
5025/* 2.4 GHz */
5026static const u8 iwl4965_eeprom_band_1[14] = {
5027 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
5028};
5029
5030/* 5.2 GHz bands */
5031static const u8 iwl4965_eeprom_band_2[] = { /* 4915-5080MHz */
5032 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16
5033};
5034
5035static const u8 iwl4965_eeprom_band_3[] = { /* 5170-5320MHz */
5036 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
5037};
5038
5039static const u8 iwl4965_eeprom_band_4[] = { /* 5500-5700MHz */
5040 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
5041};
5042
5043static const u8 iwl4965_eeprom_band_5[] = { /* 5725-5825MHz */
5044 145, 149, 153, 157, 161, 165
5045};
5046
5047static u8 iwl4965_eeprom_band_6[] = { /* 2.4 FAT channel */
5048 1, 2, 3, 4, 5, 6, 7
5049};
5050
5051static u8 iwl4965_eeprom_band_7[] = { /* 5.2 FAT channel */
5052 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157
5053};
5054
5055static void iwl4965_init_band_reference(const struct iwl4965_priv *priv,
5056 int band,
5057 int *eeprom_ch_count,
5058 const struct iwl4965_eeprom_channel
5059 **eeprom_ch_info,
5060 const u8 **eeprom_ch_index)
5061{
5062 switch (band) {
5063 case 1: /* 2.4GHz band */
5064 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_1);
5065 *eeprom_ch_info = priv->eeprom.band_1_channels;
5066 *eeprom_ch_index = iwl4965_eeprom_band_1;
5067 break;
5068 case 2: /* 4.9GHz band */
5069 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_2);
5070 *eeprom_ch_info = priv->eeprom.band_2_channels;
5071 *eeprom_ch_index = iwl4965_eeprom_band_2;
5072 break;
5073 case 3: /* 5.2GHz band */
5074 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_3);
5075 *eeprom_ch_info = priv->eeprom.band_3_channels;
5076 *eeprom_ch_index = iwl4965_eeprom_band_3;
5077 break;
5078 case 4: /* 5.5GHz band */
5079 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_4);
5080 *eeprom_ch_info = priv->eeprom.band_4_channels;
5081 *eeprom_ch_index = iwl4965_eeprom_band_4;
5082 break;
5083 case 5: /* 5.7GHz band */
5084 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_5);
5085 *eeprom_ch_info = priv->eeprom.band_5_channels;
5086 *eeprom_ch_index = iwl4965_eeprom_band_5;
5087 break;
5088 case 6: /* 2.4GHz FAT channels */
5089 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_6);
5090 *eeprom_ch_info = priv->eeprom.band_24_channels;
5091 *eeprom_ch_index = iwl4965_eeprom_band_6;
5092 break;
5093 case 7: /* 5 GHz FAT channels */
5094 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_7);
5095 *eeprom_ch_info = priv->eeprom.band_52_channels;
5096 *eeprom_ch_index = iwl4965_eeprom_band_7;
5097 break;
5098 default:
5099 BUG();
5100 return;
5101 }
5102}
5103
5104/**
5105 * iwl4965_get_channel_info - Find driver's private channel info
5106 *
5107 * Based on band and channel number.
5108 */
5109const struct iwl4965_channel_info *iwl4965_get_channel_info(const struct iwl4965_priv *priv,
5110 enum ieee80211_band band, u16 channel)
5111{
5112 int i;
5113
5114 switch (band) {
5115 case IEEE80211_BAND_5GHZ:
5116 for (i = 14; i < priv->channel_count; i++) {
5117 if (priv->channel_info[i].channel == channel)
5118 return &priv->channel_info[i];
5119 }
5120 break;
5121 case IEEE80211_BAND_2GHZ:
5122 if (channel >= 1 && channel <= 14)
5123 return &priv->channel_info[channel - 1];
5124 break;
5125 default:
5126 BUG();
5127 }
5128
5129 return NULL;
5130}
5131
5132#define CHECK_AND_PRINT(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \
5133 ? # x " " : "")
5134
5135/**
5136 * iwl4965_init_channel_map - Set up driver's info for all possible channels
5137 */
5138static int iwl4965_init_channel_map(struct iwl4965_priv *priv)
5139{
5140 int eeprom_ch_count = 0;
5141 const u8 *eeprom_ch_index = NULL;
5142 const struct iwl4965_eeprom_channel *eeprom_ch_info = NULL;
5143 int band, ch;
5144 struct iwl4965_channel_info *ch_info;
5145
5146 if (priv->channel_count) {
5147 IWL_DEBUG_INFO("Channel map already initialized.\n");
5148 return 0;
5149 }
5150
5151 if (priv->eeprom.version < 0x2f) {
5152 IWL_WARNING("Unsupported EEPROM version: 0x%04X\n",
5153 priv->eeprom.version);
5154 return -EINVAL;
5155 }
5156
5157 IWL_DEBUG_INFO("Initializing regulatory info from EEPROM\n");
5158
5159 priv->channel_count =
5160 ARRAY_SIZE(iwl4965_eeprom_band_1) +
5161 ARRAY_SIZE(iwl4965_eeprom_band_2) +
5162 ARRAY_SIZE(iwl4965_eeprom_band_3) +
5163 ARRAY_SIZE(iwl4965_eeprom_band_4) +
5164 ARRAY_SIZE(iwl4965_eeprom_band_5);
5165
5166 IWL_DEBUG_INFO("Parsing data for %d channels.\n", priv->channel_count);
5167
5168 priv->channel_info = kzalloc(sizeof(struct iwl4965_channel_info) *
5169 priv->channel_count, GFP_KERNEL);
5170 if (!priv->channel_info) {
5171 IWL_ERROR("Could not allocate channel_info\n");
5172 priv->channel_count = 0;
5173 return -ENOMEM;
5174 }
5175
5176 ch_info = priv->channel_info;
5177
5178 /* Loop through the 5 EEPROM bands adding them in order to the
5179 * channel map we maintain (that contains additional information than
5180 * what just in the EEPROM) */
5181 for (band = 1; band <= 5; band++) {
5182
5183 iwl4965_init_band_reference(priv, band, &eeprom_ch_count,
5184 &eeprom_ch_info, &eeprom_ch_index);
5185
5186 /* Loop through each band adding each of the channels */
5187 for (ch = 0; ch < eeprom_ch_count; ch++) {
5188 ch_info->channel = eeprom_ch_index[ch];
5189 ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ :
5190 IEEE80211_BAND_5GHZ;
5191
5192 /* permanently store EEPROM's channel regulatory flags
5193 * and max power in channel info database. */
5194 ch_info->eeprom = eeprom_ch_info[ch];
5195
5196 /* Copy the run-time flags so they are there even on
5197 * invalid channels */
5198 ch_info->flags = eeprom_ch_info[ch].flags;
5199
5200 if (!(is_channel_valid(ch_info))) {
5201 IWL_DEBUG_INFO("Ch. %d Flags %x [%sGHz] - "
5202 "No traffic\n",
5203 ch_info->channel,
5204 ch_info->flags,
5205 is_channel_a_band(ch_info) ?
5206 "5.2" : "2.4");
5207 ch_info++;
5208 continue;
5209 }
5210
5211 /* Initialize regulatory-based run-time data */
5212 ch_info->max_power_avg = ch_info->curr_txpow =
5213 eeprom_ch_info[ch].max_power_avg;
5214 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg;
5215 ch_info->min_power = 0;
5216
5217 IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s%s(0x%02x"
5218 " %ddBm): Ad-Hoc %ssupported\n",
5219 ch_info->channel,
5220 is_channel_a_band(ch_info) ?
5221 "5.2" : "2.4",
5222 CHECK_AND_PRINT(VALID),
5223 CHECK_AND_PRINT(IBSS),
5224 CHECK_AND_PRINT(ACTIVE),
5225 CHECK_AND_PRINT(RADAR),
5226 CHECK_AND_PRINT(WIDE),
5227 CHECK_AND_PRINT(NARROW),
5228 CHECK_AND_PRINT(DFS),
5229 eeprom_ch_info[ch].flags,
5230 eeprom_ch_info[ch].max_power_avg,
5231 ((eeprom_ch_info[ch].
5232 flags & EEPROM_CHANNEL_IBSS)
5233 && !(eeprom_ch_info[ch].
5234 flags & EEPROM_CHANNEL_RADAR))
5235 ? "" : "not ");
5236
5237 /* Set the user_txpower_limit to the highest power
5238 * supported by any channel */
5239 if (eeprom_ch_info[ch].max_power_avg >
5240 priv->user_txpower_limit)
5241 priv->user_txpower_limit =
5242 eeprom_ch_info[ch].max_power_avg;
5243
5244 ch_info++;
5245 }
5246 }
5247
5248 /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */
5249 for (band = 6; band <= 7; band++) {
5250 enum ieee80211_band ieeeband;
5251 u8 fat_extension_chan;
5252
5253 iwl4965_init_band_reference(priv, band, &eeprom_ch_count,
5254 &eeprom_ch_info, &eeprom_ch_index);
5255
5256 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */
5257 ieeeband = (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
5258
5259 /* Loop through each band adding each of the channels */
5260 for (ch = 0; ch < eeprom_ch_count; ch++) {
5261
5262 if ((band == 6) &&
5263 ((eeprom_ch_index[ch] == 5) ||
5264 (eeprom_ch_index[ch] == 6) ||
5265 (eeprom_ch_index[ch] == 7)))
5266 fat_extension_chan = HT_IE_EXT_CHANNEL_MAX;
5267 else
5268 fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE;
5269
5270 /* Set up driver's info for lower half */
5271 iwl4965_set_fat_chan_info(priv, ieeeband,
5272 eeprom_ch_index[ch],
5273 &(eeprom_ch_info[ch]),
5274 fat_extension_chan);
5275
5276 /* Set up driver's info for upper half */
5277 iwl4965_set_fat_chan_info(priv, ieeeband,
5278 (eeprom_ch_index[ch] + 4),
5279 &(eeprom_ch_info[ch]),
5280 HT_IE_EXT_CHANNEL_BELOW);
5281 }
5282 }
5283
5284 return 0;
5285}
5286
5287/*
5288 * iwl4965_free_channel_map - undo allocations in iwl4965_init_channel_map
5289 */
5290static void iwl4965_free_channel_map(struct iwl4965_priv *priv)
5291{
5292 kfree(priv->channel_info);
5293 priv->channel_count = 0;
5294}
5295
5296/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after 4726/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after
5297 * sending probe req. This should be set long enough to hear probe responses 4727 * sending probe req. This should be set long enough to hear probe responses
5298 * from more than one AP. */ 4728 * from more than one AP. */
@@ -5316,7 +4746,7 @@ static void iwl4965_free_channel_map(struct iwl4965_priv *priv)
5316#define IWL_PASSIVE_DWELL_BASE (100) 4746#define IWL_PASSIVE_DWELL_BASE (100)
5317#define IWL_CHANNEL_TUNE_TIME 5 4747#define IWL_CHANNEL_TUNE_TIME 5
5318 4748
5319static inline u16 iwl4965_get_active_dwell_time(struct iwl4965_priv *priv, 4749static inline u16 iwl4965_get_active_dwell_time(struct iwl_priv *priv,
5320 enum ieee80211_band band) 4750 enum ieee80211_band band)
5321{ 4751{
5322 if (band == IEEE80211_BAND_5GHZ) 4752 if (band == IEEE80211_BAND_5GHZ)
@@ -5325,7 +4755,7 @@ static inline u16 iwl4965_get_active_dwell_time(struct iwl4965_priv *priv,
5325 return IWL_ACTIVE_DWELL_TIME_24; 4755 return IWL_ACTIVE_DWELL_TIME_24;
5326} 4756}
5327 4757
5328static u16 iwl4965_get_passive_dwell_time(struct iwl4965_priv *priv, 4758static u16 iwl4965_get_passive_dwell_time(struct iwl_priv *priv,
5329 enum ieee80211_band band) 4759 enum ieee80211_band band)
5330{ 4760{
5331 u16 active = iwl4965_get_active_dwell_time(priv, band); 4761 u16 active = iwl4965_get_active_dwell_time(priv, band);
@@ -5349,14 +4779,14 @@ static u16 iwl4965_get_passive_dwell_time(struct iwl4965_priv *priv,
5349 return passive; 4779 return passive;
5350} 4780}
5351 4781
5352static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, 4782static int iwl4965_get_channels_for_scan(struct iwl_priv *priv,
5353 enum ieee80211_band band, 4783 enum ieee80211_band band,
5354 u8 is_active, u8 direct_mask, 4784 u8 is_active, u8 direct_mask,
5355 struct iwl4965_scan_channel *scan_ch) 4785 struct iwl4965_scan_channel *scan_ch)
5356{ 4786{
5357 const struct ieee80211_channel *channels = NULL; 4787 const struct ieee80211_channel *channels = NULL;
5358 const struct ieee80211_supported_band *sband; 4788 const struct ieee80211_supported_band *sband;
5359 const struct iwl4965_channel_info *ch_info; 4789 const struct iwl_channel_info *ch_info;
5360 u16 passive_dwell = 0; 4790 u16 passive_dwell = 0;
5361 u16 active_dwell = 0; 4791 u16 active_dwell = 0;
5362 int added, i; 4792 int added, i;
@@ -5384,7 +4814,7 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv,
5384 4814
5385 scan_ch->channel = ieee80211_frequency_to_channel(channels[i].center_freq); 4815 scan_ch->channel = ieee80211_frequency_to_channel(channels[i].center_freq);
5386 4816
5387 ch_info = iwl4965_get_channel_info(priv, band, 4817 ch_info = iwl_get_channel_info(priv, band,
5388 scan_ch->channel); 4818 scan_ch->channel);
5389 if (!is_channel_valid(ch_info)) { 4819 if (!is_channel_valid(ch_info)) {
5390 IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", 4820 IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n",
@@ -5436,7 +4866,7 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv,
5436 return added; 4866 return added;
5437} 4867}
5438 4868
5439static void iwl4965_init_hw_rates(struct iwl4965_priv *priv, 4869static void iwl4965_init_hw_rates(struct iwl_priv *priv,
5440 struct ieee80211_rate *rates) 4870 struct ieee80211_rate *rates)
5441{ 4871{
5442 int i; 4872 int i;
@@ -5460,9 +4890,9 @@ static void iwl4965_init_hw_rates(struct iwl4965_priv *priv,
5460/** 4890/**
5461 * iwl4965_init_geos - Initialize mac80211's geo/channel info based from eeprom 4891 * iwl4965_init_geos - Initialize mac80211's geo/channel info based from eeprom
5462 */ 4892 */
5463static int iwl4965_init_geos(struct iwl4965_priv *priv) 4893int iwl4965_init_geos(struct iwl_priv *priv)
5464{ 4894{
5465 struct iwl4965_channel_info *ch; 4895 struct iwl_channel_info *ch;
5466 struct ieee80211_supported_band *sband; 4896 struct ieee80211_supported_band *sband;
5467 struct ieee80211_channel *channels; 4897 struct ieee80211_channel *channels;
5468 struct ieee80211_channel *geo_ch; 4898 struct ieee80211_channel *geo_ch;
@@ -5490,12 +4920,12 @@ static int iwl4965_init_geos(struct iwl4965_priv *priv)
5490 4920
5491 /* 5.2GHz channels start after the 2.4GHz channels */ 4921 /* 5.2GHz channels start after the 2.4GHz channels */
5492 sband = &priv->bands[IEEE80211_BAND_5GHZ]; 4922 sband = &priv->bands[IEEE80211_BAND_5GHZ];
5493 sband->channels = &channels[ARRAY_SIZE(iwl4965_eeprom_band_1)]; 4923 sband->channels = &channels[ARRAY_SIZE(iwl_eeprom_band_1)];
5494 /* just OFDM */ 4924 /* just OFDM */
5495 sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; 4925 sband->bitrates = &rates[IWL_FIRST_OFDM_RATE];
5496 sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE; 4926 sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE;
5497 4927
5498 iwl4965_init_ht_hw_capab(&sband->ht_info, IEEE80211_BAND_5GHZ); 4928 iwl4965_init_ht_hw_capab(priv, &sband->ht_info, IEEE80211_BAND_5GHZ);
5499 4929
5500 sband = &priv->bands[IEEE80211_BAND_2GHZ]; 4930 sband = &priv->bands[IEEE80211_BAND_2GHZ];
5501 sband->channels = channels; 4931 sband->channels = channels;
@@ -5503,7 +4933,7 @@ static int iwl4965_init_geos(struct iwl4965_priv *priv)
5503 sband->bitrates = rates; 4933 sband->bitrates = rates;
5504 sband->n_bitrates = IWL_RATE_COUNT; 4934 sband->n_bitrates = IWL_RATE_COUNT;
5505 4935
5506 iwl4965_init_ht_hw_capab(&sband->ht_info, IEEE80211_BAND_2GHZ); 4936 iwl4965_init_ht_hw_capab(priv, &sband->ht_info, IEEE80211_BAND_2GHZ);
5507 4937
5508 priv->ieee_channels = channels; 4938 priv->ieee_channels = channels;
5509 priv->ieee_rates = rates; 4939 priv->ieee_rates = rates;
@@ -5582,7 +5012,7 @@ static int iwl4965_init_geos(struct iwl4965_priv *priv)
5582/* 5012/*
5583 * iwl4965_free_geos - undo allocations in iwl4965_init_geos 5013 * iwl4965_free_geos - undo allocations in iwl4965_init_geos
5584 */ 5014 */
5585static void iwl4965_free_geos(struct iwl4965_priv *priv) 5015void iwl4965_free_geos(struct iwl_priv *priv)
5586{ 5016{
5587 kfree(priv->ieee_channels); 5017 kfree(priv->ieee_channels);
5588 kfree(priv->ieee_rates); 5018 kfree(priv->ieee_rates);
@@ -5595,7 +5025,7 @@ static void iwl4965_free_geos(struct iwl4965_priv *priv)
5595 * 5025 *
5596 ******************************************************************************/ 5026 ******************************************************************************/
5597 5027
5598static void iwl4965_dealloc_ucode_pci(struct iwl4965_priv *priv) 5028static void iwl4965_dealloc_ucode_pci(struct iwl_priv *priv)
5599{ 5029{
5600 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_code); 5030 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_code);
5601 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_data); 5031 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_data);
@@ -5609,7 +5039,7 @@ static void iwl4965_dealloc_ucode_pci(struct iwl4965_priv *priv)
5609 * iwl4965_verify_inst_full - verify runtime uCode image in card vs. host, 5039 * iwl4965_verify_inst_full - verify runtime uCode image in card vs. host,
5610 * looking at all data. 5040 * looking at all data.
5611 */ 5041 */
5612static int iwl4965_verify_inst_full(struct iwl4965_priv *priv, __le32 *image, 5042static int iwl4965_verify_inst_full(struct iwl_priv *priv, __le32 *image,
5613 u32 len) 5043 u32 len)
5614{ 5044{
5615 u32 val; 5045 u32 val;
@@ -5657,7 +5087,7 @@ static int iwl4965_verify_inst_full(struct iwl4965_priv *priv, __le32 *image,
5657 * using sample data 100 bytes apart. If these sample points are good, 5087 * using sample data 100 bytes apart. If these sample points are good,
5658 * it's a pretty good bet that everything between them is good, too. 5088 * it's a pretty good bet that everything between them is good, too.
5659 */ 5089 */
5660static int iwl4965_verify_inst_sparse(struct iwl4965_priv *priv, __le32 *image, u32 len) 5090static int iwl4965_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len)
5661{ 5091{
5662 u32 val; 5092 u32 val;
5663 int rc = 0; 5093 int rc = 0;
@@ -5700,7 +5130,7 @@ static int iwl4965_verify_inst_sparse(struct iwl4965_priv *priv, __le32 *image,
5700 * iwl4965_verify_ucode - determine which instruction image is in SRAM, 5130 * iwl4965_verify_ucode - determine which instruction image is in SRAM,
5701 * and verify its contents 5131 * and verify its contents
5702 */ 5132 */
5703static int iwl4965_verify_ucode(struct iwl4965_priv *priv) 5133static int iwl4965_verify_ucode(struct iwl_priv *priv)
5704{ 5134{
5705 __le32 *image; 5135 __le32 *image;
5706 u32 len; 5136 u32 len;
@@ -5747,7 +5177,7 @@ static int iwl4965_verify_ucode(struct iwl4965_priv *priv)
5747 5177
5748 5178
5749/* check contents of special bootstrap uCode SRAM */ 5179/* check contents of special bootstrap uCode SRAM */
5750static int iwl4965_verify_bsm(struct iwl4965_priv *priv) 5180static int iwl4965_verify_bsm(struct iwl_priv *priv)
5751{ 5181{
5752 __le32 *image = priv->ucode_boot.v_addr; 5182 __le32 *image = priv->ucode_boot.v_addr;
5753 u32 len = priv->ucode_boot.len; 5183 u32 len = priv->ucode_boot.len;
@@ -5809,7 +5239,7 @@ static int iwl4965_verify_bsm(struct iwl4965_priv *priv)
5809 * the runtime uCode instructions and the backup data cache into SRAM, 5239 * the runtime uCode instructions and the backup data cache into SRAM,
5810 * and re-launches the runtime uCode from where it left off. 5240 * and re-launches the runtime uCode from where it left off.
5811 */ 5241 */
5812static int iwl4965_load_bsm(struct iwl4965_priv *priv) 5242static int iwl4965_load_bsm(struct iwl_priv *priv)
5813{ 5243{
5814 __le32 *image = priv->ucode_boot.v_addr; 5244 __le32 *image = priv->ucode_boot.v_addr;
5815 u32 len = priv->ucode_boot.len; 5245 u32 len = priv->ucode_boot.len;
@@ -5895,7 +5325,7 @@ static int iwl4965_load_bsm(struct iwl4965_priv *priv)
5895 return 0; 5325 return 0;
5896} 5326}
5897 5327
5898static void iwl4965_nic_start(struct iwl4965_priv *priv) 5328static void iwl4965_nic_start(struct iwl_priv *priv)
5899{ 5329{
5900 /* Remove all resets to allow NIC to operate */ 5330 /* Remove all resets to allow NIC to operate */
5901 iwl4965_write32(priv, CSR_RESET, 0); 5331 iwl4965_write32(priv, CSR_RESET, 0);
@@ -5907,7 +5337,7 @@ static void iwl4965_nic_start(struct iwl4965_priv *priv)
5907 * 5337 *
5908 * Copy into buffers for card to fetch via bus-mastering 5338 * Copy into buffers for card to fetch via bus-mastering
5909 */ 5339 */
5910static int iwl4965_read_ucode(struct iwl4965_priv *priv) 5340static int iwl4965_read_ucode(struct iwl_priv *priv)
5911{ 5341{
5912 struct iwl4965_ucode *ucode; 5342 struct iwl4965_ucode *ucode;
5913 int ret; 5343 int ret;
@@ -6108,7 +5538,7 @@ static int iwl4965_read_ucode(struct iwl4965_priv *priv)
6108 * We need to replace them to load runtime uCode inst and data, 5538 * We need to replace them to load runtime uCode inst and data,
6109 * and to save runtime data when powering down. 5539 * and to save runtime data when powering down.
6110 */ 5540 */
6111static int iwl4965_set_ucode_ptrs(struct iwl4965_priv *priv) 5541static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv)
6112{ 5542{
6113 dma_addr_t pinst; 5543 dma_addr_t pinst;
6114 dma_addr_t pdata; 5544 dma_addr_t pdata;
@@ -6157,7 +5587,7 @@ static int iwl4965_set_ucode_ptrs(struct iwl4965_priv *priv)
6157 * 5587 *
6158 * Tell "initialize" uCode to go ahead and load the runtime uCode. 5588 * Tell "initialize" uCode to go ahead and load the runtime uCode.
6159*/ 5589*/
6160static void iwl4965_init_alive_start(struct iwl4965_priv *priv) 5590static void iwl4965_init_alive_start(struct iwl_priv *priv)
6161{ 5591{
6162 /* Check alive response for "valid" sign from uCode */ 5592 /* Check alive response for "valid" sign from uCode */
6163 if (priv->card_alive_init.is_valid != UCODE_VALID_OK) { 5593 if (priv->card_alive_init.is_valid != UCODE_VALID_OK) {
@@ -6202,7 +5632,7 @@ static void iwl4965_init_alive_start(struct iwl4965_priv *priv)
6202 * from protocol/runtime uCode (initialization uCode's 5632 * from protocol/runtime uCode (initialization uCode's
6203 * Alive gets handled by iwl4965_init_alive_start()). 5633 * Alive gets handled by iwl4965_init_alive_start()).
6204 */ 5634 */
6205static void iwl4965_alive_start(struct iwl4965_priv *priv) 5635static void iwl4965_alive_start(struct iwl_priv *priv)
6206{ 5636{
6207 int rc = 0; 5637 int rc = 0;
6208 5638
@@ -6225,7 +5655,7 @@ static void iwl4965_alive_start(struct iwl4965_priv *priv)
6225 goto restart; 5655 goto restart;
6226 } 5656 }
6227 5657
6228 iwl4965_clear_stations_table(priv); 5658 iwlcore_clear_stations_table(priv);
6229 5659
6230 rc = iwl4965_alive_notify(priv); 5660 rc = iwl4965_alive_notify(priv);
6231 if (rc) { 5661 if (rc) {
@@ -6287,9 +5717,9 @@ static void iwl4965_alive_start(struct iwl4965_priv *priv)
6287 queue_work(priv->workqueue, &priv->restart); 5717 queue_work(priv->workqueue, &priv->restart);
6288} 5718}
6289 5719
6290static void iwl4965_cancel_deferred_work(struct iwl4965_priv *priv); 5720static void iwl4965_cancel_deferred_work(struct iwl_priv *priv);
6291 5721
6292static void __iwl4965_down(struct iwl4965_priv *priv) 5722static void __iwl4965_down(struct iwl_priv *priv)
6293{ 5723{
6294 unsigned long flags; 5724 unsigned long flags;
6295 int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status); 5725 int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status);
@@ -6302,7 +5732,7 @@ static void __iwl4965_down(struct iwl4965_priv *priv)
6302 if (!exit_pending) 5732 if (!exit_pending)
6303 set_bit(STATUS_EXIT_PENDING, &priv->status); 5733 set_bit(STATUS_EXIT_PENDING, &priv->status);
6304 5734
6305 iwl4965_clear_stations_table(priv); 5735 iwlcore_clear_stations_table(priv);
6306 5736
6307 /* Unblock any waiting calls */ 5737 /* Unblock any waiting calls */
6308 wake_up_interruptible_all(&priv->wait_command_queue); 5738 wake_up_interruptible_all(&priv->wait_command_queue);
@@ -6381,7 +5811,7 @@ static void __iwl4965_down(struct iwl4965_priv *priv)
6381 iwl4965_clear_free_frames(priv); 5811 iwl4965_clear_free_frames(priv);
6382} 5812}
6383 5813
6384static void iwl4965_down(struct iwl4965_priv *priv) 5814static void iwl4965_down(struct iwl_priv *priv)
6385{ 5815{
6386 mutex_lock(&priv->mutex); 5816 mutex_lock(&priv->mutex);
6387 __iwl4965_down(priv); 5817 __iwl4965_down(priv);
@@ -6392,7 +5822,7 @@ static void iwl4965_down(struct iwl4965_priv *priv)
6392 5822
6393#define MAX_HW_RESTARTS 5 5823#define MAX_HW_RESTARTS 5
6394 5824
6395static int __iwl4965_up(struct iwl4965_priv *priv) 5825static int __iwl4965_up(struct iwl_priv *priv)
6396{ 5826{
6397 int rc, i; 5827 int rc, i;
6398 5828
@@ -6457,7 +5887,7 @@ static int __iwl4965_up(struct iwl4965_priv *priv)
6457 5887
6458 for (i = 0; i < MAX_HW_RESTARTS; i++) { 5888 for (i = 0; i < MAX_HW_RESTARTS; i++) {
6459 5889
6460 iwl4965_clear_stations_table(priv); 5890 iwlcore_clear_stations_table(priv);
6461 5891
6462 /* load bootstrap state machine, 5892 /* load bootstrap state machine,
6463 * load bootstrap program into processor's memory, 5893 * load bootstrap program into processor's memory,
@@ -6495,8 +5925,8 @@ static int __iwl4965_up(struct iwl4965_priv *priv)
6495 5925
6496static void iwl4965_bg_init_alive_start(struct work_struct *data) 5926static void iwl4965_bg_init_alive_start(struct work_struct *data)
6497{ 5927{
6498 struct iwl4965_priv *priv = 5928 struct iwl_priv *priv =
6499 container_of(data, struct iwl4965_priv, init_alive_start.work); 5929 container_of(data, struct iwl_priv, init_alive_start.work);
6500 5930
6501 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 5931 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
6502 return; 5932 return;
@@ -6508,8 +5938,8 @@ static void iwl4965_bg_init_alive_start(struct work_struct *data)
6508 5938
6509static void iwl4965_bg_alive_start(struct work_struct *data) 5939static void iwl4965_bg_alive_start(struct work_struct *data)
6510{ 5940{
6511 struct iwl4965_priv *priv = 5941 struct iwl_priv *priv =
6512 container_of(data, struct iwl4965_priv, alive_start.work); 5942 container_of(data, struct iwl_priv, alive_start.work);
6513 5943
6514 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 5944 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
6515 return; 5945 return;
@@ -6521,7 +5951,7 @@ static void iwl4965_bg_alive_start(struct work_struct *data)
6521 5951
6522static void iwl4965_bg_rf_kill(struct work_struct *work) 5952static void iwl4965_bg_rf_kill(struct work_struct *work)
6523{ 5953{
6524 struct iwl4965_priv *priv = container_of(work, struct iwl4965_priv, rf_kill); 5954 struct iwl_priv *priv = container_of(work, struct iwl_priv, rf_kill);
6525 5955
6526 wake_up_interruptible(&priv->wait_command_queue); 5956 wake_up_interruptible(&priv->wait_command_queue);
6527 5957
@@ -6553,8 +5983,8 @@ static void iwl4965_bg_rf_kill(struct work_struct *work)
6553 5983
6554static void iwl4965_bg_scan_check(struct work_struct *data) 5984static void iwl4965_bg_scan_check(struct work_struct *data)
6555{ 5985{
6556 struct iwl4965_priv *priv = 5986 struct iwl_priv *priv =
6557 container_of(data, struct iwl4965_priv, scan_check.work); 5987 container_of(data, struct iwl_priv, scan_check.work);
6558 5988
6559 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 5989 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
6560 return; 5990 return;
@@ -6574,19 +6004,19 @@ static void iwl4965_bg_scan_check(struct work_struct *data)
6574 6004
6575static void iwl4965_bg_request_scan(struct work_struct *data) 6005static void iwl4965_bg_request_scan(struct work_struct *data)
6576{ 6006{
6577 struct iwl4965_priv *priv = 6007 struct iwl_priv *priv =
6578 container_of(data, struct iwl4965_priv, request_scan); 6008 container_of(data, struct iwl_priv, request_scan);
6579 struct iwl4965_host_cmd cmd = { 6009 struct iwl_host_cmd cmd = {
6580 .id = REPLY_SCAN_CMD, 6010 .id = REPLY_SCAN_CMD,
6581 .len = sizeof(struct iwl4965_scan_cmd), 6011 .len = sizeof(struct iwl4965_scan_cmd),
6582 .meta.flags = CMD_SIZE_HUGE, 6012 .meta.flags = CMD_SIZE_HUGE,
6583 }; 6013 };
6584 int rc = 0;
6585 struct iwl4965_scan_cmd *scan; 6014 struct iwl4965_scan_cmd *scan;
6586 struct ieee80211_conf *conf = NULL; 6015 struct ieee80211_conf *conf = NULL;
6587 u16 cmd_len; 6016 u16 cmd_len;
6588 enum ieee80211_band band; 6017 enum ieee80211_band band;
6589 u8 direct_mask; 6018 u8 direct_mask;
6019 int ret = 0;
6590 6020
6591 conf = ieee80211_get_hw_conf(priv->hw); 6021 conf = ieee80211_get_hw_conf(priv->hw);
6592 6022
@@ -6607,7 +6037,7 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
6607 if (test_bit(STATUS_SCAN_HW, &priv->status)) { 6037 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
6608 IWL_DEBUG_INFO("Multiple concurrent scan requests in parallel. " 6038 IWL_DEBUG_INFO("Multiple concurrent scan requests in parallel. "
6609 "Ignoring second request.\n"); 6039 "Ignoring second request.\n");
6610 rc = -EIO; 6040 ret = -EIO;
6611 goto done; 6041 goto done;
6612 } 6042 }
6613 6043
@@ -6640,7 +6070,7 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
6640 priv->scan = kmalloc(sizeof(struct iwl4965_scan_cmd) + 6070 priv->scan = kmalloc(sizeof(struct iwl4965_scan_cmd) +
6641 IWL_MAX_SCAN_SIZE, GFP_KERNEL); 6071 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
6642 if (!priv->scan) { 6072 if (!priv->scan) {
6643 rc = -ENOMEM; 6073 ret = -ENOMEM;
6644 goto done; 6074 goto done;
6645 } 6075 }
6646 } 6076 }
@@ -6692,8 +6122,9 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
6692 scan->direct_scan[0].len = priv->essid_len; 6122 scan->direct_scan[0].len = priv->essid_len;
6693 memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); 6123 memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
6694 direct_mask = 1; 6124 direct_mask = 1;
6695 } else 6125 } else {
6696 direct_mask = 0; 6126 direct_mask = 0;
6127 }
6697 6128
6698 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; 6129 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
6699 scan->tx_cmd.sta_id = priv->hw_setting.bcast_sta_id; 6130 scan->tx_cmd.sta_id = priv->hw_setting.bcast_sta_id;
@@ -6768,8 +6199,8 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
6768 scan->len = cpu_to_le16(cmd.len); 6199 scan->len = cpu_to_le16(cmd.len);
6769 6200
6770 set_bit(STATUS_SCAN_HW, &priv->status); 6201 set_bit(STATUS_SCAN_HW, &priv->status);
6771 rc = iwl4965_send_cmd_sync(priv, &cmd); 6202 ret = iwl_send_cmd_sync(priv, &cmd);
6772 if (rc) 6203 if (ret)
6773 goto done; 6204 goto done;
6774 6205
6775 queue_delayed_work(priv->workqueue, &priv->scan_check, 6206 queue_delayed_work(priv->workqueue, &priv->scan_check,
@@ -6786,7 +6217,7 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
6786 6217
6787static void iwl4965_bg_up(struct work_struct *data) 6218static void iwl4965_bg_up(struct work_struct *data)
6788{ 6219{
6789 struct iwl4965_priv *priv = container_of(data, struct iwl4965_priv, up); 6220 struct iwl_priv *priv = container_of(data, struct iwl_priv, up);
6790 6221
6791 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 6222 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
6792 return; 6223 return;
@@ -6798,7 +6229,7 @@ static void iwl4965_bg_up(struct work_struct *data)
6798 6229
6799static void iwl4965_bg_restart(struct work_struct *data) 6230static void iwl4965_bg_restart(struct work_struct *data)
6800{ 6231{
6801 struct iwl4965_priv *priv = container_of(data, struct iwl4965_priv, restart); 6232 struct iwl_priv *priv = container_of(data, struct iwl_priv, restart);
6802 6233
6803 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 6234 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
6804 return; 6235 return;
@@ -6809,8 +6240,8 @@ static void iwl4965_bg_restart(struct work_struct *data)
6809 6240
6810static void iwl4965_bg_rx_replenish(struct work_struct *data) 6241static void iwl4965_bg_rx_replenish(struct work_struct *data)
6811{ 6242{
6812 struct iwl4965_priv *priv = 6243 struct iwl_priv *priv =
6813 container_of(data, struct iwl4965_priv, rx_replenish); 6244 container_of(data, struct iwl_priv, rx_replenish);
6814 6245
6815 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 6246 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
6816 return; 6247 return;
@@ -6824,11 +6255,10 @@ static void iwl4965_bg_rx_replenish(struct work_struct *data)
6824 6255
6825static void iwl4965_bg_post_associate(struct work_struct *data) 6256static void iwl4965_bg_post_associate(struct work_struct *data)
6826{ 6257{
6827 struct iwl4965_priv *priv = container_of(data, struct iwl4965_priv, 6258 struct iwl_priv *priv = container_of(data, struct iwl_priv,
6828 post_associate.work); 6259 post_associate.work);
6829
6830 int rc = 0;
6831 struct ieee80211_conf *conf = NULL; 6260 struct ieee80211_conf *conf = NULL;
6261 int ret = 0;
6832 DECLARE_MAC_BUF(mac); 6262 DECLARE_MAC_BUF(mac);
6833 6263
6834 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 6264 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) {
@@ -6859,9 +6289,9 @@ static void iwl4965_bg_post_associate(struct work_struct *data)
6859 6289
6860 memset(&priv->rxon_timing, 0, sizeof(struct iwl4965_rxon_time_cmd)); 6290 memset(&priv->rxon_timing, 0, sizeof(struct iwl4965_rxon_time_cmd));
6861 iwl4965_setup_rxon_timing(priv); 6291 iwl4965_setup_rxon_timing(priv);
6862 rc = iwl4965_send_cmd_pdu(priv, REPLY_RXON_TIMING, 6292 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
6863 sizeof(priv->rxon_timing), &priv->rxon_timing); 6293 sizeof(priv->rxon_timing), &priv->rxon_timing);
6864 if (rc) 6294 if (ret)
6865 IWL_WARNING("REPLY_RXON_TIMING failed - " 6295 IWL_WARNING("REPLY_RXON_TIMING failed - "
6866 "Attempting to continue.\n"); 6296 "Attempting to continue.\n");
6867 6297
@@ -6903,7 +6333,7 @@ static void iwl4965_bg_post_associate(struct work_struct *data)
6903 case IEEE80211_IF_TYPE_IBSS: 6333 case IEEE80211_IF_TYPE_IBSS:
6904 6334
6905 /* clear out the station table */ 6335 /* clear out the station table */
6906 iwl4965_clear_stations_table(priv); 6336 iwlcore_clear_stations_table(priv);
6907 6337
6908 iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0); 6338 iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0);
6909 iwl4965_rxon_add_station(priv, priv->bssid, 0); 6339 iwl4965_rxon_add_station(priv, priv->bssid, 0);
@@ -6938,7 +6368,7 @@ static void iwl4965_bg_post_associate(struct work_struct *data)
6938 6368
6939static void iwl4965_bg_abort_scan(struct work_struct *work) 6369static void iwl4965_bg_abort_scan(struct work_struct *work)
6940{ 6370{
6941 struct iwl4965_priv *priv = container_of(work, struct iwl4965_priv, abort_scan); 6371 struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan);
6942 6372
6943 if (!iwl4965_is_ready(priv)) 6373 if (!iwl4965_is_ready(priv))
6944 return; 6374 return;
@@ -6955,8 +6385,8 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
6955 6385
6956static void iwl4965_bg_scan_completed(struct work_struct *work) 6386static void iwl4965_bg_scan_completed(struct work_struct *work)
6957{ 6387{
6958 struct iwl4965_priv *priv = 6388 struct iwl_priv *priv =
6959 container_of(work, struct iwl4965_priv, scan_completed); 6389 container_of(work, struct iwl_priv, scan_completed);
6960 6390
6961 IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, "SCAN complete scan\n"); 6391 IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, "SCAN complete scan\n");
6962 6392
@@ -6985,7 +6415,7 @@ static void iwl4965_bg_scan_completed(struct work_struct *work)
6985 6415
6986static int iwl4965_mac_start(struct ieee80211_hw *hw) 6416static int iwl4965_mac_start(struct ieee80211_hw *hw)
6987{ 6417{
6988 struct iwl4965_priv *priv = hw->priv; 6418 struct iwl_priv *priv = hw->priv;
6989 int ret; 6419 int ret;
6990 6420
6991 IWL_DEBUG_MAC80211("enter\n"); 6421 IWL_DEBUG_MAC80211("enter\n");
@@ -7062,7 +6492,7 @@ out_disable_msi:
7062 6492
7063static void iwl4965_mac_stop(struct ieee80211_hw *hw) 6493static void iwl4965_mac_stop(struct ieee80211_hw *hw)
7064{ 6494{
7065 struct iwl4965_priv *priv = hw->priv; 6495 struct iwl_priv *priv = hw->priv;
7066 6496
7067 IWL_DEBUG_MAC80211("enter\n"); 6497 IWL_DEBUG_MAC80211("enter\n");
7068 6498
@@ -7097,7 +6527,7 @@ static void iwl4965_mac_stop(struct ieee80211_hw *hw)
7097static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, 6527static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
7098 struct ieee80211_tx_control *ctl) 6528 struct ieee80211_tx_control *ctl)
7099{ 6529{
7100 struct iwl4965_priv *priv = hw->priv; 6530 struct iwl_priv *priv = hw->priv;
7101 6531
7102 IWL_DEBUG_MAC80211("enter\n"); 6532 IWL_DEBUG_MAC80211("enter\n");
7103 6533
@@ -7119,7 +6549,7 @@ static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
7119static int iwl4965_mac_add_interface(struct ieee80211_hw *hw, 6549static int iwl4965_mac_add_interface(struct ieee80211_hw *hw,
7120 struct ieee80211_if_init_conf *conf) 6550 struct ieee80211_if_init_conf *conf)
7121{ 6551{
7122 struct iwl4965_priv *priv = hw->priv; 6552 struct iwl_priv *priv = hw->priv;
7123 unsigned long flags; 6553 unsigned long flags;
7124 DECLARE_MAC_BUF(mac); 6554 DECLARE_MAC_BUF(mac);
7125 6555
@@ -7160,8 +6590,8 @@ static int iwl4965_mac_add_interface(struct ieee80211_hw *hw,
7160 */ 6590 */
7161static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 6591static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
7162{ 6592{
7163 struct iwl4965_priv *priv = hw->priv; 6593 struct iwl_priv *priv = hw->priv;
7164 const struct iwl4965_channel_info *ch_info; 6594 const struct iwl_channel_info *ch_info;
7165 unsigned long flags; 6595 unsigned long flags;
7166 int ret = 0; 6596 int ret = 0;
7167 6597
@@ -7176,7 +6606,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
7176 goto out; 6606 goto out;
7177 } 6607 }
7178 6608
7179 if (unlikely(!iwl4965_param_disable_hw_scan && 6609 if (unlikely(!priv->cfg->mod_params->disable_hw_scan &&
7180 test_bit(STATUS_SCANNING, &priv->status))) { 6610 test_bit(STATUS_SCANNING, &priv->status))) {
7181 IWL_DEBUG_MAC80211("leave - scanning\n"); 6611 IWL_DEBUG_MAC80211("leave - scanning\n");
7182 set_bit(STATUS_CONF_PENDING, &priv->status); 6612 set_bit(STATUS_CONF_PENDING, &priv->status);
@@ -7186,7 +6616,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
7186 6616
7187 spin_lock_irqsave(&priv->lock, flags); 6617 spin_lock_irqsave(&priv->lock, flags);
7188 6618
7189 ch_info = iwl4965_get_channel_info(priv, conf->channel->band, 6619 ch_info = iwl_get_channel_info(priv, conf->channel->band,
7190 ieee80211_frequency_to_channel(conf->channel->center_freq)); 6620 ieee80211_frequency_to_channel(conf->channel->center_freq));
7191 if (!is_channel_valid(ch_info)) { 6621 if (!is_channel_valid(ch_info)) {
7192 IWL_DEBUG_MAC80211("leave - invalid channel\n"); 6622 IWL_DEBUG_MAC80211("leave - invalid channel\n");
@@ -7207,7 +6637,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
7207 priv->staging_rxon.flags = 0; 6637 priv->staging_rxon.flags = 0;
7208#endif /* CONFIG_IWL4965_HT */ 6638#endif /* CONFIG_IWL4965_HT */
7209 6639
7210 iwl4965_set_rxon_channel(priv, conf->channel->band, 6640 iwlcore_set_rxon_channel(priv, conf->channel->band,
7211 ieee80211_frequency_to_channel(conf->channel->center_freq)); 6641 ieee80211_frequency_to_channel(conf->channel->center_freq));
7212 6642
7213 iwl4965_set_flags_for_phymode(priv, conf->channel->band); 6643 iwl4965_set_flags_for_phymode(priv, conf->channel->band);
@@ -7255,9 +6685,9 @@ out:
7255 return ret; 6685 return ret;
7256} 6686}
7257 6687
7258static void iwl4965_config_ap(struct iwl4965_priv *priv) 6688static void iwl4965_config_ap(struct iwl_priv *priv)
7259{ 6689{
7260 int rc = 0; 6690 int ret = 0;
7261 6691
7262 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 6692 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
7263 return; 6693 return;
@@ -7272,9 +6702,9 @@ static void iwl4965_config_ap(struct iwl4965_priv *priv)
7272 /* RXON Timing */ 6702 /* RXON Timing */
7273 memset(&priv->rxon_timing, 0, sizeof(struct iwl4965_rxon_time_cmd)); 6703 memset(&priv->rxon_timing, 0, sizeof(struct iwl4965_rxon_time_cmd));
7274 iwl4965_setup_rxon_timing(priv); 6704 iwl4965_setup_rxon_timing(priv);
7275 rc = iwl4965_send_cmd_pdu(priv, REPLY_RXON_TIMING, 6705 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
7276 sizeof(priv->rxon_timing), &priv->rxon_timing); 6706 sizeof(priv->rxon_timing), &priv->rxon_timing);
7277 if (rc) 6707 if (ret)
7278 IWL_WARNING("REPLY_RXON_TIMING failed - " 6708 IWL_WARNING("REPLY_RXON_TIMING failed - "
7279 "Attempting to continue.\n"); 6709 "Attempting to continue.\n");
7280 6710
@@ -7319,7 +6749,7 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
7319 struct ieee80211_vif *vif, 6749 struct ieee80211_vif *vif,
7320 struct ieee80211_if_conf *conf) 6750 struct ieee80211_if_conf *conf)
7321{ 6751{
7322 struct iwl4965_priv *priv = hw->priv; 6752 struct iwl_priv *priv = hw->priv;
7323 DECLARE_MAC_BUF(mac); 6753 DECLARE_MAC_BUF(mac);
7324 unsigned long flags; 6754 unsigned long flags;
7325 int rc; 6755 int rc;
@@ -7437,7 +6867,7 @@ static void iwl4965_configure_filter(struct ieee80211_hw *hw,
7437static void iwl4965_mac_remove_interface(struct ieee80211_hw *hw, 6867static void iwl4965_mac_remove_interface(struct ieee80211_hw *hw,
7438 struct ieee80211_if_init_conf *conf) 6868 struct ieee80211_if_init_conf *conf)
7439{ 6869{
7440 struct iwl4965_priv *priv = hw->priv; 6870 struct iwl_priv *priv = hw->priv;
7441 6871
7442 IWL_DEBUG_MAC80211("enter\n"); 6872 IWL_DEBUG_MAC80211("enter\n");
7443 6873
@@ -7466,7 +6896,7 @@ static void iwl4965_bss_info_changed(struct ieee80211_hw *hw,
7466 struct ieee80211_bss_conf *bss_conf, 6896 struct ieee80211_bss_conf *bss_conf,
7467 u32 changes) 6897 u32 changes)
7468{ 6898{
7469 struct iwl4965_priv *priv = hw->priv; 6899 struct iwl_priv *priv = hw->priv;
7470 6900
7471 if (changes & BSS_CHANGED_ERP_PREAMBLE) { 6901 if (changes & BSS_CHANGED_ERP_PREAMBLE) {
7472 if (bss_conf->use_short_preamble) 6902 if (bss_conf->use_short_preamble)
@@ -7497,7 +6927,7 @@ static int iwl4965_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
7497{ 6927{
7498 int rc = 0; 6928 int rc = 0;
7499 unsigned long flags; 6929 unsigned long flags;
7500 struct iwl4965_priv *priv = hw->priv; 6930 struct iwl_priv *priv = hw->priv;
7501 6931
7502 IWL_DEBUG_MAC80211("enter\n"); 6932 IWL_DEBUG_MAC80211("enter\n");
7503 6933
@@ -7550,18 +6980,69 @@ out_unlock:
7550 return rc; 6980 return rc;
7551} 6981}
7552 6982
6983static void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw,
6984 struct ieee80211_key_conf *keyconf, const u8 *addr,
6985 u32 iv32, u16 *phase1key)
6986{
6987 struct iwl_priv *priv = hw->priv;
6988 u8 sta_id = IWL_INVALID_STATION;
6989 unsigned long flags;
6990 __le16 key_flags = 0;
6991 int i;
6992 DECLARE_MAC_BUF(mac);
6993
6994 IWL_DEBUG_MAC80211("enter\n");
6995
6996 sta_id = iwl4965_hw_find_station(priv, addr);
6997 if (sta_id == IWL_INVALID_STATION) {
6998 IWL_DEBUG_MAC80211("leave - %s not in station map.\n",
6999 print_mac(mac, addr));
7000 return;
7001 }
7002
7003 iwl4965_scan_cancel_timeout(priv, 100);
7004
7005 key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
7006 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
7007 key_flags &= ~STA_KEY_FLG_INVALID;
7008
7009 if (sta_id == priv->hw_setting.bcast_sta_id)
7010 key_flags |= STA_KEY_MULTICAST_MSK;
7011
7012 spin_lock_irqsave(&priv->sta_lock, flags);
7013
7014 priv->stations[sta_id].sta.key.key_offset =
7015 (sta_id % STA_KEY_MAX_NUM);/* FIXME */
7016 priv->stations[sta_id].sta.key.key_flags = key_flags;
7017 priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32;
7018
7019 for (i = 0; i < 5; i++)
7020 priv->stations[sta_id].sta.key.tkip_rx_ttak[i] =
7021 cpu_to_le16(phase1key[i]);
7022
7023 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
7024 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
7025
7026 iwl4965_send_add_station(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
7027
7028 spin_unlock_irqrestore(&priv->sta_lock, flags);
7029
7030 IWL_DEBUG_MAC80211("leave\n");
7031}
7032
7553static int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 7033static int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
7554 const u8 *local_addr, const u8 *addr, 7034 const u8 *local_addr, const u8 *addr,
7555 struct ieee80211_key_conf *key) 7035 struct ieee80211_key_conf *key)
7556{ 7036{
7557 struct iwl4965_priv *priv = hw->priv; 7037 struct iwl_priv *priv = hw->priv;
7558 DECLARE_MAC_BUF(mac); 7038 DECLARE_MAC_BUF(mac);
7559 int rc = 0; 7039 int ret = 0;
7560 u8 sta_id; 7040 u8 sta_id = IWL_INVALID_STATION;
7041 u8 static_key;
7561 7042
7562 IWL_DEBUG_MAC80211("enter\n"); 7043 IWL_DEBUG_MAC80211("enter\n");
7563 7044
7564 if (!iwl4965_param_hwcrypto) { 7045 if (!priv->cfg->mod_params->hw_crypto) {
7565 IWL_DEBUG_MAC80211("leave - hwcrypto disabled\n"); 7046 IWL_DEBUG_MAC80211("leave - hwcrypto disabled\n");
7566 return -EOPNOTSUPP; 7047 return -EOPNOTSUPP;
7567 } 7048 }
@@ -7570,50 +7051,51 @@ static int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
7570 /* only support pairwise keys */ 7051 /* only support pairwise keys */
7571 return -EOPNOTSUPP; 7052 return -EOPNOTSUPP;
7572 7053
7573 sta_id = iwl4965_hw_find_station(priv, addr); 7054 /* FIXME: need to differenciate between static and dynamic key
7574 if (sta_id == IWL_INVALID_STATION) { 7055 * in the level of mac80211 */
7575 IWL_DEBUG_MAC80211("leave - %s not in station map.\n", 7056 static_key = !iwl4965_is_associated(priv);
7576 print_mac(mac, addr));
7577 return -EINVAL;
7578 }
7579 7057
7580 mutex_lock(&priv->mutex); 7058 if (!static_key) {
7059 sta_id = iwl4965_hw_find_station(priv, addr);
7060 if (sta_id == IWL_INVALID_STATION) {
7061 IWL_DEBUG_MAC80211("leave - %s not in station map.\n",
7062 print_mac(mac, addr));
7063 return -EINVAL;
7064 }
7065 }
7581 7066
7582 iwl4965_scan_cancel_timeout(priv, 100); 7067 iwl4965_scan_cancel_timeout(priv, 100);
7583 7068
7584 switch (cmd) { 7069 switch (cmd) {
7585 case SET_KEY: 7070 case SET_KEY:
7586 rc = iwl4965_update_sta_key_info(priv, key, sta_id); 7071 if (static_key)
7587 if (!rc) { 7072 ret = iwl4965_set_static_key(priv, key);
7588 iwl4965_set_rxon_hwcrypto(priv, 1); 7073 else
7589 iwl4965_commit_rxon(priv); 7074 ret = iwl4965_set_dynamic_key(priv, key, sta_id);
7590 key->hw_key_idx = sta_id; 7075
7591 IWL_DEBUG_MAC80211("set_key success, using hwcrypto\n"); 7076 IWL_DEBUG_MAC80211("enable hwcrypto key\n");
7592 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
7593 }
7594 break; 7077 break;
7595 case DISABLE_KEY: 7078 case DISABLE_KEY:
7596 rc = iwl4965_clear_sta_key_info(priv, sta_id); 7079 if (static_key)
7597 if (!rc) { 7080 ret = iwl4965_remove_static_key(priv);
7598 iwl4965_set_rxon_hwcrypto(priv, 0); 7081 else
7599 iwl4965_commit_rxon(priv); 7082 ret = iwl4965_clear_sta_key_info(priv, sta_id);
7600 IWL_DEBUG_MAC80211("disable hwcrypto key\n"); 7083
7601 } 7084 IWL_DEBUG_MAC80211("disable hwcrypto key\n");
7602 break; 7085 break;
7603 default: 7086 default:
7604 rc = -EINVAL; 7087 ret = -EINVAL;
7605 } 7088 }
7606 7089
7607 IWL_DEBUG_MAC80211("leave\n"); 7090 IWL_DEBUG_MAC80211("leave\n");
7608 mutex_unlock(&priv->mutex);
7609 7091
7610 return rc; 7092 return ret;
7611} 7093}
7612 7094
7613static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, int queue, 7095static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, int queue,
7614 const struct ieee80211_tx_queue_params *params) 7096 const struct ieee80211_tx_queue_params *params)
7615{ 7097{
7616 struct iwl4965_priv *priv = hw->priv; 7098 struct iwl_priv *priv = hw->priv;
7617 unsigned long flags; 7099 unsigned long flags;
7618 int q; 7100 int q;
7619 7101
@@ -7664,7 +7146,7 @@ static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, int queue,
7664static int iwl4965_mac_get_tx_stats(struct ieee80211_hw *hw, 7146static int iwl4965_mac_get_tx_stats(struct ieee80211_hw *hw,
7665 struct ieee80211_tx_queue_stats *stats) 7147 struct ieee80211_tx_queue_stats *stats)
7666{ 7148{
7667 struct iwl4965_priv *priv = hw->priv; 7149 struct iwl_priv *priv = hw->priv;
7668 int i, avail; 7150 int i, avail;
7669 struct iwl4965_tx_queue *txq; 7151 struct iwl4965_tx_queue *txq;
7670 struct iwl4965_queue *q; 7152 struct iwl4965_queue *q;
@@ -7715,7 +7197,7 @@ static u64 iwl4965_mac_get_tsf(struct ieee80211_hw *hw)
7715 7197
7716static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw) 7198static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
7717{ 7199{
7718 struct iwl4965_priv *priv = hw->priv; 7200 struct iwl_priv *priv = hw->priv;
7719 unsigned long flags; 7201 unsigned long flags;
7720 7202
7721 mutex_lock(&priv->mutex); 7203 mutex_lock(&priv->mutex);
@@ -7728,7 +7210,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
7728 spin_unlock_irqrestore(&priv->lock, flags); 7210 spin_unlock_irqrestore(&priv->lock, flags);
7729#endif /* CONFIG_IWL4965_HT */ 7211#endif /* CONFIG_IWL4965_HT */
7730 7212
7731 iwl4965_reset_qos(priv); 7213 iwlcore_reset_qos(priv);
7732 7214
7733 cancel_delayed_work(&priv->post_associate); 7215 cancel_delayed_work(&priv->post_associate);
7734 7216
@@ -7787,7 +7269,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
7787static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, 7269static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
7788 struct ieee80211_tx_control *control) 7270 struct ieee80211_tx_control *control)
7789{ 7271{
7790 struct iwl4965_priv *priv = hw->priv; 7272 struct iwl_priv *priv = hw->priv;
7791 unsigned long flags; 7273 unsigned long flags;
7792 7274
7793 mutex_lock(&priv->mutex); 7275 mutex_lock(&priv->mutex);
@@ -7817,7 +7299,7 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
7817 IWL_DEBUG_MAC80211("leave\n"); 7299 IWL_DEBUG_MAC80211("leave\n");
7818 spin_unlock_irqrestore(&priv->lock, flags); 7300 spin_unlock_irqrestore(&priv->lock, flags);
7819 7301
7820 iwl4965_reset_qos(priv); 7302 iwlcore_reset_qos(priv);
7821 7303
7822 queue_work(priv->workqueue, &priv->post_associate.work); 7304 queue_work(priv->workqueue, &priv->post_associate.work);
7823 7305
@@ -7829,7 +7311,7 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
7829#ifdef CONFIG_IWL4965_HT 7311#ifdef CONFIG_IWL4965_HT
7830 7312
7831static void iwl4965_ht_info_fill(struct ieee80211_conf *conf, 7313static void iwl4965_ht_info_fill(struct ieee80211_conf *conf,
7832 struct iwl4965_priv *priv) 7314 struct iwl_priv *priv)
7833{ 7315{
7834 struct iwl_ht_info *iwl_conf = &priv->current_ht_config; 7316 struct iwl_ht_info *iwl_conf = &priv->current_ht_config;
7835 struct ieee80211_ht_info *ht_conf = &conf->ht_conf; 7317 struct ieee80211_ht_info *ht_conf = &conf->ht_conf;
@@ -7883,7 +7365,7 @@ static void iwl4965_ht_info_fill(struct ieee80211_conf *conf,
7883static int iwl4965_mac_conf_ht(struct ieee80211_hw *hw, 7365static int iwl4965_mac_conf_ht(struct ieee80211_hw *hw,
7884 struct ieee80211_conf *conf) 7366 struct ieee80211_conf *conf)
7885{ 7367{
7886 struct iwl4965_priv *priv = hw->priv; 7368 struct iwl_priv *priv = hw->priv;
7887 7369
7888 IWL_DEBUG_MAC80211("enter: \n"); 7370 IWL_DEBUG_MAC80211("enter: \n");
7889 7371
@@ -7914,7 +7396,7 @@ static int iwl4965_mac_conf_ht(struct ieee80211_hw *hw,
7914 * 7396 *
7915 *****************************************************************************/ 7397 *****************************************************************************/
7916 7398
7917#ifdef CONFIG_IWL4965_DEBUG 7399#ifdef CONFIG_IWLWIFI_DEBUG
7918 7400
7919/* 7401/*
7920 * The following adds a new attribute to the sysfs representation 7402 * The following adds a new attribute to the sysfs representation
@@ -7926,7 +7408,7 @@ static int iwl4965_mac_conf_ht(struct ieee80211_hw *hw,
7926 7408
7927static ssize_t show_debug_level(struct device_driver *d, char *buf) 7409static ssize_t show_debug_level(struct device_driver *d, char *buf)
7928{ 7410{
7929 return sprintf(buf, "0x%08X\n", iwl4965_debug_level); 7411 return sprintf(buf, "0x%08X\n", iwl_debug_level);
7930} 7412}
7931static ssize_t store_debug_level(struct device_driver *d, 7413static ssize_t store_debug_level(struct device_driver *d,
7932 const char *buf, size_t count) 7414 const char *buf, size_t count)
@@ -7939,7 +7421,7 @@ static ssize_t store_debug_level(struct device_driver *d,
7939 printk(KERN_INFO DRV_NAME 7421 printk(KERN_INFO DRV_NAME
7940 ": %s is not in hex or decimal form.\n", buf); 7422 ": %s is not in hex or decimal form.\n", buf);
7941 else 7423 else
7942 iwl4965_debug_level = val; 7424 iwl_debug_level = val;
7943 7425
7944 return strnlen(buf, count); 7426 return strnlen(buf, count);
7945} 7427}
@@ -7947,7 +7429,7 @@ static ssize_t store_debug_level(struct device_driver *d,
7947static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, 7429static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO,
7948 show_debug_level, store_debug_level); 7430 show_debug_level, store_debug_level);
7949 7431
7950#endif /* CONFIG_IWL4965_DEBUG */ 7432#endif /* CONFIG_IWLWIFI_DEBUG */
7951 7433
7952static ssize_t show_rf_kill(struct device *d, 7434static ssize_t show_rf_kill(struct device *d,
7953 struct device_attribute *attr, char *buf) 7435 struct device_attribute *attr, char *buf)
@@ -7958,7 +7440,7 @@ static ssize_t show_rf_kill(struct device *d,
7958 * 2 - HW based RF kill active 7440 * 2 - HW based RF kill active
7959 * 3 - Both HW and SW based RF kill active 7441 * 3 - Both HW and SW based RF kill active
7960 */ 7442 */
7961 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 7443 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
7962 int val = (test_bit(STATUS_RF_KILL_SW, &priv->status) ? 0x1 : 0x0) | 7444 int val = (test_bit(STATUS_RF_KILL_SW, &priv->status) ? 0x1 : 0x0) |
7963 (test_bit(STATUS_RF_KILL_HW, &priv->status) ? 0x2 : 0x0); 7445 (test_bit(STATUS_RF_KILL_HW, &priv->status) ? 0x2 : 0x0);
7964 7446
@@ -7969,7 +7451,7 @@ static ssize_t store_rf_kill(struct device *d,
7969 struct device_attribute *attr, 7451 struct device_attribute *attr,
7970 const char *buf, size_t count) 7452 const char *buf, size_t count)
7971{ 7453{
7972 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 7454 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
7973 7455
7974 mutex_lock(&priv->mutex); 7456 mutex_lock(&priv->mutex);
7975 iwl4965_radio_kill_sw(priv, buf[0] == '1'); 7457 iwl4965_radio_kill_sw(priv, buf[0] == '1');
@@ -7983,7 +7465,7 @@ static DEVICE_ATTR(rf_kill, S_IWUSR | S_IRUGO, show_rf_kill, store_rf_kill);
7983static ssize_t show_temperature(struct device *d, 7465static ssize_t show_temperature(struct device *d,
7984 struct device_attribute *attr, char *buf) 7466 struct device_attribute *attr, char *buf)
7985{ 7467{
7986 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 7468 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
7987 7469
7988 if (!iwl4965_is_alive(priv)) 7470 if (!iwl4965_is_alive(priv))
7989 return -EAGAIN; 7471 return -EAGAIN;
@@ -7997,7 +7479,7 @@ static ssize_t show_rs_window(struct device *d,
7997 struct device_attribute *attr, 7479 struct device_attribute *attr,
7998 char *buf) 7480 char *buf)
7999{ 7481{
8000 struct iwl4965_priv *priv = d->driver_data; 7482 struct iwl_priv *priv = d->driver_data;
8001 return iwl4965_fill_rs_info(priv->hw, buf, IWL_AP_ID); 7483 return iwl4965_fill_rs_info(priv->hw, buf, IWL_AP_ID);
8002} 7484}
8003static DEVICE_ATTR(rs_window, S_IRUGO, show_rs_window, NULL); 7485static DEVICE_ATTR(rs_window, S_IRUGO, show_rs_window, NULL);
@@ -8005,7 +7487,7 @@ static DEVICE_ATTR(rs_window, S_IRUGO, show_rs_window, NULL);
8005static ssize_t show_tx_power(struct device *d, 7487static ssize_t show_tx_power(struct device *d,
8006 struct device_attribute *attr, char *buf) 7488 struct device_attribute *attr, char *buf)
8007{ 7489{
8008 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 7490 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
8009 return sprintf(buf, "%d\n", priv->user_txpower_limit); 7491 return sprintf(buf, "%d\n", priv->user_txpower_limit);
8010} 7492}
8011 7493
@@ -8013,7 +7495,7 @@ static ssize_t store_tx_power(struct device *d,
8013 struct device_attribute *attr, 7495 struct device_attribute *attr,
8014 const char *buf, size_t count) 7496 const char *buf, size_t count)
8015{ 7497{
8016 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 7498 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
8017 char *p = (char *)buf; 7499 char *p = (char *)buf;
8018 u32 val; 7500 u32 val;
8019 7501
@@ -8032,7 +7514,7 @@ static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
8032static ssize_t show_flags(struct device *d, 7514static ssize_t show_flags(struct device *d,
8033 struct device_attribute *attr, char *buf) 7515 struct device_attribute *attr, char *buf)
8034{ 7516{
8035 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 7517 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
8036 7518
8037 return sprintf(buf, "0x%04X\n", priv->active_rxon.flags); 7519 return sprintf(buf, "0x%04X\n", priv->active_rxon.flags);
8038} 7520}
@@ -8041,7 +7523,7 @@ static ssize_t store_flags(struct device *d,
8041 struct device_attribute *attr, 7523 struct device_attribute *attr,
8042 const char *buf, size_t count) 7524 const char *buf, size_t count)
8043{ 7525{
8044 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 7526 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
8045 u32 flags = simple_strtoul(buf, NULL, 0); 7527 u32 flags = simple_strtoul(buf, NULL, 0);
8046 7528
8047 mutex_lock(&priv->mutex); 7529 mutex_lock(&priv->mutex);
@@ -8066,7 +7548,7 @@ static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, show_flags, store_flags);
8066static ssize_t show_filter_flags(struct device *d, 7548static ssize_t show_filter_flags(struct device *d,
8067 struct device_attribute *attr, char *buf) 7549 struct device_attribute *attr, char *buf)
8068{ 7550{
8069 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 7551 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
8070 7552
8071 return sprintf(buf, "0x%04X\n", 7553 return sprintf(buf, "0x%04X\n",
8072 le32_to_cpu(priv->active_rxon.filter_flags)); 7554 le32_to_cpu(priv->active_rxon.filter_flags));
@@ -8076,7 +7558,7 @@ static ssize_t store_filter_flags(struct device *d,
8076 struct device_attribute *attr, 7558 struct device_attribute *attr,
8077 const char *buf, size_t count) 7559 const char *buf, size_t count)
8078{ 7560{
8079 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 7561 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
8080 u32 filter_flags = simple_strtoul(buf, NULL, 0); 7562 u32 filter_flags = simple_strtoul(buf, NULL, 0);
8081 7563
8082 mutex_lock(&priv->mutex); 7564 mutex_lock(&priv->mutex);
@@ -8105,7 +7587,7 @@ static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags,
8105static ssize_t show_measurement(struct device *d, 7587static ssize_t show_measurement(struct device *d,
8106 struct device_attribute *attr, char *buf) 7588 struct device_attribute *attr, char *buf)
8107{ 7589{
8108 struct iwl4965_priv *priv = dev_get_drvdata(d); 7590 struct iwl_priv *priv = dev_get_drvdata(d);
8109 struct iwl4965_spectrum_notification measure_report; 7591 struct iwl4965_spectrum_notification measure_report;
8110 u32 size = sizeof(measure_report), len = 0, ofs = 0; 7592 u32 size = sizeof(measure_report), len = 0, ofs = 0;
8111 u8 *data = (u8 *) & measure_report; 7593 u8 *data = (u8 *) & measure_report;
@@ -8138,7 +7620,7 @@ static ssize_t store_measurement(struct device *d,
8138 struct device_attribute *attr, 7620 struct device_attribute *attr,
8139 const char *buf, size_t count) 7621 const char *buf, size_t count)
8140{ 7622{
8141 struct iwl4965_priv *priv = dev_get_drvdata(d); 7623 struct iwl_priv *priv = dev_get_drvdata(d);
8142 struct ieee80211_measurement_params params = { 7624 struct ieee80211_measurement_params params = {
8143 .channel = le16_to_cpu(priv->active_rxon.channel), 7625 .channel = le16_to_cpu(priv->active_rxon.channel),
8144 .start_time = cpu_to_le64(priv->last_tsf), 7626 .start_time = cpu_to_le64(priv->last_tsf),
@@ -8177,7 +7659,7 @@ static ssize_t store_retry_rate(struct device *d,
8177 struct device_attribute *attr, 7659 struct device_attribute *attr,
8178 const char *buf, size_t count) 7660 const char *buf, size_t count)
8179{ 7661{
8180 struct iwl4965_priv *priv = dev_get_drvdata(d); 7662 struct iwl_priv *priv = dev_get_drvdata(d);
8181 7663
8182 priv->retry_rate = simple_strtoul(buf, NULL, 0); 7664 priv->retry_rate = simple_strtoul(buf, NULL, 0);
8183 if (priv->retry_rate <= 0) 7665 if (priv->retry_rate <= 0)
@@ -8189,7 +7671,7 @@ static ssize_t store_retry_rate(struct device *d,
8189static ssize_t show_retry_rate(struct device *d, 7671static ssize_t show_retry_rate(struct device *d,
8190 struct device_attribute *attr, char *buf) 7672 struct device_attribute *attr, char *buf)
8191{ 7673{
8192 struct iwl4965_priv *priv = dev_get_drvdata(d); 7674 struct iwl_priv *priv = dev_get_drvdata(d);
8193 return sprintf(buf, "%d", priv->retry_rate); 7675 return sprintf(buf, "%d", priv->retry_rate);
8194} 7676}
8195 7677
@@ -8200,7 +7682,7 @@ static ssize_t store_power_level(struct device *d,
8200 struct device_attribute *attr, 7682 struct device_attribute *attr,
8201 const char *buf, size_t count) 7683 const char *buf, size_t count)
8202{ 7684{
8203 struct iwl4965_priv *priv = dev_get_drvdata(d); 7685 struct iwl_priv *priv = dev_get_drvdata(d);
8204 int rc; 7686 int rc;
8205 int mode; 7687 int mode;
8206 7688
@@ -8254,7 +7736,7 @@ static const s32 period_duration[] = {
8254static ssize_t show_power_level(struct device *d, 7736static ssize_t show_power_level(struct device *d,
8255 struct device_attribute *attr, char *buf) 7737 struct device_attribute *attr, char *buf)
8256{ 7738{
8257 struct iwl4965_priv *priv = dev_get_drvdata(d); 7739 struct iwl_priv *priv = dev_get_drvdata(d);
8258 int level = IWL_POWER_LEVEL(priv->power_mode); 7740 int level = IWL_POWER_LEVEL(priv->power_mode);
8259 char *p = buf; 7741 char *p = buf;
8260 7742
@@ -8298,7 +7780,7 @@ static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL);
8298static ssize_t show_statistics(struct device *d, 7780static ssize_t show_statistics(struct device *d,
8299 struct device_attribute *attr, char *buf) 7781 struct device_attribute *attr, char *buf)
8300{ 7782{
8301 struct iwl4965_priv *priv = dev_get_drvdata(d); 7783 struct iwl_priv *priv = dev_get_drvdata(d);
8302 u32 size = sizeof(struct iwl4965_notif_statistics); 7784 u32 size = sizeof(struct iwl4965_notif_statistics);
8303 u32 len = 0, ofs = 0; 7785 u32 len = 0, ofs = 0;
8304 u8 *data = (u8 *) & priv->statistics; 7786 u8 *data = (u8 *) & priv->statistics;
@@ -8336,7 +7818,7 @@ static DEVICE_ATTR(statistics, S_IRUGO, show_statistics, NULL);
8336static ssize_t show_antenna(struct device *d, 7818static ssize_t show_antenna(struct device *d,
8337 struct device_attribute *attr, char *buf) 7819 struct device_attribute *attr, char *buf)
8338{ 7820{
8339 struct iwl4965_priv *priv = dev_get_drvdata(d); 7821 struct iwl_priv *priv = dev_get_drvdata(d);
8340 7822
8341 if (!iwl4965_is_alive(priv)) 7823 if (!iwl4965_is_alive(priv))
8342 return -EAGAIN; 7824 return -EAGAIN;
@@ -8349,7 +7831,7 @@ static ssize_t store_antenna(struct device *d,
8349 const char *buf, size_t count) 7831 const char *buf, size_t count)
8350{ 7832{
8351 int ant; 7833 int ant;
8352 struct iwl4965_priv *priv = dev_get_drvdata(d); 7834 struct iwl_priv *priv = dev_get_drvdata(d);
8353 7835
8354 if (count == 0) 7836 if (count == 0)
8355 return 0; 7837 return 0;
@@ -8374,7 +7856,7 @@ static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, show_antenna, store_antenna);
8374static ssize_t show_status(struct device *d, 7856static ssize_t show_status(struct device *d,
8375 struct device_attribute *attr, char *buf) 7857 struct device_attribute *attr, char *buf)
8376{ 7858{
8377 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 7859 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
8378 if (!iwl4965_is_alive(priv)) 7860 if (!iwl4965_is_alive(priv))
8379 return -EAGAIN; 7861 return -EAGAIN;
8380 return sprintf(buf, "0x%08x\n", (int)priv->status); 7862 return sprintf(buf, "0x%08x\n", (int)priv->status);
@@ -8389,7 +7871,7 @@ static ssize_t dump_error_log(struct device *d,
8389 char *p = (char *)buf; 7871 char *p = (char *)buf;
8390 7872
8391 if (p[0] == '1') 7873 if (p[0] == '1')
8392 iwl4965_dump_nic_error_log((struct iwl4965_priv *)d->driver_data); 7874 iwl4965_dump_nic_error_log((struct iwl_priv *)d->driver_data);
8393 7875
8394 return strnlen(buf, count); 7876 return strnlen(buf, count);
8395} 7877}
@@ -8403,7 +7885,7 @@ static ssize_t dump_event_log(struct device *d,
8403 char *p = (char *)buf; 7885 char *p = (char *)buf;
8404 7886
8405 if (p[0] == '1') 7887 if (p[0] == '1')
8406 iwl4965_dump_nic_event_log((struct iwl4965_priv *)d->driver_data); 7888 iwl4965_dump_nic_event_log((struct iwl_priv *)d->driver_data);
8407 7889
8408 return strnlen(buf, count); 7890 return strnlen(buf, count);
8409} 7891}
@@ -8416,7 +7898,7 @@ static DEVICE_ATTR(dump_events, S_IWUSR, NULL, dump_event_log);
8416 * 7898 *
8417 *****************************************************************************/ 7899 *****************************************************************************/
8418 7900
8419static void iwl4965_setup_deferred_work(struct iwl4965_priv *priv) 7901static void iwl4965_setup_deferred_work(struct iwl_priv *priv)
8420{ 7902{
8421 priv->workqueue = create_workqueue(DRV_NAME); 7903 priv->workqueue = create_workqueue(DRV_NAME);
8422 7904
@@ -8441,7 +7923,7 @@ static void iwl4965_setup_deferred_work(struct iwl4965_priv *priv)
8441 iwl4965_irq_tasklet, (unsigned long)priv); 7923 iwl4965_irq_tasklet, (unsigned long)priv);
8442} 7924}
8443 7925
8444static void iwl4965_cancel_deferred_work(struct iwl4965_priv *priv) 7926static void iwl4965_cancel_deferred_work(struct iwl_priv *priv)
8445{ 7927{
8446 iwl4965_hw_cancel_deferred_work(priv); 7928 iwl4965_hw_cancel_deferred_work(priv);
8447 7929
@@ -8489,6 +7971,7 @@ static struct ieee80211_ops iwl4965_hw_ops = {
8489 .config_interface = iwl4965_mac_config_interface, 7971 .config_interface = iwl4965_mac_config_interface,
8490 .configure_filter = iwl4965_configure_filter, 7972 .configure_filter = iwl4965_configure_filter,
8491 .set_key = iwl4965_mac_set_key, 7973 .set_key = iwl4965_mac_set_key,
7974 .update_tkip_key = iwl4965_mac_update_tkip_key,
8492 .get_stats = iwl4965_mac_get_stats, 7975 .get_stats = iwl4965_mac_get_stats,
8493 .get_tx_stats = iwl4965_mac_get_tx_stats, 7976 .get_tx_stats = iwl4965_mac_get_tx_stats,
8494 .conf_tx = iwl4965_mac_conf_tx, 7977 .conf_tx = iwl4965_mac_conf_tx,
@@ -8506,85 +7989,44 @@ static struct ieee80211_ops iwl4965_hw_ops = {
8506static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 7989static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8507{ 7990{
8508 int err = 0; 7991 int err = 0;
8509 struct iwl4965_priv *priv; 7992 struct iwl_priv *priv;
8510 struct ieee80211_hw *hw; 7993 struct ieee80211_hw *hw;
8511 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); 7994 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
8512 int i;
8513 DECLARE_MAC_BUF(mac); 7995 DECLARE_MAC_BUF(mac);
8514 7996
7997 /************************
7998 * 1. Allocating HW data
7999 ************************/
8000
8515 /* Disabling hardware scan means that mac80211 will perform scans 8001 /* Disabling hardware scan means that mac80211 will perform scans
8516 * "the hard way", rather than using device's scan. */ 8002 * "the hard way", rather than using device's scan. */
8517 if (iwl4965_param_disable_hw_scan) { 8003 if (cfg->mod_params->disable_hw_scan) {
8518 IWL_DEBUG_INFO("Disabling hw_scan\n"); 8004 IWL_DEBUG_INFO("Disabling hw_scan\n");
8519 iwl4965_hw_ops.hw_scan = NULL; 8005 iwl4965_hw_ops.hw_scan = NULL;
8520 } 8006 }
8521 8007
8522 if ((iwl4965_param_queues_num > IWL_MAX_NUM_QUEUES) || 8008 hw = iwl_alloc_all(cfg, &iwl4965_hw_ops);
8523 (iwl4965_param_queues_num < IWL_MIN_NUM_QUEUES)) { 8009 if (!hw) {
8524 IWL_ERROR("invalid queues_num, should be between %d and %d\n",
8525 IWL_MIN_NUM_QUEUES, IWL_MAX_NUM_QUEUES);
8526 err = -EINVAL;
8527 goto out;
8528 }
8529
8530 /* mac80211 allocates memory for this device instance, including
8531 * space for this driver's private structure */
8532 hw = ieee80211_alloc_hw(sizeof(struct iwl4965_priv), &iwl4965_hw_ops);
8533 if (hw == NULL) {
8534 IWL_ERROR("Can not allocate network device\n");
8535 err = -ENOMEM; 8010 err = -ENOMEM;
8536 goto out; 8011 goto out;
8537 } 8012 }
8538 SET_IEEE80211_DEV(hw, &pdev->dev); 8013 priv = hw->priv;
8014 /* At this point both hw and priv are allocated. */
8539 8015
8540 hw->rate_control_algorithm = "iwl-4965-rs"; 8016 SET_IEEE80211_DEV(hw, &pdev->dev);
8541 8017
8542 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 8018 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
8543 priv = hw->priv;
8544 priv->hw = hw;
8545 priv->cfg = cfg; 8019 priv->cfg = cfg;
8546
8547 priv->pci_dev = pdev; 8020 priv->pci_dev = pdev;
8548 priv->antenna = (enum iwl4965_antenna)iwl4965_param_antenna; 8021
8549#ifdef CONFIG_IWL4965_DEBUG 8022#ifdef CONFIG_IWLWIFI_DEBUG
8550 iwl4965_debug_level = iwl4965_param_debug; 8023 iwl_debug_level = priv->cfg->mod_params->debug;
8551 atomic_set(&priv->restrict_refcnt, 0); 8024 atomic_set(&priv->restrict_refcnt, 0);
8552#endif 8025#endif
8553 priv->retry_rate = 1;
8554
8555 priv->ibss_beacon = NULL;
8556
8557 /* Tell mac80211 and its clients (e.g. Wireless Extensions)
8558 * the range of signal quality values that we'll provide.
8559 * Negative values for level/noise indicate that we'll provide dBm.
8560 * For WE, at least, non-0 values here *enable* display of values
8561 * in app (iwconfig). */
8562 hw->max_rssi = -20; /* signal level, negative indicates dBm */
8563 hw->max_noise = -20; /* noise level, negative indicates dBm */
8564 hw->max_signal = 100; /* link quality indication (%) */
8565
8566 /* Tell mac80211 our Tx characteristics */
8567 hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE;
8568
8569 /* Default value; 4 EDCA QOS priorities */
8570 hw->queues = 4;
8571#ifdef CONFIG_IWL4965_HT
8572 /* Enhanced value; more queues, to support 11n aggregation */
8573 hw->queues = 16;
8574#endif /* CONFIG_IWL4965_HT */
8575
8576 spin_lock_init(&priv->lock);
8577 spin_lock_init(&priv->power_data.lock);
8578 spin_lock_init(&priv->sta_lock);
8579 spin_lock_init(&priv->hcmd_lock);
8580 spin_lock_init(&priv->lq_mngr.lock);
8581
8582 for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++)
8583 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
8584
8585 INIT_LIST_HEAD(&priv->free_frames);
8586 8026
8587 mutex_init(&priv->mutex); 8027 /**************************
8028 * 2. Initializing PCI bus
8029 **************************/
8588 if (pci_enable_device(pdev)) { 8030 if (pci_enable_device(pdev)) {
8589 err = -ENODEV; 8031 err = -ENODEV;
8590 goto out_ieee80211_free_hw; 8032 goto out_ieee80211_free_hw;
@@ -8592,31 +8034,28 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8592 8034
8593 pci_set_master(pdev); 8035 pci_set_master(pdev);
8594 8036
8595 /* Clear the driver's (not device's) station table */
8596 iwl4965_clear_stations_table(priv);
8597
8598 priv->data_retry_limit = -1;
8599 priv->ieee_channels = NULL;
8600 priv->ieee_rates = NULL;
8601 priv->band = IEEE80211_BAND_2GHZ;
8602
8603 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 8037 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
8604 if (!err) 8038 if (!err)
8605 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 8039 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
8606 if (err) { 8040 if (err) {
8607 printk(KERN_WARNING DRV_NAME ": No suitable DMA available.\n"); 8041 printk(KERN_WARNING DRV_NAME
8608 goto out_pci_disable_device; 8042 ": No suitable DMA available.\n");
8043 goto out_pci_disable_device;
8609 } 8044 }
8610 8045
8611 pci_set_drvdata(pdev, priv);
8612 err = pci_request_regions(pdev, DRV_NAME); 8046 err = pci_request_regions(pdev, DRV_NAME);
8613 if (err) 8047 if (err)
8614 goto out_pci_disable_device; 8048 goto out_pci_disable_device;
8615 8049
8050 pci_set_drvdata(pdev, priv);
8051
8616 /* We disable the RETRY_TIMEOUT register (0x41) to keep 8052 /* We disable the RETRY_TIMEOUT register (0x41) to keep
8617 * PCI Tx retries from interfering with C3 CPU state */ 8053 * PCI Tx retries from interfering with C3 CPU state */
8618 pci_write_config_byte(pdev, 0x41, 0x00); 8054 pci_write_config_byte(pdev, 0x41, 0x00);
8619 8055
8056 /***********************
8057 * 3. Read REV register
8058 ***********************/
8620 priv->hw_base = pci_iomap(pdev, 0, 0); 8059 priv->hw_base = pci_iomap(pdev, 0, 0);
8621 if (!priv->hw_base) { 8060 if (!priv->hw_base) {
8622 err = -ENODEV; 8061 err = -ENODEV;
@@ -8624,130 +8063,108 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8624 } 8063 }
8625 8064
8626 IWL_DEBUG_INFO("pci_resource_len = 0x%08llx\n", 8065 IWL_DEBUG_INFO("pci_resource_len = 0x%08llx\n",
8627 (unsigned long long) pci_resource_len(pdev, 0)); 8066 (unsigned long long) pci_resource_len(pdev, 0));
8628 IWL_DEBUG_INFO("pci_resource_base = %p\n", priv->hw_base); 8067 IWL_DEBUG_INFO("pci_resource_base = %p\n", priv->hw_base);
8629 8068
8630 /* Initialize module parameter values here */
8631
8632 /* Disable radio (SW RF KILL) via parameter when loading driver */
8633 if (iwl4965_param_disable) {
8634 set_bit(STATUS_RF_KILL_SW, &priv->status);
8635 IWL_DEBUG_INFO("Radio disabled.\n");
8636 }
8637
8638 priv->iw_mode = IEEE80211_IF_TYPE_STA;
8639
8640 priv->ps_mode = 0;
8641 priv->use_ant_b_for_management_frame = 1; /* start with ant B */
8642 priv->valid_antenna = 0x7; /* assume all 3 connected */
8643 priv->ps_mode = IWL_MIMO_PS_NONE;
8644
8645 /* Choose which receivers/antennas to use */
8646 iwl4965_set_rxon_chain(priv);
8647
8648
8649 printk(KERN_INFO DRV_NAME 8069 printk(KERN_INFO DRV_NAME
8650 ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name); 8070 ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name);
8651 8071
8072 /*****************
8073 * 4. Read EEPROM
8074 *****************/
8075 /* nic init */
8076 iwl4965_set_bit(priv, CSR_GIO_CHICKEN_BITS,
8077 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
8078
8079 iwl4965_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
8080 err = iwl4965_poll_bit(priv, CSR_GP_CNTRL,
8081 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
8082 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
8083 if (err < 0) {
8084 IWL_DEBUG_INFO("Failed to init the card\n");
8085 goto out_iounmap;
8086 }
8087 /* Read the EEPROM */
8088 err = iwl_eeprom_init(priv);
8089 if (err) {
8090 IWL_ERROR("Unable to init EEPROM\n");
8091 goto out_iounmap;
8092 }
8093 /* MAC Address location in EEPROM same for 3945/4965 */
8094 iwl_eeprom_get_mac(priv, priv->mac_addr);
8095 IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr));
8096 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
8097
8098 /************************
8099 * 5. Setup HW constants
8100 ************************/
8652 /* Device-specific setup */ 8101 /* Device-specific setup */
8653 if (iwl4965_hw_set_hw_setting(priv)) { 8102 if (iwl4965_hw_set_hw_setting(priv)) {
8654 IWL_ERROR("failed to set hw settings\n"); 8103 IWL_ERROR("failed to set hw settings\n");
8655 goto out_iounmap; 8104 goto out_iounmap;
8656 } 8105 }
8657 8106
8658 if (iwl4965_param_qos_enable) 8107 /*******************
8659 priv->qos_data.qos_enable = 1; 8108 * 6. Setup hw/priv
8109 *******************/
8660 8110
8661 iwl4965_reset_qos(priv); 8111 err = iwl_setup(priv);
8112 if (err)
8113 goto out_unset_hw_settings;
8114 /* At this point both hw and priv are initialized. */
8662 8115
8663 priv->qos_data.qos_active = 0; 8116 /**********************************
8664 priv->qos_data.qos_cap.val = 0; 8117 * 7. Initialize module parameters
8118 **********************************/
8665 8119
8666 iwl4965_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); 8120 /* Disable radio (SW RF KILL) via parameter when loading driver */
8667 iwl4965_setup_deferred_work(priv); 8121 if (priv->cfg->mod_params->disable) {
8668 iwl4965_setup_rx_handlers(priv); 8122 set_bit(STATUS_RF_KILL_SW, &priv->status);
8123 IWL_DEBUG_INFO("Radio disabled.\n");
8124 }
8669 8125
8670 priv->rates_mask = IWL_RATES_MASK; 8126 if (priv->cfg->mod_params->enable_qos)
8671 /* If power management is turned on, default to AC mode */ 8127 priv->qos_data.qos_enable = 1;
8672 priv->power_mode = IWL_POWER_AC;
8673 priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
8674 8128
8129 /********************
8130 * 8. Setup services
8131 ********************/
8675 iwl4965_disable_interrupts(priv); 8132 iwl4965_disable_interrupts(priv);
8676 8133
8677 err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group); 8134 err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group);
8678 if (err) { 8135 if (err) {
8679 IWL_ERROR("failed to create sysfs device attributes\n"); 8136 IWL_ERROR("failed to create sysfs device attributes\n");
8680 goto out_release_irq; 8137 goto out_unset_hw_settings;
8681 } 8138 }
8682 8139
8683 /* nic init */ 8140 err = iwl_dbgfs_register(priv, DRV_NAME);
8684 iwl4965_set_bit(priv, CSR_GIO_CHICKEN_BITS,
8685 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
8686
8687 iwl4965_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
8688 err = iwl4965_poll_bit(priv, CSR_GP_CNTRL,
8689 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
8690 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
8691 if (err < 0) {
8692 IWL_DEBUG_INFO("Failed to init the card\n");
8693 goto out_remove_sysfs;
8694 }
8695 /* Read the EEPROM */
8696 err = iwl_eeprom_init(priv);
8697 if (err) { 8141 if (err) {
8698 IWL_ERROR("Unable to init EEPROM\n"); 8142 IWL_ERROR("failed to create debugfs files\n");
8699 goto out_remove_sysfs; 8143 goto out_remove_sysfs;
8700 } 8144 }
8701 /* MAC Address location in EEPROM same for 3945/4965 */
8702 iwl_eeprom_get_mac(priv, priv->mac_addr);
8703 IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr));
8704 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
8705 8145
8706 err = iwl4965_init_channel_map(priv); 8146 iwl4965_setup_deferred_work(priv);
8707 if (err) { 8147 iwl4965_setup_rx_handlers(priv);
8708 IWL_ERROR("initializing regulatory failed: %d\n", err);
8709 goto out_remove_sysfs;
8710 }
8711
8712 err = iwl4965_init_geos(priv);
8713 if (err) {
8714 IWL_ERROR("initializing geos failed: %d\n", err);
8715 goto out_free_channel_map;
8716 }
8717
8718 iwl4965_rate_control_register(priv->hw);
8719 err = ieee80211_register_hw(priv->hw);
8720 if (err) {
8721 IWL_ERROR("Failed to register network device (error %d)\n", err);
8722 goto out_free_geos;
8723 }
8724 8148
8725 priv->hw->conf.beacon_int = 100; 8149 /********************
8726 priv->mac80211_registered = 1; 8150 * 9. Conclude
8151 ********************/
8727 pci_save_state(pdev); 8152 pci_save_state(pdev);
8728 pci_disable_device(pdev); 8153 pci_disable_device(pdev);
8729 8154
8730 return 0; 8155 return 0;
8731 8156
8732 out_free_geos:
8733 iwl4965_free_geos(priv);
8734 out_free_channel_map:
8735 iwl4965_free_channel_map(priv);
8736 out_remove_sysfs: 8157 out_remove_sysfs:
8737 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); 8158 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group);
8738 8159 out_unset_hw_settings:
8739 out_release_irq:
8740 destroy_workqueue(priv->workqueue);
8741 priv->workqueue = NULL;
8742 iwl4965_unset_hw_setting(priv); 8160 iwl4965_unset_hw_setting(priv);
8743
8744 out_iounmap: 8161 out_iounmap:
8745 pci_iounmap(pdev, priv->hw_base); 8162 pci_iounmap(pdev, priv->hw_base);
8746 out_pci_release_regions: 8163 out_pci_release_regions:
8747 pci_release_regions(pdev); 8164 pci_release_regions(pdev);
8165 pci_set_drvdata(pdev, NULL);
8748 out_pci_disable_device: 8166 out_pci_disable_device:
8749 pci_disable_device(pdev); 8167 pci_disable_device(pdev);
8750 pci_set_drvdata(pdev, NULL);
8751 out_ieee80211_free_hw: 8168 out_ieee80211_free_hw:
8752 ieee80211_free_hw(priv->hw); 8169 ieee80211_free_hw(priv->hw);
8753 out: 8170 out:
@@ -8756,7 +8173,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8756 8173
8757static void iwl4965_pci_remove(struct pci_dev *pdev) 8174static void iwl4965_pci_remove(struct pci_dev *pdev)
8758{ 8175{
8759 struct iwl4965_priv *priv = pci_get_drvdata(pdev); 8176 struct iwl_priv *priv = pci_get_drvdata(pdev);
8760 struct list_head *p, *q; 8177 struct list_head *p, *q;
8761 int i; 8178 int i;
8762 8179
@@ -8777,6 +8194,7 @@ static void iwl4965_pci_remove(struct pci_dev *pdev)
8777 } 8194 }
8778 } 8195 }
8779 8196
8197 iwl_dbgfs_unregister(priv);
8780 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); 8198 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group);
8781 8199
8782 iwl4965_dealloc_ucode_pci(priv); 8200 iwl4965_dealloc_ucode_pci(priv);
@@ -8786,7 +8204,7 @@ static void iwl4965_pci_remove(struct pci_dev *pdev)
8786 iwl4965_hw_txq_ctx_free(priv); 8204 iwl4965_hw_txq_ctx_free(priv);
8787 8205
8788 iwl4965_unset_hw_setting(priv); 8206 iwl4965_unset_hw_setting(priv);
8789 iwl4965_clear_stations_table(priv); 8207 iwlcore_clear_stations_table(priv);
8790 8208
8791 if (priv->mac80211_registered) { 8209 if (priv->mac80211_registered) {
8792 ieee80211_unregister_hw(priv->hw); 8210 ieee80211_unregister_hw(priv->hw);
@@ -8807,7 +8225,7 @@ static void iwl4965_pci_remove(struct pci_dev *pdev)
8807 pci_disable_device(pdev); 8225 pci_disable_device(pdev);
8808 pci_set_drvdata(pdev, NULL); 8226 pci_set_drvdata(pdev, NULL);
8809 8227
8810 iwl4965_free_channel_map(priv); 8228 iwl_free_channel_map(priv);
8811 iwl4965_free_geos(priv); 8229 iwl4965_free_geos(priv);
8812 8230
8813 if (priv->ibss_beacon) 8231 if (priv->ibss_beacon)
@@ -8820,7 +8238,7 @@ static void iwl4965_pci_remove(struct pci_dev *pdev)
8820 8238
8821static int iwl4965_pci_suspend(struct pci_dev *pdev, pm_message_t state) 8239static int iwl4965_pci_suspend(struct pci_dev *pdev, pm_message_t state)
8822{ 8240{
8823 struct iwl4965_priv *priv = pci_get_drvdata(pdev); 8241 struct iwl_priv *priv = pci_get_drvdata(pdev);
8824 8242
8825 if (priv->is_open) { 8243 if (priv->is_open) {
8826 set_bit(STATUS_IN_SUSPEND, &priv->status); 8244 set_bit(STATUS_IN_SUSPEND, &priv->status);
@@ -8835,7 +8253,7 @@ static int iwl4965_pci_suspend(struct pci_dev *pdev, pm_message_t state)
8835 8253
8836static int iwl4965_pci_resume(struct pci_dev *pdev) 8254static int iwl4965_pci_resume(struct pci_dev *pdev)
8837{ 8255{
8838 struct iwl4965_priv *priv = pci_get_drvdata(pdev); 8256 struct iwl_priv *priv = pci_get_drvdata(pdev);
8839 8257
8840 pci_set_power_state(pdev, PCI_D0); 8258 pci_set_power_state(pdev, PCI_D0);
8841 8259
@@ -8876,7 +8294,7 @@ static int __init iwl4965_init(void)
8876 IWL_ERROR("Unable to initialize PCI module\n"); 8294 IWL_ERROR("Unable to initialize PCI module\n");
8877 return ret; 8295 return ret;
8878 } 8296 }
8879#ifdef CONFIG_IWL4965_DEBUG 8297#ifdef CONFIG_IWLWIFI_DEBUG
8880 ret = driver_create_file(&iwl4965_driver.driver, &driver_attr_debug_level); 8298 ret = driver_create_file(&iwl4965_driver.driver, &driver_attr_debug_level);
8881 if (ret) { 8299 if (ret) {
8882 IWL_ERROR("Unable to create driver sysfs file\n"); 8300 IWL_ERROR("Unable to create driver sysfs file\n");
@@ -8890,32 +8308,11 @@ static int __init iwl4965_init(void)
8890 8308
8891static void __exit iwl4965_exit(void) 8309static void __exit iwl4965_exit(void)
8892{ 8310{
8893#ifdef CONFIG_IWL4965_DEBUG 8311#ifdef CONFIG_IWLWIFI_DEBUG
8894 driver_remove_file(&iwl4965_driver.driver, &driver_attr_debug_level); 8312 driver_remove_file(&iwl4965_driver.driver, &driver_attr_debug_level);
8895#endif 8313#endif
8896 pci_unregister_driver(&iwl4965_driver); 8314 pci_unregister_driver(&iwl4965_driver);
8897} 8315}
8898 8316
8899module_param_named(antenna, iwl4965_param_antenna, int, 0444);
8900MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
8901module_param_named(disable, iwl4965_param_disable, int, 0444);
8902MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
8903module_param_named(hwcrypto, iwl4965_param_hwcrypto, int, 0444);
8904MODULE_PARM_DESC(hwcrypto,
8905 "using hardware crypto engine (default 0 [software])\n");
8906module_param_named(debug, iwl4965_param_debug, int, 0444);
8907MODULE_PARM_DESC(debug, "debug output mask");
8908module_param_named(disable_hw_scan, iwl4965_param_disable_hw_scan, int, 0444);
8909MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 0)");
8910
8911module_param_named(queues_num, iwl4965_param_queues_num, int, 0444);
8912MODULE_PARM_DESC(queues_num, "number of hw queues.");
8913
8914/* QoS */
8915module_param_named(qos_enable, iwl4965_param_qos_enable, int, 0444);
8916MODULE_PARM_DESC(qos_enable, "enable all QoS functionality");
8917module_param_named(amsdu_size_8K, iwl4965_param_amsdu_size_8K, int, 0444);
8918MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size");
8919
8920module_exit(iwl4965_exit); 8317module_exit(iwl4965_exit);
8921module_init(iwl4965_init); 8318module_init(iwl4965_init);
diff --git a/drivers/net/wireless/libertas/11d.c b/drivers/net/wireless/libertas/11d.c
index 5e10ce0d351c..4bc46a60ae2f 100644
--- a/drivers/net/wireless/libertas/11d.c
+++ b/drivers/net/wireless/libertas/11d.c
@@ -79,7 +79,7 @@ static u8 *lbs_code_2_region(u8 code)
79 * @param nrchan number of channels 79 * @param nrchan number of channels
80 * @return the nrchan-th chan number 80 * @return the nrchan-th chan number
81*/ 81*/
82static u8 lbs_get_chan_11d(u8 band, u8 firstchan, u8 nrchan, u8 *chan) 82static u8 lbs_get_chan_11d(u8 firstchan, u8 nrchan, u8 *chan)
83/*find the nrchan-th chan after the firstchan*/ 83/*find the nrchan-th chan after the firstchan*/
84{ 84{
85 u8 i; 85 u8 i;
@@ -134,7 +134,7 @@ static u8 lbs_channel_known_11d(u8 chan,
134 return 0; 134 return 0;
135} 135}
136 136
137u32 lbs_chan_2_freq(u8 chan, u8 band) 137u32 lbs_chan_2_freq(u8 chan)
138{ 138{
139 struct chan_freq_power *cf; 139 struct chan_freq_power *cf;
140 u16 i; 140 u16 i;
@@ -264,7 +264,7 @@ static void lbs_generate_parsed_region_chan_11d(struct region_channel *region_ch
264 * @param chan chan 264 * @param chan chan
265 * @return TRUE;FALSE 265 * @return TRUE;FALSE
266*/ 266*/
267static u8 lbs_region_chan_supported_11d(u8 region, u8 band, u8 chan) 267static u8 lbs_region_chan_supported_11d(u8 region, u8 chan)
268{ 268{
269 struct chan_freq_power *cfp; 269 struct chan_freq_power *cfp;
270 int cfp_no; 270 int cfp_no;
@@ -273,7 +273,7 @@ static u8 lbs_region_chan_supported_11d(u8 region, u8 band, u8 chan)
273 273
274 lbs_deb_enter(LBS_DEB_11D); 274 lbs_deb_enter(LBS_DEB_11D);
275 275
276 cfp = lbs_get_region_cfp_table(region, band, &cfp_no); 276 cfp = lbs_get_region_cfp_table(region, &cfp_no);
277 if (cfp == NULL) 277 if (cfp == NULL)
278 return 0; 278 return 0;
279 279
@@ -367,7 +367,7 @@ static int parse_domain_info_11d(struct ieeetypes_countryinfofullset*
367 for (i = 0; idx < MAX_NO_OF_CHAN && i < nrchan; i++) { 367 for (i = 0; idx < MAX_NO_OF_CHAN && i < nrchan; i++) {
368 /*step4: channel is supported? */ 368 /*step4: channel is supported? */
369 369
370 if (!lbs_get_chan_11d(band, firstchan, i, &curchan)) { 370 if (!lbs_get_chan_11d(firstchan, i, &curchan)) {
371 /* Chan is not found in UN table */ 371 /* Chan is not found in UN table */
372 lbs_deb_11d("chan is not supported: %d \n", i); 372 lbs_deb_11d("chan is not supported: %d \n", i);
373 break; 373 break;
@@ -375,8 +375,7 @@ static int parse_domain_info_11d(struct ieeetypes_countryinfofullset*
375 375
376 lastchan = curchan; 376 lastchan = curchan;
377 377
378 if (lbs_region_chan_supported_11d 378 if (lbs_region_chan_supported_11d(region, curchan)) {
379 (region, band, curchan)) {
380 /*step5: Check if curchan is supported by mrvl in region */ 379 /*step5: Check if curchan is supported by mrvl in region */
381 parsed_region_chan->chanpwr[idx].chan = curchan; 380 parsed_region_chan->chanpwr[idx].chan = curchan;
382 parsed_region_chan->chanpwr[idx].pwr = 381 parsed_region_chan->chanpwr[idx].pwr =
@@ -554,8 +553,7 @@ done:
554 * @param resp pointer to command response buffer 553 * @param resp pointer to command response buffer
555 * @return 0; -1 554 * @return 0; -1
556 */ 555 */
557int lbs_ret_802_11d_domain_info(struct lbs_private *priv, 556int lbs_ret_802_11d_domain_info(struct cmd_ds_command *resp)
558 struct cmd_ds_command *resp)
559{ 557{
560 struct cmd_ds_802_11d_domain_info *domaininfo = &resp->params.domaininforesp; 558 struct cmd_ds_802_11d_domain_info *domaininfo = &resp->params.domaininforesp;
561 struct mrvlietypes_domainparamset *domain = &domaininfo->domain; 559 struct mrvlietypes_domainparamset *domain = &domaininfo->domain;
diff --git a/drivers/net/wireless/libertas/11d.h b/drivers/net/wireless/libertas/11d.h
index 811eea2cfba3..4f4f47f0f878 100644
--- a/drivers/net/wireless/libertas/11d.h
+++ b/drivers/net/wireless/libertas/11d.h
@@ -83,7 +83,7 @@ struct lbs_private;
83u8 lbs_get_scan_type_11d(u8 chan, 83u8 lbs_get_scan_type_11d(u8 chan,
84 struct parsed_region_chan_11d *parsed_region_chan); 84 struct parsed_region_chan_11d *parsed_region_chan);
85 85
86u32 lbs_chan_2_freq(u8 chan, u8 band); 86u32 lbs_chan_2_freq(u8 chan);
87 87
88void lbs_init_11d(struct lbs_private *priv); 88void lbs_init_11d(struct lbs_private *priv);
89 89
@@ -93,8 +93,7 @@ int lbs_cmd_802_11d_domain_info(struct lbs_private *priv,
93 struct cmd_ds_command *cmd, u16 cmdno, 93 struct cmd_ds_command *cmd, u16 cmdno,
94 u16 cmdOption); 94 u16 cmdOption);
95 95
96int lbs_ret_802_11d_domain_info(struct lbs_private *priv, 96int lbs_ret_802_11d_domain_info(struct cmd_ds_command *resp);
97 struct cmd_ds_command *resp);
98 97
99struct bss_descriptor; 98struct bss_descriptor;
100int lbs_parse_dnld_countryinfo_11d(struct lbs_private *priv, 99int lbs_parse_dnld_countryinfo_11d(struct lbs_private *priv,
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 707b7ff592ec..95d98203eb4e 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -268,13 +268,11 @@ static int assoc_helper_wep_keys(struct lbs_private *priv,
268 268
269 /* enable/disable the MAC's WEP packet filter */ 269 /* enable/disable the MAC's WEP packet filter */
270 if (assoc_req->secinfo.wep_enabled) 270 if (assoc_req->secinfo.wep_enabled)
271 priv->currentpacketfilter |= CMD_ACT_MAC_WEP_ENABLE; 271 priv->mac_control |= CMD_ACT_MAC_WEP_ENABLE;
272 else 272 else
273 priv->currentpacketfilter &= ~CMD_ACT_MAC_WEP_ENABLE; 273 priv->mac_control &= ~CMD_ACT_MAC_WEP_ENABLE;
274 274
275 ret = lbs_set_mac_packet_filter(priv); 275 lbs_set_mac_control(priv);
276 if (ret)
277 goto out;
278 276
279 mutex_lock(&priv->lock); 277 mutex_lock(&priv->lock);
280 278
@@ -304,9 +302,7 @@ static int assoc_helper_secinfo(struct lbs_private *priv,
304 memcpy(&priv->secinfo, &assoc_req->secinfo, 302 memcpy(&priv->secinfo, &assoc_req->secinfo,
305 sizeof(struct lbs_802_11_security)); 303 sizeof(struct lbs_802_11_security));
306 304
307 ret = lbs_set_mac_packet_filter(priv); 305 lbs_set_mac_control(priv);
308 if (ret)
309 goto out;
310 306
311 /* If RSN is already enabled, don't try to enable it again, since 307 /* If RSN is already enabled, don't try to enable it again, since
312 * ENABLE_RSN resets internal state machines and will clobber the 308 * ENABLE_RSN resets internal state machines and will clobber the
@@ -628,10 +624,6 @@ void lbs_association_worker(struct work_struct *work)
628 lbs_prepare_and_send_command(priv, 624 lbs_prepare_and_send_command(priv,
629 CMD_802_11_RSSI, 625 CMD_802_11_RSSI,
630 0, CMD_OPTION_WAITFORRSP, 0, NULL); 626 0, CMD_OPTION_WAITFORRSP, 0, NULL);
631
632 lbs_prepare_and_send_command(priv,
633 CMD_802_11_GET_LOG,
634 0, CMD_OPTION_WAITFORRSP, 0, NULL);
635 } else { 627 } else {
636 ret = -1; 628 ret = -1;
637 } 629 }
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 445c6dc09786..59801f103e66 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -14,9 +14,46 @@
14#include "cmd.h" 14#include "cmd.h"
15 15
16static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv); 16static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv);
17static void lbs_set_cmd_ctrl_node(struct lbs_private *priv, 17
18 struct cmd_ctrl_node *ptempnode, 18
19 void *pdata_buf); 19/**
20 * @brief Simple callback that copies response back into command
21 *
22 * @param priv A pointer to struct lbs_private structure
23 * @param extra A pointer to the original command structure for which
24 * 'resp' is a response
25 * @param resp A pointer to the command response
26 *
27 * @return 0 on success, error on failure
28 */
29int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
30 struct cmd_header *resp)
31{
32 struct cmd_header *buf = (void *)extra;
33 uint16_t copy_len;
34
35 copy_len = min(le16_to_cpu(buf->size), le16_to_cpu(resp->size));
36 memcpy(buf, resp, copy_len);
37 return 0;
38}
39EXPORT_SYMBOL_GPL(lbs_cmd_copyback);
40
41/**
42 * @brief Simple callback that ignores the result. Use this if
43 * you just want to send a command to the hardware, but don't
44 * care for the result.
45 *
46 * @param priv ignored
47 * @param extra ignored
48 * @param resp ignored
49 *
50 * @return 0 for success
51 */
52static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra,
53 struct cmd_header *resp)
54{
55 return 0;
56}
20 57
21 58
22/** 59/**
@@ -143,8 +180,7 @@ int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria)
143} 180}
144EXPORT_SYMBOL_GPL(lbs_host_sleep_cfg); 181EXPORT_SYMBOL_GPL(lbs_host_sleep_cfg);
145 182
146static int lbs_cmd_802_11_ps_mode(struct lbs_private *priv, 183static int lbs_cmd_802_11_ps_mode(struct cmd_ds_command *cmd,
147 struct cmd_ds_command *cmd,
148 u16 cmd_action) 184 u16 cmd_action)
149{ 185{
150 struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode; 186 struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode;
@@ -439,8 +475,7 @@ int lbs_cmd_802_11_key_material(struct lbs_private *priv, uint16_t cmd_action,
439 return ret; 475 return ret;
440} 476}
441 477
442static int lbs_cmd_802_11_reset(struct lbs_private *priv, 478static int lbs_cmd_802_11_reset(struct cmd_ds_command *cmd, int cmd_action)
443 struct cmd_ds_command *cmd, int cmd_action)
444{ 479{
445 struct cmd_ds_802_11_reset *reset = &cmd->params.reset; 480 struct cmd_ds_802_11_reset *reset = &cmd->params.reset;
446 481
@@ -454,30 +489,6 @@ static int lbs_cmd_802_11_reset(struct lbs_private *priv,
454 return 0; 489 return 0;
455} 490}
456 491
457static int lbs_cmd_802_11_get_log(struct lbs_private *priv,
458 struct cmd_ds_command *cmd)
459{
460 lbs_deb_enter(LBS_DEB_CMD);
461 cmd->command = cpu_to_le16(CMD_802_11_GET_LOG);
462 cmd->size =
463 cpu_to_le16(sizeof(struct cmd_ds_802_11_get_log) + S_DS_GEN);
464
465 lbs_deb_leave(LBS_DEB_CMD);
466 return 0;
467}
468
469static int lbs_cmd_802_11_get_stat(struct lbs_private *priv,
470 struct cmd_ds_command *cmd)
471{
472 lbs_deb_enter(LBS_DEB_CMD);
473 cmd->command = cpu_to_le16(CMD_802_11_GET_STAT);
474 cmd->size =
475 cpu_to_le16(sizeof(struct cmd_ds_802_11_get_stat) + S_DS_GEN);
476
477 lbs_deb_leave(LBS_DEB_CMD);
478 return 0;
479}
480
481static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv, 492static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
482 struct cmd_ds_command *cmd, 493 struct cmd_ds_command *cmd,
483 int cmd_action, 494 int cmd_action,
@@ -598,8 +609,7 @@ static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
598 return 0; 609 return 0;
599} 610}
600 611
601static int lbs_cmd_802_11_rf_tx_power(struct lbs_private *priv, 612static int lbs_cmd_802_11_rf_tx_power(struct cmd_ds_command *cmd,
602 struct cmd_ds_command *cmd,
603 u16 cmd_action, void *pdata_buf) 613 u16 cmd_action, void *pdata_buf)
604{ 614{
605 615
@@ -642,8 +652,7 @@ static int lbs_cmd_802_11_rf_tx_power(struct lbs_private *priv,
642 return 0; 652 return 0;
643} 653}
644 654
645static int lbs_cmd_802_11_monitor_mode(struct lbs_private *priv, 655static int lbs_cmd_802_11_monitor_mode(struct cmd_ds_command *cmd,
646 struct cmd_ds_command *cmd,
647 u16 cmd_action, void *pdata_buf) 656 u16 cmd_action, void *pdata_buf)
648{ 657{
649 struct cmd_ds_802_11_monitor_mode *monitor = &cmd->params.monitor; 658 struct cmd_ds_802_11_monitor_mode *monitor = &cmd->params.monitor;
@@ -870,8 +879,7 @@ static int lbs_cmd_802_11_rssi(struct lbs_private *priv,
870 return 0; 879 return 0;
871} 880}
872 881
873static int lbs_cmd_reg_access(struct lbs_private *priv, 882static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr,
874 struct cmd_ds_command *cmdptr,
875 u8 cmd_action, void *pdata_buf) 883 u8 cmd_action, void *pdata_buf)
876{ 884{
877 struct lbs_offset_value *offval; 885 struct lbs_offset_value *offval;
@@ -968,9 +976,8 @@ static int lbs_cmd_802_11_mac_address(struct lbs_private *priv,
968 return 0; 976 return 0;
969} 977}
970 978
971static int lbs_cmd_802_11_eeprom_access(struct lbs_private *priv, 979static int lbs_cmd_802_11_eeprom_access(struct cmd_ds_command *cmd,
972 struct cmd_ds_command *cmd, 980 void *pdata_buf)
973 int cmd_action, void *pdata_buf)
974{ 981{
975 struct lbs_ioctl_regrdwr *ea = pdata_buf; 982 struct lbs_ioctl_regrdwr *ea = pdata_buf;
976 983
@@ -990,8 +997,7 @@ static int lbs_cmd_802_11_eeprom_access(struct lbs_private *priv,
990 return 0; 997 return 0;
991} 998}
992 999
993static int lbs_cmd_bt_access(struct lbs_private *priv, 1000static int lbs_cmd_bt_access(struct cmd_ds_command *cmd,
994 struct cmd_ds_command *cmd,
995 u16 cmd_action, void *pdata_buf) 1001 u16 cmd_action, void *pdata_buf)
996{ 1002{
997 struct cmd_ds_bt_access *bt_access = &cmd->params.bt; 1003 struct cmd_ds_bt_access *bt_access = &cmd->params.bt;
@@ -1028,8 +1034,7 @@ static int lbs_cmd_bt_access(struct lbs_private *priv,
1028 return 0; 1034 return 0;
1029} 1035}
1030 1036
1031static int lbs_cmd_fwt_access(struct lbs_private *priv, 1037static int lbs_cmd_fwt_access(struct cmd_ds_command *cmd,
1032 struct cmd_ds_command *cmd,
1033 u16 cmd_action, void *pdata_buf) 1038 u16 cmd_action, void *pdata_buf)
1034{ 1039{
1035 struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt; 1040 struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt;
@@ -1200,24 +1205,6 @@ static void lbs_submit_command(struct lbs_private *priv,
1200 lbs_deb_leave(LBS_DEB_HOST); 1205 lbs_deb_leave(LBS_DEB_HOST);
1201} 1206}
1202 1207
1203static int lbs_cmd_mac_control(struct lbs_private *priv,
1204 struct cmd_ds_command *cmd)
1205{
1206 struct cmd_ds_mac_control *mac = &cmd->params.macctrl;
1207
1208 lbs_deb_enter(LBS_DEB_CMD);
1209
1210 cmd->command = cpu_to_le16(CMD_MAC_CONTROL);
1211 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_control) + S_DS_GEN);
1212 mac->action = cpu_to_le16(priv->currentpacketfilter);
1213
1214 lbs_deb_cmd("MAC_CONTROL: action 0x%04x, size %d\n",
1215 le16_to_cpu(mac->action), le16_to_cpu(cmd->size));
1216
1217 lbs_deb_leave(LBS_DEB_CMD);
1218 return 0;
1219}
1220
1221/** 1208/**
1222 * This function inserts command node to cmdfreeq 1209 * This function inserts command node to cmdfreeq
1223 * after cleans it. Requires priv->driver_lock held. 1210 * after cleans it. Requires priv->driver_lock held.
@@ -1260,7 +1247,7 @@ void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
1260 cmd->cmdwaitqwoken = 1; 1247 cmd->cmdwaitqwoken = 1;
1261 wake_up_interruptible(&cmd->cmdwait_q); 1248 wake_up_interruptible(&cmd->cmdwait_q);
1262 1249
1263 if (!cmd->callback) 1250 if (!cmd->callback || cmd->callback == lbs_cmd_async_callback)
1264 __lbs_cleanup_and_insert_cmd(priv, cmd); 1251 __lbs_cleanup_and_insert_cmd(priv, cmd);
1265 priv->cur_cmd = NULL; 1252 priv->cur_cmd = NULL;
1266} 1253}
@@ -1304,18 +1291,20 @@ int lbs_set_radio_control(struct lbs_private *priv)
1304 return ret; 1291 return ret;
1305} 1292}
1306 1293
1307int lbs_set_mac_packet_filter(struct lbs_private *priv) 1294void lbs_set_mac_control(struct lbs_private *priv)
1308{ 1295{
1309 int ret = 0; 1296 struct cmd_ds_mac_control cmd;
1310 1297
1311 lbs_deb_enter(LBS_DEB_CMD); 1298 lbs_deb_enter(LBS_DEB_CMD);
1312 1299
1313 /* Send MAC control command to station */ 1300 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
1314 ret = lbs_prepare_and_send_command(priv, 1301 cmd.action = cpu_to_le16(priv->mac_control);
1315 CMD_MAC_CONTROL, 0, 0, 0, NULL); 1302 cmd.reserved = 0;
1316 1303
1317 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 1304 lbs_cmd_async(priv, CMD_MAC_CONTROL,
1318 return ret; 1305 &cmd.hdr, sizeof(cmd));
1306
1307 lbs_deb_leave(LBS_DEB_CMD);
1319} 1308}
1320 1309
1321/** 1310/**
@@ -1364,7 +1353,8 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1364 goto done; 1353 goto done;
1365 } 1354 }
1366 1355
1367 lbs_set_cmd_ctrl_node(priv, cmdnode, pdata_buf); 1356 cmdnode->callback = NULL;
1357 cmdnode->callback_arg = (unsigned long)pdata_buf;
1368 1358
1369 cmdptr = (struct cmd_ds_command *)cmdnode->cmdbuf; 1359 cmdptr = (struct cmd_ds_command *)cmdnode->cmdbuf;
1370 1360
@@ -1379,11 +1369,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1379 1369
1380 switch (cmd_no) { 1370 switch (cmd_no) {
1381 case CMD_802_11_PS_MODE: 1371 case CMD_802_11_PS_MODE:
1382 ret = lbs_cmd_802_11_ps_mode(priv, cmdptr, cmd_action); 1372 ret = lbs_cmd_802_11_ps_mode(cmdptr, cmd_action);
1383 break;
1384
1385 case CMD_MAC_CONTROL:
1386 ret = lbs_cmd_mac_control(priv, cmdptr);
1387 break; 1373 break;
1388 1374
1389 case CMD_802_11_ASSOCIATE: 1375 case CMD_802_11_ASSOCIATE:
@@ -1398,25 +1384,15 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1398 case CMD_802_11_AD_HOC_START: 1384 case CMD_802_11_AD_HOC_START:
1399 ret = lbs_cmd_80211_ad_hoc_start(priv, cmdptr, pdata_buf); 1385 ret = lbs_cmd_80211_ad_hoc_start(priv, cmdptr, pdata_buf);
1400 break; 1386 break;
1401 case CMD_CODE_DNLD:
1402 break;
1403 1387
1404 case CMD_802_11_RESET: 1388 case CMD_802_11_RESET:
1405 ret = lbs_cmd_802_11_reset(priv, cmdptr, cmd_action); 1389 ret = lbs_cmd_802_11_reset(cmdptr, cmd_action);
1406 break;
1407
1408 case CMD_802_11_GET_LOG:
1409 ret = lbs_cmd_802_11_get_log(priv, cmdptr);
1410 break; 1390 break;
1411 1391
1412 case CMD_802_11_AUTHENTICATE: 1392 case CMD_802_11_AUTHENTICATE:
1413 ret = lbs_cmd_80211_authenticate(priv, cmdptr, pdata_buf); 1393 ret = lbs_cmd_80211_authenticate(priv, cmdptr, pdata_buf);
1414 break; 1394 break;
1415 1395
1416 case CMD_802_11_GET_STAT:
1417 ret = lbs_cmd_802_11_get_stat(priv, cmdptr);
1418 break;
1419
1420 case CMD_802_11_SNMP_MIB: 1396 case CMD_802_11_SNMP_MIB:
1421 ret = lbs_cmd_802_11_snmp_mib(priv, cmdptr, 1397 ret = lbs_cmd_802_11_snmp_mib(priv, cmdptr,
1422 cmd_action, cmd_oid, pdata_buf); 1398 cmd_action, cmd_oid, pdata_buf);
@@ -1425,12 +1401,12 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1425 case CMD_MAC_REG_ACCESS: 1401 case CMD_MAC_REG_ACCESS:
1426 case CMD_BBP_REG_ACCESS: 1402 case CMD_BBP_REG_ACCESS:
1427 case CMD_RF_REG_ACCESS: 1403 case CMD_RF_REG_ACCESS:
1428 ret = lbs_cmd_reg_access(priv, cmdptr, cmd_action, pdata_buf); 1404 ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf);
1429 break; 1405 break;
1430 1406
1431 case CMD_802_11_RF_TX_POWER: 1407 case CMD_802_11_RF_TX_POWER:
1432 ret = lbs_cmd_802_11_rf_tx_power(priv, cmdptr, 1408 ret = lbs_cmd_802_11_rf_tx_power(cmdptr,
1433 cmd_action, pdata_buf); 1409 cmd_action, pdata_buf);
1434 break; 1410 break;
1435 1411
1436 case CMD_802_11_RATE_ADAPT_RATESET: 1412 case CMD_802_11_RATE_ADAPT_RATESET:
@@ -1443,7 +1419,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1443 break; 1419 break;
1444 1420
1445 case CMD_802_11_MONITOR_MODE: 1421 case CMD_802_11_MONITOR_MODE:
1446 ret = lbs_cmd_802_11_monitor_mode(priv, cmdptr, 1422 ret = lbs_cmd_802_11_monitor_mode(cmdptr,
1447 cmd_action, pdata_buf); 1423 cmd_action, pdata_buf);
1448 break; 1424 break;
1449 1425
@@ -1456,12 +1432,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1456 break; 1432 break;
1457 1433
1458 case CMD_802_11_AD_HOC_STOP: 1434 case CMD_802_11_AD_HOC_STOP:
1459 ret = lbs_cmd_80211_ad_hoc_stop(priv, cmdptr); 1435 ret = lbs_cmd_80211_ad_hoc_stop(cmdptr);
1460 break;
1461
1462 case CMD_802_11_PAIRWISE_TSC:
1463 break;
1464 case CMD_802_11_GROUP_TSC:
1465 break; 1436 break;
1466 1437
1467 case CMD_802_11_MAC_ADDRESS: 1438 case CMD_802_11_MAC_ADDRESS:
@@ -1469,8 +1440,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1469 break; 1440 break;
1470 1441
1471 case CMD_802_11_EEPROM_ACCESS: 1442 case CMD_802_11_EEPROM_ACCESS:
1472 ret = lbs_cmd_802_11_eeprom_access(priv, cmdptr, 1443 ret = lbs_cmd_802_11_eeprom_access(cmdptr, pdata_buf);
1473 cmd_action, pdata_buf);
1474 break; 1444 break;
1475 1445
1476 case CMD_802_11_SET_AFC: 1446 case CMD_802_11_SET_AFC:
@@ -1537,11 +1507,11 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1537 ret = 0; 1507 ret = 0;
1538 break; 1508 break;
1539 case CMD_BT_ACCESS: 1509 case CMD_BT_ACCESS:
1540 ret = lbs_cmd_bt_access(priv, cmdptr, cmd_action, pdata_buf); 1510 ret = lbs_cmd_bt_access(cmdptr, cmd_action, pdata_buf);
1541 break; 1511 break;
1542 1512
1543 case CMD_FWT_ACCESS: 1513 case CMD_FWT_ACCESS:
1544 ret = lbs_cmd_fwt_access(priv, cmdptr, cmd_action, pdata_buf); 1514 ret = lbs_cmd_fwt_access(cmdptr, cmd_action, pdata_buf);
1545 break; 1515 break;
1546 1516
1547 case CMD_GET_TSF: 1517 case CMD_GET_TSF:
@@ -1714,36 +1684,6 @@ static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv)
1714} 1684}
1715 1685
1716/** 1686/**
1717 * @brief This function cleans command node.
1718 *
1719 * @param ptempnode A pointer to cmdCtrlNode structure
1720 * @return n/a
1721 */
1722
1723/**
1724 * @brief This function initializes the command node.
1725 *
1726 * @param priv A pointer to struct lbs_private structure
1727 * @param ptempnode A pointer to cmd_ctrl_node structure
1728 * @param pdata_buf A pointer to informaion buffer
1729 * @return 0 or -1
1730 */
1731static void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
1732 struct cmd_ctrl_node *ptempnode,
1733 void *pdata_buf)
1734{
1735 lbs_deb_enter(LBS_DEB_HOST);
1736
1737 if (!ptempnode)
1738 return;
1739
1740 ptempnode->callback = NULL;
1741 ptempnode->callback_arg = (unsigned long)pdata_buf;
1742
1743 lbs_deb_leave(LBS_DEB_HOST);
1744}
1745
1746/**
1747 * @brief This function executes next command in command 1687 * @brief This function executes next command in command
1748 * pending queue. It will put fimware back to PS mode 1688 * pending queue. It will put fimware back to PS mode
1749 * if applicable. 1689 * if applicable.
@@ -1930,10 +1870,6 @@ static int sendconfirmsleep(struct lbs_private *priv, u8 *cmdptr, u16 size)
1930 int ret = 0; 1870 int ret = 0;
1931 1871
1932 lbs_deb_enter(LBS_DEB_HOST); 1872 lbs_deb_enter(LBS_DEB_HOST);
1933
1934 lbs_deb_host("SEND_SLEEPC_CMD: before download, cmd size %d\n",
1935 size);
1936
1937 lbs_deb_hex(LBS_DEB_HOST, "sleep confirm command", cmdptr, size); 1873 lbs_deb_hex(LBS_DEB_HOST, "sleep confirm command", cmdptr, size);
1938 1874
1939 ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size); 1875 ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size);
@@ -1956,8 +1892,6 @@ static int sendconfirmsleep(struct lbs_private *priv, u8 *cmdptr, u16 size)
1956 priv->intcounter); 1892 priv->intcounter);
1957 } 1893 }
1958 spin_unlock_irqrestore(&priv->driver_lock, flags); 1894 spin_unlock_irqrestore(&priv->driver_lock, flags);
1959
1960 lbs_deb_host("SEND_SLEEPC_CMD: sent confirm sleep\n");
1961 } 1895 }
1962 1896
1963 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); 1897 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
@@ -2009,10 +1943,10 @@ void lbs_ps_wakeup(struct lbs_private *priv, int wait_option)
2009 * @param psmode Power Saving mode 1943 * @param psmode Power Saving mode
2010 * @return n/a 1944 * @return n/a
2011 */ 1945 */
2012void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode) 1946void lbs_ps_confirm_sleep(struct lbs_private *priv)
2013{ 1947{
2014 unsigned long flags =0; 1948 unsigned long flags =0;
2015 u8 allowed = 1; 1949 int allowed = 1;
2016 1950
2017 lbs_deb_enter(LBS_DEB_HOST); 1951 lbs_deb_enter(LBS_DEB_HOST);
2018 1952
@@ -2044,32 +1978,10 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
2044} 1978}
2045 1979
2046 1980
2047/** 1981static struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv,
2048 * @brief Simple callback that copies response back into command 1982 uint16_t command, struct cmd_header *in_cmd, int in_cmd_size,
2049 * 1983 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
2050 * @param priv A pointer to struct lbs_private structure 1984 unsigned long callback_arg)
2051 * @param extra A pointer to the original command structure for which
2052 * 'resp' is a response
2053 * @param resp A pointer to the command response
2054 *
2055 * @return 0 on success, error on failure
2056 */
2057int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
2058 struct cmd_header *resp)
2059{
2060 struct cmd_header *buf = (void *)extra;
2061 uint16_t copy_len;
2062
2063 copy_len = min(le16_to_cpu(buf->size), le16_to_cpu(resp->size));
2064 memcpy(buf, resp, copy_len);
2065 return 0;
2066}
2067EXPORT_SYMBOL_GPL(lbs_cmd_copyback);
2068
2069struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, uint16_t command,
2070 struct cmd_header *in_cmd, int in_cmd_size,
2071 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
2072 unsigned long callback_arg)
2073{ 1985{
2074 struct cmd_ctrl_node *cmdnode; 1986 struct cmd_ctrl_node *cmdnode;
2075 1987
@@ -2106,9 +2018,6 @@ struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, uint16_t command
2106 2018
2107 lbs_deb_host("PREP_CMD: command 0x%04x\n", command); 2019 lbs_deb_host("PREP_CMD: command 0x%04x\n", command);
2108 2020
2109 /* here was the big old switch() statement, which is now obsolete,
2110 * because the caller of lbs_cmd() sets up all of *cmd for us. */
2111
2112 cmdnode->cmdwaitqwoken = 0; 2021 cmdnode->cmdwaitqwoken = 0;
2113 lbs_queue_cmd(priv, cmdnode); 2022 lbs_queue_cmd(priv, cmdnode);
2114 wake_up_interruptible(&priv->waitq); 2023 wake_up_interruptible(&priv->waitq);
@@ -2118,6 +2027,15 @@ struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, uint16_t command
2118 return cmdnode; 2027 return cmdnode;
2119} 2028}
2120 2029
2030void lbs_cmd_async(struct lbs_private *priv, uint16_t command,
2031 struct cmd_header *in_cmd, int in_cmd_size)
2032{
2033 lbs_deb_enter(LBS_DEB_CMD);
2034 __lbs_cmd_async(priv, command, in_cmd, in_cmd_size,
2035 lbs_cmd_async_callback, 0);
2036 lbs_deb_leave(LBS_DEB_CMD);
2037}
2038
2121int __lbs_cmd(struct lbs_private *priv, uint16_t command, 2039int __lbs_cmd(struct lbs_private *priv, uint16_t command,
2122 struct cmd_header *in_cmd, int in_cmd_size, 2040 struct cmd_header *in_cmd, int in_cmd_size,
2123 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), 2041 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h
index d250e6bc0609..3dfc2d43c224 100644
--- a/drivers/net/wireless/libertas/cmd.h
+++ b/drivers/net/wireless/libertas/cmd.h
@@ -18,12 +18,9 @@
18#define lbs_cmd_with_response(priv, cmdnr, cmd) \ 18#define lbs_cmd_with_response(priv, cmdnr, cmd) \
19 lbs_cmd(priv, cmdnr, cmd, lbs_cmd_copyback, (unsigned long) (cmd)) 19 lbs_cmd(priv, cmdnr, cmd, lbs_cmd_copyback, (unsigned long) (cmd))
20 20
21/* __lbs_cmd() will free the cmdnode and return success/failure. 21void lbs_cmd_async(struct lbs_private *priv, uint16_t command,
22 __lbs_cmd_async() requires that the callback free the cmdnode */ 22 struct cmd_header *in_cmd, int in_cmd_size);
23struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, uint16_t command, 23
24 struct cmd_header *in_cmd, int in_cmd_size,
25 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
26 unsigned long callback_arg);
27int __lbs_cmd(struct lbs_private *priv, uint16_t command, 24int __lbs_cmd(struct lbs_private *priv, uint16_t command,
28 struct cmd_header *in_cmd, int in_cmd_size, 25 struct cmd_header *in_cmd, int in_cmd_size,
29 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), 26 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index 63aa884b18f2..888f92d8afc9 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -146,22 +146,6 @@ static int lbs_ret_reg_access(struct lbs_private *priv,
146 return ret; 146 return ret;
147} 147}
148 148
149static int lbs_ret_802_11_stat(struct lbs_private *priv,
150 struct cmd_ds_command *resp)
151{
152 lbs_deb_enter(LBS_DEB_CMD);
153/* currently priv->wlan802_11Stat is unused
154
155 struct cmd_ds_802_11_get_stat *p11Stat = &resp->params.gstat;
156
157 // TODO Convert it to Big endian befor copy
158 memcpy(&priv->wlan802_11Stat,
159 p11Stat, sizeof(struct cmd_ds_802_11_get_stat));
160*/
161 lbs_deb_leave(LBS_DEB_CMD);
162 return 0;
163}
164
165static int lbs_ret_802_11_snmp_mib(struct lbs_private *priv, 149static int lbs_ret_802_11_snmp_mib(struct lbs_private *priv,
166 struct cmd_ds_command *resp) 150 struct cmd_ds_command *resp)
167{ 151{
@@ -303,20 +287,6 @@ static int lbs_ret_802_11_eeprom_access(struct lbs_private *priv,
303 return 0; 287 return 0;
304} 288}
305 289
306static int lbs_ret_get_log(struct lbs_private *priv,
307 struct cmd_ds_command *resp)
308{
309 struct cmd_ds_802_11_get_log *logmessage = &resp->params.glog;
310
311 lbs_deb_enter(LBS_DEB_CMD);
312
313 /* Stored little-endian */
314 memcpy(&priv->logmsg, logmessage, sizeof(struct cmd_ds_802_11_get_log));
315
316 lbs_deb_leave(LBS_DEB_CMD);
317 return 0;
318}
319
320static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv, 290static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv,
321 struct cmd_ds_command *resp) 291 struct cmd_ds_command *resp)
322{ 292{
@@ -335,7 +305,6 @@ static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv,
335} 305}
336 306
337static inline int handle_cmd_response(struct lbs_private *priv, 307static inline int handle_cmd_response(struct lbs_private *priv,
338 unsigned long dummy,
339 struct cmd_header *cmd_response) 308 struct cmd_header *cmd_response)
340{ 309{
341 struct cmd_ds_command *resp = (struct cmd_ds_command *) cmd_response; 310 struct cmd_ds_command *resp = (struct cmd_ds_command *) cmd_response;
@@ -352,10 +321,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
352 ret = lbs_ret_reg_access(priv, respcmd, resp); 321 ret = lbs_ret_reg_access(priv, respcmd, resp);
353 break; 322 break;
354 323
355 case CMD_RET(CMD_802_11_GET_LOG):
356 ret = lbs_ret_get_log(priv, resp);
357 break;
358
359 case CMD_RET_802_11_ASSOCIATE: 324 case CMD_RET_802_11_ASSOCIATE:
360 case CMD_RET(CMD_802_11_ASSOCIATE): 325 case CMD_RET(CMD_802_11_ASSOCIATE):
361 case CMD_RET(CMD_802_11_REASSOCIATE): 326 case CMD_RET(CMD_802_11_REASSOCIATE):
@@ -364,7 +329,7 @@ static inline int handle_cmd_response(struct lbs_private *priv,
364 329
365 case CMD_RET(CMD_802_11_DISASSOCIATE): 330 case CMD_RET(CMD_802_11_DISASSOCIATE):
366 case CMD_RET(CMD_802_11_DEAUTHENTICATE): 331 case CMD_RET(CMD_802_11_DEAUTHENTICATE):
367 ret = lbs_ret_80211_disassociate(priv, resp); 332 ret = lbs_ret_80211_disassociate(priv);
368 break; 333 break;
369 334
370 case CMD_RET(CMD_802_11_AD_HOC_START): 335 case CMD_RET(CMD_802_11_AD_HOC_START):
@@ -372,10 +337,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
372 ret = lbs_ret_80211_ad_hoc_start(priv, resp); 337 ret = lbs_ret_80211_ad_hoc_start(priv, resp);
373 break; 338 break;
374 339
375 case CMD_RET(CMD_802_11_GET_STAT):
376 ret = lbs_ret_802_11_stat(priv, resp);
377 break;
378
379 case CMD_RET(CMD_802_11_SNMP_MIB): 340 case CMD_RET(CMD_802_11_SNMP_MIB):
380 ret = lbs_ret_802_11_snmp_mib(priv, resp); 341 ret = lbs_ret_802_11_snmp_mib(priv, resp);
381 break; 342 break;
@@ -394,7 +355,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
394 break; 355 break;
395 356
396 case CMD_RET(CMD_MAC_MULTICAST_ADR): 357 case CMD_RET(CMD_MAC_MULTICAST_ADR):
397 case CMD_RET(CMD_MAC_CONTROL):
398 case CMD_RET(CMD_802_11_RESET): 358 case CMD_RET(CMD_802_11_RESET):
399 case CMD_RET(CMD_802_11_AUTHENTICATE): 359 case CMD_RET(CMD_802_11_AUTHENTICATE):
400 case CMD_RET(CMD_802_11_BEACON_STOP): 360 case CMD_RET(CMD_802_11_BEACON_STOP):
@@ -413,7 +373,7 @@ static inline int handle_cmd_response(struct lbs_private *priv,
413 break; 373 break;
414 374
415 case CMD_RET(CMD_802_11_AD_HOC_STOP): 375 case CMD_RET(CMD_802_11_AD_HOC_STOP):
416 ret = lbs_ret_80211_ad_hoc_stop(priv, resp); 376 ret = lbs_ret_80211_ad_hoc_stop(priv);
417 break; 377 break;
418 378
419 case CMD_RET(CMD_802_11_EEPROM_ACCESS): 379 case CMD_RET(CMD_802_11_EEPROM_ACCESS):
@@ -421,7 +381,7 @@ static inline int handle_cmd_response(struct lbs_private *priv,
421 break; 381 break;
422 382
423 case CMD_RET(CMD_802_11D_DOMAIN_INFO): 383 case CMD_RET(CMD_802_11D_DOMAIN_INFO):
424 ret = lbs_ret_802_11d_domain_info(priv, resp); 384 ret = lbs_ret_802_11d_domain_info(resp);
425 break; 385 break;
426 386
427 case CMD_RET(CMD_802_11_TPC_CFG): 387 case CMD_RET(CMD_802_11_TPC_CFG):
@@ -624,7 +584,7 @@ int lbs_process_rx_command(struct lbs_private *priv)
624 ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg, 584 ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg,
625 resp); 585 resp);
626 } else 586 } else
627 ret = handle_cmd_response(priv, 0, resp); 587 ret = handle_cmd_response(priv, resp);
628 588
629 spin_lock_irqsave(&priv->driver_lock, flags); 589 spin_lock_irqsave(&priv->driver_lock, flags);
630 590
@@ -675,11 +635,9 @@ int lbs_process_event(struct lbs_private *priv)
675 eventcause = priv->eventcause >> SBI_EVENT_CAUSE_SHIFT; 635 eventcause = priv->eventcause >> SBI_EVENT_CAUSE_SHIFT;
676 spin_unlock_irq(&priv->driver_lock); 636 spin_unlock_irq(&priv->driver_lock);
677 637
678 lbs_deb_cmd("event cause %d\n", eventcause);
679
680 switch (eventcause) { 638 switch (eventcause) {
681 case MACREG_INT_CODE_LINK_SENSED: 639 case MACREG_INT_CODE_LINK_SENSED:
682 lbs_deb_cmd("EVENT: MACREG_INT_CODE_LINK_SENSED\n"); 640 lbs_deb_cmd("EVENT: link sensed\n");
683 break; 641 break;
684 642
685 case MACREG_INT_CODE_DEAUTHENTICATED: 643 case MACREG_INT_CODE_DEAUTHENTICATED:
@@ -698,7 +656,7 @@ int lbs_process_event(struct lbs_private *priv)
698 break; 656 break;
699 657
700 case MACREG_INT_CODE_PS_SLEEP: 658 case MACREG_INT_CODE_PS_SLEEP:
701 lbs_deb_cmd("EVENT: sleep\n"); 659 lbs_deb_cmd("EVENT: ps sleep\n");
702 660
703 /* handle unexpected PS SLEEP event */ 661 /* handle unexpected PS SLEEP event */
704 if (priv->psstate == PS_STATE_FULL_POWER) { 662 if (priv->psstate == PS_STATE_FULL_POWER) {
@@ -708,17 +666,17 @@ int lbs_process_event(struct lbs_private *priv)
708 } 666 }
709 priv->psstate = PS_STATE_PRE_SLEEP; 667 priv->psstate = PS_STATE_PRE_SLEEP;
710 668
711 lbs_ps_confirm_sleep(priv, (u16) priv->psmode); 669 lbs_ps_confirm_sleep(priv);
712 670
713 break; 671 break;
714 672
715 case MACREG_INT_CODE_HOST_AWAKE: 673 case MACREG_INT_CODE_HOST_AWAKE:
716 lbs_deb_cmd("EVENT: HOST_AWAKE\n"); 674 lbs_deb_cmd("EVENT: host awake\n");
717 lbs_send_confirmwake(priv); 675 lbs_send_confirmwake(priv);
718 break; 676 break;
719 677
720 case MACREG_INT_CODE_PS_AWAKE: 678 case MACREG_INT_CODE_PS_AWAKE:
721 lbs_deb_cmd("EVENT: awake\n"); 679 lbs_deb_cmd("EVENT: ps awake\n");
722 /* handle unexpected PS AWAKE event */ 680 /* handle unexpected PS AWAKE event */
723 if (priv->psstate == PS_STATE_FULL_POWER) { 681 if (priv->psstate == PS_STATE_FULL_POWER) {
724 lbs_deb_cmd( 682 lbs_deb_cmd(
@@ -749,14 +707,16 @@ int lbs_process_event(struct lbs_private *priv)
749 lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n"); 707 lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n");
750 handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST); 708 handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST);
751 break; 709 break;
710
752 case MACREG_INT_CODE_MIB_CHANGED: 711 case MACREG_INT_CODE_MIB_CHANGED:
712 lbs_deb_cmd("EVENT: MIB CHANGED\n");
713 break;
753 case MACREG_INT_CODE_INIT_DONE: 714 case MACREG_INT_CODE_INIT_DONE:
715 lbs_deb_cmd("EVENT: INIT DONE\n");
754 break; 716 break;
755
756 case MACREG_INT_CODE_ADHOC_BCN_LOST: 717 case MACREG_INT_CODE_ADHOC_BCN_LOST:
757 lbs_deb_cmd("EVENT: ADHOC beacon lost\n"); 718 lbs_deb_cmd("EVENT: ADHOC beacon lost\n");
758 break; 719 break;
759
760 case MACREG_INT_CODE_RSSI_LOW: 720 case MACREG_INT_CODE_RSSI_LOW:
761 lbs_pr_alert("EVENT: rssi low\n"); 721 lbs_pr_alert("EVENT: rssi low\n");
762 break; 722 break;
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 8f88786b036f..7072e26b42d9 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -19,7 +19,7 @@ static char *szStates[] = {
19}; 19};
20 20
21#ifdef PROC_DEBUG 21#ifdef PROC_DEBUG
22static void lbs_debug_init(struct lbs_private *priv, struct net_device *dev); 22static void lbs_debug_init(struct lbs_private *priv);
23#endif 23#endif
24 24
25static int open_file_generic(struct inode *inode, struct file *file) 25static int open_file_generic(struct inode *inode, struct file *file)
@@ -78,7 +78,7 @@ static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
78 u16 spectrum_mgmt = (iter_bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT); 78 u16 spectrum_mgmt = (iter_bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT);
79 79
80 pos += snprintf(buf+pos, len-pos, 80 pos += snprintf(buf+pos, len-pos,
81 "%02u| %03d | %04ld | %s |", 81 "%02u| %03d | %04d | %s |",
82 numscansdone, iter_bss->channel, iter_bss->rssi, 82 numscansdone, iter_bss->channel, iter_bss->rssi,
83 print_mac(mac, iter_bss->bssid)); 83 print_mac(mac, iter_bss->bssid));
84 pos += snprintf(buf+pos, len-pos, " %04x-", iter_bss->capability); 84 pos += snprintf(buf+pos, len-pos, " %04x-", iter_bss->capability);
@@ -778,7 +778,7 @@ void lbs_debugfs_init_one(struct lbs_private *priv, struct net_device *dev)
778 } 778 }
779 779
780#ifdef PROC_DEBUG 780#ifdef PROC_DEBUG
781 lbs_debug_init(priv, dev); 781 lbs_debug_init(priv);
782#endif 782#endif
783exit: 783exit:
784 return; 784 return;
@@ -952,7 +952,7 @@ static struct file_operations lbs_debug_fops = {
952 * @param dev pointer net_device 952 * @param dev pointer net_device
953 * @return N/A 953 * @return N/A
954 */ 954 */
955static void lbs_debug_init(struct lbs_private *priv, struct net_device *dev) 955static void lbs_debug_init(struct lbs_private *priv)
956{ 956{
957 int i; 957 int i;
958 958
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index 4e22341b4f3d..cadc59d7f77f 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -17,7 +17,7 @@ struct net_device;
17struct cmd_ctrl_node; 17struct cmd_ctrl_node;
18struct cmd_ds_command; 18struct cmd_ds_command;
19 19
20int lbs_set_mac_packet_filter(struct lbs_private *priv); 20void lbs_set_mac_control(struct lbs_private *priv);
21 21
22void lbs_send_tx_feedback(struct lbs_private *priv); 22void lbs_send_tx_feedback(struct lbs_private *priv);
23 23
@@ -49,7 +49,7 @@ int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band);
49int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *); 49int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *);
50 50
51void lbs_ps_sleep(struct lbs_private *priv, int wait_option); 51void lbs_ps_sleep(struct lbs_private *priv, int wait_option);
52void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode); 52void lbs_ps_confirm_sleep(struct lbs_private *priv);
53void lbs_ps_wakeup(struct lbs_private *priv, int wait_option); 53void lbs_ps_wakeup(struct lbs_private *priv, int wait_option);
54 54
55struct chan_freq_power *lbs_find_cfp_by_band_and_channel( 55struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
@@ -63,7 +63,6 @@ void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str);
63 63
64/* main.c */ 64/* main.c */
65struct chan_freq_power *lbs_get_region_cfp_table(u8 region, 65struct chan_freq_power *lbs_get_region_cfp_table(u8 region,
66 u8 band,
67 int *cfp_no); 66 int *cfp_no);
68struct lbs_private *lbs_add_card(void *card, struct device *dmdev); 67struct lbs_private *lbs_add_card(void *card, struct device *dmdev);
69int lbs_remove_card(struct lbs_private *priv); 68int lbs_remove_card(struct lbs_private *priv);
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index ff2c046ca73f..17e02bed6bfa 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -252,7 +252,7 @@ struct lbs_private {
252 struct sk_buff *currenttxskb; 252 struct sk_buff *currenttxskb;
253 253
254 /** NIC Operation characteristics */ 254 /** NIC Operation characteristics */
255 u16 currentpacketfilter; 255 u16 mac_control;
256 u32 connect_status; 256 u32 connect_status;
257 u32 mesh_connect_status; 257 u32 mesh_connect_status;
258 u16 regioncode; 258 u16 regioncode;
@@ -323,8 +323,6 @@ struct lbs_private {
323 u8 *prdeeprom; 323 u8 *prdeeprom;
324 struct lbs_offset_value offsetvalue; 324 struct lbs_offset_value offsetvalue;
325 325
326 struct cmd_ds_802_11_get_log logmsg;
327
328 u32 monitormode; 326 u32 monitormode;
329 u8 fw_ready; 327 u8 fw_ready;
330}; 328};
diff --git a/drivers/net/wireless/libertas/host.h b/drivers/net/wireless/libertas/host.h
index 1aa04076b1ac..aae878b042c0 100644
--- a/drivers/net/wireless/libertas/host.h
+++ b/drivers/net/wireless/libertas/host.h
@@ -33,7 +33,6 @@
33#define CMD_RET_802_11_ASSOCIATE 0x8012 33#define CMD_RET_802_11_ASSOCIATE 0x8012
34 34
35/* Command codes */ 35/* Command codes */
36#define CMD_CODE_DNLD 0x0002
37#define CMD_GET_HW_SPEC 0x0003 36#define CMD_GET_HW_SPEC 0x0003
38#define CMD_EEPROM_UPDATE 0x0004 37#define CMD_EEPROM_UPDATE 0x0004
39#define CMD_802_11_RESET 0x0005 38#define CMD_802_11_RESET 0x0005
@@ -68,8 +67,6 @@
68#define CMD_802_11_AD_HOC_JOIN 0x002c 67#define CMD_802_11_AD_HOC_JOIN 0x002c
69#define CMD_802_11_QUERY_TKIP_REPLY_CNTRS 0x002e 68#define CMD_802_11_QUERY_TKIP_REPLY_CNTRS 0x002e
70#define CMD_802_11_ENABLE_RSN 0x002f 69#define CMD_802_11_ENABLE_RSN 0x002f
71#define CMD_802_11_PAIRWISE_TSC 0x0036
72#define CMD_802_11_GROUP_TSC 0x0037
73#define CMD_802_11_SET_AFC 0x003c 70#define CMD_802_11_SET_AFC 0x003c
74#define CMD_802_11_GET_AFC 0x003d 71#define CMD_802_11_GET_AFC 0x003d
75#define CMD_802_11_AD_HOC_STOP 0x0040 72#define CMD_802_11_AD_HOC_STOP 0x0040
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h
index 56bc1aa2bb00..acbcd56831cb 100644
--- a/drivers/net/wireless/libertas/hostcmd.h
+++ b/drivers/net/wireless/libertas/hostcmd.h
@@ -195,6 +195,8 @@ struct cmd_ds_802_11_scan_rsp {
195}; 195};
196 196
197struct cmd_ds_802_11_get_log { 197struct cmd_ds_802_11_get_log {
198 struct cmd_header hdr;
199
198 __le32 mcasttxframe; 200 __le32 mcasttxframe;
199 __le32 failed; 201 __le32 failed;
200 __le32 retry; 202 __le32 retry;
@@ -211,8 +213,9 @@ struct cmd_ds_802_11_get_log {
211}; 213};
212 214
213struct cmd_ds_mac_control { 215struct cmd_ds_mac_control {
216 struct cmd_header hdr;
214 __le16 action; 217 __le16 action;
215 __le16 reserved; 218 u16 reserved;
216}; 219};
217 220
218struct cmd_ds_mac_multicast_adr { 221struct cmd_ds_mac_multicast_adr {
@@ -695,13 +698,11 @@ struct cmd_ds_command {
695 /* command Body */ 698 /* command Body */
696 union { 699 union {
697 struct cmd_ds_802_11_ps_mode psmode; 700 struct cmd_ds_802_11_ps_mode psmode;
698 struct cmd_ds_mac_control macctrl;
699 struct cmd_ds_802_11_associate associate; 701 struct cmd_ds_802_11_associate associate;
700 struct cmd_ds_802_11_deauthenticate deauth; 702 struct cmd_ds_802_11_deauthenticate deauth;
701 struct cmd_ds_802_11_ad_hoc_start ads; 703 struct cmd_ds_802_11_ad_hoc_start ads;
702 struct cmd_ds_802_11_reset reset; 704 struct cmd_ds_802_11_reset reset;
703 struct cmd_ds_802_11_ad_hoc_result result; 705 struct cmd_ds_802_11_ad_hoc_result result;
704 struct cmd_ds_802_11_get_log glog;
705 struct cmd_ds_802_11_authenticate auth; 706 struct cmd_ds_802_11_authenticate auth;
706 struct cmd_ds_802_11_get_stat gstat; 707 struct cmd_ds_802_11_get_stat gstat;
707 struct cmd_ds_802_3_get_stat gstat_8023; 708 struct cmd_ds_802_3_get_stat gstat_8023;
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 5a9cadb97503..d17746582160 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -882,6 +882,9 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
882 goto out3; 882 goto out3;
883 } 883 }
884 884
885 /* The firmware for the CF card supports powersave */
886 priv->ps_supported = 1;
887
885 ret = 0; 888 ret = 0;
886 goto out; 889 goto out;
887 890
diff --git a/drivers/net/wireless/libertas/join.c b/drivers/net/wireless/libertas/join.c
index 56e64a697c37..3e5026ff2ffa 100644
--- a/drivers/net/wireless/libertas/join.c
+++ b/drivers/net/wireless/libertas/join.c
@@ -561,8 +561,7 @@ done:
561 return ret; 561 return ret;
562} 562}
563 563
564int lbs_cmd_80211_ad_hoc_stop(struct lbs_private *priv, 564int lbs_cmd_80211_ad_hoc_stop(struct cmd_ds_command *cmd)
565 struct cmd_ds_command *cmd)
566{ 565{
567 cmd->command = cpu_to_le16(CMD_802_11_AD_HOC_STOP); 566 cmd->command = cpu_to_le16(CMD_802_11_AD_HOC_STOP);
568 cmd->size = cpu_to_le16(S_DS_GEN); 567 cmd->size = cpu_to_le16(S_DS_GEN);
@@ -773,8 +772,7 @@ done:
773 return ret; 772 return ret;
774} 773}
775 774
776int lbs_ret_80211_disassociate(struct lbs_private *priv, 775int lbs_ret_80211_disassociate(struct lbs_private *priv)
777 struct cmd_ds_command *resp)
778{ 776{
779 lbs_deb_enter(LBS_DEB_JOIN); 777 lbs_deb_enter(LBS_DEB_JOIN);
780 778
@@ -863,8 +861,7 @@ done:
863 return ret; 861 return ret;
864} 862}
865 863
866int lbs_ret_80211_ad_hoc_stop(struct lbs_private *priv, 864int lbs_ret_80211_ad_hoc_stop(struct lbs_private *priv)
867 struct cmd_ds_command *resp)
868{ 865{
869 lbs_deb_enter(LBS_DEB_JOIN); 866 lbs_deb_enter(LBS_DEB_JOIN);
870 867
diff --git a/drivers/net/wireless/libertas/join.h b/drivers/net/wireless/libertas/join.h
index 792c64fe3514..bfc3a10a2f39 100644
--- a/drivers/net/wireless/libertas/join.h
+++ b/drivers/net/wireless/libertas/join.h
@@ -18,8 +18,7 @@ int lbs_cmd_80211_authenticate(struct lbs_private *priv,
18int lbs_cmd_80211_ad_hoc_join(struct lbs_private *priv, 18int lbs_cmd_80211_ad_hoc_join(struct lbs_private *priv,
19 struct cmd_ds_command *cmd, 19 struct cmd_ds_command *cmd,
20 void *pdata_buf); 20 void *pdata_buf);
21int lbs_cmd_80211_ad_hoc_stop(struct lbs_private *priv, 21int lbs_cmd_80211_ad_hoc_stop(struct cmd_ds_command *cmd);
22 struct cmd_ds_command *cmd);
23int lbs_cmd_80211_ad_hoc_start(struct lbs_private *priv, 22int lbs_cmd_80211_ad_hoc_start(struct lbs_private *priv,
24 struct cmd_ds_command *cmd, 23 struct cmd_ds_command *cmd,
25 void *pdata_buf); 24 void *pdata_buf);
@@ -31,10 +30,8 @@ int lbs_cmd_80211_associate(struct lbs_private *priv,
31 30
32int lbs_ret_80211_ad_hoc_start(struct lbs_private *priv, 31int lbs_ret_80211_ad_hoc_start(struct lbs_private *priv,
33 struct cmd_ds_command *resp); 32 struct cmd_ds_command *resp);
34int lbs_ret_80211_ad_hoc_stop(struct lbs_private *priv, 33int lbs_ret_80211_ad_hoc_stop(struct lbs_private *priv);
35 struct cmd_ds_command *resp); 34int lbs_ret_80211_disassociate(struct lbs_private *priv);
36int lbs_ret_80211_disassociate(struct lbs_private *priv,
37 struct cmd_ds_command *resp);
38int lbs_ret_80211_associate(struct lbs_private *priv, 35int lbs_ret_80211_associate(struct lbs_private *priv,
39 struct cmd_ds_command *resp); 36 struct cmd_ds_command *resp);
40 37
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 2e5bac826c48..1eb0cb0a82b7 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -581,45 +581,45 @@ static int lbs_copy_multicast_address(struct lbs_private *priv,
581static void lbs_set_multicast_list(struct net_device *dev) 581static void lbs_set_multicast_list(struct net_device *dev)
582{ 582{
583 struct lbs_private *priv = dev->priv; 583 struct lbs_private *priv = dev->priv;
584 int oldpacketfilter; 584 int old_mac_control;
585 DECLARE_MAC_BUF(mac); 585 DECLARE_MAC_BUF(mac);
586 586
587 lbs_deb_enter(LBS_DEB_NET); 587 lbs_deb_enter(LBS_DEB_NET);
588 588
589 oldpacketfilter = priv->currentpacketfilter; 589 old_mac_control = priv->mac_control;
590 590
591 if (dev->flags & IFF_PROMISC) { 591 if (dev->flags & IFF_PROMISC) {
592 lbs_deb_net("enable promiscuous mode\n"); 592 lbs_deb_net("enable promiscuous mode\n");
593 priv->currentpacketfilter |= 593 priv->mac_control |=
594 CMD_ACT_MAC_PROMISCUOUS_ENABLE; 594 CMD_ACT_MAC_PROMISCUOUS_ENABLE;
595 priv->currentpacketfilter &= 595 priv->mac_control &=
596 ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE | 596 ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE |
597 CMD_ACT_MAC_MULTICAST_ENABLE); 597 CMD_ACT_MAC_MULTICAST_ENABLE);
598 } else { 598 } else {
599 /* Multicast */ 599 /* Multicast */
600 priv->currentpacketfilter &= 600 priv->mac_control &=
601 ~CMD_ACT_MAC_PROMISCUOUS_ENABLE; 601 ~CMD_ACT_MAC_PROMISCUOUS_ENABLE;
602 602
603 if (dev->flags & IFF_ALLMULTI || dev->mc_count > 603 if (dev->flags & IFF_ALLMULTI || dev->mc_count >
604 MRVDRV_MAX_MULTICAST_LIST_SIZE) { 604 MRVDRV_MAX_MULTICAST_LIST_SIZE) {
605 lbs_deb_net( "enabling all multicast\n"); 605 lbs_deb_net( "enabling all multicast\n");
606 priv->currentpacketfilter |= 606 priv->mac_control |=
607 CMD_ACT_MAC_ALL_MULTICAST_ENABLE; 607 CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
608 priv->currentpacketfilter &= 608 priv->mac_control &=
609 ~CMD_ACT_MAC_MULTICAST_ENABLE; 609 ~CMD_ACT_MAC_MULTICAST_ENABLE;
610 } else { 610 } else {
611 priv->currentpacketfilter &= 611 priv->mac_control &=
612 ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE; 612 ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
613 613
614 if (!dev->mc_count) { 614 if (!dev->mc_count) {
615 lbs_deb_net("no multicast addresses, " 615 lbs_deb_net("no multicast addresses, "
616 "disabling multicast\n"); 616 "disabling multicast\n");
617 priv->currentpacketfilter &= 617 priv->mac_control &=
618 ~CMD_ACT_MAC_MULTICAST_ENABLE; 618 ~CMD_ACT_MAC_MULTICAST_ENABLE;
619 } else { 619 } else {
620 int i; 620 int i;
621 621
622 priv->currentpacketfilter |= 622 priv->mac_control |=
623 CMD_ACT_MAC_MULTICAST_ENABLE; 623 CMD_ACT_MAC_MULTICAST_ENABLE;
624 624
625 priv->nr_of_multicastmacaddr = 625 priv->nr_of_multicastmacaddr =
@@ -642,9 +642,8 @@ static void lbs_set_multicast_list(struct net_device *dev)
642 } 642 }
643 } 643 }
644 644
645 if (priv->currentpacketfilter != oldpacketfilter) { 645 if (priv->mac_control != old_mac_control)
646 lbs_set_mac_packet_filter(priv); 646 lbs_set_mac_control(priv);
647 }
648 647
649 lbs_deb_leave(LBS_DEB_NET); 648 lbs_deb_leave(LBS_DEB_NET);
650} 649}
@@ -804,7 +803,7 @@ static int lbs_thread(void *data)
804 lbs_deb_thread("main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p dnld_sent=%d cur_cmd=%p, confirm now\n", 803 lbs_deb_thread("main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p dnld_sent=%d cur_cmd=%p, confirm now\n",
805 priv->intcounter, priv->currenttxskb, priv->dnld_sent, priv->cur_cmd); 804 priv->intcounter, priv->currenttxskb, priv->dnld_sent, priv->cur_cmd);
806 805
807 lbs_ps_confirm_sleep(priv, (u16) priv->psmode); 806 lbs_ps_confirm_sleep(priv);
808 } else { 807 } else {
809 /* workaround for firmware sending 808 /* workaround for firmware sending
810 * deauth/linkloss event immediately 809 * deauth/linkloss event immediately
@@ -945,7 +944,7 @@ static int lbs_setup_firmware(struct lbs_private *priv)
945 goto done; 944 goto done;
946 } 945 }
947 946
948 lbs_set_mac_packet_filter(priv); 947 lbs_set_mac_control(priv);
949 948
950 ret = lbs_get_data_rate(priv); 949 ret = lbs_get_data_rate(priv);
951 if (ret < 0) { 950 if (ret < 0) {
@@ -1036,7 +1035,7 @@ static int lbs_init_adapter(struct lbs_private *priv)
1036 priv->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; 1035 priv->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1037 priv->mode = IW_MODE_INFRA; 1036 priv->mode = IW_MODE_INFRA;
1038 priv->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL; 1037 priv->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL;
1039 priv->currentpacketfilter = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON; 1038 priv->mac_control = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
1040 priv->radioon = RADIO_ON; 1039 priv->radioon = RADIO_ON;
1041 priv->auto_rate = 1; 1040 priv->auto_rate = 1;
1042 priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE; 1041 priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE;
@@ -1392,7 +1391,7 @@ static void lbs_remove_mesh(struct lbs_private *priv)
1392 * @param cfp_no A pointer to CFP number 1391 * @param cfp_no A pointer to CFP number
1393 * @return A pointer to CFP 1392 * @return A pointer to CFP
1394 */ 1393 */
1395struct chan_freq_power *lbs_get_region_cfp_table(u8 region, u8 band, int *cfp_no) 1394struct chan_freq_power *lbs_get_region_cfp_table(u8 region, int *cfp_no)
1396{ 1395{
1397 int i, end; 1396 int i, end;
1398 1397
@@ -1426,7 +1425,7 @@ int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band)
1426 1425
1427 memset(priv->region_channel, 0, sizeof(priv->region_channel)); 1426 memset(priv->region_channel, 0, sizeof(priv->region_channel));
1428 1427
1429 cfp = lbs_get_region_cfp_table(region, band, &cfp_no); 1428 cfp = lbs_get_region_cfp_table(region, &cfp_no);
1430 if (cfp != NULL) { 1429 if (cfp != NULL) {
1431 priv->region_channel[i].nrcfp = cfp_no; 1430 priv->region_channel[i].nrcfp = cfp_no;
1432 priv->region_channel[i].CFP = cfp; 1431 priv->region_channel[i].CFP = cfp;
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 0598541451d8..3825b7979fc4 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -602,7 +602,7 @@ static int lbs_scan_networks(struct lbs_private *priv, int full_scan)
602 lbs_deb_scan("scan table:\n"); 602 lbs_deb_scan("scan table:\n");
603 list_for_each_entry(iter, &priv->network_list, list) 603 list_for_each_entry(iter, &priv->network_list, list)
604 lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n", 604 lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n",
605 i++, print_mac(mac, iter->bssid), (int)iter->rssi, 605 i++, print_mac(mac, iter->bssid), iter->rssi,
606 escape_essid(iter->ssid, iter->ssid_len)); 606 escape_essid(iter->ssid, iter->ssid_len));
607 mutex_unlock(&priv->lock); 607 mutex_unlock(&priv->lock);
608#endif 608#endif
@@ -948,7 +948,7 @@ struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv,
948 uint8_t *bssid, uint8_t mode, 948 uint8_t *bssid, uint8_t mode,
949 int channel) 949 int channel)
950{ 950{
951 uint8_t bestrssi = 0; 951 u32 bestrssi = 0;
952 struct bss_descriptor * iter_bss = NULL; 952 struct bss_descriptor * iter_bss = NULL;
953 struct bss_descriptor * found_bss = NULL; 953 struct bss_descriptor * found_bss = NULL;
954 struct bss_descriptor * tmp_oldest = NULL; 954 struct bss_descriptor * tmp_oldest = NULL;
diff --git a/drivers/net/wireless/libertas/scan.h b/drivers/net/wireless/libertas/scan.h
index c50c8b74714b..b50cf1415e04 100644
--- a/drivers/net/wireless/libertas/scan.h
+++ b/drivers/net/wireless/libertas/scan.h
@@ -34,14 +34,9 @@ struct bss_descriptor {
34 u8 ssid_len; 34 u8 ssid_len;
35 35
36 u16 capability; 36 u16 capability;
37 37 u32 rssi;
38 /* receive signal strength in dBm */
39 long rssi;
40
41 u32 channel; 38 u32 channel;
42
43 u16 beaconperiod; 39 u16 beaconperiod;
44
45 u32 atimwindow; 40 u32 atimwindow;
46 41
47 /* IW_MODE_AUTO, IW_MODE_ADHOC, IW_MODE_INFRA */ 42 /* IW_MODE_AUTO, IW_MODE_ADHOC, IW_MODE_INFRA */
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index cded4bb69164..738142e802d4 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -605,7 +605,7 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
605 lbs_deb_wext("chan_no %d\n", chan_no); 605 lbs_deb_wext("chan_no %d\n", chan_no);
606 range->freq[range->num_frequency].i = (long)chan_no; 606 range->freq[range->num_frequency].i = (long)chan_no;
607 range->freq[range->num_frequency].m = 607 range->freq[range->num_frequency].m =
608 (long)lbs_chan_2_freq(chan_no, band) * 100000; 608 (long)lbs_chan_2_freq(chan_no) * 100000;
609 range->freq[range->num_frequency].e = 1; 609 range->freq[range->num_frequency].e = 1;
610 range->num_frequency++; 610 range->num_frequency++;
611 } 611 }
@@ -656,13 +656,10 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
656 range->num_encoding_sizes = 2; 656 range->num_encoding_sizes = 2;
657 range->max_encoding_tokens = 4; 657 range->max_encoding_tokens = 4;
658 658
659 range->min_pmp = 1000000; 659 /*
660 range->max_pmp = 120000000; 660 * Right now we support only "iwconfig ethX power on|off"
661 range->min_pmt = 1000; 661 */
662 range->max_pmt = 1000000; 662 range->pm_capa = IW_POWER_ON;
663 range->pmp_flags = IW_POWER_PERIOD;
664 range->pmt_flags = IW_POWER_TIMEOUT;
665 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
666 663
667 /* 664 /*
668 * Minimum version we recommend 665 * Minimum version we recommend
@@ -784,21 +781,14 @@ static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
784 struct iw_param *vwrq, char *extra) 781 struct iw_param *vwrq, char *extra)
785{ 782{
786 struct lbs_private *priv = dev->priv; 783 struct lbs_private *priv = dev->priv;
787 int mode;
788 784
789 lbs_deb_enter(LBS_DEB_WEXT); 785 lbs_deb_enter(LBS_DEB_WEXT);
790 786
791 mode = priv->psmode;
792
793 if ((vwrq->disabled = (mode == LBS802_11POWERMODECAM))
794 || priv->connect_status == LBS_DISCONNECTED)
795 {
796 goto out;
797 }
798
799 vwrq->value = 0; 787 vwrq->value = 0;
788 vwrq->flags = 0;
789 vwrq->disabled = priv->psmode == LBS802_11POWERMODECAM
790 || priv->connect_status == LBS_DISCONNECTED;
800 791
801out:
802 lbs_deb_leave(LBS_DEB_WEXT); 792 lbs_deb_leave(LBS_DEB_WEXT);
803 return 0; 793 return 0;
804} 794}
@@ -820,6 +810,7 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
820 int stats_valid = 0; 810 int stats_valid = 0;
821 u8 rssi; 811 u8 rssi;
822 u32 tx_retries; 812 u32 tx_retries;
813 struct cmd_ds_802_11_get_log log;
823 814
824 lbs_deb_enter(LBS_DEB_WEXT); 815 lbs_deb_enter(LBS_DEB_WEXT);
825 816
@@ -863,7 +854,11 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
863 /* Quality by TX errors */ 854 /* Quality by TX errors */
864 priv->wstats.discard.retries = priv->stats.tx_errors; 855 priv->wstats.discard.retries = priv->stats.tx_errors;
865 856
866 tx_retries = le32_to_cpu(priv->logmsg.retry); 857 memset(&log, 0, sizeof(log));
858 log.hdr.size = cpu_to_le16(sizeof(log));
859 lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log);
860
861 tx_retries = le32_to_cpu(log.retry);
867 862
868 if (tx_retries > 75) 863 if (tx_retries > 75)
869 tx_qual = (90 - tx_retries) * POOR / 15; 864 tx_qual = (90 - tx_retries) * POOR / 15;
@@ -879,10 +874,9 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
879 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD; 874 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
880 quality = min(quality, tx_qual); 875 quality = min(quality, tx_qual);
881 876
882 priv->wstats.discard.code = le32_to_cpu(priv->logmsg.wepundecryptable); 877 priv->wstats.discard.code = le32_to_cpu(log.wepundecryptable);
883 priv->wstats.discard.fragment = le32_to_cpu(priv->logmsg.rxfrag);
884 priv->wstats.discard.retries = tx_retries; 878 priv->wstats.discard.retries = tx_retries;
885 priv->wstats.discard.misc = le32_to_cpu(priv->logmsg.ackfailure); 879 priv->wstats.discard.misc = le32_to_cpu(log.ackfailure);
886 880
887 /* Calculate quality */ 881 /* Calculate quality */
888 priv->wstats.qual.qual = min_t(u8, quality, 100); 882 priv->wstats.qual.qual = min_t(u8, quality, 100);
@@ -892,8 +886,6 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
892 /* update stats asynchronously for future calls */ 886 /* update stats asynchronously for future calls */
893 lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0, 887 lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
894 0, 0, NULL); 888 0, 0, NULL);
895 lbs_prepare_and_send_command(priv, CMD_802_11_GET_LOG, 0,
896 0, 0, NULL);
897out: 889out:
898 if (!stats_valid) { 890 if (!stats_valid) {
899 priv->wstats.miss.beacon = 0; 891 priv->wstats.miss.beacon = 0;
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index 4709c11da419..ad1549592c00 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -134,7 +134,7 @@ config RT2500USB
134 134
135config RT2500USB_LEDS 135config RT2500USB_LEDS
136 bool "RT2500 leds support" 136 bool "RT2500 leds support"
137 depends on RT2500USB 137 depends on RT2500USB && BROKEN
138 select RT2X00_LIB_LEDS 138 select RT2X00_LIB_LEDS
139 ---help--- 139 ---help---
140 This adds support for led triggers provided my mac80211. 140 This adds support for led triggers provided my mac80211.
@@ -152,7 +152,7 @@ config RT73USB
152 152
153config RT73USB_LEDS 153config RT73USB_LEDS
154 bool "RT73 leds support" 154 bool "RT73 leds support"
155 depends on RT73USB 155 depends on RT73USB && BROKEN
156 select RT2X00_LIB_LEDS 156 select RT2X00_LIB_LEDS
157 ---help--- 157 ---help---
158 This adds support for led triggers provided my mac80211. 158 This adds support for led triggers provided my mac80211.
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 1f49561d3ddc..a6e9c89c802a 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -270,6 +270,31 @@ static void rt2400pci_led_brightness(struct led_classdev *led_cdev,
270/* 270/*
271 * Configuration handlers. 271 * Configuration handlers.
272 */ 272 */
273static void rt2400pci_config_filter(struct rt2x00_dev *rt2x00dev,
274 const unsigned int filter_flags)
275{
276 u32 reg;
277
278 /*
279 * Start configuration steps.
280 * Note that the version error will always be dropped
281 * since there is no filter for it at this time.
282 */
283 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
284 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
285 !(filter_flags & FIF_FCSFAIL));
286 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
287 !(filter_flags & FIF_PLCPFAIL));
288 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
289 !(filter_flags & FIF_CONTROL));
290 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
291 !(filter_flags & FIF_PROMISC_IN_BSS));
292 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
293 !(filter_flags & FIF_PROMISC_IN_BSS));
294 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
295 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
296}
297
273static void rt2400pci_config_intf(struct rt2x00_dev *rt2x00dev, 298static void rt2400pci_config_intf(struct rt2x00_dev *rt2x00dev,
274 struct rt2x00_intf *intf, 299 struct rt2x00_intf *intf,
275 struct rt2x00intf_conf *conf, 300 struct rt2x00intf_conf *conf,
@@ -306,8 +331,8 @@ static void rt2400pci_config_intf(struct rt2x00_dev *rt2x00dev,
306 conf->bssid, sizeof(conf->bssid)); 331 conf->bssid, sizeof(conf->bssid));
307} 332}
308 333
309static int rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev, 334static void rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev,
310 struct rt2x00lib_erp *erp) 335 struct rt2x00lib_erp *erp)
311{ 336{
312 int preamble_mask; 337 int preamble_mask;
313 u32 reg; 338 u32 reg;
@@ -347,8 +372,6 @@ static int rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev,
347 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84); 372 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84);
348 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); 373 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110));
349 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); 374 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg);
350
351 return 0;
352} 375}
353 376
354static void rt2400pci_config_phymode(struct rt2x00_dev *rt2x00dev, 377static void rt2400pci_config_phymode(struct rt2x00_dev *rt2x00dev,
@@ -1076,12 +1099,13 @@ static void rt2400pci_fill_rxdone(struct queue_entry *entry,
1076 * of the preamble bit (0x08). 1099 * of the preamble bit (0x08).
1077 */ 1100 */
1078 rxdesc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL) & ~0x08; 1101 rxdesc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL) & ~0x08;
1079 rxdesc->signal_plcp = 1;
1080 rxdesc->rssi = rt2x00_get_field32(word2, RXD_W3_RSSI) - 1102 rxdesc->rssi = rt2x00_get_field32(word2, RXD_W3_RSSI) -
1081 entry->queue->rt2x00dev->rssi_offset; 1103 entry->queue->rt2x00dev->rssi_offset;
1082 rxdesc->ofdm = 0;
1083 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1104 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1084 rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); 1105
1106 rxdesc->dev_flags = RXDONE_SIGNAL_PLCP;
1107 if (rt2x00_get_field32(word0, RXD_W0_MY_BSS))
1108 rxdesc->dev_flags |= RXDONE_MY_BSS;
1085} 1109}
1086 1110
1087/* 1111/*
@@ -1396,64 +1420,6 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1396/* 1420/*
1397 * IEEE80211 stack callback functions. 1421 * IEEE80211 stack callback functions.
1398 */ 1422 */
1399static void rt2400pci_configure_filter(struct ieee80211_hw *hw,
1400 unsigned int changed_flags,
1401 unsigned int *total_flags,
1402 int mc_count,
1403 struct dev_addr_list *mc_list)
1404{
1405 struct rt2x00_dev *rt2x00dev = hw->priv;
1406 u32 reg;
1407
1408 /*
1409 * Mask off any flags we are going to ignore from
1410 * the total_flags field.
1411 */
1412 *total_flags &=
1413 FIF_ALLMULTI |
1414 FIF_FCSFAIL |
1415 FIF_PLCPFAIL |
1416 FIF_CONTROL |
1417 FIF_OTHER_BSS |
1418 FIF_PROMISC_IN_BSS;
1419
1420 /*
1421 * Apply some rules to the filters:
1422 * - Some filters imply different filters to be set.
1423 * - Some things we can't filter out at all.
1424 */
1425 *total_flags |= FIF_ALLMULTI;
1426 if (*total_flags & FIF_OTHER_BSS ||
1427 *total_flags & FIF_PROMISC_IN_BSS)
1428 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1429
1430 /*
1431 * Check if there is any work left for us.
1432 */
1433 if (rt2x00dev->packet_filter == *total_flags)
1434 return;
1435 rt2x00dev->packet_filter = *total_flags;
1436
1437 /*
1438 * Start configuration steps.
1439 * Note that the version error will always be dropped
1440 * since there is no filter for it at this time.
1441 */
1442 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
1443 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
1444 !(*total_flags & FIF_FCSFAIL));
1445 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
1446 !(*total_flags & FIF_PLCPFAIL));
1447 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
1448 !(*total_flags & FIF_CONTROL));
1449 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
1450 !(*total_flags & FIF_PROMISC_IN_BSS));
1451 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
1452 !(*total_flags & FIF_PROMISC_IN_BSS));
1453 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
1454 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
1455}
1456
1457static int rt2400pci_set_retry_limit(struct ieee80211_hw *hw, 1423static int rt2400pci_set_retry_limit(struct ieee80211_hw *hw,
1458 u32 short_retry, u32 long_retry) 1424 u32 short_retry, u32 long_retry)
1459{ 1425{
@@ -1579,7 +1545,7 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = {
1579 .remove_interface = rt2x00mac_remove_interface, 1545 .remove_interface = rt2x00mac_remove_interface,
1580 .config = rt2x00mac_config, 1546 .config = rt2x00mac_config,
1581 .config_interface = rt2x00mac_config_interface, 1547 .config_interface = rt2x00mac_config_interface,
1582 .configure_filter = rt2400pci_configure_filter, 1548 .configure_filter = rt2x00mac_configure_filter,
1583 .get_stats = rt2x00mac_get_stats, 1549 .get_stats = rt2x00mac_get_stats,
1584 .set_retry_limit = rt2400pci_set_retry_limit, 1550 .set_retry_limit = rt2400pci_set_retry_limit,
1585 .bss_info_changed = rt2x00mac_bss_info_changed, 1551 .bss_info_changed = rt2x00mac_bss_info_changed,
@@ -1607,6 +1573,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
1607 .write_tx_data = rt2x00pci_write_tx_data, 1573 .write_tx_data = rt2x00pci_write_tx_data,
1608 .kick_tx_queue = rt2400pci_kick_tx_queue, 1574 .kick_tx_queue = rt2400pci_kick_tx_queue,
1609 .fill_rxdone = rt2400pci_fill_rxdone, 1575 .fill_rxdone = rt2400pci_fill_rxdone,
1576 .config_filter = rt2400pci_config_filter,
1610 .config_intf = rt2400pci_config_intf, 1577 .config_intf = rt2400pci_config_intf,
1611 .config_erp = rt2400pci_config_erp, 1578 .config_erp = rt2400pci_config_erp,
1612 .config = rt2400pci_config, 1579 .config = rt2400pci_config,
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 0f5139a2f238..1bdb873b65f2 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -270,6 +270,35 @@ static void rt2500pci_led_brightness(struct led_classdev *led_cdev,
270/* 270/*
271 * Configuration handlers. 271 * Configuration handlers.
272 */ 272 */
273static void rt2500pci_config_filter(struct rt2x00_dev *rt2x00dev,
274 const unsigned int filter_flags)
275{
276 u32 reg;
277
278 /*
279 * Start configuration steps.
280 * Note that the version error will always be dropped
281 * and broadcast frames will always be accepted since
282 * there is no filter for it at this time.
283 */
284 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
285 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
286 !(filter_flags & FIF_FCSFAIL));
287 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
288 !(filter_flags & FIF_PLCPFAIL));
289 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
290 !(filter_flags & FIF_CONTROL));
291 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
292 !(filter_flags & FIF_PROMISC_IN_BSS));
293 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
294 !(filter_flags & FIF_PROMISC_IN_BSS));
295 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
296 rt2x00_set_field32(&reg, RXCSR0_DROP_MCAST,
297 !(filter_flags & FIF_ALLMULTI));
298 rt2x00_set_field32(&reg, RXCSR0_DROP_BCAST, 0);
299 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
300}
301
273static void rt2500pci_config_intf(struct rt2x00_dev *rt2x00dev, 302static void rt2500pci_config_intf(struct rt2x00_dev *rt2x00dev,
274 struct rt2x00_intf *intf, 303 struct rt2x00_intf *intf,
275 struct rt2x00intf_conf *conf, 304 struct rt2x00intf_conf *conf,
@@ -309,8 +338,8 @@ static void rt2500pci_config_intf(struct rt2x00_dev *rt2x00dev,
309 conf->bssid, sizeof(conf->bssid)); 338 conf->bssid, sizeof(conf->bssid));
310} 339}
311 340
312static int rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev, 341static void rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
313 struct rt2x00lib_erp *erp) 342 struct rt2x00lib_erp *erp)
314{ 343{
315 int preamble_mask; 344 int preamble_mask;
316 u32 reg; 345 u32 reg;
@@ -350,8 +379,6 @@ static int rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
350 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84); 379 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84);
351 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); 380 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110));
352 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); 381 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg);
353
354 return 0;
355} 382}
356 383
357static void rt2500pci_config_phymode(struct rt2x00_dev *rt2x00dev, 384static void rt2500pci_config_phymode(struct rt2x00_dev *rt2x00dev,
@@ -1225,13 +1252,16 @@ static void rt2500pci_fill_rxdone(struct queue_entry *entry,
1225 * the signal is the PLCP value. If it was received with 1252 * the signal is the PLCP value. If it was received with
1226 * a CCK bitrate the signal is the rate in 100kbit/s. 1253 * a CCK bitrate the signal is the rate in 100kbit/s.
1227 */ 1254 */
1228 rxdesc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM);
1229 rxdesc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL); 1255 rxdesc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL);
1230 rxdesc->signal_plcp = rxdesc->ofdm;
1231 rxdesc->rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) - 1256 rxdesc->rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) -
1232 entry->queue->rt2x00dev->rssi_offset; 1257 entry->queue->rt2x00dev->rssi_offset;
1233 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1258 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1234 rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); 1259
1260 rxdesc->dev_flags = 0;
1261 if (rt2x00_get_field32(word0, RXD_W0_OFDM))
1262 rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP;
1263 if (rt2x00_get_field32(word0, RXD_W0_MY_BSS))
1264 rxdesc->dev_flags |= RXDONE_MY_BSS;
1235} 1265}
1236 1266
1237/* 1267/*
@@ -1728,69 +1758,6 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1728/* 1758/*
1729 * IEEE80211 stack callback functions. 1759 * IEEE80211 stack callback functions.
1730 */ 1760 */
1731static void rt2500pci_configure_filter(struct ieee80211_hw *hw,
1732 unsigned int changed_flags,
1733 unsigned int *total_flags,
1734 int mc_count,
1735 struct dev_addr_list *mc_list)
1736{
1737 struct rt2x00_dev *rt2x00dev = hw->priv;
1738 u32 reg;
1739
1740 /*
1741 * Mask off any flags we are going to ignore from
1742 * the total_flags field.
1743 */
1744 *total_flags &=
1745 FIF_ALLMULTI |
1746 FIF_FCSFAIL |
1747 FIF_PLCPFAIL |
1748 FIF_CONTROL |
1749 FIF_OTHER_BSS |
1750 FIF_PROMISC_IN_BSS;
1751
1752 /*
1753 * Apply some rules to the filters:
1754 * - Some filters imply different filters to be set.
1755 * - Some things we can't filter out at all.
1756 */
1757 if (mc_count)
1758 *total_flags |= FIF_ALLMULTI;
1759 if (*total_flags & FIF_OTHER_BSS ||
1760 *total_flags & FIF_PROMISC_IN_BSS)
1761 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1762
1763 /*
1764 * Check if there is any work left for us.
1765 */
1766 if (rt2x00dev->packet_filter == *total_flags)
1767 return;
1768 rt2x00dev->packet_filter = *total_flags;
1769
1770 /*
1771 * Start configuration steps.
1772 * Note that the version error will always be dropped
1773 * and broadcast frames will always be accepted since
1774 * there is no filter for it at this time.
1775 */
1776 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
1777 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
1778 !(*total_flags & FIF_FCSFAIL));
1779 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
1780 !(*total_flags & FIF_PLCPFAIL));
1781 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
1782 !(*total_flags & FIF_CONTROL));
1783 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
1784 !(*total_flags & FIF_PROMISC_IN_BSS));
1785 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
1786 !(*total_flags & FIF_PROMISC_IN_BSS));
1787 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
1788 rt2x00_set_field32(&reg, RXCSR0_DROP_MCAST,
1789 !(*total_flags & FIF_ALLMULTI));
1790 rt2x00_set_field32(&reg, RXCSR0_DROP_BCAST, 0);
1791 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
1792}
1793
1794static int rt2500pci_set_retry_limit(struct ieee80211_hw *hw, 1761static int rt2500pci_set_retry_limit(struct ieee80211_hw *hw,
1795 u32 short_retry, u32 long_retry) 1762 u32 short_retry, u32 long_retry)
1796{ 1763{
@@ -1891,7 +1858,7 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = {
1891 .remove_interface = rt2x00mac_remove_interface, 1858 .remove_interface = rt2x00mac_remove_interface,
1892 .config = rt2x00mac_config, 1859 .config = rt2x00mac_config,
1893 .config_interface = rt2x00mac_config_interface, 1860 .config_interface = rt2x00mac_config_interface,
1894 .configure_filter = rt2500pci_configure_filter, 1861 .configure_filter = rt2x00mac_configure_filter,
1895 .get_stats = rt2x00mac_get_stats, 1862 .get_stats = rt2x00mac_get_stats,
1896 .set_retry_limit = rt2500pci_set_retry_limit, 1863 .set_retry_limit = rt2500pci_set_retry_limit,
1897 .bss_info_changed = rt2x00mac_bss_info_changed, 1864 .bss_info_changed = rt2x00mac_bss_info_changed,
@@ -1919,6 +1886,7 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
1919 .write_tx_data = rt2x00pci_write_tx_data, 1886 .write_tx_data = rt2x00pci_write_tx_data,
1920 .kick_tx_queue = rt2500pci_kick_tx_queue, 1887 .kick_tx_queue = rt2500pci_kick_tx_queue,
1921 .fill_rxdone = rt2500pci_fill_rxdone, 1888 .fill_rxdone = rt2500pci_fill_rxdone,
1889 .config_filter = rt2500pci_config_filter,
1922 .config_intf = rt2500pci_config_intf, 1890 .config_intf = rt2500pci_config_intf,
1923 .config_erp = rt2500pci_config_erp, 1891 .config_erp = rt2500pci_config_erp,
1924 .config = rt2500pci_config, 1892 .config = rt2500pci_config,
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index c8216d755835..f5c18f011e93 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -316,6 +316,35 @@ static void rt2500usb_led_brightness(struct led_classdev *led_cdev,
316/* 316/*
317 * Configuration handlers. 317 * Configuration handlers.
318 */ 318 */
319static void rt2500usb_config_filter(struct rt2x00_dev *rt2x00dev,
320 const unsigned int filter_flags)
321{
322 u16 reg;
323
324 /*
325 * Start configuration steps.
326 * Note that the version error will always be dropped
327 * and broadcast frames will always be accepted since
328 * there is no filter for it at this time.
329 */
330 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
331 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CRC,
332 !(filter_flags & FIF_FCSFAIL));
333 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_PHYSICAL,
334 !(filter_flags & FIF_PLCPFAIL));
335 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CONTROL,
336 !(filter_flags & FIF_CONTROL));
337 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_NOT_TO_ME,
338 !(filter_flags & FIF_PROMISC_IN_BSS));
339 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_TODS,
340 !(filter_flags & FIF_PROMISC_IN_BSS));
341 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_VERSION_ERROR, 1);
342 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_MULTICAST,
343 !(filter_flags & FIF_ALLMULTI));
344 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_BROADCAST, 0);
345 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
346}
347
319static void rt2500usb_config_intf(struct rt2x00_dev *rt2x00dev, 348static void rt2500usb_config_intf(struct rt2x00_dev *rt2x00dev,
320 struct rt2x00_intf *intf, 349 struct rt2x00_intf *intf,
321 struct rt2x00intf_conf *conf, 350 struct rt2x00intf_conf *conf,
@@ -358,18 +387,11 @@ static void rt2500usb_config_intf(struct rt2x00_dev *rt2x00dev,
358 (3 * sizeof(__le16))); 387 (3 * sizeof(__le16)));
359} 388}
360 389
361static int rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev, 390static void rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev,
362 struct rt2x00lib_erp *erp) 391 struct rt2x00lib_erp *erp)
363{ 392{
364 u16 reg; 393 u16 reg;
365 394
366 /*
367 * When in atomic context, we should let rt2x00lib
368 * try this configuration again later.
369 */
370 if (in_atomic())
371 return -EAGAIN;
372
373 rt2500usb_register_read(rt2x00dev, TXRX_CSR1, &reg); 395 rt2500usb_register_read(rt2x00dev, TXRX_CSR1, &reg);
374 rt2x00_set_field16(&reg, TXRX_CSR1_ACK_TIMEOUT, erp->ack_timeout); 396 rt2x00_set_field16(&reg, TXRX_CSR1_ACK_TIMEOUT, erp->ack_timeout);
375 rt2500usb_register_write(rt2x00dev, TXRX_CSR1, reg); 397 rt2500usb_register_write(rt2x00dev, TXRX_CSR1, reg);
@@ -378,8 +400,6 @@ static int rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev,
378 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE, 400 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE,
379 !!erp->short_preamble); 401 !!erp->short_preamble);
380 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg); 402 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg);
381
382 return 0;
383} 403}
384 404
385static void rt2500usb_config_phymode(struct rt2x00_dev *rt2x00dev, 405static void rt2500usb_config_phymode(struct rt2x00_dev *rt2x00dev,
@@ -1139,13 +1159,16 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry,
1139 * the signal is the PLCP value. If it was received with 1159 * the signal is the PLCP value. If it was received with
1140 * a CCK bitrate the signal is the rate in 100kbit/s. 1160 * a CCK bitrate the signal is the rate in 100kbit/s.
1141 */ 1161 */
1142 rxdesc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM);
1143 rxdesc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL); 1162 rxdesc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL);
1144 rxdesc->signal_plcp = rxdesc->ofdm;
1145 rxdesc->rssi = rt2x00_get_field32(word1, RXD_W1_RSSI) - 1163 rxdesc->rssi = rt2x00_get_field32(word1, RXD_W1_RSSI) -
1146 entry->queue->rt2x00dev->rssi_offset; 1164 entry->queue->rt2x00dev->rssi_offset;
1147 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1165 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1148 rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); 1166
1167 rxdesc->dev_flags = 0;
1168 if (rt2x00_get_field32(word0, RXD_W0_OFDM))
1169 rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP;
1170 if (rt2x00_get_field32(word0, RXD_W0_MY_BSS))
1171 rxdesc->dev_flags |= RXDONE_MY_BSS;
1149 1172
1150 /* 1173 /*
1151 * Adjust the skb memory window to the frame boundaries. 1174 * Adjust the skb memory window to the frame boundaries.
@@ -1641,6 +1664,7 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1641 */ 1664 */
1642 __set_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags); 1665 __set_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags);
1643 __set_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags); 1666 __set_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags);
1667 __set_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags);
1644 1668
1645 /* 1669 /*
1646 * Set the rssi offset. 1670 * Set the rssi offset.
@@ -1653,78 +1677,6 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1653/* 1677/*
1654 * IEEE80211 stack callback functions. 1678 * IEEE80211 stack callback functions.
1655 */ 1679 */
1656static void rt2500usb_configure_filter(struct ieee80211_hw *hw,
1657 unsigned int changed_flags,
1658 unsigned int *total_flags,
1659 int mc_count,
1660 struct dev_addr_list *mc_list)
1661{
1662 struct rt2x00_dev *rt2x00dev = hw->priv;
1663 u16 reg;
1664
1665 /*
1666 * Mask off any flags we are going to ignore from
1667 * the total_flags field.
1668 */
1669 *total_flags &=
1670 FIF_ALLMULTI |
1671 FIF_FCSFAIL |
1672 FIF_PLCPFAIL |
1673 FIF_CONTROL |
1674 FIF_OTHER_BSS |
1675 FIF_PROMISC_IN_BSS;
1676
1677 /*
1678 * Apply some rules to the filters:
1679 * - Some filters imply different filters to be set.
1680 * - Some things we can't filter out at all.
1681 */
1682 if (mc_count)
1683 *total_flags |= FIF_ALLMULTI;
1684 if (*total_flags & FIF_OTHER_BSS ||
1685 *total_flags & FIF_PROMISC_IN_BSS)
1686 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1687
1688 /*
1689 * Check if there is any work left for us.
1690 */
1691 if (rt2x00dev->packet_filter == *total_flags)
1692 return;
1693 rt2x00dev->packet_filter = *total_flags;
1694
1695 /*
1696 * When in atomic context, reschedule and let rt2x00lib
1697 * call this function again.
1698 */
1699 if (in_atomic()) {
1700 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work);
1701 return;
1702 }
1703
1704 /*
1705 * Start configuration steps.
1706 * Note that the version error will always be dropped
1707 * and broadcast frames will always be accepted since
1708 * there is no filter for it at this time.
1709 */
1710 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
1711 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CRC,
1712 !(*total_flags & FIF_FCSFAIL));
1713 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_PHYSICAL,
1714 !(*total_flags & FIF_PLCPFAIL));
1715 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CONTROL,
1716 !(*total_flags & FIF_CONTROL));
1717 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_NOT_TO_ME,
1718 !(*total_flags & FIF_PROMISC_IN_BSS));
1719 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_TODS,
1720 !(*total_flags & FIF_PROMISC_IN_BSS));
1721 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_VERSION_ERROR, 1);
1722 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_MULTICAST,
1723 !(*total_flags & FIF_ALLMULTI));
1724 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_BROADCAST, 0);
1725 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
1726}
1727
1728static int rt2500usb_beacon_update(struct ieee80211_hw *hw, 1680static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1729 struct sk_buff *skb, 1681 struct sk_buff *skb,
1730 struct ieee80211_tx_control *control) 1682 struct ieee80211_tx_control *control)
@@ -1821,7 +1773,7 @@ static const struct ieee80211_ops rt2500usb_mac80211_ops = {
1821 .remove_interface = rt2x00mac_remove_interface, 1773 .remove_interface = rt2x00mac_remove_interface,
1822 .config = rt2x00mac_config, 1774 .config = rt2x00mac_config,
1823 .config_interface = rt2x00mac_config_interface, 1775 .config_interface = rt2x00mac_config_interface,
1824 .configure_filter = rt2500usb_configure_filter, 1776 .configure_filter = rt2x00mac_configure_filter,
1825 .get_stats = rt2x00mac_get_stats, 1777 .get_stats = rt2x00mac_get_stats,
1826 .bss_info_changed = rt2x00mac_bss_info_changed, 1778 .bss_info_changed = rt2x00mac_bss_info_changed,
1827 .conf_tx = rt2x00mac_conf_tx, 1779 .conf_tx = rt2x00mac_conf_tx,
@@ -1845,6 +1797,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1845 .get_tx_data_len = rt2500usb_get_tx_data_len, 1797 .get_tx_data_len = rt2500usb_get_tx_data_len,
1846 .kick_tx_queue = rt2500usb_kick_tx_queue, 1798 .kick_tx_queue = rt2500usb_kick_tx_queue,
1847 .fill_rxdone = rt2500usb_fill_rxdone, 1799 .fill_rxdone = rt2500usb_fill_rxdone,
1800 .config_filter = rt2500usb_config_filter,
1848 .config_intf = rt2500usb_config_intf, 1801 .config_intf = rt2500usb_config_intf,
1849 .config_erp = rt2500usb_config_erp, 1802 .config_erp = rt2500usb_config_erp,
1850 .config = rt2500usb_config, 1803 .config = rt2500usb_config,
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index c016bfe1defd..333484ddb993 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -560,6 +560,8 @@ struct rt2x00lib_ops {
560 /* 560 /*
561 * Configuration handlers. 561 * Configuration handlers.
562 */ 562 */
563 void (*config_filter) (struct rt2x00_dev *rt2x00dev,
564 const unsigned int filter_flags);
563 void (*config_intf) (struct rt2x00_dev *rt2x00dev, 565 void (*config_intf) (struct rt2x00_dev *rt2x00dev,
564 struct rt2x00_intf *intf, 566 struct rt2x00_intf *intf,
565 struct rt2x00intf_conf *conf, 567 struct rt2x00intf_conf *conf,
@@ -568,8 +570,8 @@ struct rt2x00lib_ops {
568#define CONFIG_UPDATE_MAC ( 1 << 2 ) 570#define CONFIG_UPDATE_MAC ( 1 << 2 )
569#define CONFIG_UPDATE_BSSID ( 1 << 3 ) 571#define CONFIG_UPDATE_BSSID ( 1 << 3 )
570 572
571 int (*config_erp) (struct rt2x00_dev *rt2x00dev, 573 void (*config_erp) (struct rt2x00_dev *rt2x00dev,
572 struct rt2x00lib_erp *erp); 574 struct rt2x00lib_erp *erp);
573 void (*config) (struct rt2x00_dev *rt2x00dev, 575 void (*config) (struct rt2x00_dev *rt2x00dev,
574 struct rt2x00lib_conf *libconf, 576 struct rt2x00lib_conf *libconf,
575 const unsigned int flags); 577 const unsigned int flags);
@@ -624,6 +626,7 @@ enum rt2x00_flags {
624 DRIVER_REQUIRE_FIRMWARE, 626 DRIVER_REQUIRE_FIRMWARE,
625 DRIVER_REQUIRE_BEACON_GUARD, 627 DRIVER_REQUIRE_BEACON_GUARD,
626 DRIVER_REQUIRE_ATIM_QUEUE, 628 DRIVER_REQUIRE_ATIM_QUEUE,
629 DRIVER_REQUIRE_SCHEDULED,
627 630
628 /* 631 /*
629 * Driver configuration 632 * Driver configuration
@@ -987,6 +990,10 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
987int rt2x00mac_config_interface(struct ieee80211_hw *hw, 990int rt2x00mac_config_interface(struct ieee80211_hw *hw,
988 struct ieee80211_vif *vif, 991 struct ieee80211_vif *vif,
989 struct ieee80211_if_conf *conf); 992 struct ieee80211_if_conf *conf);
993void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
994 unsigned int changed_flags,
995 unsigned int *total_flags,
996 int mc_count, struct dev_addr_list *mc_list);
990int rt2x00mac_get_stats(struct ieee80211_hw *hw, 997int rt2x00mac_get_stats(struct ieee80211_hw *hw,
991 struct ieee80211_low_level_stats *stats); 998 struct ieee80211_low_level_stats *stats);
992int rt2x00mac_get_tx_stats(struct ieee80211_hw *hw, 999int rt2x00mac_get_tx_stats(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 5e2d81a9e438..a9930a03f450 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -80,7 +80,6 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
80 struct ieee80211_bss_conf *bss_conf) 80 struct ieee80211_bss_conf *bss_conf)
81{ 81{
82 struct rt2x00lib_erp erp; 82 struct rt2x00lib_erp erp;
83 int retval;
84 83
85 memset(&erp, 0, sizeof(erp)); 84 memset(&erp, 0, sizeof(erp));
86 85
@@ -101,14 +100,7 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
101 erp.ack_consume_time += PREAMBLE; 100 erp.ack_consume_time += PREAMBLE;
102 } 101 }
103 102
104 retval = rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp); 103 rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp);
105
106 if (retval) {
107 spin_lock(&intf->lock);
108 intf->delayed_flags |= DELAYED_CONFIG_ERP;
109 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work);
110 spin_unlock(&intf->lock);
111 }
112} 104}
113 105
114void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, 106void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index acf4d67ba43d..f52e92512f90 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -580,19 +580,28 @@ void rt2x00lib_rxdone(struct queue_entry *entry,
580 for (i = 0; i < sband->n_bitrates; i++) { 580 for (i = 0; i < sband->n_bitrates; i++) {
581 rate = rt2x00_get_rate(sband->bitrates[i].hw_value); 581 rate = rt2x00_get_rate(sband->bitrates[i].hw_value);
582 582
583 if ((rxdesc->signal_plcp && rate->plcp == rxdesc->signal) || 583 if (((rxdesc->dev_flags & RXDONE_SIGNAL_PLCP) &&
584 (!rxdesc->signal_plcp && rate->bitrate == rxdesc->signal)) { 584 (rate->plcp == rxdesc->signal)) ||
585 (!(rxdesc->dev_flags & RXDONE_SIGNAL_PLCP) &&
586 (rate->bitrate == rxdesc->signal))) {
585 idx = i; 587 idx = i;
586 break; 588 break;
587 } 589 }
588 } 590 }
589 591
592 if (idx < 0) {
593 WARNING(rt2x00dev, "Frame received with unrecognized signal,"
594 "signal=0x%.2x, plcp=%d.\n", rxdesc->signal,
595 !!(rxdesc->dev_flags & RXDONE_SIGNAL_PLCP));
596 idx = 0;
597 }
598
590 /* 599 /*
591 * Only update link status if this is a beacon frame carrying our bssid. 600 * Only update link status if this is a beacon frame carrying our bssid.
592 */ 601 */
593 hdr = (struct ieee80211_hdr *)entry->skb->data; 602 hdr = (struct ieee80211_hdr *)entry->skb->data;
594 fc = le16_to_cpu(hdr->frame_control); 603 fc = le16_to_cpu(hdr->frame_control);
595 if (is_beacon(fc) && rxdesc->my_bss) 604 if (is_beacon(fc) && (rxdesc->dev_flags & RXDONE_MY_BSS))
596 rt2x00lib_update_link_stats(&rt2x00dev->link, rxdesc->rssi); 605 rt2x00lib_update_link_stats(&rt2x00dev->link, rxdesc->rssi);
597 606
598 rt2x00dev->link.qual.rx_success++; 607 rt2x00dev->link.qual.rx_success++;
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 0a11c27d603b..17b6bb034ebf 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -380,6 +380,50 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw,
380} 380}
381EXPORT_SYMBOL_GPL(rt2x00mac_config_interface); 381EXPORT_SYMBOL_GPL(rt2x00mac_config_interface);
382 382
383void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
384 unsigned int changed_flags,
385 unsigned int *total_flags,
386 int mc_count, struct dev_addr_list *mc_list)
387{
388 struct rt2x00_dev *rt2x00dev = hw->priv;
389
390 /*
391 * Mask off any flags we are going to ignore
392 * from the total_flags field.
393 */
394 *total_flags &=
395 FIF_ALLMULTI |
396 FIF_FCSFAIL |
397 FIF_PLCPFAIL |
398 FIF_CONTROL |
399 FIF_OTHER_BSS |
400 FIF_PROMISC_IN_BSS;
401
402 /*
403 * Apply some rules to the filters:
404 * - Some filters imply different filters to be set.
405 * - Some things we can't filter out at all.
406 * - Multicast filter seems to kill broadcast traffic so never use it.
407 */
408 *total_flags |= FIF_ALLMULTI;
409 if (*total_flags & FIF_OTHER_BSS ||
410 *total_flags & FIF_PROMISC_IN_BSS)
411 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
412
413 /*
414 * Check if there is any work left for us.
415 */
416 if (rt2x00dev->packet_filter == *total_flags)
417 return;
418 rt2x00dev->packet_filter = *total_flags;
419
420 if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags))
421 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work);
422 else
423 rt2x00dev->ops->lib->config_filter(rt2x00dev, *total_flags);
424}
425EXPORT_SYMBOL_GPL(rt2x00mac_configure_filter);
426
383int rt2x00mac_get_stats(struct ieee80211_hw *hw, 427int rt2x00mac_get_stats(struct ieee80211_hw *hw,
384 struct ieee80211_low_level_stats *stats) 428 struct ieee80211_low_level_stats *stats)
385{ 429{
@@ -419,6 +463,7 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
419{ 463{
420 struct rt2x00_dev *rt2x00dev = hw->priv; 464 struct rt2x00_dev *rt2x00dev = hw->priv;
421 struct rt2x00_intf *intf = vif_to_intf(vif); 465 struct rt2x00_intf *intf = vif_to_intf(vif);
466 unsigned int delayed = 0;
422 467
423 /* 468 /*
424 * When the association status has changed we must reset the link 469 * When the association status has changed we must reset the link
@@ -439,11 +484,19 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
439 * When the erp information has changed, we should perform 484 * When the erp information has changed, we should perform
440 * additional configuration steps. For all other changes we are done. 485 * additional configuration steps. For all other changes we are done.
441 */ 486 */
442 if (changes & BSS_CHANGED_ERP_PREAMBLE) 487 if (changes & BSS_CHANGED_ERP_PREAMBLE) {
443 rt2x00lib_config_erp(rt2x00dev, intf, bss_conf); 488 if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags))
489 rt2x00lib_config_erp(rt2x00dev, intf, bss_conf);
490 else
491 delayed |= DELAYED_CONFIG_ERP;
492 }
444 493
445 spin_lock(&intf->lock); 494 spin_lock(&intf->lock);
446 memcpy(&intf->conf, bss_conf, sizeof(*bss_conf)); 495 memcpy(&intf->conf, bss_conf, sizeof(*bss_conf));
496 if (delayed) {
497 intf->delayed_flags |= delayed;
498 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work);
499 }
447 spin_unlock(&intf->lock); 500 spin_unlock(&intf->lock);
448} 501}
449EXPORT_SYMBOL_GPL(rt2x00mac_bss_info_changed); 502EXPORT_SYMBOL_GPL(rt2x00mac_bss_info_changed);
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.h b/drivers/net/wireless/rt2x00/rt2x00queue.h
index c5f46f234083..7027c9f47d3f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.h
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.h
@@ -129,27 +129,35 @@ static inline struct skb_frame_desc* get_skb_frame_desc(struct sk_buff *skb)
129} 129}
130 130
131/** 131/**
132 * enum rxdone_entry_desc_flags: Flags for &struct rxdone_entry_desc
133 *
134 * @RXDONE_SIGNAL_PLCP: Does the signal field contain the plcp value,
135 * or does it contain the bitrate itself.
136 * @RXDONE_MY_BSS: Does this frame originate from device's BSS.
137 */
138enum rxdone_entry_desc_flags {
139 RXDONE_SIGNAL_PLCP = 1 << 0,
140 RXDONE_MY_BSS = 1 << 1,
141};
142
143/**
132 * struct rxdone_entry_desc: RX Entry descriptor 144 * struct rxdone_entry_desc: RX Entry descriptor
133 * 145 *
134 * Summary of information that has been read from the RX frame descriptor. 146 * Summary of information that has been read from the RX frame descriptor.
135 * 147 *
136 * @signal: Signal of the received frame. 148 * @signal: Signal of the received frame.
137 * @signal_plcp: Does the signal field contain the plcp value,
138 * or does it contain the bitrate itself.
139 * @rssi: RSSI of the received frame. 149 * @rssi: RSSI of the received frame.
140 * @ofdm: Was frame send with an OFDM rate.
141 * @size: Data size of the received frame. 150 * @size: Data size of the received frame.
142 * @flags: MAC80211 receive flags (See &enum mac80211_rx_flags). 151 * @flags: MAC80211 receive flags (See &enum mac80211_rx_flags).
143 * @my_bss: Does this frame originate from device's BSS. 152 * @dev_flags: Ralink receive flags (See &enum rxdone_entry_desc_flags).
153
144 */ 154 */
145struct rxdone_entry_desc { 155struct rxdone_entry_desc {
146 int signal; 156 int signal;
147 int signal_plcp;
148 int rssi; 157 int rssi;
149 int ofdm;
150 int size; 158 int size;
151 int flags; 159 int flags;
152 int my_bss; 160 int dev_flags;
153}; 161};
154 162
155/** 163/**
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index babb240cef3d..0d2e6f7dd692 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -321,6 +321,37 @@ static void rt61pci_led_brightness(struct led_classdev *led_cdev,
321/* 321/*
322 * Configuration handlers. 322 * Configuration handlers.
323 */ 323 */
324static void rt61pci_config_filter(struct rt2x00_dev *rt2x00dev,
325 const unsigned int filter_flags)
326{
327 u32 reg;
328
329 /*
330 * Start configuration steps.
331 * Note that the version error will always be dropped
332 * and broadcast frames will always be accepted since
333 * there is no filter for it at this time.
334 */
335 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
336 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC,
337 !(filter_flags & FIF_FCSFAIL));
338 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL,
339 !(filter_flags & FIF_PLCPFAIL));
340 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
341 !(filter_flags & FIF_CONTROL));
342 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
343 !(filter_flags & FIF_PROMISC_IN_BSS));
344 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
345 !(filter_flags & FIF_PROMISC_IN_BSS));
346 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
347 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
348 !(filter_flags & FIF_ALLMULTI));
349 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BROADCAST, 0);
350 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS,
351 !(filter_flags & FIF_CONTROL));
352 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
353}
354
324static void rt61pci_config_intf(struct rt2x00_dev *rt2x00dev, 355static void rt61pci_config_intf(struct rt2x00_dev *rt2x00dev,
325 struct rt2x00_intf *intf, 356 struct rt2x00_intf *intf,
326 struct rt2x00intf_conf *conf, 357 struct rt2x00intf_conf *conf,
@@ -368,8 +399,8 @@ static void rt61pci_config_intf(struct rt2x00_dev *rt2x00dev,
368 } 399 }
369} 400}
370 401
371static int rt61pci_config_erp(struct rt2x00_dev *rt2x00dev, 402static void rt61pci_config_erp(struct rt2x00_dev *rt2x00dev,
372 struct rt2x00lib_erp *erp) 403 struct rt2x00lib_erp *erp)
373{ 404{
374 u32 reg; 405 u32 reg;
375 406
@@ -381,8 +412,6 @@ static int rt61pci_config_erp(struct rt2x00_dev *rt2x00dev,
381 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, 412 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
382 !!erp->short_preamble); 413 !!erp->short_preamble);
383 rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg); 414 rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
384
385 return 0;
386} 415}
387 416
388static void rt61pci_config_phymode(struct rt2x00_dev *rt2x00dev, 417static void rt61pci_config_phymode(struct rt2x00_dev *rt2x00dev,
@@ -1649,12 +1678,15 @@ static void rt61pci_fill_rxdone(struct queue_entry *entry,
1649 * the signal is the PLCP value. If it was received with 1678 * the signal is the PLCP value. If it was received with
1650 * a CCK bitrate the signal is the rate in 100kbit/s. 1679 * a CCK bitrate the signal is the rate in 100kbit/s.
1651 */ 1680 */
1652 rxdesc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM);
1653 rxdesc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL); 1681 rxdesc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL);
1654 rxdesc->signal_plcp = rxdesc->ofdm;
1655 rxdesc->rssi = rt61pci_agc_to_rssi(entry->queue->rt2x00dev, word1); 1682 rxdesc->rssi = rt61pci_agc_to_rssi(entry->queue->rt2x00dev, word1);
1656 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1683 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1657 rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); 1684
1685 rxdesc->dev_flags = 0;
1686 if (rt2x00_get_field32(word0, RXD_W0_OFDM))
1687 rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP;
1688 if (rt2x00_get_field32(word0, RXD_W0_MY_BSS))
1689 rxdesc->dev_flags |= RXDONE_MY_BSS;
1658} 1690}
1659 1691
1660/* 1692/*
@@ -2281,71 +2313,6 @@ static int rt61pci_probe_hw(struct rt2x00_dev *rt2x00dev)
2281/* 2313/*
2282 * IEEE80211 stack callback functions. 2314 * IEEE80211 stack callback functions.
2283 */ 2315 */
2284static void rt61pci_configure_filter(struct ieee80211_hw *hw,
2285 unsigned int changed_flags,
2286 unsigned int *total_flags,
2287 int mc_count,
2288 struct dev_addr_list *mc_list)
2289{
2290 struct rt2x00_dev *rt2x00dev = hw->priv;
2291 u32 reg;
2292
2293 /*
2294 * Mask off any flags we are going to ignore from
2295 * the total_flags field.
2296 */
2297 *total_flags &=
2298 FIF_ALLMULTI |
2299 FIF_FCSFAIL |
2300 FIF_PLCPFAIL |
2301 FIF_CONTROL |
2302 FIF_OTHER_BSS |
2303 FIF_PROMISC_IN_BSS;
2304
2305 /*
2306 * Apply some rules to the filters:
2307 * - Some filters imply different filters to be set.
2308 * - Some things we can't filter out at all.
2309 * - Multicast filter seems to kill broadcast traffic so never use it.
2310 */
2311 *total_flags |= FIF_ALLMULTI;
2312 if (*total_flags & FIF_OTHER_BSS ||
2313 *total_flags & FIF_PROMISC_IN_BSS)
2314 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
2315
2316 /*
2317 * Check if there is any work left for us.
2318 */
2319 if (rt2x00dev->packet_filter == *total_flags)
2320 return;
2321 rt2x00dev->packet_filter = *total_flags;
2322
2323 /*
2324 * Start configuration steps.
2325 * Note that the version error will always be dropped
2326 * and broadcast frames will always be accepted since
2327 * there is no filter for it at this time.
2328 */
2329 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
2330 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC,
2331 !(*total_flags & FIF_FCSFAIL));
2332 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL,
2333 !(*total_flags & FIF_PLCPFAIL));
2334 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
2335 !(*total_flags & FIF_CONTROL));
2336 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
2337 !(*total_flags & FIF_PROMISC_IN_BSS));
2338 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
2339 !(*total_flags & FIF_PROMISC_IN_BSS));
2340 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
2341 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
2342 !(*total_flags & FIF_ALLMULTI));
2343 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BROADCAST, 0);
2344 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS,
2345 !(*total_flags & FIF_CONTROL));
2346 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
2347}
2348
2349static int rt61pci_set_retry_limit(struct ieee80211_hw *hw, 2316static int rt61pci_set_retry_limit(struct ieee80211_hw *hw,
2350 u32 short_retry, u32 long_retry) 2317 u32 short_retry, u32 long_retry)
2351{ 2318{
@@ -2454,7 +2421,7 @@ static const struct ieee80211_ops rt61pci_mac80211_ops = {
2454 .remove_interface = rt2x00mac_remove_interface, 2421 .remove_interface = rt2x00mac_remove_interface,
2455 .config = rt2x00mac_config, 2422 .config = rt2x00mac_config,
2456 .config_interface = rt2x00mac_config_interface, 2423 .config_interface = rt2x00mac_config_interface,
2457 .configure_filter = rt61pci_configure_filter, 2424 .configure_filter = rt2x00mac_configure_filter,
2458 .get_stats = rt2x00mac_get_stats, 2425 .get_stats = rt2x00mac_get_stats,
2459 .set_retry_limit = rt61pci_set_retry_limit, 2426 .set_retry_limit = rt61pci_set_retry_limit,
2460 .bss_info_changed = rt2x00mac_bss_info_changed, 2427 .bss_info_changed = rt2x00mac_bss_info_changed,
@@ -2484,6 +2451,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2484 .write_tx_data = rt2x00pci_write_tx_data, 2451 .write_tx_data = rt2x00pci_write_tx_data,
2485 .kick_tx_queue = rt61pci_kick_tx_queue, 2452 .kick_tx_queue = rt61pci_kick_tx_queue,
2486 .fill_rxdone = rt61pci_fill_rxdone, 2453 .fill_rxdone = rt61pci_fill_rxdone,
2454 .config_filter = rt61pci_config_filter,
2487 .config_intf = rt61pci_config_intf, 2455 .config_intf = rt61pci_config_intf,
2488 .config_erp = rt61pci_config_erp, 2456 .config_erp = rt61pci_config_erp,
2489 .config = rt61pci_config, 2457 .config = rt61pci_config,
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 46b040bf62de..187e832bab2e 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -333,6 +333,37 @@ static void rt73usb_led_brightness(struct led_classdev *led_cdev,
333/* 333/*
334 * Configuration handlers. 334 * Configuration handlers.
335 */ 335 */
336static void rt73usb_config_filter(struct rt2x00_dev *rt2x00dev,
337 const unsigned int filter_flags)
338{
339 u32 reg;
340
341 /*
342 * Start configuration steps.
343 * Note that the version error will always be dropped
344 * and broadcast frames will always be accepted since
345 * there is no filter for it at this time.
346 */
347 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
348 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC,
349 !(filter_flags & FIF_FCSFAIL));
350 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL,
351 !(filter_flags & FIF_PLCPFAIL));
352 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
353 !(filter_flags & FIF_CONTROL));
354 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
355 !(filter_flags & FIF_PROMISC_IN_BSS));
356 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
357 !(filter_flags & FIF_PROMISC_IN_BSS));
358 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
359 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
360 !(filter_flags & FIF_ALLMULTI));
361 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BROADCAST, 0);
362 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS,
363 !(filter_flags & FIF_CONTROL));
364 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
365}
366
336static void rt73usb_config_intf(struct rt2x00_dev *rt2x00dev, 367static void rt73usb_config_intf(struct rt2x00_dev *rt2x00dev,
337 struct rt2x00_intf *intf, 368 struct rt2x00_intf *intf,
338 struct rt2x00intf_conf *conf, 369 struct rt2x00intf_conf *conf,
@@ -380,18 +411,11 @@ static void rt73usb_config_intf(struct rt2x00_dev *rt2x00dev,
380 } 411 }
381} 412}
382 413
383static int rt73usb_config_erp(struct rt2x00_dev *rt2x00dev, 414static void rt73usb_config_erp(struct rt2x00_dev *rt2x00dev,
384 struct rt2x00lib_erp *erp) 415 struct rt2x00lib_erp *erp)
385{ 416{
386 u32 reg; 417 u32 reg;
387 418
388 /*
389 * When in atomic context, we should let rt2x00lib
390 * try this configuration again later.
391 */
392 if (in_atomic())
393 return -EAGAIN;
394
395 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg); 419 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
396 rt2x00_set_field32(&reg, TXRX_CSR0_RX_ACK_TIMEOUT, erp->ack_timeout); 420 rt2x00_set_field32(&reg, TXRX_CSR0_RX_ACK_TIMEOUT, erp->ack_timeout);
397 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg); 421 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
@@ -400,8 +424,6 @@ static int rt73usb_config_erp(struct rt2x00_dev *rt2x00dev,
400 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, 424 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
401 !!erp->short_preamble); 425 !!erp->short_preamble);
402 rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg); 426 rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg);
403
404 return 0;
405} 427}
406 428
407static void rt73usb_config_phymode(struct rt2x00_dev *rt2x00dev, 429static void rt73usb_config_phymode(struct rt2x00_dev *rt2x00dev,
@@ -1409,12 +1431,15 @@ static void rt73usb_fill_rxdone(struct queue_entry *entry,
1409 * the signal is the PLCP value. If it was received with 1431 * the signal is the PLCP value. If it was received with
1410 * a CCK bitrate the signal is the rate in 100kbit/s. 1432 * a CCK bitrate the signal is the rate in 100kbit/s.
1411 */ 1433 */
1412 rxdesc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM);
1413 rxdesc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL); 1434 rxdesc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL);
1414 rxdesc->signal_plcp = rxdesc->ofdm;
1415 rxdesc->rssi = rt73usb_agc_to_rssi(entry->queue->rt2x00dev, word1); 1435 rxdesc->rssi = rt73usb_agc_to_rssi(entry->queue->rt2x00dev, word1);
1416 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1436 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1417 rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); 1437
1438 rxdesc->dev_flags = 0;
1439 if (rt2x00_get_field32(word0, RXD_W0_OFDM))
1440 rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP;
1441 if (rt2x00_get_field32(word0, RXD_W0_MY_BSS))
1442 rxdesc->dev_flags |= RXDONE_MY_BSS;
1418 1443
1419 /* 1444 /*
1420 * Adjust the skb memory window to the frame boundaries. 1445 * Adjust the skb memory window to the frame boundaries.
@@ -1869,6 +1894,7 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1869 * This device requires firmware. 1894 * This device requires firmware.
1870 */ 1895 */
1871 __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags); 1896 __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags);
1897 __set_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags);
1872 1898
1873 /* 1899 /*
1874 * Set the rssi offset. 1900 * Set the rssi offset.
@@ -1881,80 +1907,6 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1881/* 1907/*
1882 * IEEE80211 stack callback functions. 1908 * IEEE80211 stack callback functions.
1883 */ 1909 */
1884static void rt73usb_configure_filter(struct ieee80211_hw *hw,
1885 unsigned int changed_flags,
1886 unsigned int *total_flags,
1887 int mc_count,
1888 struct dev_addr_list *mc_list)
1889{
1890 struct rt2x00_dev *rt2x00dev = hw->priv;
1891 u32 reg;
1892
1893 /*
1894 * Mask off any flags we are going to ignore from
1895 * the total_flags field.
1896 */
1897 *total_flags &=
1898 FIF_ALLMULTI |
1899 FIF_FCSFAIL |
1900 FIF_PLCPFAIL |
1901 FIF_CONTROL |
1902 FIF_OTHER_BSS |
1903 FIF_PROMISC_IN_BSS;
1904
1905 /*
1906 * Apply some rules to the filters:
1907 * - Some filters imply different filters to be set.
1908 * - Some things we can't filter out at all.
1909 * - Multicast filter seems to kill broadcast traffic so never use it.
1910 */
1911 *total_flags |= FIF_ALLMULTI;
1912 if (*total_flags & FIF_OTHER_BSS ||
1913 *total_flags & FIF_PROMISC_IN_BSS)
1914 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1915
1916 /*
1917 * Check if there is any work left for us.
1918 */
1919 if (rt2x00dev->packet_filter == *total_flags)
1920 return;
1921 rt2x00dev->packet_filter = *total_flags;
1922
1923 /*
1924 * When in atomic context, reschedule and let rt2x00lib
1925 * call this function again.
1926 */
1927 if (in_atomic()) {
1928 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work);
1929 return;
1930 }
1931
1932 /*
1933 * Start configuration steps.
1934 * Note that the version error will always be dropped
1935 * and broadcast frames will always be accepted since
1936 * there is no filter for it at this time.
1937 */
1938 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
1939 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC,
1940 !(*total_flags & FIF_FCSFAIL));
1941 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL,
1942 !(*total_flags & FIF_PLCPFAIL));
1943 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
1944 !(*total_flags & FIF_CONTROL));
1945 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
1946 !(*total_flags & FIF_PROMISC_IN_BSS));
1947 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
1948 !(*total_flags & FIF_PROMISC_IN_BSS));
1949 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
1950 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
1951 !(*total_flags & FIF_ALLMULTI));
1952 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BROADCAST, 0);
1953 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS,
1954 !(*total_flags & FIF_CONTROL));
1955 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
1956}
1957
1958static int rt73usb_set_retry_limit(struct ieee80211_hw *hw, 1910static int rt73usb_set_retry_limit(struct ieee80211_hw *hw,
1959 u32 short_retry, u32 long_retry) 1911 u32 short_retry, u32 long_retry)
1960{ 1912{
@@ -2064,7 +2016,7 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = {
2064 .remove_interface = rt2x00mac_remove_interface, 2016 .remove_interface = rt2x00mac_remove_interface,
2065 .config = rt2x00mac_config, 2017 .config = rt2x00mac_config,
2066 .config_interface = rt2x00mac_config_interface, 2018 .config_interface = rt2x00mac_config_interface,
2067 .configure_filter = rt73usb_configure_filter, 2019 .configure_filter = rt2x00mac_configure_filter,
2068 .get_stats = rt2x00mac_get_stats, 2020 .get_stats = rt2x00mac_get_stats,
2069 .set_retry_limit = rt73usb_set_retry_limit, 2021 .set_retry_limit = rt73usb_set_retry_limit,
2070 .bss_info_changed = rt2x00mac_bss_info_changed, 2022 .bss_info_changed = rt2x00mac_bss_info_changed,
@@ -2093,6 +2045,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2093 .get_tx_data_len = rt73usb_get_tx_data_len, 2045 .get_tx_data_len = rt73usb_get_tx_data_len,
2094 .kick_tx_queue = rt73usb_kick_tx_queue, 2046 .kick_tx_queue = rt73usb_kick_tx_queue,
2095 .fill_rxdone = rt73usb_fill_rxdone, 2047 .fill_rxdone = rt73usb_fill_rxdone,
2048 .config_filter = rt73usb_config_filter,
2096 .config_intf = rt73usb_config_intf, 2049 .config_intf = rt73usb_config_intf,
2097 .config_erp = rt73usb_config_erp, 2050 .config_erp = rt73usb_config_erp,
2098 .config = rt73usb_config, 2051 .config = rt73usb_config,
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 5ab6a350ee6d..48428a6b9109 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -644,6 +644,21 @@ enum sta_notify_cmd {
644}; 644};
645 645
646/** 646/**
647 * enum ieee80211_tkip_key_type - get tkip key
648 *
649 * Used by drivers which need to get a tkip key for skb. Some drivers need a
650 * phase 1 key, others need a phase 2 key. A single function allows the driver
651 * to get the key, this enum indicates what type of key is required.
652 *
653 * @IEEE80211_TKIP_P1_KEY: the driver needs a phase 1 key
654 * @IEEE80211_TKIP_P2_KEY: the driver needs a phase 2 key
655 */
656enum ieee80211_tkip_key_type {
657 IEEE80211_TKIP_P1_KEY,
658 IEEE80211_TKIP_P2_KEY,
659};
660
661/**
647 * enum ieee80211_hw_flags - hardware flags 662 * enum ieee80211_hw_flags - hardware flags
648 * 663 *
649 * These flags are used to indicate hardware capabilities to 664 * These flags are used to indicate hardware capabilities to
@@ -812,6 +827,16 @@ static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
812 * parameter is guaranteed to be valid until another call to set_key() 827 * parameter is guaranteed to be valid until another call to set_key()
813 * removes it, but it can only be used as a cookie to differentiate 828 * removes it, but it can only be used as a cookie to differentiate
814 * keys. 829 * keys.
830 *
831 * In TKIP some HW need to be provided a phase 1 key, for RX decryption
832 * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key
833 * handler.
834 * The update_tkip_key() call updates the driver with the new phase 1 key.
835 * This happens everytime the iv16 wraps around (every 65536 packets). The
836 * set_key() call will happen only once for each key (unless the AP did
837 * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is
838 * provided by udpate_tkip_key only. The trigger that makes mac80211 call this
839 * handler is software decryption with wrap around of iv16.
815 */ 840 */
816 841
817/** 842/**
@@ -988,6 +1013,10 @@ enum ieee80211_ampdu_mlme_action {
988 * and remove_interface calls, i.e. while the interface with the 1013 * and remove_interface calls, i.e. while the interface with the
989 * given local_address is enabled. 1014 * given local_address is enabled.
990 * 1015 *
1016 * @update_tkip_key: See the section "Hardware crypto acceleration"
1017 * This callback will be called in the context of Rx. Called for drivers
1018 * which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY.
1019 *
991 * @hw_scan: Ask the hardware to service the scan request, no need to start 1020 * @hw_scan: Ask the hardware to service the scan request, no need to start
992 * the scan state machine in stack. The scan must honour the channel 1021 * the scan state machine in stack. The scan must honour the channel
993 * configuration done by the regulatory agent in the wiphy's registered 1022 * configuration done by the regulatory agent in the wiphy's registered
@@ -1079,6 +1108,9 @@ struct ieee80211_ops {
1079 int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd, 1108 int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1080 const u8 *local_address, const u8 *address, 1109 const u8 *local_address, const u8 *address,
1081 struct ieee80211_key_conf *key); 1110 struct ieee80211_key_conf *key);
1111 void (*update_tkip_key)(struct ieee80211_hw *hw,
1112 struct ieee80211_key_conf *conf, const u8 *address,
1113 u32 iv32, u16 *phase1key);
1082 int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len); 1114 int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len);
1083 int (*get_stats)(struct ieee80211_hw *hw, 1115 int (*get_stats)(struct ieee80211_hw *hw,
1084 struct ieee80211_low_level_stats *stats); 1116 struct ieee80211_low_level_stats *stats);
@@ -1472,6 +1504,21 @@ int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
1472int ieee80211_get_hdrlen(u16 fc); 1504int ieee80211_get_hdrlen(u16 fc);
1473 1505
1474/** 1506/**
1507 * ieee80211_get_tkip_key - get a TKIP rc4 for skb
1508 *
1509 * This function computes a TKIP rc4 key for an skb. It computes
1510 * a phase 1 key if needed (iv16 wraps around). This function is to
1511 * be used by drivers which can do HW encryption but need to compute
1512 * to phase 1/2 key in SW.
1513 *
1514 * @keyconf: the parameter passed with the set key
1515 * @skb: the skb for which the key is needed
1516 * @rc4key: a buffer to which the key will be written
1517 */
1518void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
1519 struct sk_buff *skb,
1520 enum ieee80211_tkip_key_type type, u8 *key);
1521/**
1475 * ieee80211_wake_queue - wake specific queue 1522 * ieee80211_wake_queue - wake specific queue
1476 * @hw: pointer as obtained from ieee80211_alloc_hw(). 1523 * @hw: pointer as obtained from ieee80211_alloc_hw().
1477 * @queue: queue number (counted from zero). 1524 * @queue: queue number (counted from zero).
diff --git a/include/net/wireless.h b/include/net/wireless.h
index c7f805ee5545..f4b77ab66bae 100644
--- a/include/net/wireless.h
+++ b/include/net/wireless.h
@@ -304,4 +304,10 @@ extern int ieee80211_channel_to_frequency(int chan);
304 */ 304 */
305extern int ieee80211_frequency_to_channel(int freq); 305extern int ieee80211_frequency_to_channel(int freq);
306 306
307/**
308 * ieee80211_get_channel - get channel struct from wiphy for specified frequency
309 */
310extern struct ieee80211_channel *ieee80211_get_channel(struct wiphy *wiphy,
311 int freq);
312
307#endif /* __NET_WIRELESS_H */ 313#endif /* __NET_WIRELESS_H */
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c
index 55b63712e48c..616ce10d2a38 100644
--- a/net/mac80211/ieee80211.c
+++ b/net/mac80211/ieee80211.c
@@ -386,7 +386,6 @@ static int ieee80211_stop(struct net_device *dev)
386 struct ieee80211_local *local = sdata->local; 386 struct ieee80211_local *local = sdata->local;
387 struct ieee80211_if_init_conf conf; 387 struct ieee80211_if_init_conf conf;
388 struct sta_info *sta; 388 struct sta_info *sta;
389 int i;
390 389
391 /* 390 /*
392 * Stop TX on this interface first. 391 * Stop TX on this interface first.
@@ -400,11 +399,7 @@ static int ieee80211_stop(struct net_device *dev)
400 399
401 list_for_each_entry_rcu(sta, &local->sta_list, list) { 400 list_for_each_entry_rcu(sta, &local->sta_list, list) {
402 if (sta->sdata == sdata) 401 if (sta->sdata == sdata)
403 for (i = 0; i < STA_TID_NUM; i++) 402 ieee80211_sta_tear_down_BA_sessions(dev, sta->addr);
404 ieee80211_sta_stop_rx_ba_session(sdata->dev,
405 sta->addr, i,
406 WLAN_BACK_RECIPIENT,
407 WLAN_REASON_QSTA_LEAVE_QBSS);
408 } 403 }
409 404
410 rcu_read_unlock(); 405 rcu_read_unlock();
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 7f10ff5d4a0b..a6485f01b3c8 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -928,10 +928,12 @@ void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
928 u16 agg_size, u16 timeout); 928 u16 agg_size, u16 timeout);
929void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid, 929void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
930 u16 initiator, u16 reason_code); 930 u16 initiator, u16 reason_code);
931
931void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da, 932void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da,
932 u16 tid, u16 initiator, u16 reason); 933 u16 tid, u16 initiator, u16 reason);
933void sta_rx_agg_session_timer_expired(unsigned long data); 934void sta_rx_agg_session_timer_expired(unsigned long data);
934void sta_addba_resp_timer_expired(unsigned long data); 935void sta_addba_resp_timer_expired(unsigned long data);
936void ieee80211_sta_tear_down_BA_sessions(struct net_device *dev, u8 *addr);
935u64 ieee80211_sta_get_rates(struct ieee80211_local *local, 937u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
936 struct ieee802_11_elems *elems, 938 struct ieee802_11_elems *elems,
937 enum ieee80211_band band); 939 enum ieee80211_band band);
diff --git a/net/mac80211/ieee80211_ioctl.c b/net/mac80211/ieee80211_ioctl.c
index 1d91575a0fe9..5af23d318726 100644
--- a/net/mac80211/ieee80211_ioctl.c
+++ b/net/mac80211/ieee80211_ioctl.c
@@ -279,36 +279,15 @@ static int ieee80211_ioctl_giwmode(struct net_device *dev,
279 279
280int ieee80211_set_freq(struct ieee80211_local *local, int freqMHz) 280int ieee80211_set_freq(struct ieee80211_local *local, int freqMHz)
281{ 281{
282 int set = 0;
283 int ret = -EINVAL; 282 int ret = -EINVAL;
284 enum ieee80211_band band; 283 struct ieee80211_channel *chan;
285 struct ieee80211_supported_band *sband;
286 int i;
287
288 for (band = 0; band < IEEE80211_NUM_BANDS; band ++) {
289 sband = local->hw.wiphy->bands[band];
290 284
291 if (!sband) 285 chan = ieee80211_get_channel(local->hw.wiphy, freqMHz);
292 continue;
293 286
294 for (i = 0; i < sband->n_channels; i++) { 287 if (chan && !(chan->flags & IEEE80211_CHAN_DISABLED)) {
295 struct ieee80211_channel *chan = &sband->channels[i]; 288 local->oper_channel = chan;
296
297 if (chan->flags & IEEE80211_CHAN_DISABLED)
298 continue;
299
300 if (chan->center_freq == freqMHz) {
301 set = 1;
302 local->oper_channel = chan;
303 break;
304 }
305 }
306 if (set)
307 break;
308 }
309 289
310 if (set) { 290 if (local->sta_sw_scanning || local->sta_hw_scanning)
311 if (local->sta_sw_scanning)
312 ret = 0; 291 ret = 0;
313 else 292 else
314 ret = ieee80211_hw_config(local); 293 ret = ieee80211_hw_config(local);
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index 8b991ebcbb4e..cf51ca6804dd 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -220,6 +220,61 @@ static int ecw2cw(int ecw)
220 return (1 << ecw) - 1; 220 return (1 << ecw) - 1;
221} 221}
222 222
223
224static void ieee80211_sta_def_wmm_params(struct net_device *dev,
225 struct ieee80211_sta_bss *bss,
226 int ibss)
227{
228 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
229 struct ieee80211_local *local = sdata->local;
230 int i, have_higher_than_11mbit = 0;
231
232
233 /* cf. IEEE 802.11 9.2.12 */
234 for (i = 0; i < bss->supp_rates_len; i++)
235 if ((bss->supp_rates[i] & 0x7f) * 5 > 110)
236 have_higher_than_11mbit = 1;
237
238 if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ &&
239 have_higher_than_11mbit)
240 sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE;
241 else
242 sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
243
244
245 if (local->ops->conf_tx) {
246 struct ieee80211_tx_queue_params qparam;
247 int i;
248
249 memset(&qparam, 0, sizeof(qparam));
250
251 qparam.aifs = 2;
252
253 if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ &&
254 !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE))
255 qparam.cw_min = 31;
256 else
257 qparam.cw_min = 15;
258
259 qparam.cw_max = 1023;
260 qparam.txop = 0;
261
262 for (i = IEEE80211_TX_QUEUE_DATA0; i < NUM_TX_DATA_QUEUES; i++)
263 local->ops->conf_tx(local_to_hw(local),
264 i + IEEE80211_TX_QUEUE_DATA0,
265 &qparam);
266
267 if (ibss) {
268 /* IBSS uses different parameters for Beacon sending */
269 qparam.cw_min++;
270 qparam.cw_min *= 2;
271 qparam.cw_min--;
272 local->ops->conf_tx(local_to_hw(local),
273 IEEE80211_TX_QUEUE_BEACON, &qparam);
274 }
275 }
276}
277
223static void ieee80211_sta_wmm_params(struct net_device *dev, 278static void ieee80211_sta_wmm_params(struct net_device *dev,
224 struct ieee80211_if_sta *ifsta, 279 struct ieee80211_if_sta *ifsta,
225 u8 *wmm_param, size_t wmm_param_len) 280 u8 *wmm_param, size_t wmm_param_len)
@@ -467,8 +522,8 @@ static void ieee80211_set_associated(struct net_device *dev,
467 memcpy(wrqu.ap_addr.sa_data, sdata->u.sta.bssid, ETH_ALEN); 522 memcpy(wrqu.ap_addr.sa_data, sdata->u.sta.bssid, ETH_ALEN);
468 ieee80211_sta_send_associnfo(dev, ifsta); 523 ieee80211_sta_send_associnfo(dev, ifsta);
469 } else { 524 } else {
525 ieee80211_sta_tear_down_BA_sessions(dev, ifsta->bssid);
470 ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; 526 ifsta->flags &= ~IEEE80211_STA_ASSOCIATED;
471
472 netif_carrier_off(dev); 527 netif_carrier_off(dev);
473 ieee80211_reset_erp_info(dev); 528 ieee80211_reset_erp_info(dev);
474 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); 529 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
@@ -1145,7 +1200,7 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev,
1145 status = WLAN_STATUS_INVALID_QOS_PARAM; 1200 status = WLAN_STATUS_INVALID_QOS_PARAM;
1146#ifdef CONFIG_MAC80211_HT_DEBUG 1201#ifdef CONFIG_MAC80211_HT_DEBUG
1147 if (net_ratelimit()) 1202 if (net_ratelimit())
1148 printk(KERN_DEBUG "Block Ack Req with bad params from " 1203 printk(KERN_DEBUG "AddBA Req with bad params from "
1149 "%s on tid %u. policy %d, buffer size %d\n", 1204 "%s on tid %u. policy %d, buffer size %d\n",
1150 print_mac(mac, mgmt->sa), tid, ba_policy, 1205 print_mac(mac, mgmt->sa), tid, ba_policy,
1151 buf_size); 1206 buf_size);
@@ -1169,7 +1224,7 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev,
1169 if (tid_agg_rx->state != HT_AGG_STATE_IDLE) { 1224 if (tid_agg_rx->state != HT_AGG_STATE_IDLE) {
1170#ifdef CONFIG_MAC80211_HT_DEBUG 1225#ifdef CONFIG_MAC80211_HT_DEBUG
1171 if (net_ratelimit()) 1226 if (net_ratelimit())
1172 printk(KERN_DEBUG "unexpected Block Ack Req from " 1227 printk(KERN_DEBUG "unexpected AddBA Req from "
1173 "%s on tid %u\n", 1228 "%s on tid %u\n",
1174 print_mac(mac, mgmt->sa), tid); 1229 print_mac(mac, mgmt->sa), tid);
1175#endif /* CONFIG_MAC80211_HT_DEBUG */ 1230#endif /* CONFIG_MAC80211_HT_DEBUG */
@@ -1427,7 +1482,7 @@ static void ieee80211_sta_process_delba(struct net_device *dev,
1427 if (net_ratelimit()) 1482 if (net_ratelimit())
1428 printk(KERN_DEBUG "delba from %s (%s) tid %d reason code %d\n", 1483 printk(KERN_DEBUG "delba from %s (%s) tid %d reason code %d\n",
1429 print_mac(mac, mgmt->sa), 1484 print_mac(mac, mgmt->sa),
1430 initiator ? "recipient" : "initiator", tid, 1485 initiator ? "initiator" : "recipient", tid,
1431 mgmt->u.action.u.delba.reason_code); 1486 mgmt->u.action.u.delba.reason_code);
1432#endif /* CONFIG_MAC80211_HT_DEBUG */ 1487#endif /* CONFIG_MAC80211_HT_DEBUG */
1433 1488
@@ -1497,8 +1552,8 @@ timer_expired_exit:
1497} 1552}
1498 1553
1499/* 1554/*
1500 * After receiving Block Ack Request (BAR) we activated a 1555 * After accepting the AddBA Request we activated a timer,
1501 * timer after each frame arrives from the originator. 1556 * resetting it after each frame that arrives from the originator.
1502 * if this timer expires ieee80211_sta_stop_rx_ba_session will be executed. 1557 * if this timer expires ieee80211_sta_stop_rx_ba_session will be executed.
1503 */ 1558 */
1504void sta_rx_agg_session_timer_expired(unsigned long data) 1559void sta_rx_agg_session_timer_expired(unsigned long data)
@@ -1518,6 +1573,19 @@ void sta_rx_agg_session_timer_expired(unsigned long data)
1518 WLAN_REASON_QSTA_TIMEOUT); 1573 WLAN_REASON_QSTA_TIMEOUT);
1519} 1574}
1520 1575
1576void ieee80211_sta_tear_down_BA_sessions(struct net_device *dev, u8 *addr)
1577{
1578 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1579 int i;
1580
1581 for (i = 0; i < STA_TID_NUM; i++) {
1582 ieee80211_stop_tx_ba_session(&local->hw, addr, i,
1583 WLAN_BACK_INITIATOR);
1584 ieee80211_sta_stop_rx_ba_session(dev, addr, i,
1585 WLAN_BACK_RECIPIENT,
1586 WLAN_REASON_QSTA_LEAVE_QBSS);
1587 }
1588}
1521 1589
1522static void ieee80211_rx_mgmt_auth(struct net_device *dev, 1590static void ieee80211_rx_mgmt_auth(struct net_device *dev,
1523 struct ieee80211_if_sta *ifsta, 1591 struct ieee80211_if_sta *ifsta,
@@ -2289,6 +2357,8 @@ static int ieee80211_sta_join_ibss(struct net_device *dev,
2289 rates |= BIT(j); 2357 rates |= BIT(j);
2290 } 2358 }
2291 ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; 2359 ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates;
2360
2361 ieee80211_sta_def_wmm_params(dev, bss, 1);
2292 } while (0); 2362 } while (0);
2293 2363
2294 if (skb) { 2364 if (skb) {
@@ -2356,6 +2426,7 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
2356 struct sta_info *sta; 2426 struct sta_info *sta;
2357 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2427 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2358 u64 beacon_timestamp, rx_timestamp; 2428 u64 beacon_timestamp, rx_timestamp;
2429 struct ieee80211_channel *channel;
2359 DECLARE_MAC_BUF(mac); 2430 DECLARE_MAC_BUF(mac);
2360 DECLARE_MAC_BUF(mac2); 2431 DECLARE_MAC_BUF(mac2);
2361 2432
@@ -2420,6 +2491,11 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
2420 else 2491 else
2421 freq = rx_status->freq; 2492 freq = rx_status->freq;
2422 2493
2494 channel = ieee80211_get_channel(local->hw.wiphy, freq);
2495
2496 if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
2497 return;
2498
2423#ifdef CONFIG_MAC80211_MESH 2499#ifdef CONFIG_MAC80211_MESH
2424 if (elems.mesh_config) 2500 if (elems.mesh_config)
2425 bss = ieee80211_rx_mesh_bss_get(dev, elems.mesh_id, 2501 bss = ieee80211_rx_mesh_bss_get(dev, elems.mesh_id,
@@ -3274,6 +3350,7 @@ static int ieee80211_sta_config_auth(struct net_device *dev,
3274 ieee80211_sta_set_ssid(dev, selected->ssid, 3350 ieee80211_sta_set_ssid(dev, selected->ssid,
3275 selected->ssid_len); 3351 selected->ssid_len);
3276 ieee80211_sta_set_bssid(dev, selected->bssid); 3352 ieee80211_sta_set_bssid(dev, selected->bssid);
3353 ieee80211_sta_def_wmm_params(dev, selected, 0);
3277 ieee80211_rx_bss_put(dev, selected); 3354 ieee80211_rx_bss_put(dev, selected);
3278 ifsta->state = IEEE80211_AUTHENTICATE; 3355 ifsta->state = IEEE80211_AUTHENTICATE;
3279 ieee80211_sta_reset_auth(dev, ifsta); 3356 ieee80211_sta_reset_auth(dev, ifsta);
@@ -3448,43 +3525,10 @@ int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len)
3448{ 3525{
3449 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3526 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3450 struct ieee80211_if_sta *ifsta; 3527 struct ieee80211_if_sta *ifsta;
3451 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3452 3528
3453 if (len > IEEE80211_MAX_SSID_LEN) 3529 if (len > IEEE80211_MAX_SSID_LEN)
3454 return -EINVAL; 3530 return -EINVAL;
3455 3531
3456 /* TODO: This should always be done for IBSS, even if IEEE80211_QOS is
3457 * not defined. */
3458 if (local->ops->conf_tx) {
3459 struct ieee80211_tx_queue_params qparam;
3460 int i;
3461
3462 memset(&qparam, 0, sizeof(qparam));
3463
3464 qparam.aifs = 2;
3465
3466 if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ &&
3467 !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE))
3468 qparam.cw_min = 31;
3469 else
3470 qparam.cw_min = 15;
3471
3472 qparam.cw_max = 1023;
3473 qparam.txop = 0;
3474
3475 for (i = IEEE80211_TX_QUEUE_DATA0; i < NUM_TX_DATA_QUEUES; i++)
3476 local->ops->conf_tx(local_to_hw(local),
3477 i + IEEE80211_TX_QUEUE_DATA0,
3478 &qparam);
3479
3480 /* IBSS uses different parameters for Beacon sending */
3481 qparam.cw_min++;
3482 qparam.cw_min *= 2;
3483 qparam.cw_min--;
3484 local->ops->conf_tx(local_to_hw(local),
3485 IEEE80211_TX_QUEUE_BEACON, &qparam);
3486 }
3487
3488 ifsta = &sdata->u.sta; 3532 ifsta = &sdata->u.sta;
3489 3533
3490 if (ifsta->ssid_len != len || memcmp(ifsta->ssid, ssid, len) != 0) 3534 if (ifsta->ssid_len != len || memcmp(ifsta->ssid, ssid, len) != 0)
@@ -3596,6 +3640,9 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw)
3596 3640
3597 if (local->sta_hw_scanning) { 3641 if (local->sta_hw_scanning) {
3598 local->sta_hw_scanning = 0; 3642 local->sta_hw_scanning = 0;
3643 if (ieee80211_hw_config(local))
3644 printk(KERN_DEBUG "%s: failed to restore operational "
3645 "channel after scan\n", dev->name);
3599 /* Restart STA timer for HW scan case */ 3646 /* Restart STA timer for HW scan case */
3600 rcu_read_lock(); 3647 rcu_read_lock();
3601 list_for_each_entry_rcu(sdata, &local->interfaces, list) 3648 list_for_each_entry_rcu(sdata, &local->interfaces, list)
diff --git a/net/mac80211/tkip.c b/net/mac80211/tkip.c
index 3abe194e4d55..45d59f19c29f 100644
--- a/net/mac80211/tkip.c
+++ b/net/mac80211/tkip.c
@@ -214,6 +214,59 @@ void ieee80211_tkip_gen_rc4key(struct ieee80211_key *key, u8 *ta,
214 key->u.tkip.iv16, rc4key); 214 key->u.tkip.iv16, rc4key);
215} 215}
216 216
217void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
218 struct sk_buff *skb, enum ieee80211_tkip_key_type type,
219 u8 *outkey)
220{
221 struct ieee80211_key *key = (struct ieee80211_key *)
222 container_of(keyconf, struct ieee80211_key, conf);
223 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
224 u8 *data = (u8 *) hdr;
225 u16 fc = le16_to_cpu(hdr->frame_control);
226 int hdr_len = ieee80211_get_hdrlen(fc);
227 u8 *ta = hdr->addr2;
228 u16 iv16;
229 u32 iv32;
230
231 iv16 = data[hdr_len] << 8;
232 iv16 += data[hdr_len + 2];
233 iv32 = data[hdr_len + 4] +
234 (data[hdr_len + 5] >> 8) +
235 (data[hdr_len + 6] >> 16) +
236 (data[hdr_len + 7] >> 24);
237
238#ifdef CONFIG_TKIP_DEBUG
239 printk(KERN_DEBUG "TKIP encrypt: iv16 = 0x%04x, iv32 = 0x%08x\n",
240 iv16, iv32);
241
242 if (iv32 != key->u.tkip.iv32) {
243 printk(KERN_DEBUG "skb: iv32 = 0x%08x key: iv32 = 0x%08x\n",
244 iv32, key->u.tkip.iv32);
245 printk(KERN_DEBUG "Wrap around of iv16 in the middle of a "
246 "fragmented packet\n");
247 }
248#endif /* CONFIG_TKIP_DEBUG */
249
250 /* Update the p1k only when the iv16 in the packet wraps around, this
251 * might occur after the wrap around of iv16 in the key in case of
252 * fragmented packets. */
253 if (iv16 == 0 || !key->u.tkip.tx_initialized) {
254 /* IV16 wrapped around - perform TKIP phase 1 */
255 tkip_mixing_phase1(ta, &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY],
256 iv32, key->u.tkip.p1k);
257 key->u.tkip.tx_initialized = 1;
258 }
259
260 if (type == IEEE80211_TKIP_P1_KEY) {
261 memcpy(outkey, key->u.tkip.p1k, sizeof(u16) * 5);
262 return;
263 }
264
265 tkip_mixing_phase2(key->u.tkip.p1k,
266 &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY], iv16, outkey);
267}
268EXPORT_SYMBOL(ieee80211_get_tkip_key);
269
217/* Encrypt packet payload with TKIP using @key. @pos is a pointer to the 270/* Encrypt packet payload with TKIP using @key. @pos is a pointer to the
218 * beginning of the buffer containing payload. This payload must include 271 * beginning of the buffer containing payload. This payload must include
219 * headroom of eight octets for IV and Ext. IV and taildroom of four octets 272 * headroom of eight octets for IV and Ext. IV and taildroom of four octets
@@ -238,7 +291,7 @@ void ieee80211_tkip_encrypt_data(struct crypto_blkcipher *tfm,
238int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm, 291int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
239 struct ieee80211_key *key, 292 struct ieee80211_key *key,
240 u8 *payload, size_t payload_len, u8 *ta, 293 u8 *payload, size_t payload_len, u8 *ta,
241 int only_iv, int queue, 294 u8 *ra, int only_iv, int queue,
242 u32 *out_iv32, u16 *out_iv16) 295 u32 *out_iv32, u16 *out_iv16)
243{ 296{
244 u32 iv32; 297 u32 iv32;
@@ -315,6 +368,19 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
315 printk("\n"); 368 printk("\n");
316 } 369 }
317#endif /* CONFIG_TKIP_DEBUG */ 370#endif /* CONFIG_TKIP_DEBUG */
371 if (key->local->ops->update_tkip_key &&
372 key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
373 u8 bcast[ETH_ALEN] =
374 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
375 u8 *sta_addr = key->sta->addr;
376
377 if (is_multicast_ether_addr(ra))
378 sta_addr = bcast;
379
380 key->local->ops->update_tkip_key(
381 local_to_hw(key->local), &key->conf,
382 sta_addr, iv32, key->u.tkip.p1k_rx[queue]);
383 }
318 } 384 }
319 385
320 tkip_mixing_phase2(key->u.tkip.p1k_rx[queue], 386 tkip_mixing_phase2(key->u.tkip.p1k_rx[queue],
diff --git a/net/mac80211/tkip.h b/net/mac80211/tkip.h
index 73d8ef2a93b0..ffaee3253e19 100644
--- a/net/mac80211/tkip.h
+++ b/net/mac80211/tkip.h
@@ -31,7 +31,7 @@ enum {
31int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm, 31int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
32 struct ieee80211_key *key, 32 struct ieee80211_key *key,
33 u8 *payload, size_t payload_len, u8 *ta, 33 u8 *payload, size_t payload_len, u8 *ta,
34 int only_iv, int queue, 34 u8 *ra, int only_iv, int queue,
35 u32 *out_iv32, u16 *out_iv16); 35 u32 *out_iv32, u16 *out_iv16);
36 36
37#endif /* TKIP_H */ 37#endif /* TKIP_H */
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index df0b7341efc8..45709ada8fee 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -312,7 +312,7 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx)
312 res = ieee80211_tkip_decrypt_data(rx->local->wep_rx_tfm, 312 res = ieee80211_tkip_decrypt_data(rx->local->wep_rx_tfm,
313 key, skb->data + hdrlen, 313 key, skb->data + hdrlen,
314 skb->len - hdrlen, rx->sta->addr, 314 skb->len - hdrlen, rx->sta->addr,
315 hwaccel, rx->queue, 315 hdr->addr1, hwaccel, rx->queue,
316 &rx->tkip_iv32, 316 &rx->tkip_iv32,
317 &rx->tkip_iv16); 317 &rx->tkip_iv16);
318 if (res != TKIP_DECRYPT_OK || wpa_test) { 318 if (res != TKIP_DECRYPT_OK || wpa_test) {
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 77336c22fcf2..f3e623df3515 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -33,6 +33,29 @@ int ieee80211_frequency_to_channel(int freq)
33} 33}
34EXPORT_SYMBOL(ieee80211_frequency_to_channel); 34EXPORT_SYMBOL(ieee80211_frequency_to_channel);
35 35
36struct ieee80211_channel *ieee80211_get_channel(struct wiphy *wiphy,
37 int freq)
38{
39 enum ieee80211_band band;
40 struct ieee80211_supported_band *sband;
41 int i;
42
43 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
44 sband = wiphy->bands[band];
45
46 if (!sband)
47 continue;
48
49 for (i = 0; i < sband->n_channels; i++) {
50 if (sband->channels[i].center_freq == freq)
51 return &sband->channels[i];
52 }
53 }
54
55 return NULL;
56}
57EXPORT_SYMBOL(ieee80211_get_channel);
58
36static void set_mandatory_flags_band(struct ieee80211_supported_band *sband, 59static void set_mandatory_flags_band(struct ieee80211_supported_band *sband,
37 enum ieee80211_band band) 60 enum ieee80211_band band)
38{ 61{